:root {
  color-scheme: dark;
  --bg: #10151b;
  --panel: #181f28;
  --text: #e5e8e6;
  --muted: #a9b4bf;
  --line: #303d4a;
  --accent: #a9d3f4;
  --font: 21px;
  --spacing: 1.85;
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--text);
}
:root[data-theme="gray"] {
  --bg: #252525;
  --panel: #303030;
  --text: #ebebeb;
  --muted: #bcbcbc;
  --line: #515151;
  --accent: #bedbf5;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eceeeb;
  --panel: #f8f9f7;
  --text: #202a32;
  --muted: #4e606c;
  --line: #bbc5c9;
  --accent: #234c73;
}
:root[data-theme="light"] .intro h1 em {
  color: #3f6056;
}
:root[data-theme="light"] .reader-toolbar [aria-pressed="true"] {
  color: #235f9d;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
select,
input {
  font: inherit;
}
button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}
button,
select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 15px;
}
button {
  cursor: pointer;
  min-height: 44px;
}
button:hover {
  border-color: var(--accent);
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
a {
  color: var(--accent);
  text-underline-offset: 4px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
.skip {
  position: fixed;
  top: -80px;
  left: 12px;
  z-index: 30;
  background: var(--panel);
  padding: 12px;
}
.skip:focus {
  top: 8px;
}
.site-header {
  max-width: 1160px;
  margin: auto;
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-size: 18px;
  color: var(--text);
}
.brand strong {
  font-weight: 500;
}
.site-header nav {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 13px;
}
.site-header nav a {
  text-decoration: none;
}
.intro {
  padding: 66px 0 44px;
  max-width: 760px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.16em;
  font-weight: 650;
  color: var(--accent);
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
.intro h1 {
  font:
    clamp(38px, 5vw, 66px)/1.12 Georgia,
    serif;
  letter-spacing: -0.025em;
  margin: 20px 0;
}
.intro h1 em {
  color: #c0cdbb;
  font-weight: 400;
}
.intro > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.75;
  max-width: 590px;
}
.intro-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.intro-meta span:before {
  content: "·";
  margin-right: 7px;
  color: var(--accent);
}
#library {
  max-width: 1096px;
  padding: 0 32px;
  margin: auto;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}
.section-title h2 {
  font-size: 21px;
  margin: 0;
}
.section-title button {
  font-size: 12px;
  background: none;
}
.book-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 24px 0 38px;
}
.book-card {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}
.book-card img {
  width: 140px;
  height: 210px;
  box-shadow: 0 10px 25px #0004;
  border-radius: 4px;
}
.book-card h3 {
  font:
    26px/1.25 Georgia,
    serif;
  margin: 8px 0;
}
.book-card p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}
.book-card .genre {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.book-card button {
  font-size: 13px;
  margin-top: 8px;
}
.book-progress {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin: 12px 0 2px;
}
.demo-note {
  border: 1px solid var(--line);
  padding: 24px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}
.demo-note strong {
  color: var(--text);
}
.demo-note p {
  margin-bottom: 0;
}
.site-footer {
  max-width: 1160px;
  margin: 40px auto 0;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 32px 36px;
  font-size: 12px;
  color: var(--muted);
}
body.reading .site-header,
body.reading .site-footer {
  display: none;
}
#reader {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  max-width: 920px;
  margin: auto;
  padding-top: env(safe-area-inset-top);
}
.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.reader-header h1 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  text-align: center;
}
.reader-header p {
  font-size: 11px;
  text-align: center;
  color: var(--muted);
  margin: 4px 0 0;
}
.reader-header button {
  font-size: 13px;
  background: none;
}
.reader-header > div {
  min-width: 0;
}
#reading-area {
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y;
  position: relative;
  overscroll-behavior-x: none;
}
#passage {
  height: 100%;
  width: 100%;
  padding: 24px;
  column-gap: 48px;
  column-fill: auto;
  font:
    var(--font)/var(--spacing) Georgia,
    "Times New Roman",
    serif;
  overflow: visible;
  overflow-wrap: break-word;
  hyphens: auto;
  will-change: transform;
}
#passage h2 {
  font:
    600 1.05em/1.5 system-ui,
    sans-serif;
  color: var(--muted);
  margin: 0 0 24px;
  break-after: avoid;
}
#passage p {
  margin: 0 0 1em;
}
#passage .recorded {
  background: #8c9d9b25;
  border-radius: 3px;
}
.reader-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 18px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.reader-status button {
  background: none;
  padding: 6px 16px;
}
.reader-toolbar {
  display: flex;
  justify-content: space-evenly;
  padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
}
.reader-toolbar button {
  border: 0;
  background: none;
  font-size: 23px;
  padding: 5px 12px;
}
.reader-toolbar span {
  display: block;
  font-size: 10px;
  margin-top: 2px;
}
.reader-toolbar [aria-pressed="true"] {
  color: #77baff;
}
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 15px;
  max-width: min(560px, calc(100vw - 24px));
  width: 100%;
  padding: 24px;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  box-shadow: 0 24px 70px #0008;
}
dialog::backdrop {
  background: #0009;
}
dialog p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.dialog-heading h2 {
  margin: 0;
  font-size: 21px;
}
.dialog-heading button {
  font-size: 22px;
  background: none;
  border: 0;
}
label {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0;
  font-size: 14px;
}
label input {
  width: 100%;
  accent-color: var(--accent);
}
#contents[open] {
  display: flex;
  flex-direction: column;
  max-width: 680px;
  height: calc(100dvh - 24px);
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
#chapter-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
#chapter-list button {
  display: block;
  text-align: left;
  width: 100%;
  border-radius: 0;
  padding: 20px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
}
#mini {
  position: fixed;
  z-index: 10;
  bottom: calc(106px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(510px, calc(100% - 24px));
  display: flex;
  align-items: center;
  padding: 9px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  box-shadow: 0 10px 40px #0007;
}
#mini button {
  border: 0;
  padding: 8px;
  flex-shrink: 0;
  font-size: 13px;
}
#mini-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  font-size: 12px !important;
}
#audio-excerpt {
  margin: 20px 0 0;
  padding: 15px;
  border-left: 2px solid var(--line);
  font:
    17px/1.7 Georgia,
    serif;
}
#audio-excerpt.active {
  background: #8c9d9b25;
}
#notice:empty {
  display: none;
}
#notice {
  position: fixed;
  bottom: 12px;
  left: 12px;
  right: 12px;
  padding: 12px;
  z-index: 25;
  background: var(--panel);
  border: 1px solid var(--line);
}
.import-book {
  display: flex;
  gap: 20px;
  align-items: center;
  margin: 22px 0;
}
.import-book img {
  border-radius: 5px;
}
.import-book h3 {
  font-family: Georgia, serif;
  font-size: 23px;
}
#import-chapters label {
  justify-content: flex-start;
  margin: 0;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
