/* ============================================================================
   audiolibri.org — app.css
   Single consolidated stylesheet. Replaces: styles.css, tailwind-styles.css,
   mobile-navigation.css, mobile-fixes.css, dynamic-components.css,
   tailwind-mobile.css, tailwind-grid-components.css, tailwind-nav-components.css,
   tailwind-modern-ios.css.

   Sections:
     1. Design tokens (scale: space / type / radius / shadow / motion)
     2. Utilities (the load-bearing tw-/pill set, defined once)
     3. Components & base  (proven rules, color tokens live here)
     4. Mobile overrides
     5. iOS safe-area helpers
   Color tokens (--primary-color, --text-color, …) are defined in §3 and
   themed via prefers-color-scheme.
   ============================================================================ */

/* Self-hosted variable fonts — airgapped, no Google Fonts/gstatic calls. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/fonts/fraunces-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/fonts/fraunces-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── 1. Design tokens ───────────────────────────────────────────────────── */
:root {
    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Type scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.8rem;
    --leading-tight: 1.3;
    --leading-normal: 1.6;

    /* Radius scale */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;
    --radius-pill: 9999px;

    /* Elevation */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Motion */
    --dur-fast: 0.15s;
    --dur: 0.2s;
    --dur-slow: 0.3s;
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

    /* Typography families */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;

    /* Layout */
    --max-width: 1200px;
}

/* ── 2. Utilities (load-bearing set only — defined once) ────────────────────
   These are the only tw-*/pill utilities actually referenced by the markup
   and app.js. Previously-undefined utility classes in the HTML (e.g. tw-px-4,
   tw-min-h-[…], sm:tw-*) were no-ops without a build step and are intentionally
   left undefined — their visual effect already comes from semantic selectors. */

/* layout */
.tw-container { width: 100%; max-width: var(--max-width); margin-left: auto; margin-right: auto; padding: var(--space-8); }
.tw-flex { display: flex; }
.tw-flex-col { flex-direction: column; }
.tw-grid { display: grid; }
.tw-items-center { align-items: center; }
.tw-justify-center { justify-content: center; }

/* spacing */
.tw-gap-2 { gap: var(--space-2); }
.tw-gap-3 { gap: var(--space-3); }
.tw-gap-4 { gap: var(--space-4); }
.tw-gap-6 { gap: var(--space-6); }
.tw-mb-2 { margin-bottom: var(--space-2); }
.tw-mb-4 { margin-bottom: var(--space-4); }
.tw-mb-6 { margin-bottom: var(--space-6); }
.tw-mt-2 { margin-top: var(--space-2); }

/* type */
.tw-text-center { text-align: center; }
.tw-text-sm { font-size: var(--text-sm); }
.tw-text-base { font-size: var(--text-base); }
.tw-text-lg { font-size: var(--text-lg); }
.tw-font-medium { font-weight: 500; }
.tw-font-semibold { font-weight: 600; }

/* radius */
.tw-rounded-full { border-radius: var(--radius-pill); }

/* component utilities (mirror the proven semantic rules; kept because the
   markup applies these class names alongside semantic ones) */
.tw-card {
    background-color: var(--card-background);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    margin-bottom: var(--space-8);
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.tw-button {
    padding: 0.875rem var(--space-5);
    border-radius: var(--radius-pill);
    border: none;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    font-size: var(--text-base);
    font-weight: 500;
    font-family: inherit;
    transition: all var(--dur) ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    line-height: 1;
}
.tw-button:hover { background-color: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }
.tw-button:active { transform: translateY(0); }
.tw-input {
    padding: 0.875rem var(--space-5);
    width: 100%;
    border-radius: var(--radius-pill);
    border: 1px solid var(--search-border);
    font-size: var(--text-base);
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    transition: all 0.25s ease;
    background-color: var(--card-background);
    color: var(--text-color);
}
.tw-input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.15); }

