/* ===== Editorial dark mode — readability pass ===== */

:root {
  --bg:         #14130F;
  --bg-panel:   #1B1A14;
  --bg-elev:    #221F18;
  --bg-hover:   #2A2620;
  --text:       #FBF6E8;       /* near-white warm; high contrast for body prose */
  --text-strong:#FFFCF1;       /* maximum contrast for headings and key numbers */
  --text-mute:  #C8C0AE;       /* used to be #948D80 — was too dim; now readable secondary */
  --text-faint: #948D80;       /* the old mute, now used only for hints/timestamps */
  --accent:     #E5BC73;       /* slightly brighter gold than before */
  --accent-soft:#B89261;
  --accent-2:   #8BC09D;
  --accent-3:   #D27575;
  --rule:       #34302A;
  --rule-soft:  #261F19;

  --serif-display: "Instrument Serif", "Newsreader", "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --serif:         "Newsreader", "Source Serif 4", "Source Serif Pro", "Charter", Georgia, "Iowan Old Style", serif;
  --mono:          "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --col-chat: 680px;          /* tighter for readability — ~70ch */
  --col-params: 320px;
  --col-rail: 220px;

  --radius: 4px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 18.5px;
  font-weight: 450;              /* up from 400 for higher perceived contrast */
  line-height: 1.7;
  font-feature-settings: "kern", "liga", "calt";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(212,174,106,0.35); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }

button { font-family: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection { background: rgba(212, 174, 106, 0.3); color: var(--text-strong); }

/* ===== Shell ===== */
.shell { height: 100vh; display: flex; flex-direction: column; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand-mark {
  font-family: var(--serif-display);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -0.5px;
  font-style: italic;
  color: var(--text-strong);
}
.brand-sub { color: var(--text-mute); font-style: italic; font-size: 13.5px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.cost-badge {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 5px 10px;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
}
.ghost {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--text-mute);
  padding: 6px 13px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--serif);
  transition: color 0.15s, border-color 0.15s;
}
.ghost:hover { color: var(--text); border-color: var(--text-mute); }

/* Main grid */
.main {
  flex: 1;
  display: grid;
  grid-template-columns: var(--col-rail) 1fr var(--col-params);
  min-height: 0;
}

/* Rail */
.rail {
  border-right: 1px solid var(--rule);
  background: var(--bg);
  overflow-y: auto;
  padding: 16px 0;
}
.rail ul { list-style: none; margin: 0; padding: 0; }
.rail li {
  padding: 10px 18px;
  border-left: 2px solid transparent;
  color: var(--text-mute);
  cursor: pointer;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--serif);
}
.rail li:hover { color: var(--text); background: var(--rule-soft); }
.rail li.active { color: var(--text-strong); border-left-color: var(--accent); background: var(--rule-soft); }

/* Chat column */
.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 44px 56px 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  scroll-behavior: smooth;
}
.messages > article {
  max-width: var(--col-chat);
  width: 100%;
  margin: 0 auto;
}

/* ===== Hero (empty state) ===== */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 44px;
  align-items: center;
  padding: 16px 0 12px;
  margin-top: 4px;
}
.hero-figure {
  position: relative;
  margin: 0;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
}
.hero-figure img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.6s ease;
}
.hero:hover .hero-figure img { transform: scale(1.02); }
.hero-figure-gradient {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 60% at 20% 30%, rgba(20,19,15,0.5) 0%, transparent 60%),
    linear-gradient(180deg, transparent 65%, rgba(20,19,15,0.5) 100%);
  pointer-events: none;
}
.hero-text { display: flex; flex-direction: column; gap: 20px; }
.hero-title {
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: clamp(28px, 3.4vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.5px;
  margin: 0;
  color: var(--text-strong);
}
.hero-title em {
  font-style: italic;
  color: var(--accent);
  font-family: var(--serif-display);
  font-weight: 400;
}
.hero-lead {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text-mute);
  margin: 0;
  max-width: 58ch;
}
.hero-points {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--rule);
  padding-top: 20px;
}
.hero-points li {
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text-mute);
  padding-left: 18px;
  position: relative;
}
.hero-points li::before {
  content: "·";
  position: absolute;
  left: 0;
  top: -2px;
  color: var(--accent);
  font-size: 26px;
  line-height: 1;
}
.hero-points strong {
  color: var(--text);
  font-weight: 600;
  font-family: var(--serif);
  letter-spacing: 0.1px;
}
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.hero-cta-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--text-mute);
  margin-right: 4px;
}
.chip {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.6px;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  transition: all 0.15s;
}
.chip:hover {
  background: var(--bg-hover);
  border-color: var(--accent-soft);
  color: var(--accent);
}
.chip:active { transform: translateY(1px); }
.hero-fine {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--text-faint);
  margin: 8px 0 0;
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .hero-figure { aspect-ratio: 16 / 9; max-height: 280px; }
}

