:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #6b6f76;
  --line: #e4e0d8;
  --accent: #2f6f62;
  --accent-soft: #e3efeb;
  --good: #2e7d4f;
  --good-soft: #e5f3ea;
  --bad: #c0392b;
  --bad-soft: #fbe9e7;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1e2124;
    --ink: #eceae6;
    --muted: #9a9ea5;
    --line: #2f3338;
    --accent: #6cc2ad;
    --accent-soft: #203530;
    --good: #6fcf97;
    --good-soft: #1f3328;
    --bad: #f08a7e;
    --bad-soft: #3a2422;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }

/* 헤더 */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 8px;
}
.top { flex-wrap: wrap; gap: 8px 16px; }
.logo {
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}
.logo b { color: var(--accent); }
.nav { display: flex; gap: 16px; font-size: 15px; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--accent); }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

/* 단계 카드 */
.stages { display: grid; gap: 10px; }
.stage-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
button.stage-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.stage-card.disabled { opacity: .5; cursor: default; }
.stage-card .num {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.stage-text { display: flex; flex-direction: column; }
.stage-text small { color: var(--muted); font-size: 13px; }

/* 패널 */
.panel {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.panel h2 { margin: 0; font-size: 18px; }

select, input[type="number"], .editor input, .type-form input {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.editor { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.editor li {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 6px 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  counter-increment: s;
}
.editor li:first-child { border-top: 0; }
.editor li::before {
  content: counter(s);
  grid-row: span 2;
  color: var(--accent);
  font-weight: 700;
  padding-top: 8px;
}
.editor input { width: 100%; }
.editor input.en { font-family: system-ui, sans-serif; }

.row { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

.settings summary { cursor: pointer; font-weight: 600; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.settings-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.settings-grid label.check { flex-direction: row; align-items: center; gap: 8px; grid-column: 1 / -1; color: var(--ink); }

/* 버튼 */
.btn {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0f1a17; } }
.btn.wide { min-width: 140px; }

.hint { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.msg { margin: 10px 2px 0; color: var(--bad); font-size: 14px; }
.warn {
  margin-top: 20px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 14px;
}

/* 학습 화면 */
.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
}
.progress-row b { color: var(--ink); }
.bar { height: 6px; margin: 8px 0 16px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

.card {
  padding: 24px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.stage-card-big {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
}
.ko { margin: 0; font-size: clamp(20px, 5vw, 26px); font-weight: 600; word-break: keep-all; }
.en {
  margin: 0;
  font-size: clamp(19px, 4.6vw, 24px);
  color: var(--accent);
  font-family: system-ui, sans-serif;
  min-height: 1.6em;
  transition: opacity .2s;
}
.en.veil { opacity: 0; }

.cue { width: min(280px, 100%); color: var(--muted); font-size: 14px; min-height: 40px; }
.timer { height: 4px; margin-top: 6px; border-radius: 2px; background: var(--line); overflow: hidden; }
.timer > div { height: 100%; width: 0; background: var(--accent); }

.controls { display: flex; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* 마이크 */
.mic {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 4px 14px rgb(0 0 0 / .12);
}
.mic svg { width: 34px; height: 34px; fill: #fff; }
.mic.on { background: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(192 57 43 / .45); }
  100% { box-shadow: 0 0 0 18px rgb(192 57 43 / 0); }
}
.heard { margin: 0; min-height: 1.6em; font-family: system-ui, sans-serif; color: var(--muted); font-style: italic; }

.type-form { display: flex; gap: 8px; margin-top: 12px; }
.type-form input { flex: 1; min-width: 0; }

/* 채점 결과 */
#s2Result { width: 100%; text-align: left; }
.verdict { margin: 0 0 10px; font-weight: 700; text-align: center; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.diff { margin: 6px 0; font-family: system-ui, sans-serif; line-height: 2; }
.diff .label { display: inline-block; width: 48px; color: var(--muted); font-size: 13px; font-family: inherit; }
.diff span.w { padding: 2px 4px; border-radius: 4px; }
.diff span.miss { background: var(--good-soft); color: var(--good); font-weight: 600; }
.diff span.extra { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.answer {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  font-family: system-ui, sans-serif;
}

/* 결과 요약 */
#s2Done h2 { margin: 0 0 4px; }
.score { font-size: 40px; font-weight: 700; color: var(--accent); margin: 4px 0 12px; }
.wrong-list { margin: 0; padding-left: 20px; }
.wrong-list li { margin: 8px 0; }
.wrong-list .en { display: block; font-size: 16px; }

/* 홈 소개 문구 */
.intro { margin: 4px 2px 16px; color: var(--muted); word-break: keep-all; }

/* 푸터 */
.foot {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 6px; }
.foot a { color: var(--muted); }
.foot p { margin: 0; }

/* 블로그 본문 */
.prose { word-break: keep-all; overflow-wrap: anywhere; }
.prose h1 { font-size: clamp(24px, 6vw, 30px); line-height: 1.35; margin: 12px 0 6px; letter-spacing: -0.02em; }
.prose h2 { font-size: 21px; margin: 36px 0 10px; }
.prose h3 { font-size: 18px; margin: 28px 0 8px; }
.prose p, .prose li { font-size: 17px; line-height: 1.8; }
.prose a { color: var(--accent); }
.prose blockquote {
  margin: 18px 0;
  padding: 10px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
}
.prose blockquote p { margin: 6px 0; }
.prose code { padding: 1px 5px; border-radius: 4px; background: var(--accent-soft); font-size: .92em; }
.prose table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 15px; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--surface); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }
.post-meta { margin: 0 0 20px; color: var(--muted); font-size: 14px !important; }

/* 글 목록 */
.post-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 12px; }
.post-list a {
  display: block;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color .15s;
}
.post-list a:hover { border-color: var(--accent); }
.post-list h2 { margin: 0 0 4px; font-size: 19px; }
.post-list p { margin: 0; color: var(--muted); font-size: 15px; }
.post-list .post-meta { margin: 0 0 4px; font-size: 13px !important; }

.cta {
  display: block;
  margin: 36px 0 20px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
@media (prefers-color-scheme: dark) { .cta { color: #0f1a17; } }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.post-nav a {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  font-size: 15px;
}
.post-nav a:last-child { text-align: right; }
.post-nav small { display: block; color: var(--muted); font-size: 12px; }
