:root {
  color-scheme: light;
  --bg: #f6f5f1; --surface-1: #ffffff; --surface-2: #f0efea; --border: #e4e2dc;
  --text-primary: #111111; --text-secondary: #4f4e4a; --text-muted: #7c7b75; --grid: #ebe9e3;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  --ref: #8d8b84; --accent: #2a78d6; --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #101010; --surface-1: #191918; --surface-2: #222220; --border: #2d2d2a;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86; --grid: #2a2a28;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #0ca30c; --series-7: #9085e9; --series-8: #e66767; --ref: #77766f; --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101010; --surface-1: #191918; --surface-2: #222220; --border: #2d2d2a;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86; --grid: #2a2a28;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #0ca30c; --series-7: #9085e9; --series-8: #e66767; --ref: #77766f; --accent: #3987e5;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text-primary); font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.mono, td.num { font-family: ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
.top { padding: 26px 20px 14px; position: relative; }
.eyebrow { color: var(--accent); font-size: 13px; letter-spacing: .05em; text-transform: uppercase; margin: 0 0 8px; }
h1 { font-size: clamp(22px, 3vw, 30px); line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; margin: 0; max-width: 900px; }
.lede { font-size: 18px; color: var(--text-secondary); max-width: 720px; margin: 0 0 28px; }
h2 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 64px 0 6px; }
.sub { color: var(--text-secondary); margin: 0 0 18px; max-width: 760px; }
h3 { font-size: 15px; font-weight: 500; margin: 0 0 10px; }
.small { font-size: 13px; } .muted { color: var(--text-muted); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0 6px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.tile .v { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--text-secondary); font-size: 14px; }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.stage { padding: 0; overflow: hidden; }
.stage { display: flex; flex-direction: column; }
.scene-wrap { position: relative; flex: 1 1 auto; min-height: 420px; }
#scene { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.caption { padding: 14px 20px; border-top: 1px solid var(--border); font-size: 16px; display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: baseline; }
.caption .when { font-family: monospace; color: var(--text-muted); font-size: 14px; }
.caption .what { font-weight: 500; }
.caption .nums { display: flex; gap: 18px; color: var(--text-secondary); font-size: 14px; }
.caption .nums b { font-weight: 500; color: var(--text-primary); font-family: monospace; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.btn { font: inherit; font-size: 14px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; min-width: 76px; }
.tbtns { display: flex; gap: 6px; flex-wrap: wrap; }
.tbtns .btn { padding: 6px 11px; }
#date { padding: 5px 10px; color-scheme: dark light; }
.slide { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; min-width: 0; }
.slide.wide { flex: 2 1 320px; }
.slide input[type=range] { flex: 1 1 auto; min-width: 0; accent-color: var(--accent); height: 22px; }
.slide .sl { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; }
#todlabel { min-width: 3.2em; text-align: right; }
.usecmp { margin: 10px 0 6px; padding: 16px 20px; }
.usecmp h3 { margin: 0 0 10px; }
.usecmp .row { display: grid; grid-template-columns: minmax(150px, 220px) 1fr auto; align-items: center; gap: 12px; padding: 7px 8px; border-radius: 10px; cursor: pointer; }
.usecmp .row:hover { background: var(--surface-2); }
.usecmp .row.on { outline: 1px solid var(--accent); }
.usecmp .bar { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.usecmp .bar i { display: block; height: 100%; border-radius: 6px; background: var(--series-1); }
.usecmp .row.best .bar i { background: var(--series-3); }
.usecmp .val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 7.5em; text-align: right; }
.usecmp .tag { font-size: 12px; margin-left: 6px; color: var(--series-3); }
.usecmp table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.usecmp th, .usecmp td { padding: 4px 6px; text-align: right; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.usecmp th:first-child, .usecmp td:first-child { text-align: left; }
.usecmp td.best { color: var(--series-3); font-weight: 600; }
@media (max-width: 640px) { .usecmp .row { grid-template-columns: 1fr auto; } .usecmp .bar { grid-column: 1 / -1; order: 3; } }
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; margin: 2px 0 8px; }
.pill.in { background: rgba(65,196,107,.16); color: #41c46b; } .pill.out { background: rgba(160,166,178,.16); color: var(--text-secondary); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 .card { margin-bottom: 0; }
.chart { min-width: 0; }
.uplot { font-family: sans-serif; }
.u-legend { font-size: 12.5px; color: var(--text-secondary); text-align: left; }
.stages { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.st { text-align: left; background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 12px; cursor: pointer; font: inherit; color: inherit; }
.st.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.st .n { font-size: 12px; color: var(--text-muted); }
.st .t { font-weight: 500; font-size: 14px; margin: 2px 0 6px; }
.st .k { font-size: 12.5px; color: var(--text-secondary); line-height: 1.4; }
.st .m { font-family: monospace; font-size: 13px; margin-top: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 500; font-size: 13px; }
tr.hl td { background: var(--surface-2); }
.tablewrap { overflow-x: auto; }
.note { color: var(--text-muted); font-size: 14px; margin: 10px 0 0; max-width: 820px; }
.extra .v { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; }
.extra .lead { margin: 10px 0 6px; font-size: 15px; line-height: 1.45; color: var(--text-primary); }
.extra .xl { margin: 6px 0 10px; padding-left: 18px; font-size: 14px; line-height: 1.5; color: var(--text-secondary); }
.extra .xl li { margin: 3px 0; }
.extra .xt { width: 100%; border-collapse: collapse; margin: 8px 0 10px; font-size: 14px; }
.extra .xt caption { caption-side: top; text-align: left; font-size: 12px; padding-bottom: 4px; color: var(--text-muted); }
.extra .xt td { padding: 5px 0; border-top: 1px solid var(--grid); vertical-align: top; }
.extra .xt td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.extra .note.small { font-size: 12.5px; margin: 6px 0 0; }
.specs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.spec { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; background: var(--surface-1); }
.spec h4 { margin: 0 0 8px; font-size: 15px; font-weight: 500; }
.spec dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.spec dt { color: var(--text-secondary); } .spec dd { margin: 0; text-align: right; }
.gloss { display: grid; grid-template-columns: 220px 1fr; gap: 10px 20px; margin: 0; }
.gloss dt { font-weight: 500; } .gloss dd { margin: 0; color: var(--text-secondary); }
.foot { color: var(--text-muted); font-size: 12px; padding: 48px 20px 40px; }
@media (max-width: 900px) {
  .stages { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .specs { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .grid2, .specs { grid-template-columns: 1fr; }
  .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scene-wrap { min-height: 340px; }
  .gloss { grid-template-columns: 1fr; gap: 2px 0; } .gloss dd { margin-bottom: 10px; }
  h2 { margin-top: 48px; }
  .wrap { padding: 0 16px; }
}

/* simulation + plant settings, side by side */
.simgrid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: stretch; }
.simgrid .card { margin-bottom: 0; }
.cfg h3 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.presets button { font: inherit; font-size: 12.5px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary); cursor: pointer; }
.ctl { display: block; margin: 12px 0 0; font-size: 14px; color: var(--text-secondary); }
.ctl > span { display: flex; justify-content: space-between; margin-bottom: 2px; }
.ctl b { color: var(--text-primary); font-weight: 500; font-family: monospace; font-size: 13px; }
.ctl input[type=range] { width: 100%; accent-color: var(--accent); margin: 4px 0; height: 22px; }
.seg { display: flex; gap: 4px; margin-top: 4px; }
.seg button { flex: 1; font: inherit; font-size: 13px; padding: 7px 0; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary); cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; border-color: transparent; }
.tile .l b { color: var(--text-primary); font-weight: 500; }
.tile .s { color: var(--text-muted); font-size: 13px; margin-top: 4px; line-height: 1.45; }
.up { color: var(--series-3); } .down { color: var(--series-8); }
@media (max-width: 980px) {
  .simgrid { grid-template-columns: 1fr; }
  .cfg { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
  .cfg h3, .cfg .presets { grid-column: 1 / -1; }
  .tiles { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .top { padding: 18px 16px 10px; }
  .cfg { grid-template-columns: 1fr 1fr; gap: 0 14px; }
  .cfg h3 { margin-bottom: 8px; }
  .presets { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .presets::-webkit-scrollbar { display: none; }
  .presets button { white-space: nowrap; }
  .ctl { font-size: 13px; margin-top: 10px; }
  .tiles { gap: 8px; margin-top: 12px; }
  .tile { padding: 12px 14px; } .tile .v { font-size: 20px; } .tile .l { font-size: 13px; } .tile .s { font-size: 12px; }
  .caption { padding: 12px 14px; font-size: 15px; gap: 4px 14px; }
  .caption .nums { flex-wrap: wrap; gap: 4px 14px; }
  .controls { padding: 10px 14px; gap: 8px; }
  .slide, .slide.wide { flex: 1 1 100%; }
  .tbtns .btn { padding: 6px 9px; font-size: 13px; }
  .card { padding: 16px; }
  .stage { padding: 0; }
}
@media (max-width: 340px) { .tiles, .cfg { grid-template-columns: 1fr; } }
.windows { margin: -4px 0 10px; font-size: 14px; color: var(--text-secondary); line-height: 1.7; font-family: ui-monospace, monospace; }
.windows .buy, .windows .sell { display: inline-block; min-width: 52px; font-family: sans-serif; font-weight: 500; }
.windows .buy { color: var(--series-1); } .windows .sell { color: var(--series-2); }
.tiles.busy { opacity: .55; transition: opacity .1s; }
/* loading state */
.loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: linear-gradient(180deg, #3d7fd6 0%, #9cc6f0 62%, #c9b98e 62%, #b9a678 100%); color: #fff; z-index: 2; transition: opacity .4s; }
.loading .sun { width: 46px; height: 46px; border-radius: 50%; background: #fff3c4; box-shadow: 0 0 40px 14px rgba(255,236,170,.7); animation: rise 2.4s ease-in-out infinite alternate; }
@keyframes rise { from { transform: translateY(18px); } to { transform: translateY(-18px); } }
.ld-text { font-size: 15px; font-weight: 500; text-shadow: 0 1px 4px rgba(0,0,0,.35); text-align: center; padding: 0 16px; }
.ld-bar { width: min(260px, 70%); height: 5px; border-radius: 3px; background: rgba(255,255,255,.35); overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: 0; background: #fff; transition: width .15s; }
body:not(.is-loading) .loading { opacity: 0; pointer-events: none; }
.skel .v, .skel .l, .skel .s, body.is-loading .chart > div, body.is-loading .stages:empty, body.is-loading #specs:empty {
  border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; color: transparent; }
.skel .v { width: 60%; margin-bottom: 8px; } .skel .l { width: 80%; margin-bottom: 6px; } .skel .s { width: 90%; height: 30px; }
body.is-loading .chart > div { min-height: 220px; }
body.is-loading .stages:empty { min-height: 120px; } body.is-loading #specs:empty { min-height: 160px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.topbar { position: absolute; right: 20px; top: 18px; display: flex; gap: 8px; align-items: center; }
.lang { font-size: 13px; padding: 5px 12px; }
.country { margin: 0; } .country button { padding: 5px 12px; font-size: 13px; flex: none; }
@media (max-width: 680px) { .topbar { position: static; margin-bottom: 10px; } .top h1 { padding-right: 0; } }
/* status line: fixed size so changing text never moves the page */
.caption { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; gap: 6px 18px; align-items: baseline; height: 76px; overflow: hidden; }
.caption .what { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.caption .nums { grid-column: 1 / -1; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
.caption .nums > span { flex: none; }
.caption .nums b { display: inline-block; min-width: 4.2em; }
@media (max-width: 680px) {
  .caption { grid-template-columns: minmax(0, 1fr); height: 112px; gap: 4px; }
  .caption .nums { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; white-space: nowrap; }
  .caption .nums b { min-width: 0; }
}
@media (max-width: 680px) {
  .caption { height: 132px; }
  .caption .what { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; height: 2.7em; }
  .caption .nums { font-size: 13px; }
}
@media (max-width: 680px) { .caption .nums { grid-template-columns: auto auto; justify-content: space-between; font-size: 12.5px; } }
.country button { display: inline-flex; align-items: center; gap: 6px; }
.flag { width: 18px; height: 12px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); flex: none; }
