:root {
  --bg: #0E1114; --panel: #15191E; --raised: #1C2127; --hover: #171C22; --border: #2A3038;
  --grid: #1F252C; --text: #E8E4D8; --text2: #B9BDC3; --sand: #C9C4B6; --muted: #9098A1;
  --faint: #5A626B; --accent: #F2A33A; --accent-hover: #FFC170; --blue: #6FA3F2;
  --green: #4CC38A; --red: #F07060; --zone-orange: #3A2E14; --zone-red: #3A1C19;
  --cell-orange: #2A2112; --cell-red: #2A1614;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-weight: 600; margin: 0; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }
.error { color: var(--red); min-height: 1.2em; }
.mono, .label { font-family: var(--mono); }
.label { font-size: 11px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.green { color: var(--green); } .red { color: var(--red); } .orange { color: var(--accent); }

/* buttons and fields */
.btn { background: var(--raised); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.accent { background: var(--accent); color: #17130B; border-color: var(--accent); font-weight: 600; }
.btn.accent:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0 4px; }
input, select, textarea { background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input.bad { border-color: var(--red); }
textarea { width: 100%; resize: vertical; }

/* welcome page (login) */
.welcome { min-height: 100vh; display: flex; flex-direction: column; }
.w-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 32px; border-bottom: 1px solid var(--border); }
.w-top .brand { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-weight: 600;
  font-size: 13px; letter-spacing: .06em; }
.w-top .brand img { width: 28px; height: 28px; }
.w-tag { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--accent);
  border: 1px solid var(--accent); padding: 2px 8px; border-radius: 2px; }
.w-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 56px 32px; }
.w-wrap { width: 100%; max-width: 1240px; display: flex; flex-wrap: wrap; align-items: center; gap: 64px; }
.w-left { flex: 1 1 440px; min-width: 0; display: flex; flex-direction: column; gap: 28px; }
.w-title { font-weight: 600; font-size: clamp(36px, 5.2vw, 68px); line-height: 1.03; letter-spacing: -.03em;
  text-wrap: balance; }
.w-lead { margin: 16px 0 0; max-width: 520px; font-size: 18px; line-height: 1.55; color: var(--muted); }
.w-form { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.w-form label { font-size: 14px; font-weight: 500; }
.w-code { position: relative; }
.w-cells { display: flex; gap: 6px; }
.w-cell { flex: 0 0 auto; width: 46px; height: 58px; display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 2px; font-family: var(--mono);
  font-size: 24px; font-weight: 500; transition: border-color .12s; }
.w-cell.filled { background: var(--raised); border-color: var(--faint); }
.w-cell.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.w-cell.err { border-color: var(--red); }
.w-code input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: text; border: 0;
  font-size: 16px; }
.w-help { margin: 0; font-size: 13px; color: var(--muted); }
.w-err { color: var(--red); }
.w-err:empty { display: none; }
.w-btn { height: 56px; border: 0; border-radius: 2px; cursor: pointer; font: 600 16px var(--sans);
  background: var(--border); color: var(--text2); transition: background .15s, color .15s; }
.w-btn.ready { background: var(--accent); color: var(--bg); }
.w-btn.ready:hover { background: var(--accent-hover); }
.w-btn:disabled { cursor: progress; opacity: .8; }
.w-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.w-note { margin: 0; font-size: 13px; color: var(--muted); max-width: 560px; }
.w-panel { flex: 1 1 440px; min-width: 0; margin: 0; background: var(--panel); border: 1px solid var(--border); }
.w-phead { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); }
.w-pname { font-size: 12px; color: var(--muted); text-align: right; }
.w-kpis { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--border); font-family: var(--mono); }
.w-kpis div { flex: 1 1 120px; padding: 10px 16px; }
.w-kpis div + div { border-left: 1px solid var(--border); }
.w-kpis small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.w-kpis b { display: block; font-weight: 400; font-size: 18px; margin-top: 2px; }
.w-kpis i { display: block; font-style: normal; font-family: var(--sans); font-size: 11px; color: var(--faint); }
.w-chart { padding: 14px 16px 4px; }
.w-chart svg { display: block; width: 100%; height: auto; font-family: var(--mono); font-size: 11px; }
.w-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 6px 16px 4px; font-size: 12px; color: var(--text2); }
.w-legend > span { display: flex; align-items: center; gap: 6px; }
.w-legend i { display: inline-block; width: 16px; }
.sw-plan { height: 2px; background: var(--accent); }
.sw-late { border-top: 2px dashed var(--sand); }
.sw-red { height: 9px; background: var(--zone-red); border: 1px solid #5A2A24; }
.w-caption { padding: 4px 16px 14px; font-size: 13px; color: var(--muted); }
.w-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 14px 32px;
  border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
@keyframes w-draw { from { stroke-dashoffset: 1400; } to { stroke-dashoffset: 0; } }
@keyframes w-fade { from { opacity: 0; } to { opacity: 1; } }
.w-line { stroke-dasharray: 1400; animation: w-draw 1.8s cubic-bezier(.3, .7, .2, 1) .2s both; }
.w-late { animation: w-fade .6s ease 1.5s both; }
@media (prefers-reduced-motion: reduce) { .w-line, .w-late { animation: none; } }
@media (max-width: 600px) {
  .w-top, .w-foot { padding-left: 16px; padding-right: 16px; }
  .w-main { padding: 28px 16px; }
  .w-wrap { gap: 36px; }
  .w-lead { font-size: 16px; }
  .w-cells { gap: 4px; }
  .w-cell { width: calc((100vw - 32px - 10 * 4px) / 11); height: 48px; font-size: 18px; }
  .w-kpis div { flex-basis: 100px; padding: 8px 12px; }
  .w-kpis b { font-size: 15px; white-space: nowrap; }
  .w-kpis div { padding: 8px 10px; }
}

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font: 600 14px var(--mono); letter-spacing: .1em; }
.brand img { width: 30px; height: 30px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.top-actions select { max-width: 340px; }
.who { color: var(--muted); font-size: 12px; margin-left: 6px; }
.ticker { display: flex; overflow-x: auto; border-bottom: 1px solid var(--border); background: var(--bg); }
.ticker div { padding: 9px 16px; border-right: 1px solid var(--border); white-space: nowrap;
  font: 13px var(--mono); }
.ticker span { color: var(--muted); margin-right: 8px; font-size: 11px; letter-spacing: .06em; }
.tabs { display: flex; background: var(--panel); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 16px;
  color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); background: var(--bg); }
