/* ==========================================================================
   EX LIBRIS — WARM & CLASSIC LIBRARY STYLESHEET
   Palette: Parchment Cream, Antique Alabaster, Forest Green, Burnished Brass,
            Oxblood Burgundy, Walnut Wood, Deep Espresso Ink
   ========================================================================== */

:root {
  /* Backgrounds & Surfaces */
  --bg-parchment: #f6f1e7;
  --bg-parchment-deep: #ece3d2;
  --bg-card: #fcfaf5;
  --bg-sidebar: #182b20; /* Deep British Racing / Library Green */
  --bg-sidebar-hover: #223b2d;
  --bg-sidebar-active: #2a4737;

  /* Typography Colors */
  --ink-primary: #1e1915;
  --ink-secondary: #594e43;
  --ink-muted: #8a7c6d;
  --sidebar-text: #f3ece0;
  --sidebar-muted: #a6b8ad;

  /* Accents */
  --forest-primary: #1e3f2d;
  --forest-hover: #142c1f;
  --brass-gold: #c29b48;
  --brass-light: #dfbe73;
  --brass-subtle: rgba(194, 155, 72, 0.16);
  --oxblood: #7a2826;
  --oxblood-soft: rgba(122, 40, 38, 0.1);

  /* Borders & Shadows */
  --border-warm: #dcd0bc;
  --border-subtle: #e7decb;
  --shadow-soft: 0 4px 20px -2px rgba(30, 25, 21, 0.07), 0 2px 6px -1px rgba(30, 25, 21, 0.04);
  --shadow-book: 4px 6px 14px rgba(25, 20, 15, 0.18), 1px 2px 4px rgba(25, 20, 15, 0.12);
  --shadow-book-hover: 8px 14px 24px rgba(25, 20, 15, 0.25), 2px 4px 8px rgba(25, 20, 15, 0.15);
  --shadow-modal: 0 24px 48px rgba(20, 15, 10, 0.35);

  /* Fonts */
  --font-serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Transitions & Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition: 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background-color: var(--bg-parchment);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Subtle paper grain overlay */
.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.032;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   LAYOUT: SIDEBAR + MAIN STAGE
   ========================================================================== */

.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.sidebar {
  background: linear-gradient(180deg, #172a1f 0%, #122118 100%);
  color: var(--sidebar-text);
  padding: 28px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid #0e1a13;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-shadow: inset -1px 0 0 rgba(194, 155, 72, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(194, 155, 72, 0.22);
}

.ex-libris-seal {
  width: 44px;
  height: 44px;
  color: var(--brass-light);
  flex-shrink: 0;
}

.brand-sub {
  display: block;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--brass-light);
  font-weight: 600;
  text-transform: uppercase;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.05;
  color: #fffdf9;
  letter-spacing: 0.01em;
}

.btn-add-main {
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(135deg, #c9a24d 0%, #ae8430 100%);
  color: #16120c;
  border: 1px solid #dfbe73;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.btn-add-main:hover {
  background: linear-gradient(135deg, #d7b25f 0%, #bc9139 100%);
  transform: translateY(-1px);
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.sidebar-heading {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--brass-light);
  font-weight: 600;
  padding: 0 8px;
}

.sidebar-hint {
  font-size: 10.5px;
  color: var(--sidebar-muted);
  font-style: italic;
  font-family: var(--font-serif);
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--sidebar-text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-sans);
  font-size: 13.5px;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.nav-item:hover {
  background-color: var(--bg-sidebar-hover);
  color: #ffffff;
}

.nav-item.active {
  background-color: var(--bg-sidebar-active);
  border-color: rgba(194, 155, 72, 0.35);
  color: #fff;
  font-weight: 600;
}

.nav-label {
  display: flex;
  align-items: center;
  gap: 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-label svg {
  color: var(--brass-light);
  flex-shrink: 0;
  opacity: 0.85;
}

.badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-muted);
}

.nav-item.active .badge {
  background: var(--brass-gold);
  color: #16120c;
  font-weight: 600;
}

/* Genre Chips in Sidebar */
.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 6px;
}

.genre-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--sidebar-text);
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 99px;
  cursor: pointer;
  transition: var(--transition);
}

