:root {
  color-scheme: light;
  --bg: #eef1f6;
  --bg-alt: #e4e9f2;
  --paper: #ffffff;
  --ink: #12151c;
  --muted: #5b6474;
  --line: #d8dee8;
  --accent: #2f5bff;
  --accent-ink: #ffffff;
  --accent-soft: #e8edff;
  --ok: #1f7a4c;
  --danger: #c42b2b;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(18, 21, 28, 0.08);
  --header-h: 64px;
  --font-ui: "Segoe UI", system-ui, sans-serif;
  --font-read: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--accent); }
.wrap {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 0.9rem;
  z-index: 20;
}
.skip:focus {
  left: 0.75rem;
  top: 0.75rem;
}

.top {
  position: sticky;
  top: 0;
  z-index: 12;
  min-height: var(--header-h);
  background: rgba(15, 18, 24, 0.94);
  color: #eef1f6;
  backdrop-filter: blur(12px);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--header-h);
}
.is-reader .nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
}
.is-reader .brand { justify-self: center; }
.brand {
  font-weight: 700;
  text-decoration: none;
  color: #fff;
  letter-spacing: -0.03em;
  font-size: 1.05rem;
}
.nav-toggle {
  display: none;
  min-height: 44px;
  min-width: 44px;
  padding: 0 0.9rem;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.nav-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  color: #d5dbe8;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.nav-links a:hover,
.nav-links a:focus-visible { color: #fff; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 2rem;
  padding: 2.4rem 0 2.8rem;
  align-items: start;
}
.kicker {
  margin: 0 0 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
}
.hero h1,
.empty-card h1 {
  margin: 0 0 0.8rem;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1.12;
  letter-spacing: -0.04em;
}
.lead {
  font-size: 1.12rem;
  color: var(--muted);
  margin: 0 0 1.4rem;
  max-width: 38rem;
}
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.facts li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.upload-card,
.empty-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.2rem 1.4rem;
}
.upload-card { position: sticky; top: calc(var(--header-h) + 1rem); }
.upload-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}
.hint { margin: 0 0 1rem; color: var(--muted); font-size: 0.92rem; }
.drop {
  display: grid;
  gap: 0.7rem;
  position: relative;
}
.drop input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.drop-label {
  display: grid;
  gap: 0.2rem;
  place-items: center;
  text-align: center;
  min-height: 120px;
  padding: 1rem;
  border: 1.5px dashed #b7c2dc;
  border-radius: 12px;
  background: var(--accent-soft);
  cursor: pointer;
}
.drop.is-drag .drop-label {
  border-color: var(--accent);
  background: #dce4ff;
}
.drop-title { font-weight: 700; }
.drop-sub { color: var(--muted); font-size: 0.88rem; }

.btn,
.btn-ghost,
.btn-danger,
.drop button {
  font: inherit;
  border: 0;
  border-radius: 10px;
  min-height: 44px;
  padding: 0.65rem 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}
.btn,
.drop button {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.btn-ghost {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--line);
  min-height: 44px;
}
.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.flash-error {
  margin: 0 0 0.8rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: #fdecec;
  color: var(--danger);
}
#file-status,
.status-line {
  min-height: 1.2em;
  margin: 0;
  color: var(--ok);
  font-size: 0.88rem;
}
#file-status.is-error,
.status-line.is-error { color: var(--danger); }

.band {
  background: var(--bg-alt);
  padding: 2.2rem 0;
}
.band h2,
.steps-block h2,
.faq-block h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.empty { color: var(--muted); margin: 0; }

.book-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}
.book-item {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.book-link {
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.book-title { display: block; font-weight: 700; }
.book-meta { display: block; color: var(--muted); font-size: 0.88rem; }

.steps-block { padding: 2.4rem 0; }
.steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  padding: 0;
  margin: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1rem 1.1rem 3.2rem;
  position: relative;
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0.9rem;
  top: 0.95rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
}
.alice-block p { max-width: 42rem; color: var(--muted); }
.alice-block p:first-of-type { color: var(--ink); }

.faq-block { padding: 2.2rem 0 4rem; }
details {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.2rem 1rem;
  margin: 0 0 0.6rem;
}
summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 48px;
  display: flex;
  align-items: center;
}
details p { color: var(--muted); margin-top: 0; }

