/*
 * ╔═══════════════════════════════════════════════════════════════╗
 * ║  BINGERY — styles.css                                        ║
 * ║  Dark-mode-first, fully responsive stylesheet.               ║
 * ║  Uses CSS custom properties (variables) for consistent        ║
 * ║  theming and easy customisation.                             ║
 * ║                                                              ║
 * ║  Table of Contents:                                          ║
 * ║  1.  Custom Properties (Design Tokens)                       ║
 * ║  2.  CSS Reset & Base Styles                                 ║
 * ║  3.  Utility / Accessibility Helpers                         ║
 * ║  4.  Layout — App Shell                                      ║
 * ║  5.  Header & Branding                                       ║
 * ║  6.  Search Bar                                              ║
 * ║  7.  Filter Panel (Sidebar)                                  ║
 * ║  8.  Filter Chips & Sort Select                              ║
 * ║  9.  Stats Bar                                               ║
 * ║  10. Media Grid                                              ║
 * ║  11. Media Card                                              ║
 * ║  12. Type Badge Colors                                       ║
 * ║  13. Status Badge Colors                                     ║
 * ║  14. Loading / Empty / Error States                          ║
 * ║  15. Modal Overlay                                           ║
 * ║  16. Modal Content Layout                                    ║
 * ║  17. Animations & Transitions                                ║
 * ║  18. Responsive Breakpoints                                  ║
 * ╚═══════════════════════════════════════════════════════════════╝
 */

/* ═══════════════════════════════════════════════════════════════
   1. CUSTOM PROPERTIES (Design Tokens)
   All colours, spacing, and typography values live here for
   easy theming. Override any variable to change the whole UI.
═══════════════════════════════════════════════════════════════ */
:root {
  /* ── Colour palette ── */
  --bg-primary:      #0d0f14;   /* Main page background */
  --bg-secondary:    #131720;   /* Card / sidebar backgrounds */
  --bg-elevated:     #1a1f2e;   /* Hover states, modal bg */
  --bg-overlay:      rgba(0, 0, 0, 0.75); /* Modal backdrop */

  --border:          #252b3b;   /* Subtle borders */
  --border-focus:    #4a80d4;   /* Keyboard focus rings */

  --text-primary:    #e8eaf0;   /* Main text */
  --text-secondary:  #8a90a8;   /* Muted labels, metadata */
  --text-muted:      #4a5068;   /* Placeholder, disabled text */

  --accent:          #4a80d4;   /* Primary interactive accent (blue) */
  --accent-hover:    #6298e8;   /* Accent on hover */
  --accent-subtle:   rgba(74, 128, 212, 0.15); /* Tinted backgrounds */

  --danger:          #e85050;   /* Error states */
  --warning:         #e8c030;   /* Warning / in-progress */
  --success:         #40c870;   /* Completed status */

  /* ── Type-badge colours (per media type) ── */
  --type-anime:      #e8703a;
  --type-manga:      #30c8c0;
  --type-manhwa:     #a060e0;
  --type-manhua:     #e878a8;
  --type-book:       #70c038;
  --type-movie:      #e8c030;

  /* ── Status colours ── */
  --status-completed:    #40c870;
  --status-in-progress:  #e8c030;
  --status-dropped:      #e85050;
  --status-planned:      #4a80d4;

  /* ── Rating colour ── */
  --star-fill:       #e8c030;
  --star-empty:      #2a3048;

  /* ── Spacing scale (multiples of 4 px) ── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ── Typography ── */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code",
               Menlo, Consolas, monospace;

  --text-xs:   0.70rem;   /* 11.2 px */
  --text-sm:   0.80rem;   /* 12.8 px */
  --text-base: 0.9375rem; /* 15 px   */
  --text-md:   1.0625rem; /* 17 px   */
  --text-lg:   1.25rem;   /* 20 px   */
  --text-xl:   1.5rem;    /* 24 px   */
  --text-2xl:  1.875rem;  /* 30 px   */

  --weight-regular: 400;
  --weight-medium:  500;
  --weight-bold:    700;

  /* ── Borders & Shapes ── */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  /* ── Shadows ── */
  --shadow-card:   0 2px 12px rgba(0, 0, 0, 0.5);
  --shadow-modal:  0 8px 48px rgba(0, 0, 0, 0.75);
  --shadow-focus:  0 0 0 3px rgba(74, 128, 212, 0.45);

  /* ── Layout ── */
  --header-height: 64px;
  --sidebar-width: 240px;
  --card-min-width: 160px;

  /* ── Transitions ── */
  --transition-fast:   120ms ease-out;
  --transition-normal: 220ms ease-out;
  --transition-slow:   350ms ease-out;
}

