:root {
  --bg: #f5f6f8; --panel: #ffffff; --panel-2: #f0f2f5; --text: #15181d; --muted: #5d6673; --line: #dfe3e8;
  --accent: #0b6bcb; --accent-ink: #fff; --ok: #12805c; --warn: #b26a00; --bad: #c23934; --info: #5b4fd6;
  --chip: #eef1f5; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --panel: #171b21; --panel-2: #1e232b; --text: #e8ebef; --muted: #9aa4b1; --line: #2a313b;
    --accent: #4ea1ff; --accent-ink: #06121f; --ok: #3ccf91; --warn: #f0b44c; --bad: #ff6b66; --info: #9a90ff;
    --chip: #232a33; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --panel: #171b21; --panel-2: #1e232b; --text: #e8ebef; --muted: #9aa4b1; --line: #2a313b;
  --accent: #4ea1ff; --accent-ink: #06121f; --ok: #3ccf91; --warn: #f0b44c; --bad: #ff6b66; --info: #9a90ff;
  --chip: #232a33; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Vazirmatn", "Segoe UI", Tahoma, sans-serif; font-size: 16px; line-height: 1.7;
}
a { color: var(--accent); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
header.top .brand { font-weight: 700; font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 0 0 8px; } h2 { font-size: 19px; margin: 0 0 10px; } h3 { font-size: 16px; margin: 0 0 8px; }
label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type=text], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
button, .btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 10px 18px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; display: inline-block;
}
button.secondary, .btn.secondary { background: var(--chip); color: var(--text); }
button.danger { background: var(--bad); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--chip); font-size: 13px; }
.chip.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.chip.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.chip.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.chip.info { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }
.err { color: var(--bad); font-weight: 600; }
.consent { background: var(--panel-2); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.checkline { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.checkline input { margin-top: 6px; }
.hidden { display: none !important; }

/* ---------- interview ---------- */
.stage { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 860px) { .stage { grid-template-columns: 1fr; } }
.videobox { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 4/3; }
.videobox video, .videobox canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.hud { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.6); color: #fff; font: 12px/1.4 ui-monospace, monospace; padding: 8px; border-radius: 8px; direction: ltr; white-space: pre; max-width: 60%; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--chip); font-weight: 600; }
.status-pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status-pill.speaking .dot { background: var(--info); animation: pulse 1s infinite; }
.status-pill.listening .dot { background: var(--bad); animation: pulse 1s infinite; }
.status-pill.thinking .dot { background: var(--warn); animation: pulse .6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.question { font-size: 21px; font-weight: 600; line-height: 1.7; min-height: 110px; }
.transcript { background: var(--panel-2); border-radius: 10px; padding: 12px; min-height: 90px; color: var(--muted); }
.meter { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .08s; }
.checks li { margin: 4px 0; }
.endbar { height: 6px; background: var(--chip); border-radius: 999px; overflow: hidden; }
.endbar > span { display: block; height: 100%; width: 0; background: var(--warn); }
.center-screen { max-width: 640px; margin: 40px auto; }
.calib { position: fixed; inset: 0; background: var(--bg); z-index: 50; }
.calib-dot { position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%; background: var(--bad);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--bad) 25%, transparent); transition: left .35s ease, top .35s ease; }
.calib-text { position: absolute; bottom: 24px; inset-inline: 0; text-align: center; font-size: 20px; font-weight: 600; }

/* ---------- admin ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; } tr.click:hover { background: var(--panel-2); }
.monitor { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; }
@media (max-width: 960px) { .monitor { grid-template-columns: 1fr; } }
.snap { width: 100%; aspect-ratio: 4/3; background: #000; border-radius: 10px; object-fit: cover; transform: scaleX(-1); }
.alerts { max-height: 300px; overflow: auto; display: grid; gap: 6px; }
.alert { border-inline-start: 4px solid var(--warn); background: var(--panel-2); padding: 6px 10px; border-radius: 6px; font-size: 14px; }
.alert.integrity { border-color: var(--bad); }
.alert.event { border-color: var(--info); }
.seg { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--panel); }
.seg.hot { border-color: var(--bad); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 25%, transparent); }
.seg .q { font-weight: 600; } .seg .a { background: var(--panel-2); padding: 8px 10px; border-radius: 8px; margin: 8px 0; }
.score { font-size: 28px; font-weight: 700; }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 160px 1fr 40px; gap: 8px; align-items: center; font-size: 14px; }
.bar .track { height: 8px; background: var(--chip); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); }
canvas.chart { width: 100%; height: 220px; display: block; background: var(--panel-2); border-radius: 10px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.legend label { display: inline-flex; gap: 4px; align-items: center; margin: 0; font-weight: 500; cursor: pointer; }
.legend i { width: 12px; height: 4px; border-radius: 2px; display: inline-block; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { background: var(--chip); color: var(--text); }
.tabs button.active { background: var(--accent); color: var(--accent-ink); }
ul.clean { padding-inline-start: 20px; margin: 6px 0; }
@media print { header.top, .noprint { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }
