:root, [data-theme="paper"] {
  --bg: #f2ede2;
  --bg-2: #ebe4d5;
  --card: #f8f5ee;
  --ink: #1b1a17;
  --ink-2: #4a463e;
  --ink-3: #8a8375;
  --rule: #d4cab6;
  --rule-strong: #1b1a17;
  --gain: #17784a;
  --gain-soft: rgba(23, 120, 74, .14);
  --loss: #c23b22;
  --loss-soft: rgba(194, 59, 34, .13);
  --buy: #2a4f86;
  --unk: #9a917f;
  --gold: #c9871d;
  --price: #1b1a17;
  --scroll: rgba(27, 26, 23, .28);
  --shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 20px 40px -28px rgba(60, 45, 20, .35);
  color-scheme: light;
}
[data-theme="night"] {
  --bg: #12110f;
  --bg-2: #1a1916;
  --card: #1c1b18;
  --ink: #efe8d8;
  --ink-2: #c3bba9;
  --ink-3: #847d6e;
  --rule: #343029;
  --rule-strong: #efe8d8;
  --gain: #4fc58a;
  --gain-soft: rgba(79, 197, 138, .16);
  --loss: #ff6b4f;
  --loss-soft: rgba(255, 107, 79, .15);
  --buy: #7aa5e6;
  --unk: #7b7466;
  --gold: #e9a23b;
  --price: #efe8d8;
  --scroll: rgba(239, 232, 216, .22);
  --shadow: 0 20px 40px -28px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
html { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 "Newsreader", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  transition: background .4s, color .4s;
  min-height: 100vh;
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.3 0 0 0 0 0.2 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="night"] .grain { mix-blend-mode: screen; opacity: .35; }

.masthead, main { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 0 28px; }
.masthead { padding-top: 22px; }
.mast-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.mast-kicker { font: 500 11px/1 "IBM Plex Mono", monospace; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.mast-tools { display: flex; gap: 8px; }
.mast-title {
  font-family: "Fraunces", serif; font-optical-sizing: auto; font-weight: 800; font-variation-settings: "SOFT" 30, "WONK" 1;
  font-size: clamp(46px, 8.4vw, 112px); line-height: .9; letter-spacing: -.035em; margin: 14px 0 0;
}
.mast-title em { font-style: italic; font-weight: 400; color: var(--gold); }
.mast-rule {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-top: 3px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong);
  margin-top: 14px; padding: 7px 0 6px;
  font: 500 12px/1.3 "IBM Plex Mono", monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2);
}
#mastPrice b { color: var(--ink); font-weight: 600; }

.chip {
  font: 500 12px/1 "IBM Plex Mono", monospace; letter-spacing: .04em;
  border: 1px solid var(--rule-strong); background: transparent; color: var(--ink);
  padding: 8px 12px; border-radius: 999px; cursor: pointer; transition: background .2s, color .2s;
}
.chip:hover { background: var(--ink); color: var(--bg); }
.chip-ghost { border-color: var(--rule); color: var(--ink-3); }
.chip-ghost:hover { background: var(--loss); border-color: var(--loss); color: #fff; }

/* ---------- empty state ---------- */
.drop { display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; padding: 56px 0 80px; align-items: center; }
.drop-zone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px;
  min-height: 380px; padding: 40px; cursor: pointer; border-radius: 4px;
  background:
    repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--rule) 45%, transparent) 14px 15px),
    var(--card);
  border: 1.5px dashed var(--ink-3); box-shadow: var(--shadow);
  transition: transform .3s cubic-bezier(.2,.8,.2,1), border-color .2s;
}
.drop-zone:hover { transform: rotate(-.6deg) translateY(-3px); border-color: var(--gold); }
.drop-glyph { font: 400 120px/1 "Fraunces", serif; font-style: italic; color: var(--gold); margin-bottom: 4px; }
.drop-zone strong { font: 700 28px/1.1 "Fraunces", serif; letter-spacing: -.01em; }
.drop-zone > span:not(.drop-glyph) { color: var(--ink-2); max-width: 34ch; }
.drop-btn {
  margin-top: 14px; font: 600 13px/1 "IBM Plex Mono", monospace; letter-spacing: .06em; text-transform: uppercase;
  background: var(--ink); color: var(--bg) !important; padding: 13px 20px; border-radius: 2px;
}
.lede { font: 400 italic 30px/1.18 "Fraunces", serif; margin: 0 0 24px; letter-spacing: -.01em; }
.steps { margin: 0 0 22px; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 12px 0 12px 44px; border-top: 1px solid var(--rule); color: var(--ink-2); }
.steps li::before { content: counter(s, decimal-leading-zero); position: absolute; left: 0; top: 13px; font: 600 13px "IBM Plex Mono", monospace; color: var(--gold); }
.link { background: none; border: 0; padding: 0; font: 600 14px "IBM Plex Mono", monospace; color: var(--buy); cursor: pointer; border-bottom: 1px solid currentColor; }
.err { color: var(--loss); font: 500 14px "IBM Plex Mono", monospace; }
.dragover {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(3px);
  font: 800 italic 12vw "Fraunces", serif; color: var(--gold); pointer-events: none;
}