/* ═══════════════════════════════════════════════════════════════
   2. CSS RESET & BASE STYLES
   Opinionated reset based on modern best practices.
═══════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Ensure the HTML `hidden` attribute always hides elements regardless of
   display properties set by other rules (e.g. display: flex on .empty-state). */
[hidden] { display: none !important; }

html {
  /* Smooth scroll for in-page navigation */
  scroll-behavior: smooth;
  /* Improve font rendering */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  /* Prevent horizontal scroll from accidental overflow */
  overflow-x: hidden;
  min-height: 100dvh;
}

/* Reset list styles */
ul, ol { list-style: none; }

/* Reset button defaults */
button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* Reset anchor defaults */
a {
  color: inherit;
  text-decoration: none;
}

/* Reset input defaults */
input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  background: none;
  outline: none;
}

/* Reset image defaults */
img, svg {
  display: block;
  max-width: 100%;
}

/* Remove default fieldset / legend styles */
fieldset { border: none; }

/* Code element */
code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--bg-elevated);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

/* ═══════════════════════════════════════════════════════════════
   3. UTILITY / ACCESSIBILITY HELPERS
═══════════════════════════════════════════════════════════════ */

/* Visually hide content while keeping it accessible to screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip-link for keyboard users — jumps past header to main content */
.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 9999;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  transform: translateY(-200%);
  transition: transform var(--transition-fast);
}
.skip-link:focus {
  transform: translateY(0);
}

/* Standard focus ring — applied globally */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Body scroll lock — applied via JS classList when a modal is open.
   Uses a CSS class instead of element.style to stay CSP-compliant. */
body.modal-open { overflow: hidden; }

/* ═══════════════════════════════════════════════════════════════
   4. LAYOUT — APP SHELL
═══════════════════════════════════════════════════════════════ */

/* Full-viewport layout with sticky header */
.app-layout {
  display: flex;
  min-height: calc(100dvh - var(--header-height));
  margin-top: var(--header-height);
}

/* ═══════════════════════════════════════════════════════════════
   5. HEADER & BRANDING
═══════════════════════════════════════════════════════════════ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  /* Glass-like depth with a subtle shadow */
  box-shadow: 0 1px 16px rgba(0, 0, 0, 0.4);
}

.header-inner {
  max-width: 1600px;
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* ── Brand / Logo ── */
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  user-select: none;
}

.brand-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.brand-name {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* ── Filter toggle button (visible on mobile only) ── */
.filter-toggle {
  display: none; /* hidden on desktop; shown via media query below */
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast);
}
.filter-toggle svg { width: 18px; height: 18px; }
.filter-toggle:hover,
.filter-toggle[aria-expanded="true"] {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   6. SEARCH BAR
═══════════════════════════════════════════════════════════════ */
.search-wrapper {
  flex: 1;
  position: relative;
  max-width: 480px;
}

.search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-8) 0 calc(var(--space-3) + 18px + var(--space-2));
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px; /* fully rounded pill shape */
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
              background var(--transition-fast);
}
/* Override browser's default search-input decorations */
.search-input::-webkit-search-cancel-button { display: none; }
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--border-focus);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-focus);
}
.search-input:focus ~ .search-icon,
.search-wrapper:focus-within .search-icon {
  color: var(--accent);
}

/* Clear button inside search field */
.search-clear {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.search-clear svg { width: 14px; height: 14px; }
.search-clear:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
/* Hidden by default; shown via app.js when input has value */
.search-clear[hidden] { display: none; }

/* ═══════════════════════════════════════════════════════════════
   7. FILTER PANEL (Sidebar)
═══════════════════════════════════════════════════════════════ */
.filter-panel {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding: var(--space-6) var(--space-4);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  /* Stick to viewport top (below header) */
  position: sticky;
  top: var(--header-height);
  height: calc(100dvh - var(--header-height));
  /* Smooth scroll within the sidebar */
  overscroll-behavior: contain;
}

/* Each filter group */
.filter-section {
  margin-bottom: var(--space-6);
}

/* Section heading */
.filter-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

/* Reset button at the bottom of the sidebar */
.reset-btn {
  width: 100%;
  padding: var(--space-2) var(--space-4);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast);
}
.reset-btn:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════
   8. FILTER CHIPS & SORT SELECT
═══════════════════════════════════════════════════════════════ */

/* Container for chip groups */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Genre chips wrap more so allow extra room */
.genre-chips { max-height: 200px; overflow-y: auto; }

/* Individual filter chip button */
.chip {
  padding: 3px var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), transform var(--transition-fast);
  user-select: none;
}
.chip:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}
/* Active / selected chip */
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip:active { transform: scale(0.96); }

/* Sort dropdown */
.sort-select-wrapper {
  position: relative;
}

.sort-select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  /* Custom dropdown arrow using CSS */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9' fill='none' stroke='%238a90a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-2) center;
  background-size: 18px;
  padding-right: 32px;
  transition: border-color var(--transition-fast);
}
.sort-select:hover { border-color: var(--text-secondary); }
.sort-select:focus { border-color: var(--border-focus); box-shadow: var(--shadow-focus); }
.sort-select option { background: var(--bg-secondary); }

/* ═══════════════════════════════════════════════════════════════
   9. STATS BAR
═══════════════════════════════════════════════════════════════ */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.results-count {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
}

.stats-meta {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Small type stat badge */
.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════
   10. MEDIA GRID
   Responsive auto-fill grid that adapts the number of columns
   to the available viewport width.
═══════════════════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  min-width: 0; /* prevent overflow in flex child */
  display: flex;
  flex-direction: column;
}

.media-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width), 1fr));
  gap: var(--space-4);
  padding: var(--space-5);
  align-content: start;
}

/* ═══════════════════════════════════════════════════════════════
   11. MEDIA CARD
   Each card represents one media entry.
═══════════════════════════════════════════════════════════════ */
.media-card {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  /* Remove default list-item role styling */
  list-style: none;
  /* Allow the card to grow to fill its grid cell */
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal),
              border-color var(--transition-normal);
  /* Performance hint: promote to its own compositor layer */
  will-change: transform;
}

.media-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card), 0 8px 32px rgba(0, 0, 0, 0.4);
  border-color: var(--accent);
}

.media-card:focus-visible {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  outline: none;
}

/* Cover image container — maintains 2:3 aspect ratio */
.card-cover-wrap {
  position: relative;
  width: 100%;
  /* Intrinsic aspect ratio: width / height = 2 / 3 */
  aspect-ratio: 2 / 3;
  background: var(--bg-elevated);
  overflow: hidden;
}

/* Cover image — fills the container, cropped to fit */
.card-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transition: transform var(--transition-slow), filter var(--transition-slow);
}
.media-card:hover .card-cover {
  transform: scale(1.04);
  filter: brightness(0.85);
}

