/* Newsprint treatment for the existing market and portfolio workbenches.
   Configuration may set tokens inline; the theme owns presentation only. */
body.newsprint-theme #terminal-root {
  --t-up: #b52c32 !important;
  --t-down: #28664f !important;
  --t-accent: #111111 !important;
  --t-warning: #865a10 !important;
  --t-call: #295b84 !important;
  --t-put: #80517e !important;
  --t-panel: #f9f9f7 !important;
  --t-panel-alt: #f1f1ec !important;
  --t-line: #d8d8d1 !important;
  --t-text: #111111 !important;
  --t-muted: #60605a !important;
  --t-gap: 16px !important;
  --t-right: 330px !important;
  --t-chart-height: 235px !important;
  font: 13px/1.65 var(--np-sans);
  color: var(--np-ink);
  color-scheme: light;
}

body.newsprint-theme #portfolio-root {
  --pp-background: #f1f1ec !important;
  --pp-panel: #f9f9f7 !important;
  --pp-line: #d8d8d1 !important;
  --pp-muted: #60605a !important;
  --pp-text: #111111 !important;
  --pp-accent: #111111 !important;
  --pp-up: #b52c32 !important;
  --pp-down: #28664f !important;
  --pp-warning: #865a10 !important;
  --pp-gap: 16px !important;
  --pp-radius: 0px !important;
  --pp-matrix-row-height: 36px !important;
  font: 13px/1.65 var(--np-sans);
  color: var(--np-ink);
  color-scheme: light;
}

