/* ─────────────────────────────────────────────────────────
   M · A  —  CSS Design System
   Cormorant Garamond (romance) + Montserrat (clarity)
   Color engine: HSL-based, one --h variable shifts all accents
   Base: creamy obsidian. Alive section by section.
───────────────────────────────────────────────────────── */

@layer reset, tokens, base, layout, views, components, animations;

/* ── RESET ──────────────────────────────────────────── */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
  html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
  input, textarea { font: inherit; color: inherit; background: none; border: none; outline: none; }
  ul, ol { list-style: none; }
  img { display: block; width: 100%; height: 100%; object-fit: cover; }
  dialog { border: none; background: none; padding: 0; color: inherit; }
  dialog::backdrop { background: rgba(0,0,0,.65); }
}

/* ── DESIGN TOKENS ──────────────────────────────────── */
@layer tokens {
  :root {
    /* Obsidian base — slightly warm, slightly purple */
    --ink-1: #07060A;
    --ink-2: #0C0A10;
    --ink-3: #111018;
    --ink-4: #161420;

    /* Pearl — the light source in the dark */
    --pearl:    #E8E0D4;
    --pearl-60: rgba(232,224,212,.6);
    --pearl-30: rgba(232,224,212,.3);
    --pearl-12: rgba(232,224,212,.12);
    --pearl-06: rgba(232,224,212,.06);

    /* Text */
    --t-1: #EDE8DF;          /* bright */
    --t-2: rgba(237,232,223,.6);   /* mid */
    --t-3: rgba(237,232,223,.3);   /* dim */

    /* Surfaces */
    --s-1: rgba(255,255,255,.03);
    --s-2: rgba(255,255,255,.055);
    --s-3: rgba(255,255,255,.09);
    --b-1: rgba(232,224,212,.14);  /* border */
    --b-2: rgba(232,224,212,.07);  /* border dim */

    /* Accent engine — everything derives from --h, --s, --l */
    /* Default: crimson for home */
    --h: 350; --s: 72%; --l: 40%;
    --accent:      hsl(var(--h),var(--s),var(--l));
    --accent-hi:   hsl(var(--h),var(--s),calc(var(--l) + 14%));
    --accent-glow: hsla(var(--h),var(--s),var(--l),.38);
    --accent-dim:  hsla(var(--h),var(--s),var(--l),.18);
    --accent-soft: hsla(var(--h),var(--s),var(--l),.07);
    --accent-t:    hsl(var(--h),60%,72%);   /* text on dark bg */

    /* Layout */
    --nav-h:    64px;
    --safe-t:   env(safe-area-inset-top, 0px);
    --safe-b:   env(safe-area-inset-bottom, 0px);
    --r:        16px;
    --r-sm:     10px;
    --r-lg:     22px;

    /* Shadow */
    --shadow:
      0 2px  4px  rgba(0,0,0,.25),
      0 8px  24px rgba(0,0,0,.55),
      0 32px 64px rgba(0,0,0,.7),
      inset 0 1px 0 rgba(255,255,255,.03);

    /* Easing */
    --out:     cubic-bezier(.25,.46,.45,.94);
    --spring:  cubic-bezier(.34,1.56,.64,1);
    --smooth:  cubic-bezier(.4,0,.2,1);
  }

  /* ── Section accent hues ── */
  [data-view="home"]    { --h:350; --s:72%; --l:40%; }
  [data-view="letters"] { --h:348; --s:68%; --l:36%; }
  [data-view="wishes"]  { --h: 40; --s:55%; --l:52%; }
  [data-view="her"]     { --h: 22; --s:60%; --l:48%; }
  [data-view="diaries"] { --h:245; --s:45%; --l:50%; }
  [data-view="games"]   { --h:196; --s:82%; --l:44%; }
  [data-view="media"]   { --h:272; --s:45%; --l:54%; }
}

/* ── BASE ───────────────────────────────────────────── */
@layer base {
  body {
    font-family: 'Montserrat', sans-serif;
    font-weight: 300;
    background: var(--ink-1);
    color: var(--t-1);
    -webkit-font-smoothing: antialiased;
  }

  h1, h2, h3, blockquote, cite, .serif {
    font-family: 'Cormorant Garamond', serif;
  }

  h2 {
    font-size: clamp(1.9rem, 6vw, 2.6rem);
    font-weight: 300;
    color: var(--pearl);
    letter-spacing: .02em;
    padding: 20px 20px 8px;
    flex-shrink: 0;
  }

  .eyebrow {
    font-family: 'Montserrat', sans-serif;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: .32em;
    text-transform: uppercase;
    color: var(--t-3);
  }

  .btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 50px;
    background: var(--accent);
    border-radius: var(--r-sm);
    font-family: 'Montserrat', sans-serif;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--pearl);
    box-shadow: 0 4px 20px var(--accent-glow);
    transition: transform .12s, box-shadow .2s, background .25s;
  }
  .btn-primary:active { transform: scale(.97); }

  .btn-ghost {
    height: 44px;
    padding: 0 20px;
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 300;
    letter-spacing: .08em;
    color: var(--t-2);
    transition: background .2s;
  }
  .btn-ghost:active { background: var(--s-2); }

  .btn-danger {
    height: 44px;
    padding: 0 20px;
    border: 1px solid hsla(0,60%,50%,.3);
    border-radius: var(--r-sm);
    background: hsla(0,60%,50%,.08);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: .08em;
    color: hsl(0,60%,72%);
    transition: background .2s;
  }

  .fab {
    position: absolute;
    bottom: 18px;
    right: 18px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    font-size: 1.6rem;
    color: white;
    box-shadow: 0 6px 24px var(--accent-glow);
    transition: transform .2s var(--spring), box-shadow .2s, background .25s;
    z-index: 10;
  }
  .fab:active { transform: scale(.92); }

  .chip {
    height: 30px;
    padding: 0 14px;
    border: 1px solid var(--b-1);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: .06em;
    color: var(--t-3);
    transition: background .2s, border-color .2s, color .2s;
  }
  .chip.active {
    background: var(--accent-soft);
    border-color: var(--accent-dim);
    color: var(--accent-t);
  }
}

