:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --panel: #fffdf8;
  --ink: #202124;
  --muted: #65615a;
  --line: #dfd8ca;
  --accent: #176d6a;
  --accent-strong: #0f5654;
  --warn: #9b3f2f;
  --ok: #2e7351;
  --shadow: 0 18px 50px rgba(48, 42, 32, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.home-shell,
.practice-shell {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.home-hero {
  padding: 24px 0 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 8vw, 4.8rem);
  line-height: 1;
  letter-spacing: 0;
}

.lead {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.level-card {
  min-height: 168px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 160ms ease, border-color 160ms ease;
}

.level-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.wide-card {
  grid-column: 1 / -1;
}

.level-name {
  font-size: 3rem;
  font-weight: 800;
}

.level-desc {
  color: var(--muted);
  font-weight: 600;
}

.topbar {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h1 {
  font-size: clamp(2rem, 7vw, 3.6rem);
}

.back-link {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
}

.practice-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.progress-row,
.bottom-row,
.action-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.progress-row {
  justify-content: space-between;
  color: var(--muted);
  font-weight: 700;
}

.listen-area {
  margin: 24px 0;
}

.voice-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  align-items: end;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7ef;
}

.voice-panel label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

select {
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.rate-control {
  display: grid;
  grid-template-columns: auto minmax(54px, auto) auto;
  gap: 8px;
  align-items: center;
}

.rate-control span {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.source-line,
.session-line {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.answer-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  line-height: 1.55;
}

textarea:focus {
  outline: 3px solid rgba(23, 109, 106, 0.18);
  border-color: var(--accent);
}

button {
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.primary-btn {
  width: 100%;
  min-height: 72px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 1.25rem;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.action-row {
  margin-top: 14px;
}

.bottom-row {
  margin-top: 18px;
}

.hint-box,
.answer-box,
.result-box,
.empty-state {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7ef;
}

.hint-box span,
.answer-box span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.hint-box p,
.answer-box p {
  margin: 0;
  line-height: 1.7;
}

.answer-box p {
  font-size: 1.1rem;
  font-weight: 800;
}

.result-box {
  color: var(--warn);
  font-weight: 800;
}

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

@media (max-width: 720px) {
  .home-shell,
  .practice-shell {
    width: min(100% - 24px, 960px);
    padding: 22px 0;
  }

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

  .level-card {
    min-height: 118px;
  }

  .topbar {
    display: block;
  }

  .back-link {
    display: inline-flex;
    align-items: center;
    margin-bottom: 16px;
  }

  .practice-panel {
    padding: 16px;
  }

  .voice-panel {
    grid-template-columns: 1fr;
  }

  .rate-control {
    grid-template-columns: 1fr minmax(54px, auto) 1fr;
  }

  .action-row button,
  .bottom-row button {
    flex: 1 1 130px;
  }
}
