:root {
  --page: #edf1f3;
  --paper: #fcfbf7;
  --paper-deep: #f6f3eb;
  --ink: #172f45;
  --ink-soft: #617080;
  --muted: #8a969c;
  --line: #dce2e4;
  --accent: #318e72;
  --accent-deep: #1f715b;
  --brass: #b58b48;
  --reader-size: 18px;
  --rail-width: 286px;
  --topbar-height: 84px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--page); color: var(--ink); }
button, a { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
  align-items: center;
  min-height: var(--topbar-height);
  padding: 0 34px;
  background: rgba(247, 249, 250, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand-lockup, .top-actions, .font-controls, .reading-intro, .rail-topline, .book-progress-row, .rail-tool, .popover-word-row, .popover-actions { display: flex; align-items: center; }
.brand-lockup { gap: 11px; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--ink); color: var(--ink); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.brand-name, .brand-caption, .eyebrow, .section-kicker, .meta-label, .rail-section-heading, .stat-label, .cover-kicker { margin: 0; letter-spacing: .14em; text-transform: uppercase; }
.brand-name { font-size: 11px; font-weight: 800; }
.brand-caption { margin-top: 3px; color: var(--muted); font-size: 9px; }
.book-heading { text-align: center; }
.eyebrow, .section-kicker { color: var(--accent-deep); font-size: 10px; font-weight: 800; }
.book-heading h1 { margin: 4px 0 2px; font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 600; letter-spacing: .01em; }
.author-line { color: var(--muted); font-size: 11px; }
.top-actions { justify-content: flex-end; gap: 18px; }
.reading-stat { display: flex; align-items: baseline; gap: 8px; }
.stat-label { color: var(--muted); font-size: 9px; }
.reading-stat strong { font-size: 13px; font-weight: 700; }
.font-controls { gap: 4px; padding-left: 16px; border-left: 1px solid var(--line); }
.icon-button { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 7px; border: 0; background: transparent; cursor: pointer; }
.icon-button:hover, .icon-button:focus-visible { background: #e4ece9; outline: none; }
.progress-track { position: sticky; top: var(--topbar-height); z-index: 19; height: 3px; background: #dfe7e6; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s ease; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-width); min-height: calc(100vh - var(--topbar-height)); }
.reading-main { min-width: 0; padding: 34px 40px 80px; background: var(--page); }
.reading-wrap { max-width: 940px; margin: 0 auto; }
.reading-intro { justify-content: space-between; max-width: 790px; margin: 0 auto 26px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.current-chapter { margin: 5px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 18px; }
.text-button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border: 1px solid var(--line); color: var(--ink-soft); background: transparent; font-size: 12px; cursor: pointer; }
.text-button:hover, .text-button:focus-visible { border-color: var(--accent); color: var(--accent-deep); outline: none; }
.button-icon { color: var(--accent); font-size: 15px; }
.reading-content { max-width: 790px; margin: 0 auto; padding: 9px 0 30px; }
.book-section { scroll-margin-top: 120px; padding: 26px 0 42px; }
.book-section + .book-section { margin-top: 36px; padding-top: 54px; border-top: 1px solid var(--line); }
.section-heading { display: grid; grid-template-columns: auto 1fr; align-items: end; column-gap: 14px; margin-bottom: 30px; }
.section-heading h2 { grid-row: 2; margin: 6px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 30px; font-weight: 600; letter-spacing: .01em; }
.section-rule { grid-column: 2; grid-row: 2; height: 1px; margin-bottom: 7px; background: var(--line); }
.section-body { color: #22394f; font-family: Georgia, "Times New Roman", serif; font-size: var(--reader-size); line-height: 1.92; }
.reading-paragraph { margin: 0 0 20px; }
.reading-paragraph.stage-direction { color: #66737c; font-size: calc(var(--reader-size) - 1px); font-style: italic; }
.sentence { position: relative; border-radius: 3px; cursor: pointer; transition: background .15s ease, box-shadow .15s ease; }
.sentence:hover, .sentence:focus-visible { background: #e8f2ed; outline: none; box-shadow: 0 0 0 2px #e8f2ed; }
.sentence.is-active { background: #b9e2cf; box-shadow: 0 0 0 3px #b9e2cf; }
.word-button { display: inline; padding: 0; border: 0; border-bottom: 1px solid transparent; background: transparent; color: inherit; cursor: pointer; }
.word-button:hover, .word-button:focus-visible { border-color: var(--accent); color: var(--accent-deep); outline: none; }
.word-button.is-selected { color: var(--accent-deep); border-color: var(--accent); }
.translation-label { flex: 0 0 auto; color: var(--accent-deep); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.reading-footer { display: flex; justify-content: space-between; max-width: 790px; margin: 20px auto 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; letter-spacing: .04em; }

.book-rail { position: sticky; top: var(--topbar-height); align-self: start; height: calc(100vh - var(--topbar-height)); overflow-y: auto; padding: 34px 25px 26px; border-left: 1px solid var(--line); background: #f7f8f8; }
.rail-topline { justify-content: space-between; margin-bottom: 35px; }
.back-link { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; }
.back-link span { color: var(--accent-deep); font-size: 20px; }
.rail-close, .mobile-menu-button { display: none; }
.book-card { display: grid; gap: 17px; }
.book-cover { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 236px; padding: 22px 19px 18px; overflow: hidden; color: #f8f4e6; background: #315d57; box-shadow: 8px 8px 0 #dfe5e1; }
.book-cover::before { position: absolute; inset: 9px; border: 1px solid rgba(242, 229, 184, .48); content: ''; }
.cover-rule { position: relative; z-index: 1; width: 40px; height: 2px; background: #d6b761; }
.cover-kicker, .cover-author { position: relative; z-index: 1; font-size: 8px; }
.book-cover strong { position: relative; z-index: 1; margin-top: 35px; font-family: Georgia, "Times New Roman", serif; font-size: 24px; line-height: .98; font-weight: 500; letter-spacing: .02em; }
.cover-author { margin-top: auto; color: #e1c875; }
.cover-figure { position: absolute; right: 27px; bottom: 38px; width: 50px; height: 80px; border: 1px solid #dec572; border-radius: 50% 50% 0 0; opacity: .72; }
.cover-figure::before { position: absolute; top: -20px; left: 15px; width: 18px; height: 18px; border: 1px solid #dec572; border-radius: 50%; content: ''; }
.cover-figure i { position: absolute; top: 25px; left: 8px; width: 32px; height: 1px; background: #dec572; transform: rotate(25deg); }
.cover-figure b { position: absolute; bottom: 17px; left: 0; width: 47px; height: 1px; background: #dec572; transform: rotate(-20deg); }
.book-meta h2 { margin: 4px 0 2px; font-family: Georgia, "Times New Roman", serif; font-size: 22px; font-weight: 600; }
.book-meta p { margin: 0; color: var(--muted); font-size: 12px; }
.meta-label { color: var(--accent-deep); font-size: 9px; font-weight: 800; }
.book-progress-row { justify-content: space-between; margin-top: 19px; color: var(--muted); font-size: 10px; }
.book-progress-row strong { color: var(--ink); font-size: 11px; }
.book-progress { height: 4px; margin-top: 7px; background: #dce6e1; }
.book-progress span { display: block; width: 0; height: 100%; background: var(--accent); }
.toc { margin-top: 38px; }
.rail-section-heading { display: flex; justify-content: space-between; margin-bottom: 11px; color: var(--muted); font-size: 9px; font-weight: 800; }
.rail-section-heading span:last-child { letter-spacing: 0; text-transform: none; font-weight: 500; }
.toc-list { border-top: 1px solid var(--line); }
.toc-item { display: grid; grid-template-columns: 26px 1fr 16px; gap: 9px; align-items: center; padding: 13px 3px; border-bottom: 1px solid var(--line); color: var(--ink-soft); }
.toc-item:hover, .toc-item:focus-visible, .toc-item.is-active { color: var(--ink); outline: none; }
.toc-item.is-active { color: var(--accent-deep); }
.toc-index { font-size: 10px; font-weight: 700; }
.toc-item strong, .toc-item small { display: block; }
.toc-item strong { font-family: Georgia, "Times New Roman", serif; font-size: 15px; font-weight: 600; }
.toc-item small { margin-top: 2px; font-size: 9px; color: var(--muted); }
.toc-arrow { opacity: 0; font-size: 16px; transition: opacity .15s ease, transform .15s ease; }
.toc-item:hover .toc-arrow, .toc-item.is-active .toc-arrow { opacity: 1; transform: translate(2px, -2px); }
.rail-tools { margin-top: 31px; border-top: 1px solid var(--line); }
.rail-tool { width: 100%; justify-content: flex-start; gap: 10px; padding: 14px 2px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.rail-tool > span:nth-child(2) { flex: 1; }
.rail-tool strong, .rail-tool small { display: block; }
.rail-tool strong { font-size: 12px; font-weight: 600; }
.rail-tool small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.tool-icon { color: var(--accent); font-size: 17px; }
.rail-tool:hover, .rail-tool:focus-visible { color: var(--accent-deep); outline: none; }
.rail-note { display: flex; gap: 8px; margin-top: 30px; color: var(--muted); }
.note-dot { flex: 0 0 auto; width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--brass); }
.rail-note p { margin: 0; font-size: 10px; line-height: 1.7; }

.word-popover { position: fixed; z-index: 40; width: min(380px, calc(100vw - 32px)); padding: 22px 22px 14px; border: 1px solid #d8e1de; background: #fff; box-shadow: 0 18px 45px rgba(22, 47, 69, .17); }
.word-popover[hidden], .info-dialog[hidden] { display: none; }
.popover-close, .dialog-close { position: absolute; top: 7px; right: 7px; color: var(--muted); font-size: 20px; }
.popover-word-row { justify-content: space-between; padding-right: 22px; }
.popover-word-row h2 { margin: 0; font-size: 25px; font-weight: 700; letter-spacing: -.02em; }
.popover-word-row span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; font-style: italic; }
.sound-button { color: var(--accent); font-size: 20px; }
.popover-meaning { margin: 16px 0 5px; font-size: 17px; font-weight: 600; }
.popover-divider { height: 1px; margin: 18px 0 7px; background: var(--line); }
.popover-actions { justify-content: space-between; gap: 10px; }
.popover-action { display: inline-flex; align-items: center; gap: 6px; padding: 8px 0; border: 0; color: var(--ink-soft); background: transparent; font-size: 12px; cursor: pointer; }
.popover-action:hover, .popover-action:focus-visible, .popover-action.is-saved { color: var(--accent-deep); outline: none; }
.popover-action:last-child { color: var(--accent); font-weight: 600; }
.popover-translation { margin-top: 10px; padding: 13px 0 2px; border-top: 1px solid var(--line); }
.popover-translation p { margin: 6px 0 0; color: #496056; font-family: Georgia, "Times New Roman", serif; font-size: 14px; line-height: 1.65; }
.info-dialog { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 20px; background: rgba(23, 47, 69, .34); }
.dialog-panel { position: relative; width: min(440px, 100%); padding: 32px; background: var(--paper); box-shadow: 0 20px 55px rgba(23, 47, 69, .22); }
.dialog-panel h2 { margin: 8px 0 14px; font-family: Georgia, "Times New Roman", serif; font-size: 28px; }
.dialog-panel p { margin: 0; color: var(--ink-soft); font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.8; }
.dialog-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 15px; margin-top: 25px; padding-top: 17px; border-top: 1px solid var(--line); font-size: 12px; }
.dialog-facts span { color: var(--muted); }
.dialog-facts strong { font-weight: 600; text-align: right; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; max-width: calc(100vw - 32px); padding: 11px 16px; color: #fff; background: var(--ink); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.rail-backdrop { display: none; }

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr auto; padding: 0 20px; }
  .book-heading { display: none; }
  .mobile-menu-button { display: inline-grid; }
  .top-actions { gap: 8px; }
  .reading-main { padding-inline: 25px; }
}

@media (max-width: 860px) {
  .book-rail { position: fixed; top: 0; right: 0; z-index: 35; width: min(330px, calc(100vw - 34px)); height: 100vh; padding-top: 28px; transform: translateX(102%); transition: transform .25s ease; }
  .rail-close { display: inline-grid; }
  .rail-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(23, 47, 69, .25); }
  .rail-open .book-rail { transform: translateX(0); }
  .rail-open .rail-backdrop { display: block; }
  .workspace { display: block; }
  .reading-main { padding-top: 27px; }
}

@media (max-width: 560px) {
  .topbar { min-height: 68px; padding: 0 13px; }
  .progress-track { top: 68px; }
  .brand-caption, .reading-stat, .font-controls { display: none; }
  .brand-name { font-size: 10px; }
  .reading-main { padding: 20px 15px 60px; }
  .reading-intro { align-items: flex-start; margin-bottom: 21px; }
  .current-chapter { font-size: 16px; }
  .text-button { padding: 7px 8px; font-size: 11px; }
  .section-heading { display: block; }
  .section-heading h2 { font-size: 26px; }
  .section-rule { display: block; margin-top: 13px; }
  .section-body { font-size: var(--reader-size); line-height: 1.88; }
  .reading-footer { display: block; line-height: 1.8; }
  .reading-footer span { display: block; }
  .reading-footer span + span { margin-top: 3px; }
  .word-popover { bottom: 12px; width: calc(100vw - 24px); padding: 19px 18px 12px; }
  .popover-word-row h2 { font-size: 23px; }
}
