/* ============================================================
   THE GRAND ARCHIVE — Polished Edition
   Deep fantasy library aesthetic: ornate, atmospheric, refined
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:         #d4a843;
  --gold-light:   #f2d070;
  --gold-pale:    #f8e9b8;
  --gold-dim:     #a07828;
  --gold-deep:    #7a5c18;
  --gold-faint:   rgba(212,168,67,.08);

  --ink:          #0b0806;
  --ink-deep:     #070503;
  --ink-mid:      #130d06;
  --ink-warm:     #1a1007;
  --ink-raised:   #201408;
  --ink-card:     #170f06;

  --parch:        #f2e5c6;
  --parch-dim:    #c8b688;
  --parch-mute:   #8a7050;
  --parch-faint:  #503c22;
  --parch-ghost:  #2e2010;

  --ember:        #8a2410;
  --ember-warm:   #b83820;
  --ember-glow:   rgba(138,36,16,.25);

  --teal-lite:    #3aabb8;
  --sage-lite:    #5ab040;

  --border:       #2c1e0e;
  --border-warm:  #3a2812;
  --border-gold:  rgba(212,168,67,.3);

  --shad-deep:    rgba(0,0,0,.65);
  --shad-mid:     rgba(0,0,0,.4);

  --glow-gold:    rgba(212,168,67,.14);
  --glow-bright:  rgba(212,168,67,.28);
}

/* ── BASE ── */
body {
  font-family: 'Crimson Pro', Georgia, serif;
  background: var(--ink);
  color: var(--parch);
  min-height: 100vh;
  /* Subtle warm paper texture */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.032'/%3E%3C/svg%3E");
}

.page { display: none; }
.page.active { display: block; }

/* ═══════════════════════════════════════
   AUTH PAGE
═══════════════════════════════════════ */

.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 50% at 50% -5%, rgba(212,168,67,.18) 0%, transparent 70%),
    radial-gradient(ellipse 60% 60% at 10% 100%, rgba(138,36,16,.1) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 90% 90%, rgba(212,168,67,.06) 0%, transparent 60%),
    linear-gradient(180deg, #0c0906 0%, #0e0a05 100%);
}

/* Floating rune particles */
.auth-wrap::before {
  content: '✦ ✧ ⚔ ✦ ✧ ⚔ ✦ ✧';
  position: absolute;
  top: 8%; left: 0; right: 0;
  text-align: center;
  font-size: .6rem; letter-spacing: 1.8rem;
  color: rgba(212,168,67,.1);
  pointer-events: none;
  white-space: nowrap;
}
.auth-wrap::after {
  content: '✦ ✧ ⚔ ✦ ✧ ⚔ ✦ ✧';
  position: absolute;
  bottom: 8%; left: 0; right: 0;
  text-align: center;
  font-size: .6rem; letter-spacing: 1.8rem;
  color: rgba(212,168,67,.08);
  pointer-events: none;
  white-space: nowrap;
}

.auth-box {
  background: linear-gradient(165deg, #1e1409 0%, #130d06 55%, #0d0803 100%);
  border: 1px solid var(--gold-deep);
  padding: 3rem 2.4rem 2.6rem;
  width: 100%; max-width: 400px;
  border-radius: 4px;
  position: relative;
  box-shadow:
    0 0 0 1px var(--border),
    0 30px 80px rgba(0,0,0,.8),
    0 0 100px rgba(212,168,67,.1),
    inset 0 0 60px rgba(0,0,0,.3);
}

/* Corner ornaments */
.auth-box::before {
  content: '';
  position: absolute; inset: 6px;
  border: 1px solid rgba(212,168,67,.12);
  border-radius: 2px;
  pointer-events: none;
}

/* Top gold rule */
.auth-box::after {
  content: '';
  position: absolute;
  top: -1px; left: 12%; right: 12%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--gold-light), var(--gold), transparent);
  border-radius: 0 0 2px 2px;
}

/* Corner diamond decorations via SVG data URI approach using box-shadow on pseudo */
.auth-logo {
  text-align: center;
  margin-bottom: 2.4rem;
  position: relative;
}
.auth-logo::before {
  content: '◆ · · · · · · · · ◆';
  display: block;
  font-size: .5rem; letter-spacing: .15rem;
  color: rgba(212,168,67,.2);
  margin-bottom: 1.2rem;
}
.auth-logo::after {
  content: '◆ · · · · · · · · ◆';
  display: block;
  font-size: .5rem; letter-spacing: .15rem;
  color: rgba(212,168,67,.2);
  margin-top: 1.2rem;
}