/* pill nav (genre-style pills built by app.js) */
.tw-pill {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 0.375rem var(--space-3);
    border-radius: var(--radius-pill);
    background-color: var(--tag-bg, #e2e8f0);
    color: var(--tag-text, #4a5568);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--dur) ease, transform 0.1s ease;
}
.tw-pill:active { transform: scale(0.95); }
.tw-pill.active { background-color: var(--primary-color, #4a6cf7); color: white; }

/* mobile search input + horizontal scroller */
.tw-mobile-input {
    height: 48px;
    width: 100%;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color, #e5e7eb);
    font-size: 16px;
    background-color: var(--card-background, #ffffff);
}
.tw-mobile-scroll {
    display: flex;
    overflow-x: auto;
    padding-bottom: 12px;
    margin: 0 -8px;
    padding-left: 8px;
    padding-right: 8px;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.tw-mobile-scroll::-webkit-scrollbar { display: none; } /* l0git: ignore hidden_scrollbar reason: horizontal scroller; swipe + edge affordance replace the bar */
.tw-mobile-scroll-item { scroll-snap-align: start; flex-shrink: 0; width: 160px; margin-right: 12px; }
@media (min-width: 640px) {
    .tw-mobile-scroll-item { width: 192px; }
}

/* ── 3. Components & base (color tokens defined here, themed below) ───────── */
/* styles.css */

/* WCAG 2.1 AA Compliance Styles */

/* Skip Link for Screen Readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 6px;
}

/* Screen Reader Only Text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Enhanced Focus Indicators - WCAG 2.1 AA compliant */
*:focus {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* ── Color tokens ───────────────────────────────────────────────────────────
   Light is the default (and the no-JS / FOUC fallback). System dark applies
   unless the user forced light; an explicit [data-theme] (set by the toggle)
   always wins. One warm coral + teal identity, consistent across both themes. */
:root {
    --primary-rgb: 184, 50, 74;
    --accent-rgb: 12, 122, 110;
    --card-background-rgb: 255, 255, 255;
    --background-color: #f5f7fa;
    --text-color: #1a202c;
    --card-background: #ffffff;
    --card-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    --border-color: #e2e8f0;
    --primary-color: #b8324a;
    --primary-hover: #9e2a40;
    --accent-color: #0c7a6e;
    --accent-hover: #0a5f56;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --header-color: #111827;
    --secondary-text: #4b5563;
    --placeholder-bg: #f8fafc;
    --meta-background: rgba(0, 0, 0, 0.75);
    --search-border: #9ca3af;
    --disabled-button: #9ca3af;
    --loading-color: #b8324a;
    --tag-bg: #d1d5db;
    --tag-text: #374151;
    --hover-overlay: rgba(0, 0, 0, 0.05);
    --progress-bg: #e5e7eb;
    --progress-fill: #b8324a;
    --focus-ring: #b8324a;
}

/* Prevent FOUC */
body {
    visibility: visible;
}

/* High contrast focus for dark mode */
@media (prefers-color-scheme: dark) {
    *:focus {
        outline-color: var(--focus-ring);
    }
}

/* Remove default focus for mouse users but keep for keyboard */
*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
    *:focus-visible {
        outline-color: var(--focus-ring);
    }
}

/* Ensure minimum 44px touch targets on mobile */
@media (max-width: 768px) {
    button, a, input, [role="button"] {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Dark theme — explicit toggle, or OS preference unless the user forced light */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary-rgb: 255, 107, 107;
        --accent-rgb: 78, 205, 196;
        --card-background-rgb: 18, 18, 18;
        --background-color: #000000;
        --text-color: #f1f5f9;
        --card-background: #121212;
        --card-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
        --border-color: #404040;
        --primary-color: #ff6b6b;
        --primary-hover: #ff5252;
        --accent-color: #4ecdc4;
        --accent-hover: #26a69a;
        --danger-color: #ff5252;
        --danger-hover: #f44336;
        --header-color: #ffffff;
        --secondary-text: #b3b3b3;
        --placeholder-bg: #1e1e1e;
        --meta-background: rgba(0, 0, 0, 0.85);
        --search-border: #525252;
        --disabled-button: #525252;
        --loading-color: #ff6b6b;
        --tag-bg: #404040;
        --tag-text: #f1f5f9;
        --hover-overlay: rgba(255, 255, 255, 0.08);
        --progress-bg: #404040;
        --progress-fill: #4ecdc4;
        --focus-ring: #4ecdc4;
    }
}
:root[data-theme="dark"] {
    --primary-rgb: 255, 107, 107;
    --accent-rgb: 78, 205, 196;
    --card-background-rgb: 18, 18, 18;
    --background-color: #000000;
    --text-color: #f1f5f9;
    --card-background: #121212;
    --card-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    --border-color: #404040;
    --primary-color: #ff6b6b;
    --primary-hover: #ff5252;
    --accent-color: #4ecdc4;
    --accent-hover: #26a69a;
    --danger-color: #ff5252;
    --danger-hover: #f44336;
    --header-color: #ffffff;
    --secondary-text: #b3b3b3;
    --placeholder-bg: #1e1e1e;
    --meta-background: rgba(0, 0, 0, 0.85);
    --search-border: #525252;
    --disabled-button: #525252;
    --loading-color: #ff6b6b;
    --tag-bg: #404040;
    --tag-text: #f1f5f9;
    --hover-overlay: rgba(255, 255, 255, 0.08);
    --progress-bg: #404040;
    --progress-fill: #4ecdc4;
    --focus-ring: #4ecdc4;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--background-color);
    margin: 0;
    padding: 0;
    color: var(--text-color);
    line-height: var(--leading-normal);
    font-size: var(--text-base);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header card redesign */
header {
    text-align: center;
    margin-bottom: 2.5rem;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    padding: 2rem;
    border: 0px solid var(--border-color);
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
                rgba(var(--primary-rgb), 0.08) 0%, 
                rgba(var(--card-background-rgb), 1) 50%,
                rgba(var(--accent-rgb), 0.08) 100%);
    z-index: -1;
}

/* Enhanced title styling */
.site-title-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.5rem;
}

h1 {
    color: var(--header-color);
    font-size: 2rem;
    letter-spacing: -0.025em;
    font-weight: 800;
    margin: 0 0 0.5rem;
    position: relative;
    display: inline-block;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    /* Fallback for browsers that don't support text-fill-color */
    color: transparent;
}

.title-icon {
    margin-bottom: 0.75rem;
    font-size: 2rem;
    animation: pulse 2s infinite ease-in-out;
}

.site-tagline {
    color: var(--secondary-text);
    font-size: 1.2rem;
    font-weight: 500;
    max-width: 600px;
    margin: 0 auto;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Library stats styling */
.library-stats-container {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.library-stats-container::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 25%;
    right: 25%;
    height: 1px;
    background: linear-gradient(to right, 
                transparent 0%, 
                var(--primary-color) 50%, 
                transparent 100%);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.stat-item {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--secondary-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.search-container {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin: 0 auto;
    max-width: 650px;
    width: 100%;
}

.navigation-container {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.button-group {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

#search {
    padding: 0.875rem 1.25rem;
    width: 100%;
    border-radius: 9999px;
    border: 1px solid var(--search-border);
    font-size: 1rem;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    transition: all 0.25s ease;
    background-color: var(--card-background);
    color: var(--text-color);
}

#search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.15);
}

/* Neutral baseline: a class-less <button> carries no pill chrome. CTAs opt into
   .tw-button / .hero-cta / .control-button etc. for their look. Previously this
   forced a primary-colour pill (+ hover) onto EVERY button, which leaked a maroon
   hover background onto structural buttons like cards and row arrows. */
button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.single-card {
    background-color: var(--card-background);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.audiobook-card {
    position: relative;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    overflow: hidden;
    min-height: 500px;
    background-size: cover;
    background-position: center;
}

.card-overlay {
    position: relative;
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.85) 100%);
    width: 100%;
    height: 100%;
    color: white;
    padding: 2rem;
    box-sizing: border-box;
}

@media (min-width: 800px) {
    .card-overlay {
        flex-direction: row;
        align-items: flex-start;
        gap: 2rem;
    }
}

/* Media container and player */
.media-container {
    z-index: 3;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 320px;
    margin-bottom: 1.5rem;
}

#youtube-player {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    margin-bottom: 1rem;
    aspect-ratio: 16/9;
}

.player-controls {
    /* crisp masked-SVG control icons (replace emoji glyphs); colour = currentColor */
    --ic-play: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M8 5v14l11-7z'/></svg>");
    --ic-pause: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M7 4h3v16H7zm7 0h3v16h-3z'/></svg>");
    --ic-rewind: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M11 5 2 12l9 7zM22 5l-9 7 9 7z'/></svg>");
    --ic-forward: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M13 5l9 7-9 7zM2 5l9 7-9 7z'/></svg>");
    --ic-volume: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M11 5 6 9H2v6h4l5 4z' fill='black'/><path d='M15.5 8.5a5 5 0 0 1 0 7'/><path d='M19 5a8 8 0 0 1 0 14'/></svg>");
    background-color: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    padding: 1rem 1.1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.25rem;
}

.progress-container {
    width: 100%;
    height: 5px;
    background-color: var(--progress-bg);
    border-radius: 999px;
    margin: 0.5rem 0;
    position: relative;
    cursor: pointer;
    transition: height var(--dur) var(--ease-out);
}
.progress-container:hover,
.progress-container:focus-visible { height: 8px; outline: none; }

.progress-bar {
    height: 100%;
    background-color: var(--progress-fill);
    border-radius: inherit;
    width: 0%;
    transition: width 0.1s linear;
}

.progress-handle {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background-color: #fff;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    left: 0%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--dur);
}
.progress-container:hover .progress-handle,
.progress-container:focus-within .progress-handle,
.progress-container:focus-visible .progress-handle { opacity: 1; }

.time-display {
    color: white;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.control-button {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    padding: 0;
    border: none;
}

.control-button:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
    box-shadow: none;
}

.control-button.large {
    width: 56px;
    height: 56px;
    background-color: #fff;
    color: #111;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.control-button.large:hover {
    background-color: #fff;
    transform: scale(1.06);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    color: rgba(255, 255, 255, 0.6);
}

#volume-slider {
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    outline: none;
    cursor: pointer;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    transition: transform var(--dur);
}
#volume-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
#volume-slider::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border: none;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

/* Player icons: masked SVGs tinted with currentColor (crisp, theme-aware). */
.play-icon, .pause-icon, .rewind-icon, .forward-icon, .volume-icon {
    display: block;
    background-color: currentColor;
    -webkit-mask: center / contain no-repeat;
    mask: center / contain no-repeat;
}
.play-icon { width: 20px; height: 20px; margin-left: 2px; -webkit-mask-image: var(--ic-play); mask-image: var(--ic-play); }
.pause-icon { width: 20px; height: 20px; -webkit-mask-image: var(--ic-pause); mask-image: var(--ic-pause); }
.rewind-icon { width: 22px; height: 22px; -webkit-mask-image: var(--ic-rewind); mask-image: var(--ic-rewind); }
.forward-icon { width: 22px; height: 22px; -webkit-mask-image: var(--ic-forward); mask-image: var(--ic-forward); }
.volume-icon { width: 18px; height: 18px; flex-shrink: 0; -webkit-mask-image: var(--ic-volume); mask-image: var(--ic-volume); }

.error-icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    background-color: var(--danger-color);
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 24px;
    margin-right: 8px;
    font-style: normal;
    font-weight: bold;
}

.time-icon::before {
    content: "⏱";
    margin-right: 5px;
}

.audio-icon::before {
    content: "🎧";
    margin-right: 5px;
}

/* Book details */
.book-details {
    flex: 1;
    z-index: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.book-text-content {
    background-color: rgba(0, 0, 0, 0.75);
    padding: 1.75rem;
    border-radius: 12px;
    margin-bottom: 0;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.book-details h2 {
    color: white;
    margin-top: 0;
    font-size: 1.75rem;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    letter-spacing: -0.025em;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.book-details h3 {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    margin-top: 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
}

.book-details p {
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0px 1px 2px rgba(0,0,0,0.7);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.book-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.category-tag {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

#audio-player {
    width: 100%;
    margin-top: 1rem;
    border-radius: 8px;
    height: 36px;
}

.meta-inline {
    margin-top: 1.25rem;
    font-size: 0.875rem;
    color: white;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.meta-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    color: #c4c4c4;
}

.duration-badge {
    display: inline-flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    margin-left: 0.5rem;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.875rem;
}

.audio-status.available {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
    background-color: var(--accent-color);
    color: white;
}

.channel-link {
    display: inline-flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.15);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    margin-left: 0.25rem;
    transition: all 0.2s ease;
    text-decoration: none;
    color: white;
}

.channel-link:hover {
    background-color: rgba(255, 255, 255, 0.25);
    text-decoration: none;
    color: white;
}

.channel-link .channel-icon {
    width: 18px;
    height: 18px;
    margin-right: 0.5rem;
}

/* Loading states */
.loading-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 500px;
    color: var(--text-color);
    background-color: var(--card-background);
    border-radius: 16px;
    padding: 2rem;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1.5rem;
}

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

.error-message, .no-results {
    padding: 3rem 2rem;
    text-align: center;
    border-radius: 12px;
    margin: 1rem 0;
}

.error-message {
    color: var(--danger-color);
    background-color: rgba(239, 68, 68, 0.1);
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.no-results {
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.05);
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.search-icon::before {
    content: "🔍";
    font-size: 32px;
    display: block;
}

.book-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 400px;
    color: var(--secondary-text);
    text-align: center;
    font-size: 1.125rem;
    background-color: var(--placeholder-bg);
    border-radius: 12px;
    gap: 1rem;
}

.book-placeholder-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    opacity: 0.5;
}

/* Footer */
/* Footer */
.site-footer {
    margin-top: clamp(2.5rem, 6vw, 4rem);
    padding: var(--space-8) 0;
    border-top: 1px solid var(--border-color);
    color: var(--secondary-text);
    font-size: var(--text-sm);
    background: linear-gradient(to top, rgba(var(--primary-rgb), 0.03), transparent);
}
.footer-top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-6);
    margin-bottom: var(--space-8);
}
.footer-brand { max-width: 360px; }
.footer-brand-name {
    font-size: var(--text-lg);
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.footer-brand p { margin: var(--space-2) 0 0; line-height: var(--leading-normal); }
.footer-cols {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-6) var(--space-8);
}
.footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-5);
}
.footer-link {
    position: relative;
    text-decoration: none;
    color: var(--secondary-text);
    font-weight: 500;
    transition: color var(--dur);
}
.footer-link:hover { color: var(--text-color); }
.footer-link::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width var(--dur);
}
.footer-link:hover::after { width: 100%; }
.footer-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* Shared ghost button (footer actions, reused across chrome) */
.ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-color);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--dur), border-color var(--dur), transform var(--dur);
}
.ghost-btn:hover { background: var(--hover-overlay); border-color: var(--secondary-text); transform: translateY(-1px); }
.ghost-btn svg { width: 16px; height: 16px; }
.theme-icon { display: inline-flex; transition: transform var(--dur-slow); }
#theme-toggle:hover .theme-icon { transform: rotate(150deg); }