.badge { font: 700 11px var(--mono); padding: 1px 5px; border-radius: 3px; margin-left: 4px;
  animation: glow 1.4s infinite alternate; }
.badge.red { background: var(--red); color: var(--bg); } .badge.orange { background: var(--accent); color: var(--bg); }
@keyframes glow { from { opacity: 1; } to { opacity: .45; } }
.status-bar { background: var(--cell-red); color: var(--red); padding: 8px 16px; border-bottom: 1px solid var(--border); }

main { padding: 0 0 80px; }
.page { display: none; padding: 16px; max-width: 1400px; }
.page.on { display: block; }
.section { margin: 18px 0 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: 3fr 2fr; gap: 28px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.hint { color: var(--muted); font-size: 12px; }

/* verdict tags */
.tag { font: 700 11px var(--mono); padding: 2px 7px; border: 1px solid; border-radius: 4px; letter-spacing: .06em; }
.tag.ok { color: var(--green); } .tag.orange { color: var(--accent); } .tag.red { color: var(--red); }
.verdict { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.verdict h2 { font-size: 18px; font-weight: 500; }

/* spreadsheet-like tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { background: var(--panel); color: var(--muted); font: 600 11px var(--mono); letter-spacing: .05em;
  text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th.help { cursor: help; text-decoration: underline dotted var(--faint); text-underline-offset: 3px; }
th.l, td.l { text-align: left; }
td { padding: 7px 10px; border-bottom: 1px solid var(--grid); text-align: right;
  font-family: var(--mono); white-space: nowrap; }
td.sans { font-family: var(--sans); white-space: normal; min-width: 150px; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--hover); }
tr.sel td { background: var(--raised); }
td.orange-cell { background: var(--cell-orange); color: var(--accent); }
td.red-cell { background: var(--cell-red); color: var(--red); }
td.b { font-weight: 700; }
td.dim { color: var(--muted); }
tr.group td { background: var(--bg); color: var(--sand); font: 600 12px var(--sans); text-align: left; padding-top: 12px; }
tr.total td { font-weight: 700; border-top: 1px solid var(--border); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; vertical-align: -1px; }

/* the inputs sheet */
.sheet td { padding: 4px 10px; }
.sheet td.l { font-family: var(--sans); }
.sheet .type { color: var(--muted); font: 11px var(--mono); }
.sheet input.cell { width: 130px; text-align: right; font-family: var(--mono); background: #1B2129;
  border: 1px solid #343C46; border-radius: 4px; padding: 5px 8px; }
.sheet input.cell:hover { border-color: var(--muted); }
.sheet input.cell:focus { border-color: var(--accent); outline: none; background: var(--raised); }
.sheet .unit { color: var(--muted); font: 11px var(--mono); text-align: left; }
.sheet .means { color: var(--muted); font: 12px var(--sans); white-space: normal; text-align: left; min-width: 260px; }
.season input.cell { width: 56px; text-align: center; }
.calc { color: var(--sand); }

/* scenarios list */
.scen { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--grid); }
.scen:last-child { border-bottom: 0; }
.scen.sel { background: var(--raised); }
.scen .name { flex: 1; cursor: pointer; }
.scen .warn { font: 700 11px var(--mono); cursor: pointer; }

/* charts */
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font: 11px var(--mono); fill: var(--muted); }
.tip { position: absolute; pointer-events: none; background: var(--raised); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; font: 12px var(--mono); white-space: nowrap; z-index: 5; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.legend button { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 3px 10px; cursor: pointer; font-size: 12px; }
.legend button.off { opacity: .4; text-decoration: line-through; }
.zones { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.zones i { display: inline-block; width: 12px; height: 8px; margin-right: 6px; border: 1px solid; }

/* advice */
.ideas li, .steps li { margin: 6px 0; }
.lesson { margin-bottom: 12px; }
.lesson h3 { font-size: 15px; }
.yours { background: var(--bg); border-radius: 6px; padding: 10px 12px; margin-top: 10px; }
.tipcard { border-left: 3px solid var(--faint); padding: 8px 12px; margin-bottom: 8px; background: var(--panel); border-radius: 4px; }
.tipcard.danger { border-color: var(--red); } .tipcard.warn { border-color: var(--accent); }
.tipcard.good { border-color: var(--green); } .tipcard.info { border-color: var(--blue); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 5px 10px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--raised); color: var(--text); }

/* figures list */
.figs div { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--grid); cursor: help; }
.figs b { font-family: var(--mono); }

/* guide */
.guide { max-width: 860px; }
.guide h1 { font-size: 24px; margin: 8px 0 10px; }
.guide h2 { font-size: 17px; margin: 28px 0 8px; color: var(--accent); }
.guide .lead { font-size: 16px; color: var(--text2); }
.guide .term { display: grid; grid-template-columns: 240px 1fr; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--grid); }
@media (max-width: 700px) { .guide .term { grid-template-columns: 1fr; gap: 2px; } }
.guide .tip-box { background: var(--panel); border-left: 3px solid var(--accent); padding: 10px 14px; margin: 10px 0; border-radius: 4px; }
.guide .step { display: grid; grid-template-columns: 34px 1fr; gap: 8px; margin: 10px 0; }
.guide .step b.n { color: var(--accent); font-family: var(--mono); font-size: 16px; }

