:root {
  --paper: #fbf6ec;
  --ink: #3b2918;
  --brick: #b5523a;
  --bamboo: #2d6a4f;
  --gold: #e6b15a;
  --earth: #8a5a32;
  --card: #fffaf3;
  --line: #eadcc4;
  --read-scale: 1;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

body { min-height: 100vh; }

button, a { font: inherit; }

button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  background: var(--earth);
  color: white;
  cursor: pointer;
}

button:focus-visible, a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

button[disabled] { opacity: 0.45; cursor: default; }

.shell { width: min(1100px, calc(100% - 1.5rem)); margin: 0 auto; padding: 1rem 0 2.5rem; }

.mast {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}

h1, h2 { line-height: 1.2; margin: 0; }

h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); letter-spacing: 0.02em; }

.lede { margin: 0.35rem 0 0; max-width: 40rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  min-height: 100%;
}

.card .thumb {
  aspect-ratio: 4 / 3;
  background: #efe2c9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card img { width: 100%; height: 100%; object-fit: contain; }

.card .meta { padding: 0.8rem 0.9rem 1rem; }

.card h2 { font-size: 1.35rem; }

.row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }

.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.heart.on { background: var(--brick); }

.reader-bar, .pager, .tools { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }

.reader-bar { margin-bottom: 0.7rem; }

.frame {
  background: #efe2c9;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.frame img {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #efe2c9;
}

.story-text {
  margin-top: 0.8rem;
  padding: 0.9rem 1rem 1rem;
  border-radius: 16px;
  background: rgba(255, 250, 243, 0.94);
  border: 1px solid var(--line);
}

.narration {
  margin: 0;
  font-size: calc(1.28rem * var(--read-scale));
  line-height: 1.55;
}

.page-no { font-weight: 700; color: var(--earth); }

.status {
  min-height: 1.4rem;
  margin: 0.35rem 0 0;
}

.status.warn { color: #8a2e22; font-weight: 700; }

.talk h2 { margin-bottom: 0.6rem; }

.talk li { margin: 0.4rem 0; }

.note { font-size: 0.95rem; }

.hidden { display: none; }

@media (max-width: 800px) and (orientation: portrait) {
  .frame img { max-height: 46vh; }
  .narration { font-size: calc(1.2rem * var(--read-scale)); }
  .mast { display: block; }
}