/* ===== Chat messages ===== */
.msg-user {
  align-self: flex-end;
  max-width: 80%;
  font-family: var(--mono);
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-strong);
  white-space: pre-wrap;
  letter-spacing: 0.2px;
}
.msg-asst {
  border-top: 1px solid var(--rule-soft);
  padding-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.msg-asst.streaming .msg-body:last-child::after,
.msg-asst.streaming > .msg-body:last-of-type::after {
  content: "▍";
  color: var(--accent);
  animation: blink 1.1s steps(1) infinite;
  display: inline-block;
  margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* === Stage progress lines === */
.stage {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14.5px;
  color: var(--text-mute);
  padding: 4px 0 4px 18px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}
.stage .stage-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
  box-shadow: 0 0 0 0 rgba(212,174,106,0.4);
  animation: pulse 1.6s ease-out infinite;
}
.stage.done .stage-dot { background: var(--accent-2); animation: none; }
.stage.error { color: var(--accent-3); }
.stage.error .stage-dot { background: var(--accent-3); animation: none; }
.stage.warning { color: var(--accent); }
.stage.warning .stage-dot { background: var(--accent); animation: none; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(212,174,106,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(212,174,106,0); }
  100% { box-shadow: 0 0 0 0 rgba(212,174,106,0); }
}

/* === Tool calls === */
.tool {
  font-family: var(--mono);
  font-size: 12.5px;
  background: rgba(34, 31, 24, 0.5);
  border-left: 2px solid var(--rule);
  padding: 7px 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: var(--text-mute);
  letter-spacing: 0.1px;
}
.tool.done { border-left-color: var(--accent-soft); }
.tool .arrow { color: var(--accent); margin-right: 6px; font-weight: 600; }
.tool-name { color: var(--text); font-weight: 500; }
.tool-args { color: var(--text-mute); opacity: 0.85; }
.tool-result {
  color: var(--text-faint);
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12px;
  padding-top: 2px;
  border-top: 1px dashed rgba(46,42,36,0.6);
  margin-top: 4px;
}
.tool-result .arrow { color: var(--accent-2); }
.tool-spin { color: var(--text-faint); font-style: italic; }
.tool-spin::after {
  content: "…";
  animation: blink 1.1s steps(1) infinite;
}

/* === Reasoning (thinking) block === */
.reasoning {
  border-left: 2px solid var(--text-faint);
  padding: 4px 0 4px 14px;
  margin: 4px 0;
  background: transparent;
}
.reasoning summary {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13.5px;
  color: var(--text-mute);
  cursor: pointer;
  letter-spacing: 0.3px;
  list-style: none;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.reasoning-preview {
  color: var(--text-faint);
  font-size: 12.5px;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 540px;
}
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary::before {
  content: "▸ ";
  color: var(--text-faint);
  display: inline-block;
  transition: transform 0.15s;
}
.reasoning[open] summary::before { content: "▾ "; }
.reasoning-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--text-faint);
  line-height: 1.6;
  margin: 8px 0 4px;
  white-space: pre-wrap;
}

