/* Minuit/violet, spacing and radii from Android app/design_tokens.dart. */
:root {
  color-scheme: dark;
  --canvas: #07070a;
  --bg0: #0a0a0c;
  --bg1: #111015;
  --bg2: #171620;
  --bg3: #1f1d28;
  --fg0: #f5f3f8;
  --fg1: #b8b4c2;
  --fg2: #8f8c98;
  --accent: #a78bfa;
  --accent-deep: #7c5bf2;
  --accent-soft: #a78bfa2e;
  --border: #ffffff14;
  --border-strong: #ffffff24;
  --status-green: #4ade80;
  --status-amber: #fbbf24;
  --status-red: #ff6b6b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --paper: var(--canvas);
  --ink: var(--fg0);
  --muted: var(--fg1);
  --line: var(--border);
  --green: var(--accent);
  --wash: var(--bg2);
  --white: var(--bg1);
  --error: var(--status-red);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--canvas);
  color: var(--fg0);
  accent-color: var(--accent);
  caret-color: var(--accent);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button {
  cursor: pointer;
  min-height: 46px;
  max-width: 100%;
  padding: .65rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg2);
  color: var(--fg0);
  font-size: .875rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
button:hover { background: var(--bg3); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg0); }
button.primary:hover { background: #bca6fc; }
button.quiet { background: transparent; border-color: transparent; }
button.danger { color: var(--status-red); }
a { color: var(--accent); text-underline-offset: 4px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--bg0); }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.25; overflow-wrap: anywhere; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.01em; margin-bottom: .45rem; }
h2 { font-size: 1.125rem; font-weight: 600; margin: 1.8rem 0 .8rem; }
h3 { font-size: .95rem; font-weight: 600; margin-bottom: .5rem; }
p { max-width: 65ch; font-size: .875rem; }
small, .muted { color: var(--fg1); }
small { font-size: .75rem; }

