/* Alie2 dashboard — futuristic, calm, high-contrast.
   Built for Marvin's assistant: large readable type, plain language.

   Palette is intentionally three-tier on both surfaces (bg / card / raised)
   and text (text / text-2 / muted) so the eye has somewhere to rest and
   hover states feel tactile. Accent is used sparingly — the teal carries
   the meaning of "active / interactive". */

:root {
  /* surfaces */
  --bg:          #0a0f1e;
  --bg-2:        #0e1426;
  --surface-0:   #131a30;
  --surface-1:   #1a2240;
  --surface-2:   #232c50;
  /* borders + dividers — translucent so they stack cleanly on gradients */
  --line:        rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  /* text */
  --text:        #f1f4fb;
  --text-2:      #c8d1e6;
  --muted:       #8d97b3;
  /* accent + semantic */
  --accent:      #5eead4;
  --accent-2:    #2dd4bf;
  --accent-soft: rgba(94, 234, 212, 0.14);
  --accent-edge: rgba(94, 234, 212, 0.45);
  --good:        #4ade80;
  --warn:        #fbbf24;
  --bad:         #f87171;
  /* shape + motion */
  --radius:      14px;
  --radius-sm:   10px;
  --radius-pill: 999px;
  --shadow-1:    0 1px 0 rgba(255, 255, 255, 0.04) inset,
                 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-2:    0 1px 0 rgba(255, 255, 255, 0.06) inset,
                 0 18px 50px rgba(0, 0, 0, 0.55);
  --t-fast:      .12s ease;
  --t:           .18s ease;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 700px at 50% -200px, #122242 0%, var(--bg) 60%),
              var(--bg);
  color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-weight: 600; letter-spacing: .01em; color: var(--text); }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); color: var(--text); }

/* Scrollbars — discreet, so they don't compete with content. */
* { scrollbar-width: thin; scrollbar-color: var(--surface-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--line-strong); }

/* ── Sign-in ─────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(900px 500px at 50% -10%, #19264a, var(--bg)); }
.login-card {
  width: 340px; padding: 2.2rem 2rem; background: var(--surface-1);
  border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: .6rem;
  box-shadow: var(--shadow-2);
}
.brand-big { font-size: 1.95rem; font-weight: 700; letter-spacing: .06em; }
.brand-big .logo, .brand .logo { color: var(--accent); }
.login-card label { font-size: .85rem; color: var(--muted); margin-top: .6rem; }
.login-card input, #chat-input {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-sm); padding: .75rem .9rem; font-size: 1rem;
  outline: none; transition: border-color var(--t), box-shadow var(--t);
}
.login-card input:focus, #chat-input:focus {
  border-color: var(--accent-edge);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-card button, .primary {
  margin-top: .9rem;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #052625; border: 0; border-radius: var(--radius-sm);
  padding: .75rem; font-size: 1rem; font-weight: 600;
  transition: transform var(--t-fast), box-shadow var(--t);
  box-shadow: 0 6px 16px rgba(45, 212, 191, 0.25);
}
.login-card button:hover, .primary:hover { transform: translateY(-1px); }
.login-card button:active { transform: translateY(0); }
.error { color: var(--bad); font-size: .9rem; margin: .4rem 0 0; }

/* ── App shell ───────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--line);
  padding: 1.3rem .75rem;
  display: flex; flex-direction: column; gap: .2rem;
}
.brand { font-size: 1.35rem; font-weight: 700; letter-spacing: .06em;
  padding: .2rem .7rem 1.2rem; }
.nav-btn {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  background: transparent; color: var(--text-2); border: 0; text-align: left;
  padding: .7rem .8rem; border-radius: var(--radius-sm); font-size: .98rem;
  border-left: 3px solid transparent;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-btn:hover { background: var(--surface-0); color: var(--text); }
.nav-btn[aria-current="true"] {
  background: var(--surface-1); color: var(--text);
  border-left-color: var(--accent);
  box-shadow: 0 0 0 1px var(--line) inset;
}
.nav-ico { color: var(--accent); width: 1.15rem; text-align: center; }
.nav-spacer { flex: 1; }
.logout { color: var(--muted); font-size: .9rem; }
.logout:hover { color: var(--bad); background: transparent; }

.main { padding: 1.6rem 2.2rem 3rem; overflow: auto; }
.topbar { margin-bottom: 1.4rem; }
.topbar h1 { margin: 0 0 .25rem; font-size: 1.55rem; letter-spacing: -0.01em; }
.topbar .muted { margin: 0; font-size: .95rem; color: var(--text-2); }

/* ── Cards / panels ──────────────────────────────────────────────────── */
.group { margin-bottom: 1.6rem; }
.group-head { display: flex; align-items: baseline; gap: .6rem; margin: 0 0 .6rem; }
.group-head h2 { margin: 0; font-size: 1.1rem; }
.count { color: var(--muted); font-size: .9rem; font-weight: 500; }
.group-hint { color: var(--muted); font-size: .9rem; margin: -.2rem 0 .7rem; }

.list { display: flex; flex-direction: column; gap: .55rem; }
.row {
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .85rem 1.05rem;
  display: flex; align-items: center; gap: .9rem;
  text-align: left; width: 100%; color: var(--text);
  transition: transform var(--t-fast), border-color var(--t),
              background var(--t), box-shadow var(--t);
}
.row:hover {
  border-color: var(--accent-edge);
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
.row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.row .title { flex: 1; font-size: .98rem; color: var(--text); }
.row .meta {
  color: var(--muted); font-size: .82rem; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge {
  font-size: .72rem; padding: .2rem .55rem; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-edge);
  white-space: nowrap; letter-spacing: .02em; font-weight: 500;
}
.badge.perm {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.35);
}

