/* classics.<도메인> — 한지 같은 종이 화면(기본)과 먹빛 밤 화면. 원문은 명조(Noto Serif TC/KR), 독음은 루비, 화면 글자는 Pretendard.
   틀: web/templates/classics/base.html, 동작: classics.js */
:root {
  --paper: #f4eee2; --paper2: #ebe2cf; --card: #fbf7ee; --line: #ded2b8; --ink: #1f1a14; --ink2: #4a4236; --mute: #6b6252;
  --seal: #b23a2b; --seal2: #8f2a1f; --gold: #9a6a0a; --rt: #9a5b1e; --link: #7a2e22;
  --zh-font: 'Noto Serif KR', 'AppleMyungjo', 'Songti TC', 'PMingLiU', serif; /* 한자도 Noto Serif KR(KS X 1001 한자) — TC 를 함께 받으면 글꼴 조각이 많아 감속 모바일에서 다 받는 데 30초 걸렸다. 없는 희귀자는 기기 명조 */
  --ko-font: 'Noto Serif KR', 'AppleMyungjo', serif;
  --fs: 1.7rem;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #14120f; --paper2: #1c1915; --card: #1f1b16; --line: #3a3228; --ink: #ece4d4; --ink2: #c9bfad; --mute: #a39887;
  --seal: #e0604c; --seal2: #c84a37; --gold: #e2b85c; --rt: #e3b277; --link: #f0a08f;
  color-scheme: dark;
}
:root[data-fs="1"] { --fs: 1.45rem; } :root[data-fs="3"] { --fs: 2.05rem; } :root[data-fs="4"] { --fs: 2.45rem; }
/* 공용 조각(_site_foot·_channel·_related)이 읽는 이름을 이 사이트 색으로 */
:root { --text: var(--ink); --text-sub: var(--ink2); --muted: var(--mute); --faint: var(--mute); --border: var(--line); --accent: var(--seal); --accent2: var(--gold); }

body.cx { margin: 0; background: var(--paper); color: var(--ink);
  background-image: radial-gradient(circle at 12% 0%, rgba(178,58,43,.06), transparent 40%), radial-gradient(circle at 100% 30%, rgba(154,106,10,.05), transparent 45%); }
body.cx::before { display: none; }
.cx a { color: var(--link); }
.cx-wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.cx-narrow { max-width: 780px; }

.cx-nav { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.cx-nav-in { max-width: 1040px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.cx-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink) !important; font-weight: 800; flex: none; }
.cx-seal { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; background: var(--seal); color: #fff6ea;
  font-family: var(--zh-font); font-weight: 700; font-size: 1.05rem; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.cx-brand-t { font-size: 1rem; white-space: nowrap; }
.cx-tabs { margin-left: auto; display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.cx-tabs::-webkit-scrollbar { display: none; }
.cx-tabs a, .cx-tabs button { flex: none; display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 10px; border-radius: 8px;
  color: var(--ink2) !important; text-decoration: none; font: inherit; background: none; border: 0; cursor: pointer; }
.cx-tabs a b { font-family: var(--zh-font); font-weight: 700; font-size: 1.02rem; }
.cx-tabs a.on, .cx-tabs a:hover, .cx-tabs button:hover { background: var(--paper2); color: var(--seal) !important; }
.cx-tabs .ic svg { width: 20px; height: 20px; }
.cx-tabs a:focus-visible, .cx-tabs button:focus-visible { outline: 2px solid var(--seal); outline-offset: 1px; }

.cx-main { padding: 24px 0 40px; min-height: 60vh; }
.cx-hero { text-align: center; padding: 28px 0 22px; }
.cx-hero-sm { padding: 14px 0 10px; }
.cx-kick { font-family: var(--zh-font); color: var(--seal); letter-spacing: .3em; font-weight: 700; margin: 0 0 8px; }
.cx-hero h1 { font-family: var(--ko-font); font-size: clamp(1.7rem, 4.5vw, 2.5rem); margin: 0 0 12px; letter-spacing: -.01em; }
.cx-lead { max-width: 640px; margin: 0 auto; color: var(--ink2); line-height: 1.75; word-break: keep-all; }
html:not([lang="ko"]) .cx-lead { word-break: normal; }
.cx-search { display: flex; gap: 8px; max-width: 560px; margin: 20px auto 0; }
.cx-search input { flex: 1; min-width: 0; height: 46px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 16px; }
.cx-search input:focus { outline: none; border-color: var(--seal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--seal) 22%, transparent); }
.cx-search button { width: 46px; border-radius: 10px; border: 0; background: var(--seal); color: #fff; cursor: pointer; }
.cx-search button svg { width: 20px; height: 20px; }
.cx-hint, .cx-count { color: var(--mute); font-size: .86rem; text-align: center; }

.cx-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; margin: 0 0 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,.5) inset, 0 10px 30px -22px rgba(60,40,10,.35); }
.cx-card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.cx-card-h h2 { font-size: .9rem; letter-spacing: .08em; color: var(--seal); margin: 0; }
.cx-ref { font-size: .88rem; text-decoration: none; font-weight: 700; }
.cx-sec-h { font-family: var(--ko-font); font-size: 1.25rem; margin: 26px 0 12px; }

