/* =========================================================
   1. COLOR PALETTE  (variables — set the colors in ONE place)
   Change a value here and it updates everywhere it's used.
   ========================================================= */
:root {
  --bg: #0f1017;        /* page background (deep dark) */
  --surface: #191b26;   /* card background (a bit lighter) */
  --border: rgba(255, 255, 255, 0.08); /* faint outlines */
  --text: #f3f4f8;      /* main text (almost white) */
  --muted: #9aa0b8;     /* quiet gray text */
  --accent: #ff5470;    /* our brand pink-red */
  --accent-2: #ff9a5a;  /* our brand orange */
}

/* =========================================================
   2. BASICS  (apply to the whole page)
   ========================================================= */
* {
  box-sizing: border-box; /* makes sizing behave nicely */
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  position: relative;
  overflow-x: hidden; /* stop the glows from making a sideways scrollbar */
}

/* ===== ANIME AURA: glowing colored lights behind everything ===== */
body::before {
  content: "";          /* a pseudo-element needs this to show up */
  position: fixed;      /* stay put even when the page scrolls */
  inset: 0;             /* stretch across the whole screen */
  z-index: -1;          /* sit BEHIND all the content */
  pointer-events: none; /* clicks pass straight through it */
  background:
    radial-gradient(600px circle at 15% 20%, rgba(255, 84, 112, 0.22), transparent 60%),
    radial-gradient(700px circle at 85% 12%, rgba(79, 172, 254, 0.18), transparent 60%),
    radial-gradient(650px circle at 50% 95%, rgba(255, 154, 90, 0.16), transparent 60%);
  animation: auraFloat 14s ease-in-out infinite; /* gently breathe */
}

@keyframes auraFloat {
  0%, 100% { transform: scale(1)    translateY(0);    opacity: 1;   }
  50%      { transform: scale(1.08) translateY(-12px); opacity: 0.8; }
}

a {
  text-decoration: none; /* remove underlines from links */
  color: inherit;
}

/* =========================================================
   3. TOP BAR
   ========================================================= */
