/* ==========================================================
   Diana & Elian — hoja de estilos
   Papel rosado, tinta violeta y fresa. Lo escrito "a mano"
   (Caveat) se reserva para lo que ellos mismos escriben.
   ========================================================== */

/* ===== TOKENS ===== */
:root {
    --paper:      #F7EEF1;
    --paper-2:    #EFE1E8;
    --card:       #FFFBFC;
    --ink:        #26173A;
    --ink-soft:   #5C4D6B;
    --line:       #DCC9D4;
    --berry:      #C8304E;
    --berry-deep: #A6223E;
    --on-berry:   #FFFFFF;
    --butter:     #F6D88A;
    --lilac:      #B7A3DE;
    --focus:      #6B4BD1;

    --invert-bg:   #26173A;
    --invert-card: #33224A;
    --invert-ink:  #F7EEF1;
    --invert-soft: #C9BAD4;
    --invert-line: #4A3863;

    --shadow-sm: 0 1px 2px rgba(38,23,58,.08), 0 2px 8px rgba(38,23,58,.06);
    --shadow-md: 0 2px 4px rgba(38,23,58,.06), 0 12px 32px rgba(38,23,58,.12);

    --display: 'Young Serif', Georgia, 'Times New Roman', serif;
    --body:    'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --hand:    'Caveat', 'Segoe Print', cursive;

    --radius:    14px;
    --radius-lg: 22px;
    --gutter:    clamp(1rem, 4vw, 2.5rem);
    --topbar-h:  64px;
    --player-h:  84px;
    --ease-out:  cubic-bezier(.22,.61,.36,1);

    color-scheme: light;
}

:root[data-theme="dark"] {
    --paper:      #170F22;
    --paper-2:    #1D142B;
    --card:       #241935;
    --ink:        #F4E9F0;
    --ink-soft:   #BFAFCB;
    --line:       #3B2D4E;
    --berry:      #FF7D93;
    --berry-deep: #FF9AAB;
    --on-berry:   #2A0E18;
    --butter:     #5A3A82;
    --lilac:      #8C77BF;
    --focus:      #C9B6FF;

    --invert-bg:   #241935;
    --invert-card: #2E2142;
    --invert-ink:  #F4E9F0;
    --invert-soft: #BFAFCB;
    --invert-line: #45355C;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 2px 8px rgba(0,0,0,.25);
    --shadow-md: 0 2px 4px rgba(0,0,0,.3), 0 16px 40px rgba(0,0,0,.4);

    color-scheme: dark;
}

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--topbar-h) + 12px);
}
html:has(dialog[open]) { overflow: hidden; }

body {
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--body);
    font-size: 1.0625rem;
    line-height: 1.6;
    padding-bottom: calc(var(--player-h) + 24px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    transition: background-color .3s ease, color .3s ease;
}

img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
ul[role="list"], ol { list-style: none; padding: 0; }
[hidden] { display: none !important; }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
    border-radius: 6px;
}
main:focus { outline: none; }

