/* hedgekit — one stylesheet, two themes (light / dark by the system setting).
   Tokens first; every component below uses them. Purely visual: the scripts'
   class names are the contract and are all kept. */

:root {
  color-scheme: light;
  --page: #f5f6f8;
  --surface-1: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e2e5ea;
  --line-strong: #cfd4dc;
  --text-primary: #0e1726;
  --text-secondary: #4a5568;
  --text-muted: #6b7686;
  --series-1: #2563eb;
  --series-2: #ea580c;
  --good: #15803d;
  --warning: #b45309;
  --critical: #c62828;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-ink: #ffffff;
  --accent-soft: #e8efff;
  --good-soft: #e7f6ec;
  --warning-soft: #fdf3e2;
  --critical-soft: #fdecec;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 1px 3px rgba(16, 24, 40, 0.06), 0 6px 16px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0b0e13;
    --surface-1: #12161d;
    --surface-2: #171c25;
    --line: #232a35;
    --line-strong: #323b48;
    --text-primary: #e8ebf0;
    --text-secondary: #a6afbd;
    --text-muted: #7d8898;
    --series-1: #5b8def;
    --series-2: #f08a4b;
    --good: #3fbf6f;
    --warning: #e5a33a;
    --critical: #f0625a;
    --accent: #5b8def;
    --accent-hover: #7aa3f4;
    --accent-ink: #0b0e13;
    --accent-soft: rgba(91, 141, 239, 0.14);
    --good-soft: rgba(63, 191, 111, 0.13);
    --warning-soft: rgba(229, 163, 58, 0.14);
    --critical-soft: rgba(240, 98, 90, 0.14);
    --shadow-sm: none;
    --shadow-md: 0 1px 0 rgba(255, 255, 255, 0.02), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

/* ── base ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.022em; font-weight: 650; }
h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted);
  margin: 0 0 14px; font-weight: 650;
}
h3 { font-size: 15px; margin: 18px 0 8px; font-weight: 650; letter-spacing: -0.01em; }
.sub { color: var(--text-secondary); margin: 0 0 22px; max-width: 78ch; font-size: 15px; }
.meta { color: var(--text-secondary); font-size: 13px; }
.hint { color: var(--text-muted); font-size: 12px; margin: 5px 0 0; }
.empty { color: var(--text-muted); font-size: 14px; margin: 0; }
.prose { white-space: pre-line; margin: 0 0 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ── header ───────────────────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px; flex-wrap: nowrap;
  min-height: var(--header-h); padding: 0 24px;
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 9px; flex: none;
  font-weight: 700; font-size: 16px; letter-spacing: -0.02em; color: var(--text-primary); text-decoration: none;
}
.brand:hover { color: var(--text-primary); }
.brand .mark { width: 26px; height: 26px; flex: none; display: block; }
.brand .mark rect { fill: var(--accent); }
.brand .mark path { stroke: var(--accent-ink); }
.top .nav { display: flex; gap: 2px; margin-right: auto; font-size: 14px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.top .nav::-webkit-scrollbar { display: none; }
.top .nav[hidden] { display: none; }
.top .nav a {
  color: var(--text-secondary); text-decoration: none; white-space: nowrap;
  padding: 6px 11px; border-radius: 8px; font-weight: 550; transition: background-color 0.12s, color 0.12s;
}
.top .nav a:hover { color: var(--text-primary); background: var(--surface-2); }
.top .nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.who {
  color: var(--text-secondary); font-size: 13px; font-weight: 550; white-space: nowrap; flex: none;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2);
}
#signout { flex: none; }

/* ── layout ───────────────────────────────────────────────────────────── */
main { max-width: 1180px; margin: 0 auto; padding: 32px 24px 48px; }
.grid { display: grid; gap: 16px; }
.grid.sleeves { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stack { display: grid; gap: 18px; }
.grid > *, .stack > *, .tiles > * { min-width: 0; }
.row { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.row.head { justify-content: space-between; }
.actions { margin-top: 4px; }
ul.plain li span:last-child, ul.lines li { overflow-wrap: anywhere; }

/* ── footer ───────────────────────────────────────────────────────────── */
.foot {
  max-width: 1180px; margin: 0 auto; padding: 20px 24px 36px;
  color: var(--text-muted); font-size: 12px; line-height: 1.6; border-top: 1px solid var(--line);
}
.foot p { margin: 0 0 6px; max-width: 110ch; }
.foot strong { color: var(--text-secondary); font-weight: 600; }

/* ── cards and notices ────────────────────────────────────────────────── */
.card {
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
}
.card > h2:first-child { margin-top: 0; }
.banner { border-left: 3px solid var(--critical); background: color-mix(in srgb, var(--critical-soft) 55%, var(--surface-1)); }
.banner strong { display: block; margin-bottom: 4px; }
.notice { border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface-1)); }
.notice p { margin: 0 0 8px; }
.notice p:last-child { margin-bottom: 0; }
.notice button.primary { width: auto; }
.notice-line {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 8px 12px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 0;
}
.disclaimer { color: var(--text-muted); font-size: 12px; margin: 4px 0 0; }
.card.focus { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── buttons ──────────────────────────────────────────────────────────── */
button.primary, a.button, button.secondary, button.danger, .notice button.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; line-height: 1; text-decoration: none; cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
button.primary { background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); width: 100%; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
a.button, button.secondary {
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--line-strong); box-shadow: var(--shadow-sm);
}
a.button:hover, button.secondary:hover { border-color: var(--text-muted); background: var(--surface-2); color: var(--text-primary); }
a.button.primary, a.button.primary-link { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
a.button.primary:hover, a.button.primary-link:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
button.danger { background: var(--surface-1); border: 1px solid var(--critical); color: var(--critical); }
button.danger:hover { background: var(--critical-soft); }
main button:not([class]) {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface-1); color: var(--text-primary);
  font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-sm);
}
main button:not([class]):hover { background: var(--surface-2); border-color: var(--text-muted); }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px 6px; font-weight: 550; }
button.link:hover { color: var(--accent-hover); text-decoration: underline; }
button.inline:not(.primary):not(.secondary):not(.danger):not(.link) {
  min-height: 32px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface-1); color: var(--text-primary); font-weight: 600; font-size: 13px; cursor: pointer;
}
button.inline:not(.primary):not(.secondary):not(.danger):not(.link):hover { background: var(--surface-2); border-color: var(--text-muted); }
button.primary.inline, .form button.primary.inline { width: auto; display: inline-flex; margin-top: 0; }
button:disabled, button:disabled:hover { opacity: 0.55; cursor: not-allowed; }