/* ── LAYOUT ─────────────────────────────────────────── */
@layer layout {

  /* The intro and lock sit outside the app */
  #intro-screen,
  #lock-screen {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--ink-1);
    transition: opacity .5s var(--out), transform .5s var(--out);
  }

  #intro-screen.out, #lock-screen.out {
    opacity: 0;
    pointer-events: none;
    transform: scale(.97);
  }

  #intro-screen[hidden], #lock-screen[hidden] { display: none !important; }

  #app {
    position: fixed;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity .4s var(--out);
  }

  #app.ready {
    opacity: 1;
    pointer-events: auto;
  }

  #views {
    position: absolute;
    inset: 0 0 var(--nav-h) 0;
    padding-top: var(--safe-t);
    overflow: hidden;
  }

  /* Each view */
  #views > section {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    transform: translateY(22px);
    transition:
      opacity .46s var(--out),
      transform .46s var(--out),
      visibility 0s .46s;
    /* push accent hue down into children */
    --h: 350; --s: 72%; --l: 40%;
  }

  #views > section::-webkit-scrollbar { display: none; }

  #views > section.active {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition:
      opacity .46s var(--out),
      transform .46s var(--out),
      visibility 0s 0s;
  }

  #views > section.leaving {
    opacity: 0;
    transform: translateY(-14px);
    transition: opacity .3s var(--out), transform .3s var(--out);
  }

  /* View-level accent injection */
  section[data-view="letters"] { --h:348; --s:68%; --l:36%; }
  section[data-view="wishes"]  { --h: 40; --s:55%; --l:52%; }
  section[data-view="her"]     { --h: 22; --s:60%; --l:48%; }
  section[data-view="diaries"] { --h:245; --s:45%; --l:50%; }
  section[data-view="games"]   { --h:196; --s:82%; --l:44%; }
  section[data-view="media"]   { --h:272; --s:45%; --l:54%; }

  #bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    display: flex;
    background: rgba(7,6,10,.9);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border-top: 1px solid var(--b-2);
    z-index: 100;
  }

  #bar > button {
    flex: 1;
    height: var(--nav-h);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--t-3);
    transition: color .22s;
    position: relative;
  }

  #bar > button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform .22s var(--spring);
  }

  #bar > button span {
    font-size: 8.5px;
    font-weight: 400;
    letter-spacing: .06em;
    text-transform: uppercase;
    line-height: 1;
  }

  #bar > button.active {
    color: var(--accent);
  }

  #bar > button.active svg {
    transform: translateY(-1px) scale(1.1);
  }

  /* Active tab underline glow */
  #bar > button.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 1px;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
    border-radius: 0 0 2px 2px;
  }

  /* Per-nav-tab accent colors */
  #bar > button[data-go="letters"].active { --accent: hsl(348,68%,48%); }
  #bar > button[data-go="wishes"].active  { --accent: hsl(40,55%,55%);  }
  #bar > button[data-go="her"].active     { --accent: hsl(22,60%,56%);  }
  #bar > button[data-go="diaries"].active { --accent: hsl(245,45%,58%); }
  #bar > button[data-go="games"].active   { --accent: hsl(196,82%,50%); }
  #bar > button[data-go="media"].active   { --accent: hsl(272,45%,62%); }
}