/* === Per-message meter row: timer + token counts + status === */
.meter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--rule);
  margin-bottom: 2px;
}
.meter-chip {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-mute);
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px 10px;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
}
.meter-time { color: var(--accent); border-color: var(--accent-soft); }
.meter-tok  { color: var(--text); }
.meter-sub  { color: var(--text-faint); font-size: 10.5px; margin-left: 4px; }
.meter-cost { color: var(--text); }
.meter-running { color: var(--accent); border-color: var(--accent-soft); }
.meter-running::before {
  content: ""; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-right: 5px;
  vertical-align: middle;
  animation: pulse 1.6s ease-out infinite;
}
.meter-done { color: var(--accent-2); border-color: var(--accent-2); opacity: 0.8; }

/* === Message footer: cost + continue button === */
.msg-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px dashed var(--rule);
  padding-top: 12px;
  margin-top: 8px;
}
.cost-pill {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px 10px;
  letter-spacing: 0.3px;
}
.continue-btn {
  font-family: var(--serif);
  font-size: 13.5px;
  color: var(--text-strong);
  background: var(--bg-elev);
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius);
  padding: 6px 14px;
  letter-spacing: 0.1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.continue-btn:hover {
  background: var(--accent);
  color: #0E0D0A;
  border-color: var(--accent);
}
.continue-arrow {
  font-size: 14px;
  display: inline-block;
  transition: transform 0.4s ease;
}
.continue-btn:hover .continue-arrow {
  transform: rotate(180deg);
}

.pdf-btn {
  font-family: var(--serif);
  font-size: 13.5px;
  color: var(--text-mute);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 6px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.1px;
  transition: all 0.15s;
}
.pdf-btn:hover {
  color: var(--text-strong);
  border-color: var(--accent-soft);
  background: var(--bg-elev);
}
.pdf-icon { font-size: 13px; }

/* === Markdown body (the actual report) === */
.msg-body {
  font-family: var(--serif);
  font-size: 18.5px;
  line-height: 1.72;
  color: var(--text);
  font-weight: 450;
}
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4 {
  font-family: var(--serif-display);
  font-weight: 400;
  color: var(--text-strong);
  margin: 36px 0 14px;
  letter-spacing: -0.3px;
  line-height: 1.2;
}
.msg-body h1 { font-size: 34px; }
.msg-body h2 { font-size: 26px; margin-top: 40px; }
.msg-body h3 { font-size: 20px; font-family: var(--serif); font-weight: 600; letter-spacing: -0.1px; }
.msg-body h4 { font-size: 17px; color: var(--accent); font-family: var(--serif); font-weight: 600; }
.msg-body p { margin: 0 0 18px; }
.msg-body p:has(+ ul), .msg-body p:has(+ ol) { margin-bottom: 10px; }
.msg-body strong { color: var(--text-strong); font-weight: 600; }
.msg-body em { color: var(--text-mute); font-style: italic; }
.msg-body ul, .msg-body ol { padding-left: 26px; margin: 6px 0 18px; }
.msg-body li { margin: 6px 0; }
.msg-body code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg-elev);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--accent);
}
.msg-body pre {
  background: linear-gradient(180deg, #1A1812 0%, #221F18 100%);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent-soft);
  border-radius: 6px;
  padding: 18px 22px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.72;
  margin: 20px 0 24px;
  position: relative;
}
.msg-body pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-family: var(--mono);
  font-feature-settings: "kern", "calt";
  font-variant-numeric: tabular-nums;
}
.msg-body pre.lang-yaml::before {
  content: "yaml";
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: 0.6px;
  text-transform: lowercase;
}

/* YAML syntax coloring — applied by colorizeCodeBlocks() in app.js */
.y-k { color: var(--accent); font-weight: 500; }     /* keys: amber */
.y-c { color: var(--text-faint); }                    /* colon separator */
.y-v { color: var(--text-strong); font-weight: 450; }/* values: bright text */
.y-d { color: var(--accent-soft); }                   /* list dashes */

/* Verdict coloring — BUY (green), SELL (red), HOLD (amber). Wins over .y-v. */
.verdict-buy {
  color: var(--accent-2) !important;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 0 2px;
}
.verdict-sell {
  color: var(--accent-3) !important;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 0 2px;
}
.verdict-hold {
  color: var(--accent) !important;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 0 2px;
}
.msg-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 18px;
  color: var(--text-mute);
  font-style: italic;
  margin: 20px 0;
}
.msg-body hr { border: 0; border-top: 1px solid var(--rule); margin: 32px 0; }