.topbar {
  display: flex;                  /* lay children in a row */
  justify-content: space-between; /* logo left, nav right */
  align-items: center;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;               /* stays at top when scrolling */
  top: 0;
  background: rgba(15, 16, 23, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
}
.logo img {
  height: 40px;
  display: block;
}

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

.nav a {
  color: var(--muted);
  font-weight: 600;
}

/* =========================================================
   4. BUTTONS  (reused everywhere)
   ========================================================= */
.btn {
  padding: 10px 18px;
  border-radius: 999px; /* fully rounded pill shape */
  border: none;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: white;
}

.btn-outline {
  border: 1px solid var(--border);
  color: var(--text);
  background: transparent;
}

.btn-small {
  padding: 8px 14px;
  font-size: 13px;
}

.btn:hover {
  transform: translateY(-1px); /* tiny lift on hover */
  opacity: 0.92;
}

/* =========================================================
   5. HERO
   ========================================================= */
.hero {
  text-align: center;
  padding: 80px 20px 60px;
}

.hero-title {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1px;
}

/* the colorful word inside the title */
.accent {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-subtitle {
  color: var(--muted);
  font-size: 18px;
  margin: 16px auto 0;
  max-width: 560px;
}

.search {
  margin-top: 28px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.search-box {
  position: relative;      /* anchor: the dropdown positions against this */
  width: min(360px, 70vw);
}

.search input {
  padding: 12px 18px;
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
}

/* ===== SEARCH SUGGESTIONS DROPDOWN ===== */
.suggestions {
  display: none;           /* hidden until JavaScript adds the .open class */
  position: absolute;
  top: calc(100% + 8px);   /* sit just below the input */
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  z-index: 20;
  text-align: left;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
}

.suggestions.open {
  display: block;
}

.suggestion {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
}

.suggestion:hover {
  background: rgba(255, 255, 255, 0.06);
}

.suggestion img {
  width: 34px;
  height: 46px;
  object-fit: cover;
  border-radius: 6px;
}

.suggestion span {
  color: var(--muted);
  font-size: 13px;
}

.suggestion.empty {
  justify-content: center;
  color: var(--muted);
  cursor: default;
}

/* =========================================================
   6. THE LIBRARY GRID
   ========================================================= */
.library {
  max-width: 1100px;
  margin: 0 auto;      /* centers the section */
  padding: 20px 24px 60px;
}

.section-title {
  font-size: 26px;
  margin-bottom: 24px;
}

.grid {
  display: grid;
  /* auto-fill = as many columns as fit; each at least 220px wide */
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 22px;
}

/* =========================================================
   7. A MANGA CARD
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column; /* stack cover, body, footer top-to-bottom */
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  transform: translateY(-6px); /* the card lifts up */
  border-color: var(--accent);
  box-shadow: 0 12px 30px rgba(255, 84, 112, 0.25); /* glow */
}

.cover {
  height: 300px;
  overflow: hidden;      /* hide any part of the image that spills out */
  background: #0b0c12;   /* dark fill shown while the photo loads */
}

/* the real cover photo fills the whole box */
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;     /* fill the space & crop neatly, never squished */
  display: block;
  transition: transform 0.4s ease;
}

/* the cover zooms in a little when you hover the card */
.card:hover .cover img {
  transform: scale(1.06);
}

.card-body {
  padding: 16px 16px 8px;
  flex-grow: 1; /* pushes the footer to the bottom */
}

.card-title {
  font-size: 18px;
}

.card-author {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.card-desc {
  font-size: 14px;
  color: #c7cbdb;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 16px;
}

.price {
  font-weight: 800;
  color: var(--accent-2);
}

/* the glowing pulse when you jump to a manga from search */
.card.highlight {
  animation: pop 1.6s ease;
}

@keyframes pop {
  0%   { box-shadow: 0 0 0 0 rgba(255, 84, 112, 0.7);  border-color: var(--accent); }
  100% { box-shadow: 0 0 0 26px rgba(255, 84, 112, 0); border-color: var(--border); }
}

/* =========================================================
   8. FOOTER
   ========================================================= */
.footer {
  text-align: center;
  padding: 30px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.footer-legal { margin-top: 6px; font-size: 12px; opacity: 0.75; }
.auth-check { display: flex; align-items: center; gap: 8px; margin: 12px 0; font-size: 14px; color: var(--muted); cursor: pointer; }

/* ---- rental orders 🛒 ---- */
.order-lines, .order-total { max-width: 560px; margin: 10px 0; }
.order-line { display: flex; justify-content: space-between; gap: 16px; padding: 8px 4px; border-bottom: 1px dashed var(--border); font-size: 15px; }
.order-total .order-line:last-child { border-bottom: none; font-size: 16px; }
.order-days { margin: 14px 0; }
.order-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin: 18px 0; max-width: 560px; }
.upi-pay { background: rgba(255, 84, 112, 0.08); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 10px 0; font-size: 15px; line-height: 1.9; }
.order-method { padding: 6px 8px; border-radius: 8px; background: var(--card, #1a1a1f); color: inherit; border: 1px solid var(--border); }

/* =========================================================
   ============  ADDED IN THE BIG UPGRADE  =================
   categories · volume pop-up · cart · toast
   ========================================================= */

.hidden { display: none !important; }

.card { cursor: pointer; }               /* cards feel clickable now */
.card-meta { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ---------- category chips (jump links) ---------- */
.cat-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 28px;
}
.cat-chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cat-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- category sections ---------- */
.category { margin-top: 48px; }
.category-head { margin-bottom: 20px; }
.category-head h2 { font-size: 28px; }
.category-head .jp { font-size: 18px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.category-blurb { color: var(--muted); margin-top: 6px; max-width: 640px; }

/* ---------- cart count badge ---------- */
.cart-count {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 12px;
  text-align: center;
  margin-left: 4px;
}

/* ---------- dark overlay behind pop-ups ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 40;
}

/* ---------- the volume pop-up (modal) ---------- */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(680px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 26px;
  z-index: 50;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.18); }
.modal-top { display: flex; gap: 20px; margin-bottom: 20px; }
.modal-cover {
  width: 150px;
  height: 220px;
  object-fit: cover;
  border-radius: 12px;
  flex-shrink: 0;
}
.modal-info h2 { font-size: 24px; }
.modal-author { color: var(--muted); margin: 4px 0 10px; }
.modal-desc { font-size: 15px; color: #c7cbdb; }
.modal-price { margin-top: 12px; font-weight: 800; color: var(--accent-2); }
.vol-title { font-size: 16px; margin-bottom: 12px; }
.vol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}
.vol-chip {
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.vol-chip:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  transform: translateY(-2px);
}

/* volume states: out on loan · at my home · already ours · just showing */
.vol-chip:disabled { cursor: default; }
.vol-chip.out  { opacity: 0.4; text-decoration: line-through; }
.vol-chip.mine { border-color: #4facfe; color: #4facfe; }
.vol-chip.have { border-color: rgba(56, 239, 125, 0.5); color: #38ef7d; opacity: 0.75; }
.vol-chip.idle { opacity: 0.85; }
.vol-more { margin: 10px 0 14px; }
#volPickWrap .vol-grid { margin-top: 4px; }
@media (max-width: 520px) {
  .modal-top { flex-direction: column; align-items: center; text-align: center; }
}

/* ---------- slide-out cart ---------- */
.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(380px, 90vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);      /* parked off-screen to the right */
  transition: transform 0.25s ease;
}
.cart-drawer.open { transform: translateX(0); }  /* slides in */
.cart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.cart-head h2 { font-size: 20px; }
.cart-items { flex-grow: 1; overflow-y: auto; padding: 12px 16px; }
.cart-empty { color: var(--muted); text-align: center; margin-top: 40px; }
.cart-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item img { width: 40px; height: 56px; object-fit: cover; border-radius: 6px; }
.cart-item-info { flex-grow: 1; font-size: 14px; }
.cart-item-info span { color: var(--muted); font-size: 13px; }
.cart-remove { background: none; border: none; cursor: pointer; font-size: 16px; }
.cart-foot { padding: 18px 20px; border-top: 1px solid var(--border); }
.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 14px;
}
.cart-foot .btn { width: 100%; }

/* ---------- toast (little pop-up message) ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: white;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 10px 30px rgba(255, 84, 112, 0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =========================================================
   ==========  ADDED: age ratings + sign-in  ==============
   ========================================================= */

/* age-rating badge on each cover */
.cover { position: relative; }
.age-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11px;
  font-weight: 800;
  color: #0b0c12;
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.3px;
  z-index: 1;
}
.modal-rating { margin-top: 8px; font-size: 14px; color: var(--muted); }

/* banner shown when signed in */
.age-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 8px;
}

/* profile area in the top bar */
.profile { display: flex; align-items: center; gap: 8px; }
.who-chip { font-weight: 700; font-size: 14px; }
.age-chip { font-size: 12px; color: var(--muted); border: 1px solid var(--border); padding: 2px 8px; border-radius: 999px; }
.kid-badge { font-size: 12px; color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent)); padding: 2px 8px; border-radius: 999px; font-weight: 700; }