/* Overlay shown on card hover — provides visual affordance */
.card-hover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.75) 0%,
    transparent 50%
  );
  opacity: 0;
  transition: opacity var(--transition-normal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: var(--space-4);
}
.media-card:hover .card-hover-overlay { opacity: 1; }

.card-hover-cta {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
  padding: var(--space-1) var(--space-3);
  border-radius: 20px;
}

/* ── Card bottom info section ── */
.card-info {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
}

.card-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1.35;
  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-author {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  /* Single line clamp */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Card meta row (type badge + rating) ── */
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-2);
}

/* ── Type badge ── */
.type-badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  /* Color is set per-type in section 12 */
}

/* ── Star rating display ── */
.card-rating {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--star-fill);
  flex-shrink: 0;
}
.card-rating-value { color: var(--text-primary); }
.rating-star { color: var(--star-fill); }
.rating-star-half  { color: var(--star-fill); opacity: 0.55; }

/* ── Status indicator dot ── */
.status-dot {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
  /* Color is set per-status in section 13 */
}

/* ── Genre tags on card ── */
.card-genres {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-1);
}
.genre-tag {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   12. TYPE BADGE COLOURS
   Each media type has a distinct background and text colour for
   fast visual scanning.
═══════════════════════════════════════════════════════════════ */
.type-anime   { background: rgba(232, 112, 58,  0.2); color: var(--type-anime);   }
.type-manga   { background: rgba(48,  200, 192, 0.2); color: var(--type-manga);   }
.type-manhwa  { background: rgba(160, 96,  224, 0.2); color: var(--type-manhwa);  }
.type-manhua  { background: rgba(232, 120, 168, 0.2); color: var(--type-manhua);  }
.type-book    { background: rgba(112, 192, 56,  0.2); color: var(--type-book);    }
.type-movie   { background: rgba(232, 192, 48,  0.2); color: var(--type-movie);   }

/* ═══════════════════════════════════════════════════════════════
   13. STATUS BADGE COLOURS
═══════════════════════════════════════════════════════════════ */
.status-completed    { background-color: var(--status-completed);   }
.status-in-progress  { background-color: var(--status-in-progress); }
.status-dropped      { background-color: var(--status-dropped);     }
.status-planned      { background-color: var(--status-planned);     }

/* Inline status pill (used in modal and stats) */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}
.status-pill::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.status-pill.status-completed   { color: var(--status-completed);   background: rgba(64,  200, 112, 0.15); }
.status-pill.status-completed::before   { background: var(--status-completed);   }
.status-pill.status-in-progress { color: var(--status-in-progress); background: rgba(232, 192, 48,  0.15); }
.status-pill.status-in-progress::before { background: var(--status-in-progress); }
.status-pill.status-dropped     { color: var(--status-dropped);     background: rgba(232, 80,  80,  0.15); }
.status-pill.status-dropped::before     { background: var(--status-dropped);     }
.status-pill.status-planned     { color: var(--status-planned);     background: rgba(74,  128, 212, 0.15); }
.status-pill.status-planned::before     { background: var(--status-planned);     }

/* ═══════════════════════════════════════════════════════════════
   14. LOADING / EMPTY / ERROR STATES
═══════════════════════════════════════════════════════════════ */

/* Loading spinner */
.loading-state {
  grid-column: 1 / -1; /* span full grid width */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-12);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.spinner {
  width: 40px;
  height: 40px;
  color: var(--accent);
  animation: spin 1s linear infinite;
}

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

/* Empty state */
.empty-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
  text-align: center;
  margin: auto; /* centre within the flex main-content column */
}

.empty-state svg,
.error-state svg {
  width: 56px;
  height: 56px;
  color: var(--text-muted);
}

.empty-title,
.error-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-secondary);
}

.empty-sub,
.error-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 380px;
}

.error-state { color: var(--danger); }
.error-state svg { color: var(--danger); }
.error-title { color: var(--danger); }

/* ═══════════════════════════════════════════════════════════════
   15. MODAL OVERLAY
═══════════════════════════════════════════════════════════════ */

