/* ==========================================================================
   Glopy · Pantalla 02.1 — Modo Lista
   --------------------------------------------------------------------------
   Escrita SOBRE TOKENS (theme.css), sin colores fijos, salvo los de marca.
   Es la pantalla piloto del modo claro: al no tener ni un color de fondo o de
   texto incrustado, cambia de tema sola con [data-theme] en <html>.

   No declara :root a propósito. Antes cada hoja repetía el suyo y ganaba la
   última que cargara, así que no había forma de cambiar el tema desde un sitio.
   ========================================================================== */

.fl-body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--gl-surface);
    color: var(--gl-text);
    -webkit-font-smoothing: antialiased;
}

.fl-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Cabecera ------------------------------------------------------------------
   Pestañas + botones rotulados Feed/Mapa en una sola fila. Mismo tamaño y
   estilo que .feed-action del feed de swipe (petición de Toni: coherencia). */
/* Mismas medidas que la cabecera del feed de swipe: tokens --gl-head-* en
   theme.css. Antes cada pantalla tenía las suyas y en un iPhone se veían de
   tamaños distintos. */
.fl-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: calc(env(safe-area-inset-top) + var(--gl-head-pad-top)) var(--gl-head-pad-x) var(--gl-head-pad-bottom);
}
.fl-actions { display: flex; align-items: flex-start; gap: var(--gl-head-btn-gap); flex: 0 0 auto; }
.fl-action {
    flex: 0 0 auto;
    box-sizing: border-box;  /* feed_list.css no tiene reset global: sin esto el botón mide 68px, no 54 */
    width: var(--gl-head-btn);
    display: inline-flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px;
    padding: 9px 4px 7px;
    border-radius: var(--gl-head-btn-radius);
    color: var(--gl-text-soft); font-size: var(--gl-head-btn-icon);
    text-decoration: none;
    background: var(--gl-surface-hover);
    border: 1px solid rgba(255, 255, 255, 0.09);
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.fl-action span {
    font-size: var(--gl-head-btn-label); font-weight: 600; line-height: 1;
    color: var(--gl-text);
}
.fl-action:hover,
.fl-action:active {
    color: var(--gl-text);
    background: rgba(58, 130, 247, 0.18);
    border-color: rgba(58, 130, 247, 0.5);
    transform: scale(1.05);
}
.fl-tabs { display: flex; align-items: center; gap: var(--gl-head-tab-gap); min-width: 0; overflow-x: auto; scrollbar-width: none; padding-right: 10px; }
.fl-tabs::-webkit-scrollbar { display: none; }
.fl-tab {
    position: relative; padding: 8px 0 10px;
    color: var(--gl-text-muted);
    font-size: var(--gl-head-tab-size); font-weight: var(--gl-head-tab-weight);
    text-decoration: none; white-space: nowrap;
}
.fl-tab .heart { color: var(--gl-red); }
.fl-tab.is-active { color: var(--gl-text); }
.fl-tab.is-active::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 2px;
    height: 3px; border-radius: 3px; background: var(--gl-blue);
}

.fl-scroll {
    flex: 1 1 auto; overflow-y: auto; overflow-x: hidden;
    padding: 10px 16px 18px;
    -webkit-overflow-scrolling: touch;
}

/* Buscador ----------------------------------------------------------------- */
.fl-search { display: flex; gap: 10px; margin-bottom: 14px; }
.fl-search__box {
    flex: 1 1 auto; min-width: 0;
    display: flex; align-items: center; gap: 10px;
    padding: 0 14px; height: 50px;
    border-radius: 16px;
    background: var(--gl-surface-raised);
    border: 1px solid var(--gl-border);
}
.fl-search__box > i { color: var(--gl-text-muted); font-size: 1.05rem; flex: 0 0 auto; }
.fl-search__box input {
    flex: 1 1 auto; min-width: 0;
    background: none; border: none; outline: none;
    /* 16px floor: below this iOS Safari auto-zooms the whole page on focus. */
    color: var(--gl-text); font: inherit; font-size: 1rem;
}
.fl-search__box input::placeholder { color: var(--gl-text-muted); }
/* El aspa nativa del type=search cambia según el navegador y aquí ya hay un
   botón propio, así que se retira para no tener dos. */
.fl-search__box input::-webkit-search-cancel-button { display: none; }
.fl-search__clear {
    flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--gl-surface-hover); border: none; cursor: pointer;
    color: var(--gl-text-muted); font-size: 0.72rem;
}

/* Contador + orden --------------------------------------------------------- */
.fl-meta {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 14px; position: relative;
}
/* `min-width: 0` no basta: sin `flex: 0 1 auto` el texto no encoge y se mete
   debajo del boton de orden ("...oportunidades" cortado por "Mejor puntuacion"). */
