:root {
  --bg: #f4f7f5;
  --ink: #17211c;
  --muted: #617067;
  --line: #dbe3dc;
  --panel: #ffffff;
  --accent: #0b6b5b;
  --accent-2: #a33d2f;
  --accent-3: #e7b84b;
  --good: #0f7b4f;
  --bad: #b83b35;
  font-family: "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px) 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 10px;
  min-width: 280px;
}

.stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
}

.stats strong {
  display: block;
  font-size: 24px;
}

.stats span {
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  padding: 18px clamp(18px, 4vw, 48px) 40px;
}

.sidebar,
.quiz {
  min-width: 0;
}

.panel,
.question-card,
.term-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel {
  margin-bottom: 14px;
  padding: 16px;
}

.panel h2 {
  margin-bottom: 12px;
  font-size: 17px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented button,
.secondary,
.ghost,
.primary {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.segmented button.active,
.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.field,
.check {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.field select {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.check {
  grid-template-columns: 18px 1fr;
  align-items: center;
}

.primary,
.secondary,
.ghost {
  width: 100%;
  margin-top: 8px;
  padding: 0 14px;
}

.secondary {
  border-color: #a7bbb2;
  background: #eef5f1;
}

.ghost {
  color: var(--muted);
}

.progress {
  display: grid;
  gap: 8px;
}

.progress div {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eeea;
}

.progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-3);
}

.mini-stat {
  margin: 12px 0 4px;
  color: var(--accent-2);
  font-size: 14px;
  font-weight: 700;
}

.quiz-head,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.quiz-head span {
  color: var(--muted);
  font-weight: 700;
}

.question-card {
  min-height: 390px;
  padding: clamp(18px, 3vw, 28px);
}

#questionText {
  min-height: 92px;
  margin-bottom: 22px;
  white-space: pre-line;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.38;
  letter-spacing: 0;
}

.answers {
  display: grid;
  gap: 10px;
}

.answer {
  min-height: 54px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  text-align: left;
  line-height: 1.45;
}

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

.answer.correct {
  border-color: var(--good);
  background: #e8f5ef;
}

.answer.wrong {
  border-color: var(--bad);
  background: #fae9e7;
}

.feedback {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef2f6;
  color: #26384b;
  font-weight: 700;
}

.feedback.good {
  background: #e8f5ef;
  color: var(--good);
}

.feedback.bad {
  background: #fae9e7;
  color: var(--bad);
}

.actions {
  margin-top: 12px;
}

.actions button {
  width: auto;
  min-width: 130px;
}

.term-detail {
  margin-top: 14px;
  padding: 18px;
}

.term-detail h3 {
  margin-bottom: 10px;
  font-size: 22px;
}

.term-detail p {
  color: var(--muted);
  line-height: 1.65;
}

dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: 80vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

.dialog-head {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.dialog-head h2 {
  margin: 0;
}

.dialog-head button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.review-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.review-list article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.review-list p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.review-list small {
  display: block;
  margin-top: 4px;
  color: var(--accent-2);
  font-weight: 700;
}

@media (max-width: 900px) {
  .topbar {
    display: grid;
    align-items: start;
  }

  .stats {
    width: 100%;
    min-width: 0;
  }

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

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions button {
    width: 100%;
  }
}
