/* ==========================================================================
   KFotos — hoja de estilos de la aplicación.

   Dos temas. theme.js pone data-theme="light|dark" en <html> antes del primer pintado,
   así que aquí basta con dos juegos de variables y ninguna regla duplicada.

   Los elementos que se superponen a las fotos (insignias, check de selección, barra del
   visor) mantienen fondos oscuros en los dos temas: van sobre imágenes, no sobre el
   fondo de la página, y un scrim claro sobre una foto clara no se lee.
   ========================================================================== */

:root,
:root[data-theme="light"] {
    --kf-bg: #ffffff;
    --kf-bg-2: #f3f4f7;
    --kf-bg-3: #e6e8ed;
    --kf-line: #d6dae1;
    --kf-text: #16181d;
    --kf-muted: #5c6472;
    --kf-accent: #1a5fd0;
    --kf-danger: #c62f28;
    --kf-warn: #8a6414;
    --kf-warn-bg: #ffe9a8;

    --kf-nav-bg: rgba(255, 255, 255, .9);
    --kf-shimmer-a: #eceef2;
    --kf-shimmer-b: #dfe2e8;
    --kf-failed-bg: #fbe3e1;
    --kf-failed-fg: #a3251f;
    --kf-error-bg: #fdecea;
    --kf-error-line: #f3c4bf;
    --kf-error-fg: #8c211b;
    --kf-pill-work-bg: #dbe7fb;
    --kf-pill-work-fg: #1a4f9e;
    --kf-pill-error-bg: #fbdedb;
    --kf-pill-error-fg: #8c211b;

    /* Fondo del visor: casi blanco, pero no blanco puro, para que una foto con fondo
       claro siga teniendo borde visible. */
    /* El visor es oscuro en los dos temas: una foto se ve mejor sobre negro, y un fondo
       claro deslumbra y le roba contraste. Mismos valores que en el tema oscuro. */
    --kf-lb-bg: rgba(8, 9, 12, .97);
    --kf-lb-fg: #e8eaef;
    --kf-lb-scrim: rgba(0, 0, 0, .75);
    --kf-lb-hover: rgba(255, 255, 255, .12);
    --kf-lb-nav-bg: rgba(255, 255, 255, .07);
    --kf-lb-nav-hover: rgba(255, 255, 255, .18);
    --kf-fav: #ffd76e;

    --kf-radius: 10px;
    --kf-nav-h: 56px;
    --kf-tabbar-h: 56px;
    --kf-lb-bar-h: 52px;
}

:root[data-theme="dark"] {
    --kf-bg: #0f1115;
    --kf-bg-2: #171a21;
    --kf-bg-3: #21252e;
    --kf-line: #2c313c;
    --kf-text: #e8eaef;
    --kf-muted: #9aa2b1;
    --kf-accent: #4c8dff;
    --kf-danger: #e5534b;
    --kf-warn: #d2a53c;
    --kf-warn-bg: #d2a53c;

    --kf-nav-bg: rgba(15, 17, 21, .92);
    --kf-shimmer-a: #171a21;
    --kf-shimmer-b: #21252e;
    --kf-failed-bg: #3a1e1c;
    --kf-failed-fg: #ffb3ae;
    --kf-error-bg: #3a1e1c;
    --kf-error-line: #5c2f2b;
    --kf-error-fg: #ffc9c5;
    --kf-pill-work-bg: #2b3b56;
    --kf-pill-work-fg: #a9c8ff;
    --kf-pill-error-bg: #4a2422;
    --kf-pill-error-fg: #ffb3ae;

    --kf-lb-bg: rgba(8, 9, 12, .97);
    --kf-lb-fg: #e8eaef;
    --kf-lb-scrim: rgba(0, 0, 0, .75);
    --kf-lb-hover: rgba(255, 255, 255, .12);
    --kf-lb-nav-bg: rgba(255, 255, 255, .07);
    --kf-lb-nav-hover: rgba(255, 255, 255, .18);
    --kf-fav: #ffd76e;
}

/* Sin JavaScript (o si falla), se respeta la preferencia del sistema. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --kf-bg: #0f1115;
        --kf-bg-2: #171a21;
        --kf-bg-3: #21252e;
        --kf-line: #2c313c;
        --kf-text: #e8eaef;
        --kf-muted: #9aa2b1;
        --kf-accent: #4c8dff;
        --kf-nav-bg: rgba(15, 17, 21, .92);
        --kf-shimmer-a: #171a21;
        --kf-shimmer-b: #21252e;
        --kf-lb-bg: rgba(8, 9, 12, .97);
        --kf-lb-fg: #e8eaef;
        --kf-lb-scrim: rgba(0, 0, 0, .75);
        --kf-lb-hover: rgba(255, 255, 255, .12);
        --kf-lb-nav-bg: rgba(255, 255, 255, .07);
        --kf-lb-nav-hover: rgba(255, 255, 255, .18);
        --kf-fav: #ffd76e;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--kf-bg);
    color: var(--kf-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--kf-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.4rem; font-weight: 600; margin: 0; }

/* ---------- Navegación ---------- */

.kf-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--kf-nav-h);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0 1rem;
    background: var(--kf-nav-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--kf-line);
}

.kf-nav-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--kf-text);
    flex-shrink: 0;
}
.kf-nav-brand:hover { text-decoration: none; }
.kf-nav-logo { color: var(--kf-accent); font-size: 1.2rem; }

