:root {
  --bg: #0d1117;
  --panel: #151b24;
  --panel-2: #1c2430;
  --line: #273142;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #4f8cff;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.muted { color: var(--muted); font-weight: 400; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, .18);
}
.status {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}
.status.ok { color: #4ade80; }
.status.err { color: #f87171; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; }
}

/* ---------- stage ---------- */
.stage {
  position: relative;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
}
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 24px;
  pointer-events: none;
}
.ph-title { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.ph-sub { color: var(--muted); margin: 0; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.metrics {
  margin-left: auto;
  font: 12px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--muted);
}

/* ---------- controls ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 9px;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { border-color: #3a475c; background: #222c3a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #3d7af0; }
.btn.danger { background: #b42318; border-color: #b42318; color: #fff; }
.file-btn { display: inline-block; }

.select {
  appearance: none;
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b98a9'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 30px 8px 10px;
  border-radius: 9px;
  font: inherit;
  max-width: 100%;
}

/* ---------- side panel ---------- */
.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 650;
}

.dominant { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dom-emoji { font-size: 38px; line-height: 1; width: 44px; text-align: center; }
.dom-label { font-size: 20px; font-weight: 650; }
.dom-conf { color: var(--muted); font-size: 13px; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.bar {
  display: grid;
  grid-template-columns: 84px 1fr 40px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.bar-track { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 99px; transition: width .15s linear; }
.bar-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.timeline {
  width: 100%;
  display: block;
  background: var(--panel-2);
  border-radius: 8px;
}

.field { margin-bottom: 14px; }
.field label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}
.field output { color: var(--text); font-variant-numeric: tabular-nums; }
.field .select { width: 100%; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.foot { font-size: 12px; margin: 0 4px; }
.foot a { color: var(--muted); }

/* ---------- v2: personalization ---------- */
.teach-card { margin-top: 16px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 99px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.badge.ok { color: #4ade80; border-color: rgba(74, 222, 128, .35); background: rgba(74, 222, 128, .08); }
.hint { color: var(--muted); margin: 0 0 12px; font-size: 13px; }
.hint b, .hint em { color: var(--text); }
.teach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.teach-btn {
  appearance: none; font: inherit; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 9px 11px; border-radius: 9px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--c);
  transition: background .15s, border-color .15s;
}
.teach-btn span { font-weight: 600; font-size: 13px; }
.teach-btn small { color: var(--muted); font-size: 11px; }
.teach-btn:hover:not(:disabled) { background: #222c3a; }
.teach-btn.done small { color: #4ade80; }
.teach-btn:disabled { opacity: .45; cursor: not-allowed; }
.teach-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 12px; }
.btn.small { padding: 6px 10px; font-size: 12px; }

/* ---------- v2: signals ---------- */
.meter-row { display: grid; grid-template-columns: 62px 1fr 42px; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; }
.meter { position: relative; height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.meter-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #3a475c; }
.meter-fill { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; background: #4ade80; border-radius: 99px; transition: left .15s linear, width .15s linear; }
.meter-fill.aro { background: #fb923c; }
.meter-num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; font-size: 12px; min-height: 24px; }
.chip { padding: 3px 8px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); }
.chip b { color: var(--accent); margin-right: 2px; }

/* ---------- v2: design notes ---------- */
.notes {
  max-width: 1400px;
  margin: 12px auto 48px;
  padding: 28px 20px 0;
  border-top: 1px solid var(--line);
}
.notes > header, .notes > section { max-width: 920px; }
.eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: 12px; color: var(--accent); font-weight: 650; margin: 0 0 6px; }
.notes h2 { font-size: 24px; line-height: 1.25; margin: 0 0 10px; text-wrap: balance; }
.notes h3 { font-size: 16px; margin: 28px 0 10px; }
.lede { font-size: 15px; color: #c9d4df; margin: 0; }
.notes p, .notes li { color: #c9d4df; }
.notes li { margin-bottom: 8px; }
.notes b { color: var(--text); }
.notes code { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.pipeline { padding-left: 20px; }
.small { font-size: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.notes table { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 640px; }
.notes table.results { min-width: 0; }
.notes th, .notes td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.notes th { background: var(--panel); color: var(--muted); font-weight: 600; font-size: 12px; }
.notes tr:last-child td { border-bottom: 0; }
td.yes { color: #4ade80; font-weight: 600; }
td.no { color: #f87171; font-weight: 600; }
@media (max-width: 900px) { .notes { padding-inline: 16px; } }