/* the sign-in form */
.auth h2 { font-size: 22px; }
.auth-sub { color: var(--muted); font-size: 14px; margin: 6px 0 18px; }
.auth-who { display: flex; gap: 10px; margin-bottom: 16px; }
.who-btn {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.who-btn.active { border-color: var(--accent); background: rgba(255, 84, 112, 0.12); }
.auth-field { display: block; margin-bottom: 14px; }
.auth-field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.auth-field input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.auth-note { color: var(--accent-2); font-size: 13px; min-height: 18px; margin-bottom: 10px; }
.auth .btn-primary { width: 100%; }
.auth-demo { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }

/* =========================================================
   ==========  ADDED: "selected / in cart" highlights  =====
   ========================================================= */

/* a volume you've added turns green with a checkmark */
.vol-chip.selected,
.vol-chip.selected:hover {
  background: #1f9d57;
  border-color: #38ef7d;
  color: #fff;
}
.vol-chip.selected::after { content: " ✓"; }

/* the green "In cart" badge on a book card */
.cart-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #38ef7d;
  color: #05371f;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  display: none;      /* hidden until the book is in the cart */
  z-index: 1;
}
.card.in-cart .cart-badge { display: block; }
.card.in-cart { border-color: rgba(56, 239, 125, 0.6); }

