/* Trading journal: dark only */
:root {
    color-scheme: dark;
    --bg: #0b0505;
    --fg: #d0cdcd;
    --fg-sub: #a8a2a2;
    --fg-muted: #857272;
    --accent: #877aac;
    --accent-warm: #6868a2;
    --win: #6cc58f;
    --loss: #e06c6c;
    --be: #e3b555;
    --fade: #5e9de6;
    --nfp: #e06c6c;
    --cpi: #e89a52;
    --ppi: #e3c86c;
    --fomc: #c678dd;
    --ecb: #6f9ee8;
    --opex: #56b6c2;
    --cell: #1f1616;
    --day: #271d1d;
    --head: #1a1212;
    --edge: #322626;
    --sel-row: #493a3a;
    --divider: #302525;
    --input: #2a2020;
    --day-sel: #433a50;
    --day-sel-idle: #3e3030;
    --curve: #9fb3c8;
    --pad: 22px;
    --head-h: 64px;
    --font: "JetBrains Mono", "JetBrainsMono Nerd Font", ui-monospace, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }
html { background: var(--bg); scrollbar-color: var(--edge) transparent; }
* { scrollbar-color: var(--edge) transparent; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 13px/1.4 var(--font); min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
h2 { font-size: 15px; margin: 0; font-weight: 700; }
h3 { font-size: 13px; margin: 0; font-weight: 700; }
h4 { font-size: 10px; letter-spacing: 1px; color: var(--fg-sub); margin: 18px 0 8px; font-weight: 700; }
.muted { color: var(--fg-muted); }
.empty { color: var(--fg-muted); font-style: italic; font-size: 11px; margin: 8px 6px; }
.hint { color: var(--fg-muted); font-size: 10px; }
.grow { flex: 1; }
.bad { color: var(--loss); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

input, select, textarea {
    background: var(--input); border: 1px solid var(--edge); border-radius: 4px; padding: 5px 8px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input.bad { border-color: var(--loss); }
textarea { resize: vertical; line-height: 1.45; }
select option { background: var(--bg); }

button.primary, button.danger, .dialog-foot button, button.add {
    border: 1px solid var(--edge); border-radius: 4px; padding: 4px 12px; background: var(--head); font-size: 11px; white-space: nowrap;
}
button.primary { border-color: var(--accent); color: var(--fg); background: color-mix(in srgb, var(--accent) 22%, var(--bg)); }
button.danger { color: var(--loss); }
button:hover:not(:disabled) { filter: brightness(1.25); }

/* pills: which one of a few is on (tabs, scopes, filters) */
.pills { display: inline-flex; gap: 2px; padding: 3px; background: var(--head); border: 1px solid var(--edge); border-radius: 6px; flex-wrap: nowrap; }
.pills.wrap { flex-wrap: wrap; }
.pills button { padding: 2px 9px; border-radius: 4px; color: var(--fg-sub); font-size: 10px; white-space: nowrap; }
.pills button.on { background: color-mix(in srgb, var(--hue, var(--sel-row)) 30%, var(--bg)); color: var(--hue, var(--fg)); font-weight: 700; }
.pills:not(:has(.on[style])) button.on { background: var(--sel-row); color: var(--fg); }

/* ---------- header: a second row when the window is narrow (it wraps) ---------- */
#head {
    position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; flex-wrap: wrap; align-items: center;
    gap: 8px 16px; padding: 14px var(--pad) 10px;
}
.head-left, .head-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.head-right { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; gap: 6px 12px; }
.brand { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: var(--fg-sub); white-space: nowrap; }
.tabs { padding: 3px; }
.tabs button { font-size: 11px; padding: 3px 9px; }
.busy { width: 14px; color: var(--fg-muted); }
.message { font-size: 11px; color: var(--fg-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.message.bad { color: var(--loss); }
.legend { display: inline-flex; gap: 10px; font-size: 10px; color: var(--fg-muted); white-space: nowrap; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.month-total { font-size: 12px; white-space: nowrap; }
.evals { font-size: 11px; color: var(--fg-sub); white-space: nowrap; }
.nav { display: inline-flex; align-items: center; gap: 10px; }
.month-title { font-size: 15px; font-weight: 700; white-space: nowrap; }
.arrow { color: var(--accent); font-size: 14px; padding: 0 4px; }
.icon { color: var(--fg-muted); font-size: 13px; width: 22px; height: 22px; border-radius: 4px; text-align: center; }
.icon:hover { color: var(--fg); background: var(--head); }
@media (max-width: 560px) { .brand { display: none; } }

#main { padding: 4px var(--pad) 20px; container: main / inline-size; }

.lock-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 2px 0 10px; padding: 9px 14px; border-radius: 6px;
    border: 1px solid color-mix(in srgb, var(--be) 50%, var(--bg)); background: color-mix(in srgb, var(--be) 9%, var(--bg)); font-size: 12px; }
.lock-notice b { color: var(--be); }
.lock-notice span { color: var(--fg-sub); font-size: 11px; flex: 1; min-width: 240px; }
@container main (min-width: 857px) { .lock-notice + .month-view { height: calc(100dvh - var(--head-h) - 80px); } }

/* ---------- PNL and News: the month, the day beside it (or under it, narrow) ---------- */
.month-view {
    display: grid; grid-template-columns: minmax(0, 63.5fr) 1px minmax(0, 36.5fr); gap: 0 22px;
    height: calc(100dvh - var(--head-h) - 24px); min-height: 240px;
}
.month-view > .divider { background: var(--divider); }
.grid-pane { container: grid / size; min-height: 0; }
.month-nav { display: flex; justify-content: center; align-items: center; gap: 14px; height: 34px; }

.cal {
    --cols: 7;
    --gap: 6px;
    /* square while the height allows; a short window widens them (up to 1.8×) so the amounts still fit */
    --fitw: calc((100cqw - (var(--cols) - 1) * var(--gap)) / var(--cols));
    --fith: calc((100cqh - 34px - 30px - (var(--weeks, 6) - 1) * var(--gap)) / var(--weeks, 6));
    --ch: max(14px, min(var(--fitw), var(--fith)));
    --cw: max(14px, min(var(--fitw), calc(var(--ch) * 1.8)));
    display: grid; grid-template-columns: repeat(var(--cols), var(--cw)); grid-template-rows: 24px; grid-auto-rows: var(--ch);
    gap: var(--gap); justify-content: center;
}
.cal.with-week { --cols: 8; }
.wday { height: 24px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--fg-sub); }
.wday .short { display: none; }
@container grid (max-width: 330px) { .wday .long { display: none; } .wday .short { display: inline; } }

.day, .week { container-type: size; position: relative; overflow: hidden; border-radius: 4px; background: var(--day); display: block; width: 100%; height: 100%; }
.day .in, .week .in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.day.out { background: transparent; cursor: default; }
.day.out .date { color: var(--fg-muted); }
.day.closed { opacity: .4; }
.day.lit { background: color-mix(in srgb, var(--hue) 17%, var(--bg)); }
.news .day.lit { background: color-mix(in srgb, var(--hue) 11%, var(--bg)); }
.day.sel { background: var(--day-sel); }
.day.sel.lit { background: color-mix(in srgb, var(--hue) 34%, var(--bg)); }
.day.today { box-shadow: inset 0 0 0 2px var(--accent-warm); }
.day .date, .week .date { font-size: 12px; color: var(--fg); }
.day.sel .date, .day.today .date { font-weight: 700; }
.busy .in { justify-content: flex-start; padding-top: 7px; }
.amount { display: flex; flex-direction: column; align-items: center; margin-top: auto; }
.busy .amount { margin-top: 6px; }
.amount b { font-size: 13px; }
.amount .mid, .amount .small { display: none; }
.rate { font-size: 10px; color: color-mix(in srgb, var(--hue) 80%, var(--bg)); white-space: nowrap; }
.week .rules { font-size: 9px; color: var(--fg-sub); }
.week .rules.all { color: color-mix(in srgb, var(--win) 85%, var(--bg)); }
.fade-badge { position: absolute; top: 6px; right: 6px; font-size: 9px; font-weight: 700; color: var(--fade); padding: 0 4px; border-radius: 3px;
    background: color-mix(in srgb, var(--fade) 30%, var(--bg)); border: 1px solid color-mix(in srgb, var(--fade) 70%, var(--bg)); }
.fade-dot { display: none; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--fade); }
.week { background: var(--head); }
.week.lit { background: color-mix(in srgb, var(--hue) 10%, var(--bg)); }
.week.cur { background: var(--day-sel-idle); }
.week.cur.lit { background: color-mix(in srgb, var(--hue) 22%, var(--bg)); }
.week .date { font-size: 11px; font-weight: 700; color: var(--fg-sub); }
.note-mark { position: absolute; top: 5px; right: 7px; color: var(--accent); font-size: 11px; }
.day .badges { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; padding: 0 4px; margin-top: 4px; }
.badge { font-size: 9px; font-weight: 700; color: var(--hue); padding: 0 4px; border-radius: 3px; line-height: 14px; text-align: center;
    background: color-mix(in srgb, var(--hue) 30%, var(--bg)); border: 1px solid color-mix(in srgb, var(--hue) 75%, var(--bg)); }
.day .lines { display: flex; flex-direction: column; width: 100%; padding: 3px 6px 0; font-size: 9px; color: var(--fg-sub); }
.day .lines span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day .lines .more { color: var(--accent); }

/* the days shed detail as they shrink: whole dollars, then k, then only the colour */
@container (max-width: 109px) { .amount .full { display: none; } .amount .mid { display: inline; } }
@container (max-width: 120px) { .day .lines { display: none; } }
@container (max-width: 75px) or (max-height: 69px) {
    .rate, .week .rules, .fade-badge, .note-mark, .day .lines { display: none; }
    .fade-dot { display: block; }
    .busy .in { padding-top: 3px; }
    .busy .date { font-size: 10px; }
    .amount b { font-size: 11px; }
    .busy .amount { margin-top: 1px; }
    .day .badges { margin-top: 1px; padding: 0 2px; }
}
@container (max-width: 59px) { .amount .mid { display: none; } .amount .small { display: inline; } }
@container (max-width: 35px) or (max-height: 31px) {
    .amount, .rate, .badges, .lines { display: none !important; }
    .busy .in { justify-content: center; padding-top: 0; }
}

/* the day */
.day-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: auto; }
.day-head { display: flex; align-items: center; gap: 8px; height: 30px; }
.day-head h2 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-total { font-size: 15px; }
.day-sub { font-size: 10px; color: var(--fg-sub); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trades { display: flex; flex-direction: column; max-height: 190px; overflow: auto; flex: none; }
.trades .add { align-self: flex-start; margin: 4px 6px 2px; font-size: 10px; color: var(--fg-sub); }
.trade-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 6px; border-radius: 4px; min-height: 44px; width: 100%; }
.trade-row.sel { background: var(--sel-row); box-shadow: inset 0 -1px 0 var(--accent); }
.trade-row:hover:not(.sel) { background: var(--head); }
.trade-row .bar, .hit .bar, .day-trade .bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--hue); flex: none; }
.trade-row .main, .hit .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trade-row .top { display: flex; gap: 6px; align-items: center; overflow: hidden; white-space: nowrap; }
.trade-row .top b { font-size: 12px; }
.tag { font-size: 9px; color: var(--fg-sub); background: var(--head); border: 1px solid var(--edge); border-radius: 3px; padding: 0 5px; }
.trade-row .bits { font-size: 10px; color: color-mix(in srgb, var(--hue) 85%, var(--bg)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grade { font-size: 10px; font-weight: 700; color: var(--hue); padding: 0 5px; border-radius: 3px; min-width: 22px; text-align: center;
    background: color-mix(in srgb, var(--hue) 25%, var(--bg)); border: 1px solid color-mix(in srgb, var(--hue) 70%, var(--bg)); }
.trade-row .pnl { font-size: 13px; white-space: nowrap; }

.charts { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; flex: 0 1 auto; min-height: 0; }
.slot { position: relative; border-radius: 6px; background: var(--cell); border: 1px solid var(--edge); overflow: hidden; aspect-ratio: 2.1; min-height: 60px; width: 100%; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.slot.drop, .slot-edit.drop { border-color: var(--accent); border-width: 2px; }
.slot .none, .slot-edit .none, .thumb .none { color: var(--fg-muted); font-style: italic; font-size: 11px; }
.slot .tag, .slot-edit .tag { position: absolute; top: 6px; left: 6px; font-size: 10px; font-weight: 700; color: var(--fg); background: color-mix(in srgb, var(--bg) 85%, transparent); }
.collage { display: grid; grid-template-columns: repeat(var(--cols, 1), 1fr); gap: 2px; width: 100%; height: 100%; }
.collage img { width: 100%; height: 100%; object-fit: cover; display: block; min-height: 0; }

.news-title { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--divider); padding: 12px 0 4px; font-size: 12px; }
.news-title span { color: var(--fg-muted); font-size: 10px; }
.news-list { overflow: auto; min-height: 60px; flex: 1; padding-top: 4px; }
.news-row { display: grid; grid-template-columns: 54px 42px minmax(0, 1fr); column-gap: 8px; align-items: center; padding: 4px 6px; font-size: 11px; }
.news-row .time { color: var(--fg-sub); }
.news-row .badge { font-size: 8px; }
.news-row .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.news-row .detail { grid-column: 3; color: var(--fg-muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.news-head { color: var(--accent); font-weight: 700; font-size: 11px; padding: 10px 0 2px; }
h3.sec { font-size: 12px; border-bottom: 1px solid var(--divider); padding: 18px 0 4px; }

/* narrow: the month across the top, the day under it */
@container main (max-width: 856px) {
    .month-view { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; height: auto; min-height: 0; gap: 16px; }
    .month-view > .divider { height: 1px; }
    .grid-pane { container: grid / inline-size; }
    .cal { --fith: calc((min(60dvh, 100dvh - var(--head-h) - 260px) - 34px - 30px - (var(--weeks, 6) - 1) * var(--gap)) / var(--weeks, 6)); --fitw: calc((100cqw - (var(--cols) - 1) * var(--gap)) / var(--cols)); }
    .trades { max-height: 140px; }
    .charts { flex-direction: row; }
    .charts .slot { aspect-ratio: 1.6; min-height: 0; }
    .news-list { overflow: visible; }
}

/* ---------- views with a heading and pills ---------- */
.view-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin: 6px 0 12px; }
.view-head h2 { margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.view-head h2 .muted { font-size: 11px; font-weight: 400; }
.head-pills { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.tiles.seven { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.tile { background: var(--cell); border: 1px solid var(--edge); border-radius: 6px; padding: 9px 10px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tile label { font-size: 9px; letter-spacing: 1px; color: var(--fg-muted); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile span { font-size: 9px; color: var(--fg-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@container main (max-width: 856px) {
    .tiles, .tiles.seven { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ---------- Stats ---------- */
.stats-overview { display: grid; grid-template-columns: minmax(0, 63.5fr) minmax(0, 36.5fr); gap: 0 45px; }
.stats-side { border-left: 1px solid var(--divider); padding-left: 22px; margin-left: -23px; }
@container main (max-width: 856px) {
    .stats-overview { grid-template-columns: minmax(0, 1fr); }
    .stats-side { border-left: 0; padding-left: 0; margin-left: 0; border-top: 1px solid var(--divider); margin-top: 18px; padding-top: 16px; }
}
.h4-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.h4-row span { font-size: 10px; }
.equity { background: var(--cell); border: 1px solid var(--edge); border-radius: 6px; height: 260px; padding: 6px; }
.curve { position: relative; width: 100%; height: 100%; }
.curve svg { width: 100%; height: 100%; display: block; }
.curve .dot { position: absolute; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--curve); }
.weekdays { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }
.wd-card { background: var(--cell); border: 1px solid var(--edge); border-radius: 6px; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.wd-card.lit { background: color-mix(in srgb, var(--hue) 8%, var(--bg)); border-color: color-mix(in srgb, var(--hue) 35%, var(--bg)); }
.wd-card label { font-size: 10px; font-weight: 700; color: var(--fg-sub); }
.wd-card { container-type: inline-size; }
.wd-card b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wd-card b .mid { display: none; }
@container (max-width: 120px) { .wd-card b .full { display: none; } .wd-card b .mid { display: inline; } }
.wd-card span { font-size: 9px; color: var(--fg-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wd-card .bar, .side-row .bar { height: 4px; border-radius: 2px; display: block; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
.kv > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kv label { font-size: 9px; letter-spacing: 1px; color: var(--fg-muted); font-weight: 700; }
.kv b, .kv span { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.stats-side h2 { margin: 6px 0 12px; }
@container main (min-width: 560px) and (max-width: 856px) { .kv.days { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.side-row { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; gap: 2px 8px; padding: 6px; font-size: 11px; }
.side-row .muted { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-row .bar { grid-column: 1 / -1; }
.side-row.dim { opacity: .4; }
table { border-collapse: separate; border-spacing: 0 1px; width: 100%; font-size: 10px; }
th { font-size: 9px; color: var(--fg-muted); font-weight: 700; text-align: right; padding: 2px 6px; white-space: nowrap; }
th:first-child { text-align: left; }
td { padding: 4px 6px; text-align: right; white-space: nowrap; }
td:first-child { text-align: left; white-space: normal; }
tbody tr:nth-child(odd) td { background: var(--head); }
tbody tr td:first-child { border-radius: 3px 0 0 3px; }
tbody tr td:last-child { border-radius: 0 3px 3px 0; }
tr.dim { opacity: .4; }
table.setups { margin-top: 12px; }
table.setups td, table.setups th { text-align: right; }
table.setups td:first-child, table.setups th:first-child { text-align: left; }
p.line { font-size: 10px; color: var(--fg-sub); margin: 4px 6px; }
.stat-table { min-width: 0; }
.stat-table table { font-size: 10px; }
.breakdown { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 4px 20px; }
.insights { display: flex; flex-direction: column; gap: 8px; }
table.ins { font-size: 11px; }
table.ins th:first-child { letter-spacing: 1px; }
table.ins td.what { font-size: 9px; color: var(--fg-muted); font-weight: 700; letter-spacing: .5px; width: 70px; }
table.ins tr.good td { background: color-mix(in srgb, var(--win) 7%, var(--bg)); }
table.ins tr.bad td { background: color-mix(in srgb, var(--loss) 7%, var(--bg)); }
table.ins tr.vs td { background: var(--head); text-align: left; white-space: normal; }
table.ins tr.early { opacity: .75; }
table.ins tr td:first-child { box-shadow: inset 3px 0 0 var(--win); }
table.ins tr.bad td:first-child { box-shadow: inset 3px 0 0 var(--loss); }
table.ins tr.vs td:first-child { box-shadow: inset 3px 0 0 var(--fg-sub); }
table.ins td:nth-child(2) { text-align: left; white-space: normal; }
table.ins tr.vs td:nth-child(2) { white-space: normal; }
@container main (max-width: 600px) { table.ins tr:not(.vs) td:last-child, table.ins th:last-child { display: none; } }
@container main (max-width: 460px) { table.ins td.what, table.ins th:first-child + th { display: none; } }

/* ---------- Charts ---------- */
.gallery { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@container main (min-width: 540px) { .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container main (min-width: 860px) { .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.chart-card { background: var(--cell); border: 1px solid var(--edge); border-radius: 6px; padding: 6px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.chart-card.sel { background: var(--sel-row); border: 2px solid var(--fg); padding: 5px; }
.thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.thumb { aspect-ratio: 1.4; border-radius: 4px; background: var(--bg); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.caption { display: flex; align-items: center; gap: 8px; font-size: 11px; min-width: 0; }
.caption .bar { width: 3px; height: 14px; border-radius: 2px; flex: none; }
.caption .what { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caption b { white-space: nowrap; }

/* ---------- Accounts ---------- */
.table-wrap { overflow-x: auto; margin-top: 18px; }
table.accounts { font-size: 11px; min-width: 520px; }
table.accounts th { text-align: left; }
table.accounts th.num, table.accounts td.num { text-align: right; }
table.accounts td { text-align: left; padding: 6px; }
table.accounts tr { cursor: pointer; }
table.accounts tr.sel td { background: var(--sel-row); box-shadow: inset 0 -1px 0 var(--accent); }

/* ---------- Notes ---------- */
.notes-view { display: grid; grid-template-columns: 230px 1px minmax(0, 1fr); gap: 0 22px; min-height: calc(100dvh - var(--head-h) - 30px); }
.notes-view > .divider { background: var(--divider); }
.note-list { display: flex; flex-direction: column; gap: 2px; }
.note-list h2 { margin: 6px 0 10px; }
.note-list button { padding: 10px 12px; border-radius: 4px; color: var(--fg-sub); font-size: 12px; }
.note-list button.sel { background: var(--sel-row); color: var(--fg); font-weight: 700; box-shadow: inset 0 -1px 0 var(--accent); }
.note { cursor: text; font-size: 12px; line-height: 1.55; max-width: 80ch; padding-bottom: 40px; }
.note h1 { font-size: 22px; margin: 4px 0 14px; }
.note h2 { font-size: 16px; margin: 18px 0 8px; }
.note h3 { margin: 14px 0 6px; }
.note a { color: var(--accent); }
.note blockquote, .week-summary .muted { border-left: 2px solid var(--edge); margin: 6px 0; padding-left: 10px; color: var(--fg-sub); }
.note code { background: var(--head); padding: 0 4px; border-radius: 3px; }
.note img { max-width: 100%; }
.note ul, .note ol { padding-left: 22px; }
.note-editor { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.note-edit { flex: 1; min-height: 60vh; font-size: 12px; }
@container main (max-width: 640px) {
    .notes-view { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1px auto; align-content: start; gap: 12px; }
    .note-list { flex-direction: row; flex-wrap: wrap; align-items: center; }
    .note-list h2 { width: 100%; margin: 4px 0; }
    .note-list button { padding: 6px 10px; }
}

/* ---------- overlays ---------- */
#overlay { position: fixed; inset: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 60%, transparent); display: flex; align-items: center; justify-content: center; padding: 12px; }
#overlay[hidden] { display: none; }
.dialog {
    background: var(--bg); border: 1px solid var(--edge); border-radius: 6px; padding: 14px 16px; width: min(620px, 100%);
    max-height: calc(100dvh - 24px); overflow: auto; display: flex; flex-direction: column; gap: 10px;
}
.dialog-head { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.dialog-head h3 { flex: 1; min-width: 0; }
.dialog-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; position: sticky; bottom: -14px; background: var(--bg); padding: 8px 0 0; margin-top: 4px; }
.dialog.chooser { width: min(300px, 100%); }
.type-list { display: flex; flex-direction: column; border-top: 1px solid var(--divider); padding-top: 6px; }
.type-list button { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 4px; color: var(--fg-sub); font-size: 12px; }
.type-list button:nth-child(2n):not(:last-child) { margin-bottom: 6px; }
.type-list button.sel { background: var(--sel-row); color: var(--fg); font-weight: 700; box-shadow: inset 0 -1px 0 var(--accent); }
.type-list button.dim { opacity: .35; }
.type-list .dir { font-size: 10px; color: var(--fg-muted); }
.time-row { display: flex; align-items: center; gap: 12px; }
.time-row input { width: 140px; font-weight: 700; }

.dialog.trade-window { width: min(880px, 100%); }
.preview { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12px; padding: 2px 0 6px; border-bottom: 1px solid var(--divider); }
.preview b { font-size: 15px; }
.word { font-size: 11px; font-weight: 700; color: var(--hue); padding: 1px 7px; border-radius: 4px; border: 1px solid var(--hue); background: color-mix(in srgb, var(--hue) 18%, var(--bg)); }
.form-body { display: flex; flex-direction: column; gap: 6px; }
fieldset { border: 0; border-top: 1px solid var(--divider); margin: 0; padding: 8px 0 4px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: 8px 12px; }
legend { font-size: 10px; letter-spacing: 1px; color: var(--fg-sub); font-weight: 700; padding: 0 8px 0 0; text-transform: uppercase; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > span { font-size: 10px; color: var(--fg-sub); }
.field.wide, .grid2 .field.wide { grid-column: 1 / -1; }
fieldset.questions, fieldset.charts-edit { grid-template-columns: minmax(0, 1fr); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--input); border: 1px solid var(--edge); border-radius: 4px; padding: 4px 6px; }
.chips:focus-within { border-color: var(--accent); }
.chips input { border: 0; background: transparent; padding: 1px 2px; flex: 1; min-width: 120px; width: auto; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 4px 1px 8px; border-radius: 4px; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--bg)); }
.chip button { color: var(--fg-sub); padding: 0 3px; }
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 620px) { .slots { grid-template-columns: minmax(0, 1fr); } }
.slot-edit { position: relative; border: 1px dashed var(--edge); border-radius: 6px; padding: 30px 8px 8px; min-height: 120px; display: flex; flex-direction: column; gap: 8px; }
.slot-edit:focus { border-color: var(--accent); border-style: solid; outline: none; }
.slot-edit .thumbs { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
.slot-edit img { width: 100%; aspect-ratio: 1.4; object-fit: cover; border-radius: 3px; cursor: zoom-in; }
.slot-buttons { display: flex; gap: 6px; margin-top: auto; flex-wrap: wrap; }
.slot-buttons button { border: 1px solid var(--edge); border-radius: 4px; padding: 2px 8px; font-size: 10px; background: var(--head); }

.dialog.detail { width: min(1100px, 100%); }
.detail-head { display: flex; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; border-bottom: 1px solid var(--divider); padding-bottom: 10px; }
.detail-head h3 { font-size: 15px; }
.detail-head .result { display: flex; align-items: center; gap: 14px; }
.detail-head .result b { font-size: 18px; }
.detail-charts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .detail-charts { grid-template-columns: minmax(0, 1fr); } }
.detail-body { display: grid; grid-template-columns: minmax(0, 42fr) minmax(0, 58fr); gap: 0 36px; }
.detail-right { border-left: 1px solid var(--divider); padding-left: 18px; margin-left: -18px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 720px) {
    .detail-body { grid-template-columns: minmax(0, 1fr); }
    .detail-right { border-left: 0; padding-left: 0; margin-left: 0; border-top: 1px solid var(--divider); padding-top: 12px; margin-top: 12px; }
}
.detail-left .kv { margin-top: 4px; }
.detail-left .kv .wide { grid-column: 1 / -1; }
.detail-left .kv span { white-space: normal; }
.vs { display: grid; grid-template-columns: 46px 100px minmax(0, 1fr); align-items: baseline; gap: 6px; font-size: 11px; padding: 2px 0; }
.vs .muted:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-trade { display: flex; gap: 8px; align-items: center; font-size: 11px; padding: 3px 0; width: 100%; color: var(--fg-sub); }
.day-trade span:nth-child(2) { flex: 1; }
.day-trade.me { color: var(--fg); font-weight: 700; cursor: default; }
.answer b { font-size: 11px; color: var(--fg-sub); }
.answer p { margin: 4px 0 0; white-space: pre-wrap; line-height: 1.5; font-size: 12px; }

.dialog.week-window { width: min(720px, 100%); }
.week-summary { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.checks { display: flex; flex-direction: column; gap: 4px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input[type=checkbox] { width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.check .x { color: var(--fg-muted); padding: 0 6px; }
.checks .add { align-self: flex-start; font-size: 10px; }

.dialog.search-box { width: min(720px, 100%); align-self: flex-start; margin-top: 48px; max-height: calc(100dvh - 72px); }
.search { font-size: 13px; padding: 8px 10px; }
.hits { display: flex; flex-direction: column; overflow: auto; min-height: 0; }
.hit { display: flex; gap: 10px; align-items: center; padding: 6px 8px 6px 4px; border-radius: 4px; width: 100%; }
.hit.sel { background: var(--sel-row); }
.hit .top { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit.sel .top { font-weight: 700; }
.hit .sub { font-size: 10px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hit b { font-size: 12px; font-weight: 400; white-space: nowrap; }

.dialog.help { width: min(1100px, 100%); }
.help-cols { columns: 300px; column-gap: 24px; }
.help-sec { break-inside: avoid; margin-bottom: 16px; }
.help-sec h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: 0; }
.help-sec.here h4 { color: var(--accent); }
.help-sec dl { display: grid; grid-template-columns: minmax(0, 120px) minmax(0, 1fr); gap: 3px 10px; margin: 0; font-size: 11px; }
.help-sec dt { color: var(--fg); }
.help-sec dd { margin: 0; color: var(--fg-muted); }

.dialog.clear, .dialog.confirm { width: min(380px, 100%); }
.option { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 8px; padding: 8px 12px; border-radius: 4px; font-size: 12px; }
.option:hover { background: var(--sel-row); }
.option b { color: var(--accent); }

.dialog.settings { width: min(860px, 100%); height: calc(100dvh - 24px); }
.dialog.settings textarea.code { flex: 1; min-height: 240px; font-size: 12px; white-space: pre; overflow-wrap: normal; overflow: auto; }
.errors p { margin: 2px 0; font-size: 11px; }
.dialog.account-window { width: min(560px, 100%); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px 12px; }

.lightbox { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
#overlay:has(.lightbox) { background: color-mix(in srgb, var(--bg) 92%, transparent); }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-out; }
.lightbox .count { position: absolute; bottom: 4px; right: 8px; font-size: 11px; color: var(--fg-sub); }

#toast { position: fixed; right: 16px; bottom: 16px; z-index: 30; max-width: min(520px, calc(100vw - 32px)); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; }
#toast.on { opacity: 1; transform: none; }
#toast div { background: var(--head); border: 1px solid var(--edge); border-left: 3px solid var(--accent); border-radius: 6px; padding: 10px 14px; font-size: 12px; }
#toast div.good { border-left-color: var(--win); }
#toast div.bad { border-left-color: var(--loss); }
