:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e6e6e6;
  --line-strong: #d4d4d4;
  --wash: #fafafa;
  --radius: 12px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  padding: clamp(24px, 5vw, 64px) clamp(16px, 5vw, 40px) 48px;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: min(1000px, 100%);
  margin: 0 auto;
}

/* ---------- hero ---------- */

.hero {
  max-width: 620px;
  margin-bottom: clamp(24px, 4vw, 40px);
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 600;
}

.lede {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
  max-width: 58ch;
}
.lede strong { color: var(--text); font-weight: 500; }

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

.board {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 18px;
}

/* ---------- stage ---------- */

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 18px;
}
.tab {
  appearance: none;
  border: 0;
  background: none;
  padding: 0 0 6px;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1.5px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}
.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
}
.status.is-ready::before { background: #16a34a; }
.status.is-error { color: #b91c1c; }
.status.is-error::before { background: #dc2626; }

.viewport {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--wash);
  display: grid;
  place-items: center;
}

.viewport video,
.viewport img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.viewport video.is-live,
.viewport img.is-live { display: block; }
.viewport video { transform: scaleX(-1); }

.empty {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px;
  max-width: 32ch;
  color: var(--muted);
}
.empty p { margin: 10px 0 0; font-size: 13.5px; }
.empty strong { color: var(--text); font-weight: 500; }
.empty-icon { font-size: 22px; color: var(--faint); }
.empty.is-hidden { display: none; }

.badge {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  font-size: 12px;
  font-weight: 500;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
}
.badge.tone-good::before { background: #16a34a; }
.badge.tone-warn::before { background: #d97706; }

.stage-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  padding: 8px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn:hover:not(:disabled) { background: var(--wash); border-color: var(--muted); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}
.btn.primary:hover:not(:disabled) { background: #000; border-color: #000; }

.file-btn { position: relative; overflow: hidden; }

.toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--text); width: 14px; height: 14px; }

/* ---------- results ---------- */

.results h2 {
  margin: 0 0 14px;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 500;
}

.verdict {
  margin: 0;
  font-size: clamp(26px, 3.4vw, 32px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--faint);
}
.verdict.tone-good { color: var(--text); }
.verdict.tone-warn { color: var(--text); }

.verdict-sub {
  margin: 6px 0 22px;
  font-size: 13px;
  color: var(--muted);
  min-height: 1.4em;
}

.bars {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: grid;
  gap: 14px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 13.5px;
}
.bar-name { font-weight: 500; }
.bar-val {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12.5px;
}

.bar-track {
  height: 4px;
  border-radius: 2px;
  background: #efefef;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: var(--text);
  transition: width 0.18s ease;
}
.bar:nth-child(2) .bar-fill { background: #b8b8b8; }

.meta {
  margin: 0 0 16px;
  border-top: 1px solid var(--line);
}
.meta > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.meta dt { color: var(--muted); }
.meta dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.meta a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.meta a:hover { border-bottom-color: var(--text); }

.hint {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--wash);
}

/* ---------- footer ---------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--faint);
}
.foot a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
.foot a:hover { color: var(--text); }

@media (max-width: 840px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  .toggle { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
