:root {
  --ink: #1c1915;
  --muted: #6d655b;
  --paper: #fffef8;
  --bg: #efe8da;
  --line: #e4dccb;
  --blue: #1d4e89;
  --blue-down: #163a66;
  --pass: #146c43;
  --fail: #a32018;
  --hear: #8a5a12;
  --chip-good: #146c43;
  --chip-good-bg: rgba(61, 220, 151, 0.22);
  --chip-yellow: #8a5a12;
  --chip-yellow-bg: rgba(255, 193, 7, 0.26);
  --chip-bad: #a32018;
  --chip-bad-bg: rgba(255, 107, 122, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
}

body {
  padding: 20px 16px 48px;
}

body.auth-wait #app {
  visibility: hidden;
}

.top {
  max-width: 920px;
  margin: 0 auto 18px;
}

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lang-label select {
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d9d0c2;
  background: #fff;
  color: var(--ink);
}

.l1-beside {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
}

.l1-prompt {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
}

.brand {
  display: inline-block;
  color: inherit;
  text-decoration: none;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.model-label {
  margin: 10px 0 6px;
  font-size: 18px;
  color: var(--muted);
}

.track {
  height: 16px;
  background: #ddd4c4;
  border-radius: 999px;
  overflow: hidden;
}

#modelFill {
  height: 100%;
  width: 0%;
  background: var(--blue);
  border-radius: inherit;
}

.track.done { display: none; }
.model-label.done { display: none; }

#app {
  max-width: 920px;
  margin: 0 auto;
}

h1 {
  margin: 8px 0 6px;
  font-size: 40px;
  letter-spacing: -0.03em;
}

.lead {
  margin: 0 0 18px;
  font-size: 22px;
  color: var(--muted);
}

.books, .units {
  display: grid;
  gap: 12px;
}

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

@media (max-width: 640px) {
  .books { grid-template-columns: 1fr; }
}

.book, .unit, .back {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 84px;
  padding: 16px 20px;
  border: 0;
  border-radius: 18px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 28px;
  font-weight: 750;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
}

.book small, .unit small {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}

.back {
  min-height: 64px;
  margin-bottom: 14px;
  font-size: 22px;
  background: transparent;
  box-shadow: none;
  width: auto;
  padding-left: 0;
}

.sheet {
  background: var(--paper);
  border: 1px solid #e7dfd0;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(60, 40, 10, .08);
}

.shared-q {
  padding: 18px 18px 14px;
  border-bottom: 2px solid var(--line);
  background: #faf6ee;
}

.shared-q.done {
  background: #f3faf5;
}

.shared-q .en-prompt {
  margin: 0 0 10px;
  font-size: 30px;
  font-weight: 800;
  line-height: 1.25;
}

.shared-q .shared-note {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--muted);
}

.row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 8px 14px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.row:last-child { border-bottom: 0; }

.num {
  font-size: 28px;
  font-weight: 800;
  color: #9a907f;
}

.row-main {
  min-width: 0;
}

.ko-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ko-text {
  min-width: 0;
}

.row-pic {
  width: 88px;
  height: 88px;
  flex: 0 0 88px;
  border-radius: 12px;
  object-fit: cover;
  background: #efe8da;
}

.ko {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.25;
}

.row-parts {
  grid-column: 2 / -1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.part {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.part-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.part-text {
  margin: 2px 0 0;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.25;
}

.triple-hint {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--hear);
}

.mic, .hear {
  min-width: 112px;
  min-height: 72px;
  border: 0;
  border-radius: 16px;
  font: inherit;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
}

.mic {
  background: var(--blue);
  color: white;
}

.mic:active { background: var(--blue-down); }
.mic.live { background: var(--fail); }
.take-stop {
  min-width: 112px;
  min-height: 72px;
  border: 3px solid var(--fail);
  border-radius: 16px;
  background: white;
  color: var(--fail);
  font: inherit;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
}
.take-stop:active {
  background: var(--fail);
  color: white;
}
.mic:disabled, .hear:disabled {
  background: #d9d3c7;
  color: #6d655b;
  cursor: not-allowed;
}

.grade-bar {
  grid-column: 1 / -1;
  display: none;
  height: 14px;
  margin: 4px 0 2px 78px;
  background: #ddd4c4;
  border-radius: 999px;
  overflow: hidden;
}

.grade-bar.shared-grade {
  grid-column: auto;
  margin: 12px 0 0;
}

.grade-bar.show { display: block; }

.grade-fill {
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg, var(--blue), #3d7ab8, var(--blue));
  background-size: 200% 100%;
  border-radius: inherit;
  animation: grade-slide 0.9s ease-in-out infinite;
}

@keyframes grade-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.after {
  grid-column: 1 / -1;
  display: none;
  padding: 4px 0 6px 78px;
}

.after.show { display: block; }

.verdict {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 6px;
}

.verdict.pass { color: var(--pass); }
.verdict.pass.yellow { color: var(--chip-yellow); }
.verdict.fail { color: var(--fail); }

.retry-missed {
  color: var(--blue);
  font-weight: 800;
}

.meta, .english {
  margin: 0 0 8px;
  font-size: 22px;
}

.english b { font-size: 26px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
  align-items: flex-start;
}

.word-chip-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: 12rem;
}

