:root {
  --paper: #eef1f6; --card: #ffffff; --ink: #1f2433; --muted: #586074; --line: #d7dde8; --accent: #2b477a; --accent-ink: #ffffff;
  --brass: #a8792a; --warm: #9a5a10; --cool: #2f5694; --warn: #9b2f2f; --warn-bg: #f8e4e1; --info-bg: #e5ebf5; --ok-bg: #e3efe8; --ok-ink: #2c6047; --field: #f9fafc;
  --v-sweet: #9a5a10; --v-harsh: #2f5694; --v-true: #5b4a8a; --v-ink: #ffffff;
  --shadow: 0 1px 0 rgba(20, 30, 60, 0.05), 0 8px 22px rgba(20, 30, 60, 0.07);
}
html[data-theme="dark"] {
  --paper: #121521; --card: #1b1f2e; --ink: #e9edf5; --muted: #a9b1c4; --line: #2f3549; --accent: #a8c0f0; --accent-ink: #111726;
  --brass: #d8b065; --warm: #f3b866; --cool: #9ab8ec; --warn: #ff9a8c; --warn-bg: #3a2324; --info-bg: #1f2840; --ok-bg: #1d2e26; --ok-ink: #8fd3ad; --field: #161a27;
  --v-sweet: #f3b866; --v-harsh: #9ab8ec; --v-true: #c6b6f0; --v-ink: #141826;
  --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 16px/1.55 "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif; }
a { color: var(--accent); }
h1, h2, h3, .brand strong { font-family: "Iowan Old Style", Palatino, Georgia, serif; }
code { font-size: 0.88em; background: var(--info-bg); padding: 1px 4px; border-radius: 3px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 0.88rem; } .muted { color: var(--muted); }

.top, .bar { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; box-shadow: var(--shadow); }
.back { text-decoration: none; color: var(--muted); font-size: 0.9rem; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; }
.logo { width: 24px; height: 24px; }
.lg-g { fill: #cdd9ee; stroke: var(--accent); stroke-width: 1.5; } .lg-s { fill: #ffffff; } .lg-b { fill: #8a5a36; }
.session { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip-s { font-size: 0.85rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }

.btn, .pill { font: inherit; font-size: 0.9rem; border: 1.5px solid var(--accent); color: var(--accent); background: transparent; border-radius: 999px; padding: 6px 14px; cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.3; }
.btn:hover:not(:disabled), .pill:hover { background: var(--info-bg); }
.btn.solid, .pill.solid { background: var(--accent); color: var(--accent-ink); }
.btn.solid:hover:not(:disabled) { filter: brightness(1.1); background: var(--accent); color: var(--accent-ink); }
.btn.big { font-size: 1.05rem; padding: 10px 20px; }
.btn.tiny, .pill.tiny { font-size: 0.8rem; padding: 4px 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

main { max-width: 1080px; margin: 0 auto; padding: 18px 16px 30px; }
.hero { padding: 16px 0 6px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.78rem; color: var(--brass); font-weight: 600; }
h1 { font-size: 2.5rem; margin: 4px 0 8px; line-height: 1.1; }
h1 .sub { display: block; font-size: 1.12rem; font-weight: 400; font-style: italic; color: var(--muted); margin-top: 6px; }
.lede { max-width: 740px; }
.samples { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0 4px; }
.sample { font: inherit; font-size: 0.86rem; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 5px 13px; cursor: pointer; }
.sample:hover { border-color: var(--accent); }
.sample.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin: 18px 0; box-shadow: var(--shadow); }
.ch { margin: 0 0 10px; font-size: 1.32rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.no { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--accent); color: var(--accent); font-size: 0.92rem; font-family: "Avenir Next", Helvetica, Arial, sans-serif; }
.free, .paid { font-family: "Avenir Next", Helvetica, Arial, sans-serif; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; border-radius: 999px; padding: 2px 9px; }
.free { background: var(--ok-bg); color: var(--ok-ink); } .paid { background: var(--warn-bg); color: var(--warn); }
.fld { margin: 8px 0; }
.lab { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 3px; }
.inp { width: 100%; font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.inp:focus, .handle:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.seg { display: inline-flex; border: 1.5px solid var(--accent); border-radius: 999px; overflow: hidden; }
.segb { font: inherit; font-size: 0.88rem; border: 0; background: transparent; color: var(--accent); padding: 6px 14px; cursor: pointer; }
.segb[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0 4px; }
.note { background: var(--info-bg); border-left: 3px solid var(--accent); padding: 8px 10px; border-radius: 6px; font-size: 0.9rem; }

.rows { list-style: none; padding: 0; margin: 8px 0; }
.row { display: grid; grid-template-columns: 1.6em minmax(0, 1fr) 7.2em 5.6em 2em; gap: 8px; align-items: center; border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0; background: var(--field); }
.row.f-pos { border-left-color: var(--warm); } .row.f-neg { border-left-color: var(--cool); }
.row.is-peak, .row.is-end { box-shadow: inset 0 0 0 1px var(--brass); }
.rowno { font-family: Georgia, serif; font-weight: 700; }
.rowfeel, .rowmins { display: flex; flex-direction: column; }
.rowfeel .lab, .rowmins .lab { font-weight: 500; font-size: 0.72rem; color: var(--muted); margin: 0; }
.rowtag { grid-column: 2 / -1; font-size: 0.8rem; color: var(--muted); margin: -2px 0 0; }
.rowtag b { color: var(--ink); }
.x { font: inherit; border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.2rem; line-height: 1; padding: 4px 6px; }
.x:hover { color: var(--warn); }

.keep { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr); gap: 18px; align-items: start; }
.globebox { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drawing { width: 100%; border-radius: 12px; overflow: hidden; }
.drawing svg { width: 100%; height: auto; display: block; }
.drawing.curve { border: 1px solid var(--line); -webkit-user-select: none; user-select: none; }
.handle, .hit { cursor: ns-resize; touch-action: none; }
.globe .flake { transform-box: fill-box; }
.globe.shaken .flake { animation: drift 2.6s ease-out 1; }
@keyframes drift { 0% { transform: translate(0, -60px); opacity: 0.2; } 30% { opacity: 1; } 100% { transform: translate(0, 0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .globe.shaken .flake { animation: none; } }
.numbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.num { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--field); }
.num b { display: block; font-family: Georgia, serif; font-size: 1.45rem; line-height: 1.1; }
.num span { font-size: 0.78rem; color: var(--muted); }
.vline { grid-column: 1 / -1; font-size: 0.92rem; margin: 2px 0; }
.vtag { display: inline-block; font-size: 0.78rem; font-weight: 700; border-radius: 999px; padding: 2px 10px; color: var(--v-ink); white-space: nowrap; letter-spacing: 0.02em; }
.vtag.v-sweeter-in-memory { background: var(--v-sweet); } .vtag.v-harsher-in-memory { background: var(--v-harsh); } .vtag.v-true-to-life { background: var(--v-true); }
.whatif { border: 1px dashed var(--brass); border-radius: 10px; padding: 8px 12px; margin-top: 8px; }
.whatif input[type="range"] { width: 100%; accent-color: var(--brass); }
.wv { font-family: Georgia, serif; font-weight: 700; }

.progress { border: 1px dashed var(--brass); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.steps { list-style: none; padding: 0; margin: 6px 0; }
.step { color: var(--muted); } .step.done { color: var(--ok-ink); } .step.active { color: var(--ink); font-weight: 600; }
.step-ic { display: inline-block; width: 1em; font-family: monospace; }
.raw { white-space: pre-wrap; background: var(--paper); padding: 10px; border-radius: 8px; font-size: 0.82rem; max-height: 320px; overflow: auto; }

.result { margin-top: 12px; border-top: 2px solid var(--brass); padding-top: 10px; }
.result.empty .rnotes, .result.empty #rReconH, .result.empty .recon { display: none; }
.rhead { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 0.75rem; letter-spacing: 0.08em; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--muted); }
.badge.on { border-color: var(--accent); color: var(--accent); }
.caption { font-family: Georgia, serif; font-style: italic; font-size: 1.3rem; text-align: center; margin: 12px 0 4px; color: var(--brass); }
.headline { font-family: Georgia, serif; font-size: 1.18rem; margin: 10px 0; }
.rnotes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.rnote { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--field); }
.rnote dt { font-weight: 700; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.rnote dd { margin: 3px 0 0; }
.rnote .copy1 { margin-top: 6px; }
.recon { padding-left: 18px; font-size: 0.9rem; }
.recon li.bad { color: var(--warn); font-weight: 600; } .recon li.warn { color: var(--warn); } .recon li.none { color: var(--muted); list-style: none; margin-left: -18px; }
.saved { list-style: none; padding: 0; margin: 8px 0; }
.hrow { display: flex; gap: 10px; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding: 8px 0; }
.hrow.none { color: var(--muted); font-style: italic; }
.hinfo { display: flex; flex-direction: column; min-width: 0; } .hinfo b { overflow-wrap: anywhere; }
.hbtns { display: flex; gap: 6px; flex-shrink: 0; }
.about p { max-width: 820px; }
.foot { max-width: 1080px; margin: 0 auto; padding: 8px 16px 40px; font-size: 0.85rem; color: var(--muted); }
.toasts { position: fixed; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 20; max-width: min(380px, calc(100vw - 28px)); }
.toast { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 8px 12px; font-size: 0.9rem; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15); transition: opacity 0.5s; }
.toast.err { border-left-color: var(--warn); } .toast.gone { opacity: 0; }

@media (max-width: 820px) {
  .keep { grid-template-columns: 1fr; }
  .globebox .globe { max-width: 360px; }
  .rnotes { grid-template-columns: 1fr; }
  h1 { font-size: 2rem; }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1.4em minmax(0, 1fr) minmax(0, 1fr) 2em; row-gap: 6px; }
  .row > .inp { grid-column: 2 / 4; grid-row: 1; }
  .row .x { grid-row: 1; grid-column: 4; }
  .row .rowfeel { grid-column: 2; grid-row: 2; } .row .rowmins { grid-column: 3; grid-row: 2; }
  .row .rowtag { grid-column: 2 / -1; grid-row: 3; margin-top: 0; }
  .numbers { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .num b { font-size: 1.2rem; }
}
@media (max-width: 420px) {
  .top { padding: 8px 12px; gap: 8px; }
  .back-t { display: none; }
  .brand { font-size: 1rem; }
  .btn { padding: 5px 10px; }
  .card { padding: 14px 12px; }
  .seg { display: flex; } .segb { flex: 1; padding: 6px 8px; }
}
@media print {
  .top, .samples, .actions, .exports, #runBtn, .toasts, .foot, .hero .lede, .whatif, #shake { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
}
