:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --fg: #1c2230;
  --muted: #5b6474;
  --line: #d9dde5;
  --accent: #0e6267;
  --accent-soft: #dcecec;
  --ok: #1d6b3a;
  --warn: #8a4b12;
  --serif: "Noto Serif KR", "Batang", serif;
  --sans: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161d; --surface: #1a2029; --fg: #e6e9ef; --muted: #9aa3b2; --line: #2d3541;
    --accent: #7fc7c4; --accent-soft: #1d3436; --ok: #8fd3a6; --warn: #e7b889;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161d; --surface: #1a2029; --fg: #e6e9ef; --muted: #9aa3b2; --line: #2d3541;
  --accent: #7fc7c4; --accent-soft: #1d3436; --ok: #8fd3a6; --warn: #e7b889;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--sans); font-size: 15px; line-height: 1.85;
  word-break: keep-all; overflow-wrap: break-word;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
main { max-width: 720px; margin: 0 auto; padding-block: 24px 64px; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); text-wrap: balance; line-height: 1.35; }
h1 { font-size: 28px; margin: 4px 0 8px; }
h2 { font-size: 20px; margin: 44px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); scroll-margin-top: 16px; }
h3 { font-size: 16px; margin: 26px 0 8px; color: var(--accent); }
p { margin: 0 0 14px; max-width: 65ch; }
.top { margin-bottom: 20px; }
.top a { font-size: 14px; color: var(--muted); }
.top a:hover { color: var(--accent); }
.kicker { font-size: 12px; letter-spacing: 0.06em; color: var(--muted); margin: 0; }
.subtitle { color: var(--muted); font-size: 14px; margin: 0 0 6px; }
.badge { display: inline-block; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 10px; margin: 0 0 18px; }
.lede { font-size: 16px; color: var(--muted); margin: 0 0 24px; }
.note { background: var(--accent-soft); border-radius: 8px; padding: 14px 16px; margin: 16px 0; }
.note p:last-child, .note ul:last-child { margin-bottom: 0; }
.note ul { margin: 4px 0 0; padding-left: 20px; }
.note b.h { display: block; color: var(--accent); margin-bottom: 4px; }
.placeholder { border: 1px dashed var(--line); border-radius: 8px; padding: 10px 14px; color: var(--muted); font-size: 14px; margin: 12px 0 16px; }
.examples { display: grid; gap: 8px; margin: 12px 0 18px; }
.ex { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: baseline; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.ex .en { font-family: var(--serif); font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.ex .ko { grid-column: 1 / -1; font-size: 13px; color: var(--muted); margin-top: -4px; }
.tag { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; color: var(--muted); white-space: nowrap; }
.long-ex { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 12px 0 18px; }
.long-ex .en { font-family: var(--serif); font-size: 16px; overflow-wrap: anywhere; }
.long-ex .ko { font-size: 14px; color: var(--muted); margin-top: 8px; }
.quiz { margin: 14px 0; display: grid; gap: 10px; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.q .sentence { font-family: var(--serif); font-size: 16px; margin-bottom: 8px; overflow-wrap: anywhere; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
button {
  font: inherit; font-size: 14px; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 14px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button[aria-pressed="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.feedback { font-size: 13px; margin-top: 8px; min-height: 1.4em; }
.feedback.right { color: var(--ok); }
.feedback.wrong { color: var(--warn); }
.later { margin: 36px 0 0; }
.later summary {
  cursor: pointer; list-style: none; display: inline-block; color: var(--accent);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; font-size: 14px;
}
.later summary::-webkit-details-marker { display: none; }
.later summary::after { content: " \25B8"; }
.later[open] summary::after { content: " \25BE"; }
.later summary:hover { border-color: var(--accent); }
.later[open] summary { margin-bottom: 12px; }
.later .inner { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; font-size: 14px; }
.later ul { margin: 6px 0 0; padding-left: 20px; }
.later li { margin-bottom: 6px; }
.steps { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 14px 0 10px; padding: 0; list-style: none; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 14px; }
.steps b { display: block; color: var(--accent); font-weight: 500; margin-bottom: 2px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); margin: 12px 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; color: var(--muted); font-size: 12px; background: var(--bg); }
tr:last-child td { border-bottom: 0; }
td.grade { white-space: nowrap; color: var(--muted); }
td.en { font-family: var(--serif); }
.chapter-name { font-weight: 500; }
/* 목차 */
.toc { margin: 8px 0 0; }
.toc > ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.toc .box, .toc summary {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 14px; font-size: 15px; font-weight: 500; cursor: pointer;
}
.toc summary { list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: "\25B8"; color: var(--muted); }
.toc details[open] > summary::after { content: "\25BE"; }
.toc .box::after { content: "\2192"; color: var(--muted); }
.toc .box:hover, .toc summary:hover { border-color: var(--accent); color: var(--accent); }
.toc .sub { list-style: none; padding: 0; margin: 6px 0 4px 14px; display: grid; gap: 2px; }
.toc .sub a { display: block; border-left: 2px solid var(--line); padding: 4px 0 4px 14px; font-size: 14px; color: var(--muted); }
.toc .sub a:hover { color: var(--accent); border-left-color: var(--accent); }
.pager { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--line); }
.pager a {
  display: inline-block; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; font-size: 14px; max-width: 100%;
}
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.source { margin-top: 28px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }
.source p { margin-bottom: 6px; }
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .top, .pager, .quiz, .choices { display: none; }
  .later .inner { border: 0; padding: 0; }
  main { max-width: none; padding: 0; }
}
.nb { display: inline-block; }
.copyright { margin-top: 14px; font-size: 13px; color: var(--muted); }
.copyright p { margin: 0 0 6px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.theme { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; }
.theme button { border: 0; border-radius: 0; background: var(--surface); color: var(--muted); font-size: 12px; padding: 5px 10px; }
.theme button + button { border-left: 1px solid var(--line); }
.theme button[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
@media print { .theme { display: none; } }
.term { color: var(--muted); font-weight: 400; }
.toc .sub a { color: var(--fg); } .toc .sub a .term, .pager a .term { color: var(--muted); }
h1.brand { font-family: "Do Hyeon", var(--sans); font-weight: 400; font-size: 40px; line-height: 1.15; letter-spacing: -0.01em; margin: 6px 0 12px; }
h1.brand span { color: var(--accent); }
/* 제목 글꼴: 도현체 (한 가지 굵기라 font-weight 400) */
h1, h2, h3, .toc .box, .toc summary, .toc .group { font-family: "Do Hyeon", var(--sans); font-weight: 400; letter-spacing: -0.005em; }
h1 { font-size: 32px; }
h2 { font-size: 23px; }
h3 { font-size: 19px; }
.toc .box, .toc summary { font-size: 17px; }
/* 긴 글 읽기 편하게: 문단 사이와 줄 간격을 넓힘 */
main > p, main > .source + p { line-height: 1.95; margin-bottom: 24px; }
/* 큰 제목과 본문 사이 여백 */
h1 { margin-bottom: 26px; }
h1 + .subtitle { margin-top: -16px; }
.subtitle + .badge, h1 + .badge { margin-bottom: 24px; }
.term-line { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }

/* 베타 표시 */
.beta { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.beta b { font-family: "Do Hyeon", "Noto Sans KR", sans-serif; font-weight: 400; letter-spacing: 0.08em; font-size: 13px; color: var(--bg); background: var(--accent); border-radius: 999px; padding: 2px 10px 1px; }

/* 이어 보기 */
.resume { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; margin: 0 0 18px; padding: 14px 16px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent-soft); color: var(--fg); }
.resume:hover { border-color: var(--accent); }
.resume-k { font-size: 12px; color: var(--accent); font-weight: 700; white-space: nowrap; }
.resume-t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.resume-a { color: var(--accent); }
.toc a.seen::after { content: " ✓"; color: var(--ok, var(--accent)); font-size: 12px; }

/* 약관·방침 문서 */
.doc-draft { border: 1px dashed var(--warn, var(--line)); border-radius: 8px; padding: 10px 14px; font-size: 14px; color: var(--muted); margin: 0 0 20px; }
.fill { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 4px; font-size: 0.95em; }
.legal ol, .legal ul { padding-left: 22px; }
.legal h2 { font-size: 19px; }
.footer-links { display: flex; gap: 14px; flex-wrap: wrap; }

/* 로그인 */
.acct { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.acct span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.acct button { font-size: 12px; padding: 4px 10px; }
@media print { .acct { display: none; } }
.login { max-width: 420px; }
.login label { display: block; font-size: 14px; margin: 14px 0 6px; }
.login .consent { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 0 0 8px; }
.login input[type="email"] { width: 100%; box-sizing: border-box; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--fg); }
.login form button { margin-top: 12px; width: 100%; padding: 11px 14px; }
.login-msg { min-height: 1.5em; font-size: 14px; color: var(--muted); }
.login-need { font-size: 14px; color: var(--accent); }