.msg-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0 26px;
  font-size: 14.5px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.msg-body th, .msg-body td {
  text-align: left;
  padding: 10px 13px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.msg-body th {
  color: var(--accent);
  font-weight: 600;
  border-bottom: 1px solid var(--accent);
  letter-spacing: 0.5px;
  font-size: 11.5px;
  text-transform: uppercase;
  font-family: var(--serif);
}
.msg-body td:not(:first-child) { color: var(--text); }
.msg-body tr:hover td { background: var(--rule-soft); }

/* === Composer === */
.composer {
  border-top: 1px solid var(--rule);
  background: var(--bg);
  padding: 18px 56px 4px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-family: var(--serif);
  font-size: 16.5px;
  padding: 14px 16px;
  resize: none;
  min-height: 48px;
  max-height: 220px;
  line-height: 1.55;
  transition: border-color 0.15s;
}
.composer textarea:focus { border-color: var(--accent-soft); }
.composer textarea::placeholder { color: var(--text-faint); font-style: italic; }
#send {
  background: var(--accent);
  color: #0E0D0A;
  border: none;
  border-radius: var(--radius);
  padding: 14px 22px;
  font-weight: 600;
  font-size: 14.5px;
  font-family: var(--serif);
  letter-spacing: 0.2px;
  transition: background 0.15s;
}
#send:hover { background: #E2BC76; }
#send:disabled { opacity: 0.4; cursor: wait; }
.hint {
  padding: 8px 56px 18px;
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
  font-family: var(--serif);
}

/* === Params panel === */
.params {
  border-left: 1px solid var(--rule);
  background: var(--bg-panel);
  padding: 22px 20px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-mute);
}
.params-header {
  font-family: var(--serif);
  font-size: 11.5px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
}
.params-note { font-family: var(--serif); font-size: 11px; font-style: italic; color: var(--text-faint); text-transform: none; letter-spacing: 0; font-weight: 400; }
.yaml {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  color: var(--text-mute);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

/* === Password modal === */
.pw-modal {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 50;
  animation: fade-in 0.18s ease-out;
}
.pw-backdrop {
  position: absolute; inset: 0;
  background: rgba(10, 9, 7, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}
.pw-card {
  position: relative;
  width: min(440px, 92vw);
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 34px 30px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.6);
  animation: rise 0.22s cubic-bezier(.2,.8,.2,1);
}
.pw-title {
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: 28px;
  margin: 0 0 6px;
  color: var(--text-strong);
  letter-spacing: -0.4px;
}
.pw-sub {
  color: var(--text-mute);
  font-style: italic;
  font-size: 15px;
  margin: 0 0 22px;
  line-height: 1.55;
  font-family: var(--serif);
}
#pw-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 13px 15px;
  letter-spacing: 0.5px;
  transition: border-color 0.15s;
}
#pw-input:focus { border-color: var(--accent); outline: none; }
.pw-error {
  color: var(--accent-3);
  font-size: 13px;
  min-height: 1.2em;
  margin: 8px 0 0;
  font-family: var(--serif);
  font-style: italic;
}
.pw-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
#pw-submit {
  background: var(--accent);
  color: #0E0D0A;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s;
}
#pw-submit:hover { background: #E2BC76; }
#pw-submit:disabled { opacity: 0.5; cursor: wait; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Print stylesheet for PDF download =====
   When the user clicks "Download PDF", JS marks the target message with .pdf-target
   and adds .printing to <body>. We hide everything except the marked message and
   restyle it for white paper.