::selection { background: var(--butter); color: #26173A; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.25em; height: 1.25em; flex-shrink: 0; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

.skip-link {
    position: fixed; top: 12px; left: 12px; z-index: 500;
    padding: .7rem 1rem; border-radius: 10px;
    background: var(--ink); color: var(--paper);
    font-weight: 700; text-decoration: none;
    transform: translateY(-160%);
    transition: transform .2s ease;
}
.skip-link:focus { transform: translateY(0); }

.container { width: min(1120px, 100%); margin-inline: auto; padding-inline: var(--gutter); }
.container-narrow { width: min(820px, 100%); }

/* ===== BOTONES ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
    min-height: 48px; padding: 0 1.4rem;
    border-radius: 999px; border: 1.5px solid transparent;
    font-family: var(--body); font-weight: 700; font-size: 1rem; line-height: 1.1;
    text-decoration: none; white-space: nowrap;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .2s var(--ease-out);
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; }
.btn-sm { min-height: 42px; padding: 0 1.1rem; font-size: .9375rem; }

.btn-primary { background: var(--berry); color: var(--on-berry); }
.btn-primary:hover:not(:disabled) { background: var(--berry-deep); }

.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-quiet:hover:not(:disabled) { border-color: var(--ink); }

.btn-text {
    min-height: 44px; padding: 0 .4rem;
    background: none; color: var(--ink-soft);
    text-decoration: underline; text-underline-offset: .2em; text-decoration-thickness: 1px;
}
.btn-text:hover { color: var(--ink); }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 44px; height: 44px; padding: 0;
    border: 0; border-radius: 50%;
    background: transparent; color: inherit;
    transition: background-color .2s ease, color .2s ease, opacity .2s ease;
}
.icon-btn:hover:not(:disabled) { background: color-mix(in srgb, currentColor 10%, transparent); }
.icon-btn:disabled { opacity: .35; }

/* ===== BARRA SUPERIOR ===== */
.topbar {
    position: sticky; top: 0; z-index: 100;
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid transparent;
    transition: border-color .25s ease, background-color .3s ease;
}
.topbar.is-scrolled { border-bottom-color: var(--line); }
.topbar-inner {
    display: flex; align-items: center; gap: 1rem;
    width: min(1120px, 100%); height: var(--topbar-h);
    margin-inline: auto; padding-inline: var(--gutter);
}
.brand {
    display: inline-flex; align-items: center; gap: .55rem;
    font-family: var(--display); font-size: 1.2rem; line-height: 1;
    text-decoration: none; white-space: nowrap;
}
.brand-mark { width: 30px; height: 30px; color: var(--ink); }
.brand-amp { color: var(--berry); }

.nav { margin-left: auto; }
.nav-list { display: flex; gap: .25rem; list-style: none; padding: 0; }
.nav-list a {
    display: block; padding: .55rem .85rem; border-radius: 999px;
    color: var(--ink-soft); text-decoration: none; font-weight: 700; font-size: .9375rem;
    transition: color .2s ease, background-color .2s ease;
}
.nav-list a:hover { color: var(--ink); background: var(--paper-2); }
.nav-list a[aria-current="true"] { color: var(--ink); background: var(--paper-2); }

.topbar-actions { display: flex; align-items: center; gap: .25rem; }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

.menu-btn {
    display: none; align-items: center; gap: .4rem;
    min-height: 44px; padding: 0 .9rem;
    border: 1.5px solid var(--line); border-radius: 999px;
    background: transparent; font-weight: 700; font-size: .9375rem;
}

/* ===== INICIO ===== */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
    align-items: center; gap: clamp(1.5rem, 4vw, 4rem);
    width: min(1120px, 100%); margin-inline: auto;
    padding: clamp(1.5rem, 5vh, 4.5rem) var(--gutter) clamp(3rem, 7vw, 5rem);
    min-height: min(820px, calc(100svh - var(--topbar-h) - var(--player-h) - 28px));
}
.hero-note {
    font-family: var(--hand); font-weight: 700; font-size: 1.9rem; line-height: 1;
    color: var(--berry);
    transform: rotate(-3deg); transform-origin: left center;
    margin-bottom: .75rem;
}
.hero-title {
    font-family: var(--display); font-weight: 400;
    font-size: clamp(2.6rem, 1.2rem + 5.2vw, 5.4rem);
    line-height: 1.02; letter-spacing: -.02em;
    text-wrap: balance;
}
.hero-mark {
    background: linear-gradient(transparent 62%, var(--butter) 62%, var(--butter) 92%, transparent 92%);
    -webkit-box-decoration-break: clone; box-decoration-break: clone;
    padding: 0 .08em;
}
.hero-lede {
    margin-top: 1.25rem; max-width: 34ch;
    font-size: clamp(1.1rem, 1rem + .4vw, 1.3rem); color: var(--ink-soft);
}

.together {
    margin-top: 2rem; padding-left: 1rem;
    border-left: 3px solid var(--berry);
}
.together-main { font-size: clamp(1.15rem, 1.05rem + .5vw, 1.45rem); line-height: 1.45; text-wrap: balance; }
.together-main strong { font-weight: 700; color: var(--berry); }
.together-sub { margin-top: .3rem; color: var(--ink-soft); font-size: .9375rem; }

.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }

.hero-art { position: relative; justify-self: center; width: 100%; max-width: 480px; }
.cats { width: 100%; height: auto; overflow: visible; }
.cats .stroke {
    fill: none; stroke: var(--ink); stroke-width: 3.2;
    stroke-linecap: round; stroke-linejoin: round;
}
.cats .stroke-thin { stroke-width: 2.6; }
.cats .blush { fill: var(--berry); opacity: .22; }
.cats .cats-heart { fill: var(--berry); }
.cats .ground { stroke: var(--line); stroke-width: 2; stroke-linecap: round; stroke-dasharray: 2 9; }

.js .cats .stroke { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.2s var(--ease-out) forwards; }
.js .cats .cat-right .stroke { animation-delay: .25s; }
.js .cats .stroke-thin { animation-duration: .8s; animation-delay: 1.7s; }
.js .cats .blush { opacity: 0; animation: appear-blush .6s ease forwards 2s; }
.js .cats .cats-heart { transform-origin: 200px 214px; animation: heart-in .7s var(--ease-out) both 2.1s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes appear-blush { to { opacity: .22; } }
@keyframes heart-in {
    0%   { opacity: 0; transform: scale(.4); }
    60%  { opacity: 1; transform: scale(1.12); }
    100% { opacity: 1; transform: scale(1); }
}

.stamp {
    position: absolute; right: -2%; top: -14%;
    display: grid; justify-items: center; gap: .1rem;
    width: 132px; padding: .8rem .6rem .7rem;
    background: var(--card); color: var(--ink);
    border: 1.5px dashed var(--berry); border-radius: 10px;
    box-shadow: var(--shadow-sm);
    transform: rotate(4deg);
    text-align: center;
}
.stamp-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--berry); }
.stamp-day { font-family: var(--display); font-size: 1.7rem; line-height: 1.1; }
.stamp-text { font-size: .8125rem; line-height: 1.3; color: var(--ink-soft); }