/* Full-viewport backdrop */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  /* Backdrop blur for depth */
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  /* Animation */
  animation: fadeIn var(--transition-normal) ease-out;
}

/* Hidden state (managed by app.js via the `hidden` attribute) */
.modal-overlay[hidden] { display: none; }

/* Modal container */
.modal-container {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 860px;
  max-height: calc(100dvh - 2 * var(--space-4));
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: slideUp var(--transition-slow) ease-out;
}

/* Close button — absolutely positioned top-right */
.modal-close {
  position: sticky;
  float: right;
  top: var(--space-4);
  right: 0;
  margin: var(--space-4) var(--space-4) calc(-1 * var(--space-4) - 40px) 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  z-index: 10;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast);
}
.modal-close svg { width: 18px; height: 18px; }
.modal-close:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════
   16. MODAL CONTENT LAYOUT
═══════════════════════════════════════════════════════════════ */
.modal-content {
  padding: var(--space-6);
}

/* Top section: cover art + primary metadata side by side */
.modal-top {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

/* Modal cover image */
.modal-cover-wrap {
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 2 / 3;
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.modal-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

/* Right side metadata column */
.modal-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Title block */
.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: 1.25;
  color: var(--text-primary);
}

.modal-alt-title {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 2px;
}

/* Author row */
.modal-author {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.modal-author strong { color: var(--text-primary); font-weight: var(--weight-medium); }

/* Badges row (type + status) */
.modal-badges {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

/* Rating stars (large, in modal) */
.modal-rating {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.modal-stars {
  display: flex;
  gap: 2px;
  font-size: var(--text-md);
}
.modal-rating-value {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--star-fill);
}
.modal-rating-max {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Progress bar */
.modal-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.modal-progress-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}
.modal-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  border: none;
  background: var(--bg-elevated);
  /* Style the filled portion — vendor-prefixed for cross-browser support */
  accent-color: var(--accent);
  cursor: default;
}
/* WebKit/Blink inner track */
.modal-progress-bar::-webkit-progress-bar   { background: var(--bg-elevated); border-radius: 3px; }
.modal-progress-bar::-webkit-progress-value { background: linear-gradient(90deg, var(--accent), var(--accent-hover)); border-radius: 3px; }
/* Firefox inner bar */
.modal-progress-bar::-moz-progress-bar      { background: linear-gradient(90deg, var(--accent), var(--accent-hover)); border-radius: 3px; }

/* Dates row */
.modal-dates {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.modal-date-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.modal-date-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.modal-date-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}

/* Genre tags (in modal) */
.modal-genre-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.modal-genre-tag {
  padding: 3px var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* ── Long-form text sections ── */
.modal-section {
  margin-bottom: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.modal-section-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.modal-section-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.75;
}

/* Notes use a different visual treatment (like a sticky note) */
.modal-notes {
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.7;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════
   17. ANIMATIONS & TRANSITIONS
═══════════════════════════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

/* Card entrance animation — driven by app.js via Web Animations API
   to stay CSP-compliant (no inline animation-delay style attribute). */
@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
/* Note: The animation is NOT applied via CSS animation property here;
   it is applied programmatically via element.animate() in app.js. */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ═══════════════════════════════════════════════════════════════
   18. RESPONSIVE BREAKPOINTS
   Tablet: ≤ 900 px  |  Mobile: ≤ 600 px
═══════════════════════════════════════════════════════════════ */

/* ── Tablet (≤ 900 px) ── */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 200px;
    --card-min-width: 140px;
  }

  .brand-name { font-size: var(--text-md); }
}

/* ── Tablet/mobile breakpoint (≤ 768 px) ── */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  /* Show the filter toggle button on mobile */
  .filter-toggle { display: flex; }

  /* Sidebar becomes a collapsible full-width panel below the header */
  .filter-panel {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    height: auto;
    max-height: calc(100dvh - var(--header-height) - 80px);
    z-index: 50;
    border-right: none;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    /* Hidden by default on mobile */
    transform: translateY(-110%);
    transition: transform var(--transition-normal);
    overflow-y: auto;
  }

  /* Panel is visible when aria-expanded="true" is set on the toggle */
  .filter-panel.is-open {
    transform: translateY(0);
  }

  /* Full width for the main content since no sidebar */
  .app-layout { display: block; }
  .main-content { width: 100%; }
}

/* ── Mobile (≤ 600 px) ── */
@media (max-width: 600px) {
  :root {
    --card-min-width: 130px;
    --space-5: 16px;
  }

  .header-inner { padding: 0 var(--space-3); gap: var(--space-3); }

  .search-wrapper { max-width: unset; }

  /* Slightly tighter modal on small screens */
  .modal-container {
    border-radius: var(--radius-lg);
    max-height: 95dvh;
  }

  .modal-content { padding: var(--space-4); }

  /* Stack modal top section vertically on phones */
  .modal-top {
    grid-template-columns: 1fr;
  }

  .modal-cover-wrap {
    /* Shorter crop in single-column layout */
    aspect-ratio: 16 / 9;
  }
  .modal-cover { object-position: center 20%; }

  .media-grid { padding: var(--space-3); gap: var(--space-3); }
}

/* ── Large screens (≥ 1400 px) — widen grid columns ── */
@media (min-width: 1400px) {
  :root { --card-min-width: 180px; }
}


/* ═══════════════════════════════════════════════════════════════
   19. BUG FIX — Empty stars (§ 11 addition)
═══════════════════════════════════════════════════════════════ */
.rating-star-empty { color: var(--star-empty); }

/* ═══════════════════════════════════════════════════════════════
   20. HEADER ACTION BUTTONS
═══════════════════════════════════════════════════════════════ */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  margin-left: auto;
}

