:root {
  color-scheme: light;
  --ink: #2e3036;
  --muted: #6c7482;
  --line: #cfdced;
  --paper: #fffdf7;
  --paper-line: rgba(66, 124, 181, .14);
  --paper-red: rgba(220, 122, 122, .16);
  --mint: #e8f4eb;
  --mint-strong: #3f7659;
  --coral: #fff1e9;
  --coral-strong: #a4523b;
  --sky: #eef5fc;
  --sky-strong: #416eae;
  --cream: #fffaf0;
}
@font-face {
  font-family: "TobakBareun";
  src: url("fonts/Hakgyoansim_SangjangR.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
* { box-sizing: border-box; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "TobakBareun", "Malgun Gothic", system-ui, sans-serif;
  background: #fffaf0;
}
button, textarea { font: inherit; }
.app { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 26px 0 32px; }
.topbar, .progress-panel { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.topbar h1 { margin: 0; font-size: clamp(42px, 6vw, 72px); line-height: .95; letter-spacing: 0; }
.eyebrow { display: none; }
.mini-label { margin: 0; color: var(--muted); font-size: 17px; }
.score, .progress-panel > div { min-width: 112px; padding: 11px 14px; border: 2px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.82); text-align: center; }
.score span, .score strong, .progress-panel strong { display: block; }
.score span { color: #746b60; font-size: 20px; }
.score strong, .progress-panel strong { margin-top: 3px; font-size: 30px; color: var(--ink); }
.menu-panel { position: relative; z-index: 20; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 12px 0; align-items: start; }
.menu-section { position: relative; border: 2px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.96); }
.menu-section[open] { z-index: 30; }
.menu-section summary { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 18px; cursor: pointer; list-style: none; }
.menu-section summary::-webkit-details-marker { display: none; }
.menu-section summary::after { content: "▾"; color: var(--sky-strong); font-size: 16px; }
.menu-section[open] summary::after { content: "▴"; }
.menu-section summary span { font-size: 22px; color: #1f3761; }
.menu-section summary strong { color: #1f3761; font-size: 16px; text-align: right; }
.submenu-grid {
  position: absolute;
  top: calc(100% + 4px);
  left: -2px;
  right: -2px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: min(58vh, 420px);
  overflow-y: auto;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 28px rgba(42,81,130,.18);
}
.grade-button, .mode-button, .stage-button, .primary-button, .secondary-button, .icon-button { min-height: 52px; border: 2px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.82); color: var(--ink); padding: 10px 14px; cursor: pointer; font-size: 20px; }
.grade-button.active, .mode-button.active, .stage-button.active { border-color: var(--sky-strong); background: #eef5fc; color: #1f3761; }
.card { margin-top: 20px; min-height: 520px; padding: clamp(22px, 4vw, 42px); border: 2px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.82); box-shadow: 0 16px 42px rgba(42,81,130,.08); }
.question-meta { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; }
#categoryLabel { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 18px; border-radius: 999px; background: var(--mint); color: var(--mint-strong); font-size: 20px; }
.icon-button { min-width: 76px; min-height: 48px; padding: 8px 12px; background: #fff; color: #1f3761; border-color: var(--sky-strong); font-size: 18px; }
.listen-tools { display: flex; align-items: center; justify-content: center; flex-wrap: nowrap; gap: 8px; }
.speed-control { display: grid; grid-template-columns: auto auto; align-items: center; gap: 6px; color: var(--ink); font-size: 16px; }
.speed-control > span { display: none; }
.speed-arrows { display: grid; gap: 1px; }
.speed-arrow { width: 34px; height: 24px; padding: 0; border: 1px solid #1d5f7f; border-radius: 3px; background: #3e91b8; color: #103d56; line-height: 1; cursor: pointer; }
.speed-arrow:first-child { clip-path: polygon(50% 8%, 95% 92%, 5% 92%); }
.speed-arrow:last-child { clip-path: polygon(5% 8%, 95% 8%, 50% 92%); }
#speedValueLabel { min-width: 28px; color: var(--sky-strong); font-size: 15px; text-align: right; }
#questionTitle { margin: 14px 0 0; font-size: clamp(14px, 1.9vw, 20px); line-height: 1.25; letter-spacing: 0; }
.question-text {
  min-height: 96px;
  margin: 16px 0 22px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 0 40px, var(--paper-red) 40px 42px, transparent 42px),
    repeating-linear-gradient(90deg, transparent 0 52px, var(--paper-line) 52px 53px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.95) 0 47px, var(--paper-line) 47px 48px);
  line-height: 1.65;
  font-size: clamp(15px, 2vw, 22px);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.blank { display: inline-block; min-width: 106px; border-bottom: 4px solid var(--ink); transform: translateY(-4px); }
.choices {
  counter-reset: choice;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.choice {
  counter-increment: choice;
  min-height: 64px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.78);
  padding: 14px 16px;
  font-family: system-ui, "Noto Sans CJK KR", "Noto Sans KR", "Droid Sans", "Malgun Gothic", sans-serif;
  font-weight: 700;
  font-size: clamp(14px, 2.7vw, 20px);
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.choice::before {
  content: counter(choice) ".";
  min-width: 28px;
  color: var(--sky-strong);
}
.choice-text {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.choice.correct { border-color: var(--mint-strong); background: var(--mint); color: var(--mint-strong); }
.choice.wrong { border-color: var(--coral-strong); background: var(--coral); color: var(--coral-strong); }
.answer-form { display: none; gap: 10px; }
.answer-form.show { display: grid; }
.answer-form label { color: var(--muted); }
textarea { width: 100%; min-height: 134px; resize: vertical; padding: 16px; border: 2px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.86); color: var(--ink); font-size: clamp(24px, 3.2vw, 34px); line-height: 1.55; }
textarea:focus { outline: none; border-color: var(--sky-strong); box-shadow: 0 0 0 4px rgba(63,120,170,.12); }
.primary-button { border-color: var(--ink); background: var(--ink); color: #fff; }
.secondary-button { background: var(--cream); color: var(--ink); border-color: var(--line); }
.feedback { min-height: 72px; margin-top: 14px; padding: 14px; border-radius: 8px; background: var(--sky); color: var(--sky-strong); line-height: 1.6; font-size: 18px; }
.feedback.correct { background: var(--mint); color: var(--mint-strong); }
.feedback.wrong { background: var(--coral); color: var(--coral-strong); }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions button { flex: 1; }
.progress-panel { margin-top: 14px; align-items: stretch; }
.progress-panel > div { flex: 1; }
@media (max-width: 680px) {
  .topbar, .progress-panel { display: grid; grid-template-columns: 1fr; }
  .score { display: flex; justify-content: space-between; width: 100%; text-align: left; }
  .menu-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .menu-section summary { min-height: 52px; justify-content: center; padding: 8px 6px; }
  .menu-section summary span { display: none; }
  .menu-section summary strong { min-width: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
  .menu-section summary::after { flex: 0 0 auto; font-size: 12px; }
  .submenu-grid { gap: 6px; padding: 7px; }
  #questionTitle { font-size: clamp(14px, 4.1vw, 18px); line-height: 1.22; }
  .question-text { font-size: clamp(14px, 3.9vw, 20px); line-height: 1.5; }
  .choices { grid-template-columns: 1fr; }
  .choice { font-size: clamp(14px, 4.2vw, 19px); }
  .grade-button, .mode-button, .stage-button { width: 100%; min-height: 46px; padding: 8px 4px; font-size: 16px; }
}
