:root {
  color-scheme: light;
  --paper: #faf2e6;
  --ink: #3b2617;
  --muted: #735c4a;
  --orange: #b34012;
  --orange-pressed: #8e2f0a;
  --wash: #f0e0cc;
  --surface: #fff9f0;
  --line: #d9c6ae;
  --focus: #9b350d;
  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", serif;
  --motion: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html { min-width: 280px; scroll-padding-top: 96px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  overflow-wrap: anywhere;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; }
button, input { color: inherit; }
button:disabled { cursor: default; opacity: 0.45; }
button, a, input { scroll-margin-top: 112px; }
button { border-radius: 8px; }
a { color: var(--orange); text-decoration-thickness: 1px; text-underline-offset: 4px; }
a, button { transition: opacity 200ms var(--motion); }
button:active:not(:disabled), a:active { opacity: 0.68; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
input:focus-visible { outline-offset: 0; }
::selection { background: #eac9ad; color: var(--ink); }
[hidden] { display: none !important; }
img, svg { display: block; flex-shrink: 0; }
svg { width: 24px; height: 24px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 600; text-wrap: balance; }
p { text-wrap: pretty; }
h1 { font-size: 30px; line-height: 1.4; }
h2 { font-size: 24px; line-height: 1.4; }
h3 { font-size: 20px; line-height: 1.4; }
ul, ol { padding: 0; margin: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  top: 8px;
  left: 16px;
  z-index: 100;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1040px;
  margin: auto;
  min-height: 80px;
  padding: 12px max(24px, env(safe-area-inset-right)) 12px max(24px, env(safe-area-inset-left));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 600;
  text-decoration: none;
  flex-shrink: 0;
}
.brand img { border-radius: 8px; }
.brand-note { display: none; font-size: 14px; font-weight: 400; color: var(--muted); }
.button-quiet, .text-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  color: var(--orange);
  background: transparent;
  border: 0;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
}
.button-quiet { border-radius: 8px; }
.text-button { padding-left: 0; padding-right: 0; text-decoration: underline; text-underline-offset: 4px; }
.install-trigger { font-size: 14px; }
.main {
  width: 100%;
  max-width: 808px;
  min-height: calc(100dvh - 280px);
  margin: auto;
  padding: 40px max(24px, env(safe-area-inset-right)) 64px max(24px, env(safe-area-inset-left));
}
.main:focus { outline: none; }
.page { animation: page-in 300ms var(--motion) both; }
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }
.eyebrow { margin-bottom: 12px; color: var(--orange); font-size: 14px; letter-spacing: 0.12em; }
.muted, .helper { color: var(--muted); font-size: 14px; line-height: 1.6; }
.page-heading { margin-bottom: 32px; }
.page-heading .muted { margin-top: 16px; }
.search-intro { margin-bottom: 32px; }
.search-intro h1 { line-height: 1.6; }
.search-form { margin-bottom: 24px; }
.field-label { display: block; margin-bottom: 8px; font-size: 14px; color: var(--muted); }
.search-controls { display: flex; gap: 12px; flex-wrap: wrap; }
.search-field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  width: 100%;
  min-height: 56px;
  padding: 4px 8px 4px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
}
.search-field > svg { width: 20px; height: 20px; color: var(--muted); }
.search-field input {
  display: block;
  min-width: 0;
  width: 100%;
  min-height: 44px;
  padding: 8px 0;
  background: transparent;
  border: 0;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1.5;
  -webkit-appearance: none;
  appearance: none;
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input::placeholder { color: var(--muted); opacity: 0.8; }
.search-field .clear-search { padding: 8px; color: var(--muted); }
.clear-search svg { width: 20px; height: 20px; }
.button-primary, .button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: none;
  text-align: center;
}
.button-primary { color: #fff9f0; background: var(--orange); }
.button-primary:active:not(:disabled) { background: var(--orange-pressed); opacity: 1; }
.button-secondary { color: var(--orange); background: transparent; border-color: var(--line); }
.search-submit { width: 100%; }
.field-error { margin-top: 8px; color: var(--orange-pressed); font-size: 14px; }
.suggestions { margin: 24px 0 40px; }
.suggestions .helper { margin-bottom: 12px; }
.suggestion-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; }
.suggestion {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
}
.suggestion svg { width: 16px; height: 16px; color: var(--orange); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { flex-shrink: 0; }
.section-heading .helper { text-align: right; }
.recent-section { margin-top: 40px; }
.source-note {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}
.source-note p + p { margin-top: 8px; }
.book-list, .recent-list { list-style: none; }
.book-list > li + li, .recent-list > li + li { border-top: 1px solid var(--line); }
.book-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 112px;
  padding: 16px 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 4px;
  text-align: left;
  text-decoration: none;
}
.book-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 64px;
  height: 88px;
  background: var(--wash);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.book-cover svg { width: 32px; height: 32px; stroke-width: 1.25; }
