/* Portfolio Choice & CAPM pages (plan A3.3–A3.4). Each page is a column of sections, and each
   section is an ordinary lab workspace (scenario-lab model-workspace: tone side panel on the left,
   results on the right; style.css, scenario.css, components.css, lab-report.css). The side panel is
   the shared sticky workspace-sidebar: a sticky box cannot leave its containing block, so each
   panel stays with its own section and the next one takes over as you scroll. Only what the
   shared components do not cover is here; colours come from theme.css (D20 report direction). */
.pf-page { display: grid; gap: 56px; }
.pf-page [hidden] { display: none !important; }
.pf-section { scroll-margin-top: 104px; }
.pf-rail .board-heading:first-of-type { margin-top: 4px; }
.pf-rail-note { margin: 0 0 8px; color: var(--ink-2); font-size: .85rem; line-height: 1.45; }
.pf-controls { display: grid; gap: 8px; }
.pf-link { padding: 0; border: 0; background: none; color: var(--model-strong); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.pf-check { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0 4px; color: var(--ink); font-size: .84rem; font-weight: 600; line-height: 1.4; cursor: pointer; }
.pf-check input { flex: none; width: auto; margin: 2px 0 0; }
.pf-label { display: block; margin-bottom: 4px; font-size: .84rem; font-weight: 600; }
.pf-rail select { width: 100%; margin-bottom: 8px; }

/* Choices in the side panel: tick boxes, radio lists and the shared flat toggle. */
.pf-picker, .pf-radio { display: grid; gap: 6px; margin: 0 0 10px; padding: 0; border: 0; }
.pf-radio legend { margin-bottom: 4px; font-size: .84rem; font-weight: 600; }
.pf-picker label, .pf-radio label { display: flex; align-items: center; gap: 8px; font-size: .88rem; cursor: pointer; }
.pf-picker input, .pf-radio input { flex: none; width: auto; margin: 0; }
.pf-toggle { flex-wrap: wrap; gap: 2px; margin: 4px 0 10px; }
.pf-toggle button { flex: 1 1 auto; font-weight: 600; }

/* Security cards (Your Portfolio): each asset has its own colour (--asset-color, set by the
   script from ASSET_COLORS in shared.js), a ticker, large return and risk figures, and what the
   company does at the bottom. The chosen two carry a thicker rule in their colour. */
.pf-choose { margin: 0; color: var(--ink); font-size: 1.05rem; font-weight: 700; }
.pf-asset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pf-asset { display: grid; grid-template-rows: auto 1fr auto; gap: 12px; min-height: 180px; padding: 14px 16px 12px; border: 2px solid var(--tone-2);
    border-top: 6px solid var(--asset-color, var(--model-accent)); border-radius: var(--radius); background: #ffffff; color: var(--ink);
    text-align: left; font: inherit; cursor: pointer; transition: border-color 160ms ease, background 160ms ease; }
.pf-asset:hover { border-color: var(--ink-3); border-top-color: var(--asset-color, var(--model-accent)); }
.pf-asset[aria-pressed="true"] { border-color: var(--asset-color, var(--model-accent));
    background: color-mix(in srgb, var(--asset-color, var(--model-accent)) 7%, white); }
.pf-asset-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pf-ticker { padding: 2px 6px; border-radius: 2px; background: var(--asset-color, var(--model-accent)); color: #ffffff; font-size: .8rem; font-weight: 800; letter-spacing: .04em; }
.pf-asset-name { overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.pf-asset-figures { display: grid; grid-template-columns: 1fr 1fr; align-items: center; text-align: center; }
.pf-asset-figure { display: grid; gap: 2px; }
.pf-asset-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.pf-asset-label { color: var(--ink-2); font-size: .8rem; font-weight: 600; }
.pf-asset-kind { padding-top: 8px; border-top: 1px solid var(--tone-2); color: var(--ink-2); font-size: .85rem; }

/* "The stats of your portfolio" and the Sharpe ratio / CML pair: two boxes side by side, each with
   a centred title, a large result and its formula underneath. */
.pf-stats-intro { margin: 6px 0 14px; color: var(--ink-2); }
.pf-key { color: var(--model-strong); font-weight: 700; }
.pf-stat-boxes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pf-stat { display: grid; align-content: start; justify-items: center; gap: 4px; min-width: 0; padding: 18px 16px; background: var(--tone); text-align: center; }
.pf-stat h4 { margin: 0; color: var(--ink-2); font-size: .95rem; font-weight: 700; }
.pf-stat-value { color: var(--model-strong); font-size: clamp(1.8rem, 3vw, 2.4rem); font-weight: 800; letter-spacing: -.02em; }
.pf-stat-note { color: var(--ink-2); font-size: .82rem; }
.pf-stat .pf-math { width: 100%; }
.pf-formula-big .katex-display { margin: .6em 0; }
.pf-formula-big .katex { font-size: 1.35em; }
.pf-beta { color: var(--model-accent); }
/* Insights and stories that read as a highlighted rectangle: tone band with the model's rule on top. */
.pf-insight, .pf-position { margin: 0; padding: 18px 22px; border-top: 4px solid var(--model-accent); background: var(--tone); color: var(--ink); line-height: 1.65; }
.pf-position h3 { margin: 2px 0 8px; font-size: 1.15rem; }
.pf-position p { margin: 0 0 8px; }
.pf-position p:last-child { margin-bottom: 0; }

/* Charts. */
.pf-chart { width: 100%; min-width: 0; height: 420px; }
.pf-chart-tall { height: 480px; }
.pf-chart-small { height: 300px; }
.pf-chart-side { height: 300px; }
.pf-chart-bars { height: 330px; }
.pf-chart-agg { height: 460px; }
.pf-trio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.8fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pf-trio-even { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
.pf-trio .chart-card { padding: 14px; }
.pf-trio h3 { margin: 0 0 4px; font-size: 1rem; }
.pf-pair-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* Formulas (KaTeX) scroll inside their card rather than widening the page. */
.pf-math { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.pf-equations { display: grid; gap: 2px; margin: 12px 0; }
.pf-equations p { margin: 8px 0 0; font-weight: 600; font-size: .9rem; }
.pf-band { min-height: 190px; }
.explain-card h4 { margin: 16px 0 8px; color: var(--ink); font-size: .95rem; font-weight: 700; }

/* Signed bars: your two shares, and the three parts of the variance. */
.pf-weight-bars, .pf-split { display: grid; gap: 6px; margin: 4px 0 8px; font-size: .82rem; }
.pf-bar-row { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) 4.2rem; align-items: center; gap: 8px; }
.pf-bar-track { position: relative; height: 10px; background: var(--tone-2); }
.pf-bar-fill { position: absolute; top: 0; bottom: 0; background: var(--model-accent); }
.pf-bar-fill.is-negative { background: var(--ink-3); }
.pf-bar-zero { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.pf-bar-value { text-align: right; font-variant-numeric: tabular-nums; }
.pf-snap, .pf-presets { display: flex; flex-wrap: wrap; gap: 0 14px; }

/* Playback controls. */
.pf-play { display: grid; gap: 4px; margin-top: 8px; }
.pf-play-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.pf-play-counter { margin: 0; color: var(--ink-2); font-size: .82rem; }

/* Risk & Beta. */
.pf-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
.pf-compare article { padding: 16px 18px; background: var(--tone); }
.pf-compare h4 { margin: 0; font-size: 1rem; }
.pf-compare dl { display: grid; grid-template-columns: auto auto; gap: 4px 16px; margin: 8px 0 0; }
.pf-compare dt { color: var(--ink-2); }
.pf-compare dd { margin: 0; text-align: right; font-weight: 600; }
.pf-kinds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pf-table { width: 100%; border-collapse: separate; border-spacing: 0 2px; font-size: .88rem; }
.pf-table th, .pf-table td { padding: 8px 10px; background: var(--tone); text-align: left; }
.pf-table td { font-variant-numeric: tabular-nums; }
.pf-table thead th { background: transparent; color: var(--ink-2); font-weight: 600; }
.pf-table-wrap { overflow-x: auto; }

/* Narrow screens: the shared workspace already stacks the side panel above its results (style.css). */
@media (max-width: 1024px) {
    .pf-asset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pf-trio { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pf-trio-main { grid-column: 1 / -1; order: -1; }
    .pf-trio-even { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
    .pf-asset-grid, .pf-compare, .pf-kinds, .pf-pair-charts, .pf-trio, .pf-stat-boxes { grid-template-columns: minmax(0, 1fr); }
    .pf-chart, .pf-chart-tall { height: 340px; }
}
.pf-stat .pf-math:not(.pf-formula-big) .katex { font-size: 1em; }

/* CAPM (plan A7): the safe rate in the T-bill green of The Market, the market risk premium in blue,
   β in the model colour (pf-beta, above). The same colours mark the three definition tiles. */
.pf-rf { color: #138667; }
.pf-mrp { color: #1f5fa8; }
.pf-formula-hero .katex { font-size: 1.7em; }
.pf-definitions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.pf-definition { padding: 14px 16px; border-top: 4px solid var(--definition-color); background: var(--tone); }
.pf-definition h4 { margin: 0; color: var(--definition-color); font-size: .95rem; font-weight: 700; }
.pf-definition p { margin: 6px 0 0; color: var(--ink-2); font-size: .88rem; line-height: 1.45; }
.pf-definition .pf-definition-value { margin: 4px 0 0; color: var(--definition-color); font-size: 1.6rem; font-weight: 800; }
.pf-definition-rf { --definition-color: #138667; }
.pf-definition-beta { --definition-color: var(--model-strong); }
.pf-definition-mrp { --definition-color: #1f5fa8; }
.pf-fold { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--tone-2); }
.pf-fold summary { color: var(--ink); font-size: .9rem; font-weight: 700; cursor: pointer; }
.pf-note { margin: 8px 0 0; padding: 10px 12px; border-left: 3px solid var(--ink-3); background: var(--tone); color: var(--ink-2); font-size: .88rem; line-height: 1.5; }
.pf-notes:empty { display: none; }
.pf-hypothetical { border-top: 4px dashed var(--ink-3); }
.pf-solve-tile { grid-template-columns: minmax(0, 1fr); }
.pf-round-log { max-height: 180px; margin: 8px 0 0; padding-left: 0; overflow-y: auto; list-style: none; color: var(--ink-2); font-size: .82rem; font-variant-numeric: tabular-nums; }
.pf-round-log li { padding: 2px 0; }
.pf-round-log:empty { display: none; }
@media (max-width: 700px) {
    .pf-definitions { grid-template-columns: minmax(0, 1fr); }
    .pf-formula-hero .katex { font-size: 1.25em; }
}

/* Retire Early (plan A14): presets as a list, the review buttons, and the News log. Each entry
   carries a thin rule in a tone that follows its tier, so a crash reads differently at a glance. */
.pf-rail-list { margin: 0 0 8px; font-size: .84rem; }
.pf-preset-list { display: grid; gap: 2px; justify-items: start; margin: 4px 0 8px; }
.pf-holdings { font-weight: 600; color: var(--ink); }
.pf-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.pf-choices button { flex: 1 1 auto; }
.pf-again { display: grid; gap: 8px; justify-items: start; }
.pf-news { display: grid; gap: 10px; max-height: 640px; margin: 8px 0 0; padding: 0; overflow-y: auto; list-style: none; }
.pf-news-item { padding: 10px 14px; border-left: 4px solid var(--tone-2); background: var(--tone); font-size: .88rem; line-height: 1.5; }
.pf-news-item p { margin: 0 0 4px; }
.pf-news-item ul { margin: 4px 0; padding-left: 18px; color: var(--ink-2); }
.pf-news-head { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-2); font-size: .8rem; }
.pf-news-tier { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.pf-news-headline { font-weight: 700; color: var(--ink); }
.pf-news-story { font-style: italic; }
.pf-news-result { font-weight: 700; color: var(--model-strong); }
.pf-news-crash { border-left-color: #b8323a; }
.pf-news-bad { border-left-color: #d9822b; }
.pf-news-strong { border-left-color: #6aa36f; }
.pf-news-boom { border-left-color: #138667; }
.pf-news-market .pf-news-item { opacity: .85; }
.pf-table tr.is-best th, .pf-table tr.is-best td { font-weight: 700; color: var(--model-strong); }

/* Retire Early redesign (plan A19.4). The brief is the tab's cover: one full-width card with no
   side panel. The plan's two funds sit side by side as compact tick lists. While playing, the side
   panel is only a title and a button, and the News sits beside the wealth chart so both are seen
   at once. */
.pf-cover { display: grid; gap: 14px; padding: 22px 24px; border-top: 4px solid var(--model-accent); }
.pf-cover-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pf-cover-head h2 { margin: 2px 0 0; font-size: clamp(1.4rem, 2.6vw, 2rem); letter-spacing: -0.02em; }
.pf-cover-lede { margin: 0; color: var(--ink); font-size: 1.15rem; font-weight: 700; line-height: 1.45; }
.pf-cover-investor { margin: 0; color: var(--ink-2); }
.pf-setting { display: grid; gap: 4px; max-width: 46em; }
.pf-setting .pf-toggle { justify-self: start; margin: 0; }
.pf-cover .metric-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pf-rules { margin: 0; }
.pf-funds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; padding: 0; background: transparent; }
.pf-fund { padding: 14px 16px; background: var(--tone); }
.pf-fund h4 { margin: 0 0 8px; font-size: 1rem; }
.pf-fund-list summary { color: var(--model-strong); font-size: .88rem; font-weight: 700; cursor: pointer; }
.pf-fund-list ul { display: grid; gap: 2px; margin: 8px 0 0; padding: 0; list-style: none; }
.pf-security label { display: grid; grid-template-columns: auto 10px 3.4rem minmax(0, 1fr) auto; align-items: center; gap: 8px;
    padding: 4px 6px; background: #ffffff; font-size: .82rem; cursor: pointer; }
.pf-security input { width: auto; margin: 0; }
.pf-swatch { width: 10px; height: 10px; border-radius: 2px; }
.pf-sec-ticker { font-weight: 800; letter-spacing: .03em; }
.pf-sec-name { overflow: hidden; color: var(--ink-2); text-overflow: ellipsis; white-space: nowrap; }
.pf-sec-stats { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-fund-box { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin: 10px 0 0; }
.pf-fund-box div { padding: 8px 10px; background: #ffffff; }
.pf-fund-box dt { color: var(--ink-2); font-size: .78rem; font-weight: 600; }
.pf-fund-box dd { margin: 2px 0 0; font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pf-readout { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; margin: 6px 0 4px; }
.pf-readout div { padding: 6px 8px; background: var(--tone); }
.pf-readout dt { color: var(--ink-2); font-size: .72rem; font-weight: 600; line-height: 1.25; }
.pf-readout dd { margin: 2px 0 0; font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pf-meets { font-weight: 700; color: var(--model-strong); }
.pf-meets.is-short { color: #b8323a; }
.pf-rail-compact .sidebar-title { margin-bottom: 10px; }
.pf-play-view { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pf-news-card { display: flex; flex-direction: column; max-height: 640px; }
.pf-news-card .pf-news { flex: 1 1 auto; max-height: none; overflow-y: auto; }
.pf-review { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--tone-2); }
.pf-review h4 { margin: 0 0 6px; }
.pf-news-down, .pf-news-default, .pf-news-bad { color: #9b1c1c; }
.pf-news-up, .pf-news-good { color: #166534; }
@media (max-width: 1024px) {
    .pf-play-view { grid-template-columns: minmax(0, 1fr); }
    .pf-news-card { max-height: 520px; }
}
@media (max-width: 700px) {
    .pf-cover { padding: 16px; }
    .pf-cover .metric-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pf-funds { grid-template-columns: minmax(0, 1fr); }
    .pf-security label { grid-template-columns: auto 10px 3.2rem minmax(0, 1fr); }
    .pf-sec-stats { grid-column: 3 / -1; }
}
