/* ------------------------------------------------------------------
   styles.css — dark instrument-panel look.
   ------------------------------------------------------------------ */

:root {
  --bg:        #0b1220;
  --panel:     #111a2b;
  --panel-2:   #16213480;
  --line:      #1e2d45;
  --ink:       #e2e8f0;
  --ink-dim:   #94a3b8;
  --ink-faint: #64748b;
  --accent:    #38bdf8;
  --yes:       #34d399;
  --no:        #f87171;
  --skip:      #a78bfa;
  --warn:      #fbbf24;
  --radius:    12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 70% -10%, #16233b 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}

h1, h3, h4 { margin: 0; font-weight: 600; }
small { font-weight: 400; color: var(--ink-faint); font-size: 11px; }
kbd {
  font: 10px ui-monospace, monospace;
  background: #ffffff14; border: 1px solid #ffffff1f;
  border-radius: 4px; padding: 1px 4px; margin-left: 5px;
  color: var(--ink-dim);
}

/* ---- top bar ---- */

.topbar {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: center; justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: #0b122099;
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand h1 { font-size: 17px; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; color: var(--ink-dim); font-size: 12.5px; }

.knobs { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.knobs label {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--ink-dim); white-space: nowrap;
}
.knobs output { font: 11px ui-monospace, monospace; color: var(--accent); min-width: 30px; }

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 78px; height: 3px; border-radius: 3px;
  background: var(--line); outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px; border: 0; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

button {
  font: inherit; font-size: 12.5px;
  background: #ffffff0d; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s;
}
button:hover:not(:disabled) { background: #ffffff17; border-color: #31456a; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); color: #06121d; border-color: transparent; font-weight: 600; }
button.primary:hover { background: #67d2fb; }
button.primary kbd { background: #0000001f; border-color: #00000024; color: #06121dcc; }
button.wide { width: 100%; margin-top: 10px; }

select {
  font: inherit; font-size: 12.5px; flex: 1; min-width: 0;
  background: #ffffff0d; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px;
}

/* ---- layout ---- */

main {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(420px, 1fr) minmax(280px, 340px);
  gap: 14px; padding: 14px; align-items: start;
}
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.card {
  background: linear-gradient(180deg, var(--panel), #0e1626);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.card > h3 { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; font-size: 12px;
             text-transform: uppercase; letter-spacing: .07em; color: var(--ink-dim); }

.hint { margin: 10px 0 0; font-size: 11.5px; color: var(--ink-faint); line-height: 1.45; }
.hidden { display: none !important; }

/* ---- question ---- */

.question-card { padding: 16px; }
.q-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.q-num { font: 11px ui-monospace, monospace; color: var(--ink-faint); letter-spacing: .04em; }
.tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  padding: 2px 6px; border-radius: 4px;
  background: #38bdf81f; color: var(--accent);
}
.tag.guess { background: #fbbf241f; color: var(--warn); }
.q-text { font-size: 20px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.q-why { margin-top: 8px; font-size: 11.5px; color: var(--ink-faint); }
.q-why b { color: var(--accent); font-weight: 600; }

.answers { display: flex; gap: 8px; margin-top: 14px; }
.ans { flex: 1; padding: 10px 6px; font-weight: 600; }
.ans.yes:hover  { background: #34d3991f; border-color: #34d39959; color: var(--yes); }
.ans.no:hover   { background: #f871711f; border-color: #f8717159; color: var(--no); }
.ans.skip:hover { background: #a78bfa1f; border-color: #a78bfa59; color: var(--skip); }

.banner {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #ffffff08;
}
.banner.win  { border-color: #34d39959; background: #34d39914; }
.banner.lose { border-color: #fbbf2459; background: #fbbf2414; }
.banner-emoji { font-size: 30px; line-height: 1; }
.banner strong { display: block; font-size: 14px; }
.banner span { display: block; font-size: 11.5px; color: var(--ink-dim); margin-top: 2px; }

/* ---- stats ---- */

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { text-align: center; }
.stat span { display: block; font: 600 19px ui-monospace, monospace; color: var(--accent); }
.stat label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }

.entropy-track { height: 3px; background: var(--line); border-radius: 3px; margin: 12px 0 4px; overflow: hidden; }
#entropy-bar {
  height: 100%; width: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  transition: width .45s cubic-bezier(.4, 0, .2, 1);
}

.chart { width: 100%; height: 128px; display: block; }
.chart-sm { height: 96px; margin-top: 10px; }

.legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 0; font-size: 10px; color: var(--ink-faint); }
.legend .key { display: inline-block; width: 12px; height: 2px; margin-right: 4px; vertical-align: middle; }
.line-solid  { background: var(--accent); }
.line-grey   { background: repeating-linear-gradient(90deg, #64748b 0 3px, transparent 3px 6px); }
.line-purple { background: repeating-linear-gradient(90deg, #a855f7 0 3px, transparent 3px 6px); }
.dot-amber   { background: var(--warn); border-radius: 50%; width: 5px !important; height: 5px !important; }

.lifetime { margin: 8px 0 0; font-size: 11px; color: var(--ink-faint); }

/* ---- candidate ranking ---- */

.candidates { list-style: none; margin: 0; padding: 0; }
.candidates li {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; margin-bottom: 3px;
  font-size: 12px; overflow: hidden;
}
.cand-bar {
  position: absolute; inset: 0 auto 0 0;
  background: #38bdf814; border-radius: 6px;
}
.candidates li.lead .cand-bar { background: #38bdf82e; }
.candidates li.is-guess .cand-bar { background: #fbbf2421; }
.cand-name { position: relative; flex: 1; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.candidates li.lead .cand-name { color: var(--ink); font-weight: 600; }
.cand-val { position: relative; font: 11px ui-monospace, monospace; color: var(--accent); }
.candidates li.is-guess .cand-val { color: var(--warn); }

/* ---- graph ---- */

.graph-card { display: flex; flex-direction: column; }
.graph-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.graph-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-dim); }
.graph-toggles { display: flex; gap: 12px; font-size: 11px; color: var(--ink-faint); }
.graph-toggles label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.graph-toggles input { accent-color: var(--accent); }

.graph-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 74vh; }
#graph { width: 100%; height: 100%; display: block; }

.tooltip {
  position: absolute; display: none; pointer-events: none; z-index: 5;
  background: #0f1b2ef2; border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 9px; font-size: 11.5px;
  box-shadow: 0 8px 24px #00000059; max-width: 220px;
}
.tooltip strong { display: block; }
.tooltip span { display: block; color: var(--ink-faint); font-size: 10.5px; margin-top: 1px; }

.selection { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; min-height: 74px; }
.selection h4 { font-size: 13.5px; }
.sel-meta { margin: 3px 0 8px; font-size: 11.5px; color: var(--ink-faint); }
.sel-meta b.yes { color: var(--yes); } .sel-meta b.no { color: var(--no); } .sel-meta b.unsure { color: var(--skip); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; max-height: 92px; overflow-y: auto; }
.chip {
  font-size: 11px; padding: 2px 7px; border-radius: 20px;
  background: #ffffff0d; border: 1px solid var(--line); color: var(--ink-dim);
}

/* ---- posterior ---- */

.posterior { list-style: none; margin: 0; padding: 0; }
.posterior li {
  position: relative; display: flex; align-items: center; gap: 7px;
  padding: 5px 8px; border-radius: 6px; margin-bottom: 2px;
  font-size: 12px; cursor: pointer; overflow: hidden;
}
.posterior li:hover { background: #ffffff0a; }
.p-bar { position: absolute; inset: 0 auto 0 0; background: #38bdf81f; border-radius: 6px; }
.p-emoji, .p-name, .p-val { position: relative; }
.p-emoji { font-size: 13px; }
.p-name { flex: 1; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.posterior li:first-child .p-name { color: var(--ink); font-weight: 600; }
.p-val { font: 11px ui-monospace, monospace; color: var(--accent); }

/* ---- history ---- */

.history { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.history li {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 0; font-size: 11.5px;
  border-bottom: 1px solid #1e2d4580;
}
.h-turn { font: 10px ui-monospace, monospace; color: var(--ink-faint); width: 15px; }
.h-text { flex: 1; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-ans { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.h-ans.yes { color: var(--yes); } .h-ans.no { color: var(--no); } .h-ans.skip { color: var(--skip); }
.h-bits { font: 10px ui-monospace, monospace; color: var(--ink-faint); width: 36px; text-align: right; }
.h-bits.surprise { color: var(--warn); }

/* ---- autoplay / benchmark ---- */

.auto-row { display: flex; gap: 8px; }
.slider-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 11.5px; color: var(--ink-dim); }
.slider-row output { font: 11px ui-monospace, monospace; color: var(--accent); }
.bench-summary { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 11px; color: var(--ink-faint); }
.bench-summary b { color: var(--accent); font: 600 13px ui-monospace, monospace; display: block; }

/* ---- decision tree ---- */

.tree-section { padding: 0 14px 14px; }
.tree-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.tree-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-dim); }
.tree-blurb { margin: 6px 0 0; max-width: 66ch; font-size: 12.5px; color: var(--ink-faint); line-height: 1.5; }
.tree-blurb em { color: var(--ink-dim); font-style: italic; }
.tree-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tree-controls select { min-width: 210px; flex: none; }

.tree-stats { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.tree-stats span { display: flex; flex-direction: column; font-size: 10.5px; color: var(--ink-faint); }
.tree-stats b { font: 600 18px ui-monospace, monospace; color: var(--accent); }

.tree-note {
  margin-top: 12px; padding: 9px 11px; border-radius: 8px;
  background: #ffffff08; border: 1px solid var(--line);
  font-size: 11.5px; line-height: 1.55; color: var(--ink-faint);
}
.tree-note b { color: var(--warn); }
.tree-note em { color: var(--ink-dim); font-style: italic; }

.tree-wrap { position: relative; margin-top: 12px; }
/* Tall enough that all 104 leaves fit at a readable scale without
   zooming — the whole policy at a glance is the point. */
#tree {
  width: 100%; height: 1180px; display: block; cursor: grab;
  background: #0a1120; border: 1px solid var(--line); border-radius: 10px;
}
.tree-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  margin: 8px 0 0; font-size: 10.5px; color: var(--ink-faint);
}
.tree-legend span { display: flex; align-items: center; gap: 5px; }
.tree-legend .sw { width: 14px; height: 2px; border-radius: 2px; }
.tree-legend .dot { width: 7px; height: 7px; border-radius: 50%; }
.tree-hint { margin-left: auto; color: #52627a; }

.tree-selection { min-height: 30px; margin-top: 10px; }
.tree-selection h4 { font-size: 13.5px; }

/* ---- responsive ---- */

@media (max-width: 1180px) {
  main { grid-template-columns: 1fr 1fr; }
  .col-graph { grid-column: 1 / -1; order: -1; }
  .graph-wrap { max-height: 62vh; }
}
@media (max-width: 720px) {
  main { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .topbar { padding: 12px 14px; }
  .knobs { width: 100%; }
  .q-text { font-size: 17px; }
  .tree-section { padding: 0 10px 10px; }
  .tree-controls { width: 100%; }
  .tree-controls select { min-width: 0; flex: 1; }
  #tree { height: 560px; }
  .tree-hint { margin-left: 0; }
}