/* ---------- report ---------- */
#report > * { animation: rise .7s cubic-bezier(.2,.8,.2,1) both; }
#report > *:nth-child(2) { animation-delay: .06s; }
#report > *:nth-child(3) { animation-delay: .12s; }
#report > *:nth-child(4) { animation-delay: .18s; }
#report > *:nth-child(5) { animation-delay: .24s; }
#report > *:nth-child(6) { animation-delay: .30s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.controls { display: flex; flex-wrap: wrap; gap: 18px 32px; align-items: flex-end; padding: 22px 0 18px; border-bottom: 1px solid var(--rule); }
.ctl { display: flex; flex-direction: column; gap: 7px; }
.ctl-right { margin-left: auto; flex-direction: row; align-items: center; gap: 8px; }
.ctl-label { font: 500 10.5px/1 "IBM Plex Mono", monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.ctl-help { font-size: 14px; color: var(--ink-2); max-width: 52ch; font-style: italic; min-height: 1.4em; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 2px; overflow: hidden; }
.seg button {
  font: 500 13px/1 "IBM Plex Mono", monospace; border: 0; background: transparent; color: var(--ink);
  padding: 9px 14px; cursor: pointer; border-left: 1px solid var(--rule-strong);
}
.seg button:first-child { border-left: 0; }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.seg-sm button { padding: 7px 11px; font-size: 12px; }
select {
  font: 500 13px "IBM Plex Mono", monospace; background: var(--card); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: 2px; padding: 8px 10px;
}

.hero { display: grid; grid-template-columns: 1.25fr 1fr; gap: 40px; padding: 34px 0 30px; border-bottom: 3px double var(--rule-strong); }
.hero-kicker { font: 500 11px/1 "IBM Plex Mono", monospace; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.hero-num {
  font-family: "Fraunces", serif; font-weight: 800; font-variation-settings: "SOFT" 0, "WONK" 0;
  font-size: clamp(56px, 10vw, 132px); line-height: .92; letter-spacing: -.045em; margin: 12px 0 14px;
  font-variant-numeric: tabular-nums lining-nums;
}
.hero-num.gain { color: var(--gain); }
.hero-num.loss { color: var(--loss); }
.hero-num small { font-size: .32em; letter-spacing: 0; font-weight: 500; vertical-align: .9em; margin-right: .15em; color: var(--ink-3); }
.hero-sentence { font-size: 21px; line-height: 1.38; margin: 0; color: var(--ink-2); max-width: 46ch; }
.hero-sentence b { color: var(--ink); font-weight: 600; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; margin: 0; align-content: start; border-top: 1px solid var(--rule-strong); }
.kpis div { padding: 14px 14px 14px 0; border-bottom: 1px solid var(--rule); }
.kpis div:nth-child(odd) { border-right: 1px solid var(--rule); }
.kpis div:nth-child(even) { padding-left: 16px; }
.kpis dt { font: 500 10.5px/1.3 "IBM Plex Mono", monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.kpis dd { margin: 5px 0 0; font: 600 22px/1.1 "IBM Plex Mono", monospace; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpis dd small { display: block; font: 400 13px/1.35 "Newsreader", serif; color: var(--ink-2); letter-spacing: 0; margin-top: 4px; }
.gain-t { color: var(--gain); }
.loss-t { color: var(--loss); }
.unk-t { color: var(--unk); }

.notice {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end;
  margin: 26px 0 0; padding: 18px 22px; background: color-mix(in srgb, var(--gold) 12%, var(--card));
  border-left: 4px solid var(--gold); box-shadow: var(--shadow);
}
.notice strong { font: 700 19px/1.2 "Fraunces", serif; }
.notice p { margin: 6px 0 0; color: var(--ink-2); max-width: 70ch; }
.ext-input { display: flex; flex-direction: column; gap: 6px; font: 500 10.5px/1.2 "IBM Plex Mono", monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.money-input { display: flex; align-items: center; border-bottom: 2px solid var(--ink); }
.money-input i { font: 500 15px "IBM Plex Mono", monospace; font-style: normal; color: var(--ink-3); padding-right: 6px; }
.money-input input {
  width: 150px; border: 0; background: transparent; color: var(--ink); font: 600 24px "IBM Plex Mono", monospace; padding: 4px 0; outline: none;
}

.panel { padding: 34px 0 8px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--rule-strong); padding-top: 10px; }
.panel h2 { font: 700 30px/1.1 "Fraunces", serif; letter-spacing: -.02em; margin: 0; }
.panel h3 { font: 500 10.5px/1 "IBM Plex Mono", monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin: 18px 0 6px; }
.panel-sub { color: var(--ink-2); margin: 8px 0 16px; max-width: 70ch; font-style: italic; }
.panel-meta { font: 500 12px "IBM Plex Mono", monospace; color: var(--ink-3); }
.legend { font: 500 12.5px/1.4 "IBM Plex Mono", monospace; color: var(--ink-2); display: flex; gap: 14px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.legend b { color: var(--ink); font-weight: 600; }
.chart-keys { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 8px; font: 500 12px "IBM Plex Mono", monospace; color: var(--ink-2); }
.chart-keys > span { display: inline-flex; align-items: center; gap: 7px; }
.k { display: inline-block; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; }
.k-buy { border-bottom: 10px solid var(--buy); }
.k-gain { border-top: 10px solid var(--gain); }
.k-loss { border-top: 10px solid var(--loss); }
.k-unk { border-top: 10px solid var(--unk); }
.k-cost { width: 16px; height: 0; border: 0; border-top: 2px dashed var(--gold); }
.chart { width: 100%; height: 400px; position: relative; }
.chart-sm { height: 170px; }
.chart-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.fine { font: 400 12px/1.4 "IBM Plex Mono", monospace; color: var(--ink-3); margin: 10px 0 0; }

/* ledger: one row per sale, diverging bar */
.ledger { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: 110px minmax(180px, 1.1fr) minmax(220px, 1.4fr) 128px; gap: 18px; align-items: center;
  padding: 12px 6px; border-top: 1px solid var(--rule); cursor: pointer; transition: background .15s;
}
.row:hover, .row.open { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.row-date { font: 500 13px/1.3 "IBM Plex Mono", monospace; color: var(--ink-2); }
.row-date small { display: block; color: var(--ink-3); font-size: 11px; }
.row-what { font-size: 15.5px; line-height: 1.35; }
.row-what small { display: block; color: var(--ink-3); font-size: 13.5px; font-style: italic; }
.bar { position: relative; height: 22px; }
.bar::before { content: ""; position: absolute; left: 50%; top: -6px; bottom: -6px; border-left: 1px solid var(--rule-strong); opacity: .5; }
.bar i { position: absolute; top: 3px; height: 16px; border-radius: 1px; transform-origin: left; animation: grow .9s cubic-bezier(.2,.8,.2,1) both; }
.bar i.g { left: 50%; background: var(--gain); }
.bar i.l { right: 50%; background: var(--loss); transform-origin: right; }
.bar i.u { left: calc(50% - 3px); width: 6px; background: repeating-linear-gradient(45deg, var(--unk) 0 2px, transparent 2px 4px); }
@keyframes grow { from { transform: scaleX(0); } }
.row-pnl { text-align: right; font: 600 16px/1.2 "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }
.row-pnl small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-3); }
.row-detail { grid-column: 1 / -1; display: none; padding: 4px 0 6px 128px; }
.row.open .row-detail { display: block; animation: rise .35s both; }
.lots { width: 100%; border-collapse: collapse; font: 400 13px/1.4 "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }
.lots th { text-align: left; font-weight: 500; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--rule); }
.lots td { padding: 6px 10px 6px 0; border-bottom: 1px dotted var(--rule); }
.lots td:last-child, .lots th:last-child { text-align: right; }

.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; }
.tbl { width: 100%; border-collapse: collapse; font: 400 14px/1.4 "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; margin-top: 10px; }
.tbl th { text-align: right; font-weight: 500; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding: 8px 0 8px 12px; border-bottom: 1px solid var(--rule-strong); white-space: nowrap; }
.tbl td { text-align: right; padding: 9px 0 9px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 0; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--rule-strong); border-bottom: 0; }
.tbl-wrap { max-height: 460px; overflow: auto; }
.tbl-orders thead th { position: sticky; top: 0; background: var(--bg); z-index: 1; }
.tbl-orders td .side { display: inline-block; min-width: 3.6em; font-weight: 600; }
.side-buy { color: var(--buy); }
.side-sell { color: var(--ink); }
.open-list { margin: 10px 0 0; padding: 0; list-style: none; }
.open-list li { padding: 12px 0; border-bottom: 1px solid var(--rule); color: var(--ink-2); }
.open-list li b { color: var(--ink); font-family: "IBM Plex Mono", monospace; font-weight: 600; }
.open-list .big { display: block; font: 600 22px "IBM Plex Mono", monospace; margin-top: 2px; }

.colophon { padding: 40px 0 60px; border-top: 3px double var(--rule-strong); margin-top: 40px; color: var(--ink-3); font-size: 14px; }
.colophon p { max-width: 80ch; }

@media (max-width: 900px) {
  .masthead, main { padding: 0 18px; }
  .masthead { padding-top: 16px; }
  .drop, .hero, .two, .chart-sub { grid-template-columns: 1fr; gap: 24px; }
  .drop { padding: 30px 0 50px; }
  .drop-zone { min-height: 280px; }
  .notice { grid-template-columns: 1fr; }
  .ctl-right { margin-left: 0; }
  .row { grid-template-columns: 1fr auto; gap: 6px 12px; }
  .row-date { grid-column: 1; }
  .row-pnl { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .row-what { grid-column: 1; }
  .bar { grid-column: 1 / -1; }
  .row-detail { padding-left: 0; overflow-x: auto; }
  .chart { height: 320px; }
  .chart-sm { height: 150px; }
  .lede { font-size: 24px; }
  .two { grid-template-columns: minmax(0, 1fr); }
  .kpis dd { font-size: 18px; }
  .tbl { font-size: 12.5px; }
}