/* ── forms ────────────────────────────────────────────────────────────── */
.form label, .login label { display: block; font-size: 13px; font-weight: 550; color: var(--text-secondary); margin: 14px 0 6px; }
.form input:not([type="radio"]):not([type="checkbox"]), .login input,
.filters input, .filters select, select, .form select, textarea,
.strategy-form input:not([type="checkbox"]):not([type="radio"]), .strategy-form select, .strategy-form textarea {
  width: 100%; max-width: 440px; min-height: 38px; padding: 8px 11px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface-1); color: var(--text-primary);
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea, .strategy-form textarea { max-width: 100%; min-height: 76px; line-height: 1.5; }
select { width: auto; }
.form select, .strategy-form select { width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly] { background: var(--surface-2); color: var(--text-secondary); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.form button.primary { display: inline-flex; width: auto; margin-top: 18px; }
.form fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.form legend { padding: 0; font-weight: 650; font-size: 14px; margin-bottom: 6px; }
label.choice, .form label.choice {
  display: flex; gap: 10px; align-items: center; font-size: 14px; font-weight: 450; color: var(--text-primary); margin: 6px 0;
}
label.choice.inline { display: inline-flex; margin-right: 16px; }
label.choice.filter { flex-direction: row; align-items: center; }
.choice-block { padding: 4px 0; }
.choice-block .hint { margin: 0 0 8px 26px; }
.error { color: var(--critical); font-size: 13px; min-height: 20px; margin: 10px 0 0; }
.error:empty { min-height: 0; margin: 0; }
.error-list li { margin-bottom: 4px; }
.has-error { border-color: var(--critical) !important; box-shadow: 0 0 0 3px var(--critical-soft) !important; }
.field-error { color: var(--critical); font-size: 12px; margin: 5px 0 0; }
.unit { color: var(--text-muted); font-weight: 400; }
.req { color: var(--critical); font-size: 11px; font-weight: 600; }
.checks { display: flex; flex-wrap: wrap; gap: 0 4px; }

/* ── sign in / register ───────────────────────────────────────────────── */
.login {
  max-width: 380px; margin: 9vh auto 0; background: var(--surface-1);
  border: 1px solid var(--line); border-radius: 16px; padding: 30px 28px 26px; box-shadow: var(--shadow-md);
}
.login h1 { font-size: 22px; }
.login input { max-width: 100%; }
.login button { margin-top: 20px; }

/* ── stat tiles ───────────────────────────────────────────────────────── */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile {
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.card .tiles .tile { background: var(--surface-2); box-shadow: none; }
.tile .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 650; }
.tile .value { font-size: 24px; font-weight: 680; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; margin: 4px 0 2px; line-height: 1.2; }
.tile .note { font-size: 12px; color: var(--text-muted); }
.tile.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 10px; }
.tile.pair .value { font-size: 18px; white-space: nowrap; }
.tile.pair > * { min-width: 0; }
.value.pos, td.pos { color: var(--good); }
.value.neg, td.neg { color: var(--critical); }
.value.warn, td.warn { color: var(--warning); }
#plan .tiles { margin: 12px 0; }
#plan ul.lines { margin-bottom: 12px; }