.btn-add {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #fff;
  transition: background var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-add:hover { background: var(--accent-hover); }
.btn-add svg { width: 16px; height: 16px; }

/* Larger variant for the empty-library call-to-action */
.btn-add--large {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}
.btn-add--large svg { width: 20px; height: 20px; }

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast);
  flex-shrink: 0;
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}
/* Label shown next to icon (visible on mobile filter toggle) */
.btn-icon-label { font-size: var(--text-sm); font-weight: var(--weight-medium); }

/* On mobile, the filter toggle shows its label; other icon-buttons don't */
#filter-toggle { width: auto; padding: var(--space-2) var(--space-3); gap: var(--space-2); }

/* ═══════════════════════════════════════════════════════════════
   21. SHARED ACTION BUTTONS (used in modals & forms)
═══════════════════════════════════════════════════════════════ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: background var(--transition-fast);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.btn-secondary:hover {
  background: var(--bg-primary);
  border-color: var(--text-muted);
  color: var(--text-primary);
}
.btn-secondary svg { width: 16px; height: 16px; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: background var(--transition-fast), color var(--transition-fast);
  margin-left: auto;
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-danger svg { width: 16px; height: 16px; }

/* ── Edit / Delete action row in detail modal ── */
.modal-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* ── Delete confirmation inline block ── */
.delete-confirm {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: rgba(232, 80, 80, 0.08);
  border: 1px solid rgba(232, 80, 80, 0.3);
}
.delete-confirm-msg {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}
.delete-confirm-msg strong { color: var(--text-primary); }
.delete-confirm-btns {
  display: flex;
  gap: var(--space-3);
}
.delete-confirm-btns .btn-danger { margin-left: 0; }

