.read-page {
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  background: #0b0e0c;
  height: 100dvh;
  height: 100vh;
  overflow: hidden;
}
.read-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---- book list ---- */
.book-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 20px 48px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
.book-list-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.book-list-head .kicker {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #8fd4b8;
  font-weight: 700;
}
.book-list-head h1 {
  margin: 0;
  color: #f3f6f3;
  font-size: 24px;
}
.btn-primary {
  appearance: none;
  border: 0;
  background: #2bd39a;
  color: #08251c;
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.book-list-empty {
  color: #9aa39c;
  font-size: 14px;
  padding: 40px 4px;
}
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.book-card {
  background: #12161a;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.book-open {
  appearance: none;
  border: 0;
  background: transparent;
  color: #f3f6f3;
  text-align: left;
  padding: 16px 14px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.book-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.book-meta {
  font-size: 12px;
  color: #8b948e;
}
.book-edit {
  appearance: none;
  border: 0;
  border-top: 1px solid rgba(255,255,255,.08);
  background: transparent;
  color: #8fd4b8;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
}

/* ---- reader ---- */
.reader-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}
.reader {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.reader-empty {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9aa39c;
  font-size: 14px;
}
.reader-card {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  height: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 30px;
  box-sizing: border-box;
  position: relative;
}
.reader-card p {
  font-size: clamp(22px, 5vw, 34px);
  line-height: 1.55;
  font-weight: 700;
  color: #f3f6f3;
  text-align: center;
  white-space: pre-wrap;
  max-width: 640px;
  margin: 0;
  letter-spacing: -.01em;
}
.reader-card.tone-a { background: radial-gradient(120% 90% at 26% 0%, rgba(15,138,102,.38), transparent 62%), #0b0e0c; }
.reader-card.tone-b { background: radial-gradient(120% 90% at 26% 0%, rgba(212,137,26,.34), transparent 62%), #0b0e0c; }
.reader-card.tone-c { background: radial-gradient(120% 90% at 26% 0%, rgba(30,111,179,.34), transparent 62%), #0b0e0c; }

.back-btn {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  z-index: 6;
  appearance: none;
  border: 0;
  background: rgba(11,14,12,.55);
  backdrop-filter: blur(6px);
  color: #f3f6f3;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.reader-progress {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  gap: 4px;
  padding: 0 16px 0 90px;
  pointer-events: none;
  z-index: 5;
}
.reader-progress i {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,.18);
  overflow: hidden;
}
.reader-progress i.done { background: rgba(255,255,255,.85); }

.reader-count {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255,255,255,.45);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  pointer-events: none;
  z-index: 5;
}
.reader-hint {
  position: absolute;
  bottom: 36px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255,255,255,.4);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  animation: reader-bob 1.6s ease-in-out infinite;
}
@keyframes reader-bob {
  0%, 100% { transform: translateY(0); opacity: .35; }
  50% { transform: translateY(6px); opacity: .75; }
}

/* ---- editor ---- */
.book-editor {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 20px 48px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
.editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.back-btn-inline {
  appearance: none;
  border: 0;
  background: rgba(255,255,255,.08);
  color: #f3f6f3;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.editor-head h1 {
  margin: 0;
  color: #f3f6f3;
  font-size: 20px;
}
.field-label {
  display: block;
  margin: 16px 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: #9aa39c;
}
.field-label .dim { font-weight: 500; opacity: .8; }
.json-input {
  width: 100%;
  box-sizing: border-box;
  background: #0b0e0c;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #d7e0da;
  resize: vertical;
  min-height: 220px;
}
.json-input:focus {
  outline: 2px solid #2bd39a;
  outline-offset: 1px;
}
.editor-error {
  color: #ff9a8a;
  font-size: 13px;
  font-weight: 700;
  min-height: 1.4em;
  margin: 10px 0 0;
}
.editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.btn-ghost {
  appearance: none;
  border: 1px solid rgba(255,255,255,.14);
  background: transparent;
  color: #d7e0da;
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

/* ---- dev panel (kotlin code) ---- */
.dev-panel { padding: 16px 16px 0; }
.kt-code {
  background: #12161a;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  color: #e7ece8;
}
.kt-code-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  -webkit-tap-highlight-color: transparent;
}
.kt-code-summary::-webkit-details-marker { display: none; }
.kt-code-summary .kicker {
  margin: 0;
  color: #8fd4b8;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 700;
}
.kt-code-summary .summary-title {
  font-size: 13px;
  font-weight: 700;
  color: #b7c0ba;
}
.kt-code-summary .summary-title::after {
  content: "▾";
  margin-left: 6px;
  display: inline-block;
  transition: transform .15s ease;
}
.kt-code[open] .kt-code-summary .summary-title::after { transform: rotate(180deg); }
.kt-code-body { padding: 0 18px 18px; }
.kt-code-body .muted { color: #9aa39c; font-size: 13px; margin: 0 0 12px; }
.kt-code-body .muted code {
  background: rgba(255,255,255,.08);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.kt-code-block {
  margin: 0 0 12px;
  padding: 16px;
  background: #0b0e0c;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
  color: #d7e0da;
  white-space: pre;
  overflow: auto;
  max-height: 420px;
  user-select: all;
}
.kt-code .copy-all-btn {
  display: block;
  width: 100%;
  text-align: center;
  appearance: none;
  border: 0;
  background: #0f6e56;
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.kt-code .copy-all-btn.ok { background: #2bd39a; color: #08251c; }

@media (max-width: 640px) {
  .read-page .site-header,
  .read-page .site-footer { display: none; }
}
