/* 极乐迪斯科 中英对照读本 */
:root {
  --bg: #f4f1ea;
  --paper: #fffefa;
  --ink: #2b2823;
  --muted: #8b8376;
  --line: #e4ddd0;
  --line2: #f0ebe1;
  --accent: #7c5230;
  --accent-soft: #f2e7d7;
  --hover: #faf5eb;
  --active: #f3e8d6;
  --shadow: 0 10px 34px rgba(70, 52, 28, .075);
  --int: #0e6ea6;
  --psy: #7b3f9d;
  --fys: #bf3b31;
  --mot: #a5680b;
  --thg: #2b824d;
  --fs: 17px;
  --lh: 1.75;
  --serif: Georgia, "Times New Roman", "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", serif;
  --sans: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --font: var(--serif);
}
:root[data-theme="sepia"] { --bg: #eee3cd; --paper: #f9f1de; --ink: #43372a; --line: #dccdb0; --line2: #ede2c9; --hover: #f4e8cf; --active: #ecdcbb; --accent: #8a5a2b; --accent-soft: #ecdcbe; }
:root[data-theme="dark"] {
  --bg: #16181b; --paper: #1e2125; --ink: #e7e2d8; --muted: #96938c;
  --line: #34383e; --line2: #292d32; --accent: #d3a46e; --accent-soft: #33291d;
  --hover: #262a2f; --active: #2d2a24; --shadow: 0 10px 34px rgba(0,0,0,.28);
  --int: #58b9e8; --psy: #bf8ade; --fys: #f08078; --mot: #e4ae4e; --thg: #71c58e;
}
:root[data-palette="original"] { --int: #00b0f0; --psy: #7030a0; --fys: #ff0000; --mot: #ffc000; --thg: #92d050; }
:root[data-font="sans"] { --font: var(--sans); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: var(--fs); line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 22px;
  padding: 10px 26px; min-height: 66px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 250px; }
.logo {
  width: 38px; height: 38px; flex: none; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-family: Georgia, serif;
  font-weight: 700; font-size: 17px; letter-spacing: .5px;
}
.brand-txt h1 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .2px; }
.brand-txt p { margin: 1px 0 0; font-size: 11px; color: var(--muted); letter-spacing: .3px; }
.modes { display: flex; gap: 3px; padding: 3px; background: var(--line2); border-radius: 10px; margin: 0 auto; }
.modes button {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 17px; border-radius: 8px; font-size: 13px; font-weight: 600;
  transition: .18s;
}
.modes button:hover { color: var(--ink); }
.modes button.active { background: var(--paper); color: var(--accent); box-shadow: 0 1px 5px rgba(0,0,0,.07); }
.tools { display: flex; gap: 8px; }
.tools button, .ghost-btn {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  padding: 7px 13px; border-radius: 8px; font-size: 13px; transition: .18s;
}
.tools button:hover, .ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 工具条 ---------- */
.subbar {
  position: sticky; top: 66px; z-index: 25;
  display: flex; align-items: center; gap: 26px;
  padding: 9px 26px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.nav-group { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center;
  border: 1px solid var(--line); background: var(--paper); border-radius: 7px;
  font-size: 18px; line-height: 1; padding: 0; transition: .18s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
#pageInput {
  width: 74px; padding: 5px 8px; text-align: center;
  border: 1px solid var(--line); background: var(--paper); border-radius: 7px;
  font-variant-numeric: tabular-nums;
}
.total { color: var(--muted); white-space: nowrap; }
.view-group { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.view-group label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
select {
  border: 1px solid var(--line); background: var(--paper); border-radius: 7px;
  padding: 5px 8px; font-size: 13px;
}
.progress { flex: 1; min-width: 80px; height: 4px; background: var(--line2); border-radius: 4px; overflow: hidden; }
#progressFill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .25s; }

/* ---------- 阅读区 ---------- */
.reader { max-width: 1560px; margin: 0 auto; padding: 26px 26px 10px; }
.page-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); margin-bottom: 30px; overflow: hidden;
}
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 22px; border-bottom: 1px solid var(--line);
  background: var(--line2); font-size: 12px; color: var(--muted); letter-spacing: .4px;
}
.page-head .pg-no { font-size: 14px; font-weight: 700; color: var(--accent); }
.page-head .pg-tag { border: 1px solid var(--line); border-radius: 20px; padding: 2px 10px; background: var(--paper); }
.col-head { display: none; }
.row { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line2); }
.row:last-child { border-bottom: 0; }
.cell { padding: 11px 20px; min-width: 0; transition: background .15s; }
.cell.en { border-left: 1px dashed var(--line); }
.row:hover .cell { background: var(--hover); }
.row.active .cell { background: var(--active); }
.row .cell:empty::before { content: "—"; color: var(--muted); opacity: .4; }
.blk { position: relative; overflow-wrap: anywhere; }
.blk .spk { font-weight: 700; letter-spacing: .1px; }
.blk .spk:not(:empty)::after { content: " "; }
.blk.k-skill, .blk.k-thought, .blk.k-title { padding: 5px 10px; border-radius: 7px; margin: 2px 0; }
.blk.k-skill { border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--line2) 70%, transparent); }
.blk.k-thought { border-left: 3px solid var(--thg); background: color-mix(in srgb, var(--thg) 8%, transparent); }
.blk.k-title { font-weight: 700; }
.blk.col-int { border-left-color: var(--int); }
.blk.col-psy { border-left-color: var(--psy); }
.blk.col-fys { border-left-color: var(--fys); }
.blk.col-mot { border-left-color: var(--mot); }
.blk.col-thg { border-left-color: var(--thg); }
.blk.empty { min-height: 1.2em; opacity: .35; }
.blk.empty::before { content: "（此段仅单语有）"; font-size: .78em; color: var(--muted); }
.mk { font-weight: 600; }
.mk-int { color: var(--int); }
.mk-psy { color: var(--psy); }
.mk-fys { color: var(--fys); }
.mk-mot { color: var(--mot); }
.mk-thg { color: var(--thg); }
.mk-other { color: var(--accent); }
.no-marks .mk { color: inherit; font-weight: inherit; }
.no-marks .blk.k-skill, .no-marks .blk.k-thought { border-left-color: var(--line); background: transparent; }
em { font-style: italic; opacity: .9; }
mark { background: #ffd77a; color: #2b2823; border-radius: 3px; padding: 0 2px; }
:root[data-theme="dark"] mark { background: #a67c22; color: #fff; }

/* 单语模式 */
.reader.single .page-body { max-width: 860px; margin: 0 auto; }
.reader.single .cell { padding: 10px 34px; }
.reader.single .row { grid-template-columns: 1fr; }
.reader.single .cell.en { border-left: 0; }
.reader.single .blk { padding-left: 12px; padding-right: 12px; }
/* 整页并排 */
.page-cols { display: grid; grid-template-columns: 1fr 1fr; }
.page-cols .col { padding: 12px 22px 20px; }
.page-cols .col.en { border-left: 1px dashed var(--line); }
.page-cols .col-head { display: block; font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: 1px; margin: 4px 0 12px; }
.page-cols .blk { margin-bottom: 12px; }
.loose-note { margin: 10px 22px 0; padding: 8px 12px; font-size: 12px; color: var(--muted); background: var(--line2); border-radius: 7px; }

.loading { text-align: center; padding: 50px; color: var(--muted); }
.footer {
  max-width: 1560px; margin: 0 auto; padding: 6px 26px 46px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  font-size: 12px; color: var(--muted);
}

/* ---------- 抽屉 ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20,16,10,.28); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); z-index: 50;
  background: var(--paper); border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0,0,0,.12);
  transform: translateX(102%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.panel { display: none; padding: 18px 20px 40px; overflow-y: auto; }
.panel.active { display: block; }
.panel h3 { font-size: 12px; letter-spacing: 1px; color: var(--accent); margin: 22px 0 10px; text-transform: uppercase; }
.panel h3:first-child { margin-top: 0; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.7; }
.search-box { display: flex; gap: 8px; }
.search-box input { flex: 1; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; }
.primary-btn { border: 0; background: var(--accent); color: #fff; padding: 8px 15px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.results { margin-top: 14px; }
.res-item { display: block; width: 100%; text-align: left; padding: 11px 12px; margin-bottom: 8px; border: 1px solid var(--line); background: var(--bg); border-radius: 9px; }
.res-item:hover { border-color: var(--accent); }
.res-item .res-pg { font-size: 11px; color: var(--accent); font-weight: 700; }
.res-item .res-tx { font-size: 13px; line-height: 1.6; margin-top: 3px; color: var(--ink); }
.legend { list-style: none; padding: 0; margin: 0; }
.legend li { display: grid; grid-template-columns: 14px 78px 1fr; gap: 8px; align-items: baseline; padding: 7px 0; border-bottom: 1px dashed var(--line2); font-size: 12px; }
.legend b { font-size: 12px; }
.legend span { color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.int { background: var(--int); } .dot.psy { background: var(--psy); }
.dot.fys { background: var(--fys); } .dot.mot { background: var(--mot); } .dot.thg { background: var(--thg); }
.terms { display: flex; flex-wrap: wrap; gap: 7px; }
.term { border: 1px solid var(--line); background: var(--bg); border-radius: 20px; padding: 4px 11px; font-size: 12px; }
.term:hover { border-color: var(--accent); }
.term.int { color: var(--int); } .term.psy { color: var(--psy); }
.term.fys { color: var(--fys); } .term.mot { color: var(--mot); } .term.thg { color: var(--thg); }
.bookmarks { display: flex; flex-wrap: wrap; gap: 7px; }
.bookmark { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; font-size: 12px; background: var(--bg); }
.bookmark x { cursor: pointer; color: var(--muted); font-style: normal; }
.setting-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line2); font-size: 13px; }
.setting-row > span:first-child { width: 78px; color: var(--muted); flex: none; }
.setting-row b { min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }
.setting-row input[type=range] { flex: 1; accent-color: var(--accent); }
.setting-row input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }
#resetBtn { margin-top: 20px; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 9px 14px; }
  .brand { min-width: 0; flex: 1; }
  .brand-txt p { display: none; }
  .modes { order: 3; width: 100%; margin: 0; }
  .modes button { flex: 1; }
  .subbar { top: 0; position: static; flex-wrap: wrap; gap: 10px; padding: 9px 14px; }
  .progress { display: none; }
  .reader { padding: 14px 10px 8px; }
  .row, .page-cols { grid-template-columns: 1fr; }
  .cell.en, .page-cols .col.en { border-left: 0; border-top: 1px dashed var(--line); }
  .cell { padding: 9px 14px; }
  .reader.single .cell { padding: 8px 18px; }
  .col-head { display: none !important; }
}

/* ---------- 章节阅读 ---------- */
.chapter-btn {
  max-width: 330px; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid var(--line); background: var(--paper); border-radius: 8px;
  padding: 6px 13px; font-size: 13px; font-weight: 600; color: var(--accent); text-align: center;
}
.chapter-btn:hover { border-color: var(--accent); }
.chapter-head { padding: 26px 30px 20px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--line2), var(--paper)); }
.chapter-head .ch-eyebrow { font-size: 12px; letter-spacing: 1.2px; color: var(--accent); font-weight: 700; text-transform: uppercase; }
.chapter-head .ch-eyebrow span { color: var(--muted); font-weight: 400; letter-spacing: .3px; margin-left: 10px; text-transform: none; }
.chapter-head h2 { margin: 8px 0 3px; font-size: 26px; line-height: 1.35; letter-spacing: .5px; }
.chapter-head .ch-en { margin: 0; font-size: 13px; color: var(--muted); letter-spacing: .5px; font-family: Georgia, serif; }
.chapter-head .ch-meta { margin: 12px 0 0; font-size: 11px; color: var(--muted); }
.row { position: relative; }
.row.cont { border-top: 0; }
.row.cont .cell { padding-top: 2px; padding-bottom: 2px; }
.row.cont + .row:not(.cont) { border-top: 1px solid var(--line2); }
.pgno {
  position: absolute; left: 3px; top: 3px; z-index: 1;
  font-size: 10px; color: var(--muted); opacity: .45; letter-spacing: 0;
  font-family: var(--sans); pointer-events: none;
}
.hide-pgno .pgno { display: none; }
.scene-inline {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  padding: 9px 20px; margin: 14px 22px 8px; border-radius: 8px;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  font-size: .86em; font-weight: 700; color: var(--accent);
}
.scene-inline .sc-en { font-weight: 400; opacity: .8; padding-left: 18px; border-left: 1px dashed var(--line); }
.reader.single .scene-inline { grid-template-columns: 1fr; }
.reader.single .scene-inline .sc-en { padding-left: 0; border-left: 0; }
.reader.single .page-cols { grid-template-columns: 1fr; }
.reader.single .page-cols .col.en { border-left: 0; }
.more-sentinel { text-align: center; padding: 20px; color: var(--muted); font-size: 12px; }
.focus-glow { animation: glow 2.8s ease-out; }
@keyframes glow {
  0% { background: #ffd77a; box-shadow: 0 0 0 5px rgba(255, 215, 122, .5); }
  60% { background: rgba(255, 215, 122, .42); }
  100% { background: transparent; box-shadow: none; }
}
:root[data-theme="dark"] .focus-glow { animation-name: glowDark; }
@keyframes glowDark {
  0% { background: #7a5a18; box-shadow: 0 0 0 5px rgba(200, 150, 40, .35); }
  100% { background: transparent; box-shadow: none; }
}

/* ---------- 章节目录 ---------- */
.chapter-list { margin-top: 12px; }
.chapter-group {
  position: sticky; top: 0; padding: 9px 4px 6px; margin-top: 10px;
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px; color: var(--accent);
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.chapter-item {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 8px; align-items: center;
  width: 100%; text-align: left; padding: 9px 8px; border: 0; border-bottom: 1px solid var(--line2);
  background: transparent; font-size: 13px; line-height: 1.45;
}
.chapter-item:hover { background: var(--hover); }
.chapter-item.active { background: var(--active); }
.chapter-item.active .ci-main { color: var(--accent); font-weight: 700; }
.ci-id { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ci-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-sub { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ---------- 人物 / 技能 ---------- */
.entity-tabs { display: flex; gap: 4px; margin-bottom: 14px; padding: 3px; background: var(--line2); border-radius: 9px; }
.entity-tabs button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 7px; font-size: 13px; color: var(--muted); }
.entity-tabs button.active { background: var(--paper); color: var(--accent); font-weight: 700; }
.entity-list { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 7px; }
.entity-list .chapter-group { flex: 1 0 100%; position: static; }
.entity-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px;
  padding: 6px 9px; font-size: 13px; max-width: 100%;
}
.entity-chip:hover { border-color: var(--accent); background: var(--hover); }
.entity-chip small { color: var(--muted); font-size: 10px; }
.entity-chip span { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.entity-chip.int b { color: var(--int); } .entity-chip.psy b { color: var(--psy); }
.entity-chip.fys b { color: var(--fys); } .entity-chip.mot b { color: var(--mot); }
.entity-view { max-width: 1340px; margin: 0 auto; }
.entity-head { padding: 10px 4px 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.entity-head h2 { margin: 12px 0 4px; font-size: 24px; }
.entity-head h2 small { font-size: 14px; color: var(--muted); font-weight: 400; }
.entity-head p { margin: 0; font-size: 12px; color: var(--muted); }
.sent-list { display: flex; flex-direction: column; gap: 10px; }
.sent-item {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--paper); cursor: pointer; transition: .16s;
}
.sent-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.sent-meta { padding: 5px 13px; background: var(--line2); font-size: 11px; color: var(--accent); }
.sent-body { border-bottom: 0 !important; }
.sent-body .cell { padding: 9px 16px; }
.load-more { display: block; margin: 20px auto 40px; }
.bookmarks { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.bookmark { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; font-size: 12px; background: var(--bg); cursor: pointer; }
.bookmark x { color: var(--muted); font-style: normal; }

@media (max-width: 900px) {
  .chapter-btn { max-width: 46vw; }
  .chapter-head { padding: 18px 16px 14px; }
  .chapter-head h2 { font-size: 21px; }
  .scene-inline { grid-template-columns: 1fr; margin: 10px 12px 6px; }
  .scene-inline .sc-en { padding-left: 0; border-left: 0; margin-top: 4px; }
  .sent-body .cell { padding: 8px 14px; }
  .tools button { padding: 6px 9px; }
}