.auth-logo h1 {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 5px;
  text-shadow:
    0 0 40px var(--glow-bright),
    0 0 12px rgba(212,168,67,.3),
    0 2px 6px rgba(0,0,0,.6);
  line-height: 1.2;
}
.auth-logo p {
  font-style: italic;
  color: var(--parch-mute);
  font-size: .92rem;
  margin-top: .5rem;
  letter-spacing: .8px;
}

.auth-sep {
  display: flex; align-items: center; gap: .9rem;
  margin: .6rem 0 1.7rem;
  color: var(--parch-ghost);
  font-size: .65rem; letter-spacing: 3px;
  font-family: 'Cinzel', serif;
}
.auth-sep::before, .auth-sep::after {
  content: '';
  flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-warm));
}
.auth-sep::after { background: linear-gradient(90deg, var(--border-warm), transparent); }

/* ── FORM FIELDS ── */
.field-group { margin-bottom: 1.2rem; }
.field-group label {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: .62rem; letter-spacing: 2.5px;
  color: var(--parch-mute);
  margin-bottom: .5rem;
}
.field-group input,
.field-group select {
  width: 100%;
  background: rgba(255,255,255,.025);
  border: 1px solid var(--border);
  color: var(--parch);
  padding: .72rem 1rem;
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  outline: none;
  border-radius: 2px;
  transition: border .25s, background .25s, box-shadow .25s;
}
.field-group input:focus,
.field-group select:focus {
  border-color: var(--gold-dim);
  background: rgba(212,168,67,.04);
  box-shadow:
    0 0 0 3px rgba(212,168,67,.07),
    inset 0 1px 4px rgba(0,0,0,.35);
}
.field-group input::placeholder { color: var(--parch-faint); font-style: italic; }
.field-group select option { background: var(--ink-mid); color: var(--parch); }

/* ── GOLD BUTTON ── */
.btn-gold {
  width: 100%; padding: .85rem;
  font-family: 'Cinzel', serif;
  font-size: .7rem; letter-spacing: 3px;
  border: 1px solid var(--gold-dim);
  background: linear-gradient(180deg, #2e1f0a 0%, #1c1206 50%, #160e05 100%);
  color: var(--gold);
  cursor: pointer; border-radius: 2px;
  margin-top: .7rem;
  position: relative; overflow: hidden;
  transition: color .25s, border-color .25s, box-shadow .25s;
  box-shadow: 0 2px 10px rgba(0,0,0,.5), inset 0 1px 0 rgba(212,168,67,.12);
}
.btn-gold::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--gold-deep), #5a3e10);
  opacity: 0;
  transition: opacity .25s;
}
.btn-gold:hover { color: var(--parch-pale, #f8e9b8); border-color: var(--gold); box-shadow: 0 4px 20px rgba(0,0,0,.6), 0 0 25px rgba(212,168,67,.22); }
.btn-gold:hover::before { opacity: 1; }
.btn-gold:active { transform: translateY(1px); }
.btn-gold span { position: relative; }

.auth-switch {
  text-align: center; margin-top: 1.4rem;
  font-size: .9rem; color: var(--parch-faint);
}
.auth-switch a { color: var(--gold); cursor: pointer; transition: color .2s; }
.auth-switch a:hover { color: var(--gold-light); text-decoration: underline; }

.err-msg {
  background: rgba(138,36,16,.18);
  border: 1px solid rgba(138,36,16,.5);
  color: #e88070;
  font-size: .84rem;
  padding: .58rem .95rem;
  border-radius: 2px;
  margin-bottom: .9rem;
  display: none;
}
.hint-box {
  background: rgba(212,168,67,.05);
  border: 1px solid rgba(212,168,67,.18);
  border-radius: 2px;
  padding: .8rem 1rem;
  margin-top: 1.2rem;
  font-size: .82rem;
  color: var(--parch-mute);
  position: relative;
}
.hint-box::before {
  content: '◆';
  position: absolute; top: .7rem; left: 1rem;
  font-size: .5rem; color: var(--gold-dim);
}
.hint-box { padding-left: 1.8rem; }
.hint-box strong { color: var(--gold); }
.hint-box em { color: var(--parch-dim); font-style: normal; }

/* ═══════════════════════════════════════
   SITE HEADER
═══════════════════════════════════════ */

.site-header {
  background: linear-gradient(180deg, #09060302 0%, #0e0a05 100%);
  border-bottom: 1px solid var(--border);
  padding: .9rem 1.6rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 3px 24px rgba(0,0,0,.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background-color: rgba(14,10,5,.96);
}

/* Gold shimmer line at very bottom of header */
.site-header::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    transparent 15%,
    rgba(212,168,67,.35) 30%,
    rgba(242,208,112,.55) 50%,
    rgba(212,168,67,.35) 70%,
    transparent 85%,
    transparent 100%);
}

.header-logo {
  font-family: 'Cinzel', serif;
  font-size: 1.02rem;
  color: var(--gold);
  letter-spacing: 3px; flex: 1;
  text-shadow: 0 0 25px var(--glow-gold);
  display: flex; align-items: center; gap: .6rem;
}
.header-logo::before {
  content: '⚔';
  font-size: .8rem;
  color: var(--gold-dim);
  opacity: .7;
}
.header-user { font-size: .84rem; color: var(--parch-mute); font-style: italic; }
.header-btns { display: flex; gap: .5rem; }

.hbtn {
  font-family: 'Cinzel', serif;
  font-size: .62rem; letter-spacing: 1.5px;
  border: 1px solid var(--border-warm);
  background: transparent; color: var(--parch-mute);
  padding: .44rem .9rem; cursor: pointer;
  border-radius: 2px; transition: all .2s;
}
.hbtn:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: rgba(212,168,67,.07);
  box-shadow: 0 0 12px rgba(212,168,67,.1);
}
.hbtn.admin {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: rgba(212,168,67,.06);
}

/* ═══════════════════════════════════════
   HERO SECTION
═══════════════════════════════════════ */

.hero {
  position: relative; text-align: center;
  padding: 4rem 1rem 3rem;
  background:
    radial-gradient(ellipse 70% 60% at 50% -10%, rgba(212,168,67,.16) 0%, transparent 65%),
    radial-gradient(ellipse 40% 30% at 20% 80%, rgba(138,36,16,.08) 0%, transparent 60%),
    linear-gradient(180deg, #0e0a05 0%, #160e07 60%, #1c1108 100%);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

/* Horizontal decorative lines */
.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg,
    transparent, transparent 10%,
    rgba(212,168,67,.3) 25%,
    rgba(242,208,112,.5) 50%,
    rgba(212,168,67,.3) 75%,
    transparent 90%, transparent);
}
.hero::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,168,67,.3), transparent);
}