.genre-chip:hover {
  background: rgba(194, 155, 72, 0.2);
  border-color: var(--brass-light);
}

.genre-chip.active {
  background: var(--brass-gold);
  color: #16120c;
  border-color: var(--brass-light);
  font-weight: 600;
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(194, 155, 72, 0.2);
}

.archive-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--sidebar-muted);
  margin-bottom: 8px;
}

.archive-actions {
  display: flex;
  gap: 6px;
}

.archive-actions .btn {
  flex: 1;
  justify-content: center;
}

/* ==========================================================================
   MAIN CONTENT AREA & HEADER
   ========================================================================== */

.main-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 32px 42px 64px;
}

.top-header {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-warm);
  margin-bottom: 24px;
}

.header-top-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.collection-eyebrow {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--oxblood);
  font-weight: 600;
  margin-bottom: 4px;
}

.collection-heading {
  font-family: var(--font-serif);
  font-size: 40px;
  font-weight: 600;
  line-height: 1.05;
  color: var(--ink-primary);
}

/* Stats Ribbon */
.stats-ribbon {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  box-shadow: var(--shadow-soft);
  gap: 18px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--forest-primary);
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border-warm);
}

/* Search & View Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 11px 38px 11px 42px;
  background: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink-primary);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  border-color: var(--forest-primary);
  box-shadow: 0 0 0 3px rgba(30, 63, 45, 0.12);
}

.clear-search-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 20px;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 2px 6px;
}

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

.select-elegant {
  padding: 10px 32px 10px 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--ink-primary);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23594e43' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.view-switcher {
  display: flex;
  background: var(--bg-parchment-deep);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-warm);
}

.view-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  padding: 7px 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  transition: var(--transition);
}

.view-btn.active {
  background: var(--bg-card);
  color: var(--forest-primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Active Filter Pill Bar */
.active-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--brass-subtle);
  border: 1px solid rgba(194, 155, 72, 0.4);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 13.5px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--oxblood);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
}

/* ==========================================================================
   VIEW 1: GALLERY COVER GRID
   ========================================================================== */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 28px 24px;
}

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-soft);
  position: relative;
}

.book-card:hover {
  transform: translateY(-4px);
  border-color: var(--brass-gold);
  box-shadow: 0 12px 28px -6px rgba(30, 25, 21, 0.14);
}

.book-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 4px 8px 8px 4px;
  overflow: hidden;
  box-shadow: var(--shadow-book);
  background: var(--bg-parchment-deep);
  transition: var(--transition);
}

.book-card:hover .book-cover-wrap {
  box-shadow: var(--shadow-book-hover);
}

/* Realistic book spine crease effect */
.book-cover-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.22) 0%,
    rgba(255, 255, 255, 0.14) 4%,
    rgba(0, 0, 0, 0.06) 7%,
    transparent 14%
  );
  pointer-events: none;
}

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

/* Artisanal clothbound cover when no image is present */
.artisanal-cover {
  width: 100%;
  height: 100%;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  color: #f9f3e6;
  position: relative;
}

.artisanal-frame {
  width: 100%;
  height: 100%;
  border: 1.5px solid rgba(223, 190, 115, 0.55);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.artisanal-frame::before {
  content: '❧';
  font-size: 15px;
  color: var(--brass-light);
  opacity: 0.85;
}

.artisanal-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.artisanal-author {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brass-light);
  border-top: 1px solid rgba(223, 190, 115, 0.35);
  padding-top: 6px;
}

/* Status Pill on Cover */
.status-ribbon {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 99px;
  backdrop-filter: blur(6px);
}

.status-ribbon.reading {
  background: rgba(194, 155, 72, 0.92);
  color: #18130a;
}

.status-ribbon.completed {
  background: rgba(30, 63, 45, 0.9);
  color: #f6f1e7;
}

.status-ribbon.unread {
  background: rgba(30, 25, 21, 0.72);
  color: #f6f1e7;
}

.book-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.book-card-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card-author {
  font-size: 13px;
  color: var(--ink-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-card-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--border-warm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
}

.shelf-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--forest-primary);
  background: rgba(30, 63, 45, 0.08);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
  max-width: 125px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stars-display {
  color: var(--brass-gold);
  letter-spacing: 1px;
  font-size: 13px;
}