.kf-nav-links { display: flex; gap: .25rem; overflow-x: auto; }
.kf-nav-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.kf-nav-link {
    display: inline-block;
    padding: .4rem .7rem;
    border-radius: 8px;
    color: var(--kf-muted);
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.kf-nav-link:hover { background: var(--kf-bg-3); color: var(--kf-text); text-decoration: none; }
.kf-nav-link.active { background: var(--kf-bg-3); color: var(--kf-text); }

.kf-nav-cta {
    padding: .4rem .9rem;
    border-radius: 8px;
    background: var(--kf-accent);
    color: #fff;
    font-weight: 500;
    white-space: nowrap;
}
.kf-nav-cta:hover { text-decoration: none; filter: brightness(1.1); }

.kf-nav-user {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .5rem;
    border-radius: 8px;
    color: var(--kf-muted);
    font-size: .85rem;
}
.kf-nav-user:hover { background: var(--kf-bg-3); color: var(--kf-text); text-decoration: none; }
.kf-nav-user .kf-icon { width: 18px; height: 18px; flex-shrink: 0; }
.kf-nav-user-name {
    max-width: 16ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kf-nav-logout { margin: 0; display: flex; }

.kf-main { padding: 1rem; max-width: 2200px; margin: 0 auto; }

/* ---------- Arranque de WebAssembly ---------- */

.kf-boot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    min-height: 40vh;
    color: var(--kf-muted);
    /* Aparece con retraso: si el runtime ya está en caché, no da tiempo a verlo parpadear. */
    opacity: 0;
    animation: kf-fade-in .2s ease-out .35s forwards;
}
.kf-boot:not(:only-child) { display: none; }

.kf-boot-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--kf-line);
    border-top-color: var(--kf-accent);
    border-radius: 50%;
    animation: kf-spin .8s linear infinite;
}

@keyframes kf-spin { to { transform: rotate(360deg); } }
@keyframes kf-fade-in { to { opacity: 1; } }

/* ---------- Cabecera de página ---------- */

.kf-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.kf-header-main { display: flex; flex-direction: column; gap: .2rem; }
.kf-header-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.kf-muted { color: var(--kf-muted); font-size: .85rem; }
.kf-break { word-break: break-all; }

.kf-pill {
    display: inline-block;
    margin-left: .4rem;
    padding: .1rem .5rem;
    border-radius: 999px;
    background: var(--kf-bg-3);
    font-size: .75rem;
}
.kf-pill-work { background: var(--kf-pill-work-bg); color: var(--kf-pill-work-fg); }
.kf-pill-error { background: var(--kf-pill-error-bg); color: var(--kf-pill-error-fg); }

.kf-filters { display: flex; gap: .35rem; }

.kf-chip {
    padding: .35rem .8rem;
    border-radius: 999px;
    border: 1px solid var(--kf-line);
    background: transparent;
    color: var(--kf-muted);
    cursor: pointer;
    font: inherit;
}
.kf-chip:hover { background: var(--kf-bg-3); }
.kf-chip.is-on { background: var(--kf-text); color: var(--kf-bg); border-color: var(--kf-text); }

.kf-btn {
    padding: .45rem .9rem;
    border-radius: 8px;
    border: 1px solid var(--kf-line);
    background: var(--kf-bg-3);
    color: var(--kf-text);
    cursor: pointer;
    font: inherit;
}
/* En tema claro, aclarar con filter: brightness sobre un botón ya claro no se ve;
   se cambia el fondo, que funciona en los dos temas. */
.kf-btn:hover { background: var(--kf-line); border-color: var(--kf-muted); }
.kf-btn-danger:hover { background: var(--kf-danger); filter: brightness(1.08); }
.kf-btn-ghost:hover { background: var(--kf-bg-3); }
.kf-btn:disabled { opacity: .45; cursor: default; }
.kf-btn-danger { background: var(--kf-danger); border-color: var(--kf-danger); color: #fff; }
.kf-btn-ghost { background: transparent; }

.kf-input, .kf-select {
    padding: .45rem .7rem;
    border-radius: 8px;
    border: 1px solid var(--kf-line);
    background: var(--kf-bg-2);
    color: var(--kf-text);
    font: inherit;
}
.kf-input:focus, .kf-select:focus { outline: 2px solid var(--kf-accent); outline-offset: -1px; }

.kf-error {
    padding: .7rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--kf-radius);
    background: var(--kf-error-bg);
    border: 1px solid var(--kf-error-line);
    color: var(--kf-error-fg);
}

.kf-loading, .kf-empty { padding: 2.5rem 1rem; text-align: center; color: var(--kf-muted); }
.kf-empty { padding: 3.5rem 1rem; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.kf-empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: .5rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--kf-bg-2);
    color: var(--kf-accent);
}
.kf-empty-icon .kf-icon { width: 30px; height: 30px; stroke-width: 1.5; }
.kf-empty-title { font-size: 1.15rem; font-weight: 600; color: var(--kf-text); margin: 0; }
.kf-empty-hint { margin: 0; max-width: 46ch; margin-inline: auto; line-height: 1.5; }
.kf-empty .kf-btn { margin-top: .75rem; }