/* hint pill — explains a technical word in plain language */
.hint {
  display: inline-grid; place-items: center; width: 1.1rem; height: 1.1rem;
  border-radius: 50%; border: 1px solid var(--line-strong); color: var(--muted);
  font-size: .72rem; cursor: help;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.hint:hover { color: var(--accent); border-color: var(--accent-edge); }

/* chips (filters / folders) */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chip {
  background: var(--surface-0); border: 1px solid var(--line); color: var(--text-2);
  border-radius: var(--radius-pill); padding: .4rem .85rem; font-size: .85rem;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.chip:hover { background: var(--surface-1); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-edge);
}

/* ── Tabs (KB sources) ───────────────────────────────────────────────── */
/* Segmented chip rail — wraps to next line instead of horizontal-scrolling.
   Discovered dynamically from the API response in app.js. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  padding: .35rem;
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0 0 1.1rem;
  box-shadow: var(--shadow-1);
}
.tab {
  background: transparent;
  color: var(--text-2);
  border: 0;
  padding: .55rem 1rem;
  font-size: .92rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  font-family: inherit;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: .35rem;
  transition: background var(--t-fast), color var(--t-fast);
}
.tab:hover { background: var(--surface-1); color: var(--text); }
.tab[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #052625;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(45, 212, 191, 0.25);
}
.tab .count {
  color: inherit; opacity: .65; font-size: .82rem; font-weight: 500;
  margin: 0;
}
.tab[aria-pressed="true"] .count { opacity: .75; }
.tab-hint { color: var(--muted); font-size: .92rem; margin: 0 0 .9rem; }
.tab-content { animation: tab-fade-in .18s ease; }
@keyframes tab-fade-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* ── KB multi-select / bulk delete ──────────────────────────────────── */
/* Sticky action bar that appears below the tabs when at least one KB row
   is checked. Reads "N items selected" + Cancel + Delete-selected. */
.kb-actions {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .85rem;
  margin: 0 0 .9rem;
  background: var(--surface-1);
  border: 1px solid var(--accent-edge);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
  animation: kb-actions-in .18s ease;
}
@keyframes kb-actions-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.kb-actions-count {
  color: var(--text); font-weight: 600; font-size: .92rem;
}
.kb-actions-spacer { flex: 1; }
.kb-actions-clear, .kb-actions-delete {
  border: 0; border-radius: var(--radius-sm);
  padding: .5rem .95rem; font-size: .9rem; font-weight: 600;
  font-family: inherit;
  transition: transform var(--t-fast), background var(--t-fast),
              filter var(--t-fast);
}
.kb-actions-clear {
  background: var(--surface-2); color: var(--text-2);
}
.kb-actions-clear:hover { background: var(--line-strong); color: var(--text); }
.kb-actions-delete {
  background: linear-gradient(180deg, #fb7185, #ef4444);
  color: #fff;
  box-shadow: 0 6px 14px rgba(239, 68, 68, 0.30);
}
.kb-actions-delete:hover { transform: translateY(-1px); filter: brightness(1.05); }
.kb-actions-delete:disabled, .kb-actions-clear:disabled {
  opacity: .55; cursor: not-allowed; transform: none;
}

/* "Select all in this tab" header above the list. */
.kb-select-all {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .35rem .6rem; margin: 0 0 .55rem;
  font-size: .87rem; color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
}
.kb-select-all:hover { color: var(--text); background: var(--surface-0); }

/* KB rows are <div>s now (so a checkbox can live inside cleanly) instead
   of <button>s. Match the button-row look + cursor. */
.kb-row { cursor: pointer; }
.kb-row input[type="checkbox"] { flex: 0 0 auto; }

/* Native checkboxes restyled to fit the palette. */
input[type="checkbox"] {
  appearance: none;
  width: 1.05rem; height: 1.05rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface-0);
  cursor: pointer;
  position: relative;
  transition: border-color var(--t-fast), background var(--t-fast);
}
input[type="checkbox"]:hover { border-color: var(--accent-edge); }
input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 4px; height: 9px;
  border-right: 2px solid #052625;
  border-bottom: 2px solid #052625;
  transform: rotate(45deg);
}
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Confirm-delete modal — list of names + paired Cancel / Delete buttons. */
.kb-confirm-list {
  max-height: 240px; overflow: auto;
  margin: .6rem 0 .8rem;
  padding-left: 1.2rem;
  color: var(--text-2);
}
.kb-confirm-list li { padding: .15rem 0; }
.kb-confirm-actions {
  display: flex; justify-content: flex-end; gap: .55rem;
  margin-top: .8rem;
}

.empty, .loading { color: var(--muted); padding: 1.5rem .2rem; }
.loading::before {
  content: ""; display: inline-block;
  width: .85rem; height: .85rem; margin-right: .55rem; vertical-align: -2px;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── GitHub feed ─────────────────────────────────────────────────────── */
.commit-detail {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  border-top: 0; margin-top: -.5rem;
  padding: .95rem 1.05rem; font-size: .9rem;
}
.commit-detail pre { white-space: pre-wrap; color: var(--text); margin: 0 0 .6rem; }
.file { display: flex; gap: .6rem; font-size: .85rem; color: var(--muted); }
.file .add { color: var(--good); } .file .del { color: var(--bad); }

/* ── Chat ────────────────────────────────────────────────────────────── */
/* ── Chat page: roster (top, collapsible) + chat | live activity ───────── */
.chat-page { display: flex; flex-direction: column; gap: .8rem; height: calc(100vh - 8rem); }

.chat-roster { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem .85rem .2rem; flex: 0 0 auto; }
.chat-roster > .chat-roster-sum { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .55rem; padding: .35rem .1rem; font-weight: 600; color: var(--text); }
.chat-roster > .chat-roster-sum::-webkit-details-marker { display: none; }
.chat-roster-sum::before { content: "▸"; color: var(--muted); transition: transform var(--t); }
.chat-roster[open] > .chat-roster-sum::before { transform: rotate(90deg); }
.crs-count { color: var(--muted); font-size: .82rem; font-weight: 400; }
.roster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .55rem; padding: .55rem .1rem .35rem; max-height: 38vh; overflow: auto; }

.agent-card { background: linear-gradient(180deg, var(--surface-1, #131a30), var(--surface-0, #0e1426)); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .5rem .65rem; transition: border-color var(--t); }
.agent-card:hover { border-color: var(--accent-edge); }
.agent-card > .ac-sum { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .45rem; }
.agent-card > .ac-sum::-webkit-details-marker { display: none; }
.ac-dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--good); box-shadow: 0 0 7px var(--good); flex: 0 0 auto; }
.ac-name { font-weight: 600; color: var(--text); text-transform: capitalize; }
.ac-id { color: var(--muted); font-size: .74rem; font-family: ui-monospace, monospace; margin-left: auto; }
.ac-body { margin-top: .5rem; display: flex; flex-direction: column; gap: .45rem; }
.ac-desc { margin: 0; color: var(--text-2); font-size: .84rem; line-height: 1.45; }
.ac-skills { display: flex; flex-wrap: wrap; gap: .3rem; }
.ac-chip { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-edge); border-radius: var(--radius-pill); padding: .08rem .5rem; font-size: .71rem; }
.ac-skilllist { display: flex; flex-direction: column; gap: .35rem; border-top: 1px solid var(--line); padding-top: .45rem; }
.ac-skillrow { display: flex; flex-direction: column; gap: .1rem; }
.ac-skillname { font-size: .77rem; font-weight: 600; color: var(--text-2); }
.ac-skilldesc { font-size: .73rem; color: var(--muted); line-height: 1.4; }
.ac-meta { font-size: .74rem; }
.ac-link { color: var(--accent); text-decoration: none; }
.ac-link:hover { text-decoration: underline; }

.chat-main { display: flex; gap: .8rem; flex: 1 1 0; min-height: 0; }
.chat-wrap { display: flex; flex-direction: column; flex: 1 1 0; min-width: 0; }

