:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --ink: #111827;
  --ink2: #4b5563;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line2: #d1d5db;
  --accent: #0b5cad;
  --accent-soft: #e8f1fb;
  --flow: #0072B2;
  --base: #D55E00;
  --net: #009E73;
  --win: #E69F00;
  --warn-bg: #fff7e6;
  --warn-line: #f3c26b;
  --err: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* nav */
.nav { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .9); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.nav-inner { max-width: 1120px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.logo svg { width: 30px; height: 30px; display: block; }
.logo rect { fill: var(--accent); }
.logo path { stroke: #fff; stroke-width: 2.6; fill: none; stroke-linecap: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 17px; letter-spacing: .02em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav-links { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.nav-links a { color: var(--ink2); }
.lang { border: 1px solid var(--line2); background: #fff; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink); }
.lang:hover { border-color: var(--accent); color: var(--accent); }

main { max-width: 1120px; margin: 0 auto; padding: 8px 20px 40px; }

/* hero */
.hero { padding: 36px 0 18px; }
.hero h1 { font-size: clamp(26px, 3.6vw, 38px); line-height: 1.15; margin: 0 0 12px; letter-spacing: -.01em; max-width: 820px; }
.lead { font-size: 17px; color: var(--ink2); max-width: 760px; margin: 0 0 22px; }
.steps-bar { list-style: none; display: flex; gap: 10px; padding: 0; margin: 0; flex-wrap: wrap; }
.steps-bar li { display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 8px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.steps-bar li span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--line); color: var(--ink2); font-weight: 600; font-size: 13px; }
.steps-bar li em { font-style: normal; }
.steps-bar li.active { color: var(--ink); border-color: var(--accent); }
.steps-bar li.active span { background: var(--accent); color: #fff; }
.steps-bar li.done span { background: var(--net); color: #fff; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin: 18px 0; }
.card-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.card-head h2 { margin: 0 0 2px; font-size: 20px; }
.card-head p { margin: 0; }
.num { flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; }

/* drop zone */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 34px 18px; border: 2px dashed var(--line2); border-radius: 12px; background: #fbfcfe; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over, .drop:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.drop input { display: none; }
.drop-icon { width: 40px; height: 40px; stroke: var(--accent); stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.drop-main { font-weight: 600; font-size: 17px; }
.drop-sub { color: var(--muted); font-size: 13px; max-width: 640px; }
.witness { margin-top: 12px; font-size: 14px; }
.witness summary, .advanced summary { cursor: pointer; color: var(--ink2); }
.witness p { margin: 6px 0; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 22px 0 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.demos { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.demo { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; cursor: pointer; font: inherit; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
.demo:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.demo b { display: block; font-size: 14px; }
.demo span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.demo .go { color: var(--accent); font-size: 12.5px; margin-top: 6px; font-weight: 600; }
.demo[disabled] { opacity: .55; cursor: wait; }

/* status */
.status { font-size: 14px; color: var(--ink2); min-height: 20px; margin-top: 12px; display: flex; align-items: center; gap: 8px; }
.status.err { color: var(--err); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* step 2 */
.detected { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink2); }
.hint { font-size: 12px; color: var(--muted); }
select, input[type=number], input[type=text] { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line2); border-radius: 9px; background: #fff; color: var(--ink); min-width: 0; }
select:focus, input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
#inst { min-width: 260px; max-width: 100%; }
.pair { display: flex; align-items: center; gap: 6px; }
.pair input { width: 110px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; background: #f3f4f6; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; color: var(--ink2); white-space: nowrap; }
.chip b { color: var(--ink); font-weight: 600; }
.controls { display: flex; flex-wrap: wrap; gap: 18px 26px; align-items: flex-start; margin-top: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; user-select: none; margin-top: 22px; }
.toggle input { display: none; }
.track { width: 38px; height: 22px; border-radius: 999px; background: var(--line2); position: relative; transition: background .15s; flex: none; }
.thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track .thumb { transform: translateX(16px); }
.advanced { margin-top: 16px; font-size: 14px; }
.adv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 18px; margin: 12px 0; }
.adv-grid .toggle { margin-top: 18px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.actions .status { margin-top: 0; }
.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 11px 20px; cursor: pointer; border: 1px solid transparent; }
.btn.primary { background: var(--accent); color: #fff; font-size: 16px; padding: 12px 28px; }
.btn.primary:hover { background: #094c8f; }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: #fff; border-color: var(--line2); color: var(--ink); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* plots */
.plot { width: 100%; min-height: 300px; }
.plot-lc { height: 300px; margin-top: 8px; }
.plot-wf { height: 380px; }
#p-lc, #p-spec { height: 420px; }
#p-v, #p-a { height: 340px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.grid2 > * { min-width: 0; }
.tabpane { min-width: 0; }
.zoomnote { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.cap { font-size: 13.5px; color: var(--ink2); margin: 4px 0 10px; }

/* results */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fcfcfd; }
.kpi .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 20px; font-weight: 650; margin-top: 2px; word-break: break-word; }
.kpi .s { font-size: 12px; color: var(--muted); }
.kpi.flow .v { color: var(--flow); }
.kpi.inst .v { font-size: 15px; line-height: 1.3; }
.note { margin-top: 14px; font-size: 13.5px; background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; color: #12355b; }
.warn { margin-top: 10px; font-size: 13.5px; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 10px 14px; color: #7a4b00; }
.warn ul { margin: 4px 0 0 18px; padding: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0 12px; overflow-x: auto; scrollbar-width: none; }
.tab { font: inherit; font-size: 14px; background: none; border: 0; padding: 10px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.downloads { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.downloads h3 { margin: 0 0 10px; font-size: 16px; }
.dl-row { display: flex; flex-wrap: wrap; gap: 10px; }
.dl { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line2); border-radius: 10px; padding: 9px 14px; color: var(--ink); font-weight: 600; font-size: 14px; background: #fff; }
.dl:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.dl small { color: var(--muted); font-weight: 500; }
.dl svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* info */
.info { padding: 26px 0 8px; }
.info h2 { font-size: 22px; margin: 0 0 14px; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.how-grid > div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.how-grid h3 { font-size: 15px; margin: 0 0 6px; }
.how-grid p { margin: 0; font-size: 14px; color: var(--ink2); }
.foot { max-width: 1120px; margin: 0 auto; padding: 20px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--ink2); border-top: 1px solid var(--line); }

@media (max-width: 820px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .how-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  main { padding: 4px 14px 30px; }
  .nav-inner { padding: 10px 14px; }
  .nav-links { gap: 12px; }
  .nav-links a[href="/api/docs"] { display: none; }
  .brand-sub { display: none; }
  .hero { padding: 22px 0 8px; }
  .lead { font-size: 15.5px; }
  .card { padding: 18px 14px; border-radius: 12px; }
  .steps-bar li { font-size: 13px; }
  #inst { min-width: 0; width: 100%; }
  .detected .field { width: 100%; }
  .pair input { width: 100%; }
  .controls > .field { width: 100%; }
  .plot-wf { height: 320px; }
  #p-lc, #p-spec { height: 360px; }
  .btn.primary { width: 100%; }
  .kpi .v { font-size: 18px; }
}