/* ── sleeve cards ─────────────────────────────────────────────────────── */
.sleeve { display: flex; flex-direction: column; color: inherit; text-decoration: none; transition: border-color 0.12s, box-shadow 0.12s, transform 0.12s; }
.sleeve:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); color: inherit; }
.sleeve .name { font-weight: 650; font-size: 16px; }
.sleeve .nav { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin: 8px 0 2px; }
.sleeve.up { border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.sleeve.down { border-color: color-mix(in srgb, var(--critical) 40%, var(--line)); }
.sleeve.up:hover { border-color: var(--good); }
.sleeve.down:hover { border-color: var(--critical); }
.sleeve .pl { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-secondary); margin-bottom: 6px; }
.sleeve.up .nav, .sleeve .pl.up { color: var(--good); }
.sleeve .badges { gap: 6px; margin-top: 6px; }
.sleeve .name { overflow-wrap: anywhere; }
table.lib th, table.lib td { padding-left: 8px; padding-right: 8px; }
.card-links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.card-links a {
  font-size: 13px; font-weight: 600; text-decoration: none; padding: 4px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text-secondary);
}
.card-links a:hover { color: var(--accent); border-color: var(--accent); }
.sleeve.down .nav, .sleeve .pl.down { color: var(--critical); }

/* ── badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; line-height: 1.6;
  padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-secondary);
  background: var(--surface-2); white-space: nowrap; vertical-align: middle;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.badge.good { color: var(--good); background: var(--good-soft); border-color: transparent; }
.badge.good::before { background: var(--good); }
.badge.warn { color: var(--warning); background: var(--warning-soft); border-color: transparent; }
.badge.warn::before { background: var(--warning); border-radius: 1px; transform: rotate(45deg); }
.badge.bad { color: var(--critical); background: var(--critical-soft); border-color: transparent; }
.badge.bad::before { background: var(--critical); border-radius: 1px; }

/* ── tables ───────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th {
  font-weight: 650; color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--surface-2);
}
th.explained { text-decoration: underline dotted; text-decoration-color: var(--text-muted); text-underline-offset: 3px; cursor: help; }
thead th:first-child { border-top-left-radius: var(--radius-sm); }
thead th:last-child { border-top-right-radius: var(--radius-sm); }
th:first-child, td:first-child { text-align: left; }
tbody tr { transition: background-color 0.1s; }
tbody tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td a { font-weight: 550; text-decoration: none; }
td a:hover { text-decoration: underline; }
td { overflow-wrap: normal; }
/* Tables never scroll sideways: text wraps to fit (long ids and option legs
   may break anywhere; amounts never split), and on a phone each row becomes a
   small card of label/value pairs (labels from enhanceTables in app.js). */
