/* Share link viewer. Paper stays opaque and warm; chrome stays quiet. */

:root {
  --bg: #f4eee4;
  --surface: #fffaf2;
  --text: #2a241d;
  --muted: #6f6558;
  --line: #e2d8c8;
  --accent: #b5542f;
  --accent-text: #ffffff;
  --shadow: 0 1px 2px rgb(60 40 20 / 0.12), 0 8px 24px rgb(60 40 20 / 0.14);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a17;
    --surface: #282520;
    --text: #f2ece3;
    --muted: #b3a896;
    --line: #3a352e;
    --accent: #e0835c;
    --accent-text: #1c1a17;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 28px rgb(0 0 0 / 0.45);
  }
}

@media (prefers-contrast: more) {
  :root { --muted: var(--text); --line: var(--text); }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
}

.brand {
  font: 700 15px/1 ui-rounded, -apple-system, system-ui, sans-serif;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-decoration: none;
  flex-shrink: 0;
}

.titles { min-width: 0; }

h1 {
  margin: 0;
  font: 600 1.35rem/1.2 ui-serif, "New York", Georgia, serif;
  overflow-wrap: anywhere;
}

h2 { margin: 0 0 8px; font-size: 1.2rem; }

.meta { margin: 2px 0 0; color: var(--muted); font-size: 0.9rem; }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  outline: none;
}

.status {
  display: grid;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  padding: 48px 16px;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(1turn); } }

.card {
  width: min(420px, calc(100% - 32px));
  margin: 32px auto;
  padding: 24px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.card p { margin: 0 0 16px; color: var(--muted); }

label { display: block; font-weight: 600; margin-bottom: 6px; }

input {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 12px;
}

button {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}

button:disabled { opacity: 0.4; cursor: default; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.error { color: var(--accent) !important; font-weight: 600; }

.book { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }

.pages {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  outline: none;
}

.pages::-webkit-scrollbar { display: none; }

.page {
  flex: 0 0 100%;
  scroll-snap-align: start;
  margin: 0;
  padding: 12px 16px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
}

.page img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 230px);
  width: auto;
  height: auto;
  border-radius: 3px;
  background: #fff;
  box-shadow: var(--shadow);
}

.page figcaption { color: var(--muted); font-size: 0.9rem; text-align: center; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.round { width: 44px; height: 44px; padding: 0; font-size: 1.6rem; line-height: 1; }

.bottom {
  padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.bottom p { margin: 4px 0; }

.links { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; }

.links a { padding: 8px 0; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .pages { scroll-behavior: auto; }
}