.fl-count {
    font-size: 0.92rem; color: var(--gl-text-soft);
    display: flex; align-items: center; gap: 6px;
    min-width: 0; flex: 0 1 auto;
}
.fl-count b { flex: 0 0 auto; }
.fl-count i { color: var(--gl-blue-soft); }
.fl-count b { color: var(--gl-blue-soft); font-weight: 800; }
.fl-count__txt { min-width: 0; }
.fl-count__zone { color: var(--gl-text); font-weight: 700; text-decoration: none; border-bottom: 1px dashed var(--gl-border-strong); }
.fl-count__zone:hover { color: var(--gl-blue-soft); }

.fl-sort { position: relative; flex: 0 0 auto; }
.fl-sort summary {
    list-style: none; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 13px; border-radius: 12px;
    background: var(--gl-surface-raised);
    border: 1px solid var(--gl-border);
    color: var(--gl-text); font-size: 0.85rem; font-weight: 600; white-space: nowrap;
}
.fl-sort summary::-webkit-details-marker { display: none; }
.fl-sort summary i { color: var(--gl-text-muted); font-size: 0.85rem; transition: transform 0.2s ease; }
.fl-sort[open] summary i:last-child { transform: rotate(180deg); }
.fl-sort__menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
    min-width: 210px; padding: 6px; border-radius: 14px;
    background: var(--gl-surface-raised);
    border: 1px solid var(--gl-border);
    box-shadow: var(--gl-shadow);
}
.fl-sort__opt {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 12px; border-radius: 10px;
    color: var(--gl-text-soft); font-size: 0.88rem; text-decoration: none;
}
.fl-sort__opt:hover { background: var(--gl-surface-hover); }
.fl-sort__opt.is-active { background: rgba(16, 96, 255, 0.16); color: var(--gl-text); }
.fl-sort__opt i { color: var(--gl-blue-soft); }

/* Rejilla de tarjetas ------------------------------------------------------ */
.fl-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    transition: opacity 0.18s ease;
}
/* Filtrado en vivo: la rejilla se atenúa mientras llega la página 1 nueva y
   las tarjetas entrantes suben en cascada. Sin esto el reemplazo era un
   parpadeo seco (queja del cliente: la parte de arriba se sentía estática). */
.fl-grid.is-filtering { opacity: 0.45; pointer-events: none; }
.fl-card--in { animation: fl-card-in 0.38s ease-out both; }
@keyframes fl-card-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .fl-card--in { animation: none; }
    .fl-grid { transition: none; }
}
/* El centinela tiene display:flex propio y .fl-empty ahora vive siempre en el
   DOM: sin esta regla, el atributo hidden perdería contra esas declaraciones. */
.fl-more[hidden], .fl-empty[hidden] { display: none; }
.fl-card {
    display: flex; flex-direction: column;
    min-width: 0;
    border-radius: 18px; overflow: hidden; cursor: pointer;
    background: var(--gl-surface-raised);
    border: 1px solid var(--gl-border);
    transition: border-color 0.18s ease, transform 0.12s ease;
}
.fl-card:hover { border-color: var(--gl-border-strong); }
.fl-card:active { transform: scale(0.99); }

.fl-card__media { position: relative; aspect-ratio: 4 / 3; background: var(--gl-surface-sunken); }
.fl-card__img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Match Score, en el hueco que la maqueta daba al contador de visitas. */
.fl-score {
    position: absolute; left: 8px; bottom: 8px; z-index: 2;
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 9px; border-radius: 999px;
    background: var(--gl-chip-bg);
    backdrop-filter: blur(6px);
    border: 1px solid var(--ring);
    color: var(--gl-chip-text);
    font-size: 0.74rem; font-weight: 800; line-height: 1;
}
.fl-score b { color: var(--ring); font-weight: 900; }
.fl-score::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ring);
}

.fl-fav {
    position: absolute; top: 8px; right: 8px; z-index: 2;
    width: 34px; height: 34px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--gl-chip-bg);
    backdrop-filter: blur(6px);
    border: 1px solid var(--gl-border);
    color: var(--gl-chip-text); font-size: 0.95rem; cursor: pointer;
    transition: transform 0.12s ease;
}
.fl-fav.is-active { color: var(--gl-red); }
.fl-fav:active { transform: scale(0.85); }