.scroll { overflow-x: visible; }
html { scrollbar-color: var(--line-strong) var(--page); }
td.pos, td.neg, td.warn { white-space: nowrap; }
td .mono, td code { overflow-wrap: anywhere; }
td .meta { overflow-wrap: break-word; }
@media (min-width: 761px) {
  td.strat-cell { min-width: 220px; }
  td:first-child { min-width: 140px; }
}
td .badge { white-space: nowrap; text-align: left; }
.table-legend { margin: 10px 0 0; font-size: 12px; }
table.lib td, table.lib th { vertical-align: top; }
tr.variant td { background: var(--surface-2); }
tr.variant td:first-child { padding-left: 28px; }
td .nowrap, .nowrap { white-space: nowrap; }
td.strat-cell .meta + .meta { margin-top: 0; }
td.strat-cell .meta { margin-top: 2px; }
td .badge { margin-top: 2px; }

/* ── lists, key/value ─────────────────────────────────────────────────── */
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
ul.plain li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; font-size: 14px; }
ul.lines { margin: 0; padding-left: 18px; font-size: 14px; color: var(--text-secondary); }
dl.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 8px 16px; margin: 0 0 8px; font-size: 14px; }
dl.kv dt { color: var(--text-muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.rule-section h3 { margin-top: 14px; }
pre.log {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 12.5px;
  max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ── segmented controls (versions, tabs) ──────────────────────────────── */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.seg button, .segbtn {
  font-size: 13px; font-weight: 600; border: 1px solid var(--line-strong); background: var(--surface-1); color: var(--text-secondary);
  border-radius: var(--radius-sm); padding: 5px 11px; cursor: pointer; text-decoration: none;
}
.seg button:hover, .segbtn:hover { color: var(--text-primary); background: var(--surface-2); }
.seg button[aria-selected="true"], .segbtn[aria-current="page"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ── filters (library, community) ─────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.filter { display: flex; flex-direction: column; gap: 6px; min-width: 130px; flex: 1 1 130px; }
.filter.wide { flex: 2 1 240px; }
.filter label { font-size: 12px; font-weight: 550; color: var(--text-secondary); }
.filters input, .filters select { max-width: 100%; }

/* ── charts ───────────────────────────────────────────────────────────── */
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-secondary); }
.legend .key { display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.key.s1 { border-color: var(--series-1); }
.key.s2 { border-color: var(--series-2); }
.swatch.s1 { background: var(--series-1); }
.swatch.s2 { background: var(--series-2); }
.plot { position: relative; margin-top: 10px; min-height: 240px; overflow: hidden; }
.plot.short { min-height: 220px; }
.plot svg { display: block; }
.plot .gridline { stroke: var(--line); stroke-width: 1; }
.plot .axis { fill: var(--text-muted); font-size: 11px; }
.plot .direct { fill: var(--text-secondary); font-size: 12px; font-weight: 600; }
.plot .line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.plot .line.s1 { stroke: var(--series-1); }
.plot .line.s2 { stroke: var(--series-2); }
.plot .dot { stroke: var(--surface-1); stroke-width: 2; }
.plot .dot.s1 { fill: var(--series-1); }
.plot .dot.s2 { fill: var(--series-2); }
.plot .hair { stroke: var(--text-muted); stroke-width: 1; }
.plot .hit { fill: transparent; }
.plot .baseline { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 4; }
.plot .bar.s1 { fill: var(--series-1); }
.plot .bar.s2 { fill: var(--series-2); }
.tip {
  position: absolute; top: 0; left: 0; pointer-events: none; min-width: 160px;
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 12px; box-shadow: var(--shadow-md);
}
.tip[hidden] { display: none; }
.tip .when { color: var(--text-secondary); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 6px; }
.tip .r b { font-variant-numeric: tabular-nums; font-size: 13px; }
.tip .r span { color: var(--text-secondary); }

/* ── disclosure blocks ────────────────────────────────────────────────── */
details > summary { cursor: pointer; }
details > summary:hover { color: var(--text-primary); }
details.table { margin-top: 12px; font-size: 13px; }
details.table summary, details.adv > summary, details.adv-sections > summary { color: var(--text-secondary); font-size: 13px; font-weight: 550; }
details.table .scroll { max-height: 260px; overflow: auto; margin-top: 8px; }
details.adv { margin-top: 8px; }
details.help { margin: 8px 0 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
details.help > summary { font-weight: 600; font-size: 14px; color: var(--text-primary); }
details.help ol { margin: 10px 0 6px 20px; padding: 0; }
details.help li { margin: 6px 0; }
details.provider { border-top: 1px solid var(--line); padding: 12px 0; }
details.provider > summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; }
details.ideas-wrap { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
details.ideas-wrap > summary { font-weight: 600; color: var(--text-secondary); }

/* ── strategy form ────────────────────────────────────────────────────── */
.strategy-form fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px 14px; margin: 12px 0; min-width: 0; background: var(--surface-1); }
.strategy-form fieldset.variant { border-style: dashed; }
.strategy-form legend { font-weight: 650; font-size: 14px; padding: 0 6px; }
.strategy-form .frow { margin: 12px 0; }
.strategy-form .frow > label { display: block; font-size: 13px; font-weight: 550; color: var(--text-primary); margin-bottom: 6px; }
.strategy-form input:not([type="checkbox"]):not([type="radio"]) { max-width: 460px; }
.entry { border-left: 3px solid var(--line-strong); padding: 4px 0 4px 12px; margin: 12px 0; }
.entry .entry-name { max-width: 220px; }

/* ── new sleeve ───────────────────────────────────────────────────────── */
.strat-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 190px auto; gap: 4px 14px; align-items: end;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
}
.strat-row label { margin: 0 0 6px; }
.strat-row select { width: 100%; max-width: 100%; }
.strat-row .strat-about, .strat-row .strat-unds { grid-column: 1 / -1; margin: 4px 0 0; }
.strat-row .strat-about:empty, .strat-row .strat-unds:empty, .strat-row .strat-warn:empty { display: none; }
.strat-row .strat-warn { grid-column: 1 / -1; margin: 6px 0 0; }
.strat-unds { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.strat-share .suffix { display: flex; align-items: center; gap: 6px; }
.form .strat-share .suffix input { max-width: 110px; }
.strat-share > .meta { display: block; min-height: 1.2em; font-size: 12px; }
.strat-rm { align-self: center; }
.strat-rm button.link { width: auto; }
.ideas { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; margin-bottom: 8px; }
.idea {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 6px; transition: border-color 0.12s;
}
.idea:hover { border-color: var(--line-strong); }
.idea h3 { margin: 0; }
.idea p { margin: 0; }
.idea-list { list-style: none; padding: 0; margin: 4px 0; display: grid; gap: 8px; }
.idea-line { display: flex; justify-content: space-between; gap: 8px; }
.idea-line span { white-space: nowrap; font-variant-numeric: tabular-nums; }
.idea .row { margin-top: auto; padding-top: 8px; gap: 16px; }

/* new sleeve: the wizard */
.wizard-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.wstep {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-1); color: var(--text-secondary); font-weight: 600; font-size: 13.5px; text-align: left; cursor: pointer;
}
.wstep:hover { border-color: var(--line-strong); color: var(--text-primary); }
.wstep .wnum {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--line-strong); font-size: 12px; font-variant-numeric: tabular-nums;
}
.wstep.current { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.wstep.current .wnum { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.wstep.done .wnum { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.wizard-body > h2:first-child { margin-top: 0; }
.wizard-nav { display: flex; align-items: center; gap: 12px; }
.wizard-nav .error { flex: 1; margin: 0; text-align: right; }
.wizard-nav .primary { margin-top: 0 !important; margin-left: auto; }
.choice-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 6px 0 16px; }
label.choice-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; margin: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); font-weight: 450; transition: border-color 0.12s;
}
label.choice-card input { margin-top: 3px; }
label.choice-card:hover { border-color: var(--line-strong); }
label.choice-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
label.choice-card.disabled { cursor: not-allowed; opacity: 0.6; }
.cc-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cc-body strong { font-size: 15px; color: var(--text-primary); }
.cc-body ul { margin: 2px 0 0; padding-left: 18px; color: var(--text-secondary); font-size: 13px; }
.cc-body .badge { align-self: flex-start; }
.cc-body .hint { margin: 2px 0 0; }
.alloc { display: grid; gap: 6px; margin-top: 12px; }
.alloc .error { margin: 0; }
.alloc-bar { height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.alloc-fill { display: block; height: 100%; background: var(--accent); transition: width 0.15s; }
.alloc-fill.over { background: var(--critical); }
.summary dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 18px; margin: 14px 0; }
.summary dt { font-weight: 650; color: var(--text-secondary); }
.summary dt .link { margin-left: 6px; font-weight: 500; font-size: 12.5px; }
.summary dd { margin: 0; }
.summary dd ul { margin: 0; padding-left: 18px; }
.ok-line { color: var(--good); font-weight: 600; margin: 8px 0; }
.wizard [hidden] { display: none !important; }
@media (max-width: 640px) {
  .wizard-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary dl { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .summary dd { margin-bottom: 8px; }
}

/* ── describe a strategy (assist.js) ──────────────────────────────────── */
.assist-log { display: flex; flex-direction: column; gap: 12px; }
.assist-turn { display: flex; flex-direction: column; gap: 4px; }
.assist-turn.user p {
  margin: 0; padding: 11px 14px; border-radius: var(--radius); background: var(--accent-soft);
  border: 1px solid transparent; white-space: pre-wrap; align-self: flex-end; max-width: 85%;
}
.assist-reply { display: flex; flex-direction: column; gap: 10px; }
.assist-reply h3 { margin: 4px 0; font-size: 14px; }
.assist-note { color: var(--text-secondary); margin: 0; white-space: pre-wrap; }
.assist-form textarea { width: 100%; max-width: 100%; resize: vertical; }
.assist-form .row { margin-top: 8px; }
.assist-form > h2:first-child { margin: 0 0 10px; }
/* The next-step panel stays in reach at the bottom of the window on wide screens. */
@media (min-width: 720px) and (min-height: 700px) {
  .assist-form { position: sticky; bottom: 12px; z-index: 5; box-shadow: var(--shadow-md); }
}
.assist-actions:empty { display: none; }
.assist-actions .row { margin-top: 0; }
.assist-or { color: var(--text-muted); font-size: 12.5px; margin: 12px 0 6px; display: flex; align-items: center; gap: 10px; }
.assist-or::before, .assist-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.assist-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.assist-chips:empty { display: none; }
button.chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-secondary); border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; font-weight: 500; cursor: pointer; width: auto; text-align: left;
}
button.chip:hover { border-color: var(--accent); color: var(--accent); }
.assist-form .hint { margin: 0; }
.assist-thinking { color: var(--text-muted); font-style: italic; margin: 0; }
.assist-old { border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 10px 14px; background: var(--surface-2); }
.assist-old summary { cursor: pointer; }
.assist-old p { margin: 8px 0; }
.assist-fold, .fold { padding-top: 14px; padding-bottom: 14px; }
.fold > summary { cursor: pointer; font-weight: 650; font-size: 15px; }
.fold > .card, .fold > .stack > .card { border: 0; box-shadow: none; padding: 10px 0 0; background: none; }
.fold > .card > h2:first-child { display: none; }
.fold > .stack { gap: 0; }
/* strategy page: where it stands, and the next thing to do */
.next-step { border-left: 3px solid var(--accent); }
.next-step > p { margin: 12px 0; font-size: 15px; }
ol.progress { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 22px; }
ol.progress li { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-weight: 600; font-size: 13.5px; }
ol.progress .wnum {
  width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 12px;
}
ol.progress li.done { color: var(--good); }
ol.progress li.done .wnum { background: var(--good-soft); border-color: var(--good); }
ol.progress li.current { color: var(--accent); }
ol.progress li.current .wnum { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#card-backtest details.more { margin: 14px 0 4px; }
#card-backtest details.more > summary { cursor: pointer; color: var(--accent); font-weight: 550; }
#card-backtest .seg { margin-bottom: 2px; }
#card-backtest [hidden] { display: none !important; }
#card-backtest .notice-line { margin: 12px 0; }
.assist-fold > summary { cursor: pointer; font-weight: 650; }
.assist-fold > .card { border: 0; box-shadow: none; padding: 10px 0 0; background: none; }
.assist-fold > .card > h2:first-child { display: none; }

/* ── settings ──────────────────────────────────────────────────────────── */
.settings-tabs { margin: 14px 0 22px; }
.sleeve-list { display: grid; gap: 8px; }
details.sleeve-set { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
details.sleeve-set > summary {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 11px 14px; list-style: none;
}
details.sleeve-set > summary::-webkit-details-marker { display: none; }
details.sleeve-set > summary::before { content: "▸"; color: var(--text-muted); width: 12px; transition: transform 0.12s; }
details.sleeve-set[open] > summary::before { transform: rotate(90deg); }
details.sleeve-set > summary .sleeve-pl { margin-left: auto; font-size: 13px; font-weight: 600; text-decoration: none; }
details.sleeve-set .sleeve-body { padding: 4px 16px 16px; border-top: 1px solid var(--line); background: var(--surface-1); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
details.archived-group { margin-top: 14px; }
details.archived-group > summary { color: var(--text-secondary); font-weight: 600; margin-bottom: 8px; }
#sleeve-search, .admin-search input { max-width: 360px; margin-bottom: 12px; }
.form .row select, .row select { width: auto; min-width: 180px; max-width: 100%; }
.form .row > label { margin: 0; }

/* ── small screens ────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 6px 12px; padding: 8px 14px 0; }
  .brand { order: 1; }
  .who { order: 2; margin-left: auto; }
  #signout { order: 3; }
  .top .nav { order: 4; flex-basis: 100%; margin: 0; padding: 2px 0 8px; }
  main { padding: 22px 14px 36px; }
  .foot { padding: 18px 14px 30px; }
  h1 { font-size: 22px; }
  .card { padding: 16px; }
  .tile .value { font-size: 21px; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .strat-row { grid-template-columns: minmax(0, 1fr) auto; }
  .strat-row .strat-pick { grid-column: 1 / -1; }
  /* Each table row as a card: the first cell is its title, every other cell
     a "label … value" line. */
  .scroll table, .scroll tbody, .scroll tr, .scroll td { display: block; width: 100%; }
  .scroll thead { display: none; }
  .scroll tr {
    border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0 0 10px; padding: 8px 12px;
    background: var(--surface-1);
  }
  .scroll td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
    text-align: right; border: 0; padding: 5px 0; white-space: normal;
  }
  .scroll td::before {
    content: attr(data-label); flex: none; max-width: 45%; text-align: left;
    color: var(--text-muted); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em;
  }
  .scroll td[data-label=""]::before { content: none; }
  .scroll td:first-child { display: block; text-align: left; padding: 2px 0 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .scroll td:first-child::before { content: none; }
  .scroll td[data-label=""] { justify-content: flex-end; }
  tbody tr:hover td { background: none; }
}
.period [hidden], .card.form details [hidden] { display: none !important; }
.card.form > h2 ~ h2 { margin-top: 22px; }
.card.form details > summary { cursor: pointer; color: var(--accent); font-weight: 550; margin: 14px 0 6px; }