.kf-btn-primary { background: var(--kf-accent); border-color: var(--kf-accent); color: #fff; text-decoration: none; }
.kf-btn-primary:hover { background: var(--kf-accent); border-color: var(--kf-accent); filter: brightness(1.1); text-decoration: none; }

/* ---------- Grid del timeline ---------- */

.kf-grid { width: 100%; }
/* Hueco para que la barra de selección flotante no tape la última fila. */
.kf-grid.is-selecting { padding-bottom: 5rem; }

.kf-section { margin-bottom: 1.5rem; }

.kf-section-date {
    position: sticky;
    top: var(--kf-nav-h);
    z-index: 10;
    margin: 0 0 .5rem;
    padding: .5rem 0;
    font-size: .95rem;
    font-weight: 600;
    color: var(--kf-text);
    background: linear-gradient(to bottom, var(--kf-bg) 70%, transparent);
}

.kf-section-date { display: flex; align-items: center; gap: .5rem; }

/* Check de "todo el día": aparece al pasar por la fecha, y siempre mientras se selecciona
   (en táctil no hay hover, así que ahí solo se ve en modo selección). */
.kf-day-check {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    padding: 0;
    border: 2px solid var(--kf-muted);
    border-radius: 50%;
    background: transparent;
    color: transparent;
    cursor: pointer;
    opacity: 0;
    transition: opacity .12s ease;
}
.kf-section:hover .kf-day-check,
.kf-grid.is-selecting .kf-day-check { opacity: 1; }
.kf-day-check:hover { border-color: var(--kf-accent); color: var(--kf-accent); }
.kf-day-check.is-on { opacity: 1; background: var(--kf-accent); border-color: var(--kf-accent); color: #fff; }

/* En táctil el círculo solo existe mientras se selecciona: oculto pero ocupando sitio,
   dejaba todas las fechas desplazadas a la derecha. */
@media (hover: none) {
    .kf-day-check { display: none; }
    .kf-grid.is-selecting .kf-day-check { display: grid; opacity: 1; }
}

.kf-row { display: flex; gap: 4px; margin-bottom: 4px; }

.kf-cell {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: var(--kf-bg-2);
    cursor: pointer;
    flex-shrink: 0;

    /* Sin esto, la pulsación larga en iOS abre el menú de "Guardar imagen" o selecciona
       texto en lugar de seleccionar la foto. */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* La miniatura se recorta al hueco calculado: el layout justificado ya respetó la
   proporción, así que el recorte es de 1-2 px por redondeo. */
.kf-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .18s ease;
    user-select: none;
}
.kf-cell:hover .kf-thumb { transform: scale(1.03); }

.kf-fade .kf-thumb { opacity: 0; transition: opacity .3s ease, transform .18s ease; }
.kf-fade .kf-thumb.is-loaded { opacity: 1; }
.kf-fade .kf-cell.is-selected .kf-thumb.is-loaded { opacity: .75; }

@media (prefers-reduced-motion: reduce) {
    .kf-fade .kf-thumb { transition: none; }
}

.kf-cell.is-selected { outline: 3px solid var(--kf-accent); outline-offset: -3px; }
.kf-cell.is-selected .kf-thumb { opacity: .75; }

.kf-placeholder { width: 100%; height: 100%; display: grid; place-items: center; }
.kf-pending {
    background: linear-gradient(100deg, var(--kf-shimmer-a) 30%, var(--kf-shimmer-b) 50%, var(--kf-shimmer-a) 70%);
    background-size: 220% 100%;
    animation: kf-shimmer 1.4s linear infinite;
}
@keyframes kf-shimmer { from { background-position: 120% 0; } to { background-position: -20% 0; } }

.kf-failed { background: var(--kf-failed-bg); color: var(--kf-failed-fg); font-weight: 700; }

.kf-badge {
    position: absolute;
    padding: .1rem .35rem;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 600;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    pointer-events: none;
}
.kf-badge-video { bottom: 4px; right: 5px; }
.kf-badge-live { bottom: 4px; left: 5px; letter-spacing: .04em; }
.kf-badge-fav { top: 4px; right: 5px; background: none; color: var(--kf-fav); text-shadow: 0 1px 3px rgba(0, 0, 0, .9); }

/* El check de selección solo aparece al pasar por encima, o si ya está seleccionado. */
.kf-check {
    position: absolute;
    top: 4px;
    left: 5px;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 2px solid #fff;
    background: rgba(0, 0, 0, .35);
    color: transparent;
    font-size: .8rem;
    opacity: 0;
    transition: opacity .12s ease;
}
.kf-cell:hover .kf-check,
.kf-grid.is-selecting .kf-check { opacity: 1; }   /* seleccionando: visible en todas, también en táctil */

/* En táctil no hay hover real: el "hover pegajoso" dejaba la miniatura ampliada tras el toque. */
@media (hover: none) {
    .kf-cell:hover .kf-thumb { transform: none; }
    .kf-cell:hover:not(.is-selected) .kf-check { opacity: 0; }
    .kf-grid.is-selecting .kf-cell .kf-check { opacity: 1; }
}
.kf-cell.is-selected .kf-check { opacity: 1; background: var(--kf-accent); color: #fff; }

.kf-sentinel { height: 1px; }

/* ---------- Visor ---------- */

.kf-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--kf-lb-bg);
    color: var(--kf-lb-fg);

    /* Dentro del visor manda siempre la paleta oscura, también en el panel de información
       y en las barras de scroll nativas. */
    color-scheme: dark;
    --kf-bg-2: #171a21;
    --kf-bg-3: #21252e;
    --kf-line: #2c313c;
    --kf-text: #e8eaef;
    --kf-muted: #9aa2b1;
    --kf-accent: #4c8dff;
}

.kf-lb-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--kf-lb-bar-h);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 .75rem;
    background: linear-gradient(to bottom, var(--kf-lb-scrim), transparent);
    z-index: 2;
}
.kf-lb-title { display: flex; flex-direction: column; line-height: 1.2; margin-right: auto; }
.kf-lb-date { font-size: .85rem; }
.kf-lb-time { font-size: .75rem; color: var(--kf-muted); }
.kf-lb-actions { display: flex; gap: .25rem; }

.kf-lb-btn {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--kf-lb-fg);
    font-size: 1.05rem;
    cursor: pointer;
    text-decoration: none;
}
.kf-lb-btn:hover { background: var(--kf-lb-hover); text-decoration: none; }

/* Iconos vectoriales de la barra del visor: heredan el color del botón, así que funcionan
   igual en tema claro y oscuro y con el estado :hover. */