/* ==========================================================================
   VIEW 2: PHYSICAL WOODEN BOOKSHELVES VIEW
   ========================================================================== */

.shelves-container {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.bookcase-unit {
  background: #ede3d1;
  border: 1px solid #d3c3a8;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.bookcase-header {
  background: linear-gradient(90deg, #2b1d14 0%, #3d291d 50%, #2b1d14 100%);
  color: #f5ebd9;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #c29b48;
}

.bookcase- plaque {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bookcase-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #f9f1e1;
}

.bookcase-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--brass-light);
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid rgba(223, 190, 115, 0.3);
}

.wooden-shelf-bay {
  padding: 28px 28px 0 28px;
  background: linear-gradient(180deg, rgba(20, 14, 10, 0.08) 0%, rgba(20, 14, 10, 0.02) 100%);
  position: relative;
}

.shelf-books-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
  min-height: 210px;
}

/* Standing Book on Wooden Shelf */
.shelf-book-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.22s ease;
  position: relative;
}

.shelf-book-item:hover {
  transform: translateY(-10px) scale(1.03);
  z-index: 5;
}

.shelf-book-cover {
  width: 118px;
  height: 176px;
  border-radius: 3px 6px 6px 3px;
  overflow: hidden;
  box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.28);
  position: relative;
  background: #1e3f2d;
}

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

.shelf-plank {
  height: 22px;
  margin: 0 -28px;
  background: linear-gradient(180deg, #6b462b 0%, #4b301c 65%, #331f11 100%);
  border-top: 2px solid #865b3b;
  box-shadow: 0 8px 16px rgba(20, 12, 6, 0.25);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brass-shelf-label {
  background: linear-gradient(180deg, #dfc079 0%, #b88f3a 100%);
  color: #1f160a;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 12px;
  border-radius: 2px;
  border: 1px solid #755619;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ==========================================================================
   VIEW 3: ARCHIVAL LEDGER TABLE VIEW
   ========================================================================== */

.ledger-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-soft);
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.ledger-table th {
  background: var(--bg-parchment-deep);
  color: var(--ink-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-warm);
}

.ledger-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.ledger-row {
  cursor: pointer;
  transition: background 0.15s ease;
}

.ledger-row:hover {
  background: rgba(194, 155, 72, 0.08);
}

.ledger-title-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ledger-mini-cover {
  width: 34px;
  height: 50px;
  border-radius: 2px;
  object-fit: cover;
  box-shadow: 1px 2px 5px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.ledger-title-text {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-primary);
}

.ledger-isbn {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-muted);
}

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */

.empty-sanctum {
  text-align: center;
  padding: 72px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border-warm);
  border-radius: var(--radius-lg);
  max-width: 540px;
  margin: 24px auto;
}

.empty-sanctum h3 {
  font-family: var(--font-serif);
  font-size: 28px;
  margin-bottom: 8px;
}

.empty-sanctum p {
  color: var(--ink-secondary);
  margin-bottom: 20px;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background: var(--forest-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--forest-hover);
}

.btn-secondary {
  background: var(--brass-gold);
  color: #19130a;
}

.btn-secondary:hover {
  background: var(--brass-light);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--sidebar-text);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--brass-light);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-secondary);
  border-color: var(--border-warm);
}

.btn-ghost:hover {
  background: var(--bg-parchment-deep);
}

.btn-danger {
  background: var(--oxblood-soft);
  color: var(--oxblood);
  border-color: rgba(122, 40, 38, 0.25);
}

.btn-danger:hover {
  background: var(--oxblood);
  color: #fff;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.file-label {
  cursor: pointer;
}

/* ==========================================================================
   MODALS (ADD/EDIT & BOOK INSPECTOR)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 15, 12, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 760px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  position: relative;
  animation: modalFadeIn 0.22s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--border-warm);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--bg-parchment);
}

.modal-eyebrow {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--oxblood);
  font-weight: 700;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
}

.icon-close-btn {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0 6px;
}

.icon-close-btn:hover {
  color: var(--ink-primary);
}

.modal-body {
  padding: 24px 28px;
}

/* Open Library Auto-Fetch Box */
.autofetch-box {
  background: linear-gradient(135deg, rgba(30, 63, 45, 0.06) 0%, rgba(194, 155, 72, 0.1) 100%);
  border: 1px solid rgba(30, 63, 45, 0.22);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 22px;
}

