* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #e2e8f0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.container {
  max-width: 720px;
  width: 100%;
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 1.25rem;
  padding: 2rem;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}
h1 { font-size: 1.75rem; letter-spacing: -0.02em; margin-bottom: 0.25rem; }
.subtitle { color: #94a3b8; font-size: 0.95rem; margin-bottom: 1.25rem; }
.status-bar {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #334155;
  color: #cbd5e1;
  margin-bottom: 1rem;
  border: 1px solid rgba(255,255,255,0.05);
}
.btn {
  background: #22d3ee;
  color: #0f172a;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: 0.6rem;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 14px rgba(34,211,238,0.25);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(34,211,238,0.35); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.5rem; }
.panel { background: rgba(15,23,42,0.6); border: 1px solid rgba(255,255,255,0.05); border-radius: 0.75rem; padding: 1rem; }
.panel h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; margin-bottom: 0.5rem; }
.transcript-box { min-height: 120px; background: rgba(2,6,23,0.5); border-radius: 0.5rem; padding: 0.75rem; color: #e2e8f0; font-size: 0.95rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.log { margin-top: 1.25rem; padding: 0.75rem; background: rgba(2,6,23,0.4); border-radius: 0.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; color: #cbd5e1; min-height: 80px; max-height: 160px; overflow-y: auto; white-space: pre-wrap; border: 1px solid rgba(255,255,255,0.05); }
/* M1 additions */
.container > .panel { margin-top: 1rem; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.btn-small { padding: 0.45rem 0.9rem; font-size: 0.85rem; }
.prompt-panel { border-color: rgba(34,211,238,0.25); }
.prompt-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.25rem; }
.prompt-objective { color: #cbd5e1; font-size: 0.92rem; line-height: 1.45; }
.hint { margin-top: 0.5rem; font-size: 0.82rem; color: #94a3b8; }
.feedback h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; margin: 0.6rem 0 0.25rem; }
.feedback h3:first-child { margin-top: 0; }
.feedback ul { margin-left: 1.1rem; font-size: 0.9rem; line-height: 1.5; }
.feedback li { margin-bottom: 0.2rem; }
.feedback .metrics { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.feedback .metric { background: rgba(2,6,23,0.5); border: 1px solid rgba(255,255,255,0.06); border-radius: 0.4rem; padding: 0.25rem 0.55rem; font-size: 0.8rem; }
.feedback .retry-focus { background: rgba(34,211,238,0.12); border: 1px solid rgba(34,211,238,0.35); border-radius: 0.5rem; padding: 0.5rem 0.7rem; font-size: 0.9rem; margin-top: 0.6rem; }
.cmp-good { color: #4ade80; }
.cmp-bad { color: #f87171; }
.cmp-same { color: #cbd5e1; }
/* Skill bars + replay quotes */
.skill-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; font-size: 0.85rem; }
.skill-name { flex: 0 0 130px; }
.skill-bar { flex: 1; height: 8px; background: rgba(2,6,23,0.6); border-radius: 999px; overflow: hidden; }
.skill-fill { display: block; height: 100%; border-radius: 999px; }
.skill-fill.cmp-good { background: #4ade80; }
.skill-fill.cmp-bad { background: #f87171; }
.skill-fill.cmp-same { background: #94a3b8; }
.replay { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 0.5rem; }
.replay blockquote {
  margin: 0;
  padding: 0.5rem 0.65rem;
  background: rgba(2,6,23,0.5);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.45;
  border-left: 3px solid #94a3b8;
}
.replay blockquote.after { border-left-color: #4ade80; }
.replay cite { display: block; font-style: normal; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; margin-bottom: 0.2rem; }
@media (max-width: 640px) { .replay { grid-template-columns: 1fr; } .skill-name { flex-basis: 100px; } }
/* M1 mode + attempt-state indicators (additive) */
.mode-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #22d3ee;
  background: rgba(34,211,238,0.12);
  border: 1px solid rgba(34,211,238,0.35);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  vertical-align: middle;
  white-space: nowrap;
}
.state-pill {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #cbd5e1;
  background: #334155;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  white-space: nowrap;
}
.state-pill.state-active { color: #22d3ee; border-color: rgba(34,211,238,0.5); }
/* Polish batch: timers, pulse, motion, focus */
.timer-pill {
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
  background: #22d3ee;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  white-space: nowrap;
}
.timer-pill:empty { display: none; }
@keyframes statePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,211,238,0.45); }
  50% { box-shadow: 0 0 0 6px rgba(34,211,238,0); }
}
.state-pill.state-active { animation: statePulse 1.6s ease-in-out infinite; }
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.feedback, .thread-msg { animation: fadeSlideIn 0.25s ease-out; }
.btn:focus-visible, button:focus-visible, select:focus-visible {
  outline: 2px solid #22d3ee;
  outline-offset: 2px;
}
h1 {
  background: linear-gradient(90deg, #e2e8f0 60%, #67e8f9);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
h1 .mode-label { -webkit-text-fill-color: #22d3ee; }
.panel { transition: border-color 0.2s ease; }
.transcript-box:empty::before {
  content: '…';
  color: #475569;
}
#welcomePanel { border-color: rgba(34,211,238,0.25); }
#cameraPreview { border-radius: 0.5rem; border: 1px solid rgba(255,255,255,0.08); margin-top: 0.5rem; }
.cam-wrap { position: relative; display: inline-block; margin-top: 0.5rem; }
.cam-wrap #cameraPreview { margin-top: 0; }
#faceOverlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* Detection composite: the exact frame the detector received, with dots
   drawn on it. Internal pixels are set per frame; CSS only scales. */
#snapshotPreview { border-radius: 0.5rem; border: 1px solid rgba(255,255,255,0.08); margin-top: 0.5rem; max-width: 100%; height: auto; }
/* Coach Engine selector */
.engine-row { align-items: center; }
.engine-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; font-weight: 700; }
.engine-option { font-size: 0.88rem; font-weight: 600; color: #e2e8f0; display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.engine-option input { accent-color: #22d3ee; }
.engine-option input:disabled + span, .engine-option:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
/* Debate mode (additive) */
#motionSelect, #roleSelect {
  background: rgba(2,6,23,0.5);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.5rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
  max-width: 100%;
}
#debateThread { max-height: 320px; overflow-y: auto; margin-bottom: 0.5rem; }
.thread-msg {
  background: rgba(2,6,23,0.5);
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.thread-msg.user { border-left: 3px solid #22d3ee; }
.thread-msg.opponent { border-left: 3px solid #f59e0b; }
.mode-tab-active { outline: 2px solid #22d3ee; }
.journey {
  color: #67e8f9;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  margin: -0.5rem 0 1rem;
}
@media (max-width: 640px) { .panels { grid-template-columns: 1fr; } }
/* Mobile pass: touch targets, tighter chrome, readable threads */
@media (max-width: 640px) {
  body { padding: 0.75rem; }
  .container { padding: 1.1rem; border-radius: 0.9rem; }
  h1 { font-size: 1.35rem; }
  .btn { padding: 0.7rem 1.1rem; font-size: 0.95rem; min-height: 44px; }
  .btn-small { min-height: 42px; }
  #debateThread { max-height: 220px; }
  #cameraPreview { max-width: 100%; height: auto; }
  #motionSelect, #roleSelect { width: 100%; }
  .transcript-box { min-height: 90px; font-size: 0.9rem; }
  .log { max-height: 110px; }
}
/* Final polish: collapsible log, reduced motion */
.log-wrap { margin-top: 1.25rem; }
.log-wrap summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: #94a3b8;
  padding: 0.25rem 0;
  user-select: none;
}
.log-wrap summary::marker { color: #22d3ee; }
.log-wrap .log { margin-top: 0.5rem; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
