:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --text: #17201c;
  --muted: #68756f;
  --line: #dbe3dd;
  --accent: #2f7d68;
  --accent-strong: #1d5d4d;
  --accent-soft: #dff0ea;
  --warn: #c57922;
  --danger: #b8403d;
  --shadow: 0 18px 45px rgba(28, 45, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Pretendard", "Noto Sans KR", system-ui, sans-serif;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #10251f;
  color: #eef7f3;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #e6fff4;
  color: #0d3e33;
  font-size: 28px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #a9bdb5;
  margin-top: 3px;
}

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

.nav-item {
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  background: transparent;
  color: #c9d9d3;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.main {
  padding: 28px;
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.topbar,
.step-head,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 22px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 320px minmax(300px, 1fr);
  gap: 18px;
  align-items: stretch;
}

.panel,
.study-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.study-panel {
  padding: 24px;
  min-height: 640px;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.choice-btn,
.eval-btn {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-btn {
  background: var(--accent);
  color: white;
}

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

.ghost-btn {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--text);
}

.danger-btn {
  background: #fff1ef;
  border-color: #f3c7c1;
  color: var(--danger);
}

.full {
  width: 100%;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.progress-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

.stats-panel {
  grid-column: 1 / -1;
}

.split-progress {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-content: space-evenly;
  min-height: 100%;
}

.progress-block {
  display: grid;
  justify-items: center;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  text-align: center;
}

.progress-block p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.progress-ring {
  position: relative;
  width: 118px;
  height: 118px;
}

.progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring circle {
  fill: none;
  stroke-width: 12;
}

.ring-bg {
  stroke: #e7ece8;
}

.ring-fg {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 0.25s ease;
}

.progress-ring strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 22px;
}

.split-label {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 4px 9px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
}

.quest-list {
  display: grid;
  gap: 10px;
}

.quest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--text);
  text-align: left;
}

.quest-item.done {
  background: var(--accent-soft);
  border-color: #b8ddd0;
}

.quest-item.active {
  border-color: var(--accent);
}

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

.quest-item small {
  color: var(--muted);
}

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

.stat {
  padding: 16px;
  border-radius: 8px;
  background: #f8faf7;
  border: 1px solid var(--line);
}

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

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

.learn-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
}

.side-progress {
  position: sticky;
  top: 28px;
  height: fit-content;
}

.study-content {
  display: grid;
  place-items: center;
  min-height: 440px;
  padding: 22px 0;
}

.kana-display {
  text-align: center;
}

.big-kana {
  display: block;
  font-size: 150px;
  line-height: 1;
  font-weight: 900;
}

.pronounce {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.pronounce span {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.mix-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 96px));
  justify-content: center;
  gap: 12px;
  width: min(100%, 520px);
  margin-top: 10px;
}

.mix-round-label {
  width: min(100%, 520px);
  margin: 0 auto 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  text-align: left;
}

.mix-board span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  font-size: 58px;
  font-weight: 900;
}

.test-board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: min(100%, 760px);
  margin-top: 10px;
}

.test-board span {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  font-size: 38px;
  font-weight: 900;
}

.answer-strip span,
.answer-strip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  padding: 6px 10px;
  background: #f7f8f5;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.answer-strip,
.test-answer-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(56px, 86px));
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.test-answer-strip {
  display: flex;
  flex-wrap: wrap;
}

.answer-strip span,
.answer-strip button,
.test-answer-strip span,
.test-answer-strip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  padding: 6px 10px;
  background: #f7f8f5;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  min-height: 42px;
  min-width: 56px;
  font-size: 18px;
  cursor: pointer;
}

.answer-strip span.filled,
.answer-strip button.filled,
.test-answer-strip span.filled,
.test-answer-strip button.filled {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: #b8ddd0;
}