/* the book's big cover gets a green ring in the pop-up */
.modal-cover.selected { box-shadow: 0 0 0 3px #38ef7d; }

/* shown while the books are being fetched, or if the server is down */
.loading { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 16px; }
.load-error {
  text-align: center;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  line-height: 1.9;
  max-width: 520px;
  margin: 20px auto;
}
.load-error b { color: var(--accent-2); }

/* the 👑 Admin badge in the top bar */
.admin-badge {
  font-size: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}

/* admin add-manga form */
.admin-row { display: flex; gap: 10px; }
.admin-row .auth-field { flex: 1; }
.auth-field select,
.auth-field textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.admin-delete {
  margin-top: 16px;
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 84, 112, 0.5);
  color: var(--accent);
  border-radius: 10px;
  padding: 11px;
  cursor: pointer;
  font-weight: 700;
}
.admin-delete:hover { background: rgba(255, 84, 112, 0.12); }
.admin-edit {
  margin-top: 16px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px;
  cursor: pointer;
  font-weight: 700;
}
.admin-edit:hover { border-color: var(--accent); }

/* the ✨ auto-fill button under the title */
.auto-fill-btn { width: 100%; margin: -4px 0 14px; }

/* ===== ADMIN DASHBOARD ===== */
.modal.dash { width: min(920px, 95vw); }
.dash-content h2 { font-size: 24px; margin-bottom: 4px; }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0 8px; }
.stat-tile {
  flex: 1;
  min-width: 110px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 26px; font-weight: 800; color: var(--accent-2); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.dash-h { margin-top: 26px; margin-bottom: 10px; font-size: 18px; }
.dash-empty { color: var(--muted); }
.table-wrap { overflow-x: auto; }
.dash-content table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dash-content th,
.dash-content td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dash-content th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.role-chip { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.role-admin { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; }
.role-member { background: rgba(79, 172, 254, 0.2); color: #4facfe; }

/* ===== stock + queue ===== */
.stock-line { margin: 10px 0 4px; font-weight: 700; }
.stock-line.in { color: #38ef7d; }
.stock-line.out { color: #ff9a5a; }
.queue-status { color: var(--muted); font-size: 14px; margin: 4px 0 10px; }
.queue-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}
.queue-btn:hover { opacity: 0.92; }
.admin-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.admin-actions button { flex: 1; margin-top: 0; width: auto; min-width: 88px; }
.admin-restock {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px;
  cursor: pointer;
  font-weight: 700;
}
.admin-restock:hover { border-color: var(--accent-2); }

/* =========================================================
   ==========  PAGES: menu, sub-nav, panels  ==============
   ========================================================= */
.menu { display: flex; gap: 4px; align-items: center; }
.menu-link { padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px; }
.menu-link:hover { color: var(--text); }
.menu-link.active { color: var(--text); background: rgba(255, 255, 255, 0.07); }

.page-head {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.page-head h1 { font-size: 30px; }
.page-note {
  max-width: 1100px;
  margin: 12px auto;
  padding: 28px 24px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.subnav { max-width: 1100px; margin: 0 auto 8px; padding: 0 24px; display: flex; gap: 8px; flex-wrap: wrap; }
.subnav-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.subnav-btn.active { border-color: var(--accent); color: var(--text); }

.account-panel, .admin-panel { max-width: 1100px; margin: 0 auto; padding: 12px 24px 60px; }

/* ===== subscription plans ===== */
.sub-status { font-size: 15px; margin-bottom: 4px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 16px; max-width: 720px; }
.plan-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; text-align: center; }
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255, 84, 112, 0.35); }
.plan-name { font-weight: 700; font-size: 18px; }
.plan-price { font-size: 30px; font-weight: 800; color: var(--accent-2); margin: 8px 0; }
.plan-price span { font-size: 14px; color: var(--muted); font-weight: 500; }
.plan-limit { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.plan-btn { width: 100%; }
.sub-cancel { margin-top: 18px; background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }
.sub-cancel:hover { color: var(--accent); }
.sub-note { margin-top: 20px; color: var(--muted); font-size: 13px; max-width: 620px; }
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: 460px;
}
.profile-card h2 { margin-bottom: 12px; }
.profile-card p { margin: 6px 0; color: #c7cbdb; }

.admin-cards {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 24px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.admin-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.admin-card:hover:not([disabled]) { border-color: var(--accent); transform: translateY(-3px); }
.admin-card[disabled] { opacity: 0.5; cursor: not-allowed; }
.admin-card .ac-emoji { font-size: 28px; }
.admin-card b { font-size: 17px; }
.admin-card .ac-sub { color: var(--muted); font-size: 13px; font-weight: 400; }

/* =========================================================
   LENDING-LIBRARY additions: availability, my books,
   the wish board, and the ISBN scanner.
   ========================================================= */

/* availability line on each card */
.avail { font-size: 12.5px; font-weight: 600; }
.avail.in   { color: #38ef7d; }
.avail.out  { color: #ff9a5a; }
.avail.mine { color: #4facfe; }
.banner-link { color: var(--accent); font-weight: 600; }
.borrow-btn { display: inline-block; margin-top: 10px; text-decoration: none; }

/* due dates + overdue */
.due-ok  { color: #38ef7d; font-size: 13px; white-space: nowrap; }
.due-bad { color: #ff5470; font-size: 13px; font-weight: 700; white-space: nowrap; }
.overdue-chip { background: #ff5470; color: #fff; border-radius: 8px; padding: 2px 8px; font-size: 12px; }
.row-overdue td { background: rgba(255, 84, 112, 0.07); }
.row-retired td { opacity: 0.5; }
.hist-chip { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* tables: small helpers */
.td-sub { color: var(--muted); font-size: 12.5px; }
.td-actions { white-space: nowrap; }
.thumb { width: 34px; height: 48px; object-fit: cover; border-radius: 4px; }
.stat-tile.warn .stat-value { color: #ff9a5a; }

/* "My Books" rows */
.mybook-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; margin: 8px 0;
  max-width: 640px;
}
.mybook-row img { width: 38px; height: 54px; object-fit: cover; border-radius: 6px; }
.mybook-info { flex: 1; }

/* wishlist board */
.page-intro { max-width: 720px; margin: 0 auto 18px; text-align: center; color: var(--muted); padding: 0 24px; }
.wish-form {
  max-width: 640px; margin: 0 auto 26px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px;
}
.wish-board { max-width: 640px; margin: 0 auto; padding: 0 0 60px; }
.wish-card {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 10px;
}
.wish-card.done { opacity: 0.65; }
.wish-vote {
  display: flex; flex-direction: column; align-items: center;
  background: none; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); padding: 6px 12px; cursor: pointer; font-size: 14px;
  line-height: 1.2; min-width: 46px;
}
.wish-vote span { font-weight: 700; font-size: 15px; }
.wish-vote.voted { border-color: var(--accent); color: var(--accent); }
.wish-body { flex: 1; }
.wish-author { color: var(--muted); font-size: 13px; }
.wish-note { color: #c7cbdb; font-size: 13.5px; margin: 4px 0; }
.wish-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.wish-del { color: #ff5470; cursor: pointer; }
.wish-chip { border-radius: 8px; padding: 1px 8px; font-size: 11.5px; font-weight: 700; }
.wish-chip.ordered  { background: rgba(79, 172, 254, 0.18); color: #4facfe; }
.wish-chip.added    { background: rgba(56, 239, 125, 0.15); color: #38ef7d; }
.wish-chip.declined { background: rgba(255, 84, 112, 0.15); color: #ff5470; }

/* pending-payment subscription banner */
.sub-status.pending { border-color: #ff9a5a; }

/* the ISBN scanner */
.scan-stage {
  position: relative; border-radius: 14px; overflow: hidden;
  background: #0b0d14; border: 1px solid var(--border);
  aspect-ratio: 4 / 3; margin-bottom: 12px;
}
.scan-stage video { width: 100%; height: 100%; object-fit: cover; }
.scan-hint {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 8px 12px; font-size: 12.5px; text-align: center;
  color: #fff; background: rgba(0, 0, 0, 0.55);
}
.walkin-row { align-items: end; }
.walkin-row .auth-field { flex: 1; }

/* =========================================================
   RESPONSIVE 📱 — phone & small-tablet fixes.
   The big idea: NOTHING may be wider than the screen.
   (body has overflow-x:hidden, so anything wider isn't
   scrollable — it's just invisible. These rules make every
   row wrap, shrink, or scroll instead of spilling out.)
   ========================================================= */

/* ---- small tablets & phones ---- */
@media (max-width: 760px) {

  /* TOP BAR: row 1 = logo + profile, row 2 = the menu.
     display:contents lifts #menu and #profile out of .nav so
     they become direct flex children of the top bar. */
  .topbar { flex-wrap: wrap; padding: 10px 14px; row-gap: 6px; }
  .nav { display: contents; }
  .logo img { height: 32px; }
  .profile { gap: 6px; }
  .profile .btn { padding: 8px 12px; font-size: 13px; }
  .who-chip {                     /* "Hi, <long name>" mustn't push */
    max-width: 110px;             /* the Sign-out button off-screen */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .menu {
    order: 3;                     /* go last → wrap onto its own row */
    flex-basis: 100%;
    overflow-x: auto;             /* many links? swipe sideways */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .menu::-webkit-scrollbar { display: none; }
  .menu-link { white-space: nowrap; padding: 6px 10px; }

  /* HERO: smaller type, and the search button may wrap below */
  .hero { padding: 44px 16px 36px; }
  .hero-title { font-size: 30px; }
  .hero-subtitle { font-size: 16px; }
  .search { flex-wrap: wrap; }
  .search-box { width: min(360px, 100%); }

  /* page scaffolding: slimmer side padding on small screens */
  .library, .account-panel, .admin-panel, .admin-cards { padding-left: 16px; padding-right: 16px; }
  .subnav { padding-left: 16px; padding-right: 16px; }
  .page-head { flex-wrap: wrap; padding: 28px 16px 8px; }
  .page-head h1 { font-size: 24px; }
  .page-note { margin-left: 16px; margin-right: 16px; }
  .category { margin-top: 36px; }

  /* form rows: 2 fields per row, not 4 squeezed slivers */
  .admin-row { flex-wrap: wrap; }
  .admin-row .auth-field { flex: 1 1 44%; min-width: 130px; }

  /* dashboard stat tiles: two per row */
  .stat-tile { flex: 1 1 40%; }

  /* "My Books" rows: wrap instead of clipping the due date */
  .mybook-row { flex-wrap: wrap; }

  /* toasts carry error messages too — keep them on screen */
  .toast { max-width: calc(100vw - 32px); text-align: center; }

  /* iOS Safari zooms the page when focusing an input smaller
     than 16px — keep inputs at 16px so the layout stays put */
  .auth-field input,
  .auth-field select,
  .auth-field textarea,
  .search input { font-size: 16px; }
}

/* ---- phones ---- */
@media (max-width: 520px) {

  /* the shelf: two covers side by side, true 2:3 manga ratio */
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .cover { height: auto; aspect-ratio: 2 / 3; }
  .card-body { padding: 10px 10px 6px; }
  .card-title { font-size: 15px; }
  .card-author { font-size: 12px; }
  .card-desc {                    /* long blurbs: show 2 lines + … */
    font-size: 12.5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .card-footer { padding: 8px 10px 12px; }

  /* pop-ups: nearly full-screen */
  .modal, .modal.dash { width: 94vw; padding: 20px 16px; max-height: 90vh; max-height: 90dvh; }

  .hero-title { font-size: 26px; }
  .section-title { font-size: 22px; }
  .category-head h2 { font-size: 22px; }
  .plan-grid { grid-template-columns: 1fr 1fr; }
}
