  :root {
    /* Stage */
    --bg-stage: #F0EEE9;

    /* Cream paper inside the phone */
    --paper:    #FAF6F1;
    --paper-2:  #F4EFE5;
    --paper-3:  #EDE6D8;

    /* Ink */
    --ink:      #14130F;     /* primary text — softened from pure black */
    --ink-2:    #3D3B38;     /* secondary */
    --ink-3:    #6B6865;     /* tertiary / meta */
    --ink-4:    #A09A8E;     /* hairline label */
    --rule:     #E5E0D5;     /* hairlines, borders */
    --rule-2:   #D9D2C5;     /* slightly stronger */

    /* Accents (used sparingly) */
    --tts:      #2D6A6A;     /* teal — TTS state */
    --listen:   #8D4B2A;     /* sienna — listening */
    --save:     #16A34A;     /* green — saving */
    --keep:     #16A34A;
    --cut:      #DC2626;
    --defer:    #B57A0A;     /* sun-readable amber */
    --warn:     #C9963A;

    --font-display: 'Outfit', system-ui, sans-serif;
    --font-sans:    'Outfit', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, monospace;
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    background: var(--bg-stage);
    color: var(--ink);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 48px 24px 64px;
  }

  /* Header */
  .stage-head {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
  }
  .stage-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 30px;
    letter-spacing: -0.025em;
    line-height: 1.05;
    color: var(--ink);
    margin: 0;
  }
  .stage-title em {
    font-style: normal;
    font-weight: 300;
    color: var(--ink-3);
  }
  .stage-sub {
    margin-top: 6px;
    color: var(--ink-3);
    font-size: 13px;
    max-width: 540px;
    line-height: 1.45;
  }
  .stage-sub code {
    font-family: var(--font-mono); font-size: 11.5px;
    background: var(--paper); border: 1px solid var(--rule);
    color: var(--ink); padding: 1px 6px; border-radius: 4px;
  }

  .switcher {
    display: inline-flex;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 12px;
    padding: 4px;
    gap: 2px;
    box-shadow: 0 1px 2px rgba(44,36,29,0.04);
  }
  .switcher button {
    appearance: none; border: 0; background: transparent;
    color: var(--ink-3);
    font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
    letter-spacing: 0.04em; text-transform: uppercase;
    padding: 8px 14px; border-radius: 8px;
    cursor: pointer;
    transition: background 120ms, color 120ms;
  }
  .switcher button:hover { color: var(--ink); }
  .switcher button.active {
    background: var(--ink); color: var(--paper);
  }
  .switcher .step-num {
    font-family: var(--font-mono); font-size: 10.5px;
    opacity: 0.55; margin-right: 6px;
  }

  /* Phone */
  .phone-wrap {
    display: flex; justify-content: center;
    margin-top: 12px;
  }
  .phone {
    width: 393px;
    height: 852px;
    border-radius: 56px;
    background: #1A1917;
    padding: 12px;
    box-shadow:
      0 0 0 1.5px #2a2a2a,
      0 30px 80px rgba(44,36,29,0.22),
      0 8px 24px rgba(44,36,29,0.14);
    position: relative;
  }
  .phone-screen {
    width: 100%;
    height: 100%;
    border-radius: 44px;
    overflow: hidden;
    position: relative;
    background: var(--paper);
    isolation: isolate;
  }
  .island {
    position: absolute;
    top: 11px; left: 50%; transform: translateX(-50%);
    width: 124px; height: 36px;
    background: #1A1917;
    border-radius: 22px;
    z-index: 100;
  }
  .statusbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 54px;
    z-index: 99;
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 32px 0;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 16px;
    color: var(--ink);
    pointer-events: none;
  }
  .sb-cell { display: flex; align-items: flex-end; gap: 2px; height: 11px; }
  .sb-cell i { display: block; width: 3px; background: var(--ink); border-radius: 0.5px; }
  .sb-cell i:nth-child(1) { height: 4px; }
  .sb-cell i:nth-child(2) { height: 6px; }
  .sb-cell i:nth-child(3) { height: 8px; }
  .sb-cell i:nth-child(4) { height: 10px; }
  .sb-bat {
    width: 26px; height: 12px;
    border: 1px solid var(--ink);
    border-radius: 3px;
    position: relative;
    padding: 1px;
  }
  .sb-bat::after {
    content: ''; position: absolute; right: -3px; top: 3px;
    width: 2px; height: 4px;
    background: var(--ink); border-radius: 0 1px 1px 0;
  }
  .sb-bat i {
    display: block; width: 70%; height: 100%;
    background: var(--ink); border-radius: 1px;
  }
  .statusbar .icons { display: flex; align-items: center; gap: 6px; }
  .statusbar .icons .mono {
    font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  }

  /* ============================================================
     APP — MINIMALIST
     Pure paper. Hairline rules. Type carries everything.
     ============================================================ */
  .app {
    position: absolute; inset: 0;
    background: var(--paper);
    color: var(--ink);
  }
  .topbar {
    position: absolute; top: 64px; left: 28px; right: 28px;
    display: flex; justify-content: space-between; align-items: center;
  }
  .meta-label {
    font-family: var(--font-sans);
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-3);
  }
  .num-display {
    font-family: var(--font-display);
    font-weight: 300;
    letter-spacing: -0.035em;
  }

  /* Pulse dot */
  @keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
  }
  .pulse-dot {
    width: 10px; height: 10px; border-radius: 50%;
    animation: pulse-dot 1.4s ease-in-out infinite;
  }

  /* Waveform (inline, small) */
  .wave-mini {
    display: inline-flex; align-items: center; gap: 3px;
    height: 18px;
  }
  .wave-mini i {
    display: block;
    width: 2.5px; border-radius: 1.5px;
    background: currentColor;
    animation: wf 1.0s ease-in-out infinite;
  }
  @keyframes wf {
    0%, 100% { transform: scaleY(0.25); }
    50%      { transform: scaleY(1); }
  }
  .wave-mini i:nth-child(1) { height: 8px; animation-delay: -0.05s; }
  .wave-mini i:nth-child(2) { height: 14px; animation-delay: 0.10s; }
  .wave-mini i:nth-child(3) { height: 18px; animation-delay: -0.15s; }
  .wave-mini i:nth-child(4) { height: 10px; animation-delay: 0.05s; }
  .wave-mini i:nth-child(5) { height: 16px; animation-delay: -0.10s; }
  .wave-mini i:nth-child(6) { height: 12px; animation-delay: 0.15s; }
  .wave-mini i:nth-child(7) { height: 18px; animation-delay: -0.20s; }
  .wave-mini i:nth-child(8) { height: 8px; animation-delay: 0.00s; }

  /* ============================================================
     STATE: PICKER
     ============================================================ */
  .state-picker .topbar .right { display: flex; align-items: center; gap: 12px; }
  .picker {
    position: absolute; top: 116px; left: 28px; right: 28px; bottom: 28px;
    display: flex; flex-direction: column;
  }
  .picker h1 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 38px;
    line-height: 1;
    letter-spacing: -0.035em;
    color: var(--ink);
    margin: 0 0 4px;
  }
  .picker h1 em {
    font-style: normal;
    font-weight: 300;
    color: var(--ink-2);
  }
  .picker .lede {
    color: var(--ink-3); font-size: 14px;
    margin-bottom: 28px;
    line-height: 1.35;
  }
  .picker .lede strong {
    color: var(--ink); font-weight: 600;
    font-family: var(--font-mono); font-size: 13px;
    background: var(--paper-3);
    border: 1px solid var(--rule);
    padding: 1px 6px; border-radius: 4px;
    margin: 0 1px;
  }
  .pick-list {
    display: flex; flex-direction: column;
    gap: 10px; flex: 1;
  }
  .pick-row {
    min-height: 84px;
    border: 1px solid var(--rule);
    background: var(--paper);
    border-radius: 6px;
    padding: 14px 18px 14px 56px;
    display: flex; flex-direction: column; justify-content: center;
    gap: 4px;
    position: relative;
    transition: border-color 120ms, transform 120ms;
  }
  .pick-row:hover { border-color: var(--rule-2); }
  .pick-row .pr-num {
    position: absolute; left: 18px; top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: 18px; font-weight: 500;
    color: var(--ink-4);
    letter-spacing: -0.02em;
    width: 24px;
  }
  .pick-row .pr-name {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 20px;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--ink);
  }
  .pick-row .pr-meta {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--ink-3);
    letter-spacing: -0.01em;
  }
  .pick-row .pr-meta .sep { color: var(--ink-4); margin: 0 6px; }
  .pick-row.primary {
    border: 1.5px solid var(--ink);
    background: var(--paper);
    box-shadow: 0 0 0 4px rgba(20,19,15,0.04);
  }
  .pick-row.primary .pr-num {
    background: var(--ink); color: var(--paper);
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px;
    font-size: 13px;
    transform: translateY(-50%);
    margin-left: -1px;
  }
  .pick-row .pr-arrow {
    position: absolute; right: 18px; top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 28px;
    color: var(--ink-4);
    line-height: 1;
  }
  .pick-row.primary .pr-arrow { color: var(--ink); }

  /* TTS prompt above the list */
  .tts-prompt {
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--paper-2);
    border: 1px solid var(--rule);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--tts);
  }
  .tts-prompt .wave-mini { color: var(--tts); }
  .tts-prompt .qtxt {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: normal;
    font-size: 15px;
    line-height: 1.25;
    color: var(--ink-2);
    letter-spacing: -0.005em;
  }
  .tts-prompt .qtxt::before { content: '„'; color: var(--ink-4); }
  .tts-prompt .qtxt::after  { content: '"'; color: var(--ink-4); }

  /* ============================================================
     STATE: ACTIVE
     ============================================================ */
  .active {
    position: absolute; top: 92px; left: 28px; right: 28px; bottom: 28px;
    display: flex; flex-direction: column;
  }
  .a-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 4px;
  }
  .a-head .count {
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--ink-3);
    letter-spacing: -0.01em;
  }
  .a-head .count b { color: var(--ink); font-weight: 600; }
  .a-head .conn {
    font-family: var(--font-mono); font-size: 11px;
    color: var(--save);
    letter-spacing: 0.04em;
    display: inline-flex; align-items: center; gap: 6px;
  }
  .a-head .conn .pulse-dot { background: var(--save); width: 7px; height: 7px; }

  /* Thin progress bar */
  .progress {
    height: 2px; background: var(--rule);
    border-radius: 1px; overflow: hidden;
    margin-bottom: 28px;
  }
  .progress i { display: block; height: 100%; background: var(--ink); border-radius: 1px; }

  .a-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 48px;
    line-height: 1.02;
    letter-spacing: -0.04em;
    color: var(--ink);
    margin: 24px 0 0;
    text-wrap: balance;
  }
  .a-title em {
    font-style: normal;
    font-weight: 500;
    color: var(--ink);
  }

  .a-state {
    margin-top: auto;
    margin-bottom: 24px;
    display: flex; align-items: center; gap: 12px;
    color: var(--tts);
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
    min-height: 24px;
  }
  .a-state.listen { color: var(--listen); }
  .a-state.save   { color: var(--save); }
  .a-state .wave-mini { color: currentColor; }
  .a-state .save-tick {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px;
  }
  .a-state .save-tick svg { width: 100%; height: 100%; }
  .a-state-text { letter-spacing: 0.08em; }

  .a-foot {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--rule);
  }
  .a-last {
    display: flex; flex-direction: column;
    gap: 4px;
    justify-content: center;
  }
  .a-last .meta-label { font-size: 10px; margin-bottom: 4px; color: var(--ink-4); }
  .a-last .row {
    display: grid;
    grid-template-columns: 26px 1fr;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--ink-2);
    line-height: 1.3;
  }
  .a-last .row .tag {
    font-weight: 600;
    letter-spacing: 0.04em;
  }
  .a-last .row .tag.k { color: var(--keep); }
  .a-last .row .tag.c { color: var(--cut); }
  .a-last .row .tag.d { color: var(--defer); }
  .a-last .row .txt {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .a-undo {
    min-height: 84px;
    background: transparent;
    color: var(--ink);
    border: 1.5px solid var(--ink);
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 15px; font-weight: 600;
    letter-spacing: 0.12em; text-transform: uppercase;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px;
    cursor: pointer;
    padding: 8px;
  }
  .a-undo .glyph {
    font-family: var(--font-sans);
    font-size: 22px;
    line-height: 1;
    font-weight: 400;
  }
  .a-undo .hint {
    font-family: var(--font-mono);
    font-size: 10px; letter-spacing: 0;
    text-transform: none;
    color: var(--ink-3);
    font-weight: 400;
  }

  /* ============================================================
     STATE: END
     ============================================================ */
  .end {
    position: absolute; top: 100px; left: 28px; right: 28px; bottom: 28px;
    display: flex; flex-direction: column;
  }
  .end h1 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 40px;
    line-height: 1.02;
    letter-spacing: -0.04em;
    color: var(--ink);
    margin: 0 0 4px;
  }
  .end h1 em { font-style: normal; font-weight: 300; color: var(--ink-2); }
  .end .e-sub {
    color: var(--ink-3); font-size: 13px;
    margin-bottom: 40px;
    font-family: var(--font-mono);
    letter-spacing: -0.01em;
  }
  .e-big {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: 152px;
    line-height: 0.85;
    letter-spacing: -0.055em;
    color: var(--ink);
    margin-bottom: 4px;
  }
  .e-big-label {
    color: var(--ink-3);
    font-size: 14px;
    margin-bottom: 32px;
    font-family: var(--font-mono);
    letter-spacing: -0.01em;
  }
  .e-breakdown {
    display: grid; grid-template-columns: 1fr 1fr 1fr;
    gap: 0;
    border-top: 1px solid var(--rule);
    padding-top: 16px;
    margin-bottom: 24px;
  }
  .e-breakdown .cell { display: flex; flex-direction: column; gap: 2px; }
  .e-breakdown .num {
    font-family: var(--font-display); font-weight: 400;
    font-size: 36px; letter-spacing: -0.035em;
    color: var(--ink); line-height: 1;
  }
  .e-breakdown .num.k { color: var(--keep); }
  .e-breakdown .num.c { color: var(--cut); }
  .e-breakdown .num.d { color: var(--defer); }
  .e-breakdown .lbl {
    font-size: 10.5px; color: var(--ink-3);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 2px;
  }
  .e-buttons {
    margin-top: auto;
    display: flex; flex-direction: column;
    gap: 10px;
  }
  .e-btn {
    min-height: 84px;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 17px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    gap: 12px;
  }
  .e-btn .hint {
    font-family: var(--font-mono); font-size: 11px;
    letter-spacing: 0;
    text-transform: none;
    font-weight: 400;
    opacity: 0.7;
  }
  .e-btn-resume {
    background: var(--ink); color: var(--paper); border: 1.5px solid var(--ink);
  }
  .e-btn-resume .hint { color: var(--paper-3); }
  .e-btn-switch {
    background: transparent; color: var(--ink); border: 1.5px solid var(--ink);
  }
  .e-btn-switch .hint { color: var(--ink-3); }

  /* helpers */
  .hide { display: none !important; }

  /* CSS-only state hiding (works in Quick Look / no-JS contexts).
     The .app starts with .state-picker, so only picker is visible by default. */
  .state-picker > [data-show]:not([data-show="picker"]) { display: none !important; }
  .state-active > [data-show]:not([data-show="active"]) { display: none !important; }
  .state-end    > [data-show]:not([data-show="end"])    { display: none !important; }

  /* Footer */
  .stage-foot {
    max-width: 1100px;
    margin: 32px auto 0;
    color: var(--ink-3);
    font-size: 12px;
    letter-spacing: 0.02em;
    text-align: center;
    display: flex; justify-content: center; gap: 16px;
    flex-wrap: wrap;
  }
  .stage-foot code {
    font-family: var(--font-mono); font-size: 11.5px;
    background: var(--paper); border: 1px solid var(--rule);
    padding: 1px 6px; border-radius: 4px; color: var(--ink);
  }

  /* ============================================================
     PWA runtime additions
     ============================================================ */
  button.pick-row {
    appearance: none;
    width: 100%;
    text-align: left;
    font: inherit;
    cursor: pointer;
  }
  button.pick-row:focus-visible,
  .a-undo:focus-visible,
  .e-btn:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 3px;
  }
  .pick-row .hint {
    position: absolute;
    right: 48px;
    bottom: 15px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0;
    color: var(--ink-3);
    white-space: nowrap;
  }
  .tts-prompt .qtxt::after { content: '”'; color: var(--ink-4); }
  .active-blocks {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--ink-3);
    font-size: 14px;
    line-height: 1.35;
  }
  .active-blocks .block {
    border-top: 1px solid var(--rule);
    padding-top: 8px;
  }
  .active-blocks .role {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-4);
    display: block;
    margin-bottom: 3px;
  }
  #last-decisions {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .sync-label {
    color: var(--save);
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .sync-label .pulse-dot {
    background: var(--save);
    width: 7px;
    height: 7px;
  }
  .conn.offline,
  .sync-label.offline {
    color: var(--defer);
  }
  .conn.offline .pulse-dot,
  .sync-label.offline .pulse-dot {
    background: var(--defer);
  }
  .toast {
    position: absolute;
    left: 28px;
    right: 28px;
    bottom: 28px;
    z-index: 120;
    padding: 12px 14px;
    border: 1px solid var(--rule-2);
    background: var(--paper-2);
    color: var(--ink-2);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.3;
    box-shadow: 0 8px 30px rgba(44,36,29,0.12);
  }
  [hidden] { display: none !important; }

  @media (display-mode: standalone), (display-mode: fullscreen), (max-width: 480px) {
    html, body {
      width: 100%;
      min-height: 100%;
      background: var(--paper);
    }
    body {
      display: block;
      padding: 0;
      gap: 0;
      min-height: 100vh;
    }
    .phone-wrap {
      margin: 0;
      width: 100vw;
      height: 100vh;
      display: block;
    }
    .phone {
      width: 100vw;
      height: 100vh;
      border-radius: 0;
      background: var(--paper);
      padding: 0;
      box-shadow: none;
    }
    .phone-screen {
      width: 100%;
      height: 100%;
      border-radius: 0;
    }
    .island,
    .statusbar {
      display: none;
    }
    .topbar {
      top: max(28px, env(safe-area-inset-top));
    }
    .picker {
      top: calc(max(28px, env(safe-area-inset-top)) + 52px);
      bottom: max(28px, env(safe-area-inset-bottom));
    }
    .active {
      top: calc(max(28px, env(safe-area-inset-top)) + 36px);
      bottom: max(28px, env(safe-area-inset-bottom));
    }
    .end {
      top: calc(max(28px, env(safe-area-inset-top)) + 62px);
      bottom: max(28px, env(safe-area-inset-bottom));
    }
  }

  @supports (height: 100dvh) {
    @media (display-mode: standalone), (display-mode: fullscreen), (max-width: 480px) {
      body,
      .phone-wrap,
      .phone {
        min-height: 100dvh;
        height: 100dvh;
      }
    }
  }
