/* ── RESET & BASE ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:   #22c55e;
  --green-d: #16a34a;
  --blue:    #3b82f6;
  --blue-d:  #2563eb;
  --amber:   #f59e0b;
  --red:     #ef4444;
  --gray-50: #f9fafb;
  --gray-100:#f3f4f6;
  --gray-200:#e5e7eb;
  --gray-400:#9ca3af;
  --gray-600:#4b5563;
  --gray-800:#1f2937;
  --white:   #ffffff;
  --radius:  12px;
  --shadow:  0 2px 12px rgba(0,0,0,0.08);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input, select, textarea {
  font-family: inherit;
}

/* ── SCREENS ─────────────────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ── NAV ─────────────────────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(160deg, #ecfdf5 0%, #eff6ff 100%);
  border-bottom: 2px solid #22c55e;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: -0.5px;
}

.nav-logo span { color: var(--blue); }

.nav-actions { display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.15s;
  min-height: 44px;
}

.btn-primary {
  background: var(--green);
  color: var(--white);
}
.btn-primary:hover { background: var(--green-d); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-800);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-outline {
  border: 2px solid var(--green);
  color: var(--green);
  background: transparent;
}
.btn-outline:hover { background: var(--green); color: var(--white); }

.btn-sm { padding: 7px 14px; font-size: 13px; min-height: 36px; }

.btn-full { width: 100%; }

/* ── HERO ─────────────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(160deg, #ecfdf5 0%, #eff6ff 100%);
  padding: 72px 20px 36px;
  text-align: center;
  flex: 1;
}

.hero h1 {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  line-height: 1.2;
  color: var(--blue-d);
  margin-bottom: 12px;
}

.hero h1 em {
  font-style: normal;
  color: var(--green);
}

.hero p {
  font-size: 17px;
  color: var(--gray-600);
  max-width: 480px;
  margin: 0 auto 28px;
  line-height: 1.6;
}

.hero-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ── HERO BOOK ANIMATION ─────────────────────────────────────────────────── */
.hero-book-wrap {
  perspective: 1100px;
  margin: 0 auto 52px;
  width: 170px;
  height: 218px;
}

.hero-book {
  width: 170px;
  height: 218px;
  position: relative;
  transform-style: preserve-3d;
}

.hero-book-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #15803d, #166534);
  border-radius: 5px 12px 12px 5px;
  box-shadow: -5px 5px 20px rgba(0,0,0,0.25);
}

.hero-book-pages {
  position: absolute;
  top: 5px;
  left: 8px;
  right: 5px;
  bottom: 5px;
  background: #fffdf5;
  border-radius: 2px 8px 8px 2px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  justify-content: center;
}

.hero-page-text {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 12px;
  font-weight: 700;
  color: #4b5563;
  line-height: 1.4;
  text-align: center;
}

.hero-book-cover {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #22c55e 0%, #3b82f6 100%);
  border-radius: 5px 12px 12px 5px;
  transform-origin: left center;
  animation: hero-book-flip 8s cubic-bezier(0.4,0,0.2,1) 0.8s infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 3px 5px 24px rgba(34,197,94,0.35);
  backface-visibility: hidden;
  transform: rotateY(-15deg);
}

.hero-book-title {
  font-size: 26px;
  font-weight: 900;
  color: white;
  letter-spacing: 3px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

@keyframes hero-book-flip {
  0%   { transform: rotateY(-15deg); }
  28%  { transform: rotateY(-82deg); }
  65%  { transform: rotateY(-82deg); }
  100% { transform: rotateY(-22deg); }
}

/* ── SECTION ─────────────────────────────────────────────────────────────── */
.section {
  padding: 32px 20px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-800);
}