body.newsprint-theme :is(#terminal-root, #portfolio-root) *,
body.newsprint-theme :is(#terminal-root, #portfolio-root) *::before,
body.newsprint-theme :is(#terminal-root, #portfolio-root) *::after {
  border-radius: 0 !important;
  box-shadow: none;
}

body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(h2, h3) {
  font-family: var(--np-serif);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--np-ink);
}
body.newsprint-theme :is(#terminal-root, #portfolio-root) h2 { font-size: 22px; line-height: 1.3; }
body.newsprint-theme :is(#terminal-root, #portfolio-root) h3 { font-size: 18px; }
body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(.terminal-num, .pp-num, pre, code) {
  font-family: var(--np-mono);
  font-variant-numeric: tabular-nums;
}
body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(button, .pp-button) {
  font-family: var(--np-sans);
  color: var(--np-ink);
  background: var(--np-paper);
  border: 1px solid var(--np-ink);
  min-height: 32px;
  letter-spacing: .02em;
  transition: color .15s, background-color .15s, border-color .15s;
}
body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(button, .pp-button):hover {
  background: #efefea;
  color: var(--np-ink);
  border-color: var(--np-ink);
}
body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(.primary, .pp-primary) {
  color: var(--np-paper);
  background: var(--np-ink);
  border-color: var(--np-ink);
}
body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(.primary, .pp-primary):hover {
  color: var(--np-paper);
  background: var(--np-red);
  border-color: var(--np-red);
}
body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(input, select, textarea) {
  font-family: var(--np-mono);
  color: var(--np-ink);
  background: transparent !important;
  border: 0;
  border-bottom: 2px solid var(--np-ink) !important;
  min-height: 32px;
  padding: 7px 8px;
  accent-color: var(--np-ink);
}
body.newsprint-theme :is(#terminal-root, #portfolio-root) textarea::placeholder { color: #70706a; opacity: 1; }
body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--np-ink);
  outline-offset: 3px;
}
body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(input, select, textarea):focus-visible { background: #efefea !important; }
body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(input[type=range], input[type=checkbox]) { border: 0 !important; }

/* Mastheads, column rules, and the shared ledger of risk metrics. */
body.newsprint-theme #terminal-root .terminal-topline,
body.newsprint-theme #portfolio-root .pp-top {
  padding: 0 0 12px;
  margin-bottom: 12px;
  border-bottom: 3px solid var(--np-ink);
  align-items: flex-start;
}
body.newsprint-theme #terminal-root .terminal-narrative,
body.newsprint-theme #portfolio-root .pp-headline { font-family: var(--np-serif); font-size: 18px; }
body.newsprint-theme #terminal-root .terminal-narrative :is(b, strong),
body.newsprint-theme #portfolio-root .pp-headline strong { color: var(--np-ink); font-weight: 700; }
body.newsprint-theme #terminal-root .terminal-live-dot,
body.newsprint-theme #portfolio-root .pp-live-dot { background: var(--np-red); width: 6px; height: 6px; }
body.newsprint-theme #terminal-root .terminal-toolbar { padding-bottom: 12px; border-bottom: 1px solid var(--np-ink); }
body.newsprint-theme #terminal-root .terminal-kpis,
body.newsprint-theme #portfolio-root .pp-kpis {
  gap: 0;
  border-top: 1px solid var(--np-ink);
  border-left: 1px solid var(--np-ink);
  margin-bottom: 20px;
}
body.newsprint-theme #terminal-root .terminal-kpi,
body.newsprint-theme #portfolio-root .pp-kpi {
  border: 0 !important;
  border-right: 1px solid var(--np-ink) !important;
  border-bottom: 1px solid var(--np-ink) !important;
  background: var(--np-paper) !important;
  padding: 14px 16px !important;
  min-height: 116px;
}
body.newsprint-theme #terminal-root .terminal-kpi:hover { background: #efefea !important; }
body.newsprint-theme #terminal-root .terminal-kpi-value strong,
body.newsprint-theme #portfolio-root .pp-kpi > strong { font-family: var(--np-mono); font-size: 27px; font-weight: 600; letter-spacing: -.06em; }
body.newsprint-theme #terminal-root .terminal-kpi[data-terminal-kpi=quality] .terminal-kpi-value strong,
body.newsprint-theme #terminal-root .terminal-kpi[data-terminal-kpi=sentiment] .terminal-kpi-value strong { font-family: var(--np-serif); font-size: 20px; letter-spacing: 0; }
body.newsprint-theme #terminal-root .terminal-kpi-bar { background: var(--np-rule); height: 2px; }
body.newsprint-theme #terminal-root .terminal-kpi-bar i { background: var(--np-ink); }
body.newsprint-theme #terminal-root .terminal-grid { gap: 20px; }
body.newsprint-theme #terminal-root :is(.terminal-panel, .terminal-loading),
body.newsprint-theme #portfolio-root :is(.pp-panel, .pp-pricing-expand) { background: var(--np-paper); border: 1px solid var(--np-ink); padding: 16px; }
body.newsprint-theme #portfolio-root .pp-pricing-expand { padding: 0; }
body.newsprint-theme #portfolio-root .pp-pricing-expand > .pp-pricing-panel { border: 0; border-top: 1px solid var(--np-ink); }
body.newsprint-theme #terminal-root .terminal-panel-head,
body.newsprint-theme #portfolio-root .pp-panel-head { padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--np-ink); flex-wrap: wrap; }
body.newsprint-theme #portfolio-root .pp-grid > .pp-panel { padding: 16px; }
body.newsprint-theme #portfolio-root .pp-pricing-top { padding-bottom: 10px; border-bottom: 1px solid var(--np-rule); }
body.newsprint-theme #portfolio-root .pp-pricing-comparison > div { background: var(--np-paper); border-color: var(--np-rule); }
body.newsprint-theme #terminal-root :is(.terminal-tag, .terminal-tag.warning),
body.newsprint-theme #portfolio-root :is(.pp-tag, .pp-structure) {
  background: transparent;
  border: 1px solid var(--np-rule);
  color: var(--np-muted);
  font-family: var(--np-mono);
  font-size: 10px;
  letter-spacing: .04em;
}
body.newsprint-theme #terminal-root .terminal-tag.warning { color: var(--t-warning); border-color: var(--t-warning); }

/* Chart ink stays semantic: red/green P&L and blue/purple call/put. */
body.newsprint-theme #terminal-root :is(.terminal-axis, .terminal-axis-caption),
body.newsprint-theme #portfolio-root :is(.pp-svg-axis, .pp-svg-caption) { fill: #60605a; font-family: var(--np-mono); }
body.newsprint-theme #terminal-root .terminal-chart-subtitle { fill: var(--np-ink); font-family: var(--np-sans); }
body.newsprint-theme #terminal-root .terminal-grid-line,
body.newsprint-theme #portfolio-root .pp-svg-grid { stroke: #d8d8d1; stroke-dasharray: none; opacity: 1; }
body.newsprint-theme #terminal-root .terminal-value-label { stroke: var(--np-paper); font-family: var(--np-mono); }
body.newsprint-theme #terminal-root .terminal-point:focus,
body.newsprint-theme #terminal-root .terminal-point:hover { stroke: var(--np-ink); }
body.newsprint-theme #portfolio-root .pp-path-dot { stroke: var(--np-paper); }
body.newsprint-theme #portfolio-root .pp-selected-line { stroke: #60605a; }
body.newsprint-theme #portfolio-root .pp-path-hit:focus,
body.newsprint-theme #portfolio-root .pp-path-hit:hover { fill: #11111118; }
body.newsprint-theme #portfolio-root .pp-hist-bar { fill: var(--pp-accent); }
body.newsprint-theme #portfolio-root .pp-hist-bar:hover { fill: #55554e; }
body.newsprint-theme #portfolio-root .pp-waterfall-value { fill: var(--np-ink); stroke: var(--np-paper); }
body.newsprint-theme #portfolio-root .pp-waterfall-label { fill: var(--np-ink); }
body.newsprint-theme #portfolio-root .pp-waterfall-sub { fill: #60605a; }
body.newsprint-theme #terminal-root .terminal-chart-empty,
body.newsprint-theme #portfolio-root .pp-empty { color: var(--np-muted); }
body.newsprint-theme #terminal-root .terminal-tabs,
body.newsprint-theme #portfolio-root .pp-history-tabs { background: transparent; border: 0; border-bottom: 1px solid var(--np-rule); padding: 0; gap: 0; }
body.newsprint-theme #terminal-root .terminal-tabs button,
body.newsprint-theme #portfolio-root .pp-history-tabs > button { color: var(--np-muted) !important; background: transparent !important; }
body.newsprint-theme #terminal-root .terminal-tabs button.active,
body.newsprint-theme #portfolio-root .pp-history-tabs > button.active { color: var(--np-paper) !important; background: var(--np-ink) !important; }