/* Decorative corner flourishes */
.hero-deco {
  position: absolute;
  font-size: .55rem; letter-spacing: .2rem;
  color: rgba(212,168,67,.15);
  top: 1.2rem;
  left: 1.5rem; right: 1.5rem;
  display: flex; justify-content: space-between;
  pointer-events: none;
}

.rune-row {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; margin-bottom: 1.3rem;
  font-family: 'Cinzel', serif;
  font-size: .62rem; letter-spacing: 5px;
  color: var(--gold-deep);
  position: relative;
}
.rune-row::before, .rune-row::after {
  content: '';
  flex: 1; max-width: 100px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-deep));
}
.rune-row::after { background: linear-gradient(90deg, var(--gold-deep), transparent); }

.hero-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(2.2rem, 6vw, 3.5rem);
  font-weight: 700; color: var(--gold);
  letter-spacing: 5px; line-height: 1.05;
  text-shadow:
    0 0 80px rgba(212,168,67,.5),
    0 0 30px rgba(212,168,67,.25),
    0 4px 12px rgba(0,0,0,.7);
}
.hero-sub {
  font-style: italic; font-size: 1.08rem;
  color: var(--parch-dim);
  margin-top: .7rem; letter-spacing: 1px;
}

/* Decorative divider below subtitle */
.hero-ornament {
  display: flex; align-items: center; justify-content: center;
  gap: .8rem; margin: 1.5rem auto 0; max-width: 320px;
  color: rgba(212,168,67,.25); font-size: .65rem;
  letter-spacing: .3rem;
}
.hero-ornament::before,
.hero-ornament::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,168,67,.2));
}
.hero-ornament::after { background: linear-gradient(90deg, rgba(212,168,67,.2), transparent); }

.search-bar {
  display: flex; max-width: 550px; margin: 1.6rem auto 0;
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  overflow: hidden;
  background: rgba(255,255,255,.04);
  box-shadow: 0 6px 25px rgba(0,0,0,.45), 0 0 40px rgba(212,168,67,.06);
  transition: box-shadow .3s, border-color .3s;
}
.search-bar:focus-within {
  border-color: var(--gold);
  box-shadow: 0 6px 30px rgba(0,0,0,.55), 0 0 50px rgba(212,168,67,.18);
}
.search-bar input {
  flex: 1; background: transparent; border: none; outline: none;
  padding: .85rem 1.2rem;
  font-family: 'Crimson Pro', serif; font-size: 1rem; color: var(--parch);
}
.search-bar input::placeholder { color: var(--parch-faint); font-style: italic; }
.search-bar button {
  background: linear-gradient(180deg, var(--gold-dim) 0%, #5a3e10 100%);
  border: none; padding: .85rem 1.4rem;
  border-left: 1px solid rgba(212,168,67,.2);
  color: var(--parch-dim);
  font-family: 'Cinzel', serif; font-size: .68rem; letter-spacing: 2px;
  cursor: pointer; transition: all .2s;
}
.search-bar button:hover {
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dim) 100%);
  color: var(--ink);
}