/* Chapa destacada. Sólo una por tarjeta, arriba a la izquierda de la foto. */
.fl-badge {
    position: absolute; top: 8px; left: 8px; z-index: 2;
    padding: 4px 10px; border-radius: 8px;
    font-size: 0.7rem; font-weight: 800; line-height: 1.4;
    color: #fff;                      /* siempre sobre color de marca */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.fl-badge--blue { background: var(--gl-blue); }
.fl-badge--green { background: var(--gl-green); color: #04210f; }
.fl-badge--violet { background: var(--gl-violet); color: #1b0733; }

/* Portal de origen, dentro del cuerpo de la tarjeta. El logo llena su
   cuadrado, sin marco blanco ni margen (cliente, 20/10/2026, T20 puntos 4-5):
   los favicons de los portales ya traen su propio color de fondo. */
.fl-provider {
    display: flex; align-items: center; gap: 6px;
    margin-top: 9px; padding-top: 9px;
    border-top: 1px solid var(--gl-border);
    color: var(--gl-text-muted); font-size: 0.75rem; font-weight: 700;
    min-width: 0;
}
.fl-provider img {
    width: 18px; height: 18px; flex: 0 0 auto;
    object-fit: cover; border-radius: 4px;
}
/* Logos oficiales en pastilla (coches.net, coches.com): anchos, no cuadrados. */
.fl-provider img[src*="/LOGOS/portales/"] { width: auto; max-width: 76px; object-fit: contain; }
.fl-provider span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fl-card__body { display: flex; flex-direction: column; padding: 11px 12px 13px; min-width: 0; }
.fl-price { font-size: 1.18rem; font-weight: 800; letter-spacing: -0.02em; color: var(--gl-text); }
.fl-title {
    margin: 3px 0 5px; font-size: 0.88rem; font-weight: 600; line-height: 1.3;
    color: var(--gl-text);
    /* Dos líneas como máximo: los títulos scrapeados llegan larguísimos y sin
       tope descuadran la rejilla. */
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}
.fl-loc {
    font-size: 0.79rem; color: var(--gl-blue-soft);
    display: flex; align-items: center; gap: 5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fl-loc i { font-size: 0.75rem; flex: 0 0 auto; }
.fl-specs {
    display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 9px;
    color: var(--gl-text-muted); font-size: 0.75rem;
}
.fl-specs span { display: inline-flex; align-items: center; gap: 4px; }
.fl-specs i { font-size: 0.75rem; }

/* Cargar más (scroll infinito) --------------------------------------------- */
.fl-more { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 0 8px; }
.fl-more__spin {
    display: none; width: 26px; height: 26px; border-radius: 50%;
    border: 2.5px solid var(--gl-border-strong); border-top-color: var(--gl-blue-soft);
    animation: fl-spin 0.75s linear infinite;
}
.fl-more__btn {
    padding: 11px 22px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--gl-border-strong); background: var(--gl-surface-hover);
    color: var(--gl-text); font: inherit; font-weight: 700; font-size: 0.92rem;
}
.fl-more__btn:hover { background: var(--gl-surface-raised); }
/* Mientras carga mostramos el spinner y ocultamos el botón, para que el
   observer y el clic manual no compitan por la misma página. */
.fl-more.is-loading .fl-more__spin { display: block; }
.fl-more.is-loading .fl-more__btn { display: none; }
@keyframes fl-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .fl-more__spin { animation: none; } }

/* Sin resultados ----------------------------------------------------------- */
.fl-empty { text-align: center; padding: 50px 24px; }
.fl-empty img { width: 84px; height: 84px; object-fit: contain; opacity: 0.85; margin-bottom: 8px; }
.fl-empty h3 { margin: 0 0 6px; font-size: 1.15rem; font-weight: 800; color: var(--gl-text); }
.fl-empty p { margin: 0 0 14px; color: var(--gl-text-muted); font-size: 0.9rem; }
.fl-empty a { color: var(--gl-blue-soft); font-weight: 700; text-decoration: none; }
.fl-empty__hint { color: var(--gl-text); font-weight: 600; }
.fl-empty__switch {
    display: inline-block; margin: 0 0 16px; padding: 12px 20px; border: 0; border-radius: 999px;
    background: var(--gl-blue); color: #fff; font: inherit; font-weight: 700; cursor: pointer;
}
.fl-empty__switch:disabled { opacity: 0.6; cursor: default; }
/* display:inline-block le ganaba al atributo hidden: salía una píldora vacía. */
.fl-empty__switch[hidden], .fl-empty__hint[hidden] { display: none; }

/* Toast -------------------------------------------------------------------- */
.fl-toast {
    position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px);
    z-index: 1200; max-width: 90%;
    padding: 12px 18px; border-radius: 14px;
    background: var(--gl-surface-raised); border: 1px solid var(--gl-border);
    box-shadow: var(--gl-shadow);
    color: var(--gl-text); font-size: 0.88rem; font-weight: 600;
    opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
}
.fl-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Móviles estrechos: una sola columna, si no las tarjetas quedan ilegibles. */
@media (max-width: 359px) {
    .fl-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Escritorio: se aprovecha el ancho del marco compartido con una columna más. */
@media (min-width: 900px) {
    .fl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
    .fl-price { font-size: 1.24rem; }
}

/* Cuando el anuncio no tiene NINGUN dato de superficie (garajes, habitaciones
   y traspasos de wallapop no los publican), se dice asi en vez de dejar la
   fila vacia o pintar "None m²". */
.fl-specs__none { color: var(--gl-text-muted); font-style: italic; }

/* ==========================================================================
   ESCRITORIO (>=1024px) — maqueta del cliente.
   La lista deja de ser un movil centrado: cabecera ancha, buscador grande,
   par Feed/Mapa como control segmentado y rejilla de 4 columnas.
   Todo cuelga de .gl-shell--full, que solo lleva esta pantalla, y ademas va
   dentro de media queries de ancho: el movil queda intacto.
   ========================================================================== */
@media (min-width: 1024px) {
    /* Cabecera ------------------------------------------------------------- */
    .gl-shell--full .fl-header {
        padding: 24px 32px 12px;
        gap: 24px;
    }
    .gl-shell--full .fl-tabs { gap: 40px; overflow: visible; padding-right: 0; }
    .gl-shell--full .fl-tab { font-size: 1.3rem; padding: 6px 0 12px; }
    .gl-shell--full .fl-tab.is-active::after { height: 4px; bottom: 0; }

    /* Feed / Mapa: control segmentado (dos botones dentro de una caja). */
    .gl-shell--full .fl-actions {
        gap: 4px;
        padding: 5px;
        border-radius: 16px;
        background: var(--gl-surface-raised);
        border: 1px solid var(--gl-border);
        align-items: center;
    }
    .gl-shell--full .fl-action {
        width: auto;
        flex-direction: row;
        gap: 10px;
        padding: 11px 22px;
        border-radius: 12px;
        border: 1px solid transparent;
        background: none;
        font-size: 1.15rem;
    }
    .gl-shell--full .fl-action span { font-size: 1rem; }
    .gl-shell--full .fl-action:hover,
    .gl-shell--full .fl-action:active {
        transform: none;
        background: var(--gl-surface-hover);
        border-color: transparent;
    }
    .gl-shell--full .fl-action.is-current {
        background: rgba(16, 96, 255, 0.16);
        border-color: var(--gl-blue);
        color: var(--gl-text);
    }

    /* Buscador ------------------------------------------------------------- */
    .gl-shell--full .fl-scroll { padding: 14px 32px 28px; }
    .gl-shell--full .fl-search { gap: 18px; margin-bottom: 22px; }
    .gl-shell--full .fl-search__box {
        height: 66px;
        padding: 0 22px;
        gap: 14px;
        border-radius: 18px;
    }
    .gl-shell--full .fl-search__box > i { font-size: 1.35rem; }
    .gl-shell--full .fl-search__box input { font-size: 1.1rem; }

    /* Contador + orden ------------------------------------------------------ */
    .gl-shell--full .fl-meta { margin-bottom: 20px; }
    .gl-shell--full .fl-count { font-size: 1.05rem; gap: 9px; }
    .gl-shell--full .fl-count i { font-size: 1.25rem; }
    .gl-shell--full .fl-count b { font-size: 1.2rem; }
    .gl-shell--full .fl-sort summary {
        min-width: 250px;
        justify-content: space-between;
        padding: 14px 20px;
        border-radius: 14px;
        font-size: 1rem;
    }
    .gl-shell--full .fl-sort summary i { font-size: 1rem; }
    .gl-shell--full .fl-sort__menu { min-width: 250px; }
    .gl-shell--full .fl-sort__opt { font-size: 0.95rem; padding: 12px 14px; }

    /* Tarjetas -------------------------------------------------------------- */
    .gl-shell--full .fl-grid { gap: 18px; }
    .gl-shell--full .fl-card { border-radius: 16px; }
    /* La foto manda mas que en movil: la maqueta la deja casi cuadrada. */
    .gl-shell--full .fl-card__media { aspect-ratio: 6 / 5; }
    .gl-shell--full .fl-card__body { padding: 16px 16px 18px; }
    .gl-shell--full .fl-price { font-size: 1.75rem; }
    .gl-shell--full .fl-title { margin: 6px 0 8px; font-size: 1.08rem; line-height: 1.35; }
    .gl-shell--full .fl-loc { font-size: 0.95rem; gap: 7px; }
    .gl-shell--full .fl-loc i { font-size: 0.9rem; }
    .gl-shell--full .fl-specs { margin-top: 12px; font-size: 0.88rem; gap: 6px 14px; }
    .gl-shell--full .fl-specs i { font-size: 0.88rem; }
    .gl-shell--full .fl-provider {
        margin-top: 13px; padding-top: 13px;
        font-size: 0.88rem; gap: 9px;
    }
    .gl-shell--full .fl-provider img { width: 24px; height: 24px; border-radius: 6px; }

    .gl-shell--full .fl-fav {
        top: 12px; right: 12px;
        width: 42px; height: 42px;
        font-size: 1.15rem;
    }
    .gl-shell--full .fl-badge {
        top: 12px; left: 12px;
        padding: 6px 13px; border-radius: 9px;
        font-size: 0.82rem;
    }
    .gl-shell--full .fl-score {
        left: 12px; bottom: 12px;
        padding: 6px 12px;
        font-size: 0.88rem;
    }

    /* Sin barra inferior en escritorio: el aviso no tiene que esquivarla. */
    .gl-shell--full ~ .fl-toast,
    .fl-toast { bottom: 32px; }
}

/* Cuatro columnas desde 1200px, como la maqueta. */
@media (min-width: 1200px) {
    .gl-shell--full .fl-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ==========================================================================
   Barra de prefiltros + hojas inferiores (peticion del cliente, sep 2026)
   ========================================================================== */

/* El buscador ocupa todo el ancho (fuera el boton cuadrado de Filtros). */
.fl-search { margin-bottom: 10px; }

/* Chips: fila desplazable horizontal, sin barra visible. Sangra hasta los
   bordes de la pantalla (margenes negativos) para que el primer y el ultimo
   chip no queden pegados al borde ni recortados por el padding del scroll. */
.fl-chips {
    display: flex; gap: 8px;
    /* 6 px arriba y abajo DENTRO del scroll (y margen negativo para que no se
       mueva nada): el anillo de foco del chip (2 px + 2 px de separación) y
       el de «Filtros» abierto (3 px) se pintan fuera del chip y con 2 px de
       hueco el overflow los recortaba; en iOS, al volver de Filtros, el chip
       queda enfocado y el cliente veía el marco «comido» (19 oct 2026). */
    margin: -4px -16px 8px; padding: 6px 16px 10px;
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    scroll-padding: 0 16px;
}
.fl-chips::-webkit-scrollbar { display: none; }
.fl-chip {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; gap: 7px;
    height: 44px; padding: 0 14px;               /* objetivo táctil mínimo (checklist del cliente) */
    border-radius: 12px;
    background: var(--gl-surface-raised);
    border: 1px solid var(--gl-border);
    color: var(--gl-text); font: inherit; font-size: 0.92rem; font-weight: 600;
    white-space: nowrap; cursor: pointer; text-decoration: none;
    scroll-snap-align: start;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.fl-chip > i:first-child { font-size: 1rem; color: var(--gl-text-soft); }
.fl-chip__chev { font-size: 0.72rem; color: var(--gl-text-muted); margin-left: -2px; }
.fl-chip:hover { border-color: var(--gl-border-strong); }
/* Activo (valor puesto) y abierto (hoja desplegada): azul, como la maqueta. */
.fl-chip.is-active, .fl-chip.is-open {
    background: rgba(16, 96, 255, 0.16);
    border-color: var(--gl-blue);
    color: #fff;
}
.fl-chip.is-active > i:first-child, .fl-chip.is-open > i:first-child,
.fl-chip.is-active .fl-chip__chev, .fl-chip.is-open .fl-chip__chev { color: var(--gl-blue-soft); }
.fl-chip:focus-visible { outline: 2px solid rgba(61, 134, 255, 0.8); outline-offset: 2px; }
/* "Filtros" (revisión del cliente, 17 sep 2026, imagen 10): recuadro azul
   —fondo oscuro, borde y texto azules—, no relleno sólido. */
.fl-chip--primary, .fl-chip--primary.is-active, .fl-chip--primary.is-open {
    background: rgba(16, 96, 255, 0.16);
    border-color: var(--gl-blue);
    color: var(--gl-blue-soft);
}
.fl-chip--primary > i:first-child, .fl-chip--primary.is-active > i:first-child, .fl-chip--primary.is-open > i:first-child { color: var(--gl-blue-soft); }
.fl-chip--primary:hover { background: rgba(16, 96, 255, 0.24); }
.fl-chip--primary.is-open { box-shadow: 0 0 0 3px rgba(61, 134, 255, 0.35); }
/* Hoja "Filtros": todas las secciones seguidas, cada una con su titulo. */
.fl-sheet__body--all .fl-pane { padding: 6px 0 18px; border-bottom: 1px solid var(--gl-border); margin-bottom: 8px; }
.fl-sheet__body--all .fl-pane:last-child { border-bottom: 0; margin-bottom: 0; }
.fl-sheet__body--all .fl-pane::before {
    content: attr(data-title); display: block;
    margin: 6px 0 10px; font-size: 1.05rem; font-weight: 800; color: var(--gl-text);
}
.fl-sheet__body--all .fl-pane > .fl-pane__label:first-of-type { display: none; }

/* Hoja inferior ----------------------------------------------------------- */
.fl-sheet { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.fl-sheet[hidden] { display: none; }
.fl-sheet__backdrop {
    position: absolute; inset: 0;
    background: rgba(3, 6, 14, 0.55);
    opacity: 0; transition: opacity 0.28s ease;
}
.fl-sheet.is-open .fl-sheet__backdrop { opacity: 1; }
.fl-sheet__panel {
    position: relative; z-index: 2;
    width: 100%;
    /* Altura = la que pida el contenido; tope para que Extras / Tipo / Mas
       filtros hagan scroll interno en vez de comerse la pantalla. */
    max-height: 86dvh;
    display: flex; flex-direction: column;
    background: var(--gl-card-2, #0f1727);
    border: 1px solid var(--gl-border); border-bottom: 0;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.45);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
    padding-bottom: env(safe-area-inset-bottom);
}
.fl-sheet.is-open .fl-sheet__panel { transform: translateY(0); }
.fl-sheet__handle { display: flex; justify-content: center; padding: 10px 0 4px; touch-action: none; cursor: grab; }
.fl-sheet__handle span { width: 44px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.28); }
.fl-sheet__head { position: relative; display: flex; align-items: center; justify-content: center; padding: 6px 60px 12px; }
.fl-sheet__title { margin: 0; font-size: 1.25rem; font-weight: 800; }
.fl-sheet__close {
    position: absolute; left: 14px; top: 0;
    width: 40px; height: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--gl-surface-hover); border: 1px solid var(--gl-border);
    color: var(--gl-text); font-size: 1.05rem; cursor: pointer;
}
.fl-sheet__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 20px 16px; -webkit-overflow-scrolling: touch; }
.fl-sheet__foot {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 14px;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--gl-border);
    background: var(--gl-card-2, #0f1727);
}
.fl-sheet__clear {
    flex: 0 0 auto; padding: 12px 10px;
    background: none; border: 0; color: var(--gl-blue-soft);
    font: inherit; font-size: 1.05rem; font-weight: 700; cursor: pointer;
}
.fl-sheet__apply {
    flex: 1 1 auto; height: 54px;
    border: 0; border-radius: 16px;
    background: linear-gradient(180deg, var(--gl-blue-soft) 0%, var(--gl-blue) 100%);
    color: #fff; font: inherit; font-size: 1.05rem; font-weight: 800; cursor: pointer;
    box-shadow: 0 10px 26px rgba(16, 96, 255, 0.4);
    transition: opacity 0.15s ease, transform 0.12s ease;
}
.fl-sheet__apply:active { transform: translateY(1px); }
.fl-sheet__apply:disabled { opacity: 0.6; cursor: default; }
.fl-sheet__apply.is-counting { opacity: 0.85; }

/* Mientras la hoja esta abierta, la pagina de detras no hace scroll. */
html.fl-sheet-open, html.fl-sheet-open body { overflow: hidden; }

/* Contenido de las hojas --------------------------------------------------- */
.fl-pane__label { margin: 8px 0 10px; font-size: 1rem; font-weight: 600; color: var(--gl-text); display: flex; align-items: center; gap: 8px; }
.fl-pane__label i { color: var(--gl-blue-soft); }
.fl-pane__note { margin: 6px 2px 0; font-size: 0.8rem; color: var(--gl-text-muted); }
.fl-pane__link { display: inline-flex; align-items: center; gap: 8px; margin: 6px 0 4px; color: var(--gl-blue-soft); font-weight: 700; text-decoration: none; }
.fl-group + .fl-group { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--gl-border); }

/* Segmento (Todo / 1+ / 2+ …) */
.fl-seg {
    display: flex; padding: 4px; border-radius: 14px;
    background: rgba(255, 255, 255, 0.04); border: 1px solid var(--gl-border);
}
.fl-seg__opt {
    flex: 1 1 0; padding: 13px 4px; border: 0; border-radius: 11px;
    background: none; color: var(--gl-text); font: inherit; font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease;
}
.fl-seg__opt + .fl-seg__opt { border-left: 1px solid var(--gl-border); }
.fl-seg__opt.is-active { background: var(--gl-blue); color: #fff; box-shadow: 0 6px 16px rgba(16, 96, 255, 0.35); border-color: transparent; }
.fl-seg__opt.is-active + .fl-seg__opt { border-left-color: transparent; }

/* Interruptor (numero exacto) */
.fl-toggle { display: flex; align-items: center; gap: 12px; margin: 16px 2px 4px; cursor: pointer; font-size: 1rem; }
.fl-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.fl-toggle__track { position: relative; width: 50px; height: 30px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); flex: none; transition: background 0.2s ease; }
.fl-toggle__knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s ease; }
.fl-toggle input:checked + .fl-toggle__track { background: var(--gl-blue); }
.fl-toggle input:checked + .fl-toggle__track .fl-toggle__knob { transform: translateX(20px); }
.fl-toggle input:focus-visible + .fl-toggle__track { outline: 2px solid rgba(61, 134, 255, 0.8); outline-offset: 2px; }