/* 원문 + 독음 루비 */
.cx-zh { font-family: var(--zh-font); font-size: calc(var(--fs) * .78); line-height: 2.5; margin: 6px 0 12px; letter-spacing: .04em; word-break: break-all; }
.cx-zh-lg { font-size: var(--fs); line-height: 2.35; }
.cx-zh ruby { ruby-position: over; }
.cx-zh rt { font-family: var(--ko-font); font-size: .4em; color: var(--rt); font-weight: 600; letter-spacing: 0; user-select: none; }
.ruby-off .cx-zh rt { visibility: hidden; }
.cx-rd { color: var(--mute); font-size: .92rem; letter-spacing: .02em; margin: -4px 0 14px; }
.ruby-off .cx-rd { display: none; }
.cx-ko { font-family: var(--ko-font); font-size: 1.08rem; line-height: 1.9; margin: 0 0 12px; word-break: keep-all; }
/* 일본어·중국어 번역: keep-all 이면 띄어쓰기 없는 글이 줄을 못 바꾼다 — 기본 줄바꿈, 그 언어 명조 */
.cx-ko[lang="ja"], .cx-ko[lang="zh-Hans"], .cx-qm[lang="ja"], .cx-qm[lang="zh-Hans"], small [lang="ja"], small [lang="zh-Hans"], small[lang="ja"], small[lang="zh-Hans"] { word-break: normal; line-break: strict; }
.cx-ko[lang="ja"] { font-family: 'Hiragino Mincho ProN', 'Yu Mincho', 'YuMincho', 'Noto Serif JP', 'Noto Serif CJK JP', serif; }
.cx-ko[lang="zh-Hans"] { font-family: 'Songti SC', 'STSong', 'Noto Serif SC', 'Noto Serif CJK SC', 'SimSun', serif; }
.cx-en { font-size: 1rem; line-height: 1.75; color: var(--ink2); margin: 0 0 6px; }
.cx-tr h2 { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); margin: 18px 0 6px; }
/* 천자문 훈음 표 — 글자 · 훈 음 */
.cx-hun { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.cx-hun li { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.cx-hun b { font-family: var(--zh-font); font-size: 1.6rem; line-height: 1.1; }
.cx-hun span { font-size: .78rem; color: var(--ink2); text-align: center; word-break: keep-all; }
.cx-note { color: var(--mute); border-left: 3px solid var(--line); padding: 6px 12px; }
.cx-where { margin: 0 0 10px; font-size: .9rem; }
.cx-where a { text-decoration: none; }
.cx-ch h1 { font-family: var(--ko-font); font-size: 1.35rem; margin: 0 0 12px; }
.cx-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.cx-bar button { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink2); font: inherit; font-size: .85rem; cursor: pointer; }
.cx-bar button[aria-pressed="true"] { border-color: var(--seal); color: var(--seal); }
.cx-bar button.on { background: var(--seal); color: #fff; border-color: var(--seal); }
.cx-bar button:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }
.cx-pn { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin: 6px 0 0; }
.cx-pn a { text-decoration: none; font-weight: 700; font-size: .92rem; padding: 10px 0; }
.cx-pn .next { text-align: right; } .cx-pn .up { color: var(--mute); padding: 10px 12px; min-width: 44px; text-align: center; }

/* 홈 책 목록 */
.cx-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.cx-book { display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink) !important;
  transition: transform .15s, border-color .15s; position: relative; overflow: hidden; }