.chat-activity { flex: 0 0 38%; max-width: 460px; display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.act-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
.act-title { font-weight: 600; font-size: .9rem; }
.act-status { font-size: .76rem; color: var(--accent); white-space: nowrap; }
.act-log { flex: 1 1 0; overflow: auto; padding: .4rem .6rem; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .76rem; line-height: 1.5; }
.act-line { display: grid; grid-template-columns: auto auto 1fr; gap: .5rem; padding: .14rem 0; border-bottom: 1px solid rgba(255,255,255,.035); white-space: pre-wrap; word-break: break-word; }
.act-ts { color: var(--muted); }
.act-who { color: var(--accent-2); font-weight: 600; }
.act-msg { color: var(--text-2); }
.act-warning .act-msg { color: var(--warn); }
.act-error .act-msg, .act-critical .act-msg { color: var(--bad); }
.msg.bot.thinking { color: var(--muted); font-style: italic; }

@media (max-width: 860px) {
  .chat-page { height: auto; }
  .chat-main { flex-direction: column; }
  .chat-activity { flex: 0 0 auto; max-width: none; height: 32vh; }
}
.chat-log {
  flex: 1; overflow: auto;
  display: flex; flex-direction: column; gap: .7rem;
  padding: .8rem .3rem;
}
.msg {
  max-width: 78%; padding: .7rem 1rem; border-radius: 14px;
  font-size: .97rem; line-height: 1.5;
  animation: msg-in .2s ease;
  white-space: pre-wrap; /* preserve line breaks in agent replies */
  word-break: break-word;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.user {
  align-self: flex-end;
  background: linear-gradient(180deg, var(--accent-soft), rgba(94, 234, 212, 0.06));
  color: var(--text);
  border: 1px solid var(--accent-edge);
}
.msg.bot {
  align-self: flex-start;
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  border: 1px solid var(--line);
}
.msg.bot.intermediate {
  /* Intermediate "thinking out loud" emissions are visibly de-emphasized
     so the eye lands on the final answer first. */
  background: var(--surface-0);
  border-style: dashed;
  opacity: .85;
  font-size: .92rem;
}
.msg.note {
  align-self: center; background: transparent; color: var(--text-2);
  font-size: .92rem; text-align: center; opacity: .9;
  max-width: 90%; padding: .5rem 1rem;
}

/* Speaker-labelled bot bubble — small "Vera ✦" header sits above the
   message body so every reply is unambiguously attributed. */
.msg-row { display: flex; flex-direction: column; gap: .25rem; align-items: flex-start; }
.msg-row.bot-row { max-width: 82%; }
.msg-speaker {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: 0 .3rem;
  font-size: .78rem; color: var(--muted);
  font-weight: 500; letter-spacing: .02em;
}
.msg-speaker-glyph { color: var(--accent); font-size: .9rem; }
.msg-speaker-name { color: var(--text-2); }

/* ── Tool-call widget (collapsed by default) ─────────────────────────── */
/* Native <details>/<summary>. Discrete chip when collapsed; expands into
   a card with a Request / Response section. Lives in the same chat flow
   so the user sees the orchestration mid-stream. */
.tool-call {
  align-self: flex-start;
  max-width: 82%;
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  animation: msg-in .2s ease;
}
.tool-call[open] {
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  border-color: var(--line-strong);
  box-shadow: var(--shadow-1);
}
.tool-call-summary {
  display: flex; align-items: center; gap: .4rem;
  padding: .45rem .75rem;
  cursor: pointer;
  list-style: none;
  color: var(--text-2);
  transition: color var(--t-fast), background var(--t-fast);
  border-radius: var(--radius-sm);
}
.tool-call-summary::-webkit-details-marker { display: none; }
.tool-call-summary::before {
  content: "▸"; color: var(--muted); margin-right: .15rem;
  transition: transform var(--t-fast);
  display: inline-block;
}
.tool-call[open] > .tool-call-summary::before { transform: rotate(90deg); }
.tool-call-summary:hover { color: var(--text); background: var(--surface-1); }
.tool-call-icon { color: var(--accent); font-size: .9rem; }
.tool-call-from, .tool-call-to { color: var(--text-2); font-weight: 500; }
.tool-call-arrow { color: var(--muted); margin: 0 .15rem; }
.tool-call-dur {
  margin-left: auto;
  color: var(--muted); font-size: .78rem;
  font-variant-numeric: tabular-nums;
}
.tool-call-body {
  padding: .25rem .85rem .8rem;
  display: flex; flex-direction: column; gap: .4rem;
  border-top: 1px solid var(--line);
  animation: msg-in .15s ease;
}
.tool-call-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 600;
  margin-top: .35rem;
}
.tool-call-label.muted { text-transform: none; letter-spacing: 0; font-weight: 400; font-style: italic; }
.tool-call-message {
  white-space: pre-wrap; word-break: break-word;
  color: var(--text);
  font-size: .92rem; line-height: 1.5;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: .55rem .75rem;
}
.tool-call-json {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .82rem;
  color: var(--text-2);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: .55rem .75rem;
  margin: 0;
  overflow-x: auto;
  white-space: pre;
}

/* Sub-agent handoff (cassandra/ada). Slimmer than a tool call —
   pure annotation, no expand. */
.agent-transfer {
  align-self: center;
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .25rem .7rem;
  color: var(--muted);
  font-size: .82rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-pill);
  background: transparent;
}

/* ── Markdown bubble ─────────────────────────────────────────────────── */
/* When the agent's reply is rendered through marked + DOMPurify the
   bubble drops `white-space: pre-wrap` (HTML structure now carries the
   line breaks) and styles the rendered tags for the chat palette. */
.msg.bot.markdown {
  white-space: normal;
}
.msg.bot.markdown > :first-child { margin-top: 0; }
.msg.bot.markdown > :last-child { margin-bottom: 0; }
.msg.bot.markdown p { margin: .35rem 0; }
.msg.bot.markdown h1, .msg.bot.markdown h2, .msg.bot.markdown h3,
.msg.bot.markdown h4 { margin: .9rem 0 .4rem; font-weight: 600; }
.msg.bot.markdown h1 { font-size: 1.15rem; }
.msg.bot.markdown h2 { font-size: 1.05rem; }
.msg.bot.markdown h3 { font-size: 1rem; color: var(--text-2); }
.msg.bot.markdown ul, .msg.bot.markdown ol {
  margin: .35rem 0; padding-left: 1.4rem;
}
.msg.bot.markdown li { margin: .15rem 0; }
.msg.bot.markdown a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-edge); }
.msg.bot.markdown a:hover { text-decoration-color: var(--accent); }
.msg.bot.markdown blockquote {
  margin: .55rem 0; padding: .1rem .85rem;
  border-left: 3px solid var(--accent-edge);
  color: var(--text-2); background: var(--surface-0);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.msg.bot.markdown code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .88em;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .05rem .35rem;
}
.msg.bot.markdown pre {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .65rem .85rem;
  overflow-x: auto;
  margin: .55rem 0;
}
.msg.bot.markdown pre code {
  background: transparent; border: 0; padding: 0;
  font-size: .85rem; line-height: 1.5;
  color: var(--text);
}
.msg.bot.markdown table {
  border-collapse: collapse; width: 100%;
  margin: .55rem 0;
  font-size: .9rem;
}
.msg.bot.markdown th, .msg.bot.markdown td {
  text-align: left;
  padding: .4rem .65rem;
  border-bottom: 1px solid var(--line);
}
.msg.bot.markdown th {
  background: var(--surface-0);
  color: var(--text-2);
  font-weight: 600;
  font-size: .82rem; text-transform: uppercase; letter-spacing: .04em;
}
.msg.bot.markdown tr:last-child td { border-bottom: 0; }
.msg.bot.markdown hr {
  border: 0; height: 1px;
  background: var(--line-strong);
  margin: .85rem 0;
}

/* ── Artifacts ──────────────────────────────────────────────────────── */
/* Structured renderings of known tool-call result shapes — currently:
   backtest result (metrics + pass/fail + provenance), hypotheses list
   table, OOS-unlock receipt. Lives inside the tool-call body, replacing
   the raw-JSON dump for shapes we know how to surface meaningfully. */
.artifact {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .65rem .85rem;
  display: flex; flex-direction: column; gap: .55rem;
}
.artifact-head {
  display: flex; align-items: center; gap: .5rem;
  font-size: .92rem;
}
.artifact-glyph { font-size: 1rem; }
.artifact-title { font-weight: 600; color: var(--text); flex: 1; }
.artifact-verdict {
  font-size: .72rem; padding: .2rem .55rem; border-radius: var(--radius-pill);
  font-weight: 600; letter-spacing: .03em;
  border: 1px solid;
  text-transform: uppercase;
}
.artifact-verdict.pass {
  background: rgba(74, 222, 128, 0.10);
  color: var(--good);
  border-color: rgba(74, 222, 128, 0.45);
}
.artifact-verdict.fail {
  background: rgba(248, 113, 113, 0.10);
  color: var(--bad);
  border-color: rgba(248, 113, 113, 0.45);
}

/* Metrics grid — backtest result */
.artifact-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .35rem .5rem;
}
.artifact-metric {
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: .4rem .55rem;
  display: flex; flex-direction: column; gap: .1rem;
}
.artifact-metric-label {
  font-size: .72rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.artifact-metric-value {
  font-size: 1.02rem; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums;
}

.artifact-provenance {
  display: flex; flex-wrap: wrap; gap: .35rem .55rem;
  align-items: center;
  font-size: .78rem; color: var(--muted);
  padding-top: .35rem;
  border-top: 1px dashed var(--line);
}
.artifact-prov-label {
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  font-size: .7rem;
}
.artifact-provenance code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .05rem .35rem;
  color: var(--text-2);
  font-size: .76rem;
}

