/* 사주 고전 뷰어 — 색은 아래 토큰으로만. 다크 모드는 같은 토큰을 다시 정의한다.
   금지: 좌측 컬러 보더·::before 좌측 막대·inset 좌측 그림자(구분은 배경·전체 테두리·제목 띠·들여쓰기). 글자 14px 이상. */
:root {
  color-scheme: light;
  --bg: #f4efe5;
  --surface: #fbf8f2;
  --surface-2: #ece4d5;
  --surface-3: #e3d8c4;
  --ink: #231f19;
  --ink-soft: #5b5348;
  --line: #d6cab5;
  --line-strong: #b9a98f;
  --accent: #8a3526;
  --accent-ink: #ffffff;
  --accent-wash: #f3e1d9;
  --verse-bg: #efe2c8;
  --verse-band: #e2cfa8;
  --note-bg: #e9ecdf;
  --note-band: #d8dec7;
  --comm-band: #e6ddcd;
  --editor-bg: #f1ebe0;
  --easy-bg: #e5ede6;
  --easy-ink: #23392b;
  --chart-bg: #fffdf8;
  --upper-bg: #eef0f4;
  --upper-band: #dfe3ea;
  --day-bg: #f3e1d9;
  --focus: rgb(138 53 38 / 35%);
  --scale: 1;
  --sans: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --serif: "Noto Serif KR", "Nanum Myeongjo", AppleMyungjo, Batang, serif;
  --header-h: 60px;
  --gutter: 16px;
  font-family: var(--sans);
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #17150f;
    --surface: #1f1c16;
    --surface-2: #2a261e;
    --surface-3: #353026;
    --ink: #ece5d8;
    --ink-soft: #b8ad9b;
    --line: #3d362b;
    --line-strong: #5a5040;
    --accent: #e8957d;
    --accent-ink: #1a1510;
    --accent-wash: #3a2620;
    --verse-bg: #2c2618;
    --verse-band: #3d3420;
    --note-bg: #20261c;
    --note-band: #2d3626;
    --comm-band: #2c271f;
    --editor-bg: #24211a;
    --easy-bg: #1d2a22;
    --easy-ink: #cfe3d4;
    --chart-bg: #1b1913;
  --upper-bg: #1d2026;
  --upper-band: #2a2f38;
    --upper-bg: #1d2026;
    --upper-band: #2a2f38;
    --day-bg: #3a2620;
    --focus: rgb(232 149 125 / 45%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17150f;
  --surface: #1f1c16;
  --surface-2: #2a261e;
  --surface-3: #353026;
  --ink: #ece5d8;
  --ink-soft: #b8ad9b;
  --line: #3d362b;
  --line-strong: #5a5040;
  --accent: #e8957d;
  --accent-ink: #1a1510;
  --accent-wash: #3a2620;
  --verse-bg: #2c2618;
  --verse-band: #3d3420;
  --note-bg: #20261c;
  --note-band: #2d3626;
  --comm-band: #2c271f;
  --editor-bg: #24211a;
  --easy-bg: #1d2a22;
  --easy-ink: #cfe3d4;
  --chart-bg: #1b1913;
  --day-bg: #3a2620;
  --focus: rgb(232 149 125 / 45%);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
}

button,
input,
select,
textarea {
  font: inherit;
  font-family: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[lang="zh-Hant"] {
  font-family: var(--serif);
}

svg {
  flex: none;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 6px;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── 머리 ─────────────────────────────────────────── */
.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100% - 2 * var(--gutter), 1440px);
  min-height: var(--header-h);
  margin-inline: auto;
}

.site-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 10px 0 4px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 15px;
  text-decoration: none;
}