/* ===== SECCIONES ===== */
.section { padding-block: clamp(3.5rem, 8vw, 6.5rem); }
.section-alt { background: var(--paper-2); }

.section-head {
    display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
    gap: 1rem 2rem; margin-bottom: clamp(2rem, 4vw, 3rem);
}
.section-head-center { justify-content: center; text-align: center; }
.section-title {
    font-family: var(--display); font-weight: 400;
    font-size: clamp(2rem, 1.3rem + 2.6vw, 3.2rem);
    line-height: 1.08; letter-spacing: -.015em;
}
.section-desc { margin-top: .5rem; color: var(--ink-soft); max-width: 46ch; }

.empty {
    display: grid; justify-items: center; gap: 1rem;
    padding: 2.5rem 1.5rem; text-align: center;
    border: 1.5px dashed var(--line); border-radius: var(--radius-lg);
    color: var(--ink-soft);
}

/* Herramientas de cada elemento (editar / eliminar) */
.item-tools { display: flex; gap: .15rem; }
.item-tools .icon-btn { width: 40px; height: 40px; color: var(--ink-soft); }
.item-tools .icon-btn:hover { color: var(--ink); }
.item-tools .icon-btn[data-action="delete"]:hover { color: var(--berry); }

/* ===== FOTOS ===== */
.photos {
    display: grid; gap: clamp(1rem, 2.5vw, 2rem);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
    align-items: start;
}
.photo {
    position: relative;
    padding: .7rem .7rem 0;
    background: var(--card);
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
    transform: rotate(var(--tilt, 0deg));
    transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out);
}
.photo:nth-child(3n+1) { --tilt: -1.4deg; }
.photo:nth-child(3n+2) { --tilt: 1deg; }
.photo:nth-child(3n)   { --tilt: -.5deg; }
.photo:hover, .photo:focus-within { transform: rotate(0deg) translateY(-4px); box-shadow: var(--shadow-md); }

.photo-open {
    display: block; width: 100%; padding: 0; border: 0;
    background: var(--paper-2); border-radius: 2px; overflow: hidden;
    aspect-ratio: 4 / 5; cursor: zoom-in;
}
.photo-open img { width: 100%; height: 100%; object-fit: cover; }
.photo-missing {
    display: grid; place-content: center; gap: .4rem;
    height: 100%; padding: 1rem; text-align: center;
    color: var(--ink-soft); font-size: .875rem; cursor: default;
}
.photo-missing .icon { width: 2rem; height: 2rem; margin-inline: auto; opacity: .5; }

.photo-caption {
    display: flex; align-items: flex-start; justify-content: space-between; gap: .25rem;
    min-height: 3.6rem; padding: .45rem .1rem .35rem .2rem;
}
.photo-caption p {
    font-family: var(--hand); font-weight: 500; font-size: 1.35rem; line-height: 1.15;
    color: var(--ink); padding-top: .35rem;
}
.photo .item-tools { margin-top: .1rem; }

/* ===== RECUERDOS (línea de tiempo) ===== */
.timeline { position: relative; display: grid; gap: clamp(1.5rem, 3vw, 2.5rem); }
.timeline::before {
    content: ''; position: absolute; top: 8px; bottom: 8px;
    left: calc(9.5rem + 1.5rem + 21px);
    border-left: 2px dashed var(--line);
}
.moment {
    display: grid; grid-template-columns: 9.5rem 44px minmax(0, 1fr);
    column-gap: 1.5rem; align-items: start;
}
.moment-date {
    padding-top: .55rem; text-align: right;
    font-weight: 700; font-size: .875rem; color: var(--berry); line-height: 1.35;
}
.moment-icon {
    position: relative; z-index: 1;
    display: grid; place-items: center;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--card); border: 2px solid var(--ink);
    font-size: 1.2rem; line-height: 1;
}
.moment-body {
    background: var(--card); border-radius: var(--radius);
    padding: 1.1rem 1.25rem 1rem; box-shadow: var(--shadow-sm);
}
.moment-title { font-family: var(--display); font-weight: 400; font-size: 1.35rem; line-height: 1.25; }
.moment-text { margin-top: .4rem; color: var(--ink-soft); white-space: pre-line; }
.moment-foot { display: flex; justify-content: flex-end; margin-top: .5rem; margin-right: -.5rem; margin-bottom: -.35rem; }

