:root {
  color-scheme: light;
  --page: #fcf9f6; --panel: #f5efed; --raised: #fffcf9;
  --ink: #2b2427; --muted: #6d6066; --line: #e6dad9;
  --accent: #8e315b; --accent-bg: #f1e1e8; --shadow: #39223118;
  --body-font: Georgia, 'PT Serif', serif; --ui-font: system-ui, sans-serif;
  --reading-size: 19px; --reading-leading: 1.75; --reading-width: 680px;
  --header-height: 72px;
}
:root[data-theme=sepia] {
  --page: #f6ebd5; --panel: #efe1c8; --raised: #fbefd8;
  --ink: #33291f; --muted: #6f5d4d; --line: #ddcbb0;
  --accent: #88452c; --accent-bg: #ecd8bf; --shadow: #3a241f1c;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --page: #1d191d; --panel: #251f25; --raised: #292228;
  --ink: #f0e8e9; --muted: #c3b3bf; --line: #493d46;
  --accent: #efaad0; --accent-bg: #452b3d; --shadow: #04020442;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(var(--header-height) + 12px); }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--ui-font); }
a { color: inherit; }
button, select, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.topbar { height: var(--header-height); position: sticky; top: 0; z-index: 4; background: var(--raised); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1490px; height: 100%; margin: auto; display: flex; align-items: center; padding-inline: 30px; gap: 12px; }
.brand { display: flex; gap: 12px; min-width: 0; align-items: center; text-decoration: none; letter-spacing: -.025em; }
.brand-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-bg); color: var(--accent); flex: none; }
.brand strong, .brand small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand strong { font-size: 16px; }
.brand small { color: var(--muted); font-size: 12px; margin-top: 2px; letter-spacing: 0; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 7px; }
.icon-button { display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; min-width: 40px; height: 40px; padding: 0 7px; background: var(--raised); color: var(--ink); }
.icon-button:hover, .icon-button[aria-pressed=true] { background: var(--accent-bg); color: var(--accent); }
.icon-button[aria-pressed=true] svg { fill: var(--accent); }
.typography { font-family: Georgia, serif; font-size: 20px; line-height: 1; }
.mobile-only { display: none; }
.progress-track { position: absolute; inset: auto 0 0; height: 2px; pointer-events: none; }
#progress-fill { width: 0; height: 100%; background: var(--accent); transition: width .16s ease; }
.layout { max-width: 1490px; display: grid; margin-inline: auto; grid-template-columns: 300px minmax(0, 1fr); }
.sidebar { border-right: 1px solid var(--line); background: var(--panel); }
.sidebar-inner { position: sticky; top: var(--header-height); height: calc(100dvh - var(--header-height)); overflow-y: auto; scrollbar-width: thin; padding: 27px 17px 30px; }
.volume-card { display: flex; gap: 13px; align-items: center; padding: 0 8px 23px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.volume-card img { flex: none; width: 56px; aspect-ratio: 1597/2262; object-fit: cover; border-radius: 5px; box-shadow: 0 3px 8px var(--shadow); }
.volume-card strong, .volume-card span { display: block; }
.volume-card strong { font-size: 14px; margin-bottom: 5px; }
.volume-card span { color: var(--muted); font-size: 12px; line-height: 1.55; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 5px; }
.sidebar-heading h2 { font-size: 16px; margin: 0; letter-spacing: -.025em; }
#progress { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 700; }
.toc-group { color: var(--muted); font-size: 11px; font-weight: 650; padding: 14px 8px 6px; }
.toc-link { display: grid; gap: 5px; text-align: left; width: 100%; border: 0; border-radius: 8px; background: transparent; padding: 9px 11px; margin: 1px 0; font-size: 13px; line-height: 1.3; }
.toc-link:has(small) { grid-template-columns: 63px minmax(0, 1fr); gap: 8px; }
.toc-link small { color: var(--muted); font-size: 11px; padding-top: 1.5px; }
.toc-link[aria-current=true] { background: var(--accent-bg); color: var(--accent); font-weight: 700; }
.toc-link[aria-current=true] small { color: var(--accent); }
.toc-link:hover { background: var(--accent-bg); }
.reading-area { min-width: 0; }
.reader { max-width: calc(var(--reading-width) + 112px); margin-inline: auto; padding: 62px 56px 70px; }
.chapter-heading { margin-bottom: 32px; }
.chapter-label { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 14px; }
.chapter-heading h1 { font: 500 clamp(31px, 4vw, 48px)/1.12 Georgia, serif; letter-spacing: -.035em; margin: 0; overflow-wrap: anywhere; }
.chapter-heading h1:focus { outline: none; }
.chapter-rule { display: block; width: 45px; height: 2px; background: var(--accent); margin-top: 23px; border-radius: 2px; }
.chapter-body { font: var(--reading-size)/var(--reading-leading) var(--body-font); overflow-wrap: anywhere; }
.chapter-body p { margin: 0 0 .82em; white-space: pre-line; }
.chapter-body h2 { margin: 1.8em 0 .7em; font: 700 1.13em/1.4 var(--body-font); }
.chapter-body .scene-end { margin-bottom: 1.65em; }
.chapter-body figure { margin: 1.6em 0; text-align: center; }
.image-button { display: inline-block; border: 0; background: none; padding: 0; max-width: 100%; line-height: 0; }
.image-button img { display: block; max-width: 100%; max-height: 82vh; height: auto; width: auto; border-radius: 5px; }
.chapter-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 46px; }
.chapter-button { min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 65px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; text-align: left; background: var(--raised); }
.chapter-button:hover { color: var(--accent); border-color: var(--accent); }
.chapter-button small, .chapter-button strong { display: block; }
.chapter-button small { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.chapter-button strong { font-size: 13px; overflow-wrap: anywhere; }
#next { justify-content: flex-end; text-align: right; grid-column: 2; }
.notice { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 5; margin: 0; padding: 10px 15px; max-width: calc(100% - 24px); border: 1px solid var(--line); border-radius: 8px; background: var(--raised); box-shadow: 0 5px 24px var(--shadow); font-size: 13px; }
.notice:empty { display: none; }
dialog { width: min(420px, calc(100% - 30px)); max-height: min(620px, calc(100dvh - 30px)); overscroll-behavior: contain; color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: 0 14px 60px var(--shadow); }
dialog::backdrop { background: #21172188; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 17px; }
.dialog-header .close { min-width: 34px; height: 34px; }
.settings-fields { display: grid; gap: 16px; padding-top: 16px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 8px; font-size: 13px; }
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.theme-options button { display: grid; justify-items: center; gap: 5px; padding: 8px 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--page); font-size: 12px; }
.theme-options button[aria-pressed=true] { border-color: var(--accent); font-weight: 700; }
.theme-options span { width: 18px; height: 18px; border: 1px solid #83717d; border-radius: 50%; background: #fcf9f6; }
.theme-options [data-theme=sepia] span { background: #f1e2c4; }
.theme-options [data-theme=dark] span { background: #282029; }
.setting-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 7px; font-size: 13px; }
.setting-row select { border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; background: var(--raised); color: var(--ink); }
.setting-row output { color: var(--accent); font-variant-numeric: tabular-nums; }
.setting-row input { grid-column: 1 / -1; width: 100%; margin: 0; accent-color: var(--accent); }
#bookmark-list { padding-top: 12px; }
.bookmark-row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.bookmark-row .toc-link { flex: 1; min-width: 0; grid-template-columns: 1fr; gap: 3px; }
.bookmark-row small { display: block; }
.bookmark-row .icon-button { flex: none; }
#lightbox { width: auto; max-width: 95vw; max-height: 95dvh; padding: 0; overflow: hidden; background: transparent; border: 0; }
#lightbox img { display: block; max-width: 95vw; max-height: 94dvh; object-fit: contain; }
#lightbox .close { position: absolute; top: 8px; right: 8px; }
@media (max-width: 1000px) {
  .layout { grid-template-columns: 253px minmax(0, 1fr); }
  .reader { padding: 48px 34px 58px; }
}
@media (max-width: 740px) {
  :root { --header-height: 60px; }
  .topbar-inner { padding-inline: 11px; gap: 8px; }
  .brand-icon { display: none; }
  .top-actions { gap: 5px; }
  .sidebar { display: none; }
  .layout { display: block; }
  .mobile-only { display: grid; }
  .reader { padding: 37px 20px 52px; }
  .chapter-heading { margin-bottom: 25px; }
  .chapter-label { margin-bottom: 10px; }
  .chapter-rule { margin-top: 17px; }
  .drawer { margin: 0 auto 0 0; border-radius: 0 14px 14px 0; max-height: 100dvh; height: 100dvh; width: min(340px, calc(100% - 42px)); }
  .width-setting { display: none; }
}
@media (max-width: 380px) {
  .brand strong { font-size: 14px; }
  .brand small { font-size: 11px; }
  .icon-button { min-width: 35px; height: 37px; }
  .reader { padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) { #progress-fill { transition: none; } }
.trial-link { display: block; width: 100%; border: 1px solid var(--line); border-radius: 8px; margin: 10px 0 8px; padding: 9px 10px; text-align: left; background: var(--raised); color: var(--accent); font-size: 12px; font-weight: 650; }
.trial-link:hover { border-color: var(--accent); background: var(--accent-bg); }