/* ── BOOK GRID ───────────────────────────────────────────────────────────── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
}

.book-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.12);
}

.book-cover {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: linear-gradient(135deg, #dbeafe, #bbf7d0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}

.book-cover img { width: 100%; height: 100%; object-fit: cover; }

.book-cover-alpha {
  background: linear-gradient(135deg, #f0fdf4, #eff6ff);
}

.book-cover-phonics {
  background: linear-gradient(135deg, #eef2ff, #ede9fe);
}
.book-cover-digraph {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
}
.book-cover-blend {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
}
.book-cover-story {
  background: linear-gradient(135deg, #fdf4ff, #fce7f3);
}

/* ── SECTION HEADERS ────────────────────────────────────────────────────── */
.browse-section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px 6px; margin-top: 4px;
}
.browse-section-title { font-size: 16px; font-weight: 700; color: #1f2937; }
.browse-section-count { font-size: 13px; color: #9ca3af; }
.shelf-section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 4px 8px;
}

/* ── COLLECTION GROUP (browse) ───────────────────────────────────────────── */
.collection-group {
  border-radius: 16px;
  border: 2px solid;
  overflow: hidden;
  margin-bottom: 8px;
}
.collection-group-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; cursor: pointer;
}
.collection-group-label { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: rgba(255,255,255,0.8); margin-bottom: 2px; }
.collection-group-title { font-size: 18px; font-weight: 800; color: white; }
.collection-add-btn {
  background: rgba(255,255,255,0.25); color: white;
  border: 2px solid rgba(255,255,255,0.6); border-radius: 20px;
  padding: 8px 16px; font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background 0.15s;
}
.collection-add-btn:hover { background: rgba(255,255,255,0.4); }
.collection-group-body {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  background: white;
}

/* ── COLLECTION CARD (browse) ────────────────────────────────────────────── */
.collection-card {
  background: white;
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border: 1px solid #f3f4f6;
  transition: transform 0.15s;
  grid-column: 1 / -1;
  margin-bottom: 4px;
}
.collection-card:active { transform: scale(0.98); }
.collection-series { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: #6b7280; margin-bottom: 4px; }
.collection-title { font-size: 18px; font-weight: 800; color: #1f2937; margin-bottom: 12px; }
.collection-preview { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.mini-cov { width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 12px; flex-shrink: 0; }
.collection-footer { display: flex; align-items: center; justify-content: space-between; }

/* ── COLLECTION BOX (my books) ───────────────────────────────────────────── */
.collection-box {
  background: white;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border: 1px solid #f3f4f6;
}
.collection-box-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.collection-box-title { font-size: 15px; font-weight: 700; color: #1f2937; }
.collection-box-count { font-size: 12px; color: #9ca3af; }
.collection-mini-grid { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-book {
  width: 44px; height: 44px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-weight: 900; font-size: 11px; flex-shrink: 0;
  transition: transform 0.1s;
}
.mini-book:active { transform: scale(0.88); }

/* ── SINGLES GRID (3-per-row, my books) ──────────────────────────────────── */
.singles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.rental-sm {
  background: white; border-radius: 12px; padding: 10px 8px 12px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border: 1px solid #f3f4f6;
}
.rental-sm-cover {
  width: 56px; height: 56px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px; overflow: hidden; font-size: 28px;
}
.rental-sm-cover img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.rental-sm-title { font-size: 11px; font-weight: 600; color: #1f2937; line-height: 1.3; }

.book-info { padding: 5px 8px 6px; }

.book-card-sm { max-width: 130px; }

.book-title {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author {
  font-size: 10px;
  color: var(--gray-600);
  margin-bottom: 3px;
}

.book-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--green-d);
}

.book-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--green);
  color: var(--white);
  margin-bottom: 4px;
}

.book-badge.free { background: var(--blue); }

/* ── GENRE CHIPS ─────────────────────────────────────────────────────────── */
.genre-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
  scrollbar-width: none;
}
.genre-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
  border: 2px solid transparent;
  min-height: 36px;
}

.chip.active {
  background: var(--green);
  color: var(--white);
  border-color: var(--green);
}

/* ── BOOK DETAIL MODAL ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 40px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal-book-header {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.modal-cover {
  width: 90px;
  height: 135px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: linear-gradient(135deg, #dbeafe, #bbf7d0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  overflow: hidden;
}

.modal-cover img { width: 100%; height: 100%; object-fit: cover; }

.modal-meta { flex: 1; }

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.3;
}

.modal-author {
  font-size: 14px;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.modal-price-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.modal-price {
  font-size: 20px;
  font-weight: 800;
  color: var(--green-d);
}

.modal-duration {
  font-size: 13px;
  color: var(--gray-600);
}

.modal-desc {
  font-size: 15px;
  color: var(--gray-600);
  line-height: 1.6;
  margin-bottom: 20px;
}

.modal-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tag {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-600);
}

/* ── AUTH ────────────────────────────────────────────────────────────────── */
.auth-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.auth-card {
  background: var(--white);
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}

.auth-logo {
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  color: var(--green);
  margin-bottom: 8px;
}

.auth-logo span { color: var(--blue); }

.auth-subtitle {
  text-align: center;
  color: var(--gray-600);
  font-size: 15px;
  margin-bottom: 28px;
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-800);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.15s;
  background: var(--white);
}

.form-input:focus {
  outline: none;
  border-color: var(--green);
}

.auth-divider {
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
  margin: 16px 0;
  position: relative;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 20px);
  height: 1px;
  background: var(--gray-200);
}