.answer-strip span.correct,
.answer-strip button.correct,
.test-answer-strip span.correct,
.test-answer-strip button.correct {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.answer-strip span.wrong,
.answer-strip button.wrong,
.test-answer-strip span.wrong,
.test-answer-strip button.wrong {
  background: #fff1ef;
  border-color: #d05b55;
  color: var(--danger);
}

.hint {
  max-width: 460px;
  margin: 20px auto 0;
  color: var(--muted);
  line-height: 1.6;
}

.write-layout {
  display: grid;
  grid-template-columns: minmax(220px, 340px);
  align-items: start;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.write-area {
  width: 100%;
}

.canvas-wrap {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #fbfbf7;
  border: 1px solid var(--line);
}

.guide-kana {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(23, 32, 28, 0.12);
  font-size: 220px;
  font-weight: 900;
  pointer-events: none;
}

canvas {
  position: relative;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.test-write-layout {
  width: min(100%, 820px);
}

.test-write-prompts {
  display: grid;
  grid-template-columns: repeat(5, minmax(70px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.test-write-prompts span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.test-write-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(70px, 1fr));
  gap: 8px;
}

.test-write-answer-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(70px, 1fr));
  gap: 8px;
}

.test-write-answer-grid span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  font-size: 64px;
  font-weight: 900;
}

.test-write-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #fbfbf7;
  border: 1px solid var(--line);
}

.write-pronunciation {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.write-pronunciation strong,
.write-pronunciation span,
.write-pronunciation em {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 7px 12px;
  font-style: normal;
  font-weight: 900;
}

.write-pronunciation strong {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 22px;
  line-height: 1;
}

.write-pronunciation span {
  background: #f7f8f5;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 18px;
}

.write-pronunciation em {
  margin-left: auto;
  background: #f7f8f5;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 15px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 12px;
  width: min(100%, 520px);
}

.five-choice-grid {
  grid-template-columns: repeat(5, minmax(64px, 1fr));
  width: min(100%, 680px);
}

.choice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: white;
  border-color: var(--line);
  font-size: 22px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.choice-btn small {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: #eef4f1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.choice-btn:hover {
  border-color: var(--accent);
  background: var(--surface-soft);
}

.choice-btn.correct {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  transform: translateY(-2px);
}

.choice-btn.correct small {
  background: rgba(255, 255, 255, 0.22);
  color: white;
}

.choice-btn.wrong {
  background: #fff1ef;
  border-color: #d05b55;
  color: var(--danger);
}

.choice-btn.correct:disabled,
.choice-btn.wrong:disabled {
  opacity: 1;
}

.eval-btn.know {
  background: var(--accent);
  color: white;
}

.eval-btn.unsure {
  background: #fff6e8;
  color: var(--warn);
}

.eval-btn.nope {
  background: #fff1ef;
  color: var(--danger);
}

.kana-grid,
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}

.unit-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.unit-card,
.kana-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.unit-card {
  color: var(--text);
  padding: 16px;
  text-align: left;
}

.unit-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.unit-card h2 {
  margin-bottom: 10px;
}

.kana-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-kana {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #f6f8f5;
  font-size: 24px;
  font-weight: 800;
}

.kana-card {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 12px 6px;
}

.kana-card .kana {
  font-size: 36px;
  font-weight: 900;
}

.kana-card .sound,
.kana-card .status {
  color: var(--muted);
}

.review-options,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  align-items: end;
  margin-bottom: 20px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.inline-select,
.side-select {
  min-width: 150px;
}

.side-select {
  margin-bottom: 14px;
}

select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
  color: var(--text);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.empty {
  color: var(--muted);
  padding: 16px 0;
}

.result-box {
  width: min(100%, 520px);
  text-align: center;
}

.result-score {
  font-size: 58px;
  font-weight: 900;
  color: var(--accent-strong);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    overflow-x: auto;
  }

  .nav-item {
    text-align: center;
    white-space: nowrap;
  }

  .main {
    padding: 18px;
  }

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

  .side-progress {
    position: static;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .big-kana {
    font-size: 118px;
  }

  .write-pronunciation {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 12px;
  }

  .topbar,
  .step-head,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 26px;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .study-panel {
    padding: 14px;
    min-height: 560px;
  }

  .study-content {
    padding: 16px 0;
  }

  .choice-grid,
  .stats {
    grid-template-columns: 1fr;
  }

  .five-choice-grid {
    grid-template-columns: repeat(5, minmax(46px, 1fr));
    gap: 8px;
  }

  .five-choice-grid .choice-btn {
    min-height: 40px;
    padding: 8px 6px;
    font-size: 18px;
  }

  .test-write-layout {
    overflow-x: auto;
  }

  .test-write-prompts,
  .test-write-grid,
  .test-write-answer-grid {
    grid-template-columns: repeat(5, 86px);
    width: max-content;
  }
}