/* Table — hypothesis list */
.artifact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.artifact-table th {
  text-align: left; padding: .4rem .6rem;
  background: var(--surface-0); color: var(--text-2);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--line);
}
.artifact-table td {
  padding: .4rem .6rem;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.artifact-table tr:last-child td { border-bottom: 0; }
.artifact-status {
  font-size: .78rem;
  color: var(--accent);
  font-weight: 500;
  text-transform: lowercase;
}

.artifact-empty {
  color: var(--muted); font-style: italic; text-align: center;
  padding: .6rem 0;
}
.artifact-body { display: flex; flex-direction: column; gap: .25rem; }
.artifact-body .muted { color: var(--muted); font-size: .82rem; }

/* ── Strategies Factory kanban ────────────────────────────────────────
   Nine-column board grouped by strategy_lifecycle.current_stage. On
   narrow viewports the board scrolls horizontally — column widths are
   fixed so the user can swipe rather than wrap an unreadable grid. */
.strategy-board {
  display: grid;
  grid-template-columns: repeat(9, minmax(200px, 1fr));
  gap: .55rem;
  overflow-x: auto;
  padding-bottom: .35rem;
  -webkit-overflow-scrolling: touch;
}
.strategy-col {
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .55rem;
  display: flex; flex-direction: column; gap: .45rem;
  min-height: 220px;
}
.strategy-col-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .78rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
  padding-bottom: .2rem; border-bottom: 1px solid var(--line);
}
.strategy-col-count {
  color: var(--text-2);
  background: var(--surface-1);
  border-radius: 999px;
  padding: 0 .45rem;
  font-size: .72rem;
}
.strategy-col-empty {
  color: var(--muted); font-size: .82rem; text-align: center;
  padding: .8rem 0; opacity: .6;
}

.strategy-card {
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .55rem .65rem;
  text-align: left;
  width: 100%;
  display: flex; flex-direction: column; gap: .3rem;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--t), transform var(--t-fast), box-shadow var(--t);
}
.strategy-card:hover {
  border-color: var(--accent-edge);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
.strategy-card-head {
  display: flex; align-items: center; gap: .35rem;
  font-weight: 600; font-size: .92rem;
}
.strategy-card-name { flex: 1; }
.strategy-pill {
  font-size: .65rem; padding: .12rem .45rem; border-radius: 999px;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid;
}
.strategy-pill.pass {
  background: rgba(74, 222, 128, 0.12);
  color: var(--good);
  border-color: rgba(74, 222, 128, 0.45);
}
.strategy-pill.fail {
  background: rgba(248, 113, 113, 0.12);
  color: var(--bad);
  border-color: rgba(248, 113, 113, 0.45);
}
.strategy-card-excerpt {
  color: var(--muted); font-size: .82rem; line-height: 1.4;
}
.strategy-card-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .2rem;
  margin-top: .2rem;
}
.strategy-mini-metric {
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .25rem .35rem;
}
.strategy-mini-label {
  font-size: .62rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.strategy-mini-value {
  font-size: .82rem; color: var(--text);
  font-variant-numeric: tabular-nums; font-weight: 500;
}
.strategy-card-repo {
  font-size: .72rem; color: var(--text-2);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  display: flex; align-items: center; gap: .25rem;
}
.strategy-card-when {
  font-size: .7rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Per-strategy detail modal */
.strategy-detail { display: flex; flex-direction: column; gap: .85rem; }
.strategy-detail-head {
  display: flex; align-items: center; gap: .65rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--line);
}
.strategy-detail-name { font-weight: 600; flex: 1; }
.strategy-detail-stage {
  font-size: .78rem; padding: .25rem .65rem;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-edge);
  border-radius: 999px;
  text-transform: lowercase;
}
.strategy-detail-repo {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .82rem;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .2rem .5rem;
}
.strategy-detail-repo:hover { background: var(--surface-1); }
.strategy-detail-idea {
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .65rem .85rem;
  color: var(--text-2);
  font-size: .92rem;
}

.strategy-timeline h3,
.strategy-runs h3 {
  font-size: .92rem; color: var(--text-2);
  margin: 0 0 .35rem;
  text-transform: uppercase; letter-spacing: .06em;
  font-weight: 600;
}
.strategy-timeline-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: .35rem;
}
.strategy-timeline-list li {
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: .35rem .55rem;
  font-size: .85rem;
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-rows: auto auto;
  gap: .2rem .55rem;
}
.strategy-timeline-stage {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--text);
  font-size: .82rem;
}
.strategy-timeline-actor {
  font-size: .72rem; color: var(--accent);
  text-transform: lowercase;
}
.strategy-timeline-when {
  font-size: .72rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.strategy-timeline-note {
  grid-column: 1 / -1;
  color: var(--text-2); font-size: .82rem;
  font-style: italic;
}

.strategy-run {
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: .35rem;
}
.strategy-run > summary {
  display: flex; align-items: center; gap: .55rem;
  padding: .45rem .65rem;
  cursor: pointer; font-size: .85rem;
}
.strategy-run-kind {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--text-2);
  flex: 1;
}
.strategy-run-when {
  font-size: .72rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.strategy-archived { margin-top: 1rem; }
.strategy-archived > summary {
  cursor: pointer; color: var(--muted); font-size: .9rem;
  padding: .5rem 0;
}
.strategy-archived-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .55rem; margin-top: .5rem;
}
.chat-form { display: flex; gap: .6rem; margin-top: .8rem; }
.chat-form input { flex: 1; }
.chat-form button {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #052625; border: 0;
  border-radius: var(--radius-sm); padding: 0 1.4rem; font-weight: 600;
  box-shadow: 0 6px 16px rgba(45, 212, 191, 0.25);
  transition: transform var(--t-fast);
}
.chat-form button:hover { transform: translateY(-1px); }

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0;
  background: rgba(4, 6, 12, 0.78);
  backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 2rem; z-index: 50;
  animation: modal-in .15s ease;
}
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: min(760px, 100%);
  max-height: 84vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-2);
}
.modal-head { display: flex; align-items: center; gap: 1rem;
  padding: 1.05rem 1.2rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.1rem; flex: 1; }
.modal-body { padding: 1.15rem 1.2rem; overflow: auto; }
.modal-body pre { white-space: pre-wrap; word-break: break-word;
  font-family: var(--font); font-size: .95rem; margin: 0; color: var(--text-2); }
.icon-btn { background: transparent; border: 0; color: var(--muted);
  font-size: 1rem; padding: .35rem .55rem; border-radius: 7px;
  transition: color var(--t-fast), background var(--t-fast); }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

/* ── Responsive — sidebar collapses to a top rail on small screens ──── */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; flex-wrap: wrap;
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: .8rem .6rem;
  }
  .brand { padding: .2rem .6rem; }
  .nav-btn {
    width: auto; flex: 1 1 auto; min-width: 0;
    padding: .55rem .7rem; font-size: .9rem;
    border-left: 0; border-bottom: 3px solid transparent;
  }
  .nav-btn[aria-current="true"] {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }
  .nav-spacer { display: none; }
  .logout { flex: 0 0 auto; }
  .main { padding: 1.2rem 1.2rem 2.5rem; }
}

/* ── Backtest Runs panel ──────────────────────────────────────────────
   Wide sortable table with frozen "Hypothesis" left column + a compare
   modal that transposes selected runs into a metric-by-metric grid.
   Built for at-a-glance scanning: tabular-nums everywhere, numeric
   columns right-aligned, the active sort header glows accent, the
   best / worst cell in compare mode is colour-coded. */