/* ── Small progress bar on card (list view) ── */
.card-progress-bar {
  width: 100%;
  height: 3px;
  border-radius: 2px;
  border: none;
  background: var(--bg-elevated);
  accent-color: var(--accent);
  margin-top: var(--space-1);
  display: block;
}
.card-progress-bar::-webkit-progress-bar   { background: var(--bg-elevated); border-radius: 2px; }
.card-progress-bar::-webkit-progress-value { background: var(--accent); border-radius: 2px; }
.card-progress-bar::-moz-progress-bar      { background: var(--accent); border-radius: 2px; }

/* ── Cover placeholder for entries with no cover image ── */
.card-cover-placeholder,
.modal-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  color: var(--text-muted);
}
.card-cover-placeholder svg { width: 48px; height: 64px; }
.modal-cover-placeholder svg { width: 60px; height: 80px; }

/* ═══════════════════════════════════════════════════════════════
   22. LIGHT THEME
═══════════════════════════════════════════════════════════════ */
body.theme-light {
  --bg-primary:    #f0f2f7;
  --bg-secondary:  #ffffff;
  --bg-elevated:   #e4e8f0;
  --bg-overlay:    rgba(0, 0, 0, 0.45);
  --border:        #d0d5e2;
  --border-focus:  #4a80d4;
  --text-primary:  #1a1e2e;
  --text-secondary:#4a5270;
  --text-muted:    #8890a8;
  --star-empty:    #c8cce0;
  --shadow-card:   0 2px 12px rgba(0, 0, 0, 0.12);
  --shadow-modal:  0 8px 48px rgba(0, 0, 0, 0.25);
}

/* ═══════════════════════════════════════════════════════════════
   23. LIST VIEW
═══════════════════════════════════════════════════════════════ */
.view-list .media-grid {
  grid-template-columns: 1fr;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
}

.view-list .media-card {
  flex-direction: row;
  align-items: stretch;
  height: 84px;
  border-radius: var(--radius-md);
  will-change: auto; /* reset for list rows */
}

.view-list .media-card:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-card);
}

.view-list .card-cover-wrap {
  width: 56px;
  flex-shrink: 0;
  aspect-ratio: unset;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.view-list .card-info {
  flex-direction: row;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  flex: 1;
  min-width: 0;
}

.view-list .card-title {
  min-width: 0;
  flex: 2;
  max-width: 300px;
  -webkit-line-clamp: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block; /* override -webkit-box */
}

.view-list .card-author {
  flex: 1;
  min-width: 0;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-list .card-genres {
  flex-wrap: nowrap;
  overflow: hidden;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.view-list .card-progress-bar { display: none; }

.view-list .card-meta {
  margin-left: auto;
  padding: 0;
  flex-shrink: 0;
}

.view-list .card-hover-overlay { display: none; }
.view-list .status-dot { top: var(--space-1); right: var(--space-1); }

/* ═══════════════════════════════════════════════════════════════
   24. CARD SIZE VARIANTS
═══════════════════════════════════════════════════════════════ */
body.card-compact  { --card-min-width: 130px; }
body.card-spacious { --card-min-width: 210px; }

/* ═══════════════════════════════════════════════════════════════
   25. FORM MODAL
═══════════════════════════════════════════════════════════════ */
.form-modal-container {
  max-width: 720px;
}

.media-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.form-heading {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group--full { grid-column: 1 / -1; }

.form-group label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.required-star { color: var(--danger); margin-left: 1px; }
.form-hint     { text-transform: none; letter-spacing: 0; font-weight: var(--weight-regular); }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  outline: none;
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-muted); }

.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9' fill='none' stroke='%238a90a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-2) center;
  background-size: 16px;
  padding-right: 28px;
  cursor: pointer;
}
.form-select option { background: var(--bg-secondary); }

/* Rating range slider */
.form-range {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-elevated);
  border: none;
  outline: none;
  cursor: pointer;
  accent-color: var(--accent);
  padding: 0;
}
.form-range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-secondary);
  box-shadow: 0 0 0 2px var(--accent);
  cursor: pointer;
  transition: transform var(--transition-fast);
}
.form-range::-webkit-slider-thumb:hover  { transform: scale(1.2); }
.form-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-secondary);
  cursor: pointer;
}

