/* 월하전 — 달밤 테마 */
:root {
  --ink: #0b0f1a;
  --night: #141b2d;
  --night-2: #1b2438;
  --line: rgba(201, 169, 106, .22);
  --moon: #f3ead2;
  --text: #ddd6c4;
  --muted: #8b93a7;
  --gold: #c9a96a;
  --gold-soft: rgba(201, 169, 106, .12);
  --serif: 'Nanum Myeongjo', 'Noto Serif KR', serif;
  --sans: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --w: 1080px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  background-color: var(--ink);
  background-image: radial-gradient(ellipse 120% 100% at 50% 0%, #26304a 0%, var(--night) 45%, var(--ink) 100%);
  background-repeat: no-repeat;
  background-size: 100% 1100px;
  color: var(--text);
  font-family: var(--serif);
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: break-word;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 2px; }
.wrap { max-width: var(--w); margin: 0 auto; padding: 0 20px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* 머리 */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(11, 15, 26, .78);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: .14em; color: var(--moon); }
.brand-moon {
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, #fffaf0, var(--moon) 60%, #d8cba8);
  box-shadow: 0 0 14px 3px rgba(243, 234, 210, .25);
}
.brand small { font-size: 11px; color: var(--gold); letter-spacing: .3em; font-weight: 400; }
.nav { display: flex; gap: 22px; font-size: 15px; }
.nav a { color: var(--muted); transition: color .2s; padding: 6px 0; }
.nav a:hover, .nav a[aria-current] { color: var(--moon); }

/* 첫 화면 */
.hero { text-align: center; padding: 88px 0 72px; position: relative; }
.moon {
  width: 128px; height: 128px; border-radius: 50%; margin: 0 auto 40px;
  background: radial-gradient(circle at 40% 38%, #fffaf0 0%, var(--moon) 55%, #d8cba8 100%);
  box-shadow: 0 0 60px 18px rgba(243, 234, 210, .18), 0 0 140px 50px rgba(243, 234, 210, .06);
  animation: glow 6s ease-in-out infinite;
}
@keyframes glow { 50% { box-shadow: 0 0 70px 24px rgba(243, 234, 210, .24), 0 0 170px 60px rgba(243, 234, 210, .08); } }
@media (prefers-reduced-motion: reduce) { .moon { animation: none; } }
.hero h1 { font-size: clamp(46px, 11vw, 80px); font-weight: 800; letter-spacing: .25em; margin-right: -.25em; color: var(--moon); line-height: 1.2; }
.hanja { color: var(--gold); font-size: 15px; letter-spacing: .6em; margin: 14px -.6em 32px 0; }
.rule { width: 40px; height: 1px; background: var(--gold); opacity: .6; margin: 0 auto 28px; }
.hero p { font-size: 17px; line-height: 2; color: #d9d3c2; }
.hero .sign { margin-top: 28px; color: var(--gold); font-size: 14px; letter-spacing: .2em; }

/* 섹션 */
.section { padding: 56px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 24px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.section-head h2 { font-size: 22px; color: var(--moon); letter-spacing: .08em; }
.section-head .more { font-size: 14px; color: var(--muted); }
.section-head .more:hover { color: var(--gold); }
.empty { color: var(--muted); padding: 28px 0; text-align: center; font-size: 15px; }

/* 작품 카드 */
.works { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.work-card {
  display: flex; flex-direction: column; gap: 14px;
  padding: 26px 24px; border: 1px solid var(--line); border-radius: 4px;
  background: linear-gradient(180deg, rgba(27, 36, 56, .75), rgba(20, 27, 45, .55));
  transition: border-color .2s, transform .2s;
}
.work-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.work-card h3 { font-size: 22px; color: var(--moon); line-height: 1.4; }
.work-card p { font-size: 15px; color: var(--text); line-height: 1.8; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-family: var(--sans); font-size: 12px; }
.badge { padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.badge.status { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.work-card .foot { margin-top: auto; font-family: var(--sans); font-size: 13px; color: var(--muted); }

/* 최신 회차 */
.ep-list { list-style: none; border-top: 1px solid var(--line); }
.ep-list li { border-bottom: 1px solid var(--line); }
.ep-list a { display: flex; align-items: baseline; gap: 14px; padding: 16px 4px; transition: background .2s; }
.ep-list a:hover { background: var(--gold-soft); }
.ep-no { font-family: var(--sans); font-size: 13px; color: var(--gold); min-width: 44px; }
.ep-title { flex: 1; color: var(--moon); font-size: 16px; }
.ep-work { font-size: 13px; color: var(--muted); }
.ep-date { font-family: var(--sans); font-size: 12px; color: var(--muted); white-space: nowrap; }
.ep-list a.read .ep-title { color: var(--muted); }

/* 작품 상세 */
.work-hero { padding: 64px 0 40px; text-align: center; border-bottom: 1px solid var(--line); }
.work-hero .kicker { color: var(--gold); font-size: 13px; letter-spacing: .4em; margin-bottom: 18px; }
.work-hero h1 { font-size: clamp(30px, 6.5vw, 46px); color: var(--moon); line-height: 1.35; letter-spacing: .02em; }
.work-hero .logline { max-width: 640px; margin: 22px auto 0; font-size: 17px; line-height: 1.9; color: #d9d3c2; }
.work-hero .meta { justify-content: center; margin-top: 22px; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 24px; border-radius: 3px; font-family: var(--sans); font-size: 15px; font-weight: 600;
  border: 1px solid var(--gold); color: var(--ink); background: var(--gold); transition: filter .2s, background .2s;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--gold); }
.btn.ghost:hover { background: var(--gold-soft); }
.btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.synopsis { max-width: 680px; margin: 0 auto; }
.synopsis p { font-size: 17px; line-height: 2.05; margin-bottom: 1.1em; }
.synopsis p:last-child { color: var(--moon); font-weight: 700; }
.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.char { padding: 20px; border: 1px solid var(--line); border-radius: 4px; background: rgba(20, 27, 45, .5); }
.char h3 { color: var(--moon); font-size: 19px; }
.char h3 small { color: var(--gold); font-size: 13px; font-weight: 400; margin-left: 6px; }
.char .role { font-family: var(--sans); font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.char p { font-size: 14.5px; line-height: 1.8; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; font-family: var(--sans); font-size: 13px; color: var(--muted); }
.toolbar button { background: none; border: 1px solid var(--line); color: var(--muted); padding: 6px 12px; border-radius: 3px; cursor: pointer; font: inherit; }
.toolbar button:hover { color: var(--moon); border-color: var(--gold); }

/* 본문 뷰어 */
.reader-top { border-bottom: 1px solid var(--line); }
.reader-top .wrap { max-width: 760px; display: flex; align-items: center; justify-content: space-between; height: 54px; gap: 12px; font-family: var(--sans); font-size: 14px; }
.reader-top .back { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-top .back:hover { color: var(--moon); }
.reader-tools { display: flex; gap: 6px; flex-shrink: 0; }
.reader-tools button {
  min-width: 40px; height: 36px; padding: 0 10px; border-radius: 3px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--text); font: 600 13px var(--sans);
}
.reader-tools button:hover { border-color: var(--gold); color: var(--moon); }
.progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--gold); z-index: 40; }
.chapter { max-width: 720px; margin: 0 auto; padding: 56px 20px 40px; }
.chapter header { text-align: center; margin-bottom: 48px; }
.chapter header .work { font-size: 14px; color: var(--gold); letter-spacing: .1em; }
.chapter header h1 { font-size: clamp(26px, 6vw, 34px); color: var(--moon); margin-top: 10px; line-height: 1.4; }
.chapter header .no { font-family: var(--sans); font-size: 13px; color: var(--muted); margin-top: 10px; }
.prose { font-size: var(--fs, 18px); line-height: var(--lh, 2); color: var(--text); }
.prose p { margin-bottom: 1.15em; text-indent: 0; }
.prose p.dialog { }
.prose hr { border: 0; text-align: center; margin: 2.4em 0; color: var(--gold); }
.prose hr::before { content: '◇   ◇   ◇'; letter-spacing: .3em; font-size: 12px; }
.prose strong { color: var(--moon); }
.ai-note {
  margin: 56px 0 0; padding: 18px 20px; border: 1px solid var(--line); border-radius: 4px;
  font-family: var(--sans); font-size: 13px; line-height: 1.75; color: var(--muted); background: rgba(20, 27, 45, .5);
}
.ai-note strong { color: var(--text); }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; max-width: 720px; margin: 0 auto; padding: 24px 20px 72px; align-items: center; }
.pager a, .pager span { font-family: var(--sans); font-size: 14px; }
.pager .prev { justify-self: start; }
.pager .next { justify-self: end; }
.pager .list { color: var(--muted); }

/* 읽기 테마 */
body.paper { background: #f4efe3; color: #2b2a26; }
body.paper .prose { color: #2b2a26; }
body.paper .chapter header h1, body.paper .prose strong { color: #1a1916; }
body.paper .reader-top, body.paper .ai-note { border-color: rgba(120, 100, 60, .25); }
body.paper .ai-note { background: rgba(255, 255, 255, .5); color: #6b665a; }
body.paper .ai-note strong { color: #2b2a26; }
body.paper .reader-tools button { color: #2b2a26; border-color: rgba(120, 100, 60, .3); }
body.paper .reader-top .back, body.paper .chapter header .no, body.paper .pager .list { color: #6b665a; }
body.paper .chapter header .work, body.paper .pager a { color: #8a6a2c; }
body.paper .prose hr { color: #8a6a2c; }

/* 소개 페이지 */
.page { max-width: 720px; margin: 0 auto; padding: 64px 20px 80px; }
.page h1 { font-size: 32px; color: var(--moon); margin-bottom: 8px; }
.page .sub { color: var(--gold); letter-spacing: .3em; font-size: 13px; margin-bottom: 40px; }
.page h2 { font-size: 20px; color: var(--moon); margin: 44px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.page p, .page li { font-size: 16.5px; line-height: 2; }
.page ul { padding-left: 1.2em; }
.page li { margin-bottom: .4em; }

/* 바닥 */
.foot-site { border-top: 1px solid var(--line); padding: 36px 0 48px; margin-top: 40px; font-family: var(--sans); font-size: 13px; color: var(--muted); }
.foot-site .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; }
.foot-site a:hover { color: var(--moon); }
.foot-site .links { display: flex; gap: 16px; }

@media (max-width: 640px) {
  .top .wrap { height: 54px; }
  .brand small { display: none; }
  .nav { gap: 16px; font-size: 14px; }
  .hero { padding: 64px 0 52px; }
  .moon { width: 104px; height: 104px; margin-bottom: 32px; }
  .hero p { font-size: 16px; }
  .section { padding: 44px 0; }
  .works { grid-template-columns: 1fr; }
  .ep-list a { flex-wrap: wrap; gap: 4px 12px; }
  .ep-date { width: 100%; padding-left: 56px; }
  .chapter { padding-top: 40px; }
  .reader-tools button { min-width: 36px; padding: 0 8px; }
}

/* 작품 소개 확장: 표지·인물·관계도·세계관·세력·경지 */
.work-hero.has-cover .wrap { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 40px; align-items: center; text-align: left; }
.work-hero.has-cover .meta, .work-hero.has-cover .actions { justify-content: flex-start; }
.work-hero.has-cover .logline { margin-left: 0; }
.cover { width: 100%; height: auto; border-radius: 4px; border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(0, 0, 0, .45); }
.subnav { position: sticky; top: 60px; z-index: 15; background: rgba(11, 15, 26, .85); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.subnav .wrap { display: flex; gap: 20px; overflow-x: auto; height: 46px; align-items: center; font-family: var(--sans); font-size: 14px; scrollbar-width: none; }
.subnav a { color: var(--muted); white-space: nowrap; }
.subnav a:hover { color: var(--moon); }
.section[id] { scroll-margin-top: 120px; }
.note { font-family: var(--sans); font-size: 13px; color: var(--muted); margin-top: 14px; }
.ai-art { text-align: center; padding-bottom: 20px; }
.work-card.with-cover { flex-direction: row; gap: 18px; padding: 18px; }
.card-cover { width: 96px; height: 128px; object-fit: cover; border-radius: 3px; flex-shrink: 0; border: 1px solid var(--line); }
.card-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.chars { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.char-img { display: block; margin: -20px -20px 16px; border-bottom: 1px solid var(--line); background: #f3eee2; border-radius: 4px 4px 0 0; overflow: hidden; }
.char-img img { width: 100%; height: auto; transition: transform .3s; }
.char-img:hover img { transform: scale(1.02); }
.char h3 .badge { font-family: var(--sans); font-size: 11px; font-weight: 400; margin-left: 8px; vertical-align: middle; }
.rel-legend { display: flex; flex-wrap: wrap; gap: 16px; font-family: var(--sans); font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.rel-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.rel-map { overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; background: rgba(20, 27, 45, .45); }
.rel-map svg { display: block; min-width: 720px; width: 100%; height: auto; }
.rel-map .rl { stroke: rgba(221, 214, 196, .35); stroke-width: 1.5; }
.rel-map .rlab { font-family: var(--sans); font-size: 13px; fill: #c8c0ad; text-anchor: middle; paint-order: stroke; stroke: #141b2d; stroke-width: 5px; stroke-linejoin: round; }
.rel-map .rn circle { stroke: #0b0f1a; stroke-width: 3; }
.rel-map .rname { font-family: var(--serif); font-size: 16px; font-weight: 700; fill: var(--moon); text-anchor: middle; paint-order: stroke; stroke: #141b2d; stroke-width: 5px; }
.rel-map .rsub { font-family: var(--sans); font-size: 12px; fill: var(--muted); text-anchor: middle; paint-order: stroke; stroke: #141b2d; stroke-width: 4px; }
.rel-list { margin-top: 12px; font-family: var(--sans); font-size: 14px; }
.rel-list summary { cursor: pointer; color: var(--gold); }
.rel-list ul { list-style: none; margin-top: 10px; columns: 2 280px; }
.rel-list li { padding: 4px 0; break-inside: avoid; }
.rel-list li span { color: var(--muted); }
.world { max-width: 720px; }
.world h3 { color: var(--moon); font-size: 18px; margin: 28px 0 8px; }
.world h3:first-child { margin-top: 0; }
.world p { font-size: 16.5px; line-height: 2; margin-bottom: .8em; }
.facs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.fac { display: flex; gap: 16px; align-items: flex-start; padding: 16px; border: 1px solid var(--line); border-radius: 4px; background: rgba(20, 27, 45, .5); }
.fac img { width: 96px; height: 96px; flex-shrink: 0; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0,0,0,.45)); }
.fac h3 { color: var(--moon); font-size: 17px; margin-bottom: 4px; }
.fac p { font-size: 14.5px; line-height: 1.8; }
.table-wrap { overflow-x: auto; }
.realms { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 14.5px; min-width: 560px; }
.realms th, .realms td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.realms thead th { color: var(--muted); font-weight: 600; font-size: 13px; }
.realms tbody th { color: var(--moon); font-family: var(--serif); font-size: 16px; white-space: nowrap; }
.realms td:first-child { color: var(--gold); width: 48px; }
@media (max-width: 640px) {
  .work-hero.has-cover .wrap { grid-template-columns: 1fr; text-align: center; gap: 24px; }
  .work-hero.has-cover .meta, .work-hero.has-cover .actions { justify-content: center; }
  .work-hero.has-cover .logline { margin-left: auto; }
  .cover { max-width: 220px; margin: 0 auto; }
  .subnav { top: 54px; }
  .chars, .facs { grid-template-columns: 1fr; }
  .realms { min-width: 0; font-size: 13.5px; }
  .realms th, .realms td { padding: 10px 6px; }
  .realms td:first-child, .realms thead th:first-child { display: none; }
  .realms td:nth-child(3) { white-space: nowrap; }
  .rel-map::before { content: '← 옆으로 밀어서 보기 →'; display: block; padding: 8px 0 0; text-align: center; font-family: var(--sans); font-size: 12px; color: var(--muted); position: sticky; left: 0; width: 100%; }
}