/* ═══════════════════════════════════════
   GENRE NAV
═══════════════════════════════════════ */

.genre-nav {
  display: flex; gap: 0; justify-content: center; flex-wrap: wrap;
  background: #0a0703;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,.5);
  position: relative;
}
.genre-nav::after {
  content: '';
  position: absolute; bottom: 0; left: 5%; right: 5%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,168,67,.1), transparent);
}

.genre-tab {
  font-family: 'Cinzel', serif;
  font-size: .64rem; letter-spacing: 2px; color: var(--parch-faint);
  padding: .92rem 1rem;
  border: none; background: transparent; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all .2s;
  position: relative;
}
.genre-tab:hover { color: var(--parch-mute); }
.genre-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  text-shadow: 0 0 18px var(--glow-gold);
  background: rgba(212,168,67,.04);
}

/* ═══════════════════════════════════════
   SECTION TITLE
═══════════════════════════════════════ */

.section-title {
  font-family: 'Cinzel', serif;
  font-size: .7rem; letter-spacing: 5px;
  color: var(--gold-dim);
  padding: 2.2rem 1.6rem 1.2rem;
  display: flex; align-items: center; gap: 1rem;
}
.section-title::before {
  content: '◆';
  font-size: .4rem; color: var(--gold-deep); opacity: .8;
}
.section-title::after {
  content: '';
  flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--border-warm), transparent);
}

/* ═══════════════════════════════════════
   BOOKS GRID & CARDS
═══════════════════════════════════════ */

.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1.5rem;
  padding: 0 1.6rem 2.2rem;
}

.book-card { cursor: pointer; transition: transform .28s cubic-bezier(.34,1.2,.64,1), filter .25s; }
.book-card:hover { transform: translateY(-8px) rotate(.3deg); filter: brightness(1.06); }

.book-cover {
  width: 100%; aspect-ratio: 2/3;
  border-radius: 2px 6px 6px 2px;
  position: relative; overflow: hidden; margin-bottom: .75rem;
  box-shadow:
    -5px 5px 18px var(--shad-deep),
    5px 3px 12px rgba(0,0,0,.5),
    inset -2px 0 0 rgba(0,0,0,.4),
    inset 1px 0 0 rgba(255,255,255,.04);
  transition: box-shadow .28s;
}
.book-card:hover .book-cover {
  box-shadow:
    -8px 8px 28px rgba(0,0,0,.75),
    7px 5px 18px rgba(0,0,0,.5),
    inset -2px 0 0 rgba(0,0,0,.4),
    0 0 30px rgba(212,168,67,.12);
}

.cover-spine {
  position: absolute; left: 0; top: 0; bottom: 0; width: 11px;
  background: linear-gradient(90deg, rgba(0,0,0,.7) 0%, rgba(0,0,0,.3) 60%, rgba(255,255,255,.03) 100%);
  z-index: 1;
}
/* Spine highlight */
.cover-spine::after {
  content: '';
  position: absolute; left: 10px; top: 0; bottom: 0; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.06), transparent);
}

.cover-img {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px;
}

.avail-badge {
  position: absolute; bottom: 8px; left: 8px;
  font-family: 'Cinzel', serif; font-size: 7px; letter-spacing: 1.2px;
  padding: 3px 7px; border-radius: 1px;
}
.av   { background: rgba(12,45,12,.92); color: #85d485; border: 1px solid rgba(50,110,50,.7); }
.unav { background: rgba(70,12,6,.92);  color: #e88070; border: 1px solid rgba(138,36,16,.7); }

.book-title {
  font-family: 'Cinzel', serif; font-size: .76rem;
  color: var(--parch); line-height: 1.35; font-weight: 600;
  transition: color .2s;
}
.book-card:hover .book-title { color: var(--gold-light); }
.book-author { font-style: italic; font-size: .79rem; color: var(--parch-mute); margin-top: 3px; }

.borrow-btn {
  margin-top: .5rem; width: 100%; padding: .38rem;
  font-family: 'Cinzel', serif; font-size: .6rem; letter-spacing: 2px;
  border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, rgba(212,168,67,.07), rgba(212,168,67,.02));
  color: var(--gold);
  cursor: pointer; transition: all .22s; border-radius: 2px;
}
.borrow-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--gold-deep), #4e3010);
  color: var(--parch); border-color: var(--gold);
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.borrow-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ═══════════════════════════════════════
   FEATURED BANNER
