/* ===========================================================
   PRISNNATRIX — 小說閱讀器樣式（沿用 style.css 的變數與配色）
   =========================================================== */

:root { --reader-scale: 1; }

/* ---------- 語言切換 ---------- */
.lang-switch { display: inline-flex; gap: 0; margin-top: 26px; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.lang-switch button {
  background: transparent; color: var(--text-dim); border: 0; cursor: pointer;
  font: inherit; font-size: .9rem; letter-spacing: .04em; padding: 8px 18px;
  transition: all .2s var(--ease);
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button.on { background: var(--accent); color: #111; font-weight: 700; }

/* ---------- 目錄 ---------- */
.toc { list-style: none; counter-reset: none; max-width: 760px; }
.toc-loading { color: var(--text-dim); }
.toc-item { border-top: 1px solid var(--line); }
.toc-item:last-child { border-bottom: 1px solid var(--line); }
.toc-item a {
  display: grid; grid-template-columns: 56px 1fr 28px; align-items: center; gap: 18px;
  padding: 22px 6px; transition: all .25s var(--ease);
}
.toc-item a:hover { padding-left: 16px; }
.toc-no { font-family: "Noto Serif TC", serif; color: var(--accent); font-size: 1.1rem; letter-spacing: .06em; }
.toc-title { font-size: 1.12rem; color: var(--text); }
.toc-go { color: var(--text-dim); text-align: right; transition: color .25s var(--ease); }
.toc-item a:hover .toc-go { color: var(--accent); }
.toc-item a:hover .toc-title { color: var(--accent-2); }

/* ---------- 繼續閱讀（讀者進度） ---------- */
.continue-reading {
  display: flex; flex-direction: column; gap: 4px;
  max-width: 760px; margin-bottom: 26px; padding: 18px 22px;
  background: linear-gradient(100deg, rgba(201,161,74,.12), rgba(201,161,74,.03));
  border: 1px solid var(--accent); border-radius: var(--radius);
  transition: all .25s var(--ease);
}
.continue-reading:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(201,161,74,.12); }
.continue-reading .cr-label { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.continue-reading .cr-title { font-size: 1.12rem; color: var(--text); }

/* ---------- 閱讀進度條 ---------- */
.read-progress { position: sticky; top: 70px; z-index: 40; height: 2px; background: transparent; }
.read-progress span { display: block; height: 100%; width: 0; background: var(--accent); box-shadow: 0 0 10px var(--accent); transition: width .1s linear; }

/* ---------- 閱讀區 ---------- */
.reader { padding: 40px 0 100px; }
.reader-wrap { max-width: 760px; }

.reader-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 46px; flex-wrap: wrap; }
.reader-back { color: var(--text-dim); font-size: .95rem; transition: color .2s var(--ease); }
.reader-back:hover { color: var(--accent); }
.reader-tools { display: flex; align-items: center; gap: 12px; }
.reader-tools .lang-switch { margin-top: 0; }
.font-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.font-switch button {
  background: transparent; color: var(--text-dim); border: 0; cursor: pointer;
  font: inherit; font-size: .9rem; padding: 8px 14px; transition: all .2s var(--ease);
}
.font-switch button:hover { color: var(--accent); }

/* 章首 */
.chapter-head { margin-bottom: 40px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.chapter-head .eyebrow { margin-bottom: 12px; }
.chapter-head h1 { font-size: clamp(1.8rem, 4.5vw, 2.8rem); font-weight: 700; line-height: 1.25; }

/* 正文 */
.chapter-body {
  font-size: calc(1.12rem * var(--reader-scale));
  line-height: 2.05; color: #dadae0; letter-spacing: .01em;
}
.chapter-body p { margin: 0 0 1.5em; }
.chapter-body p:first-of-type { margin-top: 0; }
.chapter-body .scene-break { text-align: center; color: var(--accent); letter-spacing: .5em; margin: 2.4em 0; opacity: .8; }
.chapter-body em, .chapter-body i { color: var(--accent-2); font-style: italic; }
.chapter-body h2, .chapter-body h3 { color: var(--text); margin: 1.8em 0 .8em; line-height: 1.4; }

/* 章節裝飾符號 */
.chapter-ornament {
  text-align: center; font-size: 1.3rem; letter-spacing: .3em;
  color: var(--accent); margin: 0.5em 0 1.8em; opacity: .85;
  font-family: "Noto Serif TC", serif;
}

/* 上下章導覽 */
.chapter-nav {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center;
  margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--line);
}
.chapter-nav-link {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 18px;
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: all .25s var(--ease); background: var(--bg-card);
}
.chapter-nav-link.end { text-align: right; align-items: flex-end; }
.chapter-nav-link:hover { border-color: var(--accent); transform: translateY(-2px); }
.chapter-nav-link.is-disabled { opacity: .32; pointer-events: none; }
.cn-label { color: var(--accent); font-size: .85rem; letter-spacing: .06em; }
.cn-sub { color: var(--text-dim); font-size: .92rem; }
.chapter-nav-toc { color: var(--text-dim); font-size: .9rem; padding: 0 8px; white-space: nowrap; transition: color .2s var(--ease); }
.chapter-nav-toc:hover { color: var(--accent); }

/* ===========================================================
   角色百科
   =========================================================== */
.char-tools { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.char-search {
  flex: 1 1 240px; max-width: 320px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px;
  padding: 11px 18px; color: var(--text); font: inherit; transition: border-color .2s var(--ease);
}
.char-search:focus { outline: none; border-color: var(--accent); }
.char-tags { display: flex; gap: 10px; flex-wrap: wrap; }
.char-tag {
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  color: var(--text-dim); font: inherit; font-size: .88rem; padding: 7px 16px; cursor: pointer;
  transition: all .2s var(--ease);
}
.char-tag:hover { color: var(--text); border-color: var(--accent); }
.char-tag.on { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }

.char-grid { margin-top: 28px; }
.char-empty { color: var(--text-dim); margin-top: 30px; }

.char-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 34px 24px; cursor: pointer; font: inherit; color: inherit;
  transition: all .3s var(--ease);
}
.char-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.char-avatar {
  width: 96px; height: 96px; border-radius: 50%; margin-bottom: 14px;
  background: linear-gradient(140deg, #26262c, #14141a); background-size: cover; background-position: center;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: "Noto Serif TC", serif; font-size: 2.2rem; font-weight: 800; color: var(--accent);
}
.char-card:hover .char-avatar { border-color: var(--accent); }
.char-card-name { font-size: 1.18rem; color: var(--text); }
.char-card-role { font-size: .85rem; letter-spacing: .08em; color: var(--accent); }

/* ---------- 詳情 Modal ---------- */
.char-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.char-modal-backdrop { position: absolute; inset: 0; background: rgba(6,6,8,.78); backdrop-filter: blur(6px); }
.char-modal-panel {
  position: relative; z-index: 1; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 38px; box-shadow: 0 30px 80px rgba(0,0,0,.5);
  animation: cm-in .3s var(--ease);
}
@keyframes cm-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.char-modal-close {
  position: absolute; top: 16px; right: 18px; background: none; border: 0; cursor: pointer;
  color: var(--text-dim); font-size: 1.8rem; line-height: 1; transition: color .2s var(--ease);
}
.char-modal-close:hover { color: var(--accent); }
.cm-head { display: flex; gap: 20px; align-items: center; margin-bottom: 22px; }
.cm-avatar {
  width: 84px; height: 84px; flex: 0 0 84px; border-radius: 50%;
  background: linear-gradient(140deg, #26262c, #14141a); background-size: cover; background-position: center;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: "Noto Serif TC", serif; font-size: 2rem; font-weight: 800; color: var(--accent);
}
.cm-role { color: var(--accent); font-size: .85rem; letter-spacing: .1em; margin-bottom: 4px; }
.cm-head h2 { font-size: 1.6rem; line-height: 1.2; }
.cm-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.cm-tag { font-size: .72rem; letter-spacing: .08em; color: var(--text-dim); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.cm-summary { color: #d6d6dd; line-height: 1.9; margin-bottom: 8px; }
.cm-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .95rem; }
.cm-dl dt { color: var(--text-dim); white-space: nowrap; }
.cm-dl dt::after { content: "："; color: var(--text-dim); }
.cm-dl dd { color: var(--text); }
.cm-body { color: #d6d6dd; line-height: 1.9; margin-bottom: 14px; }
.cm-body:last-child { margin-bottom: 0; }
.cm-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.cm-h { font-size: .8rem; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); margin-bottom: 14px; }
.cm-h.clickable { margin-bottom: 0; }
.cm-section details { margin-top: 0; }
.cm-section details[open] { margin-bottom: 0; }
.cm-section details summary { list-style: none; }
.cm-section details summary::-webkit-details-marker { display: none; }
.cm-section details summary::before { content: "▸ "; color: var(--accent); }
.cm-section details[open] summary::before { content: "▾ "; }
.cm-quote { border-left: 2px solid var(--accent); padding: 4px 0 4px 16px; margin: 0 0 12px; color: var(--accent-2); font-style: italic; line-height: 1.8; }
.cm-relations { display: flex; gap: 12px; flex-wrap: wrap; }
.cm-rel {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; cursor: pointer; font: inherit; color: inherit; transition: all .2s var(--ease);
}
.cm-rel:hover { border-color: var(--accent); transform: translateY(-2px); }
.cm-rel-label { font-size: .74rem; letter-spacing: .06em; color: var(--text-dim); }
.cm-rel-name { font-size: .98rem; color: var(--accent); }

.cm-chapters { display: flex; gap: 10px; flex-wrap: wrap; }
.cm-chapter {
  display: inline-block;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 14px; font-size: .88rem; color: var(--accent-2); text-decoration: none;
  transition: all .2s var(--ease);
}
.cm-chapter:hover { border-color: var(--accent); color: var(--accent); }

/* 角色關係圖譜 */
#cm-graph {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-soft); padding: 10px 6px; margin-top: 4px;
}

.cm-nav { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 8px; }
.cm-nav-btn {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 16px; cursor: pointer; font: inherit; font-size: .84rem; color: var(--text-dim);
  transition: all .2s var(--ease);
}
.cm-nav-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 世界觀辭典 ---------- */
.gloss-item { margin-bottom: 2px; }
.gloss-title {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 18px; font: inherit; font-size: 1rem; color: var(--text); cursor: pointer;
  transition: all .2s var(--ease);
}
.gloss-title:hover { border-color: var(--accent); }
.gloss-title.open { border-radius: 10px 10px 0 0; border-bottom-color: transparent; }
.gloss-cat-tag {
  display: inline-block; font-size: .7rem; letter-spacing: .06em;
  background: var(--accent); color: #111; padding: 2px 10px; border-radius: 999px;
  white-space: nowrap; flex: 0 0 auto;
}
.gloss-body {
  background: var(--bg-soft); border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 10px 10px; padding: 0 18px 16px; color: #d6d6dd; line-height: 1.9;
  margin-top: 0; font-size: .94rem;
}
.gloss-list { margin-top: 20px; }
.gloss-loading { color: var(--text-dim); text-align: center; padding: 40px 0; }

/* ===========================================================
   內容分級
   =========================================================== */
/* 進站軟確認的樣式在 gate.js 內自帶（自包含，可用於未載入 novel.css 的頁面）。 */

/* 作品分級定位行（novel 首頁） */
.rating-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--text-dim); font-size: .88rem; letter-spacing: .02em; margin-top: 14px; }
.rating-chip {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  color: #f0b6b6; border: 1px solid rgba(220,120,120,.55); border-radius: 5px; padding: 2px 9px;
}

/* 章節成熟標記 */
.mature-badge {
  display: inline-block; font-size: .62rem; font-weight: 700; letter-spacing: .04em;
  color: #f0b6b6; border: 1px solid rgba(220,120,120,.5); border-radius: 4px;
  padding: 1px 6px; vertical-align: middle; margin-left: 6px;
}

/* 閱讀前成熟警告 */
.mature-warning {
  text-align: center; max-width: 520px; margin: 40px auto;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 44px 32px; background: var(--bg-card);
}
.mw-kicker {
  display: inline-block; font-size: .8rem; font-weight: 700; letter-spacing: .08em;
  color: #f0b6b6; border: 1px solid rgba(220,120,120,.5); border-radius: 6px;
  padding: 3px 12px; margin-bottom: 18px;
}
.mature-warning h2 { font-size: 1.5rem; margin-bottom: 14px; }
.mw-text { color: var(--text-dim); line-height: 1.85; margin-bottom: 28px; }
.mw-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ===========================================================
   媒體庫（插畫畫廊 + 配樂）
   =========================================================== */
.media-grid { margin-top: 22px; }
.media-empty { color: var(--text-dim); margin-top: 20px; }

.media-tile {
  display: block; text-align: left; padding: 0; cursor: pointer; font: inherit; color: inherit;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: all .3s var(--ease);
}
.media-tile:hover { transform: translateY(-4px); border-color: var(--accent); }
.media-tile.is-placeholder { cursor: zoom-in; }
.media-thumb { display: block; width: 100%; aspect-ratio: 4 / 3; background-size: cover; background-position: center; }
.media-cap { display: block; padding: 16px 18px; }
.media-title { display: block; font-size: 1.04rem; color: var(--text); }
.media-sub { display: block; font-size: .86rem; color: var(--text-dim); margin-top: 4px; line-height: 1.5; }

/* 燈箱 */
.lightbox { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 30px; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(5,5,7,.92); backdrop-filter: blur(6px); }
.lightbox-close { position: absolute; top: 18px; right: 24px; z-index: 2; background: none; border: 0; color: var(--text-dim); font-size: 2rem; cursor: pointer; }
.lightbox-close:hover { color: var(--accent); }
.lightbox-fig { position: relative; z-index: 1; margin: 0; max-width: 900px; width: 100%; text-align: center; }
.lightbox-img { width: 100%; max-height: 78vh; aspect-ratio: 4 / 3; background-size: contain; background-repeat: no-repeat; background-position: center; }
.lightbox-fig figcaption { color: var(--text-dim); font-size: .92rem; margin-top: 16px; }

/* 配樂播放器 */
.player { max-width: 720px; margin-top: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-card); overflow: hidden; }
.player-now { padding: 16px 20px; color: var(--accent-2); font-size: .95rem; border-bottom: 1px solid var(--line); min-height: 20px; letter-spacing: .02em; }
.player-now:empty { display: none; }
.track-list { list-style: none; margin: 0; padding: 0; }
.track { border-top: 1px solid var(--line); }
.track:first-child { border-top: 0; }
.track-btn {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
  background: none; border: 0; cursor: pointer; font: inherit; color: inherit; padding: 16px 20px;
  transition: background .2s var(--ease);
}
.track-btn:hover:not([disabled]) { background: rgba(255,255,255,.03); }
.track-btn[disabled] { cursor: default; opacity: .5; }
.track-ico { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: .7rem; color: var(--accent); }
.track.playing .track-ico { background: var(--accent); color: #111; border-color: var(--accent); }
.track-meta { display: flex; flex-direction: column; gap: 2px; }
.track-title { font-size: 1.02rem; color: var(--text); }
.track-artist { font-size: .82rem; color: var(--text-dim); letter-spacing: .04em; }
.track.playing .track-title { color: var(--accent-2); }

/* ---------- 響應式 ---------- */
@media (max-width: 720px) {
  .read-progress { top: 70px; }
  .reader-bar { margin-bottom: 32px; }
  .chapter-nav { grid-template-columns: 1fr; }
  .chapter-nav-link.end { text-align: left; align-items: flex-start; }
  .chapter-nav-toc { order: 3; text-align: center; padding: 8px; }
  .chapter-body { font-size: calc(1.06rem * var(--reader-scale)); line-height: 1.95; }
  .char-tools { flex-direction: column; align-items: stretch; }
  .char-search { max-width: none; }
  .char-modal-panel { padding: 28px 22px; }
}
