/* 영어 학습 노트 — 공용 스타일 */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f1efe8;
  --text: #1f2328;
  --muted: #5f6670;
  --border: #e3e0d6;
  --accent: #2f5bd3;
  --accent-soft: #e8eefc;
  --good: #1f8a4c;
  --good-soft: #e3f4ea;
  --bad: #c2412d;
  --bad-soft: #fbe9e5;
  --star: #c98a00;
  --mark: #fff1b8;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 4px 16px rgba(20, 20, 20, .05);
  --radius: 14px;
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-en: "Georgia", "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171b;
    --surface: #1d2025;
    --surface-2: #252931;
    --text: #e8e9ec;
    --muted: #9aa1ab;
    --border: #2f343c;
    --accent: #7ea2ff;
    --accent-soft: #24304d;
    --good: #5cc98b;
    --good-soft: #1f3529;
    --bad: #f08a76;
    --bad-soft: #3d2420;
    --star: #f0c04a;
    --mark: #4a4120;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #15171b; --surface: #1d2025; --surface-2: #252931; --text: #e8e9ec; --muted: #9aa1ab;
  --border: #2f343c; --accent: #7ea2ff; --accent-soft: #24304d; --good: #5cc98b; --good-soft: #1f3529;
  --bad: #f08a76; --bad-soft: #3d2420; --star: #f0c04a; --mark: #4a4120; --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
strong { font-weight: 700; }
mark, .hl { background: var(--mark); color: inherit; padding: 0 .15em; border-radius: 3px; }
button { font: inherit; cursor: pointer; }

.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 80px; display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .page { grid-template-columns: 220px minmax(0, 1fr); padding-top: 40px; } }

main { display: grid; gap: 18px; min-width: 0; grid-template-columns: minmax(0, 1fr); }

