:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #5f5e5a;
  --text-tertiary: #888780;
  --border: rgba(0,0,0,0.10);
  --border-strong: rgba(0,0,0,0.20);
  --accent: #185FA5;
  --accent-bg: #E6F1FB;
  --accent-text: #0C447C;
  --success: #3B6D11;
  --success-bg: #EAF3DE;
  --warning: #BA7517;
  --warning-bg: #FAEEDA;
  --danger: #A32D2D;
  --danger-bg: #FCEBEB;
  --radius-md: 8px;
  --radius-lg: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}
.app { min-height: 100vh; }
.shell { max-width: 760px; margin: 0 auto; padding: 2.5rem 1.5rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 0.5px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.brand-mark {
  width: 28px; height: 28px;
  background: var(--text-primary);
  color: var(--surface);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
}
.brand-mark svg { width: 14px; height: 14px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 500;
  display: flex; align-items: center; justify-content: center;
}

.steps { display: flex; gap: 8px; margin-bottom: 2rem; }
.step { flex: 1; }
.step-line {
  height: 3px;
  background: #d8d6cd;
  border-radius: 2px;
  margin-bottom: 8px;
  transition: background 0.3s;
}
.step.done .step-line { background: var(--success); }
.step.active .step-line { background: var(--accent); }
.step-label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; }
.step.active .step-label { color: var(--text-primary); font-weight: 500; }
.step.done .step-label { color: var(--text-secondary); }

.card-main {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  padding: 2.25rem 2.25rem;
}

.module-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px;
  color: var(--accent-text);
  background: var(--accent-bg);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}
.module-tag svg { width: 14px; height: 14px; }

h1.title {
  font-size: 26px;
  font-weight: 500;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}
.subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin: 0 0 1.75rem;
  line-height: 1.6;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.timer-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  background: #ebe9e0;
  padding: 5px 11px;
  border-radius: var(--radius-md);
  font-variant-numeric: tabular-nums;
}
.timer-pill.warning { background: var(--warning-bg); color: var(--warning); }
.timer-pill.danger { background: var(--danger-bg); color: var(--danger); }
.timer-pill svg { width: 14px; height: 14px; }

.qblock { margin-bottom: 1.5rem; }
.qhead { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.qnum { font-size: 13px; color: var(--text-tertiary); font-weight: 500; min-width: 24px; }
.qtext { font-size: 15px; font-weight: 500; line-height: 1.5; color: var(--text-primary); flex: 1; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.options.single-col { grid-template-columns: 1fr; }
.opt {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--surface);
  transition: all 0.12s;
  font-size: 14px;
  user-select: none;
}
.opt:hover { border-color: var(--border-strong); background: #fafaf6; }
.opt.sel { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-text); }
.opt-key {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 0.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-secondary); font-weight: 500;
  flex-shrink: 0;
}
.opt.sel .opt-key { background: var(--accent); color: white; border-color: var(--accent); }

.footer-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 0.5px solid var(--border);
  gap: 12px; flex-wrap: wrap;
}
.progress-text { font-size: 13px; color: var(--text-secondary); }
.btn-primary {
  background: var(--text-primary);
  color: var(--surface);
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary svg { width: 14px; height: 14px; }
.hidden { display: none !important; }

.welcome-wrap { text-align: center; padding: 2rem 1rem; }
.welcome-wrap h1 { font-size: 32px; font-weight: 500; margin: 0 0 1rem; letter-spacing: -0.02em; }
.welcome-wrap p.lead { font-size: 17px; color: var(--text-secondary); max-width: 480px; margin: 0 auto 2rem; line-height: 1.6; }
.welcome-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  max-width: 560px;
  margin: 0 auto 2.5rem;
}
.welcome-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: left;
}
.welcome-card-num { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.welcome-card-title { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.welcome-card-meta { font-size: 12px; color: var(--text-secondary); }

.typing-target {
  background: #f9f7f0;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.9;
  margin-bottom: 12px;
  border: 0.5px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}
.tc.ok { color: var(--success); }
.tc.bad { color: var(--danger); background: var(--danger-bg); }
textarea {
  width: 100%;
  min-height: 130px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  resize: vertical;
  line-height: 1.6;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

.typing-meta { font-size: 13px; color: var(--text-secondary); margin-top: 8px; display: flex; justify-content: space-between; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { background: #f9f7f0; padding: 12px 14px; border-radius: var(--radius-md); }
.stat-l { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-v { font-size: 22px; font-weight: 500; font-variant-numeric: tabular-nums; }

.tp-bar { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }
.tp-bar b { color: var(--text-primary); font-weight: 500; font-variant-numeric: tabular-nums; }
.tp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 360px; margin: 1rem auto; }
.tp-cell {
  aspect-ratio: 1;
  background: #ebe9e0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.08s;
  border: 0.5px solid var(--border);
}
.tp-cell:hover { background: #d8d6cd; }
.tp-cell.green { background: #97C459; border-color: var(--success); }
.tp-cell.miss { background: #F09595; animation: flash 0.25s; }
@keyframes flash { 0% { background: #F09595; } 100% { background: #ebe9e0; } }
.tp-actions { text-align: center; margin-top: 1rem; }

.scenario {
  background: var(--accent-bg);
  color: var(--accent-text);
  padding: 16px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.7;
  border-left: 3px solid var(--accent);
}
.scenario b { color: var(--accent-text); font-weight: 600; }

.section-divider {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 2rem 0 1rem;
  font-weight: 500;
}
.section-divider:first-child { margin-top: 0; }

.end-wrap { text-align: center; padding: 3rem 1rem; }
.end-check {
  width: 64px; height: 64px;
  background: var(--success-bg);
  color: var(--success);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.5rem;
}
.end-check svg { width: 32px; height: 32px; }
.end-wrap h1 { font-size: 28px; font-weight: 500; margin: 0 0 0.75rem; letter-spacing: -0.01em; }
.end-wrap p { font-size: 16px; color: var(--text-secondary); max-width: 420px; margin: 0 auto; }

.error-banner {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin: 1rem auto 0;
  max-width: 400px;
  display: none;
}
.error-banner.show { display: block; }

.saving-pill {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  display: none;
  align-items: center; gap: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  z-index: 50;
}
.saving-pill.show { display: flex; }
.saving-pill.success { color: var(--success); }
.saving-pill.error { color: var(--danger); }
.saving-pill svg { width: 12px; height: 12px; }

.loading-screen {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-secondary);
}

@media (max-width: 600px) {
  .shell { padding: 1.5rem 1rem; }
  .card-main { padding: 1.5rem 1.25rem; }
  .options { grid-template-columns: 1fr; }
  .step-label { font-size: 0; }
  .step.active .step-label, .step.done .step-label { font-size: 11px; }
}