/* koen — 레트로 복셀(md/koen-spec.md 6절). 단단한 2~4px 오프셋 그림자만, 흐림·무한 움직임 없음. 밝은 바탕이라 공용 변수를 전부 다시 정의한다. */
:root {
  --bg: #f4efe1; --card: #fffdf7; --text: #222034; --muted: #5d5a6b; --border: #222034; --accent: #5b6ee1; --ok: #2f8f4e; --bad: #c0392b;
  --en: #306082; --ko: #8a3b2a; --rt: #6b6880; --stress: #c2410c; --sh: 3px 3px 0 #222034;
}
body.kx { background: var(--bg); color: var(--text); margin: 0; font-family: var(--sans, "Pretendard", system-ui, sans-serif); }
.kx-wrap { max-width: 920px; margin: 0 auto; padding: 16px 14px 48px; }
.kx-crumb { font-size: .9rem; display: flex; gap: 6px; flex-wrap: wrap; color: var(--muted); }
.kx-crumb a { color: var(--accent); text-decoration: none; font-weight: 700; }
.kx-h1 { font-size: clamp(1.6rem, 5vw, 2.3rem); margin: 10px 0 8px; letter-spacing: -.01em; }
.kx-h1 small { font-size: .5em; background: var(--text); color: #fff; padding: 2px 8px; vertical-align: middle; border-radius: 2px; }
.kx-h2 { font-size: 1.2rem; margin: 26px 0 10px; border-bottom: 3px solid var(--text); padding-bottom: 4px; }
.kx-lead, .kx-how, .kx-goal, .kx-plan p { line-height: 1.7; color: var(--muted); }
.kx-hero { padding: 6px 0 4px; }
.kx-hero-pix { display: flex; gap: 8px; }
.kx-hero-pix .px { width: 48px; height: 48px; }
canvas.px { image-rendering: pixelated; image-rendering: crisp-edges; width: 32px; height: 32px; vertical-align: middle; }

/* 단추 줄 */
.kx-bar, .kx-modes { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.kx-seg { display: flex; flex-wrap: wrap; gap: 4px; }
.kx-bar button, .kx-modes button, .kx-say, .kx-chip, .kx-dlg button, .kx-drill button, .kx-lt button, .kx-big, .kx-lex {
  font: inherit; font-weight: 700; border: 2px solid var(--border); background: var(--card); color: var(--text);
  box-shadow: 2px 2px 0 var(--border); border-radius: 3px; padding: 6px 10px; cursor: pointer; min-height: 36px; }
.kx-bar button[aria-pressed="true"], .kx-modes button[aria-pressed="true"] { background: var(--text); color: #fff; }
button:active { transform: translate(2px, 2px); box-shadow: none; }
@media (pointer: coarse) {
  .kx-bar button, .kx-modes button, .kx-say, .kx-chip, .kx-dlg button, .kx-drill button, .kx-lt button { min-height: 44px; min-width: 44px; }
  .kx-c { padding: 4px 2px; }
}

/* 강의 목록 */
.kx-lessons { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kx-card { display: grid; gap: 2px; padding: 12px; background: var(--card); border: 3px solid var(--border); box-shadow: var(--sh); text-decoration: none; color: var(--text); position: relative; min-height: 44px; }
.kx-card b { font-size: 1.3rem; }
.kx-card small { color: var(--muted); }
.kx-prog { display: block; height: 6px; background: #ddd6c3; margin-top: 6px; }
.kx-prog::after { content: ""; display: block; height: 100%; width: var(--p, 0%); background: var(--ok); }
.kx-src { font-size: .85rem; }

/* 규칙 */
.kx-rule { background: var(--card); border: 2px solid var(--border); padding: 10px 12px; margin: 8px 0; }
.kx-rule p { margin: 6px 0 0; line-height: 1.6; }
.kx-ex { display: flex; flex-wrap: wrap; gap: 6px; }
.kx-chip { font-weight: 600; padding: 4px 8px; min-height: 32px; }

/* 문장 */
.kx-s { background: var(--card); border: 3px solid var(--border); box-shadow: var(--sh); padding: 10px 12px 12px; margin: 14px 0; }
.kx-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .85rem; }
.kx-no { background: var(--text); color: #fff; font-weight: 800; padding: 1px 7px; }
.kx-kind { font-weight: 800; padding: 1px 6px; border: 2px solid currentColor; }
.k-q { color: #5b6ee1; } .k-a { color: #2f8f4e; } .k-s { color: #b45309; } .k-r { color: #9333ea; }
.kx-reg { color: var(--muted); border: 1px dashed var(--muted); padding: 0 5px; }
.kx-cnt { margin-left: auto; color: var(--ok); font-weight: 800; }
.kx-say { padding: 4px 8px; min-height: 32px; font-size: .85rem; }
.kx-line { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 10px; margin: 10px 0 0; }
.kx-c { display: inline-flex; flex-direction: column; align-items: center; cursor: pointer; border-radius: 3px; padding: 2px; }
.kx-c:hover, .kx-c.on { background: #ffe9a8; }
.kx-c ruby { ruby-position: over; }
.kx-en ruby { font-size: 1.45rem; font-weight: 700; color: var(--en); }
.kx-ko ruby { font-size: 1.35rem; font-weight: 700; color: var(--ko); }
.kx-c rt { font-size: .58em; font-weight: 600; color: var(--rt); letter-spacing: 0; }
.kx-c rt i { font-style: normal; }
.kx-c rt i.b, .kx-c rt i.a { color: var(--stress); font-weight: 900; }
.kx-c rt i.s { font-weight: 800; }
.kx-c rt i.e, .kx-c rt i.c { opacity: .6; font-size: .85em; }
.kx-m { font-size: .75rem; color: var(--muted); max-width: 9em; text-align: center; line-height: 1.25; margin-top: 2px; }
.kx-lit { font-size: .88rem; color: var(--muted); background: #f6f1e2; border-left: 4px solid #d9a066; padding: 6px 8px; margin: 10px 0 0; line-height: 1.55; }

/* 갈래: 한국인(기본) = 영어 위 한글 발음, 한국어 로마자는 숨김 / 영어 사용자 = 반대, 한국어가 먼저 / 아이 = 둘 다 크게 */
.who-ko .kx-ko rt, .who-ko .kx-ko .kx-m { display: none; }
.who-en .kx-en rt, .who-en .kx-en .kx-m { display: none; }
.who-en .kx-s { display: flex; flex-direction: column; } .who-en .kx-ko { order: 1; } .who-en .kx-en { order: 2; } .who-en .kx-lit { order: 3; } .who-en .kx-work { order: 4; }
.who-kid .kx-line canvas.px { width: 44px; height: 44px; }
.who-kid .kx-en ruby, .who-kid .kx-ko ruby { font-size: 1.7rem; }

/* 가리기 */
.hide-en .kx-en .kx-c ruby, .hide-ko .kx-ko .kx-c ruby { color: transparent; background: repeating-linear-gradient(45deg, #ddd6c3 0 6px, #e9e3d2 6px 12px); border-radius: 2px; }
.hide-en .kx-en .kx-c rt, .hide-ko .kx-ko .kx-c rt, .hide-en .kx-en .kx-m, .hide-ko .kx-ko .kx-m { visibility: hidden; }
.hide-en .kx-s.open .kx-en .kx-c ruby, .hide-ko .kx-s.open .kx-ko .kx-c ruby { color: inherit; background: none; }
.hide-en .kx-s.open .kx-en rt, .hide-ko .kx-s.open .kx-ko rt, .hide-en .kx-s.open .kx-en .kx-m, .hide-ko .kx-s.open .kx-ko .kx-m { visibility: visible; }
.who-ko.hide-en .kx-en rt, .who-ko.hide-en .kx-en .kx-m { visibility: hidden; }

/* 치기·받아쓰기 */
.kx-work { margin-top: 10px; }
.kx-type { display: grid; gap: 6px; }
.kx-type input, .kx-typebox input { font: inherit; font-size: 1.15rem; padding: 8px 10px; border: 2px solid var(--border); background: #fff; min-height: 44px; width: 100%; box-sizing: border-box; }
.kx-type .goal { font-size: 1.15rem; letter-spacing: .02em; word-break: break-word; }
.kx-type .goal .ok { color: var(--ok); } .kx-type .goal .bad { color: #fff; background: var(--bad); } .kx-type .goal .next { text-decoration: underline 3px var(--accent); }
.kx-type .hint { font-size: .85rem; color: var(--muted); }
.kx-type .hint kbd, .kx-key kbd { border: 2px solid var(--border); border-bottom-width: 4px; padding: 0 6px; font-weight: 800; background: #fff; }
.kx-type.done input { border-color: var(--ok); background: #eaf7ee; }
.dict .kx-en, .dict .kx-ko { display: none; }
.dict .kx-s.open .kx-en, .dict .kx-s.open .kx-ko { display: flex; }

/* 외우기 카드 */
.kx-drill { background: #fff7d6; border: 3px solid var(--border); box-shadow: var(--sh); padding: 14px; margin: 14px 0; }
.kx-drill .q { font-size: 1.35rem; font-weight: 800; margin: 6px 0; }
.kx-drill .pics canvas.px { width: 48px; height: 48px; margin-right: 6px; }
.kx-drill .ans { font-size: 1.3rem; font-weight: 800; color: var(--en); margin: 8px 0; }
.kx-drill .ans small { display: block; font-size: .7em; color: var(--rt); font-weight: 600; }
.kx-drill .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.kx-drill .stat { font-size: .85rem; color: var(--muted); }
.drill .kx-list { display: none; }

/* 글자 */
.kx-letters { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kx-l { background: var(--card); border: 3px solid var(--border); box-shadow: var(--sh); padding: 8px; display: grid; gap: 4px; justify-items: center; text-align: center; }
.kx-big { font-size: 2.6rem; line-height: 1.1; padding: 4px 14px; min-width: 72px; }
.kx-ln { font-weight: 800; } .kx-lr { color: var(--muted); font-size: .85rem; }
.kx-lex { font-size: .9rem; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; }
.kx-lex small { color: var(--muted); }
.kx-lt { display: flex; gap: 6px; }
.kx-key { font-size: .85rem; color: var(--muted); }
.kx-typebox { margin: 18px 0; background: var(--card); border: 3px solid var(--border); padding: 10px; display: grid; gap: 6px; }
#kxLtGoal { font-size: 1.6rem; font-weight: 800; letter-spacing: .2em; }

/* 따라 쓰기 */
.kx-dlg { overflow: hidden; box-sizing: border-box; border: 3px solid var(--border); box-shadow: 6px 6px 0 var(--border); padding: 10px; max-width: min(640px, 96vw); background: var(--card); }
.kx-dlg::backdrop { background: rgba(34, 32, 52, .45); }
.kx-dlg canvas { width: 100%; box-sizing: border-box; max-width: 100%; height: auto; background: #fff; border: 2px dashed var(--muted); touch-action: none; display: block; }
.kx-dlg-t { margin: 0 0 6px; } .kx-dlg-b { display: flex; gap: 8px; justify-content: flex-end; margin: 8px 0 0; }
#kxTrMsg.ok { color: var(--ok); font-weight: 800; } #kxTrMsg.bad { color: var(--bad); font-weight: 800; }
.kx-tr-on { outline: 3px solid var(--accent); }

.kx-pn { display: flex; justify-content: space-between; gap: 10px; margin: 30px 0 0; flex-wrap: wrap; }
.kx-pn a { color: var(--accent); font-weight: 800; text-decoration: none; padding: 10px 0; }
@media (max-width: 480px) { .kx-en ruby { font-size: 1.25rem; } .kx-ko ruby { font-size: 1.2rem; } .kx-letters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 이야기(md/koen-story.md): 장면·말하는 사람·멘토 */
.kx-scene { background: #222034; color: #fff; padding: 10px 12px; font-weight: 600; line-height: 1.6; margin: 6px 0 4px; box-shadow: var(--sh); }
.kx-sp { display: inline-flex; align-items: center; gap: 3px; font-weight: 800; }
.kx-sp canvas.px { width: 24px; height: 24px; }
.sp-mina { color: #b4237a; } .sp-mom { color: #8a3b2a; } .sp-dad { color: #2f6b4e; } .sp-bro { color: #b45309; }
.kx-mentor { background: #e8f1ff; border: 3px solid var(--border); box-shadow: var(--sh); padding: 12px 14px; margin: 22px 0 6px; }
.kx-mentor p { margin: 6px 0 0; line-height: 1.7; }
.kx-mentor2 { color: var(--muted); font-size: .92rem; }

/* 통째로 외울 문장 */
.kx-whole { font-weight: 800; color: #9a3412; background: #ffedd5; border: 2px solid #9a3412; padding: 0 6px; }
.kx-wl { padding-left: 1.4em; margin: 6px 0 0; display: grid; gap: 8px; }
.kx-wl li { line-height: 1.6; }
.kx-wl small { display: block; color: var(--rt); font-weight: 600; }
.drill .kx-wholes, .dict .kx-wholes { display: none; }