.runs-bar {
  display: flex; gap: .55rem; align-items: center; flex-wrap: wrap;
  margin-bottom: .6rem;
}
.runs-search {
  flex: 1; min-width: 220px;
  background: var(--surface-0); color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .55rem .75rem; font-size: .92rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.runs-search::placeholder { color: var(--muted); }
.runs-search:focus {
  outline: none; border-color: var(--accent-edge);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.runs-kind, .runs-pass {
  background: var(--surface-0); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .55rem .65rem; font-size: .9rem;
}
.runs-cols, .runs-compare-btn {
  background: var(--surface-1); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .55rem .9rem; font-size: .9rem;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.runs-cols:hover, .runs-compare-btn:not(:disabled):hover {
  background: var(--surface-2); border-color: var(--accent-edge);
}
.runs-compare-btn:not(:disabled) {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #052625; border-color: transparent; font-weight: 600;
  box-shadow: 0 6px 16px rgba(45, 212, 191, 0.2);
}
.runs-compare-btn:disabled { opacity: .5; cursor: not-allowed; }
.runs-count {
  font-size: .82rem; margin-bottom: .45rem;
  font-variant-numeric: tabular-nums;
}

.runs-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: calc(100vh - 220px);
  background: var(--surface-0);
}
.runs-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: .85rem; font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
.runs-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-1);
  border-bottom: 1px solid var(--line-strong);
  text-align: left; padding: 0;
  white-space: nowrap;
  font-weight: 500; color: var(--text);
}
.runs-table thead th.sticky,
.runs-table tbody td.sticky {
  position: sticky; left: 0; z-index: 3;
  background: var(--surface-1);
}
.runs-table thead th.sticky { z-index: 4; }
.runs-table tbody td.sticky { background: var(--surface-0); }
.runs-table tbody tr.selected td.sticky { background: var(--accent-soft); }
.runs-table .runs-chk-h,
.runs-table .runs-chk {
  position: sticky; left: 0; z-index: 3;
  background: var(--surface-1);
  width: 36px; padding: .3rem .4rem; text-align: center;
}
.runs-table tbody td.runs-chk { background: var(--surface-0); z-index: 1; }
.runs-table tbody tr.selected td.runs-chk { background: var(--accent-soft); }
.runs-sort-btn {
  background: transparent; color: inherit; border: 0;
  padding: .55rem .65rem; font: inherit;
  cursor: pointer; width: 100%; text-align: left;
  transition: color var(--t-fast);
}
.runs-sort-btn:hover { color: var(--accent); }
.runs-sort-arrow { color: var(--accent); margin-left: .25rem; }

.runs-table tbody tr {
  transition: background var(--t-fast);
}
.runs-table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.runs-table tbody tr.selected { background: var(--accent-soft); }
.runs-cell {
  padding: .4rem .65rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.runs-cell.num { text-align: right; }
.runs-cell code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .8rem; color: var(--text);
  background: var(--surface-1);
  padding: .1rem .35rem; border-radius: 4px;
}

.runs-pill {
  display: inline-block;
  padding: .12rem .55rem;
  border-radius: var(--radius-pill);
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
}
.runs-pill.pass { background: rgba(74, 222, 128, 0.18); color: var(--good); }
.runs-pill.fail { background: rgba(248, 113, 113, 0.18); color: var(--bad); }
.runs-pill.kind {
  background: var(--surface-2); color: var(--text-2);
  text-transform: lowercase; letter-spacing: 0;
}

/* ── Column picker (rendered into the modal) ─────────────────────── */
.runs-cols-menu p { margin: 0 0 .8rem; }
.runs-cols-grid {
  display: grid; gap: .4rem .8rem;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  margin-bottom: 1rem;
}
.runs-col-toggle {
  display: flex; align-items: center; gap: .4rem;
  font-size: .88rem; color: var(--text-2);
  padding: .35rem .55rem;
  background: var(--surface-0); border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.runs-col-toggle:hover { border-color: var(--accent-edge); color: var(--text); }
.runs-cols-presets { display: flex; gap: .55rem; }
.runs-cols-presets button {
  background: var(--surface-1); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .5rem .9rem; font-size: .9rem;
}
.runs-cols-presets button:hover { border-color: var(--accent-edge); }

/* ── Compare modal table ────────────────────────────────────────── */
.runs-compare-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: .88rem; font-variant-numeric: tabular-nums;
}
.runs-compare-table th,
.runs-compare-table td {
  text-align: left; padding: .42rem .7rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.runs-compare-table thead th {
  background: var(--surface-1); color: var(--text);
  position: sticky; top: 0;
  font-weight: 500;
}
.runs-compare-name { font-weight: 600; }
.runs-compare-when {
  font-size: .72rem; font-weight: 400;
}
.runs-compare-metric {
  color: var(--text-2); font-weight: 500;
  background: var(--surface-0);
  position: sticky; left: 0;
}
.runs-compare-table td.num { text-align: right; }
.runs-compare-table td.best {
  color: var(--good); font-weight: 600;
  background: rgba(74, 222, 128, 0.08);
}
.runs-compare-table td.worst {
  color: var(--bad);
  background: rgba(248, 113, 113, 0.08);
}
/* The compare modal is wider than the standard modal because it has
   up to 5 columns of side-by-side metric data. */
.modal-card:has(.runs-compare) { width: min(1080px, 100%); }

/* ── Pythia panel — 1h candle high/low predictions ────────────────────
   Scoped to #panel-pythia. Reuses the dashboard's existing palette,
   chip/tab idiom, and gradient cards so the panel blends in with the
   rest of the dashboard. */
.nav-btn .nav-sub {
  font-size: .72rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: .04em;
  margin-left: .35rem;
}
.nav-btn[aria-current="true"] .nav-sub { color: var(--accent); }

#panel-pythia .py-watchlist {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  padding: .4rem;
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  margin: 0 0 1.2rem;
}
#panel-pythia .py-watchlist-label {
  color: var(--muted); font-size: .82rem;
  padding: 0 .55rem 0 .65rem; letter-spacing: .02em;
}
#panel-pythia .py-chips { display: contents; }
#panel-pythia .py-sym-chip {
  background: transparent; color: var(--text-2);
  border: 0; padding: .5rem .85rem .5rem .75rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .9rem; font-weight: 600; letter-spacing: .04em;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; gap: .4rem;
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer;
}
#panel-pythia .py-sym-chip:hover { background: var(--surface-1); color: var(--text); }
#panel-pythia .py-sym-chip[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #052625;
  box-shadow: 0 4px 12px rgba(45, 212, 191, 0.25);
}
#panel-pythia .py-sym-chip[aria-pressed="true"] .py-sym-x { color: rgba(5, 38, 37, 0.55); }
#panel-pythia .py-sym-x { color: var(--muted); font-weight: 400; font-size: .85em; padding-left: .15rem; }
#panel-pythia .py-sym-x:hover { color: var(--bad); }
#panel-pythia .py-sym-add {
  background: transparent; color: var(--muted);
  border: 1px dashed var(--line-strong);
  padding: .45rem .8rem; font-size: .85rem; font-family: inherit;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}
#panel-pythia .py-sym-add:hover { color: var(--accent); border-color: var(--accent-edge); }