/* ===== FRASES ===== */
.section-ink { background: var(--invert-bg); color: var(--invert-ink); }
.section-ink .section-desc { color: var(--invert-soft); }
.section-ink .btn-quiet { color: var(--invert-ink); border-color: var(--invert-line); }
.section-ink .btn-quiet:hover { border-color: var(--invert-ink); }
.section-ink .empty { border-color: var(--invert-line); color: var(--invert-soft); }

.phrases { columns: 3 19rem; column-gap: 1.25rem; }
.phrase {
    break-inside: avoid; margin-bottom: 1.25rem;
    padding: 1.5rem 1.5rem 1rem;
    background: var(--invert-card); border-radius: var(--radius-lg);
}
.phrase-quote {
    display: block; height: 2.2rem;
    font-family: var(--display); font-size: 4rem; line-height: 1;
    color: var(--berry);
}
:root:not([data-theme="dark"]) .section-ink .phrase-quote { color: #FF8FA3; }
.phrase-text {
    font-family: var(--display); font-size: clamp(1.15rem, 1.05rem + .35vw, 1.35rem);
    line-height: 1.45; white-space: pre-line;
}
.phrase-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: 1rem; }
.phrase-author { font-size: .9375rem; color: var(--invert-soft); }
.phrase .item-tools { margin-right: -.6rem; }
.phrase .item-tools .icon-btn { color: var(--invert-soft); }
.phrase .item-tools .icon-btn:hover { color: var(--invert-ink); }

/* ===== CARTA ===== */
.letter { display: grid; justify-items: center; }

.envelope {
    position: relative; width: min(520px, 100%); aspect-ratio: 16 / 10.5;
    margin-top: .5rem;
}
.envelope-back {
    position: absolute; inset: 0; border-radius: 10px;
    background:
        linear-gradient(to top right, transparent 49.6%, color-mix(in srgb, var(--ink) 7%, transparent) 50%, transparent 50.4%) left bottom / 50% 62% no-repeat,
        linear-gradient(to top left,  transparent 49.6%, color-mix(in srgb, var(--ink) 7%, transparent) 50%, transparent 50.4%) right bottom / 50% 62% no-repeat,
        var(--card);
    box-shadow: var(--shadow-md);
}
.envelope-flap {
    position: absolute; left: 0; right: 0; top: 0; height: 58%;
    background: var(--paper-2);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    border-radius: 10px 10px 0 0;
    filter: drop-shadow(0 2px 0 var(--line));
}
.seal {
    position: absolute; left: 50%; top: 58%;
    display: grid; place-items: center;
    width: 76px; height: 76px; margin: -38px 0 0 -38px;
    border: 0; border-radius: 50%;
    background: var(--berry); color: var(--on-berry);
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--berry) 22%, transparent), var(--shadow-sm);
    transition: transform .3s var(--ease-out), box-shadow .3s ease;
}
.seal svg { width: 32px; height: 32px; }
.seal:hover { transform: scale(1.06); box-shadow: 0 0 0 10px color-mix(in srgb, var(--berry) 18%, transparent), var(--shadow-md); }
.envelope-hint {
    position: absolute; left: 0; right: 0; bottom: 9%;
    text-align: center; font-family: var(--hand); font-size: 1.45rem; color: var(--ink-soft);
}

.sheet {
    position: relative; width: min(680px, 100%);
    padding: clamp(1.75rem, 5vw, 3.25rem) clamp(1.25rem, 5vw, 3.5rem) 1.5rem;
    background:
        linear-gradient(to right, transparent calc(clamp(1.25rem, 5vw, 3.5rem) - 14px), color-mix(in srgb, var(--berry) 30%, transparent) calc(clamp(1.25rem, 5vw, 3.5rem) - 14px), color-mix(in srgb, var(--berry) 30%, transparent) calc(clamp(1.25rem, 5vw, 3.5rem) - 12px), transparent calc(clamp(1.25rem, 5vw, 3.5rem) - 12px)),
        repeating-linear-gradient(to bottom, transparent 0, transparent calc(2.25rem - 1px), color-mix(in srgb, var(--lilac) 45%, transparent) calc(2.25rem - 1px), color-mix(in srgb, var(--lilac) 45%, transparent) 2.25rem),
        var(--card);
    background-position: 0 0, 0 clamp(1.75rem, 5vw, 3.25rem), 0 0;
    border-radius: 6px;
    box-shadow: var(--shadow-md);
}
.sheet-text {
    font-family: var(--hand); font-weight: 500;
    font-size: clamp(1.45rem, 1.25rem + .7vw, 1.7rem);
    line-height: 2.25rem; white-space: pre-line; color: var(--ink);
}
.sheet-sign {
    margin-top: 2.25rem; text-align: right;
    font-family: var(--hand); font-weight: 700; font-size: 2rem; line-height: 2.25rem; color: var(--berry);
}
.sheet .btn-text { display: flex; margin: 1.5rem auto 0; }

