:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --border: #e2e0da;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #8a8883;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #008300;
  --warn: #c98500;
  --bad: #e34948;
  --series-loan: #2a78d6;
  --series-equity: #eb6834;
  --series-fund: #1baf7a;
  --series-listed: #eda100;
  --series-note: #e87ba4;
  --series-safe: #4a3aa7;
  --grid: #e8e6e0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.05);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #2e2e2b;
    --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e87;
    --accent: #3987e5; --good: #3fb53f; --warn: #e0a030; --bad: #e66767;
    --series-loan: #3987e5; --series-equity: #d95926; --series-fund: #199e70;
    --series-listed: #c98500; --series-note: #d55181; --series-safe: #9085e9;
    --grid: #2a2a28; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --border: #2e2e2b;
  --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e87;
  --accent: #3987e5; --good: #3fb53f; --warn: #e0a030; --bad: #e66767;
  --series-loan: #3987e5; --series-equity: #d95926; --series-fund: #199e70;
  --series-listed: #c98500; --series-note: #d55181; --series-safe: #9085e9;
  --grid: #2a2a28; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 .8em; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--mono); font-size: .85em; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

header.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
header.top .container { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 14px; font-weight: 800; }
nav.tabs { display: flex; gap: 4px; margin-left: auto; }
nav.tabs a { padding: 8px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
nav.tabs a:hover { background: var(--surface-2); text-decoration: none; }
nav.tabs a.active { background: var(--surface-2); color: var(--text); }
.theme-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; font-size: .85rem; }

main { padding: 32px 0 80px; }
.page-head { margin-bottom: 24px; }
.page-head p { max-width: 70ch; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card h2, .card h3 { margin-top: 0; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.loan .dot { background: var(--series-loan); }
.badge.equity .dot { background: var(--series-equity); }
.badge.fund-commitment .dot { background: var(--series-fund); }
.badge.listed-equity .dot { background: var(--series-listed); }
.badge.convertible-note .dot { background: var(--series-note); }
.badge.safe .dot { background: var(--series-safe); }
.badge.bv { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); border-color: transparent; }
.badge.private { background: color-mix(in srgb, var(--series-equity) 14%, transparent); color: var(--series-equity); border-color: transparent; }
.badge.unknown { border-style: dashed; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.status.active::before, .status.performing::before { background: var(--good); }
.status.overdue::before { background: var(--bad); }
.status.open::before { background: var(--warn); }
.status.invested::before { background: var(--good); }
.status.passed::before { background: var(--text-3); }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stat .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; }
.stat .value { font-size: 1.45rem; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.stat .sub { font-size: .8rem; color: var(--text-2); margin-top: 2px; }

/* ideas */
.idea-card { display: grid; grid-template-columns: 1fr; }
.idea-card .thumb { aspect-ratio: 16/9; background: var(--surface-2); overflow: hidden; border-bottom: 1px solid var(--border); }
.idea-card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.idea-card .body { padding: 18px 20px; }
.idea-card .meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-weight: 600; border: 0; cursor: pointer; font: inherit; font-size: .9rem; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.sm { padding: 6px 10px; font-size: .8rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.deck-frame { width: 100%; height: min(78vh, 820px); border: 0; display: block; background: var(--surface-2); }
.deck-fallback { padding: 24px; text-align: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .9rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: .85rem; }
.chip b { display: block; font-size: .95rem; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
tbody tr:hover { background: var(--surface-2); }
.src { font-size: .75rem; color: var(--text-3); }

/* portfolio list */
.inv-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--border); }
.inv-row:last-child { border-bottom: 0; }
.inv-row .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.inv-row .amt { font-size: 1.15rem; font-weight: 700; text-align: right; white-space: nowrap; }
.inv-row .amt .sub { display: block; font-size: .75rem; color: var(--text-3); font-weight: 500; }
details.events { margin-top: 10px; }
details.events summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
ul.events { list-style: none; padding: 0; margin: 8px 0 0; font-size: .85rem; }
ul.events li { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
ul.events li .d { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* timeline */
.timeline-wrap { position: relative; overflow-x: auto; }
.timeline-wrap svg { display: block; min-width: 720px; width: 100%; height: auto; font-family: var(--font); }
.tl-grid { stroke: var(--grid); stroke-width: 1; }
.tl-axis { fill: var(--text-3); font-size: 11px; }
.tl-label { fill: var(--text); font-size: 12px; }
.tl-sub { fill: var(--text-3); font-size: 10px; }
.tl-bar { stroke-width: 6; stroke-linecap: round; opacity: .35; }
.tl-mark { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.tl-mark.maturity { fill: var(--surface); stroke-width: 2.5; }
.tl-today { stroke: var(--text-3); stroke-dasharray: 3 3; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .8rem; color: var(--text-2); margin: 10px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend i.hollow { background: transparent !important; border: 2px solid var(--text-2); }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 8px; padding: 8px 10px; font-size: .8rem; max-width: 280px; z-index: 20; display: none; }
.tooltip b { display: block; }

.note { background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border)); border-radius: 10px; padding: 12px 14px; font-size: .88rem; }
.note.info { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.section { margin-top: 32px; }
.section > h2 { margin-bottom: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
footer { color: var(--text-3); font-size: .8rem; border-top: 1px solid var(--border); padding: 20px 0; }

@media print {
  header.top, .actions, .toolbar, .theme-btn, details.events { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; break-inside: avoid; }
  main { padding: 0; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .inv-row { grid-template-columns: 1fr; }
  .inv-row .amt { text-align: left; }
  nav.tabs a { padding: 6px 8px; font-size: .9rem; }
}

/* idea groups, placeholders and one-pager */
.group-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin: 0 0 12px; }
.idea-card .thumb.placeholder { display: flex; flex-direction: column; justify-content: flex-end; padding: 20px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--surface-2)), var(--surface-2)); color: var(--text); }
.idea-card .thumb.placeholder .ph-name { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.idea-card .thumb.placeholder .ph-tag { font-size: .9rem; color: var(--text-2); }
.onepager .op-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px 28px; }
.onepager h4 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin: 0 0 4px; }
.onepager p { margin: 0; font-size: .95rem; }

/* statuses added after the Google sweep */
.status.matured::before { background: var(--warn); }
.status.impaired::before { background: var(--bad); }
.status.written-off::before { background: var(--text-3); }
.status.exited::before, .status.closed::before { background: var(--text-3); }
.story { padding-left: 20px; margin: 0; }
.story li { margin: 6px 0; }
.src div { margin-top: 2px; }