/* Heat maps retain magnitude and sign. Their display colors are theme-aware in JS. */
body.newsprint-theme #terminal-root :is(.terminal-chain, .terminal-scenario-matrix) table,
body.newsprint-theme #portfolio-root .pp-matrix table { font-family: var(--np-mono); border-spacing: 3px; }
body.newsprint-theme #terminal-root :is(.terminal-chain, .terminal-scenario-matrix) th,
body.newsprint-theme #portfolio-root .pp-matrix th { color: #60605a; background: transparent; }
body.newsprint-theme #terminal-root :is(.terminal-chain, .terminal-scenario-matrix) button { color: var(--np-ink) !important; border: 1px solid transparent !important; }
body.newsprint-theme #terminal-root :is(.terminal-chain, .terminal-scenario-matrix) button:hover,
body.newsprint-theme #terminal-root :is(.terminal-chain, .terminal-scenario-matrix) button.selected { border-color: var(--np-ink) !important; }
body.newsprint-theme #terminal-root .terminal-chain button { background: var(--cell-color, #e5e5e0) !important; }
body.newsprint-theme #terminal-root .terminal-scenario-matrix button { background: var(--cell-color, #e5e5e0) !important; }
body.newsprint-theme #terminal-root .terminal-chain .no-node { color: #92928b; }
body.newsprint-theme #portfolio-root .pp-matrix button {
  color: var(--np-ink) !important;
  background: var(--pp-cell, #e5e5e0) !important;
  border: 1px solid transparent !important;
  font-family: var(--np-mono) !important;
  min-height: var(--pp-matrix-row-height);
}
body.newsprint-theme #portfolio-root .pp-matrix button.selected,
body.newsprint-theme #portfolio-root .pp-matrix button:hover { border-color: var(--np-ink) !important; box-shadow: none; outline: 1px solid var(--np-ink); outline-offset: -3px; }
body.newsprint-theme #portfolio-root .pp-cell-badge { color: var(--np-ink) !important; font-family: var(--np-sans) !important; }
body.newsprint-theme #portfolio-root .pp-cell-selected { background: var(--np-ink); }
body.newsprint-theme #portfolio-root .pp-matrix-legend i { height: 7px; background: linear-gradient(90deg, #a3bcb0, #f9f9f7, #ddb0b2); }
body.newsprint-theme #portfolio-root .pp-matrix { height: calc(var(--pp-matrix-rows, 7) * (var(--pp-matrix-row-height) + 3px) + 75px); }

/* Attribution rows and contract tables read as ledgers, with explicit zero axes. */
body.newsprint-theme #portfolio-root .pp-contributor { border-bottom: 1px solid var(--np-rule) !important; }
body.newsprint-theme #portfolio-root .pp-contributor.selected,
body.newsprint-theme #portfolio-root .pp-contributor:hover { background: #efefea !important; }
body.newsprint-theme #portfolio-root .pp-contributor :is(.pp-bar-label, strong),
body.newsprint-theme #portfolio-root .pp-contributor:hover .pp-bar-label,
body.newsprint-theme #portfolio-root .pp-contributor.selected .pp-bar-label { color: var(--np-ink); }
body.newsprint-theme #portfolio-root .pp-bar-track { background: #efefea; }
body.newsprint-theme #portfolio-root .pp-factor-track > span { border-color: var(--np-rule); }
body.newsprint-theme #portfolio-root .pp-table th { color: var(--np-ink); background: #edede7; border-bottom: 1px solid var(--np-ink); font-family: var(--np-mono); }
body.newsprint-theme #portfolio-root .pp-table td { color: var(--np-ink); border-color: var(--np-rule); font-family: var(--np-mono); }
body.newsprint-theme #portfolio-root .pp-table tr.selected td { background: #e5e5e0; }
body.newsprint-theme #portfolio-root .pp-table :is(.pp-contract-link, .pp-evidence-link) { color: var(--np-ink) !important; text-decoration-color: var(--np-red); }
body.newsprint-theme #portfolio-root .pp-table :is(.pp-contract-link, .pp-evidence-link):hover { text-decoration: underline; text-decoration-color: var(--np-red); text-underline-offset: 4px; }
body.newsprint-theme #portfolio-root .pp-contracts > summary { color: var(--np-ink) !important; }