.letter[data-open="true"] .envelope { display: none; }
.js .letter[data-open="true"] .sheet { animation: unfold .7s var(--ease-out); }
@keyframes unfold {
    from { opacity: 0; transform: translateY(24px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

/* ===== PIE ===== */
.footer {
    border-top: 1px solid var(--line);
    padding-block: clamp(2.5rem, 6vw, 4rem);
}
.footer-inner {
    display: grid; grid-template-columns: 1fr minmax(0, 1.3fr);
    gap: 2rem 4rem; align-items: start;
}
.footer-love { display: flex; align-items: center; gap: .75rem; font-family: var(--display); font-size: 1.2rem; }
.footer-mark { width: 40px; height: 40px; }
.backup-title { font-family: var(--display); font-weight: 400; font-size: 1.3rem; }
.backup-text { margin-top: .4rem; color: var(--ink-soft); font-size: .9375rem; max-width: 54ch; }
.backup-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }

/* ===== REPRODUCTOR ===== */
.player {
    position: fixed; z-index: 150;
    left: 50%; bottom: calc(14px + env(safe-area-inset-bottom));
    width: min(860px, calc(100% - 28px));
    transform: translateX(-50%);
    display: grid; align-items: center; column-gap: .9rem;
    grid-template-columns: 52px minmax(0, 1fr) auto minmax(150px, 1.2fr) auto;
    grid-template-areas: "cover meta controls progress extra";
    min-height: var(--player-h);
    padding: .75rem .9rem;
    background: var(--ink); color: var(--paper);
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 40px rgba(23,15,34,.32);
    transition: width .35s var(--ease-out), padding .35s var(--ease-out), border-radius .35s var(--ease-out);
}
:root[data-theme="dark"] .player { background: #2C2040; color: var(--ink); border: 1px solid var(--line); }

.player-cover {
    grid-area: cover;
    position: relative; display: grid; place-items: center;
    width: 52px; height: 52px; padding: 0; border: 0; border-radius: 10px; overflow: hidden;
    background: color-mix(in srgb, currentColor 14%, transparent); color: inherit;
    cursor: default;
}
.player-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.player.is-playing .player-cover::after {
    content: ''; position: absolute; inset: 0; border-radius: inherit;
    box-shadow: inset 0 0 0 2px var(--berry);
}
.player-meta { grid-area: meta; min-width: 0; }
.player-title, .player-artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-title { font-weight: 700; font-size: .9375rem; line-height: 1.3; }
.player-artist { font-size: .8125rem; opacity: .75; line-height: 1.3; }

.player-controls { grid-area: controls; display: flex; align-items: center; gap: .1rem; }
.player .play-btn { width: 48px; height: 48px; background: var(--paper); color: var(--ink); }
.player .play-btn:hover:not(:disabled) { background: var(--berry); color: #fff; }
:root[data-theme="dark"] .player .play-btn { background: var(--berry); color: var(--on-berry); }
:root[data-theme="dark"] .player .play-btn:hover:not(:disabled) { background: var(--berry-deep); }
.play-btn .icon { width: 22px; height: 22px; }

.player-progress { grid-area: progress; display: flex; align-items: center; gap: .55rem; min-width: 0; }
.player-time { font-size: .75rem; font-variant-numeric: tabular-nums; opacity: .75; min-width: 2.4em; text-align: center; }

.player-extra { grid-area: extra; display: flex; align-items: center; gap: .1rem; }

/* Controles deslizantes */
.range {
    --fill: 0%;
    -webkit-appearance: none; appearance: none;
    flex: 1; min-width: 0; height: 28px; background: transparent; cursor: pointer;
}
.range:disabled { cursor: default; opacity: .5; }
.range::-webkit-slider-runnable-track {
    height: 4px; border-radius: 4px;
    background: linear-gradient(to right, var(--berry) var(--fill), color-mix(in srgb, currentColor 22%, transparent) var(--fill));
}
.range::-moz-range-track { height: 4px; border-radius: 4px; background: color-mix(in srgb, currentColor 22%, transparent); }
.range::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--berry); }
.range::-webkit-slider-thumb {
    -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px;
    border-radius: 50%; background: currentColor; border: 0;
    transition: transform .15s ease;
}
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: currentColor; border: 0; }
.range:hover::-webkit-slider-thumb, .range:focus-visible::-webkit-slider-thumb { transform: scale(1.25); }
.range:focus-visible { outline-offset: 0; }
.volume { flex: 0 0 84px; width: 84px; }

.playlist {
    position: absolute; right: .75rem; bottom: calc(100% + 10px);
    width: min(340px, calc(100vw - 40px));
    padding: .75rem; border-radius: var(--radius);
    background: var(--card); color: var(--ink);
    border: 1px solid var(--line); box-shadow: var(--shadow-md);
}
.playlist-title { padding: .25rem .5rem .5rem; font-size: .8125rem; font-weight: 700; color: var(--ink-soft); }
.playlist-items { display: grid; gap: .15rem; }
.playlist-item {
    display: grid; grid-template-columns: 40px minmax(0,1fr); align-items: center; gap: .7rem;
    width: 100%; padding: .4rem .5rem; border: 0; border-radius: 10px;
    background: transparent; text-align: left;
}
.playlist-item:hover { background: var(--paper-2); }
.playlist-item[aria-current="true"] { background: var(--paper-2); }
.playlist-item img, .playlist-item .pl-ph { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--paper-2); }
.playlist-item strong, .playlist-item small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playlist-item strong { font-size: .9375rem; }
.playlist-item small { font-size: .8125rem; color: var(--ink-soft); }
.playlist-item[aria-current="true"] strong { color: var(--berry); }

