/* Year Reel - cream paper and plum ink in light, a late-night purple in dark; the story cards carry their own fixed
 * duotones (reel.js) so they read the same in either theme. */
:root {
  --bg: #fbf6ef; --panel: #ffffff; --paper: #f4ece0; --ink: #21152f; --muted: #5d5168; --line: #e3d7c6;
  --plum: #5b2a86; --plum-ink: #ffffff; --coral: #c2381f; --mint: #0f766e; --sun: #8a5a00;
  --chip: #efe4f7; --chip-ink: #3e1a5e; --warn-bg: #fff1e6; --warn-ink: #8a3412; --info-bg: #eef4ff; --info-ink: #1e3a8a;
  --shadow: 0 10px 30px rgba(33, 21, 47, 0.10);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15101d; --panel: #1f1729; --paper: #281e34; --ink: #f4eefb; --muted: #b9abc9; --line: #3b2e4b;
  --plum: #c9a2f2; --plum-ink: #1b1024; --coral: #ff8a70; --mint: #5eead4; --sun: #ffd23f;
  --chip: #33264a; --chip-ink: #eadcff; --warn-bg: #3a2016; --warn-ink: #ffc9a8; --info-bg: #1d2742; --info-ink: #c7d7ff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); }
a { color: var(--plum); }
h1, h2, h3 { line-height: 1.15; overflow-wrap: anywhere; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 0.86rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* Header */
.bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.back { text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.logo { width: 28px; height: 28px; }
.lg-a { fill: var(--coral); } .lg-b { fill: var(--plum); } .lg-c { fill: var(--bg); }
.session { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 6px 13px; font: 600 0.88rem var(--sans); cursor: pointer; text-decoration: none; }
.pill:hover:not(:disabled) { border-color: var(--plum); }
.pill.solid { background: var(--plum); border-color: var(--plum); color: var(--plum-ink); }
.pill.ghost { cursor: default; }
.pill.tiny { padding: 3px 10px; font-size: 0.8rem; }
.pill:disabled { opacity: 0.5; cursor: not-allowed; }

main { max-width: 1180px; margin: 0 auto; padding: 0 16px 40px; }

/* Hero */
.hero { display: grid; grid-template-columns: 1fr 260px; gap: 24px; align-items: center; padding: 26px 0 14px; }
.kicker { margin: 0; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; font-size: 0.78rem; color: var(--coral); }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); margin: 4px 0 8px; letter-spacing: -0.02em; }
.lede { margin: 0 0 12px; max-width: 64ch; }
.samples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { border: 1.5px solid transparent; background: var(--chip); color: var(--chip-ink); border-radius: 999px; padding: 5px 12px; font: 600 0.84rem var(--sans); cursor: pointer; }
.chip.on { border-color: var(--plum); background: var(--plum); color: var(--plum-ink); }
.fan { position: relative; height: 230px; }
.fc { position: absolute; top: 10px; width: 120px; height: 200px; border-radius: 16px; padding: 14px 12px; display: flex; flex-direction: column; justify-content: flex-end; box-shadow: var(--shadow); }
.fc b { font-size: 1.7rem; line-height: 1; } .fc i { font-style: normal; font-weight: 600; font-size: 0.85rem; }
.f1 { left: 0; transform: rotate(-9deg); background: linear-gradient(160deg, #3b1c5a, #7a2e8e); color: #fff; }
.f2 { left: 70px; transform: rotate(2deg); background: linear-gradient(160deg, #ff6a4d, #ffa24c); color: #1d0f1f; z-index: 1; }
.f3 { left: 138px; transform: rotate(11deg); background: linear-gradient(160deg, #0b3d3a, #0f766e); color: #fff; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.col-in { display: grid; gap: 18px; min-width: 0; }
.col-out { position: sticky; top: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.ph { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 1.2rem; flex-wrap: wrap; }
.step-tag { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--coral); color: #fff; font-size: 0.95rem; font-weight: 800; flex: none; }
:root[data-theme="dark"] .step-tag { color: #1b1024; }
.lbl { display: block; font-weight: 600; font-size: 0.88rem; margin: 10px 0 4px; }
input[type="text"], select, textarea { width: 100%; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px; padding: 9px 11px; font: 15px/1.45 var(--sans); }
textarea { font-family: var(--mono); font-size: 0.86rem; resize: vertical; min-height: 220px; }
textarea.dropping { border-color: var(--plum); border-style: dashed; }
input:focus, select:focus, textarea:focus, .phone:focus-visible, button:focus-visible { outline: 3px solid var(--plum); outline-offset: 2px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.filerow { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.filebtn { cursor: pointer; }

/* The count */
.lean { display: flex; gap: 14px; justify-content: space-between; flex-wrap: wrap; }
.lean-l { display: flex; flex-direction: column; gap: 4px; flex: 1 1 260px; }
.lean-r { display: grid; grid-template-columns: repeat(4, minmax(56px, 1fr)); gap: 6px; flex: 1 1 260px; }
.lean-r div { background: var(--paper); border-radius: 12px; padding: 6px 4px; text-align: center; }
.lean-r b { display: block; font-size: 1.35rem; color: var(--ink); }
.lean-r span { font-size: 0.75rem; color: var(--muted); }
.badge { align-self: flex-start; display: inline-block; border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: 0.9rem; background: var(--paper); color: var(--ink); }
.badge.v-full { background: #0f766e; color: #fff; }
.badge.v-short { background: #8a5a00; color: #fff; }
.badge.v-too-thin { background: #b42318; color: #fff; }
:root[data-theme="dark"] .badge.v-full { background: #5eead4; color: #062a27; }
:root[data-theme="dark"] .badge.v-short { background: #ffd23f; color: #2a1640; }
:root[data-theme="dark"] .badge.v-too-thin { background: #ffb4a8; color: #3b0a07; }
.months { list-style: none; padding: 0; margin: 14px 0 6px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; align-items: end; height: 92px; }
.months li { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 2px; }
.months .mb { width: 100%; border-radius: 6px 6px 2px 2px; background: var(--plum); min-height: 3px; }
.months .mb.zero { background: var(--line); }
.months .mb.top { background: var(--coral); }
.months .ml { font-size: 0.68rem; color: var(--muted); font-weight: 600; }
.months .mn { font-size: 0.7rem; font-weight: 700; color: var(--ink); }
.flags { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.flags li { border-radius: 10px; padding: 6px 10px; font-size: 0.86rem; }
.flags li.lv-warn { background: var(--warn-bg); color: var(--warn-ink); }
.flags li.lv-info { background: var(--info-bg); color: var(--info-ink); }
.lv { font-weight: 800; text-transform: uppercase; font-size: 0.7rem; margin-right: 6px; letter-spacing: 0.05em; }
.facts { list-style: none; padding: 0; margin: 10px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.facts li { border: 1.5px dashed var(--line); border-radius: 12px; padding: 8px 10px; background: var(--bg); display: grid; gap: 2px; align-content: start; }
.fid { font: 700 0.72rem var(--mono); color: var(--chip-ink); background: var(--chip); border-radius: 6px; padding: 1px 6px; justify-self: start; align-self: start; }
.flab { font-size: 0.78rem; color: var(--muted); }
.fval { font-weight: 700; font-size: 0.95rem; overflow-wrap: anywhere; }
.facts .none, .board .board-empty { color: var(--muted); border: 0; background: none; }
.rules { margin: 8px 0 0; }

/* Ask */
.tones { border: 0; padding: 0; margin: 0 0 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.tones legend { padding: 0; }
.tone { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.tone:has(input:checked) { border-color: var(--plum); background: var(--chip); color: var(--chip-ink); }
.go { display: block; width: 100%; border: 0; border-radius: 14px; background: var(--coral); color: #fff; font: 800 1.05rem var(--sans); padding: 13px; cursor: pointer; margin-top: 6px; }
:root[data-theme="dark"] .go { color: #1b1024; }
.go:disabled { opacity: 0.5; cursor: not-allowed; }
.note { background: var(--info-bg); color: var(--info-ink); border-radius: 10px; padding: 7px 10px; font-size: 0.88rem; margin: 6px 0; }
.note.warn { background: var(--warn-bg); color: var(--warn-ink); }
.meter { margin: 8px 0 0; }
.gate { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 8px 10px; font-size: 0.88rem; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Stage: the phone */
.stage-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.seg-switch { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; padding: 2px; }
.sw { border: 0; background: none; color: var(--ink); border-radius: 999px; padding: 4px 12px; font: 700 0.84rem var(--sans); cursor: pointer; }
.sw.on { background: var(--plum); color: var(--plum-ink); }
.sw:disabled { opacity: 0.45; cursor: not-allowed; }
.phone { position: relative; width: 100%; max-width: 340px; margin: 0 auto; aspect-ratio: 9 / 16; border-radius: 26px; overflow: hidden; background: #0e0a14; box-shadow: 0 18px 40px rgba(20, 10, 30, 0.35); border: 6px solid #0e0a14; }
.segs { position: absolute; z-index: 3; top: 10px; left: 12px; right: 12px; display: flex; gap: 4px; pointer-events: none; }
.seg { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.35); overflow: hidden; }
.seg i { display: block; height: 100%; width: 0; background: #fff; }
.seg.done i { width: 100%; }
.seg.on i { width: 12%; }
.face-slot { position: absolute; inset: 0; }
.tap { position: absolute; z-index: 2; top: 0; bottom: 0; width: 40%; border: 0; background: transparent; cursor: pointer; }
.tap-l { left: 0; } .tap-r { right: 0; width: 60%; }
.face { position: absolute; inset: 0; padding: 30px 20px 18px; display: flex; flex-direction: column; overflow: hidden; animation: rise 0.35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .face { animation: none; } }
.f-deco { position: absolute; pointer-events: none; }
.f-deco.d1 { width: 180px; height: 180px; border-radius: 50%; right: -60px; top: 40px; opacity: 0.22; }
.f-deco.d2 { width: 150px; height: 150px; border-radius: 50%; left: -50px; bottom: 30px; border: 10px solid; opacity: 0.32; }
.f-top { position: relative; display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
.f-kicker { font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.74rem; }
.f-num { font: 700 0.74rem var(--mono); opacity: 0.85; }
.f-mid { position: relative; margin: auto 0; display: flex; flex-direction: column; gap: 8px; }
.f-bigrow { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.f-big { font-size: clamp(3.2rem, 18vw, 5.4rem); line-height: 0.95; font-weight: 900; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.f-unit { font-size: 1.4rem; font-weight: 800; }
.f-head { margin: 0; font-size: 1.55rem; font-weight: 850; line-height: 1.1; overflow-wrap: anywhere; }
.f-list { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 7px; }
.f-list li { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; font-weight: 700; font-size: 0.95rem; }
.f-rank { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-weight: 900; font-size: 0.85rem; }
.f-lab { overflow-wrap: anywhere; }
.f-val { font-weight: 900; font-variant-numeric: tabular-nums; }
.f-cap { margin: 4px 0 0; font-size: 0.98rem; line-height: 1.35; font-weight: 500; }
.f-mark { position: relative; font-weight: 700; font-size: 0.72rem; opacity: 0.85; }
.face-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 30px; color: #d9cfe6; font-weight: 600; }
.stage-ctl { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* Storyboard */
.boardbox { margin-top: 18px; }
.board { list-style: none; margin: 0; padding: 4px 2px 10px; display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; }
.frame { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; scroll-snap-align: start; }
.frame-btn { position: relative; width: 112px; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; border: 3px solid transparent; padding: 0; cursor: pointer; background: #0e0a14; }
.frame.cur .frame-btn { border-color: var(--coral); }
.frame-cap { font-size: 0.74rem; color: var(--muted); font-weight: 700; }
.face.small { padding: 10px 8px 8px; animation: none; }
.face.small .f-kicker { font-size: 0.48rem; }
.face.small .f-top { margin-top: 0; }
.face.small .f-big { font-size: 1.7rem; }
.face.small .f-unit { font-size: 0.7rem; }
.face.small .f-head { font-size: 0.72rem; line-height: 1.15; }
.face.small .f-list { gap: 2px; }
.face.small .f-list li { grid-template-columns: 12px 1fr auto; gap: 3px; font-size: 0.5rem; }
.face.small .f-rank { width: 12px; height: 12px; font-size: 0.45rem; }
.face.small .f-deco.d1 { width: 60px; height: 60px; right: -20px; top: 14px; }
.face.small .f-deco.d2 { width: 50px; height: 50px; left: -18px; bottom: 10px; border-width: 4px; }

/* Progress */
.progress { margin-top: 18px; }
.stages { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; }
.stage { color: var(--muted); font-size: 0.92rem; }
.stage.done { color: var(--mint); } .stage.active { color: var(--ink); font-weight: 700; }
.stage-ic { font-family: var(--mono); display: inline-block; width: 1.2em; }
.raw { white-space: pre-wrap; overflow-wrap: anywhere; font: 0.8rem var(--mono); background: var(--paper); padding: 10px; border-radius: 10px; max-height: 360px; overflow: auto; }
#rawResult, #how { margin-top: 18px; }

/* Result */
.result { margin-top: 18px; display: grid; gap: 14px; }
.res-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.res-head h2 { margin: 0; font-size: 1.6rem; }
.persona { display: grid; gap: 2px; background: linear-gradient(120deg, #3b1c5a, #7a2e8e); color: #fff; border-radius: 16px; padding: 12px 14px; }
.persona .muted { color: #e9d8ff; }
.persona b { font-size: 1.35rem; }
.askmore { background: var(--warn-bg); color: var(--warn-ink); border-radius: 14px; padding: 12px 14px; }
.askmore h3 { margin: 0 0 6px; }
.asks { margin: 0 0 10px; padding-left: 20px; }
.sharebox h3, .result h3 { margin: 0 0 6px; font-size: 1.05rem; }
.share { margin: 0 0 8px; background: var(--paper); border-radius: 12px; padding: 10px 12px; font-weight: 600; }
.recon { list-style: none; padding: 0; margin: 0; display: grid; gap: 5px; }
.recon li { border-radius: 10px; padding: 6px 10px; font-size: 0.88rem; background: var(--paper); }
.recon li.warn { background: var(--warn-bg); color: var(--warn-ink); }
.recon li.info { background: var(--info-bg); color: var(--info-ink); }
.recon li.none { color: var(--muted); }

/* Exports + history */
.exports, .history { margin-top: 18px; }
.exports h3, .history h3 { margin: 0 0 8px; }
.cardrow { display: flex; flex-wrap: wrap; gap: 8px; }
.hlist { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.hrow { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; flex-wrap: wrap; }
.hinfo { display: grid; flex: 1 1 200px; min-width: 0; }
.hinfo b { overflow-wrap: anywhere; }
.hlist .none { color: var(--muted); }

/* Footer + toasts */
.foot { max-width: 1180px; margin: 10px auto 0; padding: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.86rem; }
.toasts { position: fixed; right: 14px; bottom: 14px; display: grid; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 28px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; box-shadow: var(--shadow); transition: opacity 0.5s; }
.toast.err { background: #b42318; color: #fff; }
.toast a { color: inherit; font-weight: 700; }
.toast.gone { opacity: 0; }

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .col-out { position: static; order: -1; }
  .hero { grid-template-columns: 1fr; }
  .fan { display: none; }
}
@media (max-width: 520px) {
  .grid3 { grid-template-columns: 1fr; }
  .lean-r b { font-size: 1.15rem; }
  .phone { max-width: 300px; }
  .months { height: 76px; }
}
.f-cur { font-size: clamp(2rem, 10vw, 3.2rem); font-weight: 900; margin-right: -6px; }