.footer-base {
    padding-top: var(--space-5);
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--secondary-text);
    font-size: var(--text-xs);
    line-height: var(--leading-normal);
}
.footer-base p { margin: var(--space-1) 0; }

@media (max-width: 640px) {
    .footer-top { flex-direction: column; gap: var(--space-5); }
}

/* EN 301 549 European Accessibility Standard Styles */

/* Session Timeout Warning Dialog */
.session-timeout-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.timeout-content {
    background-color: var(--card-background);
    color: var(--text-color);
    border-radius: 8px;
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--primary-color);
}

.timeout-content h3 {
    margin-bottom: 1rem;
    color: var(--header-color);
    font-size: 1.25rem;
}

.timeout-content p {
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.extend-session-btn,
.dismiss-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    margin: 0.5rem;
    min-height: 44px;
    min-width: 44px;
    transition: all 0.2s ease;
}

.extend-session-btn:hover,
.dismiss-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.extend-session-btn:focus,
.dismiss-btn:focus {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.dismiss-btn {
    background-color: var(--secondary-text);
}

.dismiss-btn:hover {
    background-color: var(--text-color);
}

/* Accessible Error Dialog */
.accessible-error-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.error-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
}

.error-dialog-content {
    position: relative;
    background-color: var(--card-background);
    color: var(--text-color);
    border-radius: 8px;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--danger-color);
}

