:root {
  --bg: #f4efe6; --surface: #fffdf8; --surface2: #ece5d8; --ink: #1b1a17; --muted: #5f5a50;
  --line: #d9cfbe; --accent: #c2541b; --accent-ink: #fff; --pine: #1d2b24; --pine-ink: #f4efe6;
  --hook: #c2541b; --backfill: #6d3fa0; --live: #1f7a3c; --setup: #1f5fa8; --payoff: #a87a00; --close: #59544a;
  --e1: #c2541b; --e2: #a87a00; --e3: #1f5fa8; --e4: #1f7a3c; --e5: #6d3fa0;
  --up: #1f7a3c; --down: #b3261e;
  --r: 16px; --shadow: 0 1px 0 rgba(0,0,0,.04), 0 6px 18px rgba(60,40,10,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121512; --surface: #1c201c; --surface2: #262b26; --ink: #f2eee6; --muted: #b3ada1;
    --line: #353b35; --accent: #ff8a4c; --accent-ink: #1a0f06; --pine: #0b0e0c; --pine-ink: #f2eee6;
    --hook: #ff8a4c; --backfill: #c39af0; --live: #6fd68f; --setup: #84b5ff; --payoff: #f2c84b; --close: #c9c3b6;
    --e1: #ff8a4c; --e2: #f2c84b; --e3: #84b5ff; --e4: #6fd68f; --e5: #c39af0;
    --up: #6fd68f; --down: #ff7a70; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
h2 { font-size: 1.35rem; margin: 22px 0 10px; line-height: 1.2; }
h3 { font-size: 1.1rem; margin: 0 0 6px; }
p { margin: 6px 0; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--pine); color: var(--pine-ink); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { font-size: 1.6rem; }
.t1 { font-weight: 800; font-size: 1.05rem; line-height: 1.1; }
.t2 { font-size: .85rem; opacity: .8; }
.who { border: 2px solid var(--pine-ink); background: transparent; color: var(--pine-ink); border-radius: 999px; padding: 6px 14px; font-weight: 800; white-space: nowrap; }
.who .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #6fd68f; margin-right: 6px; vertical-align: middle; }
.who .dot.off { background: #ff7a70; }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px 24px; outline: none; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--surface); border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 0 10px; font-size: .8rem; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button span { font-size: 1.45rem; line-height: 1.1; filter: grayscale(.6); }
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button[aria-selected="true"] span { filter: none; transform: scale(1.08); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin: 0 0 12px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 2px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: .95rem; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill { display: inline-block; font-size: .78rem; font-weight: 800; letter-spacing: .02em; padding: 3px 9px; border-radius: 999px; background: var(--surface2); color: var(--ink); vertical-align: middle; }
.mode { color: #fff; }
@media (prefers-color-scheme: dark) { .mode { color: #111; } }
.m-hook { background: var(--hook); } .m-backfill { background: var(--backfill); } .m-live { background: var(--live); }
.m-setup { background: var(--setup); } .m-payoff { background: var(--payoff); } .m-close { background: var(--close); }

/* Trip */
.hero { background: var(--pine); color: var(--pine-ink); border-radius: var(--r); padding: 16px; margin: 8px 0 14px; }
.hero .big { font-size: 1.35rem; font-weight: 800; line-height: 1.25; }
.progress { height: 10px; border-radius: 999px; background: rgba(255,255,255,.18); overflow: hidden; margin-top: 12px; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.map { width: 100%; height: auto; display: block; }
.map .lake { fill: color-mix(in srgb, var(--setup) 22%, transparent); stroke: color-mix(in srgb, var(--setup) 45%, transparent); }
.map .route { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.map .route.next { stroke-dasharray: 2 7; opacity: .6; }
.map .lbl { font-size: 12px; font-weight: 800; fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.map .grid { stroke: var(--line); stroke-width: 1; }
.map .node { stroke: var(--surface); stroke-width: 3; cursor: pointer; }
.map .pulse { fill: none; stroke: var(--live); stroke-width: 3; animation: pulse 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { from { opacity: .9; transform: scale(1); } to { opacity: 0; transform: scale(2.6); } }
@media (prefers-reduced-motion: reduce) { .map .pulse { animation: none; opacity: .5; } }
.stop { display: flex; gap: 12px; align-items: flex-start; }
.stop .num { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: .9rem; }
@media (prefers-color-scheme: dark) { .stop .num { color: #111; } }
.stop ul { margin: 6px 0 0; padding-left: 18px; }
.stop .head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.thread { display: grid; grid-template-columns: 2.2rem 1fr; gap: 4px 10px; align-items: start; }
.thread .ic { font-size: 1.7rem; line-height: 1; }
.thread .arrow { color: var(--muted); font-size: .92rem; }

/* Story */
.ephead { border-left: 8px solid var(--epc, var(--accent)); }
.ephead .title { font-size: 1.4rem; font-weight: 800; line-height: 1.2; margin: 2px 0 6px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin: 0 0 14px; overflow: hidden; box-shadow: var(--shadow); scroll-margin-top: 80px; }
.panel.flash { outline: 4px solid var(--accent); }
.frame { position: relative; background: var(--surface2); aspect-ratio: 3 / 1.25; display: grid; place-items: center; color: var(--ink); border-bottom: 1px solid var(--line); }
.frame svg { height: 82%; width: auto; opacity: .85; }
.frame .n { position: absolute; left: 10px; top: 8px; font-weight: 900; font-size: .9rem; opacity: .7; }
.frame .m { position: absolute; right: 10px; top: 8px; }
.frame .s { position: absolute; left: 10px; bottom: 8px; font-size: .78rem; font-weight: 700; color: var(--muted); }
.frame .tg { position: absolute; right: 10px; bottom: 8px; }
.panel.done .frame::after { content: "✓ FILMED"; position: absolute; inset: auto auto 50% 50%; transform: translate(-50%, 50%) rotate(-8deg); border: 4px solid var(--live); color: var(--live); font-weight: 900; font-size: 1.4rem; padding: 2px 12px; border-radius: 8px; background: color-mix(in srgb, var(--surface) 75%, transparent); }
.pbody { padding: 12px 16px 6px; }
.beat { font-weight: 800; font-size: 1.15rem; line-height: 1.25; }
.prompts { margin: 8px 0; padding-left: 0; list-style: none; }
.prompts li { position: relative; padding: 6px 0 6px 26px; border-top: 1px dashed var(--line); }
.prompts li::before { content: "💬"; position: absolute; left: 0; top: 6px; font-size: .95rem; }
.broll { font-size: .92rem; color: var(--muted); }
.tip { font-size: .92rem; background: color-mix(in srgb, var(--payoff) 14%, transparent); border-radius: 10px; padding: 8px 10px; margin: 8px 0 4px; }
.actions { display: flex; gap: 8px; padding: 8px 12px 12px; flex-wrap: wrap; }
.btn { border: 2px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px 12px; font-weight: 800; font-size: .95rem; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.btn.on-check { background: var(--live); border-color: var(--live); color: #fff; }
.btn.on-up { border-color: var(--up); background: color-mix(in srgb, var(--up) 16%, var(--surface)); }
.btn.on-down { border-color: var(--down); background: color-mix(in srgb, var(--down) 14%, var(--surface)); }
.btn .who-l { font-size: .72rem; font-weight: 900; opacity: .8; }
.btn.grow { flex: 1; justify-content: center; }
.comments { padding: 0 16px 12px; }
.cmt { background: var(--surface2); border-radius: 12px; padding: 8px 10px; margin: 6px 0; font-size: .95rem; }
.cmt b { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.cmt .x { float: right; border: 0; background: none; color: var(--muted); font-size: .85rem; }
.cform { display: flex; gap: 8px; margin-top: 8px; }
.cform textarea { flex: 1; font: inherit; font-size: 1rem; border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; background: var(--surface); color: var(--ink); min-height: 44px; resize: vertical; }

/* Cards */
.seg2 { display: flex; background: var(--surface2); border-radius: 12px; padding: 4px; margin: 8px 0 10px; }
.seg2 button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 800; }
.seg2 button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); }
.deal { background: var(--surface); border: 3px solid var(--ink); border-radius: 22px; padding: 18px; min-height: 52vh; display: flex; flex-direction: column; box-shadow: var(--shadow); touch-action: pan-y; user-select: none; }
.deal .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.deal .q { font-size: clamp(1.6rem, 7vw, 2.3rem); font-weight: 800; line-height: 1.2; margin: auto 0; padding: 18px 0; }
.deal .whoask { font-size: 1.05rem; font-weight: 900; color: var(--accent); }
.deal.used { opacity: .6; }
.dealbar { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.dealbar .btn { justify-content: center; min-height: 56px; font-size: 1.05rem; }
.count { text-align: center; color: var(--muted); font-size: .9rem; margin-top: 8px; }
.tone { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.plist .card { display: flex; flex-direction: column; gap: 6px; }
.plist .card.used .ptext { text-decoration: line-through; color: var(--muted); }
.ptext { font-weight: 700; font-size: 1.08rem; }
.prow { display: flex; gap: 6px; flex-wrap: wrap; }
.prow .btn { min-height: 40px; padding: 6px 10px; font-size: .88rem; }

/* To-do */
.list h3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bar { height: 8px; border-radius: 999px; background: var(--surface2); overflow: hidden; margin: 6px 0 4px; }
.bar > i { display: block; height: 100%; background: var(--live); }
.chk { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-top: 1px solid var(--line); }
.chk input { flex: none; width: 28px; height: 28px; margin: 0; accent-color: var(--live); }
.chk.done .ct { text-decoration: line-through; color: var(--muted); }
.chk .ref { display: inline-block; margin-top: 4px; font-size: .82rem; font-weight: 800; color: var(--accent); border: 0; background: none; padding: 0; }
.note { display: grid; grid-template-columns: 2rem 1fr; gap: 2px 10px; }
.note .ic { font-size: 1.4rem; }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal .box { background: var(--surface); color: var(--ink); border-radius: 20px; padding: 22px; max-width: 420px; width: 100%; text-align: center; }
.modal .box .btn { width: 100%; justify-content: center; font-size: 1.2rem; min-height: 60px; margin-top: 10px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 700; z-index: 60; max-width: 90vw; }
.toast[hidden] { display: none; }
.empty { text-align: center; padding: 60px 16px; }
.empty .big { font-size: 3rem; }