═══════════════════════════════════════ */

.featured-banner {
  margin: 1.6rem 1.6rem 0;
  background: linear-gradient(135deg, #221206 0%, #2e1808 40%, #221005 70%, #1a0d04 100%);
  border: 1px solid rgba(212,168,67,.3);
  border-radius: 4px;
  padding: 1.8rem;
  display: flex; gap: 1.6rem; align-items: center;
  position: relative; overflow: hidden;
  box-shadow:
    0 6px 30px rgba(0,0,0,.6),
    inset 0 1px 0 rgba(212,168,67,.12),
    inset 0 -1px 0 rgba(0,0,0,.3);
}
.featured-banner::before {
  content: '';
  position: absolute; top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(212,168,67,.12) 0%, transparent 70%);
  pointer-events: none;
}
/* Top gold line */
.featured-banner::after {
  content: '';
  position: absolute; top: 0; left: 15%; right: 15%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,168,67,.6), transparent);
}

/* Inner corner ornaments on featured */
.featured-text { flex: 1; position: relative; }
.featured-label {
  font-family: 'Cinzel', serif;
  font-size: .62rem; letter-spacing: 4px;
  color: var(--gold);
  margin-bottom: .6rem;
  text-shadow: 0 0 20px var(--glow-gold);
  display: flex; align-items: center; gap: .7rem;
}
.featured-label::before { content: '◆'; font-size: .4rem; }
.featured-title {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem; font-weight: 700;
  color: var(--parch); line-height: 1.15;
}
.featured-desc {
  font-size: .93rem; color: var(--parch-mute); font-style: italic;
  margin-top: .6rem; line-height: 1.6;
}
.featured-cover {
  width: 88px; height: 132px; flex-shrink: 0;
  border-radius: 2px 6px 6px 2px;
  box-shadow: -5px 5px 18px rgba(0,0,0,.7), 0 0 25px rgba(212,168,67,.1);
}

/* ═══════════════════════════════════════
   BORROWED SHELF
═══════════════════════════════════════ */

.borrowed-shelf {
  margin: 0 1.6rem 2.2rem;
  background: var(--ink-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,.3);
}
.borrowed-item {
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem 1.3rem;
  border-bottom: 1px solid var(--border);
  transition: background .2s;
  position: relative;
}
.borrowed-item:hover { background: rgba(212,168,67,.035); }
.borrowed-item:last-child { border-bottom: none; }
/* Book icon bullet */
.borrowed-item::before {
  content: '📖';
  font-size: .85rem; opacity: .5;
  flex-shrink: 0;
}
.bi-title { color: var(--parch); font-family: 'Cinzel', serif; font-size: .73rem; letter-spacing: .5px; }
.bi-due   { font-size: .8rem; color: var(--parch-mute); font-style: italic; margin-top: 3px; }
.bi-due.overdue { color: #e88070; font-weight: 600; }

.return-btn {
  margin-left: auto; flex-shrink: 0;
  padding: .32rem .75rem;
  font-family: 'Cinzel', serif; font-size: .59rem; letter-spacing: 1.2px;
  border: 1px solid rgba(138,36,16,.4);
  background: transparent; color: #c07060;
  cursor: pointer; border-radius: 2px; transition: all .2s;
}
.return-btn:hover { border-color: var(--ember); color: var(--parch); background: var(--ember); }
.empty-shelf {
  text-align: center; padding: 2.2rem 1.2rem;
  font-style: italic; color: var(--parch-faint); font-size: .92rem;
}
/* Empty shelf decoration */
.empty-shelf::before {
  content: '◆ · · · ◆ · · · ◆';
  display: block; font-size: .5rem; letter-spacing: .3rem;
  color: rgba(212,168,67,.1); margin-bottom: .8rem;
}

/* ═══════════════════════════════════════
   MODAL
═══════════════════════════════════════ */

.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(4,2,1,.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
  background: linear-gradient(160deg, #201408, #160e06 55%, #100a04 100%);
  border: 1px solid var(--gold-deep);
  border-radius: 4px;
  max-width: 450px; width: 100%;
  padding: 2.4rem;
  position: relative;
  max-height: 92vh; overflow-y: auto;
  box-shadow:
    0 40px 100px rgba(0,0,0,.9),
    0 0 0 1px var(--border),
    0 0 80px rgba(212,168,67,.12),
    inset 0 1px 0 rgba(212,168,67,.12);
}
/* Inner border */
.modal::before {
  content: '';
  position: absolute; inset: 6px;
  border: 1px solid rgba(212,168,67,.08);
  border-radius: 2px;
  pointer-events: none;
}
/* Top gold accent */
.modal::after {
  content: '';
  position: absolute;
  top: -1px; left: 20%; right: 20%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), var(--gold), var(--gold-dim), transparent);
  border-radius: 0 0 2px 2px;
}