.cx-book:hover { transform: translateY(-2px); border-color: var(--seal); }
.cx-book-t { font-family: var(--zh-font); font-size: 2rem; font-weight: 700; color: var(--seal); line-height: 1.1; }
.cx-book b { font-size: 1.05rem; }
.cx-book small { color: var(--ink2); line-height: 1.6; word-break: keep-all; }
html:not([lang="ko"]) .cx-book small { word-break: normal; }
.cx-book-n { margin-top: auto; font-size: .8rem; color: var(--mute); font-weight: 700; }

/* 목차 */
.cx-toc-h { display: flex; align-items: baseline; gap: 8px; font-family: var(--zh-font); font-size: 1.2rem; margin: 0 0 8px; color: var(--seal); }
.cx-toc-h small { font-family: inherit; font-size: .8rem; color: var(--mute); }
.cx-list, .cx-results { list-style: none; margin: 0; padding: 0; }
.cx-list li + li, .cx-results li + li { border-top: 1px dashed var(--line); }
.cx-list a, .cx-results a { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 10px; padding: 10px 2px; text-decoration: none; color: var(--ink) !important; }
.cx-results a { grid-template-columns: 1fr; gap: 3px; }
.cx-list a:hover .cx-s > span, .cx-results a:hover span[lang] { color: var(--seal); }
.cx-l { font-size: .84rem; color: var(--mute); font-weight: 700; }
.cx-s { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cx-s > span, .cx-results span[lang] { font-family: var(--zh-font); font-size: 1.05rem; }
.cx-s small, .cx-results small { color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-results small { white-space: normal; }
.cx-wait { color: var(--mute) !important; font-style: italic; }
.cx-list a.wait .cx-s > span { color: var(--mute); }

/* 푸터 */
.cx-foot { max-width: 1040px; margin: 0 auto; padding: 10px 16px 40px; }
.cx-crumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: .82rem; color: var(--mute); margin: 16px 0 8px; }
.cx-crumb a { color: var(--mute); text-decoration: none; }
.cx-legal { display: flex; flex-wrap: wrap; gap: 12px; font-size: .78rem; margin: 8px 0; }
.cx-legal a { color: var(--mute); }
.cx-src { font-size: .78rem; color: var(--mute); line-height: 1.6; margin: 12px 0 0; }
.cx-empty { text-align: center; padding: 40px; }

@media (max-width: 560px) {
  .cx-brand-t { display: none; }
  .cx-card { padding: 16px; }
  .cx-list a { grid-template-columns: 5.6em minmax(0, 1fr); }
  .cx-zh-lg { line-height: 2.25; }
}
/* 명구 모음(/quotes) */
.cx-qg { margin: 22px 0 6px; }
.cx-qh { font-size: 1.05rem; margin: 0 0 8px; }
.cx-qh a { color: inherit; text-decoration: none; }
.cx-qh span { color: var(--mute, #8a7f6e); font-weight: 500; margin-left: 4px; }
.cx-ql { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.cx-ql a { display: block; padding: 12px 16px 12px; border-radius: 14px; background: var(--card, #fffaf0); border: 1px solid var(--line, #e6dccb); color: inherit; text-decoration: none; }
.cx-ql a:hover { border-color: var(--seal, #b23a2b); }
.cx-ql .cx-zh { margin: 2px 0 4px; }
.cx-qm { margin: 0 0 6px; line-height: 1.6; word-break: keep-all; }
.cx-ql-ref { font-size: .82rem; color: var(--mute, #8a7f6e); }
.cx-qlink { margin: 4px 0 14px; } .cx-qlink a { display: inline-block; padding: 9px 14px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); color: var(--link); font-weight: 600; text-decoration: none; }

/* 이어 읽기·읽은 장(classics.js, 이 기기 localStorage) */
.cx-resume { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 16px; }
.cx-go { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 99px; background: var(--seal2); color: #fff !important; font-weight: 700; text-decoration: none; }
.cx-off { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 4px 0 16px; }
.cx-off-b { min-height: 44px; padding: 0 18px; border-radius: 99px; border: 1.5px solid var(--seal); background: transparent; color: var(--seal); font: inherit; font-weight: 700; cursor: pointer; }
.cx-off-b:disabled { opacity: .6; cursor: default; }
.cx-off span { font-size: .8rem; color: var(--mute); font-weight: 700; }
.cx-resume span, .cx-book-r { font-size: .8rem; color: var(--mute); font-weight: 700; }
.cx-book-r { color: var(--seal); }
.cx-list a.seen .cx-l::after { content: " ✓"; content: " ✓" / ""; color: var(--seal); font-weight: 700; }
.cx-list a.seen .cx-s > span { color: var(--ink2); }
.cx-toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: min(92vw, 420px); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: var(--card); font-size: .9rem; line-height: 1.5; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 50; }
.cx-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 글자 풀이(원문 한자를 누르면 아래에서 올라오는 작은 창) */
.cx-zh ruby { cursor: pointer; border-radius: 4px; -webkit-tap-highlight-color: transparent; }
.cx-zh ruby.cx-sel { background: color-mix(in srgb, var(--seal) 18%, transparent); }
.cx-zh ruby:focus-visible { outline: 2px solid var(--seal); outline-offset: 1px; }
.cx-chp { box-sizing: border-box; position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(94vw, 440px); max-height: 60vh; overflow-y: auto;
  padding: 14px 18px 12px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 14px 40px rgba(0, 0, 0, .28); z-index: 40; color: var(--ink); }
.cx-chp[hidden], .cx [hidden] { display: none !important; } /* 클래스의 display(flex·grid)가 hidden 을 이기던 것 — 빈 이어 읽기·저장 줄이 16px 자리를 차지했다 */
.cx-chp .x { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border: 0; background: none; color: var(--mute); font-size: 1.1rem; cursor: pointer; }
.cx-chp .g { font-family: var(--zh-font); font-size: 2.6rem; line-height: 1.1; color: var(--seal); margin: 0 0 6px; }
.cx-chp dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: .92rem; line-height: 1.5; }
.cx-chp dt { color: var(--mute); font-weight: 700; font-size: .8rem; padding-top: 2px; }
.cx-chp dd { margin: 0; overflow-wrap: anywhere; }
.cx-chp .n { margin: 0; color: var(--ink2); }
.cx-chp .s { margin: 8px 0 0; font-size: .72rem; color: var(--mute); }
.cx-tip { margin: -6px 0 12px; font-size: .78rem; color: var(--mute); }

/* 외우기(classics.js memo) — 가린 글자는 자리만 남기고, 독음은 힌트로 남는다 */
.cx-zh.memo ruby.cx-m { color: transparent; background: color-mix(in srgb, var(--seal) 9%, transparent); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--seal) 55%, transparent); }
.cx-zh.memo ruby.cx-m rt { color: var(--rt); }
.cx-zh.memo ruby.cx-pk { color: var(--seal); }
.cx-memo { margin: 0 0 14px; padding: 12px; border: 1px dashed var(--seal); border-radius: 12px; background: var(--paper); }
.cx-mrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cx-mrow b { font-size: .85rem; color: var(--seal); min-width: 5.5em; text-align: center; }
.cx-memo button { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: .88rem; cursor: pointer; }
.cx-memo button:disabled { opacity: .45; cursor: default; }
.cx-memo button.pri { border-color: var(--seal); color: var(--seal); font-weight: 700; }
.cx-mtip { margin: 8px 0 0; font-size: .8rem; color: var(--mute); }
.cx-mask { margin: 12px 0 6px; font-weight: 700; font-size: .9rem; }
.cx-mq { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cx-mq button { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 4px 2px; border-radius: 12px; min-height: 52px; line-height: 1.2; }
.cx-mq small { font-size: .72rem; color: var(--mute); }
.cx-mfoot { margin-top: 12px; justify-content: space-between; }
.cx-mnext { font-size: .85rem; font-weight: 700; color: var(--ink2); }
.cx-due ol { margin: 8px 0; padding-left: 1.2em; }
.cx-due li { margin: 2px 0; }
.cx-due li a { display: inline-flex; align-items: center; min-height: 40px; color: var(--link); font-weight: 600; }
.cx-due p { margin: 4px 0 0; font-size: .82rem; color: var(--mute); }

/* 책갈피·내 서재·백업 (classics.js '책갈피·내 서재·백업') */
.cx-list a.star .cx-l::before { content: "★ "; content: "★ " / ""; color: var(--seal); }
.cx-list a.jot .cx-l::after { content: " ✎"; content: " ✎" / ""; color: var(--seal); }
.cx-list a.seen.jot .cx-l::after { content: " ✓ ✎"; content: " ✓ ✎" / ""; }
.cx-bar button.has { border-color: var(--seal); color: var(--seal); font-weight: 700; }
.cx-jot { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.cx-jot label { display: block; margin: 0 0 6px; font-size: .85rem; font-weight: 700; color: var(--ink2); }
.cx-jot textarea { display: block; box-sizing: border-box; width: 100%; min-height: 6.5em; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink);
  font: inherit; font-size: 1rem; line-height: 1.6; resize: vertical; }
.cx-jot textarea:focus-visible { outline: 2px solid var(--seal); outline-offset: 1px; border-color: var(--seal); }
.cx-jst { margin: 4px 0 0; min-height: 1.2em; font-size: .78rem; color: var(--mute); }
.cx-jh { margin: 14px 0 0; font-size: .9rem; color: var(--ink2); }
.cx-jots a small { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cx-mine { margin-top: 18px; }
.cx-stars { list-style: none; margin: 4px 0 8px; padding: 0; }
.cx-stars li { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.cx-stars li:last-child { border-bottom: 0; }
.cx-stars a { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; min-height: 44px; padding: 4px 0; color: var(--link); font-weight: 600; overflow-wrap: anywhere; text-decoration: none; }
.cx-stars a small { font-weight: 400; color: var(--mute); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cx-stars button { flex: none; width: 44px; height: 44px; border: 0; background: none; color: var(--mute); font-size: 1rem; cursor: pointer; border-radius: 8px; }
.cx-stars button:hover, .cx-stars button:focus-visible { color: var(--seal); background: var(--line); }
.cx-stars .cx-none { color: var(--mute); font-size: .85rem; padding: 6px 0; border: 0; }
.cx-mstat { margin: 4px 0 10px; font-size: .82rem; color: var(--mute); font-weight: 700; }
.cx-bk { display: flex; flex-wrap: wrap; gap: 8px; }
.cx-bk button, .cx-imp { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink2); font: inherit; font-size: .85rem; cursor: pointer; }
.cx-imp input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.cx-imp { position: relative; }
.cx-imp:focus-within, .cx-bk button:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; }
.cx-bknote { margin: 10px 0 0; font-size: .78rem; color: var(--mute); }

/* 본문으로 건너뛰기 — 탭을 처음 누르면 맨 위에 나타난다(위 공용 띠·메뉴 17칸을 건너뛴다) */
a.skip { position: fixed; left: 8px; top: -80px; z-index: 1000; padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--card); font-weight: 700; text-decoration: none; }
a.skip:focus { top: 60px; } /* 공용 위 띠(52px, 맨 위 z-index) 아래 */
main:focus { outline: none; }
