:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 28px; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }

p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); margin-top: 8px; }

code { background: #f1f3f5; padding: 1px 5px; border-radius: 3px; font-size: 13px; }
pre { background: #f1f3f5; padding: 10px; border-radius: 6px; overflow: auto; white-space: pre-wrap; }

/* --- Buttons --- */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  transition: all 0.12s;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 4px 8px; font-size: 13px; }
.btn--lg { padding: 12px 24px; font-size: 16px; }
.btn--primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.link { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; font: inherit; }
.link:hover { text-decoration: underline; }
form.inline { display: inline; }

/* --- Form fields --- */
label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
textarea, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
textarea { resize: vertical; }
.row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.row > * { flex: 0 0 auto; }
.row > label { flex: 1; min-width: 200px; }

/* --- Topbar / nav --- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { font-weight: 600; color: var(--text); }
.nav { display: flex; gap: 18px; flex: 1; }
.nav a { color: var(--muted); }
.nav a.active, .nav a:hover { color: var(--text); text-decoration: none; }
.user-block { display: flex; gap: 12px; align-items: center; }
.user-name { color: var(--muted); font-size: 13px; }

/* --- Layout --- */
.container { max-width: 1100px; margin: 24px auto; padding: 0 24px; }
.page-head {
  display: flex; justify-content: space-between; align-items: end;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.actions { display: flex; gap: 10px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* --- List / table --- */
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }

.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.grid th { color: var(--muted); font-weight: 500; font-size: 13px; }

/* --- Badges --- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; background: #eef; color: #224;
}
.badge--invited { background: #e0e7ff; color: #3730a3; }
.badge--in_progress { background: #fef3c7; color: #92400e; }
.badge--uploaded, .badge--transcribing, .badge--transcribed, .badge--evaluating {
  background: #cffafe; color: #155e75;
}
.badge--completed { background: #dcfce7; color: #166534; }
.badge--failed { background: #fee2e2; color: #991b1b; }

.score-pill {
  display: inline-block; padding: 3px 12px; border-radius: 999px;
  font-size: 13px; background: #f3f4f6; color: var(--text);
}
.score-pill--strong { background: #dcfce7; color: #166534; }
.score-pill--acceptable { background: #fef3c7; color: #92400e; }
.score-pill--weak { background: #fee2e2; color: #991b1b; }
.score-pill--no_answer { background: #f3f4f6; color: var(--muted); }

/* --- Auth --- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.auth-wrap .card { width: 380px; max-width: 90vw; }

/* --- Question editor --- */
.question {
  background: #fafbfc; border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px; margin-bottom: 12px;
}
.question summary {
  cursor: pointer; outline: none;
  display: flex; gap: 10px; align-items: center;
}
.question .qnum { font-weight: 600; color: var(--primary); }
.question .qtitle { flex: 1; }

/* --- Candidate detail --- */
.link-box {
  display: flex; gap: 8px;
}
.link-box input { font-family: monospace; font-size: 13px; }
.link-box .btn { white-space: nowrap; }

.video-block {
  display: grid; gap: 14px; grid-template-columns: 2fr 1fr; align-items: start;
}
.video-wrap { position: relative; grid-column: 1; }
.video-block video { width: 100%; border-radius: 8px; background: #000; display: block; }
/* Marker strip sits just above the native controls bar */
.video-markers { position: absolute; left: 0; right: 0; bottom: 32px; height: 0; pointer-events: none; }
.video-marker {
  position: absolute; bottom: 0; transform: translateX(-50%);
  width: 3px; height: 14px; padding: 0; border: 0; border-radius: 2px;
  background: var(--primary); box-shadow: 0 0 0 1px rgba(0,0,0,.5);
  cursor: pointer; pointer-events: auto; opacity: .85;
}
.video-marker:hover { opacity: 1; height: 20px; }
.video-chapters { grid-column: 1; display: flex; flex-wrap: wrap; gap: 6px; }
.chapter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
.chapter-chip:hover { border-color: var(--primary); background: #f4f6ff; }
.chapter-chip__n { font-weight: 600; }
.chapter-chip__t { color: var(--muted); font-size: 12px; }
.video-speed { grid-column: 1; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.video-meta { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 8px; }
.btn--speed { padding: 4px 10px; font-size: 13px; }
.btn--speed.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.transcript-full { margin-top: 16px; }

.answer {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin-bottom: 14px; background: #fafbfc;
}
.answer__head {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.answer__head h3 { margin: 0; }
.answer__transcript p, .answer__feedback p { margin: 4px 0 0; }
.answer__feedback { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.criteria { margin-top: 10px; }
.criteria summary { cursor: pointer; color: var(--muted); font-size: 13px; }

.error-card { border-left: 4px solid var(--danger); }

/* --- Candidate-facing --- */
body.candidate {
  background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}
.candidate-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.candidate-wrap .card { max-width: 640px; width: 100%; }
.lead { font-size: 17px; color: var(--text); }
.intro-text { margin: 16px 0; }
.checklist { padding-left: 20px; margin: 16px 0 24px; }
.checklist li { margin-bottom: 4px; }
.cta-row { margin-top: 24px; }

/* --- Recording UI --- */
body.recording { background: #f1f5f9; }
.recording-wrap {
  max-width: 1100px; margin: 24px auto; padding: 0 16px;
  display: grid; grid-template-columns: 320px 1fr; gap: 16px;
}
.recording-side { display: flex; flex-direction: column; gap: 16px; }
.preview-card video { width: 100%; border-radius: 8px; background: #000; aspect-ratio: 16/9; }
.mic-check {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 16px; margin: 12px 0 18px;
}
.mic-check__head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.mic-check__title { font-weight: 600; font-size: 15px; }
.mic-check__status { font-size: 14px; font-weight: 600; }
.mic-check__status.ok { color: var(--success); }
.mic-check__status.silent { color: var(--muted); font-weight: 500; }

.mic-vu {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px;
  height: 36px; margin-bottom: 10px;
}
.mic-vu span {
  background: #e2e8f0; border-radius: 3px;
  transition: background 60ms linear;
}
.mic-vu span.on { background: #22c55e; }
.mic-vu span.on.mid { background: #eab308; }
.mic-vu span.on.hi  { background: #ef4444; }

.rec-indicator {
  display: flex; gap: 8px; align-items: center;
  margin-top: 12px; color: var(--danger); font-weight: 600;
}
.rec-indicator .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.progress-list { list-style: none; padding: 0; margin: 0; }
.progress-list li {
  padding: 6px 10px; border-radius: 6px; margin-bottom: 4px;
  color: var(--muted); font-size: 13px;
}
.progress-list li.done { color: var(--success); }
.progress-list li.done::before { content: "✓ "; }
.progress-list li.current {
  background: var(--primary); color: #fff; font-weight: 500;
}

.question-card { min-height: 320px; }
.qhead {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.qhead .qnum { color: var(--muted); font-size: 13px; }
.timer {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 24px; font-weight: 600; color: var(--text);
}
.timer.urgent { color: var(--danger); }
.qtext { font-size: 18px; line-height: 1.5; margin: 16px 0 24px; white-space: pre-wrap; }
.qactions { display: flex; gap: 10px; }

.progress-bar {
  width: 100%; height: 10px; background: var(--border);
  border-radius: 999px; overflow: hidden; margin: 14px 0;
}
.progress-bar__fill {
  height: 100%; width: 0; background: var(--primary);
  transition: width 0.2s ease;
}

/* Блок спасения записи: показывается, когда отправка на сервер не удалась. */
.rescue {
  margin-top: 18px; padding: 16px 18px;
  border: 1px solid var(--danger); border-radius: 10px;
  background: #fef2f2;
}
.rescue h3 { margin: 0 0 8px; color: var(--danger); }
.rescue p { margin: 8px 0; }

@media (max-width: 800px) {
  .recording-wrap { grid-template-columns: 1fr; }
  .video-block { grid-template-columns: 1fr; }
  .video-wrap, .video-chapters, .video-speed, .video-meta { grid-column: 1; grid-row: auto; }
}

/* --- Candidate intro --- */
.intro-text { margin: 0 0 18px; }
.intro-text p { margin: 0 0 12px; line-height: 1.55; }
.intro-text p:first-child {
  font-size: 18px; font-weight: 600; margin-bottom: 14px;
}
.intro-rules {
  list-style: none; padding: 0; margin: 6px 0 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.intro-rules li {
  padding: 10px 14px; border-left: 3px solid var(--primary);
  background: #f8fafc; border-radius: 4px;
}
.intro-rules li strong { color: var(--text); }

/* --- Q/A transcript --- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.section-head h2 { margin: 0; }

.qa-list { display: flex; flex-direction: column; gap: 14px; }
.qa-item {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: #fafafa;
}
.qa-q { font-weight: 500; margin-bottom: 8px; }
.qa-a { white-space: pre-wrap; }
.qa-label {
  display: inline-block; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.04em; margin-right: 6px;
}
.qa-label--a { color: var(--primary); }
.qa-toggle {
  display: inline-block; margin-left: 6px; padding: 2px 8px;
  font-size: 12px; color: var(--muted); background: transparent;
  border: 1px dashed #cbd5e1; border-radius: 4px; cursor: pointer;
}
.qa-toggle:hover { color: var(--primary); border-color: var(--primary); }

/* --- Eval (per-question score) --- */
.eval-list { display: flex; flex-direction: column; gap: 10px; }
.eval-item {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: #fafafa;
}
.eval-row {
  display: flex; align-items: center; gap: 12px;
}
.eval-q {
  font-weight: 600; color: var(--muted); min-width: 36px;
  font-variant-numeric: tabular-nums;
}
.eval-feedback {
  margin: 8px 0 0; white-space: pre-wrap;
}

/* --- Behavior events table --- */
.behavior-table .mono { font-variant-numeric: tabular-nums; color: var(--muted); }
.behavior-table tbody tr:hover { background: #fafafa; }

.ev-badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: #f3f4f6; color: var(--muted);
}
.ev-badge--copy,
.ev-badge--cut,
.ev-badge--paste {
  background: #fee2e2; color: #991b1b;
}
.ev-badge--visibility_hidden,
.ev-badge--window_blur {
  background: #fef3c7; color: #92400e;
}
.ev-badge--visibility_visible,
.ev-badge--window_focus {
  background: #dcfce7; color: #166534;
}
.ev-badge--contextmenu {
  background: #e0e7ff; color: #3730a3;
}