.modal-close {
  position: absolute; top: 1.1rem; right: 1.1rem;
  background: transparent; border: none;
  color: var(--parch-faint); font-size: 1.1rem;
  cursor: pointer; transition: color .2s, transform .25s;
  line-height: 1; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid transparent;
}
.modal-close:hover {
  color: var(--gold); transform: rotate(90deg);
  border-color: var(--border-warm);
  background: rgba(212,168,67,.05);
}

.modal h2 {
  font-family: 'Cinzel', serif; font-size: 1.15rem;
  color: var(--gold); margin-bottom: .5rem;
  text-shadow: 0 0 25px var(--glow-gold);
  padding-right: 2rem;
}
.modal .m-author { font-style: italic; color: var(--parch-mute); font-size: .93rem; margin-bottom: 1.3rem; }
.modal .m-divider {
  height: 1px; margin: 0 0 1.3rem;
  background: linear-gradient(90deg, var(--border-warm), transparent);
}
.modal .m-desc { font-size: .95rem; color: var(--parch-dim); line-height: 1.7; margin-bottom: 1.3rem; }
.modal .m-meta { display: flex; gap: 1.2rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
.modal .mi { font-family: 'Cinzel', serif; font-size: .61rem; letter-spacing: 1.2px; color: var(--parch-mute); }
.modal .mi span {
  display: block; color: var(--parch); font-size: .88rem;
  margin-top: 4px; font-family: 'Crimson Pro', serif; letter-spacing: 0;
}

.modal-btn {
  width: 100%; padding: .82rem;
  font-family: 'Cinzel', serif; font-size: .7rem; letter-spacing: 2.5px;
  border: 1px solid var(--gold-deep);
  background: linear-gradient(180deg, #2e1f0a, #1c1206);
  color: var(--gold); cursor: pointer; border-radius: 2px;
  position: relative; overflow: hidden;
  transition: color .25s, border-color .25s, box-shadow .25s;
  box-shadow: 0 2px 10px rgba(0,0,0,.5), inset 0 1px 0 rgba(212,168,67,.1);
}
.modal-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--gold-deep), #4e3010);
  opacity: 0; transition: opacity .25s;
}
.modal-btn span { position: relative; }
.modal-btn:hover:not(:disabled) { color: var(--parch); border-color: var(--gold); box-shadow: 0 4px 20px rgba(0,0,0,.6), 0 0 25px rgba(212,168,67,.2); }
.modal-btn:hover:not(:disabled)::before { opacity: 1; }
.modal-btn:disabled { opacity: .3; cursor: not-allowed; }
.modal-btn.return-modal { border-color: rgba(138,36,16,.5); color: #e88070; background: rgba(138,36,16,.14); }
.modal-btn.return-modal::before { background: linear-gradient(180deg, var(--ember), #6a1808); }
.modal-btn.return-modal:hover:not(:disabled) { color: var(--parch); border-color: var(--ember-warm); }

/* ═══════════════════════════════════════
   ADMIN PAGE
═══════════════════════════════════════ */

.admin-wrap { padding: 1.6rem; }
.admin-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.8rem; flex-wrap: wrap;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.admin-header::after {
  content: '';
  position: absolute; bottom: -1px; left: 0; width: 80px; height: 1px;
  background: linear-gradient(90deg, var(--gold-dim), transparent);
}
.admin-header h2 {
  font-family: 'Cinzel', serif; font-size: 1.15rem;
  color: var(--gold); letter-spacing: 3px; flex: 1;
  text-shadow: 0 0 20px var(--glow-gold);
  display: flex; align-items: center; gap: .6rem;
}
.admin-header h2::before { content: '◆'; font-size: .5rem; color: var(--gold-deep); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 1rem; margin-bottom: 1.8rem;
}
.stat-card {
  background: linear-gradient(145deg, var(--ink-raised), var(--ink-card));
  border: 1px solid var(--border);
  border-radius: 3px; padding: 1.1rem 1.2rem; text-align: center;
  box-shadow: 0 3px 14px rgba(0,0,0,.35);
  transition: all .25s; position: relative; overflow: hidden;
  cursor: default;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 15%; right: 15%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212,168,67,.3), transparent);
}
.stat-card:hover {
  border-color: var(--gold-deep);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.45), 0 0 25px var(--glow-gold);
}
.stat-num {
  font-family: 'Cinzel', serif; font-size: 1.8rem;
  color: var(--gold); font-weight: 700;
  text-shadow: 0 0 25px var(--glow-gold);
}
.stat-lbl {
  font-family: 'Cinzel', serif; font-size: .56rem;
  letter-spacing: 2.5px; color: var(--parch-faint); margin-top: .35rem;
}