.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color 0.15s, background 0.15s;
  min-height: 48px;
}

.btn-google:hover { border-color: var(--blue); background: #eff6ff; }

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--gray-600);
}

.auth-switch a {
  color: var(--green-d);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

/* ── READER ──────────────────────────────────────────────────────────────── */
.reader-screen {
  background: #faf8f4;
}

.reader-screen.active {
  display: grid;
  grid-template-rows: auto 3px 1fr;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.reader-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  background: rgba(250,245,232,0.72);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border-bottom: 1px solid rgba(210,185,120,0.25);
  color: var(--gray-800);
}

.reader-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  text-align: center;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 10px;
}

.reader-btn {
  color: var(--gray-800);
  padding: 6px;
  border-radius: 8px;
  font-size: 18px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.06);
  transition: background 0.15s;
}

.reader-btn:hover { background: rgba(0,0,0,0.12); }

.reader-body {
  position: relative;
  overflow: hidden;
  min-height: 0;
  padding: 0;
}

#epub-viewer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--white);
}

#epub-viewer iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.reader-footer {
  padding: 6px 16px;
  background: rgba(250,245,232,0.72);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border-top: 1px solid rgba(210,185,120,0.25);
  display: flex;
  align-items: center;
  gap: 12px;
}

.reader-progress {
  flex: 1;
  height: 3px;
  background: rgba(0,0,0,0.12);
  border-radius: 2px;
  overflow: hidden;
}

.reader-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.3s;
}

.reader-page-info {
  font-size: 11px;
  font-weight: 500;
  color: rgba(0,0,0,0.45);
  white-space: nowrap;
}

/* ── PROFILE SCREEN ──────────────────────────────────────────────────────── */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  padding: 24px 20px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.profile-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
  border: 3px solid transparent;
}

.profile-card:hover { transform: scale(1.04); }
.profile-card.selected { border-color: var(--green); }

.profile-avatar {
  font-size: 44px;
  margin-bottom: 8px;
}

.profile-name {
  font-size: 15px;
  font-weight: 600;
}

.add-profile-card {
  background: var(--gray-100);
  border: 3px dashed var(--gray-200);
  color: var(--gray-600);
}

/* ── DASHBOARD ───────────────────────────────────────────────────────────── */
.shelf-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}

.shelf-empty-icon { font-size: 48px; margin-bottom: 12px; }

.rental-card {
  display: flex;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  cursor: pointer;
  align-items: center;
  transition: box-shadow 0.15s;
}

.rental-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.12); }

.rental-cover {
  width: 56px;
  height: 84px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: linear-gradient(135deg, #dbeafe, #bbf7d0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  overflow: hidden;
}

.rental-cover img { width: 100%; height: 100%; object-fit: cover; }

.rental-info { flex: 1; }

.rental-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.3;
}

.rental-author {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.rental-expires {
  font-size: 12px;
  color: var(--amber);
  font-weight: 600;
}

.rental-expires.ok { color: var(--green-d); }

.rental-progress-bar {
  height: 4px;
  background: var(--gray-100);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.rental-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
}

/* ── LOADING ─────────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--gray-400);
  font-size: 15px;
  gap: 10px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--gray-800);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  transition: transform 0.25s ease;
  white-space: nowrap;
  max-width: 90vw;
  text-overflow: ellipsis;
  overflow: hidden;
}

#toast.show { transform: translateX(-50%) translateY(0); }

/* ── ADD CHILD MODAL ─────────────────────────────────────────────────────── */
.child-form { padding: 0; }

.avatar-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.avatar-option {
  font-size: 28px;
  padding: 6px;
  border-radius: 8px;
  border: 3px solid transparent;
  cursor: pointer;
  line-height: 1;
}

.avatar-option.selected { border-color: var(--green); }

/* ── DOWNLOAD BUTTON ─────────────────────────────────────────────────────── */
.dl-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 14px;
  background: var(--gray-100);
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  margin-top: 1px;
  position: relative;
  overflow: hidden;
}
.dl-btn:hover { background: var(--gray-200); }
.dl-btn.dl-done { cursor: default; }
.dl-btn.dl-done .dl-icon { color: white; }
.dl-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 0%;
  background: var(--green);
  border-radius: inherit;
  transition: height 0.85s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}