.kf-icon {
    width: 19px;
    height: 19px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.kf-lb-btn.is-on { color: var(--kf-fav); }

/* Partes rellenas de un icono (estrella marcada, medio círculo del tema automático…). */
.kf-icon .kf-icon-fill { fill: currentColor; stroke: none; }

/* Iconos dentro de texto y controles pequeños. */
.kf-nav-logo .kf-icon { width: 20px; height: 20px; stroke-width: 2; }
.kf-theme-icon .kf-icon { width: 17px; height: 17px; }
.kf-lb-nav .kf-icon { width: 26px; height: 26px; stroke-width: 2; }
.kf-lb-close .kf-icon { width: 22px; height: 22px; }
.kf-check .kf-icon { width: 13px; height: 13px; stroke-width: 3; }
.kf-day-check .kf-icon { width: 13px; height: 13px; stroke-width: 3; }
.kf-badge-fav .kf-icon { width: 15px; height: 15px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .8)); }
.kf-badge-video { display: inline-flex; align-items: center; gap: .2rem; }
.kf-badge-video .kf-icon { width: 10px; height: 10px; }
#blazor-error-ui .dismiss .kf-icon { width: 16px; height: 16px; }
.kf-lb-danger:hover { background: var(--kf-danger); color: #fff; }

.kf-lb-stage {
    /* Absoluto dentro del visor (que es fixed inset:0) y SIN unidades vh.
       En móvil, 100vh es la altura con la barra de direcciones oculta, así que el stage
       quedaba más alto que la pantalla visible y el borde inferior de la foto caía fuera
       sin forma de alcanzarlo. Con inset:0 mide exactamente el área visible. */
    position: absolute;
    inset: 0;
    padding: calc(var(--kf-lb-bar-h) + 4px) .5rem 1rem;

    /* Sin scroll nativo: en móvil daba problemas. El desplazamiento de una foto ampliada
       se hace arrastrando, y funciona igualmente porque con overflow:hidden el elemento
       sigue siendo desplazable por código (scrollLeft/scrollTop). */
    overflow: hidden;

    /* Flex + margin:auto en el hijo, NO justify/align-content: con centrado por
       justify-content, el desbordamiento hacia arriba y hacia la izquierda queda
       inalcanzable al desplazar. */
    display: flex;

    /* El pinch a dos dedos se implementa con pointer events; sin esto el navegador se
       lo queda para su propio zoom. */
    touch-action: none;
}

.kf-lb-media {
    display: block;
    margin: auto;          /* centra cuando cabe y no rompe el scroll cuando no cabe */
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;   /* para el <video>, que no conserva la proporción por sí solo */

    /* IMPRESCINDIBLE. El min-height/min-width automático de los ítems flex y grid es el
       tamaño intrínseco del contenido y GANA a max-height: 100%. Sin esto, una foto
       vertical de 2370 px se renderiza a 2370 px de alto y se sale de la ventana: es
       exactamente el bug del "no puedo reducir el zoom lo suficiente". */
    min-width: 0;
    min-height: 0;
}

.kf-lb-zoomable {
    user-select: none;
    -webkit-user-drag: none;
}

/* Con tamaño explícito la imagen NO puede encogerse como ítem flex. Sin esto, el
   min-width:0 de arriba deja que flex-shrink la estreche al ancho del visor mientras el
   alto sí crece: object-fit:contain disimula la deformación pintando la foto con su ancho
   de siempre, y el zoom parecía no hacer nada salvo añadir hueco arriba y abajo. */
.kf-lb-stage.is-zoomed > .kf-lb-media { flex-shrink: 0; }

/* Con la foto ampliada la barra queda encima de la imagen: fondo sólido para que los
   botones se sigan leyendo sobre cualquier zona de la foto. */
.kf-lightbox:has(.kf-lb-stage.is-zoomed) .kf-lb-bar {
    background: var(--kf-lb-scrim);
    backdrop-filter: blur(10px);
}

/* Un toque en la foto oculta barras y flechas: solo queda la imagen. */
.kf-lb-bar, .kf-lb-nav, .kf-live-hint { transition: opacity .2s ease; }
.kf-lightbox.is-clean .kf-lb-bar,
.kf-lightbox.is-clean .kf-lb-nav,
.kf-lightbox.is-clean .kf-live-hint { opacity: 0; pointer-events: none; }
.kf-lightbox.is-clean { background: #000; }

/* En presentación la barra reaparece al pasar el ratón por arriba, para poder pararla. */
.kf-lightbox.is-playing .kf-lb-bar:hover { opacity: 1; pointer-events: auto; }
.kf-lightbox.is-playing .kf-lb-bar { pointer-events: auto; }
.kf-lightbox.is-playing .kf-lb-media { animation: kf-slide-in .7s ease; }
@keyframes kf-slide-in { from { opacity: 0; } to { opacity: 1; } }

.kf-preload {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}
.kf-preload img { width: 1px; height: 1px; }

.kf-lb-stage.is-zoomed { cursor: grab; }
.kf-lb-stage.is-zoomed:active { cursor: grabbing; }


.kf-zoom {
    display: flex;
    align-items: center;
    gap: .1rem;
    margin-right: .35rem;
    padding-right: .35rem;
    border-right: 1px solid var(--kf-lb-hover);
}

.kf-zoom-level {
    min-width: 3.6rem;
    padding: .25rem .3rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--kf-lb-fg);
    font: inherit;
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.kf-zoom-level:hover { background: var(--kf-lb-hover); }
.kf-zoom-level.is-on { color: var(--kf-accent); font-weight: 600; }

/* La insignia LIVE va suelta dentro del stage, no en un envoltorio alrededor de la
   imagen: un contenedor intermedio de alto automático rompe el max-height: 100% del
   medio (el porcentaje no tiene contra qué resolverse) y deshace el autoajuste. */
.kf-live-hint {
    position: absolute;
    top: calc(var(--kf-lb-bar-h) + 8px);
    left: 1rem;
    z-index: 2;
    padding: .15rem .45rem;
    border-radius: 4px;
    color: #fff;
    background: rgba(0, 0, 0, .55);
    font-size: .7rem;
    letter-spacing: .05em;
}

.kf-lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 72px;
    border: none;
    border-radius: 8px;
    background: var(--kf-lb-nav-bg);
    color: var(--kf-lb-fg);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}
.kf-lb-nav:hover { background: var(--kf-lb-nav-hover); }
.kf-lb-prev { left: .5rem; }
.kf-lb-next { right: .5rem; }

.kf-lb-info {
    position: absolute;
    top: var(--kf-lb-bar-h);
    right: 0;
    bottom: 0;
    width: min(360px, 90vw);
    overflow-y: auto;
    padding: 1rem 1.25rem;
    background: var(--kf-bg-2);
    border-left: 1px solid var(--kf-line);
    z-index: 3;
}
.kf-lb-info h3 { margin: 0 0 1rem; font-size: 1rem; }
.kf-lb-info dl { margin: 0; display: grid; grid-template-columns: 1fr; gap: .1rem; }
.kf-lb-info dt { color: var(--kf-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; margin-top: .8rem; }
.kf-lb-info dd { margin: 0; }

.kf-place { display: block; color: var(--kf-text); }

.kf-link-btn {
    margin-left: .4rem;
    padding: 0;
    border: none;
    background: none;
    color: var(--kf-accent);
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
}
.kf-link-btn:hover { text-decoration: underline; }
.kf-date-edit { display: flex; flex-direction: column; gap: .4rem; }
.kf-date-edit .kf-input { width: 100%; }
.kf-date-edit-actions { display: flex; gap: .4rem; justify-content: flex-end; }

/* ---------- Álbumes ---------- */

.kf-albums {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1rem;
}

.kf-album { position: relative; cursor: pointer; }
.kf-album-cover {
    aspect-ratio: 1;
    border-radius: var(--kf-radius);
    overflow: hidden;
    background: var(--kf-bg-2);
}
.kf-album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kf-album:hover .kf-album-cover { outline: 2px solid var(--kf-accent); }

.kf-album-meta { display: flex; flex-direction: column; padding: .5rem .15rem; }
.kf-album-name { font-weight: 500; }

.kf-album-del {
    position: absolute;
    top: .4rem;
    right: .4rem;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transition: opacity .12s ease;
}
.kf-album:hover .kf-album-del { opacity: 1; }
.kf-album-del:hover { background: var(--kf-danger); }

/* ---------- Subida ---------- */

.kf-hidden-input { display: none; }

.kf-dropzone {
    padding: 3rem 1.5rem;
    border: 2px dashed var(--kf-line);
    border-radius: var(--kf-radius);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.kf-dropzone:hover { border-color: var(--kf-accent); background: var(--kf-bg-2); }
.kf-dropzone.is-busy { cursor: progress; border-color: var(--kf-accent); }
.kf-dropzone.is-over { border-color: var(--kf-accent); border-style: solid; background: var(--kf-bg-2); }
.kf-dz-title { margin: 0 0 .4rem; font-size: 1.05rem; }
.kf-dz-hint { margin: 0; color: var(--kf-muted); max-width: 60ch; margin-inline: auto; }

.kf-upload-summary { display: flex; align-items: center; gap: .6rem; margin: 1.25rem 0 .5rem; }

.kf-upload-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.kf-upload-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 140px 90px;
    align-items: center;
    gap: .75rem;
    padding: .45rem .6rem;
    border-radius: 6px;
    background: var(--kf-bg-2);
    font-size: .85rem;
}
.kf-ui-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kf-ui-bar { height: 6px; border-radius: 999px; background: var(--kf-bg-3); overflow: hidden; }
.kf-ui-fill { height: 100%; background: var(--kf-accent); transition: width .2s ease; }
.kf-ui-state { text-align: right; color: var(--kf-muted); }

.kf-done .kf-ui-fill { background: #3fa45b; }
.kf-skipped .kf-ui-fill { background: var(--kf-muted); }
.kf-error .kf-ui-fill { background: var(--kf-danger); }
.kf-error .kf-ui-state { color: var(--kf-error-fg); }

/* ---------- Móvil ---------- */

@media (max-width: 700px) {
    /* Hueco abajo para la barra de pestañas fija (y la zona del gesto de inicio del iPhone). */
    .kf-main { padding: .5rem .5rem calc(var(--kf-tabbar-h) + env(safe-area-inset-bottom) + .5rem); }
    /* Sin backdrop-filter: un ancestro con filtro se convierte en el bloque contenedor de
       sus hijos position:fixed, y la barra de pestañas acabaría pegada a la cabecera en
       lugar de al borde inferior de la pantalla. */
    .kf-nav { gap: .6rem; padding: 0 .6rem; backdrop-filter: none; background: var(--kf-bg); }
    .kf-nav-user-name { display: none; }   /* en el móvil, solo el icono */

    /* En la barra de arriba no caben marca + secciones + acciones: antes las secciones se
       encogían a ancho 0 y quedaban tapadas, sin forma de llegar a Favoritos o Álbumes.
       En móvil las secciones bajan a una barra de pestañas fija, como en una app nativa. */
    .kf-nav-brand span:not(.kf-nav-logo) { display: none; }

    .kf-nav-links {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        gap: 0;
        height: calc(var(--kf-tabbar-h) + env(safe-area-inset-bottom));
        padding: 0 .25rem env(safe-area-inset-bottom);
        background: var(--kf-nav-bg);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--kf-line);
        overflow: visible;
    }

    .kf-nav-links .kf-nav-link {
        display: grid;
        place-items: center;
        border-radius: 0;
        font-size: .8rem;
        padding: 0;
    }

    .kf-nav-links .kf-nav-link.active {
        background: none;
        color: var(--kf-accent);
        font-weight: 600;
    }
    .kf-upload-item { grid-template-columns: minmax(0, 1fr) 70px; }
    .kf-ui-bar { display: none; }
    .kf-lb-nav { width: 40px; height: 60px; font-size: 1.5rem; }


    /* Barra en dos filas exactas, con GRID y no con flex-wrap: el corte de línea de
       flexbox depende de los tamaños y acababa metiendo el zoom en una tercera fila que
       se solapaba con la foto. Con áreas nombradas la colocación es determinista.
       Y objetivos de toque más grandes, que con el dedo 36 px se queda corto. */
    :root { --kf-lb-bar-h: 108px; }

    .kf-lb-bar {
        display: grid;
        /* 1fr para el texto y auto para los botones, no al revés: así la columna de
           botones se dimensiona por su contenido y nunca se queda corta, y es la fecha
           la que cede y se recorta en pantallas muy estrechas. */
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "close actions"
            "title zoom";
        align-items: center;
        row-gap: .25rem;
        padding: .35rem .5rem;
        gap: .25rem .35rem;
    }

    .kf-lb-close   { grid-area: close; }
    .kf-lb-actions { grid-area: actions; justify-self: end; }
    .kf-lb-title   { grid-area: title; margin-right: 0; min-width: 0; }
    .kf-zoom       { grid-area: zoom; justify-self: end; }

    .kf-lb-btn { width: 42px; height: 42px; font-size: 1.15rem; }
    .kf-lb-btn .kf-icon { width: 21px; height: 21px; }

    /* Con todo en una sola fila no cabe en un móvil de 360 px, así que se reparte:
         fila 1 → cerrar + acciones (favorito, info, descargar, papelera)
         fila 2 → fecha a la izquierda, controles de zoom a la derecha */
    .kf-zoom { border-right: none; margin-right: 0; padding-right: 0; }

    /* La fecha cede espacio antes que los botones: en pantallas muy estrechas se recorta
       con puntos suspensivos en lugar de empujar el zoom fuera de la pantalla. */
    .kf-lb-date, .kf-lb-time { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .kf-zoom-level { min-width: 3.1rem; }

    .kf-lb-close { width: 52px; height: 52px; font-size: 1.7rem; }

    /* order + flex-basis 100% la manda a una segunda fila completa. */
    .kf-lb-title {
        order: 3;
        flex-basis: 100%;
        padding-left: .35rem;
        line-height: 1.25;
    }
    .kf-lb-date { font-size: .9rem; }

    .kf-lb-actions { order: 2; margin-left: auto; gap: .1rem; }
}

/* ---------- Páginas de Identity (formularios de Bootstrap) ---------- */

.kf-main .form-floating > .form-control,
.kf-main input.form-control,
.kf-main select.form-select {
    background: var(--kf-bg-2);
    border-color: var(--kf-line);
    color: var(--kf-text);
}
.kf-main .form-floating > label { color: var(--kf-muted); }
.kf-main .btn-primary { background: var(--kf-accent); border-color: var(--kf-accent); }
.kf-main h2, .kf-main h3 { font-weight: 600; }
.kf-main hr { border-color: var(--kf-line); }

/* ---------- Barra lateral de fechas ---------- */

.kf-scrubber {
    position: fixed;
    top: calc(var(--kf-nav-h) + 1rem);
    bottom: 1rem;
    right: 0;
    width: 56px;
    z-index: 40;
    cursor: ns-resize;
    touch-action: none;   /* el arrastre con el dedo es de la barra, no scroll de la página */
    user-select: none;
    -webkit-user-select: none;
}
.kf-scrubber > * { pointer-events: none; }   /* así el puntero siempre "cae" en la barra */

.kf-scrub-year {
    position: absolute;
    right: 8px;
    transform: translateY(-50%);
    font-size: .7rem;
    font-weight: 600;
    color: var(--kf-muted);
    opacity: .75;
    transition: opacity .15s ease;
}
.kf-scrubber:hover .kf-scrub-year,
.kf-scrubber.is-active .kf-scrub-year { opacity: 1; }

.kf-scrub-mark {
    position: absolute;
    right: 0;
    width: 4px;
    height: 18px;
    transform: translateY(-2px);
    border-radius: 2px 0 0 2px;
    background: var(--kf-accent);
}

.kf-scrub-bubble {
    position: absolute;
    right: 52px;
    transform: translateY(-50%);
    padding: .3rem .65rem;
    border-radius: 8px;
    background: var(--kf-text);
    color: var(--kf-bg);
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}

/* El grid deja libre la franja de la barra para que los años no tapen las fotos. */
.kf-main:has(.kf-scrubber) .kf-grid { padding-right: 44px; }

.kf-jumped {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin: -.25rem 0 1rem;
    color: var(--kf-muted);
    font-size: .9rem;
}

@media (max-width: 700px) {
    .kf-scrubber {
        width: 40px;
        bottom: calc(var(--kf-tabbar-h) + env(safe-area-inset-bottom) + .5rem);
    }
    /* En el móvil los años tapaban el borde de las fotos: solo se ven al arrastrar. En
       reposo queda una guía fina en el borde que indica dónde agarrar. */
    .kf-scrubber { width: 26px; }
    .kf-scrubber::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        right: 4px;
        width: 3px;
        border-radius: 2px;
        background: var(--kf-line);
    }
    .kf-scrub-year { right: 10px; font-size: .65rem; padding: .05rem .3rem; border-radius: 4px; background: var(--kf-bg-2); opacity: 0; }
    .kf-scrubber.is-active .kf-scrub-year { opacity: 1; }
    .kf-scrub-bubble { right: 30px; }
    .kf-main:has(.kf-scrubber) .kf-grid { padding-right: 14px; }
}

/* ---------- Buscar ---------- */

.kf-nav-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--kf-muted);
}
.kf-nav-icon:hover, .kf-nav-icon.active { background: var(--kf-bg-3); color: var(--kf-text); text-decoration: none; }
.kf-nav-icon .kf-icon { width: 19px; height: 19px; }