/* Remove legacy pale-on-dark text from notes, provenance, and assistants. */
body.newsprint-theme #terminal-root :is(.terminal-asof, .terminal-kpi-header span:last-child, .terminal-command-mode, .terminal-command-submit small, .terminal-answer-meta, .terminal-source-row, .terminal-source-details, .terminal-scenario-result, .terminal-scenario-extremes, .terminal-scenario-disclosure, .terminal-scenario-disclosure summary, .terminal-data-details, .terminal-data-gaps, .terminal-contract-record, .terminal-detail p, .terminal-legacy summary, .terminal-alert small, .terminal-alert b, .terminal-alert-empty, .terminal-answer.waiting) { color: #60605a; }
body.newsprint-theme #terminal-root :is(.terminal-detail strong, .terminal-data-gaps b, .terminal-data-gaps > summary, .terminal-contract-scenario > summary, .terminal-answer) { color: var(--np-ink); }
body.newsprint-theme #terminal-root :is(.terminal-detail, .terminal-brush, .terminal-scenario-result, .terminal-alert) { border-color: var(--np-rule) !important; }
body.newsprint-theme #terminal-root .terminal-alert { background: transparent !important; }
body.newsprint-theme #terminal-root .terminal-alert:hover { background: #efefea !important; }
body.newsprint-theme #terminal-root .terminal-suggestions button,
body.newsprint-theme #portfolio-root .pp-suggestions > button { background: #efefea !important; border-color: var(--np-rule) !important; color: var(--np-ink) !important; }
body.newsprint-theme #terminal-root .terminal-evidence { color: var(--np-ink) !important; text-decoration-color: var(--np-red); }
body.newsprint-theme #portfolio-root :is(.pp-eyebrow, .pp-source, .pp-kpi > small, .pp-profile-line, .pp-footnote, .pp-scenario-summary > p, .pp-scenario-summary small, .pp-controls-panel label > span, .pp-limit-summary, .pp-assumptions p, .pp-bar-label small, .pp-selected-detail > p, .pp-factor > small, .pp-structures, .pp-replay-controls > span, .pp-command-row, .pp-answer-evidence, .pp-plan-step small, .pp-contracts > summary > span, .pp-table td small, .pp-provenance, .pp-evidence-fields dt, .pp-onboarding > p, .pp-onboarding > span, .pp-reverse-heading, .pp-reverse-results small, .pp-reverse-results > p) { color: #60605a !important; }
body.newsprint-theme #portfolio-root :is(.pp-profile-line b, .pp-capability-list b, .pp-selected-detail > strong, .pp-answer, .pp-answer-evidence code, .pp-plan-step strong, .pp-onboarding > strong) { color: var(--np-ink); }
body.newsprint-theme #portfolio-root :is(.pp-limit-summary, .pp-advanced, .pp-selected-detail, .pp-plan-step, .pp-reverse-results > button, .pp-evidence-fields > div) { border-color: var(--np-rule) !important; }
body.newsprint-theme #portfolio-root .pp-plan-step > b { color: var(--np-red); }
body.newsprint-theme #portfolio-root pre { background: #f1f1ec; color: var(--np-ink); border-color: var(--np-rule); }
body.newsprint-theme #portfolio-root .pp-empty-grid { opacity: .3; mask-image: none; }
body.newsprint-theme #portfolio-root .pp-empty-grid > i { background: #e5e5e0; }
body.newsprint-theme #portfolio-root .pp-empty-grid > i:nth-child(4n) { background: #d4e0d7; }
body.newsprint-theme #portfolio-root .pp-empty-grid > i:nth-child(5n) { background: #ead5d5; }
body.newsprint-theme #terminal-root .terminal-loading-mask { background: #f9f9f7f2; color: var(--np-ink); border-color: var(--np-ink); backdrop-filter: none; }
body.newsprint-theme #terminal-root .terminal-data-error { background: #f4ede4; color: #68451d; border-color: #865a10; }
body.newsprint-theme #portfolio-root .pp-dialog { background: var(--np-paper); color: var(--np-ink); border: 2px solid var(--np-ink); box-shadow: 8px 8px 0 #111111; }
body.newsprint-theme #portfolio-root .pp-dialog::backdrop { background: #11111170; backdrop-filter: none; }