*/
@media print {
  @page { size: A4; margin: 18mm 16mm 20mm 16mm; }
  body, html { background: #fff !important; color: #111 !important; }
  body * { color: #111 !important; background: transparent !important; box-shadow: none !important; }
  /* Hide chrome */
  .topbar, .rail, .params, .composer, .hint, .pw-modal, .msg-footer, #hero,
  .msg-asst .stage, .msg-asst .tool, .msg-asst .reasoning, .msg-user {
    display: none !important;
  }
  /* Hide every other assistant message */
  .msg-asst:not(.pdf-target) { display: none !important; }
  /* Restyle the chosen message for print */
  .pdf-target {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }
  .pdf-target::before {
    content: "Jeff — equity research note · " attr(data-print-date);
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    font-style: italic;
    font-size: 9.5pt;
    color: #555 !important;
    border-bottom: 1px solid #999;
    padding-bottom: 6pt;
    margin-bottom: 14pt;
  }
  .pdf-target .msg-body {
    font-family: Georgia, "Times New Roman", serif !important;
    font-size: 10.5pt !important;
    line-height: 1.55 !important;
    color: #111 !important;
  }
  .pdf-target .msg-body h1, .pdf-target .msg-body h2,
  .pdf-target .msg-body h3, .pdf-target .msg-body h4 {
    font-family: Georgia, "Times New Roman", serif !important;
    color: #000 !important;
    page-break-after: avoid;
    margin: 14pt 0 6pt;
  }
  .pdf-target .msg-body h1 { font-size: 18pt !important; }
  .pdf-target .msg-body h2 { font-size: 13pt !important; border-bottom: 1px solid #aaa; padding-bottom: 2pt; }
  .pdf-target .msg-body h3 { font-size: 11pt !important; }
  .pdf-target .msg-body p, .pdf-target .msg-body li { color: #222 !important; }
  .pdf-target .msg-body strong { color: #000 !important; font-weight: 700; }
  .pdf-target .msg-body table {
    width: 100% !important;
    font-family: "SF Mono", Menlo, Consolas, monospace !important;
    font-size: 9pt !important;
    page-break-inside: avoid;
    margin: 8pt 0 12pt;
    border-top: 1px solid #333 !important;
  }
  .pdf-target .msg-body th {
    color: #000 !important;
    border-bottom: 1.5px solid #333 !important;
    text-transform: uppercase;
    font-size: 8pt !important;
    letter-spacing: 0.6px;
    text-align: left;
    padding: 4pt 8pt !important;
  }
  .pdf-target .msg-body td {
    border-bottom: 0.5px solid #ccc !important;
    padding: 3pt 8pt !important;
    vertical-align: top;
  }
  .pdf-target .msg-body pre {
    background: #f7f4ec !important;
    border: 1px solid #ccc !important;
    border-left: 2px solid #888 !important;
    padding: 8pt 12pt !important;
    font-size: 8.5pt !important;
    page-break-inside: avoid;
    margin: 8pt 0 !important;
  }
  .pdf-target .msg-body pre code,
  .pdf-target .msg-body code,
  .pdf-target .y-k, .pdf-target .y-c, .pdf-target .y-v, .pdf-target .y-d {
    color: #111 !important;
    background: transparent !important;
    font-family: "SF Mono", Menlo, Consolas, monospace !important;
  }
  .pdf-target .y-k { font-weight: 700; }
  /* Keep verdict colors visible in PDF — print-safe palette */
  .pdf-target .verdict-buy  { color: #1a7f3f !important; font-weight: 800 !important; }
  .pdf-target .verdict-sell { color: #c0392b !important; font-weight: 800 !important; }
  .pdf-target .verdict-hold { color: #b07a1e !important; font-weight: 800 !important; }
  .pdf-target .msg-body blockquote {
    border-left: 2px solid #555 !important;
    color: #333 !important;
    font-style: italic;
  }
  .pdf-target .msg-body hr { border-top: 1px solid #ccc !important; }
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .main { grid-template-columns: 1fr var(--col-params); }
  .rail { display: none; }
}
@media (max-width: 720px) {
  body { font-size: 17px; }
  .main { grid-template-columns: 1fr; }
  .params {
    border-left: none;
    border-top: 1px solid var(--rule);
    max-height: 200px;
  }
  .messages, .composer, .hint { padding-left: 22px; padding-right: 22px; }
  .topbar { padding: 14px 18px; }
  .topbar-right .ghost { padding: 5px 9px; font-size: 12px; }
  .brand-sub { display: none; }
  .hero-title { font-size: 28px; }
  .msg-body { font-size: 17px; }
  .msg-body h1 { font-size: 28px; }
  .msg-body h2 { font-size: 22px; }
}