.masthead { max-width: 1080px; margin: auto; padding: calc(.9rem + env(safe-area-inset-top)) 1.25rem .5rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; }
.brand { color: var(--fg0); text-decoration: none; display: flex; align-items: center; gap: .5rem; font: 500 1.35rem/1.2 "Noto Serif JP", "Hiragino Mincho ProN", Georgia, serif; }
.brand svg { width: 23px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 1.8; flex: none; }
.brand-note { font: 500 .85em/1.2 "Noto Serif JP", "Hiragino Mincho ProN", serif; color: var(--accent); margin-left: .25rem; }
.network { color: var(--fg1); font-size: .7rem; text-align: right; }
.network::before { content: ""; display: inline-block; width: 6px; height: 6px; background: var(--status-green); border-radius: 50%; margin-right: 6px; }
.network.offline { color: var(--status-amber); }
.network.offline::before { background: var(--status-amber); }
main { max-width: 1040px; margin: auto; padding: .8rem 1.25rem 13rem; min-height: 80vh; outline: none; }
.intro { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .8rem 1rem; margin-bottom: 1.25rem; }
.intro > div { min-width: 0; }
.intro p { color: var(--fg1); max-width: 48ch; margin: .4rem 0 0; font-size: .8rem; }
.jp, .page-kicker { font: 500 .7rem/1.6 "Noto Serif JP", "Hiragino Mincho ProN", serif; letter-spacing: .25em; color: var(--fg2); }
.section-label { font: 500 .7rem/1.5 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .18em; text-transform: uppercase; color: var(--fg1); }
.empty { padding: 1rem 0 1.5rem; max-width: 650px; }
.empty h2 { margin-top: .3rem; }
.empty p { color: var(--fg1); }
.empty .actions { margin-top: 1rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.tag { display: inline-block; font-size: .65rem; font-weight: 600; line-height: 1.4; padding: .25rem .5rem; background: var(--accent-soft); color: var(--accent); border-radius: 999px; }
.tag.demo { background: var(--bg3); color: var(--fg1); }

.book-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.2rem 1rem; }
.book { min-width: 0; position: relative; }
.book-open { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 0; font-weight: 400; }
.book-open:hover { background: none; }
.cover { display: block; width: 100%; aspect-ratio: 2/3; object-fit: cover; background: var(--bg2); border-radius: var(--radius-md); overflow: hidden; }
.cover.blank { display: flex; align-items: center; justify-content: center; padding: 1rem; color: var(--accent); text-align: center; font: 500 1.3rem/1.3 "Noto Serif JP", Georgia, serif; border: 1px solid var(--border); }
.book-title { display: block; font-size: .8rem; line-height: 1.4; font-weight: 600; margin: .6rem 0 .25rem; overflow-wrap: anywhere; }
.book small { display: block; font-size: .65rem; }
.book .tag { margin-top: .35rem; }
.sample-panel { margin-top: 1.8rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.sample-panel h2 { margin-top: 0; }
.sample-panel p { color: var(--fg1); }
.samples { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.sample { min-width: 0; padding: 1rem; background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; align-items: start; gap: .65rem; overflow-wrap: anywhere; }
.sample .actions { margin-top: auto; }
.sample p { font-size: .8rem; margin: 0; }

.starter-panel { padding: 1rem; margin: 0 0 1.25rem; background: var(--bg1); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); }
.starter-panel h2 { margin-top: 0; }
.starter-panel p { color: var(--fg1); }
.starter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.starter-card { display: flex; flex-direction: column; gap: .65rem; min-width: 0; }
.starter-card .cover { max-width: 150px; }
.source-chips, .status-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.source-chips button, .status-tabs button { border-radius: 999px; background: transparent; font-size: .75rem; padding-inline: .9rem; }
.source-chips button[aria-pressed=true], .status-tabs button[aria-pressed=true] { color: var(--bg0); background: var(--accent); border-color: var(--accent); }
.resume-card { display: flex; align-items: center; gap: .9rem; padding: .75rem; margin: .65rem 0 1.25rem; background: var(--bg1); border: 1px solid var(--border); border-radius: 16px; }
.resume-card .cover { width: 56px; height: 82px; border-radius: var(--radius-sm); flex: none; }
.resume-card > div { min-width: 0; flex: 1; }
.resume-card h2, .resume-card h3 { margin: 0 0 .35rem; font-size: .85rem; }
.resume-card p { margin: 0 0 .4rem; color: var(--fg1); font-size: .7rem; }

.search-form { display: flex; gap: .65rem; flex-wrap: wrap; margin: 1rem 0; }
.search-form input { flex: 1 1 240px; min-width: 0; }
.search-form select { flex: 1 1 180px; min-width: 0; }
input, select { min-height: 48px; max-width: 100%; padding: .7rem .85rem; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--bg2); color: var(--fg0); font-size: .875rem; }
input::placeholder { color: var(--fg2); opacity: 1; }
label { font-weight: 600; }
label > input, label > select { margin-top: .35rem; }
.source-note { font-size: .75rem; color: var(--fg1); padding-bottom: .5rem; }
.back { margin: 0 0 1rem -.5rem; }
.detail { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.detail h1 { font-size: 1.375rem; margin: .65rem 0; }
.detail .actions { margin-top: .8rem; }
.description { white-space: pre-line; color: var(--fg1); margin-top: 1rem; max-height: 12rem; overflow: auto; }
.chapters { padding: 0; list-style: none; margin: 1rem 0; }
.chapter { border-top: 1px solid var(--border); padding: .9rem 0; display: flex; justify-content: space-between; gap: .8rem; align-items: center; }
.chapter:last-child { border-bottom: 1px solid var(--border); }
.chapter-heading { min-width: 0; font-size: .875rem; }
.chapter-heading strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.chapter small { display: block; margin-top: .3rem; font-size: .7rem; }
.chapter .actions { justify-content: flex-end; flex-shrink: 0; }
.download-status { color: var(--status-green); font-weight: 500; }
.warning { color: var(--status-amber); }
.error { color: var(--status-red); padding: .9rem; background: #ff6b6b12; border: 1px solid #ff6b6b30; border-radius: var(--radius-md); }
.loading { color: var(--fg1); padding: 1rem 0; }
.reader-toolbar { position: sticky; top: env(safe-area-inset-top); background: var(--canvas); z-index: 3; display: flex; align-items: center; gap: .65rem; border-bottom: 1px solid var(--border); padding: .65rem 0; margin-bottom: 1rem; }
.reader-toolbar .reader-title { flex: 1; min-width: 0; font-size: .8rem; font-weight: 600; overflow-wrap: anywhere; }
.reader-toolbar small { display: block; font-weight: 400; font-size: .65rem; margin-top: .2rem; }
.reader-toolbar button { padding: .5rem .65rem; }
.reader-text { font: 400 var(--reading-size, 1.2rem)/1.9 Literata, Georgia, "Times New Roman", serif; max-width: 65ch; margin: 1.75rem auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.reader-pages { max-width: 800px; margin: auto; }
.reader-pages figure { margin: 0 0 .6rem; }
.reader-pages img { display: block; width: 100%; height: auto; background: var(--bg2); }
.reader-pages figcaption { color: var(--fg2); font-size: .7rem; text-align: center; padding: .3rem; }
.reader-end { border-top: 1px solid var(--border); padding-top: 1.5rem; margin: 2rem auto 0; max-width: 65ch; }
.setting { padding: 1.15rem; margin-bottom: .8rem; background: var(--bg1); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.setting h2 { margin: 0 0 .6rem; font-size: 1rem; }
.setting p { color: var(--fg1); font-size: .8rem; }
.setting label { display: block; margin-bottom: .7rem; }
.setting input[type=range] { width: 100%; padding: 0; min-height: 44px; }
.storage-number { font-variant-numeric: tabular-nums; }
.progressbar { height: 4px; width: 100%; border: 0; background: var(--bg3); border-radius: 999px; overflow: hidden; margin: .5rem 0; }
progress::-webkit-progress-bar { background: var(--bg3); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }

#navigation { position: fixed; z-index: 5; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 1080px; display: flex; flex-wrap: wrap; background: var(--bg1); border: 1px solid var(--border-strong); border-bottom: 0; border-radius: 18px 18px 0 0; padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px #00000033; }
#navigation a { flex: 1 0 20%; min-width: max-content; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; min-height: 58px; font-size: .65rem; color: var(--fg1); text-decoration: none; padding: .35rem .35rem; line-height: 1.3; text-align: center; }
#navigation a span { white-space: nowrap; }
#navigation a[aria-current=page] { color: var(--accent); font-weight: 600; }
#navigation svg { box-sizing: content-box; width: 21px; height: 21px; padding: .25rem .85rem; border-radius: 999px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }
#navigation a[aria-current=page] svg { background: var(--accent-soft); }
.skip { position: fixed; top: -100px; left: 1rem; z-index: 9; background: var(--bg2); padding: 1rem; }
.skip:focus { top: 1rem; }
#notice { position: fixed; z-index: 10; bottom: calc(6rem + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--bg3); color: var(--fg0); border: 1px solid var(--border-strong); border-radius: var(--radius-md); padding: .85rem 1rem; max-width: calc(100% - 2rem); width: max-content; font-size: .8rem; box-shadow: 0 12px 40px #00000066; pointer-events: none; }
#notice:empty { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.footer-note { font-size: .7rem; color: var(--fg2); margin-top: 1.25rem; }

@media (min-width: 800px) {
  #navigation { width: 600px; }
  main { padding-top: 1.2rem; }
  .chapter-heading { max-width: 62%; }
}
@media (max-width: 600px) {
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem .75rem; }
  .samples { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 100px minmax(0, 1fr); gap: .9rem; }
  .detail h1 { font-size: 1.25rem; }
  .detail .actions { grid-column: 1/-1; }
  .chapter { align-items: start; flex-direction: column; }
  .chapter .actions { justify-content: start; }
  .search-form input, .search-form select { flex-basis: 100%; }
  .search-form button { flex: 1; }
  .setting { padding: 1rem; }
}
@media (max-width: 359px) {
  main, .masthead { padding-inline: 1rem; }
  .starter-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .cover { transition: filter .15s; }
  .book-open:hover .cover { filter: brightness(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