.dl-icon { position: relative; z-index: 1; pointer-events: none; }

/* ── REMOVE BUTTON ───────────────────────────────────────────────────────── */
.rm-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--gray-100);
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  margin-top: 1px;
  transition: background 0.15s, color 0.15s;
}
.rm-btn:hover { background: #fee2e2; color: var(--red); }

/* ── SERIES BADGE ────────────────────────────────────────────────────────── */
.series-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--blue);
  letter-spacing: 0.5px;
  margin-bottom: 1px;
}

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .hero { padding: 32px 16px 28px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .section { padding: 24px 16px; }
}

@media (min-width: 768px) {
  .modal { border-radius: 16px; margin: auto; }
  .modal-overlay { align-items: center; }
}

/* ── PWA INSTALL BANNER ──────────────────────────────────────────────────── */
.install-banner {
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: var(--white);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.install-text { font-size: 14px; font-weight: 500; }
.install-text strong { display: block; font-size: 15px; margin-bottom: 2px; }

.install-close {
  color: rgba(255,255,255,0.7);
  font-size: 20px;
  padding: 4px;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── CELEBRATION ─────────────────────────────────────────────────────────── */
#celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cel-fadein 0.4s ease;
}
@keyframes cel-fadein { from { opacity:0 } to { opacity:1 } }

.celebration-card {
  background: white;
  border-radius: 24px;
  padding: 40px 32px 32px;
  text-align: center;
  max-width: 320px;
  width: 88%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: cel-pop 0.45s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
  z-index: 1;
}
@keyframes cel-pop { from { transform:scale(0.6); opacity:0 } to { transform:scale(1); opacity:1 } }

.celebration-emoji { font-size: 72px; line-height: 1; margin-bottom: 12px; }
.celebration-title { font-size: 26px; font-weight: 800; color: #1f2937; margin-bottom: 8px; }
.celebration-book  { font-size: 15px; color: #6b7280; margin-bottom: 28px; font-style: italic; }
.celebration-btn {
  background: linear-gradient(135deg, #22c55e, #3b82f6);
  color: white;
  font-size: 18px;
  font-weight: 700;
  padding: 14px 40px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(34,197,94,0.4);
}

.confetti-piece {
  position: fixed;
  top: -20px;
  font-size: 20px;
  animation: confetti-fall linear forwards;
  z-index: 9001;
  pointer-events: none;
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity:1 }
  80%  { opacity:1 }
  100% { transform: translateY(110vh) rotate(720deg); opacity:0 }
}

/* ── TAMIL KEYBOARD ──────────────────────────────────────────────────────── */
#tamil-kbd {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 800;
  background: #f1f3f5;
  border-top: 1px solid #d1d5db;
  padding: 10px 8px 18px;
  transform: translateY(100%);
  transition: transform 0.22s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
}
#tamil-kbd.open { transform: translateY(0); }
.tkbd-row { display: flex; gap: 5px; margin-bottom: 5px; justify-content: center; }
.tkbd-key {
  flex: 1;
  max-width: 56px;
  min-width: 0;
  height: 44px;
  background: #fff;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-family: 'Tamil Sangam MN','Noto Sans Tamil','Latha',Georgia,serif;
  color: #1f2937;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.tkbd-key:active { background: #e5e7eb; transform: scale(0.94); }
.tkbd-key.tkbd-sign { background: #dbeafe; color: #1d4ed8; font-size: 16px; }
.tkbd-key.tkbd-action { background: #e5e7eb; font-size: 14px; font-family: -apple-system,sans-serif; font-weight: 700; color: #374151; }
.tkbd-key.tkbd-space { max-width: 160px; flex: 3; font-size: 13px; font-family: -apple-system,sans-serif; color: #6b7280; }
.tkbd-key.tkbd-done { background: #22c55e; color: white; max-width: 90px; flex: 2; font-size: 13px; font-family: -apple-system,sans-serif; font-weight: 800; }