#panel-pythia .py-refresh-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #052625;
  border: 0;
  padding: .5rem .95rem;
  font-size: .88rem; font-weight: 600;
  font-family: inherit; letter-spacing: .02em;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(45, 212, 191, 0.25);
  transition: transform var(--t-fast), box-shadow var(--t), filter var(--t-fast);
}
#panel-pythia .py-refresh-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}
#panel-pythia .py-refresh-btn:disabled,
#panel-pythia .py-refresh-btn.working {
  background: linear-gradient(180deg, #4b5563, #374151);
  color: #9ca3af;
  box-shadow: none;
  filter: none;
  cursor: progress;
  opacity: .7;
  transform: none;
}
#panel-pythia .py-refresh-ico {
  display: inline-block;
  font-size: 1rem;
  transition: transform .2s ease;
}
#panel-pythia .py-refresh-btn.working .py-refresh-ico {
  animation: py-spin 1.1s linear infinite;
}
@keyframes py-spin { to { transform: rotate(360deg); } }
#panel-pythia .py-watchlist-spacer { flex: 1; }
#panel-pythia .py-watchlist-meta {
  color: var(--muted); font-size: .78rem;
  padding-right: .55rem; font-variant-numeric: tabular-nums;
}

/* ── Entry monitor heat-map ─────────────────────────────────────────── */
#panel-pythia .py-monitor {
  margin: 0 0 1rem; padding: .8rem .9rem .7rem;
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius);
}
#panel-pythia .py-monitor-head {
  display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap;
}
#panel-pythia .py-monitor-title { font-weight: 700; color: var(--ink); }
#panel-pythia .py-monitor-sub { color: var(--muted); font-size: .8rem; }
#panel-pythia .py-monitor-spacer { flex: 1; }
#panel-pythia .py-monitor-status { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
#panel-pythia .py-mon-voice { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .82rem; cursor: pointer; }
#panel-pythia .py-monitor-grid {
  display: grid; gap: .5rem;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
}
#panel-pythia .py-mon-tile {
  position: relative; padding: .5rem .55rem .45rem; border-radius: 8px;
  border: 1px solid var(--line); cursor: pointer; transition: transform .08s ease;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto;
  align-items: baseline; column-gap: .3rem;
}
#panel-pythia .py-mon-tile:hover { transform: translateY(-1px); border-color: var(--accent, #ff8a00); }
#panel-pythia .py-mon-sym { grid-column: 1; font-weight: 700; color: #1a1205; font-size: .95rem; }
#panel-pythia .py-mon-arrow { grid-column: 2; grid-row: 1; font-size: .9rem; color: #5a3d00; }
#panel-pythia .py-mon-price { grid-column: 1 / span 2; grid-row: 2; color: #2a1d05; font-size: .82rem; font-variant-numeric: tabular-nums; }
#panel-pythia .py-mon-near { grid-column: 1 / span 2; grid-row: 3; color: #3a2800; font-size: .72rem; font-weight: 600; }
/* Open P&L now lives in the hover tooltip (title), not on the card. */
#panel-pythia .py-mon-rev { box-shadow: inset 0 0 0 2px rgba(34,197,94,.85); }   /* turning-up accent */
#panel-pythia .py-mon-rev .py-mon-arrow { color: #15803d; }
#panel-pythia .py-mon-refreshing::after {
  content: '⟳'; position: absolute; top: .25rem; right: .35rem; font-size: .7rem; color: #5a3d00;
  animation: py-spin 1.2s linear infinite;
}
@keyframes py-spin { to { transform: rotate(360deg); } }
#panel-pythia .py-mon-blink { animation: py-mon-blink 0.85s steps(2, start) infinite; }
@keyframes py-mon-blink { 50% { background: rgba(255,90,0,0.98) !important; } }
#panel-pythia .py-mon-empty { color: var(--muted); font-size: .85rem; padding: .4rem .2rem; grid-column: 1 / -1; }
#panel-pythia .py-monitor-legend { margin: .55rem 0 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }
#panel-pythia .py-mon-key-rev { color: #22c55e; font-weight: 700; }
#panel-pythia .py-mon-key-fall { color: #ff8a00; font-weight: 700; }

/* Exit monitor — cool (teal) palette so it never reads as the entry strip. */
#panel-pythia .py-exit-tile .py-mon-sym { color: #042f2a; }
#panel-pythia .py-exit-tile .py-mon-arrow { color: #0b3d35; }
#panel-pythia .py-exit-tile .py-mon-price { color: #062c27; }
#panel-pythia .py-exit-tile .py-mon-near { color: #0b4a40; }
#panel-pythia .py-exit-tile:hover { border-color: #0d9488; }
#panel-pythia .py-exit-roll { box-shadow: inset 0 0 0 2px rgba(168,85,247,.9); }   /* rolling-over = exit signal */
#panel-pythia .py-exit-roll .py-mon-arrow { color: #7c3aed; }
#panel-pythia .py-exit-blink { animation: py-exit-blink 0.85s steps(2, start) infinite; }
@keyframes py-exit-blink { 50% { background: rgba(6,182,212,0.98) !important; } }
#panel-pythia .py-exit-key-roll { color: #a855f7; font-weight: 700; }
#panel-pythia .py-exit-key-rise { color: #0d9488; font-weight: 700; }

/* ── Schwab token expiry: discreet → big (<4h) → full banner (expired) ── */
#panel-pythia .py-token { margin: 0 0 .8rem; }
#panel-pythia .py-token-ok {
  font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: .5rem;
}
#panel-pythia .py-token-reauth-sm { color: var(--muted); text-decoration: underline; }
#panel-pythia .py-token-warn {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  padding: .7rem .9rem; border-radius: 10px;
  background: rgba(255,138,0,.14); border: 1px solid rgba(255,138,0,.55);
}
#panel-pythia .py-token-big { font-size: 1.15rem; font-weight: 800; color: #ff8a00; }
#panel-pythia .py-token-reauth {
  font-weight: 700; color: #fff; background: #ff8a00; padding: .35rem .7rem;
  border-radius: 7px; text-decoration: none;
}
#panel-pythia .py-token-expired {
  padding: 1.4rem 1.2rem; border-radius: 12px; text-align: center;
  background: repeating-linear-gradient(45deg, #b91c1c, #b91c1c 14px, #a01010 14px, #a01010 28px);
  border: 3px solid #fde047; box-shadow: 0 0 0 3px rgba(185,28,28,.35);
  animation: py-token-pulse 1.1s ease-in-out infinite;
}
@keyframes py-token-pulse { 50% { box-shadow: 0 0 24px 4px rgba(253,224,71,.55); } }
#panel-pythia .py-token-banner-title { font-size: 1.6rem; font-weight: 900; color: #fff; letter-spacing: .3px; }
#panel-pythia .py-token-banner-sub { margin-top: .5rem; font-size: 1rem; color: #fff; }
#panel-pythia .py-token-expired .py-token-reauth { display: inline-block; margin-top: .2rem; background: #fde047; color: #7a1010; }

/* ── Improvements page: open-issues section ── */
#panel-github .gh-section-head {
  font-weight: 700; color: var(--ink); margin: 1.1rem 0 .5rem; font-size: .95rem;
}
#panel-github .gh-section-head:first-child { margin-top: 0; }
#panel-github .gh-issue-row { display: flex; align-items: baseline; gap: .55rem; text-decoration: none; }
#panel-github .gh-issue-num { color: var(--accent, #ff8a00); font-weight: 700; font-variant-numeric: tabular-nums; }

#panel-pythia .py-focus {
  background: linear-gradient(180deg, var(--surface-1), var(--surface-0));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1rem;
  box-shadow: var(--shadow-1);
  margin: 0 0 1.4rem;
}
#panel-pythia .py-focus-head {
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: .55rem 1rem; margin: 0 0 .65rem;
}
#panel-pythia .py-focus-sym {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 1.45rem; font-weight: 700; letter-spacing: .04em;
  margin: 0;
}
#panel-pythia .py-focus-meta { color: var(--muted); font-size: .82rem; margin-left: auto; }

#panel-pythia .py-chart-wrap {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .35rem .25rem 0;
}
#panel-pythia .py-chart { display: block; width: 100%; height: auto; }
#panel-pythia .py-hover { cursor: help; }

