/* =============================================================
   Olivia's Bookshelf — cozy bookshelf 📚
   Warm browns and creams, soft matte buttons, a literary serif for
   headings. Mobile-first and comfy.
   ============================================================= */
:root {
  --bg: #241a0f;          /* dark oak */
  --card: #f2e4c6;        /* aged parchment (a lit page) */
  --ink: #33240f;         /* espresso — text on cards */
  --muted: #7a5f42;       /* walnut — muted text on cards */
  --faint: #a3865f;       /* light walnut */
  --on-bg: #edd8ad;       /* warm candlelight — text on the dark wood */
  --on-bg-muted: #c2a87e; /* dimmer candlelight */
  --accent: #c1853a;      /* candle honey */
  --accent-deep: #9c5a26; /* amber (links on cards) */
  --sage: #6f7d52;        /* muted olive */
  --slate: #5f7069;       /* dusty teal */
  --gold: #d8a53a;        /* candle gold (stars) */
  --danger: #b0532f;      /* terracotta */
  --border: #d8c19a;      /* borders on cards */
  --border-strong: #c6ab7f;
  --grad: linear-gradient(135deg, #c1853a, #955322);
  --grad-soft: linear-gradient(135deg, #e6cfa5, #d9bd8b);
  --chrome: linear-gradient(120deg, #edcb8b, #c1853a);  /* gilt title on dark wood */
  --radius: 16px;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.28), 0 14px 30px -14px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 18px 42px -14px rgba(0, 0, 0, 0.62);
  --font-display: "Fraunces", Georgia, serif;
  font-family: Nunito, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

::selection { background: #c1853a; color: #2a1c0a; }

body {
  margin: 0;
  /* dark oak with a warm candle glow up top and embers below */
  background:
    radial-gradient(680px 440px at 80% -12%, rgba(224, 158, 74, 0.38) 0%, rgba(224, 158, 74, 0) 60%),
    radial-gradient(520px 400px at 8% 2%, rgba(186, 126, 58, 0.22) 0%, rgba(186, 126, 58, 0) 62%),
    radial-gradient(1000px 620px at 50% 118%, rgba(150, 96, 44, 0.28) 0%, rgba(150, 96, 44, 0) 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.6;
  font-weight: 400;
}

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 2px; }

h1, h2 { font-family: var(--font-display); letter-spacing: -0.005em; }

/* ---- Header ---- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem clamp(1rem, 4vw, 2.2rem);
  background: rgba(30, 21, 12, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(193, 133, 58, 0.28);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  background: var(--chrome);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.01em;
}
.brand:hover { text-decoration: none; filter: brightness(1.06); }

.site-header nav { display: flex; align-items: center; gap: 0.15rem; }

.site-header nav a {
  color: var(--on-bg);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  transition: background 0.15s ease;
}
.site-header nav a:hover { background: rgba(193, 133, 58, 0.18); text-decoration: none; }

.nav-user { margin-left: 0.6rem; color: var(--on-bg-muted); font-size: 0.85rem; }
.logout-form { display: inline; margin-left: 0.2rem; }

.linklike {
  background: none;
  border: none;
  color: var(--on-bg-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
}
.linklike:hover { background: rgba(193, 133, 58, 0.18); color: var(--on-bg); }

/* ---- Layout ---- */
.content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 2.2rem) 3.5rem;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.4rem;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  font-weight: 700;
  /* gilt lettering that reads on the dark wood */
  background: linear-gradient(120deg, #f2e1bd 20%, var(--gold) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hint { color: var(--muted); margin-top: -0.6rem; font-size: 0.95rem; }
/* Page-level hints sit on the dark wood; card hints keep the walnut color. */
.content > .hint, #stats-root > .hint { color: var(--on-bg-muted); }
.empty-state { color: var(--on-bg-muted); text-align: center; padding: 3rem 0; font-size: 1rem; }
.empty-state::before { content: "❦"; display: block; font-size: 1.5rem; color: var(--accent); margin-bottom: 0.4rem; }

/* ---- Buttons (soft matte) ---- */
.button {
  position: relative;
  display: inline-block;
  background: var(--grad);
  color: #fff;
  padding: 0.62rem 1.35rem;
  border-radius: 999px;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  isolation: isolate;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 4px 12px -4px rgba(120, 80, 40, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.button::before {
  /* a whisper of top sheen, not a gel cap */
  content: "";
  position: absolute;
  inset: 1px 10% auto 10%;
  height: 38%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 8px 18px -6px rgba(120, 80, 40, 0.6);
  text-decoration: none;
}
.button.secondary {
  background: #fff;
  color: var(--accent-deep);
  border: 1.5px solid var(--border-strong);
  box-shadow: 0 2px 8px -2px rgba(120, 85, 45, 0.12);
}
.button.secondary::before { display: none; }
.button.secondary:hover { border-color: #d8bd93; background: #fbf3e5; filter: none; }
.button.danger { background: linear-gradient(135deg, #c56a42, var(--danger)); }
.button:disabled {
  background: #e6dac6;
  color: var(--faint);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.button:disabled::before { display: none; }

input[type="search"], input[type="text"], input[type="password"],
input[type="number"], input[type="date"], input[type="file"], textarea, select {
  font-family: inherit;
  font-size: 0.97rem;
  font-weight: 500;
  padding: 0.66rem 1rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea, input[type="file"] { border-radius: 16px; }
input:focus, textarea:focus, select:focus {
  border-color: #cfa76b;
  box-shadow: 0 0 0 3px rgba(169, 104, 47, 0.14);
}
input::placeholder, textarea::placeholder { color: var(--faint); }

/* ---- Toolbar / filters ---- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

#search-input { flex: 1; min-width: 220px; }

.filter-group { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.filter-btn, .tag-chip {
  background: var(--card);
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s ease;
}
.filter-btn:hover, .tag-chip:hover { border-color: #d8bd93; color: var(--accent-deep); }
.filter-btn.active, .tag-chip.active {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px -4px rgba(150, 95, 45, 0.5);
}

.search-form { display: flex; gap: 0.6rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.search-form input { flex: 1; min-width: 200px; }

/* ---- Book grid (the shelf) ---- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1.6rem 1.15rem;
}

.book-card { display: block; text-decoration: none; color: inherit; }
.book-card:hover { text-decoration: none; }

/* ---- Spine view ---- */
.shelf-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}
.shelf-controls .tag-filters { margin-bottom: 0; flex: 1; }
.view-toggle { flex-shrink: 0; }

.spine-shelf {
  --slot-h: 196px;
  --shelf-gap: 26px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  column-gap: 5px;
  padding: 0 10px;
  /* One soft shelf line per row, drawn under the spines' baseline. */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent var(--slot-h),
    #d8c09a var(--slot-h),
    #cbb488 calc(var(--slot-h) + 3px),
    rgba(150, 120, 80, 0.14) calc(var(--slot-h) + 3px),
    rgba(150, 120, 80, 0) calc(var(--slot-h) + 10px),
    transparent calc(var(--slot-h) + var(--shelf-gap))
  );
}

.spine {
  width: var(--spine-w, 44px);
  height: var(--slot-h);
  margin-bottom: var(--shelf-gap);
  display: flex;
  align-items: flex-end;
  text-decoration: none;
}
.spine:hover { text-decoration: none; }

.spine-body {
  position: relative;
  width: 100%;
  height: var(--spine-h, 170px);
  border-radius: 4px 4px 2px 2px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--spine-bg, var(--grad));
  box-shadow: 1px 2px 7px rgba(120, 90, 50, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.spine:hover .spine-body {
  transform: translateY(-8px);
  box-shadow: 2px 10px 18px rgba(120, 90, 50, 0.42), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.spine-label {
  position: relative;
  z-index: 2;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  color: var(--spine-fg, #fff);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  max-height: 84%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spine-mark {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(40, 28, 15, 0.35);
}
.spine-mark.finished {
  width: auto;
  height: auto;
  background: none;
  box-shadow: none;
  font-size: 0.62rem;
  line-height: 1;
}

.book-cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 16px;
  overflow: hidden;
  background: #efe2cd;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.book-card:hover .book-cover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-pop);
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Pastel title card shown wherever a cover is missing or fails to load. */
.book-cover.placeholder,
.poster-img.placeholder,
.cover-large.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem;
  background: var(--ph-bg, var(--grad-soft));
}
.ph-title {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ph-fg, #8a5730);
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent-deep);
  box-shadow: 0 2px 8px rgba(80, 55, 30, 0.18);
  backdrop-filter: blur(4px);
}

.book-meta { padding: 0.55rem 0.2rem 0; }
.book-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--on-bg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-author {
  color: var(--on-bg-muted);
  font-size: 0.78rem;
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Poster browse (Find Books) ---- */
.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.4rem 1.1rem;
  padding: 4px 0;
}

.poster {
  position: relative;
  border: none;
  padding: 0;
  background: #efe2cd;
  cursor: pointer;
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.poster:hover,
.poster:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-pop);
  outline: none;
}
.poster-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.poster-img.placeholder { aspect-ratio: 2 / 3; }
.poster-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1.4rem 0.6rem 0.55rem;
  background: linear-gradient(to top, rgba(43, 30, 16, 0.85), rgba(43, 30, 16, 0));
  color: #fff;
  opacity: 0;
  transition: opacity 0.18s ease;
  text-align: left;
}
.poster:hover .poster-overlay,
.poster:focus-visible .poster-overlay { opacity: 1; }
.poster-title {
  font-size: 0.8rem;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(46, 32, 18, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
}
.modal {
  position: relative;
  background: var(--card);
  border: 1px solid #fff;
  border-radius: 24px;
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  display: flex;
  gap: 1.4rem;
  padding: 1.7rem;
  box-shadow: 0 30px 80px -20px rgba(60, 40, 20, 0.5);
}
.modal .cover-large { width: 170px; border-radius: 14px; }
.modal-body { flex: 1; min-width: 220px; }
.modal-body h2 { margin: 0 0 0.15rem; font-size: 1.25rem; }
.modal-body .author { color: var(--muted); font-weight: 500; }
.modal-body .meta { color: var(--faint); font-size: 0.83rem; margin: 0.2rem 0 0.6rem; }
.modal-body .description {
  font-size: 0.9rem;
  margin: 0.6rem 0 0;
  max-height: 40vh;
  overflow: auto;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: #f0e6d5;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
}
.modal-close:hover { background: #e9dcc4; color: var(--ink); }

/* ---- Book detail ---- */
.back-link { display: inline-block; margin-bottom: 1.1rem; font-weight: 600; font-size: 0.9rem; color: var(--on-bg-muted); }
.back-link:hover { color: var(--on-bg); text-decoration: none; }

.book-detail {
  display: flex;
  gap: 1.9rem;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.8rem;
  box-shadow: var(--shadow-card);
}

.cover-large {
  width: 180px;
  border-radius: 14px;
  flex-shrink: 0;
  box-shadow: 0 14px 30px -10px rgba(120, 80, 45, 0.35);
}
.cover-large.placeholder { aspect-ratio: 2 / 3; }
.cover-large.placeholder .ph-title { font-size: 1.05rem; -webkit-line-clamp: 6; }

.cover-wrap { flex-shrink: 0; display: flex; flex-direction: column; gap: 0.6rem; align-items: center; }
.cover-change-btn {
  background: #fff;
  color: var(--accent-deep);
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cover-change-btn:hover { border-color: #d8bd93; background: #fbf3e5; }

.cover-picker { max-width: 560px; }
.cover-picker-body { flex: 1; }
.cover-picker-body h2 { margin: 0 0 0.15rem; font-size: 1.2rem; }
.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}
.cover-option {
  position: relative;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #efe2cd;
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.cover-option:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }
.cover-option.current { border-color: var(--accent); }
.cover-option img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-current-tag {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--accent);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0.15rem;
  text-align: center;
}

.book-detail-main { flex: 1; min-width: 240px; }
.book-detail-main h2 { margin: 0 0 0.15rem; font-size: 1.35rem; }
.book-detail-main .author { color: var(--muted); margin-bottom: 0.75rem; font-weight: 500; }
.book-detail-main .description { font-size: 0.92rem; margin-bottom: 1.25rem; color: #574636; }

.field-row { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1rem; }

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.hint-inline { color: var(--muted); font-weight: 500; font-size: 0.72rem; text-transform: none; letter-spacing: 0; }

.spine-picker { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.spine-swatch {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.spine-swatch:hover { transform: translateY(-2px); }
.spine-swatch.selected { border-color: var(--ink); }
.spine-swatch.default {
  background: var(--card);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
}

.star-picker { display: inline-flex; gap: 0.2rem; font-size: 1.5rem; cursor: pointer; }
.star-picker .star { color: #e2d3b6; transition: transform 0.12s ease, color 0.12s ease; }
.star-picker .star:hover { transform: scale(1.2); }
.star-picker .star.filled { color: var(--gold); }

.stars { color: var(--gold); font-size: 0.95rem; letter-spacing: 1px; }

textarea { width: 100%; min-height: 90px; resize: vertical; }

.actions-row { display: flex; gap: 0.6rem; margin-top: 1.25rem; flex-wrap: wrap; }

.extension-point {
  margin-top: 1.6rem;
  padding: 1.1rem 1.2rem;
  border: 1.5px dashed var(--border-strong);
  border-radius: 16px;
  color: var(--muted);
  font-size: 0.9rem;
  background: #fbf5ea;
}
.extension-point strong { color: var(--ink); }

/* ---- Auth ---- */
.auth-card {
  position: relative;
  max-width: 390px;
  margin: 3.2rem auto;
  background: var(--card);
  border: 1px solid #fff;
  border-radius: 26px;
  padding: 2.2rem 2rem;
  box-shadow: 0 1px 2px rgba(80, 55, 30, 0.05), 0 24px 60px -20px rgba(150, 100, 55, 0.3);
}
.auth-card::before {
  /* soft y2k glow behind the card */
  content: "";
  position: absolute;
  inset: -40px -60px auto;
  height: 180px;
  background:
    radial-gradient(200px 120px at 20% 40%, rgba(200, 150, 90, 0.25), transparent 70%),
    radial-gradient(220px 130px at 80% 30%, rgba(150, 168, 120, 0.22), transparent 70%);
  z-index: -1;
  pointer-events: none;
}
.auth-card h1 { margin: 0 0 0.25rem; font-size: 1.4rem; }

.auth-form { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 1.4rem; }
.auth-form label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.auth-form input { margin-bottom: 0.8rem; }
.auth-form .button { margin-top: 0.5rem; }

/* The "make an account" / "sign in" line under the form needs breathing
   room from the button (base .hint pulls itself up under headings). */
.auth-form + .hint { margin-top: 1.2rem; margin-bottom: 0; }

.auth-error {
  background: #f6e6d8;
  color: #9a4426;
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 500;
  margin: 0.6rem 0 0;
}

/* ---- Account page ---- */
.account-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1.6rem 1.7rem;
  margin-bottom: 1.4rem;
  box-shadow: var(--shadow-card);
  max-width: 620px;
}
.account-card h2 { margin: 0 0 0.3rem; font-size: 1.1rem; }
.account-card .auth-form { max-width: 340px; }

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
}
.user-row:first-child { border-top: none; }
.user-info { display: flex; flex-direction: column; }
.user-meta { color: var(--muted); font-size: 0.82rem; }

.temp-password {
  flex-basis: 100%;
  background: var(--grad-soft);
  border-radius: 14px;
  padding: 0.8rem 1rem;
  margin: 0.2rem 0 0;
  font-size: 0.92rem;
}
.temp-password code {
  font-size: 1.02rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.75);
  padding: 0.15rem 0.5rem;
  border-radius: 8px;
  user-select: all;
}

/* ---- Hidden arcade (Konami code) ---- */
.arcade-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(30, 20, 10, 0.82);
  backdrop-filter: blur(6px);
}
.arcade-frame {
  position: relative;
  width: min(760px, 96vw);
  aspect-ratio: 4 / 3;
  max-height: 90vh;
  background: #1c130a;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7), 0 0 0 2px rgba(200, 150, 90, 0.4);
}
.arcade-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.arcade-msg {
  color: #fff;
  font-family: var(--font-display, sans-serif);
  text-align: center;
  line-height: 1.6;
}
.arcade-msg span { font-family: Outfit, sans-serif; font-size: 0.85rem; color: #d8c0a0; }
.arcade-msg code {
  background: rgba(255, 255, 255, 0.12);
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  font-size: 0.85rem;
}
.arcade-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
}
.arcade-close:hover { background: rgba(255, 255, 255, 0.3); }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 1.4rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.65rem 1.3rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(40, 28, 15, 0.35);
  z-index: 60;
}
.toast.error { background: var(--danger); }

/* ---- Reading goal card + progress ring ---- */
.goal-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.1rem 1.4rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
}
.goal-text { display: flex; flex-direction: column; gap: 0.15rem; }
.goal-text strong { font-size: 1rem; }
.goal-text span { color: var(--muted); font-size: 0.9rem; }
.goal-text a { font-weight: 600; font-size: 0.87rem; margin-top: 0.15rem; }
.goal-set { display: flex; gap: 0.5rem; margin-top: 0.4rem; }
.goal-set input { width: 110px; }

.ring { flex-shrink: 0; }
.ring-track { fill: none; stroke: #e6d6bd; stroke-width: 8; }
.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dasharray 0.6s ease;
}
.ring-text {
  fill: var(--ink);
  font-size: 19px;
  font-weight: 600;
  text-anchor: middle;
  font-family: Outfit, sans-serif;
}

/* ---- Recap / stats page ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.6rem;
}
.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.2rem 1rem 1.05rem;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
}
.stat-label { color: var(--muted); font-size: 0.82rem; margin-top: 0.3rem; }
.recap-goal { max-width: 440px; }
.recap-subhead { font-size: 1.05rem; margin: 1.4rem 0 0.75rem; color: var(--on-bg); }
.top-list { list-style: none; padding: 0; margin: 0; }
.top-list li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.65rem 1rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 2px rgba(80, 55, 30, 0.04);
}
.top-stars { color: var(--gold); }
.top-author { color: var(--muted); font-size: 0.86rem; }

/* ---- Tags / shelves ---- */
.find-covers-btn { margin-bottom: 1.4rem; font-size: 0.86rem; padding: 0.45rem 1rem; }

.tag-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.4rem; }
.tag-chip { padding: 0.32rem 0.85rem; }
.tag-count { opacity: 0.65; font-size: 0.76rem; }

.tag-editor { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.tag-chip.solid {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--grad-soft);
  color: #8a5730;
  border: none;
  cursor: default;
}
.tag-remove {
  border: none;
  background: rgba(130, 100, 60, 0.14);
  color: #8a5730;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 0.68rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.tag-remove:hover { background: rgba(130, 100, 60, 0.28); }
.tag-add { display: flex; gap: 0.5rem; }
.tag-add input { flex: 1; }

/* ---- Barcode scanner ---- */
.scanner {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.2rem;
  margin-bottom: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.scanner-inner {
  position: relative;
  max-width: 420px;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  background: #241a10;
  aspect-ratio: 4 / 3;
}
#scanner-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-reticle {
  position: absolute;
  inset: 25% 12%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  box-shadow: 0 0 0 2000px rgba(30, 20, 10, 0.3);
}
.scanner-manual {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 0.8rem 0;
  flex-wrap: wrap;
}
.scanner-manual input { max-width: 220px; }

@media (max-width: 560px) {
  .site-header { flex-wrap: wrap; justify-content: center; gap: 0.2rem 0.1rem; }
  .site-header nav { flex-wrap: wrap; justify-content: center; width: 100%; }
  .site-header nav a { padding: 0.4rem 0.6rem; font-size: 0.88rem; }
  .brand { width: 100%; text-align: center; }
  .nav-user { margin-left: 0.3rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .modal { flex-direction: column; }
  .modal .cover-large { width: 130px; align-self: center; }
  .goal-card { flex-direction: column; text-align: center; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 1.2rem 0.8rem; }
  .poster-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
}