/* chat */
main .page { padding-bottom: 104px; } /* room so the round button never covers the last row */
.chat-button { position: fixed; right: 22px; bottom: 22px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); border: 0; padding: 0; cursor: pointer; z-index: 21; display: grid; place-items: center;
  box-shadow: 0 6px 18px #0009; transition: transform .15s ease, background .15s ease, box-shadow .2s ease; }
.chat-button:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 10px 24px #000a, 0 0 0 6px #F2A33A22; }
.chat-button:active { transform: translateY(0) scale(.96); }
.chat-button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.chat-button svg { width: 26px; height: 26px; grid-area: 1 / 1; transition: opacity .15s ease, transform .2s ease; }
.chat-button .i-open path { fill: #17130B; }
.chat-button .i-open .dot { fill: var(--accent); transition: fill .15s ease; }
.chat-button:hover .i-open .dot { fill: var(--accent-hover); }
.chat-button .i-close { fill: none; stroke: #17130B; stroke-width: 2.4; stroke-linecap: round; opacity: 0; transform: rotate(-90deg); }
.chat-button.open .i-open { opacity: 0; transform: rotate(90deg) scale(.6); }
.chat-button.open .i-close { opacity: 1; transform: none; }
.chat-button.hello { animation: hello 1.6s ease-out 1s 2; }
@keyframes hello { 0% { box-shadow: 0 6px 18px #0009, 0 0 0 0 #F2A33A70; } 100% { box-shadow: 0 6px 18px #0009, 0 0 0 18px #F2A33A00; } }

.chat { position: fixed; right: 22px; bottom: 92px; width: min(400px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 124px)); background: var(--panel); border: 1px solid #3A424C;
  border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; z-index: 20;
  box-shadow: 0 18px 50px #000c; transform-origin: bottom right; animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 14px;
  background: var(--raised); border-bottom: 1px solid var(--border); }
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.chat-title strong { font-size: 15px; }
.chat-title span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title .live { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 6px; vertical-align: 1px; }
.avatar { width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--bg); border: 1px solid var(--border);
  display: grid; place-items: center; }
.avatar img { width: 15px; height: 15px; }
.avatar.big { width: 36px; height: 36px; }
.avatar.big img { width: 20px; height: 20px; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; background: none; border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chat-log { position: relative; flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.msg.me { justify-content: flex-end; }
.bubble { max-width: 86%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; line-height: 1.5;
  overflow-wrap: anywhere; animation: rise .16s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.bubble.me { background: var(--accent); color: #17130B; border-bottom-right-radius: 4px; }
.bubble.bot { background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.error { border-color: #7A3328; color: #F3B1A6; }
.bubble.typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 34px; animation: rise .16s ease-out; }
.chips.old { display: none; }
.chips button { background: transparent; border: 1px solid #3A424C; border-radius: 999px; padding: 5px 12px;
  font-size: 12.5px; cursor: pointer; color: var(--text2); text-align: left; transition: border-color .12s, color .12s, background .12s; }
.chips button:hover { border-color: var(--accent); color: var(--text); background: #F2A33A12; }
.chips button.back { color: var(--muted); border-style: dashed; }
.plan { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-left: 34px; animation: rise .16s ease-out; }
.plan .opt { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
.plan .steps { padding-left: 18px; margin: 6px 0 0; }
.plan > .label { display: block; margin-top: 14px; }
.plan > .label:first-child { margin-top: 0; }
.chat-form { display: flex; gap: 8px; align-items: center; padding: 10px 12px 12px; border-top: 1px solid var(--border); background: var(--panel); }
.chat-form input { flex: 1; min-width: 0; border-radius: 999px; padding: 9px 14px; background: var(--bg); border-color: #3A424C; }
.chat-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #F2A33A26; }
.send { width: 38px; height: 38px; flex: none; border-radius: 50%; border: 0; padding: 0; background: var(--accent); cursor: pointer;
  display: grid; place-items: center; transition: background .12s, opacity .12s; }
.send:hover:not(:disabled) { background: var(--accent-hover); }
.send:disabled { opacity: .35; cursor: default; }
.send svg { width: 18px; height: 18px; fill: none; stroke: #17130B; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 600px) {
  .chat { inset: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; border: 0; }
  .chat-button.open { display: none; }
  .chips { padding-left: 0; } .plan { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.popover { position: fixed; max-width: 360px; background: var(--raised); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px; z-index: 30; white-space: pre-wrap; box-shadow: 0 8px 30px #000a; }
.popover b { display: block; margin-bottom: 4px; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 20px; max-width: 420px; }
dialog::backdrop { background: #000a; }

@media (max-width: 700px) {
  .page { padding: 12px; }
  .top-actions select { max-width: 100%; flex: 1 1 100%; }
  .chat { right: 8px; bottom: 80px; }
}
@media (max-width: 600px) { .chat { inset: 0; } }

/* compact warning bar (Week by week) */
.alert { display: flex; gap: 12px; align-items: flex-start; margin: 12px 0 8px; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--border); border-left-width: 3px; border-radius: 8px; }
.alert.ok { border-left-color: var(--green); } .alert.orange { border-left-color: var(--accent); } .alert.red { border-left-color: var(--red); }
.alert .tag { flex: none; margin-top: 1px; }
.alert b { display: block; font-weight: 500; font-size: 15px; }
.alert span:not(.tag) { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.caption { color: var(--muted); font-size: 12px; margin: 4px 0 14px; }

/* "a new version is ready" bar */
.update { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 40; display: flex;
  gap: 14px; align-items: center; padding: 10px 12px 10px 16px; background: var(--raised);
  border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 10px 30px #000b; max-width: calc(100vw - 32px); }

/* phones: the sheet keeps Line, Value and Unit; the top bar stays compact */
@media (max-width: 700px) {
  .sheet:not(.season) th:nth-child(2), .sheet:not(.season) th:nth-child(5),
  .sheet .type, .sheet .means { display: none; }
  .sheet input.cell { width: 100%; min-width: 84px; }
  .sheet td.l { white-space: normal; }
  .sheet select { max-width: 130px; }
  .sheet td { padding: 4px 6px; }
  .top { padding: 8px 12px; gap: 8px; }
  .top-actions { gap: 6px; }
  .top-actions .btn { padding: 5px 9px; font-size: 13px; }
  #who { display: none; }
}

/* "experts coming soon": blurred placeholders, no names */
.soon .ghost { filter: blur(3px); opacity: .55; margin-bottom: 10px; pointer-events: none; user-select: none; }
.g-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.g-av { width: 34px; height: 34px; border-radius: 50%; background: #2F3640; flex: none; }
.g-lines { flex: 1; } .g-lines i { display: block; height: 9px; border-radius: 4px; background: #2F3640; margin: 6px 0; }
.soon-title { display: block; margin: 2px 0 4px; }

/* intro for new joiners: full screen chapters */
.intro { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: grid;
  grid-template-rows: auto 1fr auto; overflow: hidden; animation: intro-in .5s ease both; }
.intro.closing { animation: intro-out .45s ease both; }
@keyframes intro-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes intro-out { to { opacity: 0; transform: scale(1.015); } }
/* the background: twelve month columns, like a ledger, fading toward the top */
.intro-ledger { position: absolute; inset: 0; pointer-events: none; display: grid; grid-template-columns: repeat(12, 1fr);
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,.9), rgba(0,0,0,0) 85%);
  mask-image: linear-gradient(to top, rgba(0,0,0,.9), rgba(0,0,0,0) 85%); }
.intro-ledger span { border-left: 1px solid #171B20; display: flex; align-items: flex-end; padding: 0 0 92px 8px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: #2A3038; }
.intro-top { position: relative; display: flex; align-items: center; gap: 24px; padding: 18px 40px;
  border-bottom: 1px solid var(--border); }
.intro-top .brand { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-weight: 600;
  font-size: 12px; letter-spacing: .08em; white-space: nowrap; }
.intro-top .brand img { width: 26px; height: 26px; }
.intro-steps { list-style: none; margin: 0 auto; padding: 0; display: flex; gap: 6px; }
.intro-steps li { min-width: 96px; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--faint);
  cursor: pointer; display: grid; gap: 7px; }
.intro-steps li::before { content: ""; height: 2px; background: var(--border); border-radius: 1px;
  background-image: linear-gradient(var(--accent), var(--accent)); background-repeat: no-repeat;
  background-size: 0 100%; transition: background-size .5s ease; }
.intro-steps li.done::before, .intro-steps li.on::before { background-size: 100% 100%; }
.intro-steps li.on { color: var(--text); }
.intro-steps li.done { color: var(--muted); }
.intro-skip { background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px 0;
  white-space: nowrap; }
.intro-skip::after { content: " →"; }
.intro-skip:hover { color: var(--text); }
.intro-stage { position: relative; min-height: 0; overflow: auto; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  align-items: center; gap: 56px; padding: 32px 40px; max-width: 1360px; width: 100%; margin: 0 auto; }
.intro-num { font-family: var(--mono); font-size: 13px; color: var(--accent); letter-spacing: .1em; margin-bottom: 18px; }
.intro-num b { font-size: 64px; line-height: 1; font-weight: 500; letter-spacing: -.04em; color: transparent;
  -webkit-text-stroke: 1px #3A4049; display: block; margin-bottom: 10px; }
.intro-kicker { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--accent); text-transform: uppercase; }
.intro h1 { font-size: clamp(34px, 4.6vw, 64px); line-height: 1.04; letter-spacing: -.03em; margin: 10px 0 22px;
  text-wrap: balance; max-width: 13ch; }
.intro-body { display: grid; gap: 14px; font-size: 17px; line-height: 1.6; color: var(--text2); max-width: 520px; }
.intro-body p { margin: 0; }
.intro-body b { color: var(--text); font-weight: 600; }
.intro-goals { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--border); }
.intro-goals li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border);
  font-size: 15px; }
.intro-goals li span { font-family: var(--mono); font-size: 12px; color: var(--accent); padding-top: 3px; }
.intro-visual { min-width: 0; }
.intro-foot { position: relative; display: flex; align-items: center; gap: 16px; padding: 18px 40px 22px; }
.intro-hint { margin: 0 auto; font-family: var(--mono); font-size: 11px; color: var(--faint); letter-spacing: .06em; }
.intro-back, .intro-next { height: 48px; padding: 0 22px; border-radius: 2px; font: 600 15px var(--sans); cursor: pointer; }
.intro-back { background: none; border: 1px solid var(--border); color: var(--text2); }
.intro-back:hover { border-color: var(--faint); color: var(--text); }
.intro-next { background: var(--accent); border: 0; color: var(--bg); min-width: 170px; }
.intro-next::after { content: "  →"; }
.intro-next:hover { background: var(--accent-hover); }
.intro button:focus-visible, .intro-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* chapter changes: the old one fades up and out, the new one rises in, line by line */
.intro-stage.out .intro-text, .intro-stage.out .intro-visual { opacity: 0; transform: translateY(-10px);
  transition: opacity .22s ease, transform .22s ease; }
.intro-stage.in .intro-num, .intro-stage.in .intro-kicker, .intro-stage.in h1, .intro-stage.in .rise {
  animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; }
.intro-stage.in .intro-kicker { animation-delay: .05s; } .intro-stage.in h1 { animation-delay: .1s; }
.intro-stage.in .intro-kicker { display: inline-block; }
.intro-stage.in .rise { animation-delay: .2s; } .intro-stage.in .rise:nth-child(2) { animation-delay: .28s; }
.intro-stage.in .rise:nth-child(3) { animation-delay: .36s; }
.intro-stage.in .intro-visual { animation: fade-slow .9s ease .15s both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fade-slow { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }

/* visuals */
.iv-chart svg { display: block; width: 100%; height: auto; font-family: var(--mono); font-size: 11px; overflow: visible; }
.iv-cap { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: .06em;
  color: var(--muted); padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.iv-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 10px; font-size: 13px; color: var(--text2); }
.iv-legend span { display: inline-flex; align-items: center; gap: 8px; }
.iv-legend i { width: 18px; display: inline-block; }
.iv-versus { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); }
.iv-versus > div { padding: 22px 22px 20px; display: grid; gap: 6px; align-content: start; }
.iv-versus > div:nth-child(2) { border-left: 1px solid var(--border); background: linear-gradient(180deg, rgba(240, 112, 96, .07), transparent 70%); }
.iv-spark .late { stroke-width: 2; stroke: #D8D2C4; }
.iv-versus small { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--muted); }
.iv-versus b { font-family: var(--mono); font-weight: 400; font-size: clamp(24px, 2.6vw, 38px); letter-spacing: -.02em; }
.iv-versus span { font-size: 13px; color: var(--muted); }
.iv-spark { grid-column: 1 / -1; border-top: 1px solid var(--border); padding: 14px 22px 10px; }
.iv-sizes { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 14px; }
.iv-size { border: 1px solid var(--border); background: var(--panel); padding: 16px; display: grid; gap: 4px; position: relative; }
.iv-size::before { content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 2px; background: var(--accent); }
.iv-size small { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--accent); }
.iv-size b { font-size: 15px; line-height: 1.25; }
.iv-size span { font-size: 12px; color: var(--muted); }
.iv-size em { font-style: normal; font-family: var(--mono); font-size: 18px; margin-top: 8px; }
.iv-size i { font-style: normal; font-size: 11px; color: var(--faint); }
.iv-bar { height: var(--h); background: repeating-linear-gradient(135deg, #2A3038 0 2px, transparent 2px 7px);
  border: 1px solid var(--border); border-bottom: 0; margin-top: 10px; }
.iv-flow { list-style: none; margin: 0; padding: 0; counter-reset: f; border-left: 1px solid var(--border); }
.iv-flow li { position: relative; padding: 0 0 22px 30px; display: grid; gap: 3px; }
.iv-flow li::before { counter-increment: f; content: counter(f, decimal-leading-zero); position: absolute; left: -15px; top: -2px;
  width: 30px; height: 22px; background: var(--bg); color: var(--accent); font-family: var(--mono); font-size: 11px;
  display: grid; place-items: center; border: 1px solid var(--border); }
.iv-flow b { font-size: 16px; }
.iv-flow span { font-size: 14px; color: var(--muted); }
.iv-flow .tabname { font-family: var(--mono); font-size: 11px; color: var(--text2); letter-spacing: .06em; }
.iv-keys { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 4px; padding: 14px 16px; border: 1px solid var(--border);
  font-size: 13px; color: var(--text2); }
.iv-keys span { display: inline-flex; align-items: center; gap: 7px; }
.iv-keys i { width: 10px; height: 10px; border-radius: 2px; }
.intro-choices { display: grid; gap: 14px; }
.intro-choice { text-align: left; background: var(--panel); border: 1px solid var(--border); color: var(--text);
  padding: 24px 26px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 6px 18px; align-items: center;
  transition: border-color .15s, background .15s, transform .15s; border-radius: 2px; }
.intro-choice b { font-size: 20px; }
.intro-choice span { grid-column: 1; font-size: 14px; color: var(--muted); line-height: 1.5; }
.intro-choice::after { content: "→"; grid-row: 1 / span 2; grid-column: 2; font-size: 22px; color: var(--faint); transition: transform .15s, color .15s; }
.intro-choice:hover { border-color: var(--accent); background: var(--raised); }
.intro-choice:hover::after { transform: translateX(4px); color: var(--accent); }
.intro-choice.main { border-color: #5A4320; background: linear-gradient(180deg, rgba(242, 163, 58, .08), transparent); }
.draw { stroke-dasharray: 1600; animation: draw 2s cubic-bezier(.3, .7, .2, 1) .35s both; }
.late { animation: fade-slow .7s ease 1.7s both; }
@keyframes draw { from { stroke-dashoffset: 1600; } to { stroke-dashoffset: 0; } }

@media (max-width: 900px) {
  .intro-stage { grid-template-columns: 1fr; gap: 28px; align-items: start; padding: 24px 20px; }
  .intro-top { padding: 14px 20px; gap: 14px; }
  .intro-top .brand span { display: none; }
  .intro-steps li { min-width: 0; flex: 1; font-size: 0; }
  .intro-steps { flex: 1; }
  .intro-foot { padding: 12px 20px 16px; border-top: 1px solid var(--border); background: var(--bg); }
  .intro-hint { display: none; }
  .intro-next { margin-left: auto; min-width: 0; flex: 1; }
  .intro-num b { font-size: 44px; }
  .intro h1 { margin-bottom: 16px; }
  .intro-body { font-size: 16px; }
  .intro-ledger span { font-size: 0; }
}
@media (max-width: 560px) {
  .iv-sizes { grid-template-columns: 1fr; }
  .iv-bar { display: none; }
  .iv-versus { grid-template-columns: 1fr; }
  .iv-versus > div:nth-child(2) { border-left: 0; border-top: 1px solid var(--border); }
  .intro-ledger { grid-template-columns: repeat(6, 1fr); }
  .intro-ledger span:nth-child(n+7) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .intro, .intro.closing, .intro-stage.in .rise, .intro-stage.in .intro-visual, .draw, .late { animation: none; }
  .intro-stage.out .intro-text, .intro-stage.out .intro-visual { transform: none; }
}

/* phones and tablets: everything a finger taps is at least 40px tall (36px for small chips) */
@media (max-width: 700px), (pointer: coarse) {
  .top-actions .btn, .btn { min-height: 40px; }
  .legend button { min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .seg button { min-height: 38px; padding: 8px 12px; }
  .link { min-height: 36px; padding: 8px 6px; }
  .sheet input.cell { min-height: 40px; }
  .tabs button { min-height: 44px; }
  .chips button { min-height: 36px; }
  .tip { white-space: normal; max-width: min(280px, calc(100vw - 48px)); }
  select { min-height: 40px; }
  .link { min-width: 36px; }
  .intro-skip, #intro-skip { min-height: 40px; }
  input[type=checkbox] { width: 22px; height: 22px; }
}
