:root {
  --bg: #eef2f7;
  --bg-2: #f8fafc;
  --card: rgba(255, 255, 255, 0.94);
  --text: #0f172a;
  --muted: #64748b;
  --border: #d8e0ec;
  --border-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #dbeafe;
  --ok: #047857;
  --ok-soft: #d1fae5;
  --bad: #b42318;
  --bad-soft: #fee2e2;
  --warn: #a16207;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.11);
  --radius: 22px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, .20), transparent 30%),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(15, 23, 42, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(15, 23, 42, .035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
}

.container {
  position: relative;
  width: min(1060px, calc(100% - 28px));
  margin: 0 auto;
  padding: 26px 0 46px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: end;
  margin-bottom: 20px;
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.04;
  margin: 0 0 10px;
  letter-spacing: -0.04em;
}

.subtitle {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-card {
  min-width: 190px;
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: 18px;
  border: 1px solid rgba(37, 99, 235, .18);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(37, 99, 235, .11), rgba(255, 255, 255, .84));
  box-shadow: 0 12px 30px rgba(37, 99, 235, .12);
}

.hero-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: 1.35rem;
}

.hero-card strong { font-size: 1.05rem; }
.hero-card small { color: var(--muted); font-weight: 700; }

.card {
  background: var(--card);
  border: 1px solid rgba(203, 213, 225, .85);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  margin-bottom: 18px;
}

.setup-card {
  display: grid;
  gap: 16px;
}

.controls-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
}

label {
  display: block;
  font-weight: 800;
  margin-bottom: 7px;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 15px;
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  outline: none;
}

select:focus,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .22);
  outline-offset: 2px;
}

button {
  border: 0;
  border-radius: 15px;
  padding: 13px 16px;
  font-weight: 900;
  font-size: 1rem;
  cursor: pointer;
  background: #e8edf6;
  color: var(--text);
  transition: transform .06s ease, background .16s ease, box-shadow .16s ease, opacity .16s ease;
}

button:hover:not(:disabled) {
  background: #dfe7f3;
}

button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }

.primary {
  min-height: 50px;
  background: linear-gradient(135deg, var(--accent), #1546c7);
  color: #fff;
  box-shadow: 0 12px 22px rgba(37, 99, 235, .25);
}

.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-dark), #153da9);
}

.start-button {
  min-width: 170px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(248, 250, 252, .86);
  color: #334155;
  font-size: .94rem;
  font-weight: 800;
}

.check input { transform: scale(1.18); accent-color: var(--accent); }

.voice-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: rgba(248, 250, 252, .82);
}

.range-label {
  margin: 0;
  color: #334155;
}

input[type="range"] { accent-color: var(--accent); }

.mic-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(100, 116, 139, .24);
  border-radius: 19px;
  background: linear-gradient(135deg, rgba(15, 23, 42, .035), rgba(255, 255, 255, .78));
}

.mic-panel.on {
  border-color: rgba(4, 120, 87, .30);
  background: linear-gradient(135deg, rgba(209, 250, 229, .72), rgba(255, 255, 255, .88));
}

.mic-panel.listening {
  box-shadow: 0 0 0 4px rgba(4, 120, 87, .08);
}

.mic-light {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 0 6px rgba(148, 163, 184, .16);
}

.mic-light.on {
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(4, 120, 87, .15);
}

.mic-light.listening {
  animation: pulse 1.1s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(4, 120, 87, .35); }
  70% { box-shadow: 0 0 0 10px rgba(4, 120, 87, 0); }
  100% { box-shadow: 0 0 0 0 rgba(4, 120, 87, 0); }
}

.mic-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.mic-copy strong { font-size: 1rem; }
.mic-copy span { color: var(--muted); font-size: .94rem; }

.mic-button {
  background: #0f172a;
  color: #fff;
  white-space: nowrap;
}

.mic-button:hover:not(:disabled) { background: #1e293b; }

.total-info {
  margin-top: 10px;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 700;
}

.study-card {
  padding: 24px;
}

.study-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.study-header h2 {
  margin: 0;
  font-size: clamp(1.1rem, 2.3vw, 1.45rem);
  letter-spacing: -0.02em;
}

.counter {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #1e40af;
  font-weight: 900;
  white-space: nowrap;
}

.question {
  position: relative;
  font-size: clamp(1.35rem, 3.5vw, 2.18rem);
  line-height: 1.22;
  font-weight: 950;
  letter-spacing: -0.03em;
  margin: 18px 0 18px;
  padding: 20px;
  border-radius: 20px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.options-list {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  display: grid;
  gap: 11px;
}

.options-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: #ffffff;
  font-size: 1.03rem;
  line-height: 1.35;
}

.option-letter {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 950;
}

.options-list li.correct {
  border-color: rgba(4, 120, 87, .35);
  background: var(--ok-soft);
}

.options-list li.correct .option-letter {
  background: var(--ok);
  color: #fff;
}

.options-list li.wrong {
  border-color: rgba(180, 35, 24, .35);
  background: var(--bad-soft);
}

.options-list li.wrong .option-letter {
  background: var(--bad);
  color: #fff;
}

.options-list li.selected:not(.correct):not(.wrong) {
  border-color: rgba(37, 99, 235, .35);
}

.answer-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 11px;
  margin: 16px 0 14px;
}

.answer-btn {
  min-height: 68px;
  font-size: 1.8rem;
  background: #0f172a;
  color: #fff;
  box-shadow: 0 12px 22px rgba(15, 23, 42, .16);
}

.answer-btn:hover:not(:disabled) {
  background: #1e293b;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.result {
  min-height: 34px;
  display: flex;
  align-items: center;
  border-radius: 15px;
  font-size: 1.08rem;
  font-weight: 950;
  margin-top: 12px;
}

.result.ok {
  color: var(--ok);
}

.result.bad {
  color: var(--bad);
}

.status {
  color: var(--muted);
  min-height: 24px;
  font-weight: 700;
}

.status.error { color: var(--bad); font-weight: 900; }
.status.warn { color: var(--warn); font-weight: 900; }

.heard {
  color: var(--muted);
  font-size: .95rem;
  margin-top: 6px;
  min-height: 22px;
  font-weight: 700;
}

.help {
  color: var(--muted);
  margin: 0;
  font-size: .95rem;
  line-height: 1.45;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 34px 18px;
  display: grid;
  gap: 8px;
  place-items: center;
}

.empty strong { color: var(--text); font-size: 1.1rem; }
.empty-icon { font-size: 2rem; }

.kbd {
  display: inline-block;
  font-weight: 950;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 8px;
  padding: 1px 7px;
  background: #fff;
  color: var(--text);
}

@media (max-width: 900px) {
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .container {
    width: min(100% - 18px, 1060px);
    padding-top: 14px;
  }

  .hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .hero-card {
    width: 100%;
  }

  .controls-grid,
  .voice-row,
  .mic-panel {
    grid-template-columns: 1fr;
  }

  .start-button,
  .mic-button {
    width: 100%;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .study-header {
    flex-direction: column;
  }

  .counter {
    white-space: normal;
  }

  .question {
    padding: 16px;
  }

  .answer-buttons {
    grid-template-columns: repeat(2, minmax(80px, 1fr));
  }

  .actions button {
    flex: 1 1 46%;
  }
}
