/* Same-origin storefront fallback. No third-party URLs. Tokens + chrome so
   Android Chrome still has layout if the hashed Next CSS is delayed or dropped. */
:root {
  --bg-page: #F4F1EA;
  --bg-card: #FFFFFF;
  --bg-card-soft: #F5F2EB;
  --bg-inverse: #20242E;
  --bg-reader: #EFE9DB;
  --text-primary: #1C1A17;
  --text-secondary: #4A453E;
  --text-muted: #6E675D;
  --text-on-inverse: #EDE8E0;
  --gold: #9C7A3C;
  --gold-bright: #C9A24B;
  --gold-contrast: #FFFFFF;
  --gold-dim: rgba(156, 122, 60, 0.14);
  --border-card: rgba(156, 122, 60, 0.28);
  --border-soft: rgba(28, 26, 23, 0.10);
  --shadow-card: 0 2px 10px rgba(28, 26, 23, 0.08);
  --shadow-pop: 0 8px 28px rgba(28, 26, 23, 0.14);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --background: var(--bg-page);
  --foreground: var(--text-primary);
  --on-gold: var(--gold-contrast);
  --bg-base: var(--bg-page);
  --border: var(--border-card);
}

[data-theme="dark"],
.dark {
  --bg-page: #161A22;
  --bg-card: #1F242E;
  --bg-card-soft: #242A36;
  --bg-inverse: #10131A;
  --bg-reader: #1E1C19;
  --text-primary: #E2DCCF;
  --text-secondary: #B7B0A3;
  --text-muted: #8E887C;
  --text-on-inverse: #E2DCCF;
  --gold: #C9A24B;
  --gold-bright: #D8B25A;
  --gold-contrast: #1A1408;
  --gold-dim: rgba(201, 162, 75, 0.22);
  --border-card: rgba(201, 162, 75, 0.30);
  --border-soft: rgba(226, 220, 207, 0.10);
  --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 8px 28px rgba(0, 0, 0, 0.5);
  --background: var(--bg-page);
  --foreground: var(--text-primary);
  --on-gold: var(--gold-contrast);
  --bg-base: var(--bg-page);
  --border: var(--border-card);
}

html {
  background: var(--bg-page);
  color: var(--text-primary);
}

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, "Segoe UI", sans-serif;
}

/* Native window scroll: hashed Next CSS may arrive late on Android.
   Mobile browsers only auto-hide URL / toolbar chrome when the window scrolls. */
html,
body,
#__next,
.app-shell,
.reader-surface {
  height: auto;
  max-height: none;
  overflow: visible;
}

img {
  max-width: 100%;
  height: auto;
}

.site-header {
  background: var(--bg-inverse);
  color: var(--text-on-inverse);
  border-bottom: 1px solid var(--border-soft);
}

.site-header-link {
  color: var(--text-on-inverse);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--gold-bright);
  color: var(--gold-contrast);
  font-weight: 700;
  border: 0;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--gold);
  font-weight: 700;
}

.card-surface {
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
}

.book-cover-frame {
  display: block;
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  background: var(--bg-inverse);
}

.book-cover-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center top;
}

.reader-surface {
  background-color: var(--bg-reader);
  color: var(--text-primary);
}

/* Layered so Tailwind utilities still win once the hashed sheet arrives. */
@layer base {
  :where(a, a:link, a:visited, a:hover, a:active) {
    color: inherit;
    text-decoration: none;
  }
}