#panel-pythia .py-legend {
  display: flex; flex-wrap: wrap; gap: 1.1rem;
  padding: .55rem .25rem .15rem;
  font-size: .75rem; color: var(--muted);
}
#panel-pythia .py-legend .sw {
  display: inline-block; width: .85rem; height: .55rem;
  vertical-align: middle; border-radius: 2px; margin-right: .3rem;
}
/* Iter 15: after-hours toggle (24h-predictions checkbox) in the
   watchlist toolbar. Sits next to the refresh button. */
#panel-pythia .py-after-hours {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .78rem; color: var(--muted);
  padding: .15rem .55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-1);
  cursor: pointer;
  user-select: none;
  margin-right: .6rem;
}
#panel-pythia .py-after-hours:hover { color: var(--text); border-color: var(--accent-edge); }
#panel-pythia .py-after-hours input[type="checkbox"] {
  width: 1rem; height: 1rem; accent-color: var(--accent);
  margin: 0;
}
#panel-pythia .py-after-hours:has(input:checked) {
  color: var(--accent);
  border-color: var(--accent-edge);
  background: var(--accent-soft);
}

/* iter 13: legend swatches mirror the in-chart band colors.
   Pending is now violet (was teal — same as pass, indistinguishable).
   Opacity bumped to 0.22 fill / 0.90 edge to match the chart bands.    */
#panel-pythia .py-legend .sw.band-pass    { background: rgba(94,234,212,0.22);  border: 1px dashed rgba(94,234,212,0.90); }
#panel-pythia .py-legend .sw.band-mixed   { background: rgba(251,191,36,0.22);  border: 1px dashed rgba(251,191,36,0.90); }
#panel-pythia .py-legend .sw.band-fail    { background: rgba(248,113,113,0.22); border: 1px dashed rgba(248,113,113,0.90); }
#panel-pythia .py-legend .sw.band-pending { background: rgba(167,139,250,0.22); border: 1px dashed rgba(167,139,250,0.90); }
#panel-pythia .py-legend .sw.candle-up   { background: rgba(74,222,128,0.32);  border: 1px solid #4ade80; }
#panel-pythia .py-legend .sw.candle-down { background: rgba(248,113,113,0.32); border: 1px solid #f87171; }

/* Hover tooltip */
#panel-pythia .py-tooltip {
  position: absolute; max-width: 360px; min-width: 280px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border: 1px solid var(--accent-edge);
  border-radius: var(--radius-sm);
  padding: .6rem .8rem .7rem;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  pointer-events: none; z-index: 10;
  font-size: .85rem;
  animation: py-tt-in .12s ease;
}
/* When pinned from a history-table row, the tooltip is positioned in
   viewport coordinates so it can appear next to the clicked row (outside
   the chart wrap). Raised z-index keeps it above the table. */
#panel-pythia .py-tooltip.py-tooltip-fixed { position: fixed; z-index: 1000; }
@keyframes py-tt-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
#panel-pythia .py-tt-head { display: flex; align-items: center; gap: .5rem; margin: 0 0 .45rem; }
#panel-pythia .py-tt-sym { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: .04em; color: var(--text); }
#panel-pythia .py-tt-time { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
#panel-pythia .py-tt-made {
  color: var(--accent);
  font-size: .76rem;
  font-family: ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  margin: 0 0 .5rem;
  letter-spacing: .02em;
}
#panel-pythia .py-tt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin: 0 0 .5rem; }
#panel-pythia .py-tt-grid > div {
  display: flex; justify-content: space-between;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .25rem .55rem;
  font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums;
}
#panel-pythia .py-tt-grid .lbl { color: var(--muted); font-size: .72rem; }
#panel-pythia .py-tt-grid .val { font-weight: 600; }
#panel-pythia .py-tt-grid .val.up   { color: var(--good); }
#panel-pythia .py-tt-grid .val.down { color: var(--bad); }
#panel-pythia .py-tt-reasons {
  margin: 0; color: var(--text-2); font-size: .82rem; line-height: 1.5;
  padding-top: .35rem; border-top: 1px dashed var(--line);
  white-space: pre-wrap;
}
#panel-pythia .py-tt-reasons-label {
  display: block; color: var(--muted); font-size: .68rem;
  text-transform: uppercase; letter-spacing: .07em;
  margin: .35rem 0 .2rem;
}

#panel-pythia .py-history-head {
  display: flex; align-items: baseline; gap: .6rem;
  margin: 0 0 .55rem;
}
#panel-pythia .py-history-head h2 { margin: 0; font-size: 1.05rem; }
#panel-pythia .py-hist-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: .88rem;
}
#panel-pythia .py-hist-table th,
#panel-pythia .py-hist-table td {
  padding: .55rem .85rem; text-align: left;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
#panel-pythia .py-hist-table th {
  background: var(--bg-2); color: var(--muted);
  font-weight: 500; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .07em;
}
#panel-pythia .py-hist-table tr:last-child td { border-bottom: 0; }

/* History rows are clickable — they pin the same rich tooltip the chart
   shows on a prediction click. The whole row (including the stacked
   high/low lines) highlights on hover with a left accent bar. */
#panel-pythia .py-hist-row { cursor: pointer; transition: background .12s ease, box-shadow .12s ease; }
#panel-pythia .py-hist-table tbody tr.py-hist-row:hover {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
/* Merged High/Low column: the high value sits on top, the low directly
   beneath, inside one cell (so a record stays a single hoverable row). */
#panel-pythia .py-hl-cell { padding-top: .4rem; padding-bottom: .4rem; }
#panel-pythia .py-hl-line {
  display: flex; align-items: baseline; gap: .4rem;
  font-variant-numeric: tabular-nums; line-height: 1.45;
}
#panel-pythia .py-hl-line + .py-hl-line { margin-top: .1rem; }
#panel-pythia .py-hl-tag {
  display: inline-block; min-width: .9rem;
  font-size: .62rem; font-weight: 700; letter-spacing: .04em;
  color: var(--muted); text-transform: uppercase;
}
#panel-pythia .py-hl-num { font-weight: 600; }
#panel-pythia .py-hl-num.up   { color: var(--good); }
#panel-pythia .py-hl-num.down { color: var(--bad); }
/* Sublabel under each merged column header ("high · low") */
#panel-pythia .py-hl-th { white-space: nowrap; }
#panel-pythia .py-hl-th-sub {
  display: block; margin-top: .1rem;
  font-size: .6rem; font-weight: 500; letter-spacing: .02em;
  color: var(--muted); text-transform: none; opacity: .75;
}
#panel-pythia .py-hist-pill {
  font-size: .68rem; padding: .15rem .55rem;
  border-radius: var(--radius-pill);
  font-weight: 600; letter-spacing: .04em;
  border: 1px solid; text-transform: uppercase;
}
#panel-pythia .py-hist-pill.pass {
  background: rgba(74, 222, 128, 0.10); color: var(--good);
  border-color: rgba(74, 222, 128, 0.45);
}
#panel-pythia .py-hist-pill.mixed {
  background: rgba(251, 191, 36, 0.10); color: var(--warn);
  border-color: rgba(251, 191, 36, 0.45);
}
#panel-pythia .py-hist-pill.fail {
  background: rgba(248, 113, 113, 0.10); color: var(--bad);
  border-color: rgba(248, 113, 113, 0.45);
}
/* iter 13: pending = violet (was teal — chart pass was also teal,
   making the two visually indistinguishable). */
#panel-pythia .py-hist-pill.pending {
  background: rgba(167, 139, 250, 0.12); color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.45);
}
/* iter 21: vol-scaled categories. bullseye is the new top tier
   (bright teal, more saturated than plain pass). wide_pass desaturates
   plain pass to flag "held the band but gave itself too much room".
   near_miss sits between pass and mixed — barely-broken bound, not a
   full fail. bad_fail darkens fail's red for both-sides-collapsed. */
