/* 중국어 기초 강좌 — dic-data/zh-course/web/course.css 에서 복사됨 (손으로 고치지 말 것)
   색은 사이트 공통 토큰(shared/css/base.css)과 같은 값. 글자 크기는 --fs(가−/가+)로 rem 전체를 키운다. */
:root {
  --bg: #e3e9ee; --surface: #f8fafb; --surface-2: #edf1f4; --line: #d0d9e0;
  --text: #1c2731; --muted: #5a6875; --faint: #5d6a76;
  --accent: #bf541e; --accent-ink: #ffffff; --accent-soft: #f8e2d5; --accent-text: #a34616;
  --bad-bg: #fbe2df; --bad: #b02a20; --good-bg: #dbf0e1; --good: #1c703e; --mid-bg: #f9eecd; --mid: #855800;
  --shadow: 0 1px 2px rgba(28, 42, 56, .05), 0 6px 20px rgba(28, 42, 56, .06);
  --ko: "IBM Plex Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --zh: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --fs: 1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131a20; --surface: #1c252d; --surface-2: #232e37; --line: #313e4a;
    --text: #e4eaef; --muted: #9cabb8; --faint: #8a97a3;
    --accent: #ec7b40; --accent-ink: #1b0f07; --accent-soft: #3a2519; --accent-text: #f59c68;
    --bad-bg: #3a1d1b; --bad: #ff9c90; --good-bg: #16301f; --good: #80d69c; --mid-bg: #352a12; --mid: #f0c75e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131a20; --surface: #1c252d; --surface-2: #232e37; --line: #313e4a;
  --text: #e4eaef; --muted: #9cabb8; --faint: #8a97a3;
  --accent: #ec7b40; --accent-ink: #1b0f07; --accent-soft: #3a2519; --accent-text: #f59c68;
  --bad-bg: #3a1d1b; --bad: #ff9c90; --good-bg: #16301f; --good: #80d69c; --mid-bg: #352a12; --mid: #f0c75e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: calc(100% * var(--fs)); -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
html, body { margin: 0; overflow-x: hidden; }
body { background: var(--bg); color: var(--text); font-family: var(--ko); font-size: 1.03rem; line-height: 1.75; }
a { color: var(--accent-text); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 8px; top: 8px; z-index: 99; background: var(--surface); padding: 6px 10px; border-radius: 8px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 중국어 글자와 병음 */
.zh { font-family: var(--zh); }
.big { font-size: 1.25em; }
ruby { ruby-align: center; white-space: nowrap; }   /* 낱말 하나(公交车)가 줄 끝에서 갈라지지 않게 */
:root:not([data-py="off"]) ruby { margin-inline: .14em; }   /* 병음 낱말끼리 붙어 보이지 않게 */
rt { font-family: var(--zh); font-size: .58em; font-weight: 400; color: var(--muted); letter-spacing: 0; }
:root[data-py="under"] ruby { ruby-position: under; }
:root[data-py="off"] rt { display: none; }
.pyt { font-family: var(--zh); color: var(--accent-text); }
.lead-zh { font-size: 1.5rem; margin: 0 0 6px; line-height: 2.2; }

/* 위쪽 막대 */
.bar {
  position: fixed; z-index: 30; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px; background: var(--bg); border-bottom: 1px solid var(--line);
  transition: transform .2s; font-size: 14px;
}
.bar.away { transform: translateY(-110%); }
.bar .ttl { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .menu, .seg { flex: none; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.bar .menu { display: flex; align-items: center; gap: 6px; padding: 0 12px; font-weight: 600; font-size: 13.5px; }
.seg { display: flex; align-items: center; overflow: hidden; }
.seg .lb { padding: 0 6px 0 10px; font-size: 12.5px; color: var(--muted); }
.seg button { height: 100%; border: 0; border-left: 1px solid var(--line); background: transparent; padding: 0 10px; font-size: 13px; color: var(--muted); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.seg.font button { width: 40px; padding: 0; font-weight: 700; color: var(--text); }
.seg.font button + button { font-size: 16px; }
.seg button:disabled { color: var(--faint); opacity: .6; cursor: default; }
@media (max-width: 560px) { .bar .ttl { visibility: hidden; } .bar { gap: 6px; padding-inline: 8px; } .seg button { padding: 0 8px; } .seg.font button { width: 34px; } .bar .menu { padding: 0 10px; } }
@media (prefers-reduced-motion: reduce) { .bar { transition: none; } }

.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(10, 15, 20, .45); }
.drawer {
  position: fixed; z-index: 41; top: 0; bottom: 0; left: 0; width: min(340px, 88vw); overflow-y: auto; overscroll-behavior: contain;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 14px calc(env(safe-area-inset-bottom, 0px) + 24px);
  background: var(--surface); border-right: 1px solid var(--line); box-shadow: 4px 0 24px rgba(0, 0, 0, .18); font-size: 14px; line-height: 1.5;
}
.dhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dhead b { font-size: 15.5px; }
.dx { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: transparent; font-size: 17px; }
.dquick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dquick a { border: 1px solid var(--line); border-radius: 8px; text-align: center; padding: 7px 4px; color: var(--text); text-decoration: none; font-size: 13px; }
.drawer h3 { margin: 18px 0 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.drawer h3 small { font-weight: 400; }
.drawer .soon { margin: 0; color: var(--faint); font-size: 13px; padding-left: 8px; }
.dl { list-style: none; margin: 0; padding: 0; }
.dl a { display: flex; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 7px; color: var(--text); text-decoration: none; }
.dl a:hover { background: var(--surface-2); }
.dl a[aria-current] { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.dl .n { flex: none; width: 1.6em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.dl .t { flex: 1; min-width: 0; }
.dl .mk { flex: none; color: var(--good); font-size: 12px; }
.totop { position: fixed; z-index: 20; right: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); font-size: 20px; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }

/* 본문 */
.page { max-width: 760px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 68px) 16px calc(env(safe-area-inset-bottom, 0px) + 80px); }
.crumb { margin: 0 0 4px; font-size: .9rem; color: var(--muted); }
.crumb a { text-decoration: none; font-weight: 600; }
h1 { font-size: clamp(1.6rem, 5vw, 2.1rem); line-height: 1.3; margin: 4px 0 10px; text-wrap: balance; word-break: keep-all; }
h1 .no { display: block; font-size: .9rem; color: var(--accent-text); font-weight: 600; letter-spacing: .02em; }
h2 { font-size: 1.3rem; margin: 2.2em 0 .6em; padding-top: .6em; border-top: 1px solid var(--line); }
h3 { font-size: 1.08rem; margin: 1.6em 0 .4em; }
p, li { word-break: keep-all; overflow-wrap: anywhere; }
p { margin: 0 0 .9em; }
.hint { font-size: .9rem; color: var(--muted); }
.toc { margin: 14px 0 0; }
.toc ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.toc a { display: inline-block; font-size: .85rem; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--muted); background: var(--surface); }
.goals { padding-left: 1.2em; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 12px; padding: 12px 18px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.small { padding: 7px 14px; font-size: .92rem; border-radius: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--line); }

/* 듣기 버튼과 문장 */
.say { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--accent-text); font-size: 12px; line-height: 1; padding: 0; vertical-align: middle; }
.say:active, .say.on { background: var(--accent-soft); }
:root.no-tts .say:not(.dcell), :root.no-tts [data-sayall] { display: none; }
.sents, .dialog, .say-list { list-style: none; margin: 0; padding: 0; }
.sent, .line { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.sent .say, .line .say { margin-top: .5em; }
.st { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.st .zh { line-height: 2.1; }
:root[data-py="off"] .st .zh { line-height: 1.6; }
.st .ko { color: var(--muted); font-size: .95rem; }
.line .who { flex: none; min-width: 2.4em; margin-top: .55em; font-size: .85rem; font-weight: 700; color: var(--accent-text); }
.scene { color: var(--muted); font-size: .95rem; }
.playall { margin: 0 0 10px; }

/* 표 */
.tw { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 1em; }
table { border-collapse: collapse; width: 100%; background: var(--surface); border-radius: 10px; font-size: .95rem; }
th, td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: middle; }
thead th { background: var(--surface-2); font-size: .85rem; color: var(--muted); font-weight: 600; }
.words .wz { font-size: 1.3rem; white-space: nowrap; }
.words .wp { white-space: nowrap; }
.words .pos { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.words .ws { width: 44px; text-align: center; }
.words .rv { display: block; margin-top: 2px; font-size: .78rem; color: var(--muted); }
a.dict { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; color: var(--text); }
.tbl td .zh { font-size: 1.15em; }
.drill { table-layout: fixed; }
.drill th[scope="row"] { width: 5.5em; font-size: .85rem; color: var(--muted); }
.drill td { padding: 4px; text-align: center; }
.dcell { width: 100%; min-height: 64px; border: 1px solid transparent; border-radius: 8px; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 6px 2px; }
.dcell:hover { border-color: var(--line); background: var(--surface-2); }
.dcell .pyt { font-size: 1.15rem; font-weight: 500; }
.dcell .zh { font-size: 1.25rem; line-height: 1.4; }
.dcell .ko { font-size: .75rem; color: var(--muted); line-height: 1.3; }
@media (max-width: 480px) { .drill th[scope="row"] { width: 4em; } .dcell .pyt { font-size: 1rem; } table { font-size: .9rem; } th, td { padding: 6px; } }

.point { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px 10px; margin-bottom: 14px; }
.point h3 { margin-top: .9em; }
.point .sent { background: var(--bg); }
.practice { margin-bottom: 18px; }
.frame { padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 10px 10px 0; font-size: 1.05rem; }
.say-list li { padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.say-list .ko-q { font-weight: 600; }
.say-list details { margin-top: 4px; }
.say-list summary { cursor: pointer; color: var(--accent-text); font-size: .9rem; }
.say-list .sent { border: 0; padding: 6px 0 0; margin: 0; background: transparent; }

/* 확인 문제 */
.quiz { padding-left: 1.4em; margin: 0; }
.q { margin-bottom: 22px; }
.qq { font-weight: 600; margin-bottom: 6px; }
.qzh { margin: 0 0 6px; }
.chs { display: flex; flex-direction: column; gap: 6px; }
.ch { text-align: left; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); line-height: 1.6; min-height: 44px; }
.ch:hover:not(:disabled) { border-color: var(--accent); }
.ch:disabled { cursor: default; }
.ch.right { background: var(--good-bg); border-color: var(--good); color: var(--text); }
.ch.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--text); }
.why { margin-top: 8px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); font-size: .95rem; }
.why .res { font-weight: 700; margin-bottom: 4px; }
.why .res.ok { color: var(--good); }
.why .res.no { color: var(--bad); }
.qsum { padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.qsum .score { margin: 0; font-weight: 700; color: var(--accent-text); }

.culture { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px 8px; }
.finish { margin: 6px 0 16px; }
.btn.done[aria-pressed="true"] { background: var(--good-bg); color: var(--good); border: 1px solid var(--good); }
.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pn a { display: block; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem; word-break: keep-all; }
.pn a.n { text-align: right; }
.pn small { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; }

/* 과정 첫 화면 */
.howto { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 2px 16px 6px; margin: 18px 0; }
.howto h2 { border: 0; margin-top: .8em; padding: 0; font-size: 1.1rem; }
.resume { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 14px 16px; border-radius: 14px; background: var(--accent-soft); }
.resume p { margin: 0; color: var(--accent-text); font-weight: 600; }
.resume .btn { text-decoration: none; }
.stage h2 .no { display: inline-block; margin-right: 8px; color: var(--accent-text); }
.stage h2 small { font-size: .85rem; color: var(--muted); font-weight: 500; }
.prog { font-size: .9rem; color: var(--muted); }
.lessons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lessons a { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; }
.lessons a:hover { border-color: var(--accent); }
.lessons .n { flex: none; width: 2.2em; height: 2.2em; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.lessons a.done .n { background: var(--good-bg); color: var(--good); }
.lessons .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lessons .tz { font-size: 1.05rem; color: var(--muted); }
.lessons .s { font-size: .88rem; color: var(--muted); word-break: keep-all; }
.lessons .st { flex: none; font-size: .8rem; color: var(--good); font-weight: 600; text-align: right; }
.soon { color: var(--faint); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 14px; }
.foot { margin-top: 32px; font-size: .88rem; color: var(--muted); }

@media print { .bar, .drawer, .scrim, .totop, .say, .finish { display: none !important; } .page { padding-top: 0; } }

/* 짧은 글 읽기 (3단계부터) */
.reading { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px 10px; }
.reading h3 { margin: .8em 0 .4em; }
.reading .rp { font-size: 1.2rem; line-height: 2.3; margin: 0 0 10px; text-indent: 2em; }
:root[data-py="off"] .reading .rp { line-height: 1.8; }
.reading .rtr summary { cursor: pointer; color: var(--accent-text); font-size: .9rem; }
.reading .rtr p { color: var(--muted); font-size: .95rem; margin: 6px 0; }

/* 표현 넓히기 (4단계부터): 비슷한 말 구별 */
.expand { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px 10px; margin-bottom: 14px; }
.expand h3 { margin-top: .9em; }
.expand h3 .zh { font-size: 1.15em; }
.pair { list-style: none; margin: 0 0 6px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.pair li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.pair .st { display: flex; flex-direction: column; min-width: 0; }
.pair .ko { color: var(--muted); font-size: .92rem; word-break: keep-all; }
.expand .sent { background: var(--bg); }
.pair .say { margin-top: .5em; }

/* 쓰기 연습 (5단계부터): 과제 · 글쓰기 칸 · 모범 답안 */
.write { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px 12px; }
.write h3 { margin-top: .9em; }
.write .use-l { margin: 10px 0 4px; font-size: .9rem; font-weight: 600; color: var(--muted); }
.write .use { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.write .use li { padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--text); font-size: .95rem; }
.write .wl { display: block; font-weight: 600; margin: 4px 0 6px; }
.write .wl small { font-weight: 400; color: var(--muted); }
.wbox { display: block; width: 100%; box-sizing: border-box; min-height: 8em; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit; font-family: var(--zh); font-size: 1.1rem; line-height: 1.8; resize: vertical; }
.wbox:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.write .model { margin-top: 10px; }
.write .model summary { cursor: pointer; color: var(--accent-text); font-weight: 600; min-height: 32px; }
.write .model .rp { font-size: 1.2rem; line-height: 2.3; margin: 6px 0 8px; text-indent: 2em; }
:root[data-py="off"] .write .model .rp { line-height: 1.8; }
.write .model .mtr { color: var(--muted); font-size: .95rem; margin: 0; }
@media print { .wbox { display: none; } }

/* 고급 표현 노트 (6단계부터): 문어 허사 · 사자 구조 · 대구 · 관용 수사 */
.note { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 14px; padding: 10px 16px 10px; margin-bottom: 14px; }
.note h3 { margin-top: .3em; }
.note .sent { background: var(--bg); }
.tag { display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: .8rem; font-weight: 600; line-height: 1.7; }
.note > .tag { margin-top: 4px; }

/* 연습: 중국어 → 한국어 옮기기 (read), 틀린 문장 고치기 (fix) */
.read-list .sent { border: 0; padding: 0; margin: 0; background: transparent; }
.read-list .ko-a, .fix-list .ko-a { margin: 6px 0 0; color: var(--text); }
.fix-list .wrong { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.fix-list .wrong .zh { line-height: 2.1; text-decoration: underline wavy var(--bad); text-decoration-thickness: 1px; text-underline-offset: 6px; }
:root[data-py="off"] .fix-list .wrong .zh { line-height: 1.6; }
.fix-list .wrong .tag { background: var(--bad-bg); color: var(--bad); }
.fix-list details p { margin: 4px 0 0; font-size: .95rem; }
