:root {
  --bg: #0b0b0b;
  --surface: #17171a;
  --surface-2: #1f1f24;
  --text: #f2f1ec;
  --text-muted: #9a988f;
  --accent: #b58a4a;
  --border: #2b2b30;
  --radius: 10px;
  --font: -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overscroll-behavior-y: contain;
}

#app { display: flex; flex-direction: column; height: 100vh; max-width: 480px; margin: 0 auto; }

#toolbar, #bottom-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#bottom-bar { border-top: 1px solid var(--border); border-bottom: none; }
.toolbar-actions { display: flex; gap: 12px; }

button {
  background: none; border: none; color: var(--text); font-size: 18px;
  cursor: pointer; padding: 6px;
}
button:hover { color: var(--accent); }
button:disabled { opacity: .35; cursor: default; }
button:disabled:hover { color: var(--text); }
.home-link { color: var(--accent); text-decoration: none; font-size: 18px; padding: 6px; line-height: 1; }
.home-link:hover { opacity: .8; }

.chip-row { display: flex; gap: 6px; padding: 8px 14px; flex-wrap: wrap; }
.chip {
  font-size: 11px; padding: 4px 10px; border-radius: 12px;
  border: 1px solid var(--border); color: var(--text-muted); cursor: pointer;
}
.chip.active { background: var(--accent); color: #241a0c; border-color: var(--accent); }

#reading-pane { flex: 1; overflow-y: auto; position: relative; background: #000; }
.page-wrap { position: relative; width: 100%; aspect-ratio: 3 / 4.2; }
.page-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* Color ↔ B&W: same generated art, drained of color (a reader-side view). */
#reading-pane.bw .page-wrap img { filter: grayscale(1) contrast(1.05); }

.bubble {
  position: absolute; background: rgba(20,20,22,0.92); border: 1px solid var(--border);
  border-radius: 14px; padding: 6px 10px; font-size: 13px; line-height: 1.4;
  max-width: 70%;
}
.bubble.thought { border-style: dashed; }
.bubble.narration { border-radius: 4px; background: rgba(0,0,0,0.85); font-style: italic; }

#progress-bar { height: 3px; background: var(--surface-2); flex-shrink: 0; }
#progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width .2s; }

#toc-panel {
  position: absolute; inset: 0; background: var(--bg); overflow-y: auto; padding: 16px; z-index: 10;
}
#toc-panel.hidden { display: none; }
.toc-series h2 { font-size: 15px; margin: 18px 0 6px; }
.toc-chapter {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 8px; cursor: pointer;
}
.toc-chapter:hover { border-color: var(--accent); }

#page-indicator { font-size: 12px; color: var(--text-muted); }