.kf-search { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1.5rem; }
.kf-search-main { position: relative; display: flex; gap: .5rem; }
.kf-search-main .kf-input { flex: 1; padding-left: 2.3rem; font-size: 1rem; }
.kf-search-icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--kf-muted); pointer-events: none; }
.kf-search-icon .kf-icon { width: 18px; height: 18px; }
.kf-search-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; color: var(--kf-muted); font-size: .9rem; }
.kf-search-filters label { display: flex; align-items: center; gap: .4rem; }
.kf-check-label input { width: 17px; height: 17px; accent-color: var(--kf-accent); }

/* ---------- Mapa ---------- */

.kf-map {
    height: calc(100vh - var(--kf-nav-h) - 9rem);
    min-height: 360px;
    border-radius: var(--kf-radius);
    overflow: hidden;
    background: var(--kf-bg-2);
    z-index: 0;   /* Leaflet usa z-index altos dentro: que no tapen la cabecera ni el visor */
    isolation: isolate;
}
.kf-map.is-hidden { display: none; }

.kf-map-pin { background: none; border: none; }
.kf-map-pin img {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
    background: #ccc;
}
/* Con más especificidad que .leaflet-marker-icon, que fuerza display:block y dejaba el
   número arrinconado arriba a la izquierda del círculo. */
