:root {
  color-scheme: light dark;
  --bg: #fafaf5;
  --fg: #1a1a1a;
  --muted: #666;
  --accent: #b45309;
  --border: rgba(0,0,0,0.1);
  --header-bg: rgba(250,250,245,0.9);
  --player-bg: rgba(250,250,245,0.95);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --fg: #e8e3d8;
    --muted: #9a9a9a;
    --accent: #f59e0b;
    --border: rgba(255,255,255,0.1);
    --header-bg: rgba(26,26,26,0.9);
    --player-bg: rgba(26,26,26,0.95);
  }
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-size: 18px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
#chapter-select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font-size: 15px;
  max-width: 60%;
}
.reader {
  flex: 1;
  padding: 16px;
  padding-bottom: 140px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.reader h2 {
  font-size: 22px;
  margin-top: 8px;
  margin-bottom: 24px;
  font-weight: 600;
  text-align: center;
}
.reader p {
  margin: 0 0 1.2em 0;
  text-align: justify;
  text-indent: 2em;
}
.reader .notice {
  margin: 0 0 1em 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.12);
  color: var(--muted);
  font-size: 14px;
  text-indent: 0;
  text-align: center;
}
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: var(--player-bg);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  align-items: center;
}
.player audio {
  flex: 1;
  width: 100%;
  height: 40px;
}
.download-btn {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.download-btn:disabled { opacity: 0.6; }
.download-btn[data-cached="true"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.sentence {
  transition: background-color 0.2s, color 0.2s;
  border-radius: 4px;
  padding: 0 2px;
}
.sentence:hover {
  opacity: 0.8;
}
.sentence-active {
  background-color: var(--accent) !important;
  color: #000 !important;
}
@media (prefers-color-scheme: dark) {
  .sentence {
    background: rgba(245, 158, 11, 0.15);
  }
  .sentence:hover {
    background: rgba(245, 158, 11, 0.25);
  }
}
@media (prefers-color-scheme: light) {
  .sentence {
    background: rgba(180, 83, 9, 0.1);
  }
  .sentence:hover {
    background: rgba(180, 83, 9, 0.2);
  }
}