.book-row-copy { flex: 1; min-width: 0; }
.book-row-copy h3 { margin-bottom: 8px; }
.book-row-copy p { color: var(--muted); font-size: 14px; }
.book-row-copy p + p { margin-top: 4px; }
.book-row > svg { width: 16px; height: 16px; color: var(--muted); }
.recent-label { display: inline-block; margin-bottom: 8px; color: var(--orange); font-size: 12px; }
.recent-list .book-row { min-height: 104px; }
.recent-list .book-cover { width: 48px; height: 64px; }
.recent-list .book-cover svg { width: 24px; height: 24px; }
.recent-list h3 { font-size: 18px; }
.issues { margin-bottom: 24px; }
.issue, .error-panel, .notice-panel, .empty-panel {
  padding: 16px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
}
.issue { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.issue + .issue { margin-top: 8px; }
.issue svg { width: 20px; height: 20px; }
.issue p { flex: 1; }
.error-panel p, .notice-panel p, .empty-panel p { font-size: 16px; }
.error-panel .button-secondary { margin-top: 16px; }
.empty-panel { padding: 32px 24px; text-align: center; }
.empty-panel > svg { margin: 0 auto 16px; width: 32px; height: 32px; }
.empty-panel h2, .empty-panel h3 { margin-bottom: 12px; color: var(--ink); }
.empty-panel .button-secondary { margin-top: 16px; }
.loading-label { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; color: var(--muted); }
.loading-label::before { content: ""; display: block; width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--orange); animation: breathe 1.6s var(--motion) infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
.skeleton-row { display: flex; align-items: center; gap: 16px; padding: 16px 0; }
.skeleton-cover { width: 64px; height: 88px; border-radius: 4px; flex-shrink: 0; background: var(--wash); }
.skeleton-copy { flex: 1; }
.skeleton-line { display: block; height: 16px; width: 72%; margin-bottom: 12px; border-radius: 4px; background: var(--wash); animation: breathe 1.6s var(--motion) infinite; }
.skeleton-line.short { width: 40%; height: 12px; margin-bottom: 0; }
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin: -8px 0 24px -8px; padding: 8px; text-decoration: none; font-size: 14px; }
.back-link svg { width: 16px; height: 16px; }
.book-heading { margin-bottom: 24px; }
.book-heading h1 { margin-bottom: 12px; }
.book-heading .helper { margin-top: 8px; }
.reading-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 40px; }
.reading-actions .button-primary { width: 100%; }
.reading-actions a span { display: block; }
.reading-actions .action-detail { margin-top: 4px; font-size: 14px; font-weight: 400; }
.chapter-list { list-style: none; margin-bottom: 24px; }
.chapter-list li { border-bottom: 1px solid var(--line); }
.chapter-link {
  display: flex;
  align-items: baseline;
  gap: 16px;
  min-height: 56px;
  padding: 16px 4px;
  color: var(--ink);
  border-radius: 4px;
  text-decoration: none;
  font-size: 18px;
  line-height: 1.6;
}
.chapter-number { width: 32px; flex-shrink: 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chapter-name { flex: 1; min-width: 0; }
.chapter-last-read { display: inline-block; margin-top: 4px; color: var(--orange); font-size: 12px; }
.chapter-link.is-read { color: var(--orange); }
.toc-footer { display: grid; gap: 16px; }
.toc-footer .button-secondary { width: 100%; }
.toc-footer .helper { text-align: center; }
.notice-panel { font-size: 14px; }
.reader-page { max-width: 712px; margin: auto; }
.reader-top { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-top: -16px; margin-bottom: 24px; }
.reader-top .back-link { margin: 0 0 0 -8px; }
.reader-top .button-quiet { font-size: 14px; }
.font-panel { padding: 16px; margin-bottom: 32px; background: var(--wash); border: 1px solid var(--line); border-radius: 12px; }
.font-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.font-controls .button-secondary { min-width: 48px; background: var(--paper); }
.font-value { color: var(--ink); font-size: 16px; }
.font-panel .helper { margin-top: 12px; }
.reader-heading { margin-bottom: 40px; }
.reader-heading h1 { line-height: 1.6; }
.reader-heading p { margin-top: 16px; color: var(--muted); font-size: 14px; }
.chapter-copy { line-height: 1.9; font-size: 22px; }
.chapter-copy[data-size="16"] { font-size: 16px; }
.chapter-copy[data-size="18"] { font-size: 18px; }
.chapter-copy[data-size="20"] { font-size: 20px; }
.chapter-copy[data-size="22"] { font-size: 22px; }
.chapter-copy[data-size="24"] { font-size: 24px; }
.chapter-copy[data-size="26"] { font-size: 26px; }
.chapter-copy[data-size="28"] { font-size: 28px; }
.chapter-copy[data-size="30"] { font-size: 30px; }
.chapter-copy[data-size="32"] { font-size: 32px; }
.chapter-copy p { margin-bottom: 24px; text-indent: 2em; white-space: pre-line; text-align: start; }
.chapter-end { display: grid; gap: 16px; margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--line); text-align: center; }
.chapter-end .button-primary { justify-self: stretch; }
.chapter-end .text-button { justify-self: center; }
.reader-skeleton .skeleton-line { width: 100%; margin-bottom: 24px; height: 16px; }
.reader-skeleton .skeleton-line:nth-child(4n) { width: 64%; margin-bottom: 40px; }
.chapter-controls {
  position: fixed;
  z-index: 30;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px max(16px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.chapter-controls-inner { max-width: 712px; margin: auto; }
.chapter-controls-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.chapter-controls-buttons button, .chapter-controls-buttons a { min-height: 44px; padding: 8px; }
.chapter-controls-buttons .button-quiet { font-size: 16px; }
.chapter-controls-buttons svg { width: 16px; height: 16px; }
.reading-progress { color: var(--muted); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.is-reading .main { padding-top: 32px; padding-bottom: 48px; }
.is-reading .site-footer { padding-bottom: calc(128px + env(safe-area-inset-bottom)); }
.site-footer { max-width: 808px; margin: auto; padding: 24px max(24px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); text-align: center; color: var(--muted); font-size: 12px; }
.site-footer p + p { margin-top: 8px; }
.site-footer .text-button { margin-top: 8px; font-size: 12px; }
.network-note, .storage-note { margin: 0; padding: 12px 24px; color: var(--muted); background: var(--wash); font-size: 14px; text-align: center; }
.opening-state { padding: 48px 0; }
.access-page { max-width: 480px; margin: auto; }
.access-mark { margin-bottom: 32px; width: 64px; height: 64px; border-radius: 12px; }
.access-page .page-heading { margin-bottom: 32px; }
.access-input { width: 100%; min-height: 48px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 18px; }
.access-field { display: flex; gap: 8px; align-items: center; }
.access-field .button-quiet { flex-shrink: 0; }
.access-page .helper { margin-top: 12px; }
.access-page .button-primary { width: 100%; margin-top: 24px; }
.access-page .field-error { margin-top: 12px; }
dialog { width: calc(100% - 32px); max-width: 480px; max-height: calc(100dvh - 64px); margin: auto; padding: 24px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 16px; overflow: auto; }
dialog::backdrop { background: rgb(35 24 16 / 0.4); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.dialog-heading h2 { padding-top: 4px; }
.dialog-heading .button-quiet { flex-shrink: 0; margin-top: -8px; margin-right: -12px; font-size: 14px; }
.install-steps { padding-left: 24px; margin: 24px 0; }
.install-steps li + li { margin-top: 16px; }
dialog .button-primary { width: 100%; margin-top: 24px; }
#install-feedback { margin-top: 16px; }
.noscript-note { margin: 24px; padding: 24px; background: var(--wash); text-align: center; }

@media (hover: hover) {
  .button-quiet:hover, .text-button:hover { background: var(--wash); }
  .button-primary:hover { opacity: 0.88; }
  .button-secondary:hover, .suggestion:hover { background: var(--wash); }
  .book-row:hover, .chapter-link:hover { color: var(--orange); background: rgb(240 224 204 / 0.4); }
}
@media (min-width: 640px) {
  .brand-note { display: inline; }
  .main { padding-top: 64px; }
  .search-intro h1 { font-size: 36px; }
  .search-controls { flex-wrap: nowrap; }
  .search-submit { width: auto; flex-shrink: 0; padding-right: 24px; padding-left: 24px; }
  .reading-actions .button-primary { width: auto; min-width: 240px; }
  .search-field { flex: 1; }
  .chapter-end .button-primary { justify-self: center; min-width: 240px; }
}
@media (max-width: 360px) {
  .header-inner, .main { padding-right: max(16px, env(safe-area-inset-right)); padding-left: max(16px, env(safe-area-inset-left)); }
  .header-inner { gap: 8px; }
  .brand { gap: 8px; }
  .install-trigger { padding-left: 8px; padding-right: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