/* Terminal tooltip and toast are appended to body, outside terminal-root. */
body.newsprint-theme :is(.terminal-tooltip, .terminal-toast) { background: var(--np-paper); color: var(--np-ink); border: 1px solid var(--np-ink); border-radius: 0; box-shadow: 3px 3px 0 var(--np-ink); font-family: var(--np-mono); }
body.newsprint-theme .terminal-tooltip small { color: #60605a; }

@media (min-width: 1180px) {
  body.newsprint-theme #portfolio-root .pp-kpis { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  body.newsprint-theme #portfolio-root .pp-kpi { padding: 12px 10px !important; min-height: 102px; }
  body.newsprint-theme #portfolio-root .pp-kpi > strong { font-size: 22px; }
}
@media (max-width: 1180px) {
  body.newsprint-theme #portfolio-root .pp-grid { grid-template-columns: 1fr; grid-template-areas: none; }
  body.newsprint-theme #portfolio-root .pp-grid > .pp-panel { grid-area: auto; grid-column: 1 / -1; }
  body.newsprint-theme #portfolio-root .pp-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 970px) {
  body.newsprint-theme #terminal-root .terminal-grid { grid-template-columns: 1fr; }
  body.newsprint-theme #terminal-root .terminal-tools { flex-wrap: wrap; }
  body.newsprint-theme #terminal-root .terminal-topline { flex-wrap: wrap; }
}
@media (max-width: 767px), (pointer: coarse) {
  body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(button, .pp-button, input:not([type=checkbox]), select, summary) { min-height: 44px !important; }
  body.newsprint-theme :is(#terminal-root, #portfolio-root) :is(button, .pp-button) { min-width: 44px; }
  body.newsprint-theme #terminal-root .terminal-compare { min-height: 44px; padding: 8px 0; }
  body.newsprint-theme #terminal-root .terminal-brush input[type=range],
  body.newsprint-theme #portfolio-root input[type=range] { height: 44px !important; }
  body.newsprint-theme #terminal-root .terminal-brush { grid-template-columns: 1fr; }
  body.newsprint-theme #terminal-root .terminal-chain { max-height: 280px; }
  body.newsprint-theme #terminal-root :is(.terminal-chain, .terminal-scenario-matrix) button { height: 44px; }
  body.newsprint-theme #terminal-root .terminal-chain table { min-width: 550px; }
  body.newsprint-theme #terminal-root .terminal-scenario-matrix table { min-width: 320px; }
  body.newsprint-theme #portfolio-root { --pp-matrix-row-height: 44px !important; }
  body.newsprint-theme #portfolio-root .pp-matrix table { min-width: 470px; }
  body.newsprint-theme #portfolio-root .pp-replay-controls { height: auto; flex-wrap: wrap; }
  body.newsprint-theme #portfolio-root .pp-replay-controls > input { flex-basis: calc(100% - 100px); }
  body.newsprint-theme #portfolio-root .pp-replay-controls > span { width: 100%; text-align: left; }
  body.newsprint-theme #portfolio-root .pp-contributor { min-height: 44px !important; }
}
@media (max-width: 650px) {
  body.newsprint-theme :is(#terminal-root, #portfolio-root) h2 { font-size: 20px; }
  body.newsprint-theme #terminal-root .terminal-toolbar { align-items: flex-start; flex-wrap: wrap; }
  body.newsprint-theme #terminal-root .terminal-kpis,
  body.newsprint-theme #portfolio-root .pp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.newsprint-theme #terminal-root .terminal-chart-row { grid-template-columns: 1fr; }
  body.newsprint-theme #terminal-root .terminal-panel,
  body.newsprint-theme #portfolio-root .pp-grid > .pp-panel { padding: 14px 12px; }
  body.newsprint-theme #portfolio-root .pp-top { display: block; }
  body.newsprint-theme #portfolio-root .pp-top-actions { justify-content: flex-start; max-width: none; }
  body.newsprint-theme #portfolio-root .pp-source { flex-direction: column; }
  body.newsprint-theme #portfolio-root .pp-source > span:last-child { text-align: left; max-width: none; }
}
