:root {
  color-scheme: light;
  --green-dark: #1b5e20;
  --green: #2e7d32;
  --green-light: #4caf50;
  --gold: #d7aa38;
  --cream: #fff8e1;
  --sepia: #f4ecd8;
  --paper: #fffdf8;
  --ink: #172018;
  --muted: #68736a;
  --line: #e0ded3;
  --surface: #ffffff;
  --shadow: 0 10px 28px rgba(27, 94, 32, .12);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: #fafafa;
}
button, input, textarea, select {
  font: inherit;
}
button {
  border: 0;
  border-radius: 8px;
  background: var(--green-dark);
  color: white;
  padding: 10px 13px;
}
button.link {
  background: transparent;
  color: var(--green-dark);
  padding: 4px;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
}
.hidden { display: none !important; }
.splash {
  min-height: 100vh;
  display: grid;
  place-content: center;
  text-align: center;
  background: var(--green-dark);
  color: white;
  gap: 16px;
}
.ornament {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  margin: 0 auto;
  border: 1px solid rgba(255, 215, 0, .45);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-size: 54px;
  animation: spinIn 2.5s ease both;
}
.splash h1 { margin: 0; }
.splash p { color: var(--gold); margin: 0; font-size: 22px; }
@keyframes spinIn {
  from { transform: rotate(-90deg) scale(.8); opacity: 0; }
  to { transform: rotate(0) scale(1); opacity: 1; }
}

.app {
  min-height: 100vh;
  padding-bottom: 88px;
}
.hero {
  position: sticky;
  top: 0;
  z-index: 3;
  background:
    radial-gradient(circle at 20% 0, rgba(255, 215, 0, .18), transparent 34%),
    linear-gradient(160deg, #103e18, var(--green-dark));
  color: white;
  padding: max(22px, env(safe-area-inset-top)) 18px 18px;
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  box-shadow: var(--shadow);
}
.hero p {
  margin: 0;
  color: var(--gold);
  font-size: 18px;
}
.hero h1 {
  margin: 6px 0 18px;
  font-size: clamp(25px, 7vw, 36px);
}
.search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.search input {
  background: rgba(255, 255, 255, .96);
}
.view {
  display: none;
  padding: 20px 16px;
  animation: fadeUp .22s ease;
}
.view.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.section { margin-bottom: 24px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section h2, .view h2 {
  margin: 0 0 12px;
  font-size: 22px;
}
.featured {
  min-height: 180px;
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.featured .cover { width: 110px; height: 155px; }
.cover {
  background: linear-gradient(145deg, #d9d0ad, #7c5e24);
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .18);
}
.book-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 138px;
  gap: 14px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  scroll-snap-type: x mandatory;
}
.book-card {
  scroll-snap-align: start;
}
.book-card .cover {
  width: 120px;
  height: 160px;
  display: block;
  margin-bottom: 9px;
}
.book-card strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}
.book-card span {
  color: var(--muted);
  font-size: 12px;
}
.chips {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.chip {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--cream);
  color: var(--green-dark);
  border: 1px solid #eadcad;
  padding: 9px 13px;
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.category-card {
  border-radius: 8px;
  color: white;
  padding: 16px;
  min-height: 120px;
  display: grid;
  align-content: space-between;
}
.category-card strong {
  font-size: 18px;
}
.book-list {
  display: grid;
  gap: 12px;
}
.book-list-item {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
.book-list-item .cover {
  width: 70px;
  height: 96px;
}
.book-list-item h3 {
  margin: 0 0 4px;
  font-size: 17px;
}
.book-list-item p {
  color: var(--muted);
  margin: 0 0 8px;
  font-size: 13px;
}
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 14px;
  background: white;
}
.segmented button {
  background: transparent;
  color: var(--green-dark);
}
.segmented button.active {
  background: var(--green-dark);
  color: white;
}
.support-form, .profile-card {
  display: grid;
  gap: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.profile-card { margin-bottom: 14px; }
.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.profile-stats div {
  background: var(--cream);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--line);
  z-index: 4;
}
.bottom-nav button {
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 8px 2px;
}
.bottom-nav button.active {
  color: var(--green-dark);
  font-weight: 700;
}
.sheet {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: rgba(0, 0, 0, .45);
  display: grid;
  align-items: end;
}
.sheet-card {
  max-height: 88vh;
  overflow: auto;
  background: white;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 18px;
}
.icon-btn {
  float: right;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: #eef2ed;
  color: var(--ink);
}
.detail {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  margin-top: 22px;
}
.detail .cover {
  width: 120px;
  height: 170px;
}
.detail h2 { margin: 0 0 6px; }
.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.reader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #111;
}
.reader.theme-light { background: #f7f7f7; }
.reader.theme-sepia { background: var(--sepia); }
.reader.theme-dark { background: #111; }
.reader header, .reader footer {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 10px;
  background: rgba(10, 10, 10, .86);
  color: white;
}
.reader header span {
  display: block;
  color: #c8c8c8;
  font-size: 12px;
}
.reader iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}
.reader.bars-hidden header,
.reader.bars-hidden footer {
  display: none;
}
.snackbar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 86px;
  z-index: 12;
  background: #172018;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.shimmer:empty::before {
  content: "";
  display: block;
  height: 160px;
  width: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #eee 0%, #f8f8f8 45%, #eee 100%);
  animation: shimmer 1.1s infinite linear;
}
@keyframes shimmer {
  from { opacity: .55; }
  to { opacity: 1; }
}
@media (min-width: 760px) {
  .app {
    max-width: 900px;
    margin: 0 auto;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
  .bottom-nav {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(900px, 100vw);
  }
}
