:root {
  --paper: #faf6ed;
  --paper-2: #ede3d2;
  --card: #fdfaf2;
  --ink: #1c1917;
  --ink-soft: #44403c;
  --ink-faint: #78716c;
  --line: #e5dcce;
  --line-soft: #eee7db;
  --cinnabar: #991b1e;
  --cinnabar-2: #7f1d1d;
  --cinnabar-glow: rgba(153, 27, 30, 0.14);
  --cinnabar-wash: rgba(153, 27, 30, 0.06);
  --vermilion: #b91c1c;
  --gold: #b45309;
  --shadow: 0 1px 3px rgba(30, 20, 10, 0.05), 0 10px 30px rgba(50, 30, 10, 0.07);
  --maxw: 740px;
  --nav-h: 66px;
  --bottom-safe: calc(var(--nav-h) + env(safe-area-inset-bottom));
  --font-serif: "Noto Serif TC", "Noto Serif SC", "Songti TC", "Songti SC", "PMingLiU", "SimSun", serif;
  --font-en: "Spectral", Georgia, serif;
  --fs: 18.5px;
  --fs-bump: 0px;
  --lh: 1.95;
}

html.theme-sepia {
  --paper: #ede3d2;
  --paper-2: #ded2bd;
  --card: #f4ecde;
  --ink: #2b2219;
  --ink-soft: #554838;
  --ink-faint: #7d6b56;
  --line: #d8cbaf;
  --line-soft: #e2d7c1;
  --cinnabar: #881337;
  --cinnabar-2: #701a75;
  --cinnabar-glow: rgba(136, 19, 55, 0.14);
  --cinnabar-wash: rgba(136, 19, 55, 0.06);
  --vermilion: #9f1239;
}

html.theme-dark {
  --paper: #141210;
  --paper-2: #1e1b18;
  --card: #1c1916;
  --ink: #e6e0d6;
  --ink-soft: #b8b0a4;
  --ink-faint: #8a8174;
  --line: #352e27;
  --line-soft: #26221d;
  --cinnabar: #ef4444;
  --cinnabar-2: #f87171;
  --cinnabar-glow: rgba(239, 68, 68, 0.2);
  --cinnabar-wash: rgba(239, 68, 68, 0.08);
  --vermilion: #fca5a5;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

html.fs-0 { --fs: 16px; }
html.fs-1 { --fs: 17.25px; }
html.fs-2 { --fs: 18.5px; }
html.fs-3 { --fs: 20px; }
html.fs-4 { --fs: 22px; }

html.lh-tight { --lh: 1.7; }
html.lh-normal { --lh: 1.95; }
html.lh-loose { --lh: 2.2; }

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--fs);
  line-height: var(--lh);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: var(--bottom-safe);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  background: var(--cinnabar);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  z-index: 1000;
  text-decoration: none;
  font-size: 14px;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 16px;
}

.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 90;
  pointer-events: none;
}
.read-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cinnabar), #dc2626);
  transition: width 0.15s ease-out;
}