/* Dos campos en fila + desplegable */
.fl-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fl-field { display: flex; flex-direction: column; gap: 8px; font-size: 0.95rem; color: var(--gl-text-soft); }
.fl-select { position: relative; display: block; }
.fl-select select {
    width: 100%; height: 52px; padding: 0 40px 0 14px;
    border-radius: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--gl-border);
    color: var(--gl-text); font: inherit; font-size: 1rem;
    appearance: none; -webkit-appearance: none; cursor: pointer;
}
.fl-select select:focus { outline: 0; border-color: var(--gl-blue); }
.fl-select option { color: var(--gl-text); background: #0f1727; }
.fl-select > i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--gl-blue-soft); font-size: 0.9rem; }

/* Slider doble de precio */
.fl-range { position: relative; height: 32px; margin: 18px 10px 2px; }
.fl-range__track { position: absolute; left: 0; right: 0; top: 14px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.14); }
.fl-range__fill { position: absolute; top: 14px; height: 4px; border-radius: 2px; background: var(--gl-blue); }
.fl-range__in {
    position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 32px; margin: 0;
    background: none; -webkit-appearance: none; appearance: none; pointer-events: none;
}
.fl-range__in::-webkit-slider-runnable-track { height: 32px; background: transparent; }
.fl-range__in::-webkit-slider-thumb {
    -webkit-appearance: none; pointer-events: auto;
    width: 24px; height: 24px; margin-top: 4px; border-radius: 50%;
    background: #fff; border: 3px solid var(--gl-blue); box-shadow: 0 2px 10px rgba(16, 96, 255, 0.5); cursor: pointer;
}
.fl-range__in::-moz-range-track { height: 32px; background: transparent; }
.fl-range__in::-moz-range-thumb { pointer-events: auto; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--gl-blue); cursor: pointer; }
.fl-range__legend { display: flex; justify-content: space-between; margin: 0 2px; font-size: 0.82rem; color: var(--gl-text-muted); }