.leaflet-marker-icon.kf-map-cluster {
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--kf-accent);
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}

@media (max-width: 700px) {
    .kf-map { height: calc(100dvh - var(--kf-nav-h) - var(--kf-tabbar-h) - 8rem); }
}

/* ---------- Aviso de duplicados ---------- */

.kf-hint {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 0 0 1rem;
    padding: .6rem .7rem .6rem .9rem;
    border-radius: var(--kf-radius);
    background: var(--kf-bg-2);
    border: 1px solid var(--kf-line);
}
.kf-hint-icon { color: var(--kf-accent); display: grid; }
.kf-hint-icon .kf-icon { width: 20px; height: 20px; }
.kf-hint-text { flex: 1; min-width: 0; font-size: .9rem; }
.kf-hint-close { width: 30px; height: 30px; display: grid; place-items: center; border: none; border-radius: 8px; background: none; color: var(--kf-muted); cursor: pointer; }
.kf-hint-close:hover { background: var(--kf-bg-3); }
.kf-hint-close .kf-icon { width: 16px; height: 16px; }

/* ---------- Tal día como hoy ---------- */

.kf-memories { margin: 0 0 1.25rem; }
.kf-memories-title { margin: 0 0 .5rem; font-size: .95rem; font-weight: 600; }
.kf-memories-strip { display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: thin; }
.kf-memory {
    position: relative;
    flex: 0 0 auto;
    width: 150px;
    height: 200px;
    padding: 0;
    border: none;
    border-radius: 12px;
    overflow: hidden;
    background: var(--kf-bg-2);
    cursor: pointer;
}
.kf-memory img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
.kf-memory:hover img { transform: scale(1.04); }
.kf-memory-label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem .65rem .55rem;
    color: #fff;
    text-align: left;
    font-size: .78rem;
    background: linear-gradient(to top, rgba(0, 0, 0, .75), transparent);
}
.kf-memory-label strong { font-size: .95rem; }