.word-hint {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  color: var(--chip-bad);
}

.checking-line {
  margin: 8px 0 6px 78px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--blue);
}

.word-chip {
  border-radius: 999px;
  padding: 0.38rem 0.72rem;
  font-size: 1.05rem;
  font-weight: 800;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  background: white;
}

.word-chip.good,
.word-chip.green {
  background: var(--chip-good-bg);
  border-color: var(--chip-good);
  color: var(--chip-good);
}

.word-chip.yellow {
  background: var(--chip-yellow-bg);
  border-color: var(--chip-yellow);
  color: var(--chip-yellow);
}

.word-chip.bad,
.word-chip.red {
  background: var(--chip-bad-bg);
  border-color: var(--chip-bad);
  color: var(--chip-bad);
}

.hear {
  background: var(--hear);
  color: white;
}

.note {
  margin: 12px 0 0;
  font-size: 18px;
  color: var(--muted);
}

.ask-teacher {
  margin: 8px 0 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--fail);
}

.mic-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.got-it {
  color: var(--pass);
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
}

.not-yet {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fail);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.rush-x {
  font-size: 36px;
  line-height: 1;
}

.rush-checking {
  color: var(--blue);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.rush {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin: 0 0 14px;
}

.rush-banner {
  flex-basis: 100%;
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--blue);
}

body.phase-part2 {
  background: #c5d2e0;
}

body.phase-part2 .sheet {
  background: #f4f8fc;
  border: 4px solid #1d4e89;
  box-shadow: none;
}

body.phase-part2 .shared-q {
  background: #e7eef6;
}

body.phase-part2 .rush-clock {
  font-size: 84px;
  line-height: 0.9;
}

.rush-limit,
.rush-clock {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}

.rush-clock {
  min-width: 72px;
  color: var(--blue);
}

#rushStart,
#rushStop,
.gate-go {
  min-width: 140px;
  min-height: 72px;
  border: 0;
  border-radius: 16px;
  background: var(--blue);
  color: white;
  font: inherit;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
}

#rushStart:disabled {
  background: #d9d3c7;
  color: #6d655b;
  cursor: not-allowed;
}

.teacher-gate {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin: 0 0 14px;
}

.gate-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
}

.gate-label input {
  min-width: 220px;
  min-height: 64px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  font: inherit;
  font-size: 28px;
}

.gate-bad {
  flex-basis: 100%;
  margin: 0;
  color: var(--fail);
  font-size: 18px;
  font-weight: 700;
}

.row.teacher-row {
  grid-template-columns: 1fr auto;
}

.teacher-row .verdict {
  grid-column: 1 / -1;
  padding-left: 0;
}

.part-results {
  margin: 0 0 16px;
  padding: 18px 20px;
  border-radius: 18px;
  background: white;
}

.part-results h2 {
  margin: 0 0 8px;
  font-size: 32px;
}

.part-results p {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 750;
}

.part-results b {
  color: var(--fail);
}

/* Voice toggle (Coach Ray / Miss Harper) */
.voice-toggle { display: flex; gap: 8px; justify-content: center; margin: 6px 0; }
.voice-btn { font: inherit; font-size: 1rem; font-weight: 700; padding: 8px 14px; border-radius: 999px;
  border: 2px solid #c9d3e6; background: #fff; color: #334; cursor: pointer; }
.voice-btn.on { background: #ffd43b; border-color: #f59f00; color: #222; }
