:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --card: #ffffff;
  --text: #1f1b16;
  --muted: #6e655c;
  --line: #e2d7c9;
  --primary: #221810;
  --primary-hover: #000000;
  --soft: #efe6da;
  --danger: #a62424;
  --success: #0f7b45;
  --shadow: 0 24px 70px rgba(52, 35, 21, 0.16);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(255,255,255,0.95), transparent 32%),
    radial-gradient(circle at 90% 10%, rgba(230,209,181,0.5), transparent 30%),
    var(--bg);
  color: var(--text);
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 16px clamp(18px, 4vw, 48px);
  background: rgba(246, 241, 232, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226, 215, 201, 0.8);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 900;
  letter-spacing: -0.02em;
  font-size: clamp(1rem, 2.5vw, 1.35rem);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: #fff;
  background: var(--primary);
  font-weight: 950;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 800;
}
.site-nav a:hover { color: var(--text); }

.page {
  min-height: calc(100svh - 70px);
  width: 100%;
  display: grid;
  align-items: start;
  padding: clamp(26px, 5vw, 58px) 20px 90px;
}

.hero {
  width: min(1160px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(260px, 430px) minmax(0, 1fr);
  gap: clamp(26px, 5vw, 58px);
  align-items: start;
}

.book-cover-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.book-cover-card img {
  width: 100%;
  display: block;
  border-radius: 21px;
  object-fit: cover;
  min-height: 420px;
  max-height: 650px;
  background: linear-gradient(135deg, #dfd3c4, #ffffff);
}

.book-info {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: clamp(24px, 4vw, 42px);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 45px rgba(52, 35, 21, 0.08);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-weight: 900;
  font-size: 0.75rem;
}

h1, h2 { margin: 0; line-height: 1.06; }
h1 { font-size: clamp(2.25rem, 5.4vw, 4.7rem); letter-spacing: -0.06em; }
h2 { font-size: 1.72rem; letter-spacing: -0.035em; }
.subtitle { margin: 16px 0 0; color: var(--muted); line-height: 1.6; font-size: 1.05rem; }
.description { margin: 26px 0 0; color: #332b24; line-height: 1.78; font-size: 1.05rem; }

.actions { display: flex; align-items: center; gap: 12px; margin: 28px 0 0; flex-wrap: wrap; }
.primary-button, .secondary-button, .google-fallback-button {
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  font-weight: 900;
}
.primary-button { color: white; background: var(--primary); }
.primary-button:hover { background: var(--primary-hover); transform: translateY(-1px); }
.secondary-button { color: var(--text); background: var(--soft); }
.secondary-button:hover { transform: translateY(-1px); }
.google-fallback-button {
  width: 100%;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
}
.google-fallback-button:disabled { cursor: not-allowed; opacity: 0.58; }
.full { width: 100%; }
.secondary-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  background: var(--soft);
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 900;
}

.user-box {
  margin-top: 22px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--soft);
  color: #332b24;
  line-height: 1.55;
}
.status-message, .auth-message, .reader-status { margin-top: 16px; min-height: 24px; color: var(--muted); }
.status-message.error, .auth-message.error, .reader-status.error { color: var(--danger); }
.status-message.success, .auth-message.success, .reader-status.success { color: var(--success); }
.hidden { display: none !important; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(23, 20, 17, 0.58);
  padding: 20px;
  z-index: 20;
  overflow-y: auto;
}
.modal {
  width: min(460px, 100%);
  max-height: calc(100svh - 40px);
  overflow-y: auto;
  background: var(--card);
  border-radius: 30px;
  padding: clamp(20px, 4vw, 28px);
  box-shadow: var(--shadow);
}
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: #f2ece3; padding: 5px; border-radius: 999px; margin-bottom: 18px; }
.tab { border: 0; background: transparent; padding: 11px 12px; border-radius: 999px; cursor: pointer; font-weight: 900; color: var(--muted); }
.tab.active { background: white; color: var(--text); box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08); }
.form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: #332b24; font-weight: 800; font-size: 0.94rem; }
input { border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px; outline: none; background: white; }
input:focus { border-color: var(--primary); }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.google-button { min-height: 44px; display: grid; place-items: center; }
.google-button:empty { display: none; }

.site-footer {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 36px;
  color: var(--muted);
  font-weight: 700;
}

.reader-site-header { position: sticky; }
.reader-page { min-height: calc(100svh - 70px); padding: 28px 20px 60px; }
.reader-title, .reader-status, .iframe-wrapper { max-width: 1180px; margin-left: auto; margin-right: auto; }
.reader-title { margin-bottom: 20px; }
.reader-title h1 { font-size: clamp(1.8rem, 4vw, 3.2rem); }
.reader-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.reader-status { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; }
.iframe-wrapper { height: min(82svh, 900px); min-height: 560px; background: white; border: 1px solid var(--line); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); }
.iframe-wrapper iframe { width: 100%; height: 100%; border: 0; display: block; }

@media (max-width: 860px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  .site-nav { display: none; }
  .hero { grid-template-columns: 1fr; }
  .book-cover-card { max-width: 460px; width: 100%; margin: 0 auto; }
  .book-cover-card img { min-height: 360px; }
  .reader-actions { width: 100%; justify-content: flex-start; }
}

@media (max-width: 520px) {
  .page { padding: 22px 14px 80px; }
  .book-info { border-radius: 24px; }
  .book-cover-card { border-radius: 24px; padding: 12px; }
  .book-cover-card img { min-height: 310px; border-radius: 18px; }
  .actions { align-items: stretch; flex-direction: column; }
  .actions button { width: 100%; }
  .modal-backdrop { align-items: start; padding: 14px; }
  .modal { max-height: none; border-radius: 24px; }
  .reader-page { padding: 22px 14px 50px; }
  .iframe-wrapper { min-height: 72svh; height: 72svh; border-radius: 18px; }
}