/* Site Frame */
.site-frame {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  z-index: 80;
  margin: 0 -16px;
  padding: 0 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.icon-button {
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.icon-button:hover, .icon-button:focus-visible {
  background: var(--line-soft);
}

.brand-button {
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  min-width: 0;
}
.brand-button strong {
  font-size: 17px;
  font-weight: 700;
  color: var(--cinnabar);
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.brand-button span {
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-chip {
  background: var(--paper-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.topbar-chip:hover, .topbar-chip:focus-visible {
  background: var(--line);
  color: var(--cinnabar);
}
.topbar-chip.settings-chip {
  font-family: var(--font-en);
  font-weight: 600;
  padding: 4px 8px;
}

/* Settings Panel */
.settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 16px;
  width: 290px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 100;
}
.settings-panel[hidden] {
  display: none;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.set-label {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
  flex-shrink: 0;
}

.set-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.font-ctrl {
  background: var(--paper-2);
  border-radius: 8px;
  padding: 2px;
}
.font-ctrl .set-btn {
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: var(--font-en);
  font-size: 14px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 6px;
}
.font-ctrl .set-btn:hover {
  background: var(--paper);
}
.font-ctrl .set-val {
  font-size: 12px;
  color: var(--ink-soft);
  padding: 0 4px;
  min-width: 36px;
  text-align: center;
}

.seg-group {
  background: var(--paper-2);
  border-radius: 8px;
  padding: 2px;
  display: inline-flex;
}
.set-opt {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.set-opt.is-active, .set-opt[aria-checked="true"] {
  background: var(--paper);
  color: var(--cinnabar);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.swatch-paper { background: #faf6ed; }
.swatch-sepia { background: #ede3d2; }
.swatch-dark { background: #141210; color: #e6e0d6; }

.set-hint {
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.4;
  margin-top: -4px;
}

/* Main Views */
.view {
  padding: 24px 0 60px;
}
.view[hidden] {
  display: none;
}

/* Chapter Hero */
.chapter-hero {
  margin-bottom: 32px;
  text-align: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.chapter-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--cinnabar);
  background: var(--cinnabar-wash);
  border: 1px solid var(--cinnabar-glow);
  padding: 2px 10px;
  border-radius: 12px;
  margin-bottom: 12px;
  letter-spacing: 0.08em;
}
.chapter-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
  margin-bottom: 12px;
  letter-spacing: 0.04em;
}
.chapter-byline {
  font-size: 14px;
  color: var(--ink-faint);
  margin-bottom: 14px;
}
.chapter-blurb {
  font-size: 14.5px;
  color: var(--ink-soft);
  background: var(--paper-2);
  border-left: 3px solid var(--cinnabar);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  text-align: left;
  line-height: 1.6;
}

/* Stanzas / Paragraphs */
.stanza-segment {
  position: relative;
  margin-bottom: 20px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.stanza-segment:hover, .stanza-segment:focus-within {
  background: var(--cinnabar-wash);
}
.stanza-segment.is-active-target {
  background: var(--cinnabar-glow);
  outline: 1px solid var(--cinnabar);
}

.stanza-body {
  text-align: justify;
  letter-spacing: 0.02em;
}

.stanza-body.poem-body {
  text-align: center;
  font-style: normal;
  padding: 6px 0;
  color: var(--ink);
  line-height: 1.85;
}

.stanza-body.box-body {
  background: var(--paper-2);
  border-left: 3px solid var(--cinnabar);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  font-size: 0.95em;
}

.stanza-body.note-body {
  font-size: 0.9em;
  color: var(--ink-soft);
  line-height: 1.7;
  padding-left: 8px;
  border-left: 2px solid var(--line);
}

.stanza-body.sign-body {
  text-align: right;
  font-size: 0.9em;
  color: var(--ink-faint);
}

.stanza-subheading {
  margin: 28px 0 14px;
  text-align: center;
}
.zp-subheading {
  font-size: 19px;
  font-weight: 700;
  color: var(--cinnabar);
  letter-spacing: 0.08em;
  display: inline-block;
  padding: 4px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

/* ZP Commentary Typography */
.zp-comment {
  color: var(--vermilion);
  font-size: 0.88em;
  line-height: 1.6;
  background: var(--cinnabar-wash);
  padding: 1px 3px;
  border-radius: 4px;
  margin: 0 2px;
  display: inline;
}
.theme-dark .zp-comment {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
}

html.hide-zp-comments .zp-comment {
  display: none !important;
}

.zp-version-tag {
  display: inline-block;
  font-size: 0.78em;
  font-weight: 600;
  color: var(--cinnabar);
  background: var(--paper-2);
  border: 1px solid var(--line);
  padding: 0 5px;
  border-radius: 4px;
  margin-right: 3px;
  vertical-align: 0.05em;
  line-height: 1.4;
}

.zp-type-tag {
  display: inline-block;
  font-size: 0.78em;
  color: var(--gold);
  border: 1px solid rgba(180, 83, 9, 0.25);
  padding: 0 4px;
  border-radius: 4px;
  margin-right: 3px;
  vertical-align: 0.05em;
  line-height: 1.4;
}

.zp-glyph {
  height: 1.15em;
  vertical-align: -0.15em;
  display: inline-block;
}
.theme-dark .zp-glyph {
  filter: invert(0.9) hue-rotate(180deg);
}

.zp-illustration {
  display: block;
  max-width: 320px;
  width: 90%;
  margin: 16px auto;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.zp-note-ref {
  color: var(--cinnabar);
  font-size: 0.8em;
  font-weight: 700;
  cursor: pointer;
  padding: 0 2px;
}

/* Stanza Actions */
.stanza-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}
.stanza-segment:hover .stanza-actions {
  opacity: 1;
}

html.read-quiet .stanza-actions {
  display: none;
}
html.read-quiet .stanza-segment:hover .stanza-actions,
html.read-quiet .stanza-segment:focus-within .stanza-actions {
  display: flex;
}

.action-btn {
  background: var(--paper-2);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  font-family: inherit;
  padding: 2px 8px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.action-btn:hover {
  background: var(--line);
  color: var(--cinnabar);
}
.action-btn.is-reacted {
  background: var(--cinnabar-wash);
  color: var(--cinnabar);
  border-color: var(--cinnabar-glow);
  font-weight: 600;
}
.action-btn svg {
  width: 14px;
  height: 14px;
}

/* Chapter Pager */
.chapter-pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.pager-btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
  max-width: 48%;
  text-decoration: none;
}
.pager-btn:hover {
  background: var(--paper-2);
  color: var(--cinnabar);
  border-color: var(--cinnabar);
}
.pager-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Drawer Layer */
.drawer-layer {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
}
.drawer-layer[hidden] {
  display: none;
}
.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  cursor: pointer;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.chapter-drawer {
  position: relative;
  width: 340px;
  max-width: 85vw;
  height: 100%;
  background: var(--card);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  z-index: 151;
}
.drawer-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-header span {
  font-size: 11px;
  font-family: var(--font-en);
  letter-spacing: 0.1em;
  color: var(--cinnabar);
  font-weight: 600;
}
.drawer-header h2 {
  font-size: 18px;
  font-weight: 700;
}
.drawer-search {
  padding: 12px 16px 8px;
}
.drawer-search input {
  width: 100%;
  background: var(--paper-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  outline: none;
}
.drawer-search input:focus {
  border-color: var(--cinnabar);
}
.drawer-search-status {
  padding: 0 16px 6px;
  font-size: 11px;
  color: var(--ink-faint);
}
#drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 24px;
}
.drawer-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--cinnabar);
  padding: 12px 8px 4px;
  letter-spacing: 0.05em;
  border-top: 1px solid var(--line-soft);
  margin-top: 8px;
}
.drawer-section-title:first-child {
  border-top: none;
  margin-top: 0;
}
.drawer-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14.5px;
  line-height: 1.4;
  transition: all 0.15s ease;
}
.drawer-item:hover, .drawer-item:focus-visible {
  background: var(--paper-2);
  color: var(--cinnabar);
}
.drawer-item.is-current {
  background: var(--cinnabar-wash);
  color: var(--cinnabar);
  font-weight: 600;
}
.drawer-item .item-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--cinnabar);
  min-width: 36px;
  flex-shrink: 0;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-safe);
  background: var(--paper);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  z-index: 80;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.bottom-nav button {
  flex: 1;
  max-width: 140px;
  min-height: 44px;
  min-width: 0;
  height: 100%;
  appearance: none;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--ink-faint);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px 8px;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.bottom-nav button:hover, .bottom-nav button[aria-current="page"] {
  color: var(--cinnabar);
}
.bottom-nav button[aria-current="page"] {
  background: var(--cinnabar-glow);
  font-weight: 600;
}
.bottom-nav .nav-symbol, .bottom-nav .nav-symbol svg { display: block; }

/* Dialogs */
.reader-dialog {
  margin: auto;
  width: 90vw;
  max-width: 520px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px;
  color: var(--ink);
}
.reader-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.dialog-close-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -8px;
  margin-right: -8px;
}
.dialog-heading {
  margin-bottom: 14px;
}
.dialog-heading span {
  font-size: 11px;
  font-family: var(--font-en);
  letter-spacing: 0.1em;
  color: var(--cinnabar);
  font-weight: 600;
}
.dialog-heading h2 {
  font-size: 20px;
  font-weight: 700;
}
.dialog-heading p {
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 2px;
}
.dialog-quote {
  font-size: 13.5px;
  color: var(--ink-soft);
  background: var(--paper-2);
  border-left: 3px solid var(--cinnabar);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 14px;
  max-height: 100px;
  overflow-y: auto;
}
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
textarea {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.6;
  padding: 10px;
  border-radius: 8px;
  outline: none;
  resize: vertical;
}
textarea:focus {
  border-color: var(--cinnabar);
}
.field-status {
  font-size: 12px;
  color: var(--ink-faint);
  min-height: 18px;
  margin: 6px 0 10px;
}
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.primary-button {
  background: var(--cinnabar);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.primary-button:hover {
  background: var(--cinnabar-2);
}
.secondary-button {
  background: var(--paper-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.secondary-button:hover {
  background: var(--line);
}

.comment-thread {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.comment-item {
  background: var(--paper-2);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
}
.comment-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-faint);
  margin-bottom: 4px;
}
.comment-meta strong {
  color: var(--cinnabar);
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-safe) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: var(--ink);
  color: var(--paper);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 200;
  box-shadow: var(--shadow);
}
.toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Cover Card & About */
.about-hero {
  text-align: center;
  padding: 24px 0 32px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.about-cover {
  max-width: 180px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.about-hero h1 {
  font-size: 24px;
  color: var(--cinnabar);
  margin-bottom: 8px;
}
.about-hero p {
  font-size: 14px;
  color: var(--ink-soft);
}
.about-section {
  margin-bottom: 24px;
}
.about-section h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--cinnabar);
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.about-section p {
  font-size: 14.5px;
  line-height: 1.8;
  margin-bottom: 10px;
  color: var(--ink-soft);
}

/* Rankings */
.rankings-header {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.rankings-header h1 {
  font-size: 22px;
  color: var(--cinnabar);
}
.rankings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ranking-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  transition: all 0.15s ease;
}
.ranking-card:hover {
  border-color: var(--cinnabar);
  box-shadow: var(--shadow);
}
.ranking-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.ranking-score {
  color: var(--cinnabar);
  font-weight: 600;
}
.ranking-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  text-decoration: none;
  display: block;
}

@media (max-width: 600px) {
  :root {
    --fs: 17.5px;
  }
  .topbar {
    height: 52px;
  }
  .brand-button strong {
    font-size: 16px;
  }
  .chapter-title {
    font-size: 22px;
  }
  .settings-panel {
    width: calc(100vw - 32px);
    right: 16px;
  }
}

/* Reading controls remain reachable on short/touch screens. */
body.drawer-open { overflow: hidden; }
.settings-panel { max-height: calc(100dvh - 80px - var(--bottom-safe)); overflow-y: auto; }
.chapter-drawer { padding-bottom: env(safe-area-inset-bottom); }
.reader-dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 3px; }
.stanza-segment { scroll-margin-top: 80px; }
html.read-quiet .stanza-segment.is-selected .stanza-actions { display: flex; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