.site-back:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand-seal {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.brand-text strong {
  font-size: 16px;
  white-space: nowrap;
}

.brand-text small {
  color: var(--ink-soft);
  font-size: 14px;
}

.main-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.main-nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.main-nav a[aria-current="page"] {
  background: var(--accent-wash);
  color: var(--accent);
}

@media (max-width: 640px) {
  .brand-text small {
    display: none;
  }

  .brand-seal {
    display: none;
  }

  .header-inner {
    gap: 4px;
  }

  .site-back span {
    display: none;
  }

  .site-back {
    padding: 0 6px;
  }

  .main-nav a {
    padding: 0 8px;
    font-size: 14px;
  }

  .brand-text strong {
    font-size: 15px;
  }
}

@media (max-width: 400px) {
  .brand-text strong {
    font-size: 14px;
  }

  .main-nav {
    gap: 0;
  }

  .main-nav a {
    padding: 0 6px;
  }
}

main {
  display: block;
  min-height: 70vh;
}

main:focus {
  outline: none;
}

.wrap {
  width: min(100% - 2 * var(--gutter), 1200px);
  margin-inline: auto;
}

.loading,
.noscript {
  width: min(100% - 2 * var(--gutter), 1200px);
  margin: 40px auto;
  color: var(--ink-soft);
}

.error-box {
  margin: 32px 0;
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
}

/* ── 첫 화면 ─────────────────────────────────────── */
.hero {
  padding: 40px 0 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(26px, 4.4vw, 38px);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.hero-lead {
  max-width: 44em;
  margin: 0 0 8px;
  font-size: 17px;
}

.hero-lead b {
  font-variant-numeric: tabular-nums;
}

.entry-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-2);
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
}

.btn svg {
  width: 18px;
  height: 18px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-block: 16px 48px;
  padding: 0;
  list-style: none;
}

@media (max-width: 400px) {
  .book-grid {
    grid-template-columns: 1fr;
  }
}

.book-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.book-card h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

.book-card h2 a {
  color: var(--ink);
  text-decoration: none;
}

.book-card h2 a:hover {
  color: var(--accent);
}

.book-card .hanja {
  color: var(--ink-soft);
  font-size: 18px;
  font-weight: 500;
}

.book-meta {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.book-about {
  margin: 0;
  font-size: 16px;
}

.book-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 14px;
}

.book-facts dt {
  color: var(--ink-soft);
}

.book-facts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink);
}

.status.done {
  background: var(--easy-bg);
  color: var(--easy-ink);
}