/* Fichas (extras, tipo) y pildoras (mas filtros) */
.fl-tiles { display: grid; gap: 12px; }
.fl-tiles--2 { grid-template-columns: 1fr 1fr; }
.fl-tile {
    display: flex; align-items: center; gap: 12px;
    min-height: 58px; padding: 6px 10px 6px 12px; gap: 10px;
    border-radius: 14px; background: rgba(255, 255, 255, 0.03); border: 1.5px solid var(--gl-border);
    color: var(--gl-text); font: inherit; font-size: 0.92rem; font-weight: 600; text-align: left; cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.fl-tile i { font-size: 1.3rem; color: var(--gl-text-soft); flex: none; width: 1.35rem; text-align: center; }
/* Se parte por palabras ("Aire / acondicionado"), nunca por letras. */
.fl-tile span { min-width: 0; overflow-wrap: normal; line-height: 1.2; }
.fl-tile.is-active { border-color: var(--gl-blue); background: rgba(16, 96, 255, 0.16); color: #fff; }
.fl-tile.is-active i { color: var(--gl-blue-soft); }
.fl-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.fl-pill {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 10px 14px; border-radius: 999px;
    background: rgba(255, 255, 255, 0.04); border: 1px solid var(--gl-border);
    color: var(--gl-text); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.fl-pill.is-active { border-color: var(--gl-blue); background: rgba(16, 96, 255, 0.16); color: #fff; }
.fl-pill__dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

@media (prefers-reduced-motion: reduce) {
    .fl-sheet__panel, .fl-sheet__backdrop, .fl-chip, .fl-seg__opt, .fl-tile { transition: none !important; }
}

/* Escritorio: los chips caben sin scroll y la hoja pasa a ser un dialogo
   centrado (una tira pegada al pie de un monitor no tiene sentido). */
@media (min-width: 1024px) {
    .gl-shell--full .fl-chips { margin: 0 0 18px; padding: 2px 0 4px; gap: 10px; overflow: visible; flex-wrap: wrap; }
    .gl-shell--full .fl-chip { height: 46px; padding: 0 18px; font-size: 1rem; }
    .fl-sheet { align-items: center; }
    .fl-sheet__panel {
        width: min(600px, calc(100vw - 48px));
        max-height: 82vh;
        border-radius: 22px; border-bottom: 1px solid var(--gl-border);
        transform: translateY(18px) scale(0.98); opacity: 0;
        transition: transform 0.25s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.2s ease;
        padding-bottom: 0;
    }
    .fl-sheet.is-open .fl-sheet__panel { transform: none; opacity: 1; }
    .fl-sheet__handle { display: none; }
    .fl-sheet__head { padding-top: 22px; }
    .fl-sheet__close { top: 16px; }
    .fl-sheet__body { padding: 4px 26px 18px; }
    .fl-sheet__foot { padding: 14px 26px 20px; border-radius: 0 0 22px 22px; }
}

/* Bloque superior del listado en móvil (cliente, 07/10/2026, como Fotocasa):
   pegado arriba del scroll, se esconde al bajar y vuelve al subir un poco.
   feed_list.js pone/quita .is-hidden. En escritorio no cambia. */
@media (max-width: 899px) {
    /* El relleno superior del scroll lo pone la propia barra: con el relleno
       en el scroll, al volver a subir las tarjetas asomaban por esa franja
       de 10 px entre las pestañas y el buscador (cliente, punto 12, oct 2026). */
    .fl-scroll { padding-top: 0; }
    .fl-top {
        position: sticky; top: 0; z-index: 20;
        margin: 0 -16px 0; padding: 10px 16px 10px;
        background: var(--gl-bg);
        transition: transform 0.22s ease;
    }
    .fl-top.is-hidden { transform: translateY(-100%); transition-duration: 0.18s; }
    .fl-top .fl-chips { margin-bottom: 8px; }
    /* Dentro de la barra el margen inferior de la fila del contador se
       colapsaba fuera del bloque pegajoso y las tarjetas se cortaban a ras
       del botón de orden: ahora el aire lo da el relleno de la barra. */
    .fl-top .fl-meta { margin-bottom: 4px; }
}

/* ===== Tema claro (punto 17) =====
Modo Lista, barra de filtros rápidos y sus hojas en tema claro.
   ========================================================================== */

:root[data-theme="light"] .fl-action { background: #fff; border-color: rgba(15, 23, 42, 0.10); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05); }
:root[data-theme="light"] .fl-action:hover, :root[data-theme="light"] .fl-action:active { background: rgba(16, 96, 255, 0.07); border-color: rgba(16, 96, 255, 0.35); color: var(--gl-blue); }
:root[data-theme="light"] .fl-sort__opt.is-active { background: rgba(16, 96, 255, 0.07); color: var(--gl-blue); }
:root[data-theme="light"] .fl-score, :root[data-theme="light"] .fl-fav { box-shadow: 0 1px 4px rgba(15, 23, 42, 0.14); }
:root[data-theme="light"] .fl-badge { box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16); }
:root[data-theme="light"] .fl-provider img { box-shadow: none; }
@media (min-width: 1024px) {
    :root[data-theme="light"] .gl-shell--full .fl-action.is-current { background: rgba(16, 96, 255, 0.07); color: var(--gl-blue); }
}

/* Barra de filtros rápidos y hojas inferiores */
:root[data-theme="light"] .fl-chip { background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04); }
:root[data-theme="light"] .fl-chip.is-active, :root[data-theme="light"] .fl-chip.is-open { background: rgba(16, 96, 255, 0.07); color: var(--gl-blue); border-color: rgba(16, 96, 255, 0.45); }
:root[data-theme="light"] .fl-chip--primary, :root[data-theme="light"] .fl-chip--primary.is-active, :root[data-theme="light"] .fl-chip--primary.is-open { background: rgba(16, 96, 255, 0.07); color: var(--gl-blue); }
:root[data-theme="light"] .fl-chip--primary:hover { background: rgba(16, 96, 255, 0.12); }
:root[data-theme="light"] .fl-chip--primary.is-open { box-shadow: 0 0 0 3px rgba(16, 96, 255, 0.16); }
:root[data-theme="light"] .fl-sheet__backdrop { background: rgba(15, 23, 42, 0.38); }
:root[data-theme="light"] .fl-sheet__panel { box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.14); }
:root[data-theme="light"] .fl-sheet__handle span { background: rgba(15, 23, 42, 0.16); }
:root[data-theme="light"] .fl-sheet__foot { border-top-color: var(--gl-border); }
:root[data-theme="light"] .fl-sheet__apply { box-shadow: 0 8px 20px rgba(16, 96, 255, 0.26); }
:root[data-theme="light"] .fl-seg { background: var(--gl-surface-sunken); }
:root[data-theme="light"] .fl-seg__opt.is-active { box-shadow: 0 4px 12px rgba(16, 96, 255, 0.25); }
:root[data-theme="light"] .fl-toggle__track { background: rgba(15, 23, 42, 0.12); }
:root[data-theme="light"] .fl-toggle__knob { box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25); }
:root[data-theme="light"] .fl-select select { background: #fff; }
:root[data-theme="light"] .fl-select option { background: #fff; }
:root[data-theme="light"] .fl-range__track { background: rgba(15, 23, 42, 0.12); }
:root[data-theme="light"] .fl-range__in::-webkit-slider-thumb { box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2); }
:root[data-theme="light"] .fl-tile, :root[data-theme="light"] .fl-pill { background: #fff; }
:root[data-theme="light"] .fl-tile.is-active, :root[data-theme="light"] .fl-pill.is-active { background: rgba(16, 96, 255, 0.07); color: var(--gl-blue); }
:root[data-theme="light"] .fl-tile.is-active i { color: var(--gl-blue); }

/* Escritorio: los logos oficiales en pastilla siguen anchos (la regla de 24px de arriba no los aplasta). */
@media (min-width: 1024px) {
    .gl-shell--full .fl-provider img[src*="/LOGOS/portales/"] { width: auto; max-width: 100px; height: 24px; }
}