.error-dialog-content h2 {
    color: var(--danger-color);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.error-dialog-content p {
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.primary-action,
.secondary-action {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    transition: all 0.2s ease;
}

.primary-action:hover,
.secondary-action:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.primary-action:focus,
.secondary-action:focus {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.secondary-action {
    background-color: var(--secondary-text);
}

.secondary-action:hover {
    background-color: var(--text-color);
}

/* Language Switcher (hidden by default) */
#language-switcher {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem;
    box-shadow: var(--card-shadow);
}

#language-switcher label {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: var(--text-color);
}

#lang-select {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    background-color: var(--card-background);
    color: var(--text-color);
    font-size: 0.875rem;
    min-height: 44px;
}

#lang-select:focus {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Enhanced Mobile Accessibility */
@media (max-width: 768px) {
    .timeout-content,
    .error-dialog-content {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .error-actions {
        flex-direction: column;
    }
    
    .primary-action,
    .secondary-action,
    .extend-session-btn,
    .dismiss-btn {
        width: 100%;
        margin: 0.25rem 0;
    }
}

/* High Contrast Mode Support for EN 301 549 */
@media (prefers-contrast: high) {
    .session-timeout-warning,
    .accessible-error-dialog {
        background-color: rgba(0, 0, 0, 0.95);
    }
    
    .timeout-content,
    .error-dialog-content {
        border-width: 3px;
        box-shadow: 0 0 0 2px var(--text-color);
    }
    
    .extend-session-btn,
    .dismiss-btn,
    .primary-action,
    .secondary-action {
        border: 2px solid var(--text-color);
    }
    
    #lang-select {
        border-width: 2px;
    }
}

/* Reduced Motion Support for EN 301 549 */
@media (prefers-reduced-motion: reduce) {
    .timeout-content,
    .error-dialog-content,
    .extend-session-btn,
    .dismiss-btn,
    .primary-action,
    .secondary-action {
        transition: none !important;
        transform: none !important;
    }
    
    .extend-session-btn:hover,
    .dismiss-btn:hover,
    .primary-action:hover,
    .secondary-action:hover {
        transform: none !important;
    }
}


/* ── 3b. Dynamic components (genre nav, grids, carousel, search results) ──── */
/* Dynamic Components CSS - Extracted from app.js */

/* Genre Navigation Styles */
.genre-navigation {
    margin: 20px 0;
    padding: 1.5rem;
    background: #12121200;
    border-radius: 16px;
    box-shadow: none;
    border: 0px solid var(--border-color);
    transition: all 0.3s ease;
}

.genre-title {
    font-size: 1.25rem;
    margin-bottom: 1.25rem;
    color: var(--header-color);
    font-weight: 600;
    position: relative;
    padding-bottom: 0.75rem;
}

.genre-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 3px;
}