.status.wip {
  background: var(--verse-bg);
  color: var(--ink);
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.book-card .btn {
  align-self: flex-start;
  margin-top: auto;
}

.method {
  margin-block: 0 48px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.method h2 {
  margin: 0 0 10px;
  font-size: 19px;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.stat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.stat-table th,
.stat-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.stat-table th:first-child,
.stat-table td:first-child {
  text-align: left;
}

.stat-table thead th {
  color: var(--ink-soft);
  font-weight: 600;
}

/* ── 책 읽기 ─────────────────────────────────────── */
.reader {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 32px;
  width: min(100% - 2 * var(--gutter), 1440px);
  margin-inline: auto;
}

.toc {
  position: sticky;
  top: calc(var(--header-h) + 1px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 1px);
  overflow-y: auto;
  padding: 16px 4px 32px 0;
  overscroll-behavior: contain;
}

.toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.toc-head h2 {
  margin: 0;
  font-size: 17px;
}

.toc-head h2 small {
  display: block;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
}

.toc-head .toc-close {
  display: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.toc-search {
  display: block;
  margin: 0 0 10px;
}

.toc-search input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: 16px;
}

.toc-group {
  margin: 0 0 8px;
}

.toc-group > summary,
.toc-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.toc-group > summary::-webkit-details-marker {
  display: none;
}

.toc-group > summary:hover {
  background: var(--surface-2);
}

.toc-group > summary svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s;
}

.toc-group[open] > summary svg {
  transform: rotate(90deg);
}

.toc-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-list a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 40px;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  text-decoration: none;
}

.toc-list a:hover {
  background: var(--surface-2);
}

.toc-list a[aria-current="page"] {
  background: var(--accent-wash);
  color: var(--accent);
  font-weight: 700;
}

.toc-list .toc-no {
  flex: none;
  min-width: 2.6em;
  color: var(--ink-soft);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.toc-list .toc-title {
  min-width: 0;
}

.toc-list a.not-ready {
  color: var(--ink-soft);
}

.toc-list .tag {
  flex: none;
  margin-left: auto;
  font-size: 14px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.toc-empty {
  padding: 8px;
  color: var(--ink-soft);
  font-size: 14px;
}

.reader-main {
  min-width: 0;
  padding-bottom: 64px;
}

.toolbar {
  position: sticky;
  z-index: 10;
  top: calc(var(--header-h) + 1px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 calc(-1 * var(--gutter));
  padding: 8px var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.toc-open {
  display: none;
}

.seg-toggle {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.seg-toggle button {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.seg-toggle button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.scale-ctl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.scale-ctl output {
  min-width: 3.2em;
  text-align: center;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.scale-ctl .icon-btn {
  width: 40px;
  height: 40px;
}

.scale-ctl .icon-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.sec-head {
  padding: 28px 0 8px;
}

.crumbs {
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 14px;
}

.crumbs a {
  color: var(--ink-soft);
}

.sec-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1.3;
}

.sec-head .sec-sub {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.sec-head .sec-sub a {
  white-space: nowrap;
}

.text-col {
  max-width: calc(40em * var(--scale));
  font-size: calc(17px * var(--scale));
}

/* 천미 단락 무리 — 제목 띠·배경·들여쓰기로만 구분 */
.blk {
  margin: 22px 0;
  border-radius: 10px;
}

.blk-band {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  padding: 6px 14px;
  border-radius: 10px 10px 0 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.blk-band .band-hanja {
  font-weight: 500;
  color: var(--ink-soft);
}

.blk-body {
  padding: 4px 16px 8px;
}

.blk-verse {
  background: var(--verse-bg);
}

.blk-verse > .blk-band {
  background: var(--verse-band);
}

.blk-note {
  margin-left: 1.5em;
  background: var(--note-bg);
}

.blk-note > .blk-band {
  background: var(--note-band);
}

.blk-commentary > .blk-band {
  background: var(--comm-band);
}

.blk-commentary > .blk-body {
  padding-inline: 0;
}

.blk-editor {
  margin-left: 1.5em;
  border: 1px dashed var(--line-strong);
  background: var(--editor-bg);
}

.blk-editor > .blk-band {
  border-bottom: 1px dashed var(--line-strong);
}

.blk-plain > .blk-body {
  padding-inline: 0;
}

@media (max-width: 640px) {
  .blk-note,
  .blk-editor {
    margin-left: 0.75em;
  }

  .blk-body {
    padding-inline: 12px;
  }
}

.seg {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: calc(var(--header-h) + 72px);
}

.blk-body > .seg:last-child,
.seg-list > .seg:last-child {
  border-bottom: 0;
}

.seg:target {
  background: var(--accent-wash);
  border-radius: 8px;
  outline: 2px solid var(--accent-wash);
  outline-offset: 6px;
}

.seg-src {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 1.06em;
  line-height: 1.95;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.seg-src .small {
  color: var(--ink-soft);
  font-size: 0.86em;
}

.seg-src .part-label {
  display: inline-block;
  margin: 0 6px 0 0;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 0;
  vertical-align: 0.1em;
}

.seg-src-part + .seg-src-part {
  margin-top: 8px;
}

.layer-verse .seg-src {
  font-size: 1.32em;
  font-weight: 600;
  line-height: 1.8;
}

.layer-note .seg-src {
  font-size: 1em;
}

.seg-ko {
  margin: 0;
  line-height: 1.9;
}

.seg-easy {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--easy-bg);
  color: var(--easy-ink);
  font-size: 0.94em;
  line-height: 1.75;
}

.seg-easy .lbl {
  margin-right: 6px;
  font-weight: 700;
}

.seg-more {
  margin: 10px 0 0;
  font-size: max(14px, 0.88em);
}

.seg-more > summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  color: var(--ink-soft);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.seg-more > summary::-webkit-details-marker {
  display: none;
}

.seg-more > summary svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s;
}

.seg-more[open] > summary svg {
  transform: rotate(90deg);
}

.seg-more dl {
  display: grid;
  grid-template-columns: minmax(4em, max-content) 1fr;
  gap: 4px 14px;
  margin: 4px 0 0;
}

.seg-more dt {
  font-weight: 700;
}

.seg-more dd {
  margin: 0;
}

.seg-more ul {
  margin: 4px 0 0;
  padding-left: 1.2em;
}

.seg-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 14px;
}

.seg-foot a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
}

.seg-foot svg {
  width: 15px;
  height: 15px;
}

.seg-no {
  font-variant-numeric: tabular-nums;
}

.mode-ko .seg-src,
.mode-ko .seg-src-part {
  display: none;
}

.mode-src .seg-ko,
.mode-src .seg-easy,
.mode-src .seg-more {
  display: none;
}

.mode-src .seg-src {
  margin-bottom: 0;
}

.not-ready-box {
  margin: 24px 0;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
}

.not-ready-box h2 {
  margin: 0 0 6px;
  font-size: 19px;
}

.not-ready-box p {
  margin: 0 0 6px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 36px 0 0;
}

.pager a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 64px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}

.pager a:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.pager .dir {
  color: var(--ink-soft);
  font-size: 14px;
}

.pager .t {
  font-family: var(--serif);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.pager .next {
  grid-column: 2;
  text-align: right;
}

/* 명조표 */
.chart {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--chart-bg);
  font-size: 15px;
  max-width: 34em;
}

.chart-cap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 8px;
}

.chart-title {
  font-weight: 700;
}

.chart-sub {
  color: var(--ink-soft);
  font-size: 14px;
}

.chart-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.chart-table {
  width: 100%;
  min-width: 280px;
  border-collapse: collapse;
  text-align: center;
  table-layout: fixed;
}

.chart-table th,
.chart-table td {
  padding: 4px 2px;
  border: 1px solid var(--line);
  vertical-align: middle;
}

.chart-table thead th {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
}

.chart-table .rowhead {
  width: 4.2em;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
}

.chart-table .r-god td {
  font-size: 14px;
}

.chart-table .r-stem td,
.chart-table .r-branch td {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.3;
}

.chart-table td.is-day {
  background: var(--day-bg);
}

.chart-table .r-hidden td {
  font-size: 14px;
  line-height: 1.4;
}

.hid {
  display: block;
  white-space: nowrap;
}

.hid-g {
  margin-right: 3px;
  font-size: 15px;
}

.hid-n {
  color: var(--ink-soft);
}

.luck {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.luck-label {
  flex: none;
  width: 3.4em;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
}

.luck-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.luck-list li {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 2.9em;
  padding: 3px 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.luck-gz {
  font-size: 17px;
  line-height: 1.35;
  writing-mode: horizontal-tb;
}

.luck-god {
  color: var(--ink-soft);
  font-size: 14px;
}

.chart-notes {
  margin: 10px 0 0;
  padding-left: 1.2em;
  color: var(--ink-soft);
  font-size: 14px;
}

/* 좁은 화면 목차 서랍 */
.toc-scrim {
  display: none;
}

@media (max-width: 1023px) {
  .reader {
    display: block;
  }

  .toc {
    position: fixed;
    z-index: 50;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(88vw, 360px);
    height: 100vh;
    height: 100dvh;
    max-height: none;
    padding: 12px 16px 32px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    visibility: hidden;
  }

  .reader.toc-is-open .toc {
    transform: none;
    visibility: visible;
  }

  .reader.toc-is-open .toc-scrim {
    display: block;
    position: fixed;
    z-index: 40;
    inset: 0;
    background: rgb(0 0 0 / 35%);
  }

  .toc-head .toc-close {
    display: inline-grid;
  }

  .toc-open {
    display: inline-flex;
    gap: 6px;
    width: auto;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 600;
  }
}

.lbl-short {
  display: none;
}

@media (max-width: 560px) {
  .toolbar {
    flex-wrap: nowrap;
    gap: 6px;
  }

  .toc-open .toc-open-text,
  .lbl-long,
  .scale-ctl output {
    display: none;
  }

  .lbl-short {
    display: inline;
  }

  .toolbar .toc-open {
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  .seg-toggle button {
    padding: 0 10px;
  }

  .scale-ctl .icon-btn {
    width: 38px;
    height: 38px;
  }
}

/* ── 주제 비교 ───────────────────────────────────── */
.compare {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 28px;
  width: min(100% - 2 * var(--gutter), 1600px);
  margin-inline: auto;
  padding-bottom: 64px;
}

.topic-nav {
  position: sticky;
  top: calc(var(--header-h) + 1px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 1px);
  overflow-y: auto;
  padding: 16px 4px 32px 0;
}

.topic-nav h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.topic-group {
  margin: 0 0 14px;
}

.topic-group h3 {
  margin: 0 0 4px;
  padding: 0 8px;
  color: var(--ink-soft);
  font-size: 14px;
}

.topic-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.topic-group a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 7px 8px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  text-decoration: none;
}

.topic-group a:hover {
  background: var(--surface-2);
}

.topic-group a[aria-current="page"] {
  background: var(--accent-wash);
  color: var(--accent);
  font-weight: 700;
}

.topic-group .n {
  color: var(--ink-soft);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.topic-group.chips ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 4px;
}

.topic-group.chips a {
  min-width: 3.2em;
  justify-content: center;
  border: 1px solid var(--line);
}

.topic-pick {
  display: none;
}

.cmp-main {
  min-width: 0;
}

.cmp-head {
  padding: 28px 0 6px;
}

.cmp-head h1 {
  margin: 0;
  font-size: clamp(24px, 3.6vw, 32px);
  line-height: 1.3;
}

.cmp-head p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.memo {
  margin: 16px 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.memo h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.memo.empty {
  border-style: dashed;
  color: var(--ink-soft);
  font-size: 15px;
}

.memo.empty p {
  margin: 0;
}

.memo dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 0;
}

.memo dt {
  font-weight: 700;
}

.memo dd {
  margin: 0;
}

.memo .diverge {
  margin: 10px 0 0;
}

.book-tabs {
  display: none;
}

.cols {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  gap: 14px;
  align-items: start;
  margin-top: 12px;
}

.col {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.col-head {
  position: sticky;
  z-index: 2;
  top: calc(var(--header-h) + 1px);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
  background: var(--surface-2);
}

.col-head h2 {
  margin: 0;
  font-size: 16px;
}

.col-head h2 .hanja {
  margin-left: 4px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
}

.col-head p {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.col-body {
  padding: 4px 12px 12px;
}

.col-empty {
  margin: 10px 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.sec-group {
  border-bottom: 1px solid var(--line);
}

.sec-group:last-child {
  border-bottom: 0;
}

.sec-group > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 0;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.sec-group > summary::-webkit-details-marker {
  display: none;
}

.sec-group > summary svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s;
}

.sec-group[open] > summary svg {
  transform: rotate(90deg);
}

.sec-group > summary .n {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
}

.sec-group > summary .t {
  min-width: 0;
  font-family: var(--serif);
  overflow-wrap: anywhere;
}

.item {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.sec-group .item:first-of-type {
  border-top: 0;
}

.item-sec {
  margin: 0 0 4px;
  color: var(--ink-soft);
  font-size: 14px;
}

.item-sec a {
  color: var(--ink-soft);
}

.item-ko {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
}

.item.clamped .item-ko {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-full {
  display: none;
}

.item.expanded .item-full {
  display: block;
}

.item-full .seg-src {
  margin: 8px 0 0;
  font-size: 16px;
}

.item-full .seg-easy {
  font-size: 15px;
}

.item-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 4px;
}

.link-btn {
  min-height: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.item-btns a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  font-size: 14px;
  font-weight: 600;
}

@media (max-width: 1279px) {
  .cols {
    display: block;
  }

  .col {
    display: none;
  }

  .col.is-active {
    display: block;
  }

  .col-head {
    position: static;
  }

  .book-tabs {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding-bottom: 4px;
    overflow-x: auto;
  }

  .book-tabs button {
    flex: none;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
  }

  .book-tabs button .n {
    margin-left: 4px;
    color: var(--ink-soft);
    font-weight: 500;
  }

  .book-tabs button[aria-selected="true"] {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
  }

  .book-tabs button[aria-selected="true"] .n {
    color: inherit;
  }

  .col-body {
    max-width: 44em;
  }
}

@media (max-width: 1023px) {
  .compare {
    display: block;
  }

  .topic-nav {
    display: none;
  }

  .topic-pick {
    display: block;
    margin: 16px 0 0;
  }

  .topic-pick label {
    display: block;
    margin-bottom: 4px;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 600;
  }

  .topic-pick select {
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    font-size: 16px;
  }
}

.topic-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 16px 0 48px;
}

.topic-index .topic-group {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

/* ── 일간×월 표 ──────────────────────────────────── */
.grid-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 10px 0 14px;
  padding: 0;
  color: var(--ink-soft);
  font-size: 14px;
  list-style: none;
}

.grid-legend b {
  color: var(--ink);
}

.grid-scroll {
  max-width: 100%;
  margin-bottom: 48px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.sm-grid {
  min-width: 960px;
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.sm-grid th,
.sm-grid td {
  border: 1px solid var(--line);
  padding: 0;
  text-align: center;
  vertical-align: top;
}

.sm-grid thead th {
  padding: 6px 2px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 600;
}

.sm-grid thead th .gz,
.sm-grid tbody th .gz {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.3;
}

.sm-grid tbody th {
  width: 64px;
  padding: 6px 2px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 600;
  vertical-align: middle;
}

.sm-grid thead th:first-child {
  width: 64px;
}

.sm-grid td a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 72px;
  padding: 6px 2px;
  color: var(--ink);
  text-decoration: none;
}

.sm-grid td a:hover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.sm-grid .cell-total {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sm-grid .cell-books {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.sm-grid td.empty {
  color: var(--ink-soft);
  font-size: 14px;
  vertical-align: middle;
}

.sm-grid td.heat-1 { background: color-mix(in srgb, var(--accent-wash) 40%, var(--surface)); }
.sm-grid td.heat-2 { background: color-mix(in srgb, var(--accent-wash) 75%, var(--surface)); }
.sm-grid td.heat-3 { background: var(--accent-wash); }

.sm-grid td a {
  height: 100%;
}

.sm-grid tbody th,
.sm-grid thead th:first-child {
  position: sticky;
  z-index: 1;
  left: 0;
}

/* ── 바닥 ───────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.footer-inner {
  width: min(100% - 2 * var(--gutter), 1200px);
  margin-inline: auto;
  padding: 22px 0 28px;
  color: var(--ink-soft);
  font-size: 14px;
}

.footer-inner p {
  margin: 0 0 6px;
}

.footer-inner a {
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

.seg-ko {
  white-space: pre-line;
}

/* 연해자평 上欄 평주: 본문 구간 사이에 끼는 작은 상자. 구분은 배경·전체 테두리·제목 띠로 */
.seg.layer-upper {
  margin: 4px 0 18px;
  padding: 0 14px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--upper-bg);
  font-size: 0.95em;
}
.upper-band {
  margin: 0 -14px 10px;
  padding: 6px 14px;
  border-radius: 10px 10px 0 0;
  background: var(--upper-band);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
}
.upper-band .band-hanja {
  margin-left: 6px;
  font-family: var(--serif);
  font-weight: 400;
}
/* 연해자평 표·도해: 원문 행을 그대로 */
.src-table {
  margin: 4px 0 20px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--chart-bg);
}
.src-table figcaption {
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 14px;
}
.src-table table {
  border-collapse: collapse;
}
.src-table td {
  padding: 4px 8px;
  border: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 15px;
  white-space: nowrap;
}

.memo .diverge-h {
  margin: 14px 0 6px;
  font-size: 15px;
}
.memo ul.diverge {
  margin: 0;
  padding-left: 1.2em;
  line-height: 1.7;
}
.memo ul.diverge li + li {
  margin-top: 6px;
}

/* 로그인 게이트 */
.gate {
  display: flex;
  justify-content: center;
  padding-top: 56px;
  padding-bottom: 72px;
}
.gate-box {
  max-width: 520px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-align: center;
}
.gate-box h1 {
  margin: 6px 0 12px;
  font-size: 24px;
}
.gate-box p {
  line-height: 1.75;
}
.gate-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}