/* 목차 */
.toc { display: none; }
@media (min-width: 960px) {
  .toc { display: block; position: sticky; top: 24px; align-self: start; font-size: 14px; }
}
.toc h2 { font-size: 13px; color: var(--muted); letter-spacing: .04em; margin: 0 0 8px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.toc a:hover { background: var(--surface-2); }
.toc a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.toc a.done::after { content: "✓"; color: var(--good); margin-left: auto; font-weight: 700; }
.chips-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; position: sticky; top: 0; background: var(--bg); z-index: 5; padding-top: 8px; }
@media (min-width: 960px) { .chips-nav { display: none; } }
.chips-nav a { flex: none; font-size: 13px; padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.chips-nav a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 헤더 */
.hero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.back-link { display: inline-block; font-size: 13px; text-decoration: none; margin-bottom: 10px; }
.back-link:hover { text-decoration: underline; }
.eyebrow { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.hero h1 { font-family: var(--font-en); font-size: clamp(26px, 4.6vw, 38px); line-height: 1.2; margin: 10px 0 4px; }
.hero .ko { font-size: 18px; color: var(--muted); margin: 0 0 16px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.pill { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.pill.level { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.focus { margin: 0; }
.notice { margin-top: 14px; font-size: 14px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--star); }

.progress { margin-top: 18px; }
.progress-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* 섹션 */
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); scroll-margin-top: 56px; }
.section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.section-head h2 { font-size: 21px; margin: 0; }
.section-head .num { font-size: 13px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 2px 8px; }
.section-desc { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.done-toggle { margin-left: auto; font-size: 13px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 4px 12px; }
.done-toggle[aria-pressed="true"] { background: var(--good-soft); color: var(--good); border-color: transparent; font-weight: 600; }

.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 7px 14px; font-size: 14px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.btn.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.toolbar .spacer { flex: 1; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }

/* 학습 순서 */
.steps { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); counter-reset: s; margin: 0; padding: 0; list-style: none; }
.steps li { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.steps b { display: block; font-size: 15px; }
.steps .min { color: var(--muted); font-size: 13px; }

/* 글의 뼈대 */
.flow { list-style: none; margin: 0; padding: 0; position: relative; }
.flow li { position: relative; padding: 0 0 18px 34px; }
.flow li::before { content: ""; position: absolute; left: 11px; top: 26px; bottom: 0; width: 2px; background: var(--border); }
.flow li:last-child::before { display: none; }
.flow .dot { position: absolute; left: 0; top: 2px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.flow .part { font-family: var(--font-en); font-weight: 600; }
.flow .role { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; margin-left: 6px; }
.flow p { margin: 2px 0 0; }

/* 플립 카드 */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.flip { perspective: 900px; min-height: 150px; border: 0; background: none; padding: 0; text-align: left; color: inherit; }
.flip-inner { display: grid; width: 100%; height: 100%; min-height: 150px; transition: transform .45s; transform-style: preserve-3d; }
.flip.on .flip-inner { transform: rotateY(180deg); }
.flip-face { grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 12px; border: 1px solid var(--border); padding: 14px; display: flex; flex-direction: column; background: var(--surface); }
.flip-front { justify-content: center; align-items: center; text-align: center; background: var(--surface-2); }
.flip-front .term { font-family: var(--font-en); font-size: 19px; font-weight: 600; }
.flip-front .tap { font-size: 12px; color: var(--muted); margin-top: 6px; }
.flip-back { transform: rotateY(180deg); gap: 6px; }
.flip-back .meaning { font-weight: 700; }
.flip-back .ex { font-size: 13px; color: var(--muted); font-family: var(--font-en); }
@media (prefers-reduced-motion: reduce) { .flip-inner { transition: none; } }

/* 표현 */
.expr-list { display: grid; gap: 10px; }
.expr { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.expr summary { cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; list-style: none; }
.expr summary::-webkit-details-marker { display: none; }
.expr summary::after { content: "＋"; margin-left: auto; color: var(--muted); }
.expr[open] summary::after { content: "－"; }
.expr .en { font-family: var(--font-en); font-size: 17px; font-weight: 600; }
.expr .star { color: var(--star); font-size: 13px; font-weight: 700; }
.expr .mean { color: var(--muted); }
.expr .body { margin-top: 10px; display: grid; gap: 8px; font-size: 14px; }
.label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; }
.quote { font-family: var(--font-en); border-left: 3px solid var(--border); padding-left: 10px; }

/* 문장 패턴 */
.patterns { display: grid; gap: 12px; }
.pattern { border-radius: 12px; background: var(--surface-2); padding: 14px 16px; }
.pattern h3 { margin: 0 0 8px; font-size: 16px; }
.pattern blockquote { margin: 0 0 6px; font-family: var(--font-en); font-size: 15px; }
.pattern p { margin: 0; font-size: 14px; color: var(--muted); }

/* 표 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td.en { font-family: var(--font-en); font-weight: 600; white-space: nowrap; }

/* 퀴즈 */
.quiz { display: grid; gap: 14px; }
.q { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.q-title { font-weight: 700; margin: 0 0 10px; }
.q-title .qn { color: var(--accent); margin-right: 6px; }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 9px 12px; font-size: 15px; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt:disabled { cursor: default; }
.opt.correct { background: var(--good-soft); border-color: var(--good); color: var(--text); }
.opt.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--text); }
.explain { margin-top: 10px; font-size: 14px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.explain b { color: var(--good); }
.explain.no b { color: var(--bad); }
.score { font-weight: 700; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* 영작 */
.write { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: grid; gap: 8px; }
.write .prompt { font-weight: 600; }
.write textarea { width: 100%; min-height: 64px; resize: vertical; border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; font: 15px var(--font-en); background: var(--bg); color: var(--text); }
.write .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.write .hint { font-size: 13px; color: var(--muted); }
.write .model { font-family: var(--font-en); padding: 10px 12px; border-radius: 10px; background: var(--good-soft); }
.write .check { font-size: 13px; font-weight: 600; }
.write .check.ok { color: var(--good); }
.write .check.no { color: var(--bad); }

/* 복습 카드 덱 */
.deck { display: grid; gap: 14px; justify-items: center; }
.deck-card { width: min(520px, 100%); min-height: 200px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2); display: grid; place-items: center; text-align: center; padding: 24px; cursor: pointer; }
.deck-card .front { font-family: var(--font-en); font-size: 24px; font-weight: 600; }
.deck-card .back { font-size: 19px; }
.deck-card .hint { display: block; font-size: 12px; color: var(--muted); margin-top: 10px; }
.deck-stats { font-size: 14px; color: var(--muted); }
.deck-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

footer.credit { grid-column: 1 / -1; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 18px; }
footer.credit p { margin: 4px 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 8px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* BLOCKLAB 사이트와 같은 형식 표시 (정독 노트 = 남색) */
.note-kind { display: inline-block; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 8px; background: #e0e7ff; color: #1e3a8a; margin: 0 0 10px 8px; }
:root[data-theme="dark"] .note-kind { background: #24304d; color: #b9c8ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .note-kind { background: #24304d; color: #b9c8ff; } }