.genre-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.genre-pill {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.5rem 0.95rem;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dur), border-color var(--dur), color var(--dur), transform var(--dur);
}

.genre-pill:hover {
    background: var(--hover-overlay);
    border-color: var(--secondary-text);
    transform: translateY(-1px);
}

.genre-pill:active { transform: translateY(0); }

.genre-count {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary-color);
    border-radius: var(--radius-pill);
    padding: 2px 8px;
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: 1.4;
}

.genre-pill.selected,
.genre-pill.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.genre-pill.selected .genre-count,
.genre-pill.active .genre-count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

/* Genre View Styles */
.genre-view {
    padding: 1.5rem;
}

.genre-view-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 12px;
}

.genre-view-title {
    font-size: 1.5rem;
    color: white;
    margin: 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.genre-count-large {
    margin-left: auto;
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.9rem;
}

.back-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(0,0,0,0.4);
    border-radius: 999px;
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-button:hover {
    background: rgba(0,0,0,0.6);
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}

.back-icon::before {
    content: "←";
    margin-right: 4px;
}

.audiobooks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.book-card {
    background: var(--card-background);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 20px rgba(0,0,0,0.15);
}

.book-card-cover {
    height: 160px;
    background-size: cover;
    background-position: center;
    position: relative;
}

.card-badge {
    position: absolute;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
}

.audio-badge {
    top: 10px;
    left: 10px;
    background: var(--accent-color);
}

.duration-badge {
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
}

.book-card-details {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.book-card-title {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    color: var(--text-color);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card-author {
    margin: 0;
    font-size: 0.85rem;
    color: var(--secondary-text);
    font-weight: 500;
}


/* Search Results Styles */
/* Clean, unboxed results section — same visual language as the home rows. */
.search-results-card {
    margin: var(--space-2) 0 var(--space-8);
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.search-results-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.search-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.search-title {
    font-size: 1.5rem;
    color: var(--header-color);
    margin: 0;
    font-weight: 600;
}

.results-count {
    color: var(--secondary-text);
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 1.5rem;
}

.pagination-button {
    padding: 8px 16px;
    background: rgba(var(--primary-rgb), 0.1);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    border-radius: 999px;
    color: var(--primary-color);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-button:hover:not([disabled]) {
    background: rgba(var(--primary-rgb), 0.2);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.pagination-button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-indicator {
    color: var(--secondary-text);
    font-size: 0.9rem;
}

.prev-icon::before {
    content: "←";
}

.next-icon::before {
    content: "→";
}

.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

.no-results h3 {
    margin: 1rem 0 0.5rem;
    color: var(--header-color);
}

.no-results p {
    color: var(--secondary-text);
    margin-bottom: 1.5rem;
}

.search-icon {
    display: inline-block;
    width: 60px;
    height: 60px;
    background-color: rgba(var(--primary-rgb), 0.1);
    border-radius: 50%;
    position: relative;
}

.search-icon::before {
    content: "🔍";
    font-size: 2rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

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

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

/* Mobile Responsive Styles */
@media (min-width: 1024px) {
    .genre-list {
        gap: 14px;
    }
    
    .genre-pill {
        padding: 13px 22px;
        font-size: 1rem;
    }
    
    .genre-count {
        padding: 4px 13px;
        font-size: 0.85rem;
    }
}

@media (max-width: 768px) {
    .genre-navigation {
        padding: 1.25rem;
    }
    
    .genre-pill {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    .audiobooks-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }
    
    .genre-view {
        padding: 1rem;
    }
    
    .genre-view-header {
        margin-bottom: 1rem;
    }
    
    .genre-view-title {
        font-size: 1.25rem;
    }
    
    .search-results-card {
        padding: 1rem;
    }
    
    .search-title {
        font-size: 1.25rem;
    }
    
    .pagination-button {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}


/* ── 4. Mobile overrides (genre nav / categories) ──────────────────────────── */
/* Style the mobile genre navigation */
@media (max-width: 768px) {
    .genre-navigation {
        padding: 0.5rem !important;
        margin: 10px 0 !important;
        width: 100%;
        overflow-x: auto;
        position: sticky;
        top: 0;
        z-index: 10;
        background-color: var(--background-color);
        margin-top: 0 !important;
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    .genre-list {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding-bottom: 5px;
        width: auto;
        min-width: max-content;
        /* Add snap scrolling for better mobile experience */
        scroll-snap-type: x mandatory;
        /* Add extra padding for better thumb scrolling experience */
        padding-left: 4px;
        padding-right: 4px;
    }
    
    @media (max-width: 480px) {
        .genre-list {
            gap: 5px !important; /* Reduced from 6px for more compact layout */
            padding-bottom: 3px;
            justify-content: flex-start !important; /* Ensure proper alignment */
        }
    }

    .genre-pill {
        flex-shrink: 0;
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
        border: none !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
        white-space: nowrap;
        transition: transform 0.2s ease, background-color 0.2s ease !important;
        -webkit-tap-highlight-color: transparent; /* Remove default mobile tap highlight */
        /* Improve touch target size */
        min-height: 36px;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        /* Add snap scrolling */
        scroll-snap-align: start;
        /* Limit maximum width on small screens */
        max-width: 140px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    
    /* Special sizing for mobile portrait */
    @media (max-width: 480px) {
        .genre-pill {
            max-width: 100px !important; /* Reduced from 110px to have more pills in view */
            padding: 6px 8px !important;
            font-size: 0.7rem !important;
            /* Fix shadow rendering on mobile */
            box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important;
            width: auto !important; /* Allow buttons to size based on content */
            flex-basis: auto !important; /* Auto flex basis */
        }
    }
    
    /* Add touch feedback animation */
    .genre-pill:active {
        transform: scale(0.95) !important;
    }

    .genre-count {
        padding: 2px 6px !important;
        font-size: 0.7rem !important;
    }
    
    @media (max-width: 480px) {
        .genre-count {
            padding: 1px 4px !important;
            font-size: 0.65rem !important;
            margin-left: 3px !important;
            /* Match the reduced shadow effect */
            box-shadow: none !important;
        }
    }
    
}

/* Active state for category selection */
.genre-pill.active {
    background: var(--primary-color) !important;
    color: white !important;
}

/* ── 4b. Mobile fixes (small-screen pill / grid tuning) ────────────────────── */
/* Additional CSS fixes for mobile genre navigation buttons */
@media (max-width: 480px) {
    /* Fix for the genre pill width issue in portrait mode - optimized for space */
    .genre-pill {
        max-width: 100px !important; /* Reduced from 110px to have more pills in view */
        padding: 5px 7px !important; /* Slightly more compact */
        font-size: 0.7rem !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important; /* Lighter shadow for mobile */
        width: auto !important; /* Allow buttons to size based on content */
        flex-basis: auto !important; /* Auto flex basis */
        overflow: hidden !important;
        border-radius: 8px !important; /* Further reduced border radius for modern look */
        touch-action: manipulation !important; /* Improve touch response */
        -webkit-tap-highlight-color: transparent !important; /* Remove tap highlight on iOS */
    }
    
    /* Ensure genre name doesn't overflow - improved text handling */
    .genre-name {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 70px !important; /* Slightly increased for better readability */
        white-space: nowrap !important;
    }
    
    /* Fix for the genre count badge */
    .genre-count {
        padding: 1px 4px !important;
        font-size: 0.65rem !important;
        margin-left: 3px !important;
        box-shadow: none !important; /* Remove shadow from the count badge */
        min-width: 18px !important;
        text-align: center !important;
        border-radius: 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Adjust spacing for better arrangement */
    .genre-list {
        gap: 5px !important; /* Reduced from 6px for more compact layout */
        justify-content: flex-start !important; /* Ensure proper alignment */
        padding-bottom: 3px !important;
        overscroll-behavior-x: contain !important; /* Prevent page overscroll */
        scroll-padding: 0.5rem !important; /* Better scroll experience */
    }
    
    /* Fix for the active state of genre pills */
    .genre-pill.active, .genre-pill.selected {
        box-shadow: 0 2px 5px rgba(var(--primary-rgb), 0.2) !important;
    }
    
    /* Improve touch feedback */
    .genre-pill:active {
        transform: scale(0.95) !important;
        box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
    }
}

/* Additional fixes for very small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .genre-pill {
        max-width: 85px !important; /* Reduced from 90px for better screen usage */
        padding: 4px 5px !important; /* More compact padding */
        margin: 0 !important; /* Remove any margin */
    }
    
    .genre-name {
        max-width: 58px !important; /* Slightly increased */
        font-size: 0.65rem !important; /* Slightly smaller text */
    }
    
    .genre-count {
        min-width: 14px !important; /* Smaller count badge */
        font-size: 0.55rem !important; /* Smaller font for badge */
        padding: 1px 3px !important; /* Tighter padding */
    }
    
    .genre-list {
        gap: 3px !important; /* Further reduced gap */
        padding: 0 2px !important; /* Minimal padding */
    }
}

/* Unify the mobile genre pills with the desktop neutral-border style: the
   legacy rules above made them borderless, shadowed and width-clipped. The
   strip scrolls horizontally, so names don't need truncating. (!important is
   required only to override the legacy !important declarations above.) */
@media (max-width: 768px) {
    .genre-list .genre-pill {
        border: 1px solid var(--border-color) !important;
        border-radius: var(--radius-pill) !important;
        box-shadow: none !important;
        max-width: none !important;
        overflow: visible !important;
    }
    .genre-list .genre-pill.selected,
    .genre-list .genre-pill.active {
        border-color: var(--primary-color) !important;
    }
    .genre-list .genre-name { max-width: none !important; overflow: visible !important; }
}
@media (max-width: 768px) {
    /* Ottimizzazione della griglia di contenuti per occupare tutto lo spazio disponibile */
    .audiobook-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 10px !important;
        padding: 0 8px !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    /* Card dei contenuti ottimizzate per la visualizzazione mobile */
    .audiobook-card {
        width: 100% !important;
        min-height: 220px !important;
        margin: 0 !important;
    }
    
    /* Immagine di copertina ridimensionata per adattarsi meglio */
    .audiobook-cover {
        height: 140px !important;
        object-fit: cover !important;
    }
    
    /* Ridurre lo spazio occupato dall'intestazione */
    .site-header {
        padding: 8px 12px !important;
    }
    
    /* Migliorare l'esperienza di ricerca su mobile */
    .search-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 8px 0 !important;
    }
    
    .search-input {
        height: 40px !important;
        font-size: 0.9rem !important;
    }
}


/* ── 5. iOS safe-area & touch helpers ──────────────────────────────────────── */
/* File: tailwind-modern-ios.css */
/* Ottimizzazioni moderne per iOS con Tailwind */

/* Gestione dinamica del notch e altre aree di sicurezza su iOS */
.ios-safe-inset {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Stili specifici per il notch superiore */
.ios-top-safe {
  padding-top: env(safe-area-inset-top);
}

/* Stili specifici per la home indicator */
.ios-bottom-safe {
  padding-bottom: env(safe-area-inset-bottom);
}

/* Navigazione scorrevole migliorata per iOS */
.ios-scroll {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
}

/* Ottimizzazione dello scorrimento orizzontale */
.ios-scroll-x {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  max-width: 100vw;
  scrollbar-width: none;
}

.ios-scroll-x::-webkit-scrollbar {
  display: none; /* l0git: ignore hidden_scrollbar reason: horizontal scroller; swipe + edge affordance replace the bar */
}

/* Ottimizzazione dell'area di interazione tattile su iOS */
.ios-touch-target {
  min-height: 44px;
  min-width: 44px;
  padding: 8px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Animazioni ottimizzate per WebKit */
.ios-smooth-animation {
  -webkit-transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
  backface-visibility: hidden;
  transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1);
}

/* Stile avanzato dei pulsanti su iOS */
.ios-button {
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 500;
  background-color: var(--primary-color, #4a6cf7);
  color: white;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.ios-button:active {
  transform: scale(0.97);
  background-color: var(--primary-hover, #3a56d4);
}

/* Contenitori moderni per iOS */
.ios-card {
  border-radius: 12px;
  overflow: hidden;
  background-color: var(--card-background, #ffffff);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
}

/* Supporto per la modalità dark */
@media (prefers-color-scheme: dark) {
  .ios-card {
    background-color: var(--dark-card, #121212);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  }
}

/* Adattamenti per schermo iOS Portrait */
@media screen and (orientation: portrait) and (-webkit-min-device-pixel-ratio: 2) {
  .ios-portrait-adjust {
    width: calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right));
    margin-left: env(safe-area-inset-left);
    margin-right: env(safe-area-inset-right);
  }
}

/* ── 7. Cinematic hero (now-playing billboard) ─────────────────────────────── */
.audiobook-card { min-height: clamp(440px, 68vh, 640px); }

.hero {
    position: relative;
    display: flex;
    width: 100%;
    min-height: inherit;
    overflow: hidden;
    isolation: isolate;
}

.hero-backdrop {
    position: absolute;
    inset: -8%;
    z-index: 0;
    background-size: cover;
    background-position: center;
    filter: blur(48px) brightness(0.42) saturate(1.3);
    transform: scale(1.1);
}

.hero-scrim {
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
        linear-gradient(105deg, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.6) 44%, rgba(0,0,0,0.22) 100%),
        linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 55%);
}

.hero-body {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: clamp(1.5rem, 4vw, 3rem);
    width: 100%;
    padding: clamp(1.5rem, 4vw, 3rem);
}

.hero-media {
    flex: 0 0 clamp(280px, 34%, 420px);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.hero-media #youtube-player {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.hero-content {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    color: #fff;
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--primary-color);
}
.hero-eyebrow::before {
    content: "";
    width: 28px;
    height: 2px;
    border-radius: 2px;
    background: var(--primary-color);
}

.hero-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(2rem, 4.6vw, 3.4rem);
    font-weight: 600;
    line-height: 1.04;
    letter-spacing: -0.01em;
    color: #fff;
    text-shadow: 0 2px 24px rgba(0, 0, 0, 0.5);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-author {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 500;
    color: rgba(255, 255, 255, 0.82);
}
.hero-author b { color: #fff; font-weight: 600; }

.hero-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.hero-chip {
    padding: 0.2rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.hero-synopsis {
    margin: 0;
    max-width: 62ch;
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: rgba(255, 255, 255, 0.78);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.7);
}
.hero-meta-item { display: inline-flex; align-items: center; gap: 0.4em; }
.hero-meta-item svg { width: 15px; height: 15px; opacity: 0.85; }
.hero-meta-sep { opacity: 0.4; }

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-2);
}
.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.7rem 1.4rem;
    border: none;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform var(--dur) var(--ease-out), background-color var(--dur), box-shadow var(--dur);
}
.hero-cta svg { width: 18px; height: 18px; }
.hero-cta-primary {
    color: #111;
    background: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.hero-cta-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.hero-cta-secondary {
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(8px);
}
.hero-cta-secondary:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.26);
}

@media (max-width: 860px) {
    .hero-body { flex-direction: column; align-items: stretch; }
    .hero-media { flex-basis: auto; }
}
@media (prefers-reduced-motion: reduce) {
    .hero-cta:hover { transform: none; }
}

/* ── 8. Home rows (Netflix-style) ──────────────────────────────────────────── */
.home-rows {
    display: flex;
    flex-direction: column;
    gap: clamp(1.5rem, 3vw, 2.5rem);
    margin-top: clamp(1.5rem, 3vw, 2.5rem);
}
/* While a search-results or genre overlay is open, hide the home recommendation
   rows so those views aren't cluttered by the home content below them. */
body:has(#search-results-card) .home-rows,
body:has(#genre-books-grid-card) .home-rows { display: none; }
.nf-row { display: flex; flex-direction: column; gap: var(--space-3); }
.nf-row-title {
    margin: 0;
    font-size: var(--text-xl);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--header-color);
}
.nf-row-scroller {
    display: flex;
    gap: var(--space-4);
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 2px 14px;
}
.nf-row-scroller::-webkit-scrollbar { display: none; } /* l0git: ignore hidden_scrollbar reason: home-row scroller; edge arrows replace the bar */

.nf-row-viewport { position: relative; }
.nf-row-arrow {
    position: absolute;
    top: 4px;
    bottom: 14px;
    width: 56px;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    cursor: pointer;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur);
}
.nf-row-arrow svg { width: 26px; height: 26px; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.6)); }
.nf-row-arrow--left { left: 0; border-radius: var(--radius-md) 0 0 var(--radius-md); background: linear-gradient(to left, transparent, var(--background-color) 78%); }
.nf-row-arrow--right { right: 0; border-radius: 0 var(--radius-md) var(--radius-md) 0; background: linear-gradient(to right, transparent, var(--background-color) 78%); }
.nf-row-arrow:hover { background-color: transparent; transform: none; box-shadow: none; }
.nf-row-viewport.can-left .nf-row-arrow--left,
.nf-row-viewport.can-right .nf-row-arrow--right { pointer-events: auto; }
@media (hover: hover) {
    .nf-row-viewport:hover.can-left .nf-row-arrow--left,
    .nf-row-viewport:hover.can-right .nf-row-arrow--right { opacity: 1; }
}
@media (hover: none) {
    .nf-row-arrow { display: none; }
}

.nf-card {
    flex: 0 0 auto;
    width: clamp(160px, 22vw, 220px);
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 0;
    transition: transform var(--dur) var(--ease-out);
}
.nf-card-cover {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: linear-gradient(135deg, hsl(var(--cover-hue, 220) 42% 30%), hsl(calc(var(--cover-hue, 220) + 38) 48% 18%));
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--dur);
}
.nf-card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--dur) var(--ease-out), filter var(--dur);
}
.nf-card-cover.is-fallback .nf-card-img { display: none; }
.nf-card-cover.is-fallback::after {
    content: attr(data-initial);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 2.6rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}
/* background/box-shadow resets neutralise the global button:hover pill style
   (var(--primary) bg + 9999px radius) leaking onto these structural buttons. */
.nf-card:hover { transform: translateY(-4px); z-index: 2; background: none; box-shadow: none; }
.nf-card:hover .nf-card-cover { box-shadow: var(--shadow-lg); }
.nf-card:hover .nf-card-img { transform: scale(1.06); }
.nf-card:focus-visible { outline: none; }
.nf-card:focus-visible .nf-card-cover { box-shadow: 0 0 0 3px var(--focus-ring), var(--shadow-lg); }

.nf-card-play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 50%;
    backdrop-filter: blur(4px);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity var(--dur), transform var(--dur) var(--ease-out);
}
.nf-card-play svg { width: 22px; height: 22px; margin-left: 2px; }
.nf-card:hover .nf-card-play,
.nf-card:focus-visible .nf-card-play { opacity: 1; transform: scale(1); }

.nf-card-duration {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, 0.75);
}
.nf-card-body { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.nf-card-title {
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.nf-card-author {
    font-size: var(--text-xs);
    color: var(--secondary-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 600px) {
    .nf-card { width: 150px; }
}
@media (prefers-reduced-motion: reduce) {
    .nf-card:hover { transform: none; }
    .nf-card:hover .nf-card-img { transform: none; }
}

/* ── 9. Slim sticky top bar ────────────────────────────────────────────────── */
.site-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin: 0 0 var(--space-5);
    padding: var(--space-3) var(--space-2);
    text-align: left;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    transition: background-color var(--dur), box-shadow var(--dur), backdrop-filter var(--dur);
}
.site-bar::before { content: none; }
.site-bar.is-scrolled {
    background: var(--background-color);
    background: color-mix(in srgb, var(--background-color) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    box-shadow: 0 1px 0 var(--border-color), 0 6px 20px rgba(0, 0, 0, 0.12);
}
.site-brand { margin: 0; flex: none; }
.site-brand a {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    font-size: var(--text-xl);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--header-color);
}
.site-bar .search-container {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 440px;
    margin: 0;
    gap: var(--space-2);
}
.site-bar .search-container #search { min-width: 0; }
@media (max-width: 560px) {
    .site-brand a span { display: none; }
    .site-bar #search-button span { display: none; }
}

/* ── 10. Micro-interactions ────────────────────────────────────────────────── */
.home-rows.reveal .nf-row {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.55s var(--ease-out), transform 0.55s var(--ease-out);
}
.home-rows.reveal .nf-row.in-view {
    opacity: 1;
    transform: none;
}
.nf-card:hover .nf-card-img { filter: brightness(0.82); }

/* Even, responsive results grid (cards fill their cell instead of left-aligning). */
.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: var(--space-5) var(--space-4);
}
.search-grid .nf-card { width: auto; }
/* 170px min collapses to one full-width column on phones; force two. */
@media (max-width: 600px) {
    .search-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-4) var(--space-3);
    }
}