.autofetch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.autofetch-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--forest-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.autofetch-desc {
  font-size: 12px;
  color: var(--ink-secondary);
}

.autofetch-search-row {
  display: flex;
  gap: 8px;
}

.autofetch-search-row input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: #fff;
}

.api-results-drawer {
  margin-top: 12px;
  max-height: 210px;
  overflow-y: auto;
  border-top: 1px solid var(--border-warm);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.api-result-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.api-result-thumb {
  width: 32px;
  height: 46px;
  object-fit: cover;
  border-radius: 2px;
  background: var(--bg-parchment-deep);
  flex-shrink: 0;
}

/* Form Layout */
.form-grid-top {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 22px;
  margin-bottom: 20px;
}

.cover-preview-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.cover-preview-frame {
  width: 140px;
  height: 206px;
  border-radius: 4px 8px 8px 4px;
  overflow: hidden;
  box-shadow: var(--shadow-book);
  background: var(--forest-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--brass-light);
  font-family: var(--font-serif);
}

.placeholder-ornament {
  font-size: 28px;
}

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

.spine-color-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-secondary);
  cursor: pointer;
}

.spine-color-label input[type="color"] {
  border: 1px solid var(--border-warm);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
}

.primary-fields-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.flex-2 { flex: 2; }
.flex-1 { flex: 1; }

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.req {
  color: var(--oxblood);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  background: #fff;
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--ink-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--forest-primary);
}

.form-section-box {
  background: var(--bg-parchment);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-box-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--forest-primary);
}

/* Star Rating Picker */
.star-picker {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.star-btn {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #d4c7b4;
  cursor: pointer;
  transition: transform 0.12s ease, color 0.12s ease;
}

.star-btn.active,
.star-btn:hover {
  color: var(--brass-gold);
  transform: scale(1.12);
}

.clear-rating-btn {
  margin-left: 8px;
  background: none;
  border: none;
  font-size: 11.5px;
  color: var(--ink-muted);
  text-decoration: underline;
  cursor: pointer;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-warm);
}

/* ==========================================================================
   DETAIL INSPECTOR MODAL (EX LIBRIS CARD)
   ========================================================================== */

.detail-card {
  max-width: 680px;
  padding: 32px;
  background: var(--bg-card);
}

.detail-close {
  position: absolute;
  top: 18px;
  right: 22px;
}

.detail-layout {
  display: grid;
  grid-template-columns: 185px 1fr;
  gap: 28px;
}

.detail-cover-box {
  width: 185px;
  aspect-ratio: 2 / 3;
  border-radius: 4px 8px 8px 4px;
  overflow: hidden;
  box-shadow: var(--shadow-book-hover);
}

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

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-genre-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--oxblood);
  background: var(--oxblood-soft);
  padding: 3px 10px;
  border-radius: 99px;
}

.detail-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
}

.detail-author {
  font-size: 16px;
  color: var(--ink-secondary);
}

.detail-coordinates-box {
  background: var(--bg-parchment);
  border: 1px solid var(--border-warm);
  border-left: 4px solid var(--forest-primary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.coord-item {
  display: flex;
  flex-direction: column;
}

.coord-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

.coord-value {
  font-weight: 600;
  color: var(--forest-primary);
  font-size: 14px;
}

.detail-specs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-top: 1px dashed var(--border-warm);
  border-bottom: 1px dashed var(--border-warm);
  font-size: 13px;
}

.detail-notes-box {
  background: #faf6ed;
  border: 1px solid var(--border-subtle);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-serif);
  font-size: 17px;
  font-style: italic;
  color: var(--ink-primary);
  line-height: 1.45;
  white-space: pre-wrap;
}

.detail-actions {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--border-warm);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #182b20;
  color: #f6f1e7;
  border-left: 4px solid var(--brass-gold);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
  font-size: 13.5px;
  animation: modalFadeIn 0.2s ease-out;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 960px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
  }

  .main-content {
    padding: 24px 20px 48px;
  }

  .form-grid-top,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
  }
}