@media (max-width: 700px) {
    .kf-memory { width: 120px; height: 160px; }
}

/* ---------- Fotos con problemas ---------- */

.kf-problems { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.kf-problem {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1rem;
    border-radius: var(--kf-radius);
    background: var(--kf-bg-2);
}
.kf-problem-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.kf-problem-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kf-problem-error {
    display: block;
    margin-top: .2rem;
    font-size: .78rem;
    color: var(--kf-error-fg);
    white-space: pre-wrap;
    word-break: break-word;
}
a.kf-pill-error:hover { text-decoration: underline; }

/* ---------- Duplicados ---------- */

.kf-notice {
    padding: .6rem .9rem;
    border-radius: var(--kf-radius);
    background: var(--kf-pill-work-bg);
    color: var(--kf-pill-work-fg);
}

.kf-dup-kind { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; font-size: .85rem; color: var(--kf-muted); }
.kf-dup-kind strong { padding: .1rem .5rem; border-radius: 6px; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.kf-dup-kind-copy strong { background: var(--kf-pill-error-bg); color: var(--kf-pill-error-fg); }
.kf-dup-kind-burst strong { background: var(--kf-pill-work-bg); color: var(--kf-pill-work-fg); }
.kf-dup-kind-versions strong { background: var(--kf-bg-3); color: var(--kf-text); }

.kf-dup-group {
    display: flex;
    gap: .6rem;
    overflow-x: auto;
    padding: .75rem 0;
    border-bottom: 1px solid var(--kf-line);
}
.kf-dup-item {
    position: relative;
    flex: 0 0 auto;
    width: 180px;
    padding: 0;
    border: 3px solid transparent;
    border-radius: 10px;
    background: var(--kf-bg-2);
    color: var(--kf-text);
    text-align: left;
    font: inherit;
    cursor: pointer;
    overflow: hidden;
}
.kf-dup-item img { display: block; width: 100%; height: 135px; object-fit: cover; }
.kf-dup-item.is-marked { border-color: var(--kf-danger); }
.kf-dup-item.is-marked img { opacity: .55; }
.kf-dup-item:not(.is-marked) { border-color: #3fa45b; }
.kf-dup-tag {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: .1rem .45rem;
    border-radius: 6px;
    font-size: .72rem;
    font-weight: 600;
    color: #fff;
    background: #3fa45b;
}
.kf-dup-item.is-marked .kf-dup-tag { background: var(--kf-danger); }
.kf-dup-meta { display: flex; flex-direction: column; gap: .1rem; padding: .4rem .5rem .5rem; font-size: .75rem; color: var(--kf-muted); }
.kf-dup-name { color: var(--kf-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 700px) {
    .kf-dup-item { width: 140px; }
    .kf-dup-item img { height: 105px; }
}

/* ---------- Diálogo de confirmación ---------- */

.kf-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;   /* por encima del visor: se puede borrar desde él */
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, .5);
}
.kf-modal {
    width: min(420px, 100%);
    padding: 1.4rem 1.4rem 1.1rem;
    border-radius: 14px;
    background: var(--kf-bg);
    color: var(--kf-text);
    box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
}
.kf-modal h2 { margin: 0 0 .5rem; font-size: 1.1rem; font-weight: 600; }
.kf-modal p { margin: 0 0 1.2rem; color: var(--kf-muted); }
.kf-modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }

.kf-btn-danger-text { color: var(--kf-danger); }
.kf-btn-shared { background: var(--kf-pill-work-bg); border-color: transparent; color: var(--kf-pill-work-fg); }
.kf-share-section { margin: 1.25rem 0 .35rem; font-size: .95rem; font-weight: 600; }
.kf-modal h3.kf-share-section:first-of-type { margin-top: .5rem; }
.kf-member { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; }
.kf-member .kf-icon { width: 18px; height: 18px; color: var(--kf-muted); }
.kf-member span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.kf-member-add { display: flex; gap: .5rem; margin: .5rem 0 .75rem; }
.kf-member-add .kf-input { flex: 1; min-width: 0; }
.kf-modal { max-height: calc(100dvh - 2rem); overflow-y: auto; }
.kf-share-expiry { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.2rem; color: var(--kf-muted); }
.kf-share-msg { margin-top: -.5rem !important; color: #3fa45b !important; }
.kf-modal-actions-wrap { flex-wrap: wrap; }
.kf-nav-section { margin: 1rem 0 .25rem; padding: 0 1rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--kf-muted); }
.kf-modal-input { width: 100%; margin-bottom: 1rem; }
.kf-date-modes { display: flex; gap: 1.25rem; flex-wrap: wrap; margin-bottom: .75rem; }
.kf-date-modes label { display: flex; align-items: center; gap: .4rem; cursor: pointer; }
.kf-date-shift { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.kf-date-shift label { display: flex; align-items: center; gap: .35rem; color: var(--kf-muted); }
.kf-date-shift .kf-input { width: 5.5rem; }
.kf-modal-error { color: var(--kf-danger) !important; margin-top: -.5rem !important; }

.kf-album-del { display: grid; place-items: center; }
.kf-album-del .kf-icon { width: 16px; height: 16px; }
@media (hover: none) { .kf-album-del { opacity: 1; } }   /* en táctil no hay hover */

/* ---------- Barra de selección ---------- */

.kf-selbar {
    position: fixed;
    left: 50%;
    bottom: calc(1.25rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 60;   /* sobre la barra de pestañas, bajo el visor */
    display: flex;
    align-items: center;
    gap: .75rem;
    width: max-content;
    max-width: calc(100vw - 1.5rem);
    padding: .5rem .6rem;
    border-radius: 14px;
    background: var(--kf-bg);
    border: 1px solid var(--kf-line);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .22);
    animation: kf-toast-in .16s ease-out;
}
.kf-selbar-close {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--kf-text);
    cursor: pointer;
}
.kf-selbar-close:hover { background: var(--kf-bg-3); }
.kf-selbar-count { font-weight: 600; white-space: nowrap; }
.kf-selbar-actions { display: flex; align-items: center; gap: .4rem; margin-left: .5rem; min-width: 0; }
.kf-selbar-actions .kf-select { max-width: 11rem; }
.kf-selbar .kf-btn { display: inline-flex; align-items: center; gap: .4rem; }
.kf-selbar .kf-btn .kf-icon { width: 17px; height: 17px; }
.kf-btn-icon { padding: .45rem .6rem; }

@media (max-width: 700px) {
    .kf-selbar {
        left: .5rem;
        right: .5rem;
        width: auto;
        max-width: none;
        transform: none;
        bottom: calc(var(--kf-tabbar-h) + env(safe-area-inset-bottom) + .5rem);
        animation: none;
    }
    .kf-selbar-actions { margin-left: auto; }
    .kf-hide-sm { display: none; }
}

/* ---------- Aviso con acción (Deshacer) ---------- */

.kf-toast {
    position: fixed;
    left: 50%;
    bottom: calc(1.25rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 150;   /* por encima del visor: se borra desde él */
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: calc(100vw - 2rem);
    padding: .65rem .75rem .65rem 1.1rem;
    border-radius: 10px;
    background: #21252e;
    color: #e8eaef;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
    animation: kf-toast-in .18s ease-out;
}
.kf-toast-action {
    border: none;
    background: none;
    padding: .3rem .5rem;
    border-radius: 6px;
    color: #7fb0ff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.kf-toast-action:hover { background: rgba(255, 255, 255, .1); }

@keyframes kf-toast-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 700px) {
    /* Encima de la barra de pestañas. */
    .kf-toast { bottom: calc(var(--kf-tabbar-h) + env(safe-area-inset-bottom) + .75rem); }
}

/* Aviso de "sin conexión" (lo pone pwa.js). */
.kf-offline {
    position: fixed;
    top: calc(var(--kf-nav-h) + .5rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 55;
    padding: .35rem .9rem;
    border-radius: 999px;
    background: #21252e;
    color: #e8eaef;
    font-size: .8rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
    white-space: nowrap;
}

.kf-resume { background: var(--kf-accent); color: #fff; text-decoration: none; }
.kf-resume:hover { text-decoration: underline; color: #fff; }
.kf-hint .kf-btn { white-space: nowrap; }

#blazor-error-ui {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: none;
    padding: .8rem 1.25rem;
    background: var(--kf-warn-bg);
    color: #1a1a1a;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }


/* ---------- Conmutador de tema ---------- */

.kf-theme-toggle {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--kf-line);
    border-radius: 8px;
    background: transparent;
    color: var(--kf-muted);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
.kf-theme-toggle:hover { background: var(--kf-bg-3); color: var(--kf-text); }

/* Qué icono se ve lo decide el atributo que theme.js pone en <html>: así el botón
   funciona igual en las páginas SSR, sin estado en el servidor ni en Blazor. */
.kf-theme-icon { display: none; }
:root[data-theme-mode="auto"] .kf-theme-icon-auto,
:root[data-theme-mode="light"] .kf-theme-icon-light,
:root[data-theme-mode="dark"] .kf-theme-icon-dark { display: inline-grid; }

/* Sin JS no hay atributo: se muestra el icono de automático para que el botón no quede vacío. */
:root:not([data-theme-mode]) .kf-theme-icon-auto { display: inline-grid; }

/* ---------- Páginas de cuenta (entrar, alta, gestión) ---------- */

.kf-auth {
    max-width: 26rem;
    margin: 3rem auto;
    padding: 2rem;
    border: 1px solid var(--kf-line);
    border-radius: var(--kf-radius);
    background: var(--kf-bg-2);
}
.kf-auth-wide { max-width: 32rem; }
.kf-auth h1 { margin-bottom: .35rem; }
.kf-auth > .kf-muted { display: block; margin-bottom: 1.5rem; }
.kf-auth .kf-muted code {
    padding: .05rem .3rem;
    border-radius: 4px;
    background: var(--kf-bg-3);
    font-size: .95em;
}

.kf-auth-or {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: 1.25rem 0 .5rem;
    color: var(--kf-muted);
    font-size: .85rem;
}
.kf-auth-or::before,
.kf-auth-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--kf-line);
}

.kf-auth-actions { display: flex; align-items: center; gap: .75rem; margin-top: 1.5rem; }