/* ── 11. Header main nav (row 1) + genre strip (row 2) ─────────────────────── */
.main-nav {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    margin-left: var(--space-6);
    margin-right: auto;
}
.nav-link {
    position: relative;
    text-decoration: none;
    color: var(--secondary-text);
    font-weight: 600;
    font-size: var(--text-sm);
    transition: color var(--dur);
}
.nav-link:hover, .nav-link:focus-visible { color: var(--text-color); }
.nav-link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width var(--dur);
}
.nav-link:hover::after { width: 100%; }
@media (max-width: 720px) { .main-nav { display: none; } }

/* Genre strip = header row 2: one scrollable line (no wrapping on desktop) */
.genre-navigation {
    margin: var(--space-2) 0 0;
    padding: var(--space-2) 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}
.genre-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-behavior: smooth;
    /* overflow-x:auto forces overflow-y clipping; top/bottom padding gives the
       pill's hover lift, rounded top and focus ring room so they aren't cut. */
    padding: 6px 0 4px;
}
.genre-list::-webkit-scrollbar { display: none; } /* l0git: ignore hidden_scrollbar reason: genre strip scroller; edge arrows replace the bar */
/* keep pills at natural width so the row scrolls instead of squashing them */
.genre-list .genre-pill { flex-shrink: 0; }

/* Genre strip reuses the home-row arrows, but it's a thin light strip — so the
   chevrons need page-foreground colour (the row version is white-on-image). */
.genre-viewport { padding: 0; }
.genre-viewport .nf-row-arrow { top: 0; bottom: 4px; width: 48px; color: var(--header-color); }
.genre-viewport .nf-row-arrow svg { filter: drop-shadow(0 1px 2px var(--background-color)); }

/* "Tutti i generi" pill: a primary-tinted link to the full /generi/ index. */
.genre-pill-all { gap: var(--space-1); color: var(--primary-color); text-decoration: none; border-color: rgba(var(--primary-rgb), 0.45); }
.genre-pill-all:hover { background: rgba(var(--primary-rgb), 0.08); border-color: var(--primary-color); }
.genre-all-arrow { font-weight: 700; }

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

/* Restore a consistent horizontal gutter: .ios-safe-inset's env() padding
   collapses to 0 off-notch devices, which zeroed the container's 2rem. */
.container.ios-safe-inset {
    padding-left: max(var(--space-6), env(safe-area-inset-left));
    padding-right: max(var(--space-6), env(safe-area-inset-right));
}