#panel-pythia .py-hist-pill.bullseye {
  background: rgba(94, 234, 212, 0.22); color: #2dd4bf;
  border-color: rgba(94, 234, 212, 0.75);
  font-weight: 700;
}
#panel-pythia .py-hist-pill.wide_pass {
  background: rgba(148, 163, 184, 0.10); color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.40);
}
#panel-pythia .py-hist-pill.near_miss {
  background: rgba(251, 191, 36, 0.06); color: #d4a838;
  border-color: rgba(251, 191, 36, 0.35);
}
#panel-pythia .py-hist-pill.bad_fail {
  background: rgba(127, 29, 29, 0.20); color: #b91c1c;
  border-color: rgba(127, 29, 29, 0.65);
  font-weight: 700;
}
/* Outcome-pill legend (iter 21). Renamed to .py-pill-legend so it
   doesn't collide with the chart-band legend further up the page that
   already uses .py-legend. Collapsed by default; user expands to learn
   the new vol-unit-scaled vocabulary. */
#panel-pythia .py-pill-legend {
  margin: 0 0 .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-0);
  font-size: .82rem;
}
#panel-pythia .py-pill-legend > summary {
  cursor: pointer; padding: .5rem .9rem;
  color: var(--muted); font-weight: 500;
  list-style: revert;
}
#panel-pythia .py-pill-legend > summary:hover { color: var(--ink); }
#panel-pythia .py-pill-legend[open] > summary { color: var(--ink); }
#panel-pythia .py-pill-legend-grid {
  display: grid; gap: .45rem .9rem;
  padding: .55rem .9rem .25rem;
  grid-template-columns: max-content 1fr;
  align-items: baseline;
  border-top: 1px solid var(--line);
}
#panel-pythia .py-pill-legend-item { display: contents; }
#panel-pythia .py-pill-legend-item > span:first-child {
  /* The pill itself */
  justify-self: start;
  min-width: 5.5rem; text-align: center;
}
#panel-pythia .py-pill-legend-item > span:last-child {
  color: var(--muted); line-height: 1.35;
}
/* Chart-tooltip "why this category" breakdown (iter 21).
   Two per-side rows (high, low) with a micro-badge for the bucket
   plus the signed err in vol-units. Plus the accuracy score, vol_unit
   denominator, and a one-line plain-English sentence explaining why
   THIS row earned this combined pill. All values are populated from
   the resolver's per_prediction_outcomes — no recomputation in JS. */
.py-tooltip .py-tt-grade {
  margin: .45rem 0 0; padding: .45rem .55rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line); border-radius: 6px;
  font-size: .78rem;
}
.py-tooltip .py-tt-grade-side {
  display: grid; grid-template-columns: 2.6rem max-content 1fr;
  gap: .15rem .55rem; align-items: baseline;
  font-variant-numeric: tabular-nums;
}
.py-tooltip .py-tt-grade-side .lbl {
  color: var(--muted); font-size: .72rem;
}
.py-tooltip .py-tt-grade-side .micro {
  font-size: .72rem; padding: 0 .35rem; border-radius: 8px;
  border: 1px solid; line-height: 1.4;
  text-transform: lowercase; letter-spacing: .02em;
}
/* Per-side micro-badge palette — same 6 buckets the resolver emits. */
.py-tooltip .micro.tight_hit { color: #2dd4bf; border-color: rgba(45, 212, 191, 0.55); background: rgba(45, 212, 191, 0.10); }
.py-tooltip .micro.safe_hit  { color: #5eead4; border-color: rgba(94, 234, 212, 0.45); background: rgba(94, 234, 212, 0.08); }
.py-tooltip .micro.loose_hit { color: #94a3b8; border-color: rgba(148, 163, 184, 0.45); background: rgba(148, 163, 184, 0.10); }
.py-tooltip .micro.near_miss { color: #d4a838; border-color: rgba(251, 191, 36, 0.45); background: rgba(251, 191, 36, 0.10); }
.py-tooltip .micro.miss      { color: #f59e0b; border-color: rgba(245, 158, 11, 0.55); background: rgba(245, 158, 11, 0.10); }
.py-tooltip .micro.bad_miss  { color: #b91c1c; border-color: rgba(185, 28, 28, 0.55); background: rgba(185, 28, 28, 0.12); }
.py-tooltip .py-tt-grade-score {
  margin-top: .4rem; padding-top: .35rem;
  border-top: 1px dashed rgba(148, 163, 184, 0.25);
  color: var(--muted);
}
.py-tooltip .py-tt-grade-score strong { color: var(--text); }
.py-tooltip .py-tt-grade-math {
  margin: .35rem 0 0; padding: .4rem .55rem;
  background: rgba(148, 163, 184, 0.08);
  border-left: 2px solid var(--accent, #ff8a00); border-radius: 0 4px 4px 0;
  color: var(--text); font-size: .72rem; line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre; overflow-x: auto;
}
.py-tooltip .py-tt-grade-why {
  margin-top: .25rem; color: var(--muted); line-height: 1.35;
}

#panel-pythia .py-pill-legend-foot {
  margin: .35rem 0 .25rem;
  padding: .55rem .9rem .55rem;
  color: var(--muted); font-size: .78rem; line-height: 1.45;
  border-top: 1px solid var(--line);
}

/* Score formula + worked example shown at the top of the outcome legend. */
#panel-pythia .py-formula-block {
  padding: .25rem .9rem .15rem;
  color: var(--muted); font-size: .8rem; line-height: 1.5;
}
#panel-pythia .py-formula-block p { margin: .35rem 0; }
#panel-pythia .py-formula {
  margin: .5rem 0; padding: .6rem .8rem;
  background: var(--panel-2, rgba(255,255,255,.03));
  border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink); font-size: .82rem; line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre; overflow-x: auto;
}
#panel-pythia .py-formula sub { font-size: .72em; }
#panel-pythia .py-formula sup { font-size: .72em; }
#panel-pythia .py-formula-table {
  margin: .4rem 0 .5rem; border-collapse: collapse; font-size: .78rem;
}
#panel-pythia .py-formula-table th {
  text-align: right; padding: .15rem .6rem .15rem 0; color: var(--muted); white-space: nowrap;
}
#panel-pythia .py-formula-table td {
  text-align: center; padding: .15rem .55rem; color: var(--ink);
  font-variant-numeric: tabular-nums; border-left: 1px solid var(--line);
}
#panel-pythia .py-worked-example {
  padding: .55rem .8rem; border-left: 3px solid var(--accent, #ff8a00);
  background: rgba(255,138,0,.06); border-radius: 0 6px 6px 0; color: var(--ink);
}

/* Discreet per-row delete button. Faint until you hover the row, so it
   doesn't compete with the data; turns red on direct hover so the
   destructive intent is clear. */
#panel-pythia .py-hist-del-cell {
  width: 1.6rem; padding: .25rem .35rem; text-align: center;
}
#panel-pythia .py-hist-del-btn {
  background: transparent; border: 0;
  color: var(--muted); opacity: .35;
  font-size: 1.05rem; line-height: 1; padding: .15rem .35rem;
  border-radius: 4px; cursor: pointer;
  transition: opacity .15s ease, color .15s ease, background-color .15s ease;
}
#panel-pythia .py-hist-table tr:hover .py-hist-del-btn { opacity: .85; }
#panel-pythia .py-hist-del-btn:hover {
  opacity: 1; color: var(--bad);
  background: rgba(248, 113, 113, 0.10);
}
#panel-pythia .py-hist-del-btn:disabled {
  opacity: .45; cursor: wait; color: var(--muted); background: transparent;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
