:root {
  --bg: #141210;
  --bar: var(--bg);
  --ink: #f1ece4;
  --muted: #8f877c;
  --line: #2a2622;
  --card: #24211d;
  --accent: #f2b33d;
  --accent-ink: #1b1917;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.3 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.bar {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bar);
}
.bar h1 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.bar .sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar .back { font-size: 15px; color: var(--accent); }

/* Grid */
.scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  padding: 12px 12px 24px;
}
.grid a { display: block; }
.grid .thumb {
  aspect-ratio: 3 / 4;
  background: var(--card);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
}
.grid img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.grid .cap {
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.grid a.last .thumb { box-shadow: 0 0 0 2px var(--accent); }
.grid a.last .cap { color: var(--accent); font-weight: 600; }

/* Reader */
.reader .bar {
  align-items: center;
  padding: 6px 10px;
  background: var(--bar);
  border-bottom: 0;
}
.reader .bar h1 { font-size: 14px; font-weight: 600; flex: 1; text-align: center; }
.reader .bar .sub { font-size: 11px; min-width: 52px; text-align: right; }
.reader .bar .back {
  min-width: 52px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}
.stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
}
.tap { position: absolute; top: 0; bottom: 0; }
.tap.prev { left: 0; width: 30%; }
.tap.next { right: 0; width: 70%; }
.nav {
  flex: none;
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bar);
}
.nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
.nav a { flex: 1; background: var(--card); color: var(--ink); }
.nav a:active { filter: brightness(.85); }
.nav a.off { visibility: hidden; }