.site-footer {
  padding: 1.4rem 0 2.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.toc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0 0.75rem;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.burger {
  width: 16px;
  display: grid;
  gap: 3px;
}
.burger i {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}
.toc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 24, 0.45);
  z-index: 20;
}
.toc-drawer {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 21;
  width: min(360px, 92vw);
  height: 100%;
  background: #fff;
  color: var(--ink);
  box-shadow: 12px 0 40px rgba(15, 18, 24, 0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(-105%);
  transition: transform 0.2s ease;
}
body.is-toc-open .toc-drawer { transform: translateX(0); }
body.is-toc-open .toc-backdrop,
body.is-toc-open .toc-drawer { display: flex; }
.toc-drawer[hidden],
.toc-backdrop[hidden] { display: none !important; }
.toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
.toc-head h2 { margin: 0; font-size: 1.05rem; }
.toc-close {
  min-height: 44px;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
  color: var(--muted);
}
.toc-status { margin: 0; padding: 0.8rem 1rem; color: var(--muted); font-size: 0.9rem; }
.toc-list {
  overflow: auto;
  padding: 0.4rem 0.6rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.toc-item {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr);
  gap: 0.55rem;
  text-align: left;
  text-decoration: none;
  color: inherit;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
  min-height: 44px;
  cursor: pointer;
  font: inherit;
}
.toc-item:hover,
.toc-item:focus-visible { background: var(--accent-soft); }
.toc-item.is-current { background: var(--accent-soft); color: var(--ink); }
.toc-item .page-num { font-weight: 700; color: var(--muted); }
.toc-item .page-preview {
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reader-meta {
  margin: 0.9rem auto 0.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.status-line { padding: 0 0 0.4rem; min-height: 1.2em; }
.alice-hint {
  color: var(--muted);
  font-size: 0.85rem;
  padding-bottom: 5.5rem;
}

.feed {
  width: min(46rem, calc(100% - 2rem));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 0.6rem 0 1.5rem;
}
.sheet {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px 16px 16px 4px;
  box-shadow: var(--shadow);
  padding: 2.3rem 2.2rem 2.6rem;
  min-height: 72vh;
  font-family: var(--font-read);
  font-size: 1.2rem;
  line-height: 1.75;
}
.sheet h1 {
  font-family: var(--font-ui);
  font-size: clamp(1.25rem, 3vw, 1.7rem);
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 1.1rem;
}
.sheet p { margin: 0 0 0.9rem; }
.sheet .toc-heading {
  font-family: var(--font-ui);
  font-weight: 650;
  font-size: 1.45rem;
  letter-spacing: -0.04em;
  line-height: 1.2;
  margin: 0 0 1.1rem;
}
.sheet .toc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 0.55rem;
  margin: 0.18em 0;
  font-family: var(--font-ui);
  font-size: 1.02rem;
  line-height: 1.45;
}
.sheet .toc-row.is-chapter {
  font-weight: 700;
  margin: 0.95em 0 0.28em;
  font-size: 1.06rem;
}
.sheet .toc-row.is-sub {
  padding-left: 1.35rem;
  font-weight: 400;
}
.sheet .toc-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  min-width: 0;
}
.sheet .toc-label { flex: 0 1 auto; }
.sheet .toc-dots {
  flex: 1 0 1.6rem;
  border-bottom: 1px dotted rgba(18, 21, 28, 0.38);
  margin-left: 0.45rem;
  transform: translateY(-0.32em);
}
.sheet .toc-row.is-chapter .toc-dots { display: none; }
.sheet .toc-page {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-align: right;
}
.scan-note { color: var(--muted); font-family: var(--font-ui); font-size: 1rem; }

.pageable {
  position: sticky;
  bottom: 0;
  z-index: 11;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 0.8rem calc(0.65rem + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.96);
  border-top: 1px solid var(--line);
}
.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.page-jump input {
  width: 4.2rem;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 0.45rem;
  font: inherit;
  text-align: center;
}

body.is-read-mode .toc-drawer,
body.is-read-mode .toc-backdrop,
body.is-read-mode .pageable,
body.is-read-mode .alice-hint,
body.is-read-mode .reader-meta { display: none !important; }
body.is-read-mode .sheet:not(.is-current) { display: none; }
body.is-read-mode .sheet.is-current {
  box-shadow: none;
  border: 0;
  max-width: 40rem;
  margin: 0 auto;
  font-size: 1.28rem;
}

.empty-card { margin: 2rem auto; max-width: 36rem; }

summary:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  #site-nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: var(--header-h);
    background: #0f1218;
    padding: 0.5rem 1rem 1rem;
  }
  body.is-nav-open #site-nav { display: block; }
  .nav-links { flex-direction: column; gap: 0; }
  .hero,
  .book-list,
  .steps { grid-template-columns: 1fr; }
  .upload-card { position: static; }
  .sheet { padding: 1.4rem 1.15rem 1.8rem; min-height: 60vh; font-size: 1.08rem; }
  .sheet .toc-row.is-sub { padding-left: 0.9rem; }
  .sheet .toc-heading { font-size: 1.25rem; }
  .pageable .btn { flex: 1 1 auto; }
  .sticky-cta { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
