:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #14181f; --muted: #5b6472; --line: #e2e6ec; --soft: #f1f3f6;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #e6f4f2;
  --ok: #157f3b; --ok-soft: #e7f6ec; --warn: #a15c00; --warn-soft: #fff4e0; --bad: #b42318; --bad-soft: #fdecea;
  --c1: #2563eb; --c2: #0f766e; --c3: #d97706; --c4: #9333ea; --c5: #db2777; --c6: #64748b; --c7: #0891b2;
  --cloud: rgba(100, 116, 139, .22);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0d1117; --panel: #161b22; --ink: #e6edf3; --muted: #9aa5b1; --line: #2a313c; --soft: #1c222b;
  --accent: #2dd4bf; --accent-ink: #062b27; --accent-soft: #123430;
  --ok: #4ade80; --ok-soft: #12301d; --warn: #fbbf24; --warn-soft: #33270b; --bad: #f87171; --bad-soft: #3a1414;
  --c1: #60a5fa; --c2: #2dd4bf; --c3: #fbbf24; --c4: #c084fc; --c5: #f472b6; --c6: #94a3b8; --c7: #22d3ee;
  --cloud: rgba(148, 163, 184, .2);
  --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.backlink { text-decoration: none; color: var(--muted); white-space: nowrap; }
.backlink:hover { color: var(--ink); }
.sep { color: var(--line); }
.topactions { display: flex; align-items: center; gap: 10px; }
.freebadge { font-size: 12px; color: var(--ok); background: var(--ok-soft); padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 5px 10px; cursor: pointer; font: inherit; }
.ghost:hover { border-color: var(--muted); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 40px; }
.hero h1 { font-size: clamp(26px, 4vw, 36px); line-height: 1.15; margin: 0 0 6px; letter-spacing: -.01em; }
.lede { color: var(--muted); margin: 0 0 14px; max-width: 720px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.exlabel { font-size: 13px; color: var(--muted); margin-right: 2px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.grid { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.results, #out { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.controls { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow: auto; }
fieldset { border: 0; margin: 16px 0 8px; padding: 0; min-width: 0; }
legend { font-weight: 650; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 0; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); min-width: 0; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.field.inline input { width: 80px; }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin-bottom: 10px; }
.check input { width: auto; }
.cgrid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 6px 0 8px; }
.corrrow { justify-content: space-between; }
.btn {
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 8px;
  padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.segbtn { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 14px; padding: 7px; border-radius: 8px; cursor: pointer; }
.segbtn.on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.drop {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  border: 1.5px dashed var(--line); border-radius: 10px; padding: 16px; margin-bottom: 10px; cursor: pointer; font-size: 14px;
}
.drop small { color: var(--muted); font-size: 12px; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.msg { font-size: 13px; margin: 6px 0; color: var(--muted); }
.msg.ok { color: var(--ok); }
.msg.bad { color: var(--bad); }
.hint { font-size: 12.5px; color: var(--muted); }
.fine { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
details summary { cursor: pointer; font-size: 13.5px; color: var(--accent); margin: 8px 0; }
.tablewrap { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.edit td { padding: 3px 4px; }
table.edit input { padding: 5px 6px; font-size: 13px; }
table.edit td:first-child input { min-width: 110px; }
table.edit td:nth-child(2) input, table.edit td:nth-child(3) input { width: 74px; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 4px; }
.x:hover { color: var(--bad); }
.corrgrid th, .corrgrid td { padding: 2px; font-size: 11px; text-align: center; }
.corrgrid input { width: 56px; padding: 3px; font-size: 12px; text-align: center; }
.corrgrid .diag, .corrgrid .mirror { color: var(--muted); }

.emptystate h2 { margin: 0 0 4px; font-size: 18px; }
.emptystate p { margin: 0; color: var(--muted); }
.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); padding: 10px 16px; }
.warn.bad { background: var(--bad-soft); color: var(--bad); }
.warn p { margin: 4px 0; font-size: 14px; }
.strattabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.stab { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 13.5px; cursor: pointer; }
.stab.on { border-color: var(--ink); font-weight: 650; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; margin-right: 6px; vertical-align: -1px; }
.stab .dot { margin-right: 0; }
.dot.asset { background: var(--ink); width: 7px; height: 7px; }
.dot.cloudk { background: var(--cloud); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--soft); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; min-width: 0; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat small { font-size: 11.5px; color: var(--muted); }
.stratnote { font-size: 13.5px; color: var(--muted); margin: 12px 0 0; }
.phead { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 8px; }
.phead h2 { font-size: 16px; margin: 0; }
.chartbox svg { width: 100%; height: auto; display: block; }
.axis .gridline { stroke: var(--line); stroke-width: 1; }
.axis .tick, .axlabel { fill: var(--muted); font-size: 11px; }
.cloud circle { fill: var(--cloud); }
.frontline { fill: none; stroke: var(--ink); stroke-width: 2.4; }
.fronthit { fill: none; stroke: transparent; stroke-width: 16; cursor: crosshair; }
.cml { stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 5 4; }
.assetdot { fill: var(--panel); stroke: var(--ink); stroke-width: 1.4; }
.assetlabel { fill: var(--muted); font-size: 10.5px; }
.spt { stroke: var(--panel); stroke-width: 2; cursor: pointer; }
.spt.sel { stroke: var(--ink); stroke-width: 2.5; }
.gline { fill: none; stroke-width: 1.5; opacity: .75; }
.gline.sel { stroke-width: 3; opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; }
.legend .line { display: inline-block; width: 18px; border-top: 2.4px solid var(--ink); margin-right: 6px; }
.legend .line.dash { border-top: 1.5px dashed var(--muted); }
.targetrow { margin: 12px 0 0; }
.targetrow b { color: var(--ink); }
input[type=range] { padding: 0; border: 0; accent-color: var(--accent); }
.weights td:first-child { white-space: nowrap; }
.weights tr.zero td { color: var(--muted); }
.cell { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.cell span { font-variant-numeric: tabular-nums; font-size: 12.5px; width: 48px; text-align: right; }
.bar { flex: 1; height: 10px; background: var(--soft); border-radius: 5px; overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; border-radius: 5px; background: var(--accent); }
.bar.r i { background: var(--c3); }
.bar.neg i { background: var(--bad); }
.compare tbody tr { cursor: pointer; }
.compare tbody tr:hover td { background: var(--soft); }
.compare tr.on td { background: var(--accent-soft); font-weight: 600; }
.heat th, .heat td { text-align: center; font-size: 11.5px; padding: 4px 3px; font-variant-numeric: tabular-nums; }
.heat td { border: 1px solid var(--panel); min-width: 38px; }
.exports { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.flash { font-size: 13px; color: var(--ok); }
.how summary { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0; }
.how ul { margin: 10px 0 0; padding-left: 18px; font-size: 14px; color: var(--muted); }
.how li { margin-bottom: 8px; }
.foot { max-width: 1280px; margin: 0 auto; padding: 0 20px 40px; font-size: 13px; color: var(--muted); }
.foot p { margin: 4px 0; }

@media (max-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .controls { position: static; max-height: none; }
}
@media (max-width: 520px) {
  .wrap { padding: 16px 16px 32px; }
  .topbar { padding: 10px 16px; }
  .freebadge { display: none; }
  .panel { padding: 14px; }
  .cgrid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat b { font-size: 19px; }
  .foot { padding: 0 16px 32px; }
}