/* ── VIEWS ──────────────────────────────────────────── */
@layer views {

  /* ── INTRO ── */
  #intro-screen {
    background: radial-gradient(ellipse 70% 50% at 50% 30%, hsla(348,50%,18%,.15), transparent);
    gap: 28px;
  }

  #intro-glyph {
    display: flex;
    align-items: baseline;
    gap: 6px;
    cursor: pointer;
    user-select: none;
  }

  .glyph-m, .glyph-a {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(5rem, 22vw, 9rem);
    font-weight: 300;
    color: var(--pearl);
    line-height: 1;
    transition: letter-spacing .6s var(--out), opacity .4s;
  }

  .glyph-dot {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2rem, 8vw, 4rem);
    color: var(--accent);
    line-height: 1;
    transition: transform .6s var(--spring), color .3s;
    filter: drop-shadow(0 0 8px var(--accent-glow));
  }

  #intro-glyph:active .glyph-m  { letter-spacing: .08em; }
  #intro-glyph:active .glyph-a  { letter-spacing: .08em; }
  #intro-glyph:active .glyph-dot { transform: scale(1.3) rotate(12deg); }

  #intro-sub {
    font-size: 10px;
    font-weight: 300;
    letter-spacing: .3em;
    text-transform: uppercase;
    color: var(--t-3);
    animation: breathe 3s ease-in-out infinite;
  }

  /* ── LOCK ── */
  #lock-screen {
    background:
      radial-gradient(ellipse 60% 40% at 50% 10%, hsla(348,50%,18%,.1), transparent),
      var(--ink-1);
    gap: 32px;
    padding: 40px 32px;
  }

  .lock-wordmark {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: .3em;
    color: var(--t-2);
  }

  #lock-form {
    width: 100%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  #lock-form input {
    height: 50px;
    padding: 0 18px;
    background: var(--s-2);
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 300;
    letter-spacing: .02em;
    transition: border-color .2s, background .2s;
  }

  #lock-form input::placeholder { color: var(--t-3); }
  #lock-form input:focus { border-color: var(--pearl-30); background: var(--s-3); }

  #lock-form button {
    height: 50px;
    background: hsl(348,68%,38%);
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: var(--pearl);
    box-shadow: 0 4px 20px hsla(348,68%,38%,.4);
    transition: transform .12s;
  }
  #lock-form button:active { transform: scale(.97); }

  #lock-err {
    font-size: 12px;
    font-weight: 300;
    letter-spacing: .05em;
    color: hsl(348,68%,70%);
    text-align: center;
    min-height: 18px;
    transition: opacity .2s;
  }

  /* ── HOME ── */
  #home-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    flex-shrink: 0;
  }

  #home-greeting {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.05rem;
    font-style: italic;
    color: var(--t-2);
    flex: 1;
  }

  #home-actions {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  #home-actions > button {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--t-3);
    font-size: 1rem;
    transition: color .2s, background .2s;
    position: relative;
  }

  #home-actions > button svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.6; }
  #home-actions > button:active { background: var(--s-2); color: var(--t-1); }

  #btn-menu svg { fill: var(--t-3); stroke: none; transition: fill .2s; }
  #btn-menu.open svg { fill: var(--accent-t); }

  #notif-pip {
    position: absolute;
    top: 4px; right: 4px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: hsl(348,68%,50%);
    box-shadow: 0 0 6px hsla(348,68%,50%,.6);
  }

  #home-body {
    padding: 0 14px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* Tile = our card */
  .tile {
    background: var(--s-1);
    border: 1px solid var(--b-1);
    border-radius: var(--r);
    padding: 22px 20px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px);
    transition:
      opacity .44s var(--out),
      transform .44s var(--out),
      background .25s;
  }

  .tile.in {
    opacity: 1;
    transform: none;
  }

  /* Stagger via nth-child */
  .tile:nth-child(1) { transition-delay: .04s; }
  .tile:nth-child(2) { transition-delay: .1s; }
  .tile:nth-child(3) { transition-delay: .16s; }
  .tile:nth-child(4) { transition-delay: .22s; }
  .tile:nth-child(5) { transition-delay: .28s; }
  .tile:nth-child(6) { transition-delay: .34s; }
  .tile:nth-child(7) { transition-delay: .40s; }

  /* Thin top accent line */
  .tile::after {
    content: '';
    position: absolute;
    top: 0; left: 25%; right: 25%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-dim), transparent);
    transition: background .25s;
  }

  .tile > small {
    font-family: 'Montserrat', sans-serif;
    font-size: 9.5px;
    font-weight: 400;
    letter-spacing: .28em;
    text-transform: uppercase;
    color: var(--t-3);
    display: block;
    margin-bottom: 10px;
  }

  /* Hero counter */
  .tile--hero { text-align: center; padding: 30px 20px; }
  .tile--hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 60% at 50% 80%, hsla(348,60%,22%,.14), transparent);
  }

  #days-num {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(4rem, 18vw, 6rem);
    font-weight: 300;
    color: var(--pearl);
    line-height: 1;
    display: block;
    margin-bottom: 8px;
    letter-spacing: -.02em;
  }

  .tile--hero > span {
    font-size: 12px;
    font-weight: 300;
    color: var(--t-2);
    letter-spacing: .04em;
  }

  /* Clock */
  .tile--clock { cursor: pointer; }

  .clock-pair {
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .clock-pair > div { flex: 1; }

  .city {
    font-size: 9.5px;
    font-weight: 400;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--t-3);
    margin-bottom: 3px;
  }

  .time {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.9rem;
    font-weight: 300;
    color: var(--pearl);
    letter-spacing: .04em;
  }

  .clock-sep {
    color: var(--t-3);
    font-size: 1.4rem;
    align-self: flex-end;
    padding-bottom: 4px;
  }

  /* Quote */
  .tile--quote blockquote {
    font-size: 1.4rem;
    font-weight: 300;
    font-style: italic;
    color: var(--pearl);
    line-height: 1.5;
    margin-bottom: 8px;
  }

  .tile--quote cite {
    font-size: 11px;
    font-weight: 300;
    font-style: italic;
    color: var(--t-3);
    letter-spacing: .06em;
  }

  /* Anniversary */
  .tile--anniv { text-align: center; }

  #anniv-num {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2.4rem, 10vw, 4rem);
    font-weight: 300;
    color: var(--accent-t);
    display: block;
    line-height: 1;
    margin-bottom: 6px;
    transition: color .25s;
  }

  .tile--anniv > span {
    font-size: 10px;
    font-weight: 300;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--t-3);
  }

  /* Photo of month */
  .tile--photo { padding: 0; }

  .tile--photo figure { display: flex; flex-direction: column; }

  .tile--photo img {
    height: 200px;
    object-position: center;
    display: block;
    border-radius: var(--r) var(--r) 0 0;
  }

  .tile--photo figcaption {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--t-2);
    padding: 12px 18px 16px;
  }

  /* Rhythm */
  .tile--rhythm { cursor: pointer; }

  #rhythm-preview {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--t-2);
  }

  /* Message */
  #time-msg {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.15rem;
    font-style: italic;
    color: var(--t-2);
    line-height: 1.55;
  }


  /* ── LETTERS ── */
  section[data-view="letters"] {
    --accent: hsl(348,68%,38%);
    --accent-glow: hsla(348,68%,38%,.38);
    --accent-dim: hsla(348,68%,38%,.18);
    --accent-soft: hsla(348,68%,38%,.07);
    --accent-t: hsl(348,60%,70%);
  }

  #letter-compose {
    padding: 0 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
  }

  #letter-input {
    width: 100%;
    padding: 16px 18px;
    background: var(--s-2);
    border: 1px solid var(--b-1);
    border-radius: var(--r);
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.05rem;
    font-style: italic;
    line-height: 1.8;
    resize: none;
    color: var(--t-1);
    min-height: 110px;
    transition: border-color .2s, background .2s;
  }

  #letter-input::placeholder { color: var(--t-3); font-style: italic; }
  #letter-input:focus { border-color: var(--accent-dim); background: var(--s-3); }

  #letters-feed {
    padding: 0 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .letter-card {
    background: var(--s-1);
    border: 1px solid var(--b-1);
    border-radius: var(--r);
    overflow: hidden;
    box-shadow: var(--shadow);
    animation: rise .4s var(--out) both;
  }

  .letter-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 18px;
    border-bottom: 1px solid var(--b-2);
  }

  .letter-from {
    font-size: 10px;
    font-weight: 400;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--t-3);
  }

  .letter-date { font-size: 11px; color: var(--t-3); }

  .letter-seal-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px 18px;
    gap: 8px;
  }

  .letter-seal-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
  }

  .seal-svg {
    width: 78px;
    height: 78px;
    filter: drop-shadow(0 4px 14px var(--accent-glow));
    transition: filter .3s;
  }

  .seal-wax {
    fill: var(--accent);
    transition: fill .4s;
  }

  .seal-initial {
    font-family: 'Cormorant Garamond', serif;
    font-size: 28px;
    font-style: italic;
    fill: rgba(255,255,255,.9);
    pointer-events: none;
  }

  .crack {
    stroke: rgba(255,255,255,.45);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-dasharray: 32;
    stroke-dashoffset: 32;
    transition: stroke-dashoffset .5s ease .15s;
  }

  .seal-svg.cracked .seal-wax { fill: var(--ink-3); }
  .seal-svg.cracked .crack { stroke-dashoffset: 0; }

  .seal-hint {
    font-size: 9.5px;
    font-weight: 300;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--t-3);
  }

  .letter-body {
    padding: 0 20px 20px;
    animation: rise .35s var(--out) both;
  }

  .letter-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.05rem;
    font-style: italic;
    line-height: 1.85;
    color: var(--t-2);
    white-space: pre-wrap;
  }

  .letter-opened-note {
    font-size: 10px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--t-3);
    text-align: center;
    padding: 10px 18px;
  }

  /* ── WISHES ── */
  section[data-view="wishes"] {
    --accent: hsl(40,55%,52%);
    --accent-glow: hsla(40,55%,52%,.38);
    --accent-dim: hsla(40,55%,52%,.18);
    --accent-soft: hsla(40,55%,52%,.07);
    --accent-t: hsl(40,55%,68%);
  }

  #wish-bar {
    padding: 0 16px 16px;
    flex-shrink: 0;
  }

  #wish-author-label {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--t-3);
    margin-bottom: 10px;
  }

  #wish-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 12px;
  }

  #wish-text {
    flex: 1;
    padding: 12px 15px;
    background: var(--s-2);
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    font-style: italic;
    line-height: 1.6;
    resize: none;
    color: var(--t-1);
    transition: border-color .2s;
  }

  #wish-text::placeholder { color: var(--t-3); }
  #wish-text:focus { border-color: var(--accent-dim); }

  #wish-add {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    background: var(--accent);
    border-radius: var(--r-sm);
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
    transition: transform .12s;
  }
  #wish-add:active { transform: scale(.92); }

  #wish-filters { display: flex; gap: 7px; }

  #wishes-list {
    padding: 0 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .wish-item {
    padding: 13px 16px;
    background: var(--s-1);
    border: 1px solid var(--b-1);
    border-left: 2px solid var(--accent-dim);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    animation: rise .35s var(--out) both;
    transition: border-color .25s;
  }

  .wish-item.ma  { border-left-color: hsla(40,55%,52%,.4); }
  .wish-item.man { border-left-color: hsla(348,68%,38%,.4); }

  .wish-body {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    font-style: italic;
    color: var(--t-2);
    line-height: 1.6;
    margin-bottom: 6px;
  }

  .wish-meta {
    font-size: 10px;
    font-weight: 300;
    letter-spacing: .1em;
    color: var(--t-3);
  }

  /* ── HER ── */
  section[data-view="her"] {
    --accent: hsl(22,60%,48%);
    --accent-glow: hsla(22,60%,48%,.38);
    overflow-y: auto;
  }

  #her-banner {
    height: 270px;
    background: var(--ink-3);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    position: relative;
  }

  #her-banner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(7,6,10,.2) 0%, transparent 40%, rgba(7,6,10,.5) 100%);
  }

  #her-banner-change {
    position: absolute;
    top: calc(var(--safe-t) + 12px);
    right: 14px;
    z-index: 2;
    font-size: 10.5px;
    font-weight: 400;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--t-3);
    padding: 6px 12px;
    border: 1px solid var(--b-2);
    border-radius: 20px;
    background: rgba(7,6,10,.5);
    backdrop-filter: blur(8px);
  }

  #her-stripes {
    display: flex;
    height: 120px;
    border-top: 1px solid var(--b-2);
    flex-shrink: 0;
  }

  .stripe {
    flex: 1;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    overflow: hidden;
    border-right: 1px solid var(--b-2);
    transition: flex .3s var(--out);
  }

  .stripe:last-child { border-right: none; }
  .stripe:active { flex: 1.3; }

  #her-body-tile {
    height: 160px;
    border-top: 1px solid var(--b-2);
    border-right: none;
    flex-shrink: 0;
  }

  .stripe-img {
    flex: 1;
    background: var(--ink-3);
    background-size: cover;
    background-position: center;
  }

  .stripe > span {
    flex-shrink: 0;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8.5px;
    font-weight: 400;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--t-3);
    border-top: 1px solid var(--b-2);
    background: var(--ink-2);
  }

  /* ── DIARIES ── */
  section[data-view="diaries"] {
    --accent: hsl(245,45%,50%);
    --accent-glow: hsla(245,45%,50%,.38);
    --accent-dim: hsla(245,45%,50%,.18);
    --accent-soft: hsla(245,45%,50%,.07);
    --accent-t: hsl(245,45%,72%);
  }

  #diary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    padding: 4px 14px 80px;
  }

  .diary-card {
    background: var(--s-1);
    border: 1px solid var(--b-1);
    border-radius: var(--r);
    padding: 16px 15px;
    cursor: pointer;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    box-shadow: var(--shadow);
    animation: rise .4s var(--out) both;
    position: relative;
    overflow: hidden;
    transition: transform .2s var(--out);
  }

  .diary-card:active { transform: scale(.97); }

  .diary-card::before {
    content: '';
    position: absolute;
    left: 0; top: 18%; bottom: 18%;
    width: 2px;
    background: var(--accent-dim);
    border-radius: 1px;
  }

  .dc-num {
    font-family: 'Cormorant Garamond', serif;
    font-size: .75rem;
    font-style: italic;
    color: var(--t-3);
    letter-spacing: .15em;
  }

  .dc-icon { font-size: .95rem; }

  .dc-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    font-weight: 400;
    color: var(--pearl);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .dc-attr {
    font-size: 10px;
    font-weight: 300;
    font-style: italic;
    color: var(--t-3);
    margin-top: auto;
  }

  /* ── GAMES ── */
  section[data-view="games"] {
    --accent: hsl(196,82%,44%);
    --accent-glow: hsla(196,82%,44%,.38);
    --accent-dim: hsla(196,82%,44%,.18);
    --accent-soft: hsla(196,82%,44%,.07);
    --accent-t: hsl(196,82%,62%);
  }

  #games-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 8px 16px 24px;
    flex: 1;
  }

  #mode-toggle { display: flex; gap: 0; border: 1px solid var(--b-1); border-radius: var(--r-sm); overflow: hidden; }
  #mode-toggle .chip { border: none; border-radius: 0; height: 36px; }

  #pong-hint {
    font-size: 11px;
    font-weight: 300;
    letter-spacing: .1em;
    color: var(--t-3);
  }

  #pong {
    width: 100%;
    max-width: 380px;
    height: auto;
    display: block;
    background: var(--ink-2);
    border: 1px solid var(--b-1);
    border-radius: var(--r);
    box-shadow: var(--shadow);
  }

  #pong-play { max-width: 260px; }

  /* ── MEDIA ── */
  section[data-view="media"] {
    --accent: hsl(272,45%,54%);
    --accent-glow: hsla(272,45%,54%,.38);
    --accent-dim: hsla(272,45%,54%,.18);
    --accent-soft: hsla(272,45%,54%,.07);
    --accent-t: hsl(272,45%,72%);
  }

  section[data-view="media"] .eyebrow { padding: 20px 20px 0; }

  #media-tabs {
    display: flex;
    padding: 8px 16px 0;
    border-bottom: 1px solid var(--b-2);
    flex-shrink: 0;
    gap: 0;
  }

  #media-tabs button {
    flex: 1;
    height: 36px;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--t-3);
    border-bottom: 2px solid transparent;
    transition: color .2s, border-color .2s;
  }

  #media-tabs button.active {
    color: var(--accent-t);
    border-bottom-color: var(--accent);
  }

  #media-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px 14px 80px;
  }

  .media-thumb {
    position: relative;
    aspect-ratio: 1;
    background: var(--ink-3);
    border-radius: var(--r-sm);
    overflow: hidden;
    cursor: pointer;
    animation: rise .35s var(--out) both;
  }

  .media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s;
  }

  .media-thumb:active img { transform: scale(1.04); }

  .media-thumb-caption {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 20px 10px 8px;
    background: linear-gradient(transparent, rgba(7,6,10,.8));
    font-family: 'Cormorant Garamond', serif;
    font-size: .85rem;
    font-style: italic;
    color: var(--t-2);
  }

  .media-delete {
    position: absolute;
    top: 6px; right: 6px;
    width: 26px; height: 26px;
    background: rgba(7,6,10,.7);
    border-radius: 50%;
    font-size: 11px;
    color: var(--t-3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .2s;
  }

  .media-thumb:hover .media-delete { opacity: 1; }

  .audio-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--s-1);
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    animation: rise .35s var(--out) both;
  }

  .audio-play {
    font-size: 11px;
    font-weight: 400;
    letter-spacing: .1em;
    color: var(--accent-t);
    padding: 6px 12px;
    border: 1px solid var(--accent-dim);
    border-radius: 20px;
    flex-shrink: 0;
  }

  .audio-name {
    flex: 1;
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: .95rem;
    color: var(--t-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}


/* ── COMPONENTS ─────────────────────────────────────── */
@layer components {

  /* Panels */
  .panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-height: 92dvh;
    background: var(--ink-2);
    border-top: 1px solid var(--b-1);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: 0 -24px 64px rgba(0,0,0,.6);
    z-index: 300;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform .38s var(--out);
    overflow: hidden;
  }

  .panel[hidden] { display: flex !important; }  /* keep in DOM for animation */
  .panel.open { transform: none; }

  .panel--full { height: 92dvh; }
  .panel--bare { background: var(--ink-1); border-radius: 0; max-height: 100dvh; height: 100dvh; }

  .panel-pull {
    width: 34px; height: 4px;
    background: var(--b-1);
    border-radius: 2px;
    margin: 10px auto;
    flex-shrink: 0;
  }

  .panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--b-2);
    flex-shrink: 0;
  }

  .panel-head button {
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--t-3);
    border-radius: 50%;
    font-size: 14px;
    transition: color .2s, background .2s;
  }

  .panel-head button:active { background: var(--s-2); color: var(--t-1); }

  .panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 18px 40px;
  }

  .panel-body::-webkit-scrollbar { display: none; }

  .panel-body--form {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .panel-body--form label {
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .panel-body--form label > span {
    font-size: 9.5px;
    font-weight: 400;
    letter-spacing: .28em;
    text-transform: uppercase;
    color: var(--t-3);
  }

  .panel-body--form input,
  .panel-body--form textarea {
    padding: 13px 15px;
    background: var(--s-2);
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 300;
    color: var(--t-1);
    transition: border-color .2s;
  }

  .panel-body--form input::placeholder,
  .panel-body--form textarea::placeholder { color: var(--t-3); }

  .panel-body--form input:focus,
  .panel-body--form textarea:focus { border-color: var(--pearl-30); }

  .panel-body--form textarea {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.05rem;
    font-style: italic;
    line-height: 1.75;
    resize: none;
    min-height: 120px;
  }

  .label-grow { flex: 1; }
  .label-grow textarea { flex: 1; min-height: 0; }

  .row-split { display: grid; grid-template-columns: 90px 1fr; gap: 14px; }
  .label-marks .mark-row { flex-direction: row; flex-wrap: wrap; gap: 6px; }

  #cp-marks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .mark {
    width: 36px; height: 36px;
    background: var(--s-2);
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, border-color .15s, transform .12s;
  }

  .mark.active {
    background: var(--accent-soft);
    border-color: var(--accent-dim);
  }

  .mark:active { transform: scale(.88); }

  /* Her panel */
  #panel-her-photo {
    height: 230px;
    background: var(--ink-3);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
  }

  #her-date-label {
    font-family: 'Cormorant Garamond', serif;
    font-size: .85rem;
    font-style: italic;
    color: var(--t-3);
    margin-bottom: 22px;
    letter-spacing: .05em;
  }

  #her-seal-zone { text-align: center; }

  #her-seal {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    cursor: pointer;
  }

  #her-seal svg { width: 84px; height: 84px; }

  #her-seal span {
    font-size: 9.5px;
    font-weight: 300;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--t-3);
  }

  #her-letter {
    text-align: left;
    margin-top: 18px;
    animation: rise .5s var(--out) both;
  }

  #her-letter p {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.05rem;
    font-style: italic;
    line-height: 1.9;
    color: var(--t-2);
    white-space: pre-wrap;
  }

  #her-admin {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 9px;
  }

  #her-position { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

  .pos-row { display: flex; flex-direction: column; gap: 4px; }

  .pos-label {
    font-size: 9.5px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--t-3);
  }

  input[type="range"] { width: 100%; accent-color: var(--accent); }

  /* Diary reader */
  .panel-body--diary {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 9px;
    padding-bottom: 60px;
  }

  #dr-num {
    font-family: 'Cormorant Garamond', serif;
    font-size: .82rem;
    font-style: italic;
    color: var(--t-3);
    letter-spacing: .2em;
  }

  #dr-icon { font-size: 1.4rem; margin: 3px 0; }

  #dr-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--pearl);
    line-height: 1.3;
  }

  #dr-attr {
    font-size: .9rem;
    font-style: italic;
    color: var(--t-3);
  }

  #dr-body {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    font-style: italic;
    line-height: 1.9;
    color: var(--t-2);
    text-align: left;
    width: 100%;
    padding: 14px 0;
    white-space: pre-wrap;
  }

  #dr-date {
    font-size: 10px;
    letter-spacing: .15em;
    color: var(--t-3);
    margin-top: 4px;
  }

  #dr-delete { width: 100%; margin-top: 14px; }

  /* Tracker */
  .tracker-question {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.25rem;
    font-style: italic;
    color: var(--t-2);
    text-align: center;
    margin-bottom: 20px;
  }

  .tracker-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
  }

  .t-yes {
    height: 44px;
    padding: 0 26px;
    background: hsla(340,60%,50%,.14);
    border: 1px solid hsla(340,60%,50%,.35);
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: .1em;
    color: hsl(340,60%,72%);
    transition: background .2s, transform .12s;
  }
  .t-yes:active { transform: scale(.96); }

  .t-no {
    height: 44px;
    padding: 0 22px;
    background: var(--s-2);
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 300;
    color: var(--t-3);
  }

  .mood-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 16px 0;
  }

  .mood-btn {
    height: 42px;
    padding: 0 18px;
    background: var(--s-1);
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 300;
    color: var(--t-2);
    transition: background .2s, border-color .2s, transform .12s;
  }

  .mood-btn.on {
    background: hsla(340,60%,50%,.1);
    border-color: hsla(340,60%,50%,.35);
    color: hsl(340,60%,72%);
  }

  .mood-btn:active { transform: scale(.94); }

  .cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin: 16px 0;
  }

  .cal-dh {
    font-size: 9px;
    font-weight: 400;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--t-3);
    text-align: center;
    padding: 3px 0;
  }

  .cal-d {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 300;
    color: var(--t-2);
    cursor: pointer;
    transition: background .15s;
  }

  .cal-d.yes { background: hsla(340,60%,50%,.25); color: hsl(340,60%,72%); }
  .cal-d.no  { background: var(--s-2); color: var(--t-3); }
  .cal-d.today { box-shadow: 0 0 0 1px hsla(340,60%,50%,.35); }
  .cal-d.blank { cursor: default; }

  .tracker-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 16px;
  }

  .stat {
    background: var(--s-1);
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    padding: 14px 10px;
    text-align: center;
  }

  .stat strong {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.6rem;
    font-weight: 300;
    color: hsl(340,60%,72%);
    display: block;
    line-height: 1;
    margin-bottom: 4px;
  }

  .stat span {
    font-size: 9px;
    font-weight: 400;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--t-3);
  }

  /* Surprise screen */
  #surprise-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    width: 100%;
    max-width: 300px;
  }

  #surprise-gate p {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.3rem;
    font-style: italic;
    color: var(--t-2);
  }

  #surprise-exit {
    position: absolute;
    top: calc(var(--safe-t) + 14px);
    right: 18px;
    color: var(--t-3);
    font-size: 16px;
  }

  #pin-dots {
    display: flex;
    gap: 10px;
  }

  #pin-dots i {
    width: 12px; height: 12px;
    border-radius: 50%;
    border: 1px solid var(--b-1);
    background: transparent;
    transition: background .15s;
    font-style: normal;
  }

  #pin-dots i.filled {
    background: hsl(348,68%,40%);
    border-color: hsl(348,68%,40%);
  }

  #numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
    width: 100%;
  }

  #numpad button, #numpad span {
    height: 56px;
    background: var(--s-2);
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--t-1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .1s, transform .1s;
  }

  #numpad button:active { background: var(--s-3); transform: scale(.94); }
  #pin-back { font-size: 1rem; color: var(--t-3); }
  #numpad span { background: none; border-color: transparent; pointer-events: none; }

  #surprise-reveal {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    animation: rise .5s var(--out) both;
  }

  #confetti-cv {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  #candle {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
  }

  #flame {
    width: 14px; height: 22px;
    background: radial-gradient(ellipse at bottom, #fff 5%, #FFD700 35%, transparent 90%);
    border-radius: 50% 50% 30% 30%;
    filter: blur(1px);
    animation: flicker .4s ease-in-out infinite alternate;
  }

  #candle-body {
    width: 20px; height: 58px;
    background: linear-gradient(to bottom, #f2f2f2, #cecece);
    border-radius: 2px;
    margin-top: 2px;
  }

  #surprise-msg {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    font-style: italic;
    color: var(--pearl);
    text-align: center;
    padding: 0 26px;
    z-index: 1;
  }

  /* Dialogs */
  dialog {
    position: fixed;
    inset: 0;
    margin: auto;
    width: calc(100% - 40px);
    max-width: 340px;
    background: var(--ink-2);
    border: 1px solid var(--b-1);
    border-radius: var(--r-lg);
    padding: 26px 22px;
    box-shadow: var(--shadow);
    color: var(--t-1);
    z-index: 500;
    animation: scaleIn .28s var(--spring) both;
  }

  dialog h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.4rem;
    font-weight: 300;
    color: var(--pearl);
    margin-bottom: 16px;
  }

  dialog p {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    font-style: italic;
    line-height: 1.6;
    color: var(--t-2);
    margin-bottom: 20px;
  }

  dialog small {
    display: block;
    font-size: 11px;
    color: var(--t-3);
    margin-bottom: 20px;
    letter-spacing: .05em;
    font-style: italic;
  }

  dialog label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
  }

  dialog label span {
    font-size: 9.5px;
    font-weight: 400;
    letter-spacing: .26em;
    text-transform: uppercase;
    color: var(--t-3);
  }

  dialog input {
    height: 46px;
    padding: 0 15px;
    background: var(--s-2);
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 300;
    color: var(--t-1);
    transition: border-color .2s;
  }

  dialog input:focus { border-color: var(--pearl-30); }

  dialog #pw-err {
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    font-style: normal;
    color: hsl(0,60%,68%);
    min-height: 16px;
    margin-bottom: 8px;
  }

  .dlg-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
  }

  /* Volume dialog */
  #dlg-volume {
    text-align: center;
  }

  #dlg-volume p {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    font-style: normal;
    color: var(--t-2);
    letter-spacing: .1em;
    margin-bottom: 0;
  }

  #vol-knob { cursor: pointer; display: block; margin: 16px auto; }
  #vol-done { margin-top: 0; }

  /* Install dialog */
  #install-steps {
    font-size: 13px;
    font-weight: 300;
    line-height: 1.7;
    color: var(--t-2);
    margin-bottom: 16px;
  }

  #install-steps ol { list-style: decimal; padding-left: 18px; }
  #install-steps li { margin-bottom: 6px; }

  /* Menu dropdown */
  #menu-drop {
    position: fixed;
    top: calc(var(--safe-t) + 58px);
    right: 12px;
    width: 230px;
    background: var(--ink-2);
    border: 1px solid var(--b-1);
    border-radius: var(--r);
    z-index: 200;
    box-shadow: 0 16px 48px rgba(0,0,0,.7), 0 4px 14px rgba(0,0,0,.4);
    transform-origin: top right;
    transform: scale(.91) translateY(-6px);
    opacity: 0;
    pointer-events: none;
    transition: transform .26s var(--spring), opacity .2s var(--out);
    overflow: hidden;
  }

  #menu-drop.open {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  #menu-drop[hidden] { display: block !important; }

  #menu-drop nav { padding: 6px 0; }

  #menu-drop nav button,
  #menu-password,
  #menu-signout {
    display: block;
    width: 100%;
    padding: 12px 18px;
    font-size: 13px;
    font-weight: 300;
    letter-spacing: .04em;
    color: var(--t-2);
    text-align: left;
    transition: background .14s, color .14s;
  }

  #menu-drop nav button:hover,
  #menu-drop nav button:active,
  #menu-password:hover,
  #menu-password:active { background: var(--s-2); color: var(--t-1); }

  #menu-signout { color: hsl(340,60%,65%); padding: 12px 18px 16px; }
  #menu-signout:hover { background: var(--s-2); }

  #menu-drop hr { border: none; border-top: 1px solid var(--b-2); margin: 4px 0; }

  #menu-drop .eyebrow { padding: 8px 18px 4px; display: block; }

  #menu-activity { padding: 0; }

  .activity-item {
    padding: 9px 18px;
    font-size: 12px;
    font-weight: 300;
    color: var(--t-3);
    line-height: 1.5;
    border-bottom: 1px solid var(--b-2);
  }

  .activity-item:last-child { border-bottom: none; }

  /* Notification drawer */
  #notif-drawer {
    position: fixed;
    top: var(--safe-t);
    left: 0; right: 0;
    background: var(--ink-2);
    border-bottom: 1px solid var(--b-1);
    box-shadow: 0 12px 40px rgba(0,0,0,.5);
    z-index: 250;
    max-height: 65dvh;
    display: flex;
    flex-direction: column;
    transform: translateY(-100%);
    transition: transform .34s var(--out);
    overflow: hidden;
  }

  #notif-drawer.open { transform: none; }
  #notif-drawer[hidden] { display: flex !important; }

  #notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--b-2);
    flex-shrink: 0;
  }

  #notif-head h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.1rem;
    font-weight: 300;
    color: var(--pearl);
  }

  #notif-head > div { display: flex; gap: 9px; align-items: center; }

  #notif-mute {
    font-size: 11px;
    font-weight: 300;
    letter-spacing: .07em;
    color: var(--t-3);
    padding: 5px 10px;
    border: 1px solid var(--b-2);
    border-radius: 20px;
  }

  #notif-close {
    width: 30px; height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--t-3);
    border-radius: 50%;
    font-size: 13px;
    transition: color .2s;
  }

  #notif-banner {
    padding: 14px 18px;
    border-bottom: 1px solid var(--b-2);
    background: hsla(348,60%,30%,.06);
    flex-shrink: 0;
  }

  #notif-banner p {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    font-style: italic;
    color: var(--pearl);
    margin-bottom: 3px;
  }

  #notif-banner small {
    font-size: 11px;
    color: var(--t-3);
    display: block;
    margin-bottom: 12px;
  }

  #notif-banner > div { display: flex; gap: 8px; }
  #notif-banner #notif-enable { width: auto; height: 38px; font-size: 11px; padding: 0 16px; }
  #notif-banner #notif-skip { height: 38px; padding: 0 14px; font-size: 11px; }

  #notif-drawer .eyebrow { padding: 9px 18px 4px; display: block; flex-shrink: 0; }

  #notif-list {
    flex: 1;
    overflow-y: auto;
  }

  #notif-list::-webkit-scrollbar { display: none; }

  .notif-item {
    padding: 13px 18px;
    border-bottom: 1px solid var(--b-2);
    font-size: 12px;
    font-weight: 300;
    line-height: 1.6;
    color: var(--t-3);
    transition: color .2s;
  }

  .notif-item.unread { color: var(--t-1); }

  #notif-empty {
    padding: 22px 18px;
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    color: var(--t-3);
    text-align: center;
  }

  /* Toasts */
  #toasts {
    position: fixed;
    bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 28px);
    max-width: 360px;
    z-index: 999;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 7px;
    pointer-events: none;
  }

  .toast {
    background: var(--ink-3);
    border: 1px solid var(--b-1);
    border-radius: var(--r-sm);
    padding: 11px 17px;
    font-size: 12px;
    font-weight: 300;
    letter-spacing: .03em;
    color: var(--t-2);
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
    animation: toastIn .32s var(--out) both;
    width: 100%;
    text-align: center;
  }

  .toast.out { animation: toastOut .22s var(--out) both; }

  /* Overlays */
  .overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(4,3,6,.93);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    overflow-y: auto;
  }

  .overlay[hidden] { display: none; }
  .overlay--bare { background: rgba(4,3,6,.95); padding: 0; }

  /* Welcome letter */
  #ov-welcome {
    align-items: flex-start;
    z-index: 700;
    padding-top: calc(var(--safe-t) + 32px);
    padding-bottom: 32px;
  }

  #welcome-scroll {
    width: 100%;
    max-width: 480px;
    margin: auto;
    background: linear-gradient(155deg, rgba(232,224,212,.055) 0%, rgba(232,224,212,.025) 100%);
    border: 1px solid var(--b-1);
    border-radius: var(--r-lg);
    padding: 32px 28px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: rise .6s var(--out) both;
  }

  #welcome-scroll .ornament {
    font-family: 'Cormorant Garamond', serif;
    font-size: .8rem;
    letter-spacing: .4em;
    color: var(--t-3);
    text-align: center;
  }

  #welcome-scroll .salutation {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.55rem;
    font-style: italic;
    color: var(--pearl);
    margin-bottom: 0;
  }

  #welcome-scroll p {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.05rem;
    font-style: italic;
    line-height: 1.88;
    color: var(--t-2);
    margin: 0;
  }

  #welcome-scroll footer {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    color: var(--t-3);
    line-height: 1.7;
  }

  #welcome-scroll footer em { color: var(--t-2); }
  #welcome-done { margin-top: 6px; }

  /* Tutorial */
  #tutorial-card {
    width: 100%;
    max-width: 340px;
    background: var(--s-1);
    border: 1px solid var(--b-1);
    border-radius: var(--r-lg);
    padding: 32px 26px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    animation: scaleIn .45s var(--spring) both;
  }

  #tut-pips { display: flex; gap: 6px; }

  .pip {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--b-1);
    transition: background .3s, transform .3s;
  }

  .pip.active { background: hsl(348,60%,60%); transform: scale(1.25); }

  #tut-icon { font-size: 2rem; }

  #tut-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.55rem;
    font-weight: 300;
    color: var(--pearl);
  }

  #tut-body {
    font-size: 13px;
    font-weight: 300;
    line-height: 1.7;
    color: var(--t-2);
  }

  /* Screensaver */
  #ov-saver {
    z-index: 500;
    flex-direction: column;
    cursor: pointer;
    padding: 0;
    align-items: center;
    justify-content: center;
    background: rgba(4,3,6,.97);
  }

  #saver-petals {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  #saver-time {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(3.5rem, 20vw, 6.5rem);
    font-weight: 200;
    color: var(--pearl);
    letter-spacing: -.02em;
    line-height: 1;
    z-index: 1;
  }

  #saver-date {
    font-size: 11px;
    font-weight: 200;
    letter-spacing: .34em;
    text-transform: uppercase;
    color: var(--t-3);
    margin-top: 12px;
    z-index: 1;
  }

  #saver-hint {
    position: absolute;
    bottom: calc(var(--nav-h) + 18px + var(--safe-b));
    font-size: 10px;
    font-weight: 200;
    letter-spacing: .28em;
    text-transform: uppercase;
    color: var(--t-3);
    animation: breathe 3s ease-in-out infinite;
  }

  /* Bloom */
  #ov-bloom { z-index: 650; flex-direction: column; padding: 32px; background: radial-gradient(ellipse at center, hsla(348,50%,12%,.1), rgba(4,3,6,.98)); }

  #bloom-cv { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

  #bloom-quote {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    font-style: italic;
    color: var(--pearl);
    text-align: center;
    z-index: 1;
    animation: rise 1.2s var(--out) .5s both;
  }

  /* Kiss */
  #ov-kiss { z-index: 700; pointer-events: none; }

  #kiss-line {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.9rem;
    font-style: italic;
    color: var(--pearl);
    text-align: center;
    animation: rise .28s var(--out) both;
  }

  /* Lightbox */
  #ov-lightbox { z-index: 350; flex-direction: column; background: rgba(0,0,0,.97); padding: 0; }

  #lb-close {
    position: absolute;
    top: calc(var(--safe-t) + 14px);
    right: 18px;
    width: 38px; height: 38px;
    background: rgba(255,255,255,.07);
    border-radius: 50%;
    font-size: 14px;
    color: var(--t-2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
  }

  #lb-prev, #lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px; height: 42px;
    background: rgba(255,255,255,.06);
    border-radius: 50%;
    font-size: 1.6rem;
    color: var(--t-2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
  }

  #lb-prev { left: 12px; }
  #lb-next { right: 12px; }

  #lb-media {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
  }

  #lb-media img, #lb-media video {
    max-width: 100%;
    max-height: 78dvh;
    object-fit: contain;
    border-radius: var(--r-sm);
  }

  #lb-foot {
    padding: 14px 22px calc(var(--nav-h) + 14px + var(--safe-b));
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  #lb-caption {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 1rem;
    color: var(--t-2);
    margin: 0;
  }

  #lb-theme {
    font-size: 11px;
    font-weight: 400;
    letter-spacing: .1em;
    color: var(--t-3);
    border: 1px solid var(--b-2);
    border-radius: 20px;
    padding: 7px 15px;
    align-self: center;
  }

  /* Petals layer */
  #petals-wrap {
    position: fixed;
    inset: 0;
    z-index: 80;
    pointer-events: none;
    overflow: hidden;
  }

  #petals-wrap canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  /* Panel backdrop */
  #backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 299;
    opacity: 0;
    transition: opacity .3s;
  }

  #backdrop[hidden] { display: block !important; opacity: 0; pointer-events: none; }
  #backdrop.vis { opacity: 1; pointer-events: auto; }
}


/* ── ANIMATIONS ─────────────────────────────────────── */
@layer animations {
  @keyframes breathe {
    0%, 100% { opacity: .35; }
    50%       { opacity: .8; }
  }

  @keyframes rise {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
  }

  @keyframes scaleIn {
    from { opacity: 0; transform: scale(.93) translateY(8px); }
    to   { opacity: 1; transform: none; }
  }

  @keyframes toastIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
  }

  @keyframes toastOut {
    from { opacity: 1; transform: none; }
    to   { opacity: 0; transform: translateY(8px); }
  }

  @keyframes flicker {
    from { transform: scaleX(1) scaleY(1) rotate(-1deg); opacity: .9; }
    to   { transform: scaleX(.88) scaleY(1.06) rotate(1deg); opacity: 1; }
  }

  @keyframes crackIn {
    from { stroke-dashoffset: 32; }
    to   { stroke-dashoffset: 0; }
  }

  @keyframes lockShake {
    0%, 100% { transform: none; }
    20%       { transform: translateX(-7px); }
    40%       { transform: translateX(7px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
  }

  .shake { animation: lockShake .38s ease; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: .01ms !important;
      transition-duration: .01ms !important;
    }
  }
}