/* Reproductor minimizado */
.player.is-min {
    left: auto; right: calc(14px + env(safe-area-inset-right)); transform: none;
    width: auto; min-height: 0; padding: 6px;
    grid-template-columns: 52px; grid-template-areas: "cover";
    border-radius: 16px;
}
.player.is-min > :not(.player-cover) { display: none; }
.player.is-min .player-cover { cursor: pointer; }
body.player-min { padding-bottom: 2rem; }

/* ===== EDITOR (diálogo) ===== */
.sheet-dialog {
    width: min(540px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
    margin: auto; padding: 0; border: 0; border-radius: var(--radius-lg);
    background: var(--card); color: var(--ink);
    box-shadow: 0 30px 80px rgba(23,15,34,.35);
    overflow: auto; overscroll-behavior: contain;
}
.sheet-dialog::backdrop { background: rgba(23,15,34,.55); backdrop-filter: blur(3px); }
.sheet-dialog[open] { animation: dialog-in .28s var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }

.editor { display: grid; }
.editor-head {
    position: sticky; top: 0; z-index: 1;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem 1rem .5rem 1.5rem; background: var(--card);
}
.editor-title { font-family: var(--display); font-weight: 400; font-size: 1.5rem; }
.editor-body { display: grid; gap: 1.15rem; padding: .5rem 1.5rem 1rem; }
.editor-actions {
    position: sticky; bottom: 0;
    display: flex; justify-content: flex-end; gap: .6rem;
    padding: 1rem 1.5rem calc(1.25rem + env(safe-area-inset-bottom));
    background: var(--card); border-top: 1px solid var(--line);
}

.field { display: grid; gap: .35rem; }
.field-label { font-weight: 700; font-size: .9375rem; }
.field-label .opt { font-weight: 400; color: var(--ink-soft); }
.field-help { font-size: .8125rem; color: var(--ink-soft); line-height: 1.45; }
.field-row { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; }
.field-count { font-size: .75rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.field-error { display: none; font-size: .875rem; font-weight: 700; color: var(--berry); }
.field.has-error .field-error { display: block; }
.input {
    width: 100%; min-height: 48px; padding: .7rem .9rem;
    background: var(--paper); color: var(--ink);
    border: 1.5px solid var(--line); border-radius: 12px;
    transition: border-color .2s ease, box-shadow .2s ease;
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.input::placeholder { color: color-mix(in srgb, var(--ink-soft) 75%, transparent); }
.input:hover { border-color: color-mix(in srgb, var(--ink) 40%, var(--line)); }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.field.has-error .input { border-color: var(--berry); }

.inline-link {
    justify-self: start; padding: .2rem 0; border: 0; background: none;
    color: var(--berry); font-weight: 700; font-size: .875rem;
    text-decoration: underline; text-underline-offset: .2em;
}

.source-switch { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; padding: .3rem; border-radius: 14px; background: var(--paper-2); }
.source-switch label {
    position: relative; display: grid; place-items: center; min-height: 42px; padding: 0 .5rem;
    border-radius: 10px; font-weight: 700; font-size: .875rem; color: var(--ink-soft); cursor: pointer; text-align: center;
}
.source-switch input { position: absolute; opacity: 0; pointer-events: none; }
.source-switch label:has(input:checked) { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.source-switch label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 1px; }

.file-drop {
    display: grid; justify-items: center; gap: .3rem; padding: 1.25rem; text-align: center;
    border: 1.5px dashed var(--line); border-radius: 14px; cursor: pointer;
    transition: border-color .2s ease, background-color .2s ease;
}
.file-drop:hover, .file-drop.is-over { border-color: var(--berry); background: color-mix(in srgb, var(--berry) 6%, transparent); }
.file-drop strong { color: var(--berry); }
.file-drop span { font-size: .8125rem; color: var(--ink-soft); }
.file-drop:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.preview {
    display: grid; place-items: center; min-height: 140px; max-height: 260px; overflow: hidden;
    border-radius: 12px; background: var(--paper-2); color: var(--ink-soft); font-size: .875rem; text-align: center;
}
.preview img { width: 100%; max-height: 260px; object-fit: contain; }
.preview p { padding: 1rem; }

.emoji-pick { display: flex; flex-wrap: wrap; gap: .4rem; border: 0; padding: 0; }
.emoji-pick legend { padding: 0; margin-bottom: .35rem; font-weight: 700; font-size: .9375rem; }
.emoji-pick label { position: relative; }
.emoji-pick input { position: absolute; opacity: 0; pointer-events: none; }
.emoji-pick span {
    display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
    border: 1.5px solid var(--line); font-size: 1.3rem; cursor: pointer; background: var(--paper);
    transition: border-color .15s ease, transform .15s ease;
}
.emoji-pick span:hover { border-color: var(--ink-soft); }
.emoji-pick input:checked + span { border-color: var(--berry); background: color-mix(in srgb, var(--berry) 12%, var(--paper)); transform: scale(1.05); }
.emoji-pick input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ===== VISOR DE FOTOS ===== */
.lightbox {
    width: 100%; height: 100%; max-width: none; max-height: none;
    margin: 0; padding: 0; border: 0;
    background: rgba(18,11,26,.94); color: #F7EEF1;
}
.lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); animation: fade-in .25s ease; }
.lightbox::backdrop { background: transparent; }
@keyframes fade-in { from { opacity: 0; } }
.lightbox-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: max(.75rem, env(safe-area-inset-top)) 1rem .5rem 1.25rem;
}
.lightbox-count { font-size: .875rem; font-variant-numeric: tabular-nums; opacity: .8; }
.lightbox-figure {
    display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; align-items: center;
    gap: .9rem; min-height: 0; padding: 0 clamp(1rem, 8vw, 6rem) calc(1.5rem + env(safe-area-inset-bottom));
    touch-action: pan-y;
}
.lightbox-figure img {
    max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain; border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5); user-select: none; -webkit-user-drag: none;
}
.lightbox-figure figcaption { font-family: var(--hand); font-size: 1.6rem; line-height: 1.2; text-align: center; max-width: 40ch; }
.lightbox-nav {
    position: fixed; top: 50%; margin-top: -26px;
    width: 52px; height: 52px; background: rgba(255,255,255,.1);
}
.lightbox-nav:hover:not(:disabled) { background: rgba(255,255,255,.2); }
.lightbox-prev { left: max(.75rem, env(safe-area-inset-left)); }
.lightbox-next { right: max(.75rem, env(safe-area-inset-right)); }
.lightbox .icon-btn { color: #F7EEF1; }

/* ===== AVISOS ===== */
.toast {
    position: fixed; z-index: 400; left: 50%;
    bottom: calc(var(--player-h) + 30px + env(safe-area-inset-bottom));
    display: flex; align-items: center; gap: 1rem;
    width: max-content; max-width: calc(100% - 28px);
    padding: .75rem .75rem .75rem 1.1rem; border-radius: 14px;
    background: var(--ink); color: var(--paper);
    box-shadow: var(--shadow-md);
    font-size: .9375rem; line-height: 1.4;
    opacity: 0; visibility: hidden; transform: translate(-50%, 12px);
    transition: opacity .25s ease, transform .25s var(--ease-out), visibility 0s linear .25s;
}
:root[data-theme="dark"] .toast { background: #F4E9F0; color: #26173A; }
.toast.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.toast.is-warn { box-shadow: inset 4px 0 0 var(--berry), var(--shadow-md); }
.toast-action {
    flex-shrink: 0; min-height: 36px; padding: 0 .8rem; border: 0; border-radius: 999px;
    background: color-mix(in srgb, currentColor 14%, transparent); font-weight: 700; font-size: .875rem;
}
.toast-action:hover { background: color-mix(in srgb, currentColor 24%, transparent); }
body.player-min .toast { bottom: calc(90px + env(safe-area-inset-bottom)); }

.noscript { position: fixed; left: 12px; right: 12px; bottom: 12px; padding: 1rem; border-radius: 12px; background: var(--ink); color: var(--paper); text-align: center; }

/* ===== APARICIÓN AL DESPLAZAR ===== */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease-out), transform .7s var(--ease-out); transition-delay: var(--delay, 0ms); }
.js .reveal.is-in { opacity: 1; transform: none; }
.js .photo.reveal.is-in { transform: rotate(var(--tilt, 0deg)); }
.js .photo.reveal.is-in:hover, .js .photo.reveal.is-in:focus-within { transform: rotate(0deg) translateY(-4px); }