.form-rating-display {
  color: var(--star-fill);
  font-size: var(--text-md);
}

.form-error-msg {
  font-size: var(--text-sm);
  color: var(--danger);
  padding: var(--space-2) var(--space-3);
  background: rgba(232, 80, 80, 0.08);
  border: 1px solid rgba(232, 80, 80, 0.3);
  border-radius: var(--radius-md);
}
.form-error-msg[hidden] { display: none; }

.form-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   26. SETTINGS DRAWER
═══════════════════════════════════════════════════════════════ */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.settings-overlay[hidden] { display: none; }

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 100vw);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: slideInRight var(--transition-normal) ease-out;
  z-index: 301;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0);    }
}

.settings-head {
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1;
}
.settings-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}
.settings-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  flex: 1;
}
.settings-section { display: flex; flex-direction: column; gap: var(--space-3); }
.settings-section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Segmented toggle row */
.settings-toggle-row {
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}
.settings-toggle {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}
.settings-toggle svg { width: 14px; height: 14px; flex-shrink: 0; }
.settings-toggle.active {
  background: var(--accent);
  color: #fff;
}
.settings-toggle:not(.active):hover { color: var(--text-primary); }

/* Colour picker row */
.settings-color-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.settings-color-input {
  width: 48px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  cursor: pointer;
  background: none;
  padding: 2px;
  flex-shrink: 0;
  transition: border-color var(--transition-fast);
}
.settings-color-input:focus { border-color: var(--border-focus); outline: none; }
.settings-color-preview {
  flex: 1;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
  color: #fff;
  letter-spacing: 0.04em;
  transition: background var(--transition-fast);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.settings-reset-btn {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  flex-shrink: 0;
}
.settings-reset-btn:hover { color: var(--text-secondary); }

/* Data management buttons */
.settings-data-btns {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.settings-data-btn {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-align: left;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast);
}
.settings-data-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.settings-data-btn:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}
.settings-danger-btn { border-color: rgba(232, 80, 80, 0.3); color: var(--danger); }
.settings-danger-btn:hover {
  background: rgba(232, 80, 80, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

/* ═══════════════════════════════════════════════════════════════
   27. TOAST NOTIFICATIONS
═══════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(140%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  z-index: 500;
  transition: transform var(--transition-normal);
  max-width: min(380px, calc(100vw - 32px));
  text-align: center;
  pointer-events: none;
}
.toast--show  { transform: translateX(-50%) translateY(0); }
.toast--success { border-color: var(--success); color: var(--success); }
.toast--error   { border-color: var(--danger);  color: var(--danger);  }
.toast--info    { border-color: var(--accent);  color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════════
   28. RESPONSIVE UPDATES FOR NEW ELEMENTS
═══════════════════════════════════════════════════════════════ */

/* ── Tablet ── */
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-group--full { grid-column: 1; }
}

/* ── Mobile ── */
@media (max-width: 600px) {
  .header-actions { gap: var(--space-1); }
  .btn-add span   { display: none; }           /* show icon only on very small screens */
  .btn-add        { padding: var(--space-2); width: 36px; height: 36px; border-radius: var(--radius-md); justify-content: center; }
  .btn-add svg    { width: 18px; height: 18px; }
  #filter-toggle .btn-icon-label { display: none; }
  #filter-toggle { width: 36px; height: 36px; padding: 0; justify-content: center; }

  .view-list .card-info { gap: var(--space-2); }
  .view-list .card-author { display: none; }
  .view-list .card-genres { display: none; }
}

/* ── Reset confirmation (inside settings drawer) ── */
.settings-reset-confirm {
  margin-top: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: rgba(232, 80, 80, 0.08);
  border: 1px solid rgba(232, 80, 80, 0.3);
}
.settings-reset-confirm .btn-danger { margin-left: 0; }