#import-chapters input {
  width: auto;
}
#import-selected {
  margin-top: 16px;
}
@media (max-width: 760px) {
  .site-header {
    padding: 16px;
    align-items: flex-start;
  }
  .brand {
    font-size: 15px;
  }
  .site-header nav {
    gap: 10px;
    flex-direction: column;
    align-items: flex-end;
    font-size: 11px;
  }
  .site-header nav button {
    padding: 7px;
    font-size: 11px;
  }
  .intro {
    padding-top: 36px;
  }
  .intro-meta {
    gap: 12px;
  }
  #library {
    padding: 0 18px;
  }
  .book-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .book-card {
    padding: 18px;
    gap: 20px;
    grid-template-columns: 105px 1fr;
  }
  .book-card img {
    width: 105px;
    height: 158px;
  }
  .book-card h3 {
    font-size: 23px;
  }
  .book-card p {
    font-size: 12px;
    margin-bottom: 9px;
  }
  .book-card .genre {
    font-size: 9px;
  }
  .site-footer {
    flex-direction: column;
    padding: 24px 18px;
  }
  .reader-header {
    padding: 10px 12px;
  }
  .reader-header button {
    padding: 8px;
    font-size: 12px;
  }
  #passage {
    padding: 20px 24px;
  }
  .reader-status {
    padding: 5px 12px;
  }
  .reader-toolbar button {
    padding: 4px 9px;
  }
  dialog {
    padding: 18px;
  }
  .demo-note {
    padding: 18px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  button,
  a {
    transition:
      color 0.15s,
      border-color 0.15s;
  }
  .book-card {
    animation: appear 0.4s ease-out;
  }
  @keyframes appear {
    from {
      opacity: 0;
      transform: translateY(5px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}
