:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #64748b;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --selected-border: #2563eb;
  --selected-bg: #eff6ff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--surface-alt);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Layout ── */
.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px 56px;
  max-width: 780px;
  width: 100%;
}

.card.wide { max-width: 1200px; }

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  letter-spacing: -0.3px;
}

.progress-bar-wrap {
  flex: 1;
  margin: 0 32px;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width .4s ease;
}

.progress-label {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Typography ── */
h1 { font-size: 2rem; font-weight: 700; line-height: 1.2; margin-bottom: 12px; }
h2 { font-size: 1.4rem; font-weight: 600; margin-bottom: 8px; }
h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; }

.subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 32px;
}

.section-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s, opacity .15s;
  text-decoration: none;
}

.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-alt); }

.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 36px;
  justify-content: space-between;
  align-items: center;
}

/* ── Assessment ── */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.level-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--surface);
  user-select: none;
}

.level-card:hover { border-color: var(--primary); background: var(--primary-light); }
.level-card.selected { border-color: var(--selected-border); background: var(--selected-bg); }

.level-card .level-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
}

.level-card .level-desc {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Video comparison ── */
.experiment-header {
  margin-bottom: 24px;
}

.experiment-header .exp-num {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--primary);
  margin-bottom: 6px;
}

.experiment-header h2 {
  font-size: 1.3rem;
  font-weight: 600;
}

.video-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

.video-grid.count-2 { grid-template-columns: 1fr 1fr; }
.video-grid.count-3 { grid-template-columns: 1fr 1fr 1fr; }
.video-grid.count-4 { grid-template-columns: 1fr 1fr; }

.video-option {
  border: 2.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  background: #000;
  position: relative;
}

.video-option:hover { border-color: var(--primary); }
.video-option.selected {
  border-color: var(--selected-border);
  box-shadow: 0 0 0 3px rgba(37,99,235,.18);
}

.video-option video {
  width: 100%;
  display: block;
  max-height: 340px;
  object-fit: contain;
  background: #111;
}

.video-label {
  background: var(--surface);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.video-label .label-letter {
  font-weight: 700;
  font-size: 1rem;
}

.video-label .check-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
}

.video-option.selected .check-icon {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.selected-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--primary);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}

.video-option.selected .selected-badge { opacity: 1; }

.selection-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: .88rem;
  margin-bottom: 8px;
}

/* ── Rating bar (shown on every comparison video) ── */
.rating-bar {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  background: var(--surface);
  justify-content: center;
  border-top: 1px solid var(--border);
}

.rating-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  color: var(--text);
}

.rating-btn:hover  { border-color: var(--primary); background: var(--primary-light); }
.rating-btn.rated  { border-color: var(--primary); background: var(--primary); color: #fff; }

/* ── Duet: English source text ── */
.source-box {
  background: var(--primary-light);
  border: 1px solid #dbeafe;
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 16px 20px;
}

.source-box .source-label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--primary);
  margin-bottom: 6px;
}

.source-box .source-text {
  font-size: 1.2rem;
  line-height: 1.45;
  color: var(--text);
}

.source-box .source-text.source-missing {
  font-style: italic;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ── Duet: per-video rating layout ── */
.video-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 20px;
}

.video-row {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  padding: 18px;
}

.vid-wrap { flex: 0 0 58%; max-width: 720px; position: sticky; top: 72px; align-self: flex-start; }

.vid-caption {
  font-weight: 700;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.vid-wrap video {
  width: 100%;
  display: block;
  max-height: 80vh;
  object-fit: contain;
  background: #111;
  border-radius: 10px;
}

.vid-questions {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.q-row { display: flex; flex-direction: column; gap: 8px; }

.q-text {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
}

.scale {
  display: flex;
  gap: 8px;
}

.scale-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}

.scale-btn .num { font-weight: 700; font-size: .95rem; color: var(--text); }
.scale-btn .lbl {
  font-size: .68rem;
  line-height: 1.15;
  text-align: center;
  color: var(--text-muted);
}

.scale-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.scale-btn.rated { border-color: var(--primary); background: var(--primary); }
.scale-btn.rated .num,
.scale-btn.rated .lbl { color: #fff; }

@media (max-width: 1000px) {
  .video-row { flex-direction: column; }
  .vid-wrap { flex: 0 0 auto; width: 100%; max-width: none; position: static; }
  .scale-btn .lbl { font-size: .6rem; }
}

/* ── Completion ── */
.complete-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  text-align: center;
}

.results-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  font-size: .85rem;
  font-family: monospace;
  max-height: 260px;
  overflow: auto;
  margin: 20px 0;
  color: var(--text-muted);
  white-space: pre;
}

/* ── Intro bullets ── */
.info-list {
  list-style: none;
  margin: 24px 0 32px;
}

.info-list li {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .95rem;
  line-height: 1.5;
}

.info-list li:last-child { border-bottom: none; }

.info-list .icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Utility ── */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

@media (max-width: 640px) {
  .card { padding: 32px 20px; }
  .video-grid.count-2,
  .video-grid.count-3,
  .video-grid.count-4 { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
  header { padding: 12px 16px; }
  .progress-bar-wrap { margin: 0 16px; }
}