.admin-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.4rem; flex-wrap: wrap;
  position: relative;
}
.atab {
  font-family: 'Cinzel', serif; font-size: .63rem; letter-spacing: 2px;
  color: var(--parch-faint);
  padding: .78rem 1.1rem;
  border: none; background: transparent; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all .2s;
}
.atab:hover { color: var(--parch-mute); }
.atab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  text-shadow: 0 0 12px var(--glow-gold);
  background: rgba(212,168,67,.04);
}

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.admin-table th {
  font-family: 'Cinzel', serif; font-size: .57rem; letter-spacing: 2.2px;
  color: var(--parch-mute); padding: .7rem .95rem;
  border-bottom: 1px solid var(--border-warm);
  text-align: left; white-space: nowrap;
  background: rgba(0,0,0,.25);
}
.admin-table td {
  padding: .68rem .95rem;
  border-bottom: 1px solid var(--border);
  color: var(--parch-dim); vertical-align: middle;
}
.admin-table tr:hover td { background: rgba(212,168,67,.04); }

.status-pill {
  font-family: 'Cinzel', serif; font-size: .57rem; letter-spacing: 1px;
  padding: 3px 9px; border-radius: 2px; white-space: nowrap;
}
.s-active   { background: rgba(18,50,18,.8);  color: #85d485; border: 1px solid rgba(40,100,40,.6); }
.s-returned { background: rgba(22,16,8,.8);   color: var(--parch-faint); border: 1px solid var(--border); }
.s-overdue  { background: rgba(90,15,6,.8);   color: #e88070; border: 1px solid rgba(138,36,16,.6); }

.admin-action-btn {
  font-family: 'Cinzel', serif; font-size: .57rem; letter-spacing: 1px;
  padding: 4px 10px; border: 1px solid rgba(138,36,16,.38);
  background: transparent; color: #c07060;
  cursor: pointer; border-radius: 2px; transition: all .2s; white-space: nowrap;
}
.admin-action-btn:hover { background: var(--ember); color: var(--parch); border-color: var(--ember-warm); }

.filter-row { display: flex; gap: .65rem; margin-bottom: 1.2rem; flex-wrap: wrap; align-items: center; }
.filter-select {
  background: var(--ink-deep); border: 1px solid var(--border);
  color: var(--parch); padding: .44rem .8rem;
  font-family: 'Crimson Pro', serif; font-size: .9rem;
  outline: none; border-radius: 2px; cursor: pointer;
  transition: border .2s;
}
.filter-select:focus { border-color: var(--gold-deep); }
.search-admin {
  background: var(--ink-deep); border: 1px solid var(--border);
  color: var(--parch); padding: .44rem .95rem;
  font-family: 'Crimson Pro', serif; font-size: .9rem;
  outline: none; border-radius: 2px; flex: 1; min-width: 140px;
  transition: border .2s;
}
.search-admin:focus { border-color: var(--gold-deep); }
.search-admin::placeholder { color: var(--parch-faint); font-style: italic; }

.export-btn {
  font-family: 'Cinzel', serif; font-size: .61rem; letter-spacing: 1.5px;
  border: 1px solid rgba(36,85,22,.65); background: rgba(18,38,10,.55); color: #7ac055;
  padding: .44rem 1rem; cursor: pointer; border-radius: 2px; transition: all .2s;
}
.export-btn:hover { background: rgba(28,58,16,.7); border-color: #4a8a2a; }
.export-btn.sheet-btn {
  border-color: rgba(22,76,90,.65); color: var(--teal-lite); background: rgba(8,18,26,.55);
}
.export-btn.sheet-btn:hover { background: rgba(10,28,38,.7); border-color: #3a8090; }
.no-records {
  text-align: center; padding: 2.8rem; font-style: italic;
  color: var(--parch-faint); font-size: .92rem;
}
.no-records::before {
  content: '◆ · · · ◆ · · · ◆';
  display: block; font-size: .5rem; letter-spacing: .3rem;
  color: rgba(212,168,67,.08); margin-bottom: .8rem;
}

/* ── GOOGLE SHEET SETUP ── */
.sheet-info {
  background: var(--ink-deep); border: 1px solid var(--border);
  border-radius: 3px; padding: 1.2rem 1.4rem; margin-bottom: 1.4rem;
}
.sheet-info h3 {
  font-family: 'Cinzel', serif; font-size: .7rem;
  letter-spacing: 2.5px; color: var(--gold); margin-bottom: .9rem;
}
.sheet-link {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: 'Cinzel', serif; font-size: .63rem; letter-spacing: 1.5px;
  color: var(--gold); border: 1px solid var(--gold-deep);
  padding: .44rem 1rem; border-radius: 2px;
  cursor: pointer; background: rgba(212,168,67,.05);
  transition: all .2s; text-decoration: none;
  margin-right: .5rem; margin-bottom: .5rem;
}
.sheet-link:hover { background: var(--gold-deep); color: var(--parch); }
.gs-setup {
  background: rgba(8,18,6,.7); border: 1px solid rgba(28,65,18,.55);
  border-radius: 3px; padding: 1.2rem 1.4rem; margin-top: 1.2rem;
}
.gs-setup h4 {
  font-family: 'Cinzel', serif; font-size: .63rem;
  letter-spacing: 2.5px; color: #8ab060; margin-bottom: .85rem;
}
.gs-setup p { font-size: .84rem; color: #7a8a5a; line-height: 1.68; margin-bottom: .5rem; }
.gs-setup strong { color: #b0cc70; }
.gs-setup code {
  font-size: .75rem; background: rgba(10,18,5,.9);
  border: 1px solid rgba(38,48,14,.9); padding: 1px 6px; color: #aac870; border-radius: 2px;
}
.code-block {
  background: rgba(6,14,4,.85); border: 1px solid rgba(24,48,15,.75);
  border-radius: 3px; padding: 1rem 1.1rem; margin: .9rem 0;
  font-size: .73rem; color: #6a9a4a; font-family: monospace;
  line-height: 1.8; white-space: pre-wrap; overflow-x: auto;
}
.gs-url-input {
  width: 100%; background: rgba(255,255,255,.03);
  border: 1px solid rgba(38,58,18,.75); color: var(--parch);
  padding: .62rem .95rem; font-family: 'Crimson Pro', serif; font-size: .92rem;
  outline: none; border-radius: 2px; margin: .5rem 0; transition: border .2s;
}
.gs-url-input:focus { border-color: rgba(75,135,28,.75); }
.connect-btn {
  font-family: 'Cinzel', serif; font-size: .63rem; letter-spacing: 2px;
  border: 1px solid rgba(38,96,22,.55); background: rgba(8,24,6,.65); color: #6aaa4a;
  padding: .5rem 1.4rem; cursor: pointer; border-radius: 2px; transition: all .2s;
}
.connect-btn:hover { background: rgba(22,48,14,.8); border-color: #4a8a2a; }
#sheetStatus { font-size: .82rem; margin-top: .5rem; font-style: italic; color: #5a8a3a; min-height: 1.2rem; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 2rem; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: linear-gradient(160deg, #2e1f0a, #1c1206);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-family: 'Cinzel', serif; font-size: .68rem; letter-spacing: 2.5px;
  padding: .8rem 1.8rem; border-radius: 3px;
  transition: transform .4s cubic-bezier(.34,1.56,.64,1);
  z-index: 200; white-space: nowrap; pointer-events: none;
  box-shadow: 0 10px 40px rgba(0,0,0,.7), 0 0 30px rgba(212,168,67,.18);
  display: flex; align-items: center; gap: .7rem;
}
.toast::before { content: '◆'; font-size: .45rem; color: var(--gold-dim); }
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
  .site-header { gap: .5rem; }
  .header-user { display: none; }
  .featured-banner { flex-direction: column; }
  .books-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 1rem; }
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .hero { padding: 2.8rem 1rem 2.2rem; }
  .admin-wrap { padding: 1rem; }
  .books-grid, .borrowed-shelf, .featured-banner { margin-left: 1rem; margin-right: 1rem; }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--ink-deep); }
::-webkit-scrollbar-thumb { background: var(--border-warm); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-deep); }

/* ── SELECTION ── */
::selection { background: rgba(212,168,67,.22); color: var(--gold-light); }

/* ── PROFILE PAGE ── */
#page-profile .admin-wrap .field-group input {
  background: rgba(255,255,255,.025);
}