/* ===== RESPONSIVO ===== */
@media (hover: none) {
    .photo:hover { transform: rotate(var(--tilt, 0deg)); box-shadow: var(--shadow-sm); }
}

@media (max-width: 960px) {
    .player {
        grid-template-columns: 48px minmax(0, 1fr) auto auto;
        grid-template-areas:
            "cover meta controls extra"
            "progress progress progress progress";
        row-gap: .2rem;
    }
    .player-cover { width: 48px; height: 48px; }
    :root { --player-h: 112px; }
}

@media (max-width: 820px) {
    .hero { grid-template-columns: 1fr; min-height: 0; padding-top: 1.5rem; }
    .hero-art { order: -1; max-width: 340px; }
    .stamp {
        position: static; width: max-content; max-width: 100%;
        grid-template-columns: auto auto; column-gap: .8rem; align-items: center; justify-items: start;
        margin: .25rem auto 0; padding: .6rem 1rem; text-align: left;
        transform: rotate(-1.5deg);
    }
    .stamp-label { grid-column: 1 / -1; }
    .stamp-day { font-size: 1.45rem; }
    .footer-inner { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    :root { --topbar-h: 58px; }
    .menu-btn { display: inline-flex; }
    .nav { margin-left: auto; }
    .nav-list {
        position: absolute; top: 100%; left: 0; right: 0;
        display: grid; gap: .15rem; padding: .5rem var(--gutter) 1rem;
        background: var(--paper); border-bottom: 1px solid var(--line);
        box-shadow: 0 14px 30px rgba(23,15,34,.12);
        visibility: hidden; opacity: 0; transform: translateY(-8px);
        transition: opacity .2s ease, transform .2s var(--ease-out), visibility 0s linear .2s;
    }
    .nav-list.is-open { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }
    .nav-list a { padding: .85rem 1rem; font-size: 1.0625rem; border-radius: 12px; }

    .timeline::before { left: 21px; }
    .moment { grid-template-columns: 44px minmax(0, 1fr); column-gap: 1rem; row-gap: .35rem; }
    .moment-icon { grid-column: 1; grid-row: 1 / span 2; }
    .moment-date { grid-column: 2; grid-row: 1; text-align: left; padding-top: .7rem; }
    .moment-body { grid-column: 2; grid-row: 2; }

    .section-head { align-items: flex-start; }
}

@media (max-width: 600px) {
    body { font-size: 1rem; }
    .player {
        bottom: calc(8px + env(safe-area-inset-bottom));
        width: calc(100% - 16px);
        grid-template-columns: 44px minmax(0, 1fr) auto auto;
        column-gap: .5rem; row-gap: 0; padding: .55rem .4rem .2rem .6rem; border-radius: 18px;
    }
    .player-cover { width: 44px; height: 44px; }
    .player-extra #mpMute, .player-extra .volume { display: none; }
    .player-extra .icon-btn { width: 38px; height: 44px; }
    .player-controls #mpPrev { display: none; }
    .player-controls .icon-btn:not(.play-btn) { width: 38px; }
    .player .play-btn { width: 44px; height: 44px; }
    .player.is-min { right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); }
    .playlist { right: 0; width: calc(100vw - 16px); }
    :root { --player-h: 96px; }

    .photos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
    .photo { padding: .45rem .45rem 0; }
    .photo-caption { flex-direction: column; min-height: 0; gap: 0; }
    .photo-caption p { font-size: 1.15rem; padding-top: .2rem; }
    .photo .item-tools { margin: 0 0 0 -.4rem; }

    .sheet-dialog {
        width: 100%; max-width: none; max-height: 92dvh;
        margin: auto 0 0; border-radius: 22px 22px 0 0;
    }
    .sheet-dialog[open] { animation-name: sheet-up; }
    @keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
    .editor-actions .btn { flex: 1; }

    .lightbox-nav { top: auto; bottom: calc(1rem + env(safe-area-inset-bottom)); margin-top: 0; }
    .lightbox-figure { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
    .hero-actions .btn { flex: 1 1 auto; }
    .seal { width: 64px; height: 64px; margin: -32px 0 0 -32px; }
    .envelope-hint { font-size: 1.25rem; bottom: 6%; }
}

@media (max-width: 380px) {
    .brand > span { font-size: 1.05rem; }
    .menu-btn span { display: none; }
    .menu-btn { padding: 0 .65rem; }
    .photos { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
    .js .reveal { opacity: 1; transform: none; }
    .js .photo.reveal { transform: rotate(var(--tilt, 0deg)); }
}

@media print {
    .topbar, .player, .toast, .backup, .hero-actions, .item-tools, .section-head .btn { display: none !important; }
    body { padding: 0; background: #fff; color: #000; }
    .letter .envelope { display: none; }
    .letter .sheet { display: block !important; box-shadow: none; }
}
