:root {
    /* Surfaces - layered depth */
    --surface-bg: rgba(255, 255, 255, 0.03);
    --surface-bg-hover: rgba(255, 255, 255, 0.06);
    --surface-bg-active: rgba(79, 143, 224, 0.08);
    --surface-border: rgba(255, 255, 255, 0.06);
    --surface-border-hover: rgba(255, 255, 255, 0.1);
    --surface-blur: blur(12px);
    --surface-blur-strong: blur(20px);

    /* Background hierarchy */
    --bg-primary: #090A0E;
    --bg-surface: #0F1319;
    --bg-surface-hover: #151A22;
    --bg-card: #0F1319;
    --bg-card-hover: #151A22;
    --bg-input: #090A0E;
    --bg-sidebar: #0B0D10;
    --bg-elevated: rgba(20, 26, 36, 0.85);
    --bg-glass: rgba(15, 19, 25, 0.6);

    /* Glass utility */
    --glass-bg: rgba(15, 19, 25, 0.6);
    --glass-blur: blur(12px);
    --glass-blur-strong: blur(20px);
    --glass-border: rgba(255, 255, 255, 0.04);

    /* Accent palette */
    --accent-primary: #4F8FE0;
    --accent-primary-hover: #6BA3E8;
    --accent-primary-subtle: rgba(79, 143, 224, 0.08);
    --accent-primary-glow: rgba(79, 143, 224, 0.15);

    /* Filled controls only — darkened so white labels clear WCAG AA.
       --accent-primary stays the hue for text, icons and borders.
       Hover darkens rather than lightens: lightening drops the pair back
       below 4.5:1. Deviates from 04-design-system.md change-log #1, whose
       #3B7ACB measures 4.35:1. See docs/REDESIGN_IMPLEMENTATION_AUDIT.md. */
    --accent-primary-solid: #3874C2;
    --accent-primary-solid-hover: #3369B0;

    --accent-gold: #C89B3C;
    --accent-gold-hover: #D4AA4D;
    --accent-gold-subtle: rgba(200, 155, 60, 0.08);

    --accent-violet: #7C5CBF;
    --accent-violet-hover: #9174CF;
    --accent-violet-subtle: rgba(124, 92, 191, 0.08);

    /* Backward-compatible aliases */
    --accent: #4F8FE0;
    --accent-hover: #6BA3E8;
    --accent-subtle: rgba(79, 143, 224, 0.08);
    --accent-glow: rgba(79, 143, 224, 0.15);
    --bg-secondary: #0F1319;

    /* Semantic colors */
    --success: #4FB885;
    --success-bg: rgba(79, 184, 133, 0.1);
    --warning: #F4B860;
    --warning-bg: rgba(244, 184, 96, 0.1);
    --danger: #FF6B6B;
    --danger-bg: rgba(255, 107, 107, 0.1);
    --info: #4F8FE0;
    --info-bg: rgba(79, 143, 224, 0.1);

    /* Highlight palette — reader-chosen, never system-assigned. Identity
       colors: identical in both themes. */
    --highlight-yellow: #F4B860;
    --highlight-green: #4FB885;
    --highlight-blue: #4F8FE0;
    --highlight-pink: #E87DA0;
    --highlight-purple: #7C5CBF;
    --highlight-orange: #F49D4F;

    /* Source identity — used only in source badges. */
    --source-royalroad: #d4a574;
    --source-scribblehub: #74b9d4;
    --source-webnovel: #a574d4;
    --source-wuxiaworld: #d47474;
    --source-mvlempyr: #d4b450;

    /* Text hierarchy */
    --text-primary: #EEF0F4;
    --text-secondary: #B0B8C4;
    --text-muted: #9AA3B0;
    --text-dim: #8A93A0;

    /* Borders & Shadows */
    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.03);
    --border-hover: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.15);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 3px 8px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 6px 16px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 10px 30px rgba(0, 0, 0, 0.35);

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    --radius: 8px;

    /* Typography */
    --font-display: 'Satoshi', 'Cabinet Grotesk', Inter, -apple-system, sans-serif;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    /* Type scale
     *
     * Phase 8. Body was 0.875rem (14px) and caption 0.75rem (12px) — small for
     * any interface, and hard to defend in a product whose subject is reading.
     * 12px captions carry timestamps, chapter counts and helper text
     * throughout, so the floor mattered more than the ceiling.
     *
     * Raised to a 15px body and 13px caption. The components written in
     * Phases 3–7 already assumed these values in their var() fallbacks, so
     * this aligns the tokens with what the newer surfaces were designed
     * against rather than shifting them.
     */
    --display: 2.25rem;
    --heading: 1.375rem;
    --section: var(--heading);
    --title: 1.1rem;
    --body: 0.9375rem;
    --caption: 0.8125rem;
    --xs: 0.6875rem;
    --data: 0.875rem;

    /* Weights */
    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --weight-extrabold: 800;

    /* Leading */
    --leading-tight: 1.2;
    --leading-display: 1.15;
    --leading-normal: 1.5;
    --leading-relaxed: 1.6;

    /* Tracking */
    --tracking-tight: -0.02em;
    --tracking-display: -0.015em;
    --tracking-normal: 0;
    --tracking-wide: 0.06em;

    /* Spacing */
    --space-1: 0.25rem;
    --space-1_5: 0.375rem;
    --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;
    --space-16: 4rem;

    /* Layout */
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 64px;
    --topbar-height: 48px;
    --mobile-nav-height: 56px;

    /* Brand gradient system */
    --gradient-brand: linear-gradient(135deg, #4F8FE0, #7C5CBF);
    --gradient-brand-vertical: linear-gradient(180deg, #4F8FE0, #7C5CBF);
    --gradient-subtle: linear-gradient(135deg, rgba(79, 143, 224, 0.08), rgba(124, 92, 191, 0.05));
    --gradient-glow: radial-gradient(ellipse at 50% 0%, rgba(79, 143, 224, 0.12) 0%, transparent 60%);
    --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);

    /* Brand glow */
    --glow-brand: 0 0 20px rgba(79, 143, 224, 0.15);
    --glow-accent: 0 0 12px rgba(79, 143, 224, 0.1);

    /* Section labels */
    --section-eyebrow: 0.65rem;
    --section-eyebrow-weight: 600;
    --section-eyebrow-tracking: 0.08em;

    /* Motion */
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;
    --transition-enter: 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-exit: 0.15s ease-in;
    --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --surface-bg: rgba(0, 0, 0, 0.03);
    --surface-bg-hover: rgba(0, 0, 0, 0.06);
    --surface-bg-active: rgba(79, 143, 224, 0.06);
    --surface-border: rgba(0, 0, 0, 0.06);
    --surface-border-hover: rgba(0, 0, 0, 0.1);

    --bg-primary: #F5F6F8;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #F0F2F5;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F0F2F5;
    --bg-input: #F0F2F5;
    --bg-sidebar: #F5F6F8;
    --bg-elevated: #FFFFFF;
    --bg-glass: rgba(255, 255, 255, 0.6);
    --bg-secondary: #FFFFFF;

    --accent-primary: #2F6FB8;
    --accent-primary-hover: #255A96;
    --accent-primary-subtle: rgba(74, 144, 217, 0.06);
    --accent-primary-glow: rgba(74, 144, 217, 0.12);
    --accent-primary-solid: #2F6FB8;
    --accent-primary-solid-hover: #2A6299;
    --accent-gold: #D4A017;
    --accent-gold-hover: #C4960A;
    --accent-gold-subtle: rgba(212, 160, 23, 0.08);
    --accent-violet: #6B4FA8;
    --accent-violet-hover: #7C5CBF;
    --accent-violet-subtle: rgba(107, 79, 168, 0.08);

    --accent: #2F6FB8;
    --accent-hover: #255A96;
    --accent-subtle: rgba(74, 144, 217, 0.06);
    --accent-glow: rgba(74, 144, 217, 0.12);

    --success: #3CB371;
    --success-bg: rgba(60, 179, 113, 0.08);
    --warning: #D4A017;
    --warning-bg: rgba(212, 160, 23, 0.08);
    --danger: #E05555;
    --danger-bg: rgba(224, 85, 85, 0.08);
    --info: #4A90D9;
    --info-bg: rgba(74, 144, 217, 0.08);

    --text-primary: #1A1D23;
    --text-secondary: #4A4F56;
    --text-muted: #5F6670;
    --text-dim: #6B7280;

    --border: rgba(0, 0, 0, 0.06);
    --border-light: rgba(0, 0, 0, 0.03);
    --border-hover: rgba(0, 0, 0, 0.1);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 3px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 6px 16px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 10px 30px rgba(0, 0, 0, 0.1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    background: var(--bg-primary, #0B0D10);
    color: var(--text-secondary, #C8CED6);
    line-height: var(--leading-relaxed, 1.6);
    min-height: 100vh;
    font-size: var(--body, 0.875rem);
    font-weight: var(--weight-normal, 400);
}

::selection {
    background: var(--accent-subtle, rgba(94, 161, 255, 0.08));
    color: var(--text-primary, #F3F5F7);
}

:focus-visible {
    outline: 2px solid var(--accent-primary, #5EA1FF);
    outline-offset: 2px;
    border-radius: var(--radius-sm, 4px);
}

/* Skip link — lets keyboard and screen-reader users jump past the sidebar and
   topbar straight to page content. Visually hidden until focused. */
.skip-link {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1000;
    padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
    background: var(--bg-elevated, #14161C);
    color: var(--text-primary, #F3F5F7);
    border: 1px solid var(--border, #262A33);
    border-radius: 0 0 var(--radius-md, 8px) 0;
    transform: translateY(-150%);
    transition: transform 0.15s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

/* Respect users who have asked the OS to reduce motion. The app uses fade-in,
   scale-in and progress-bar transitions throughout. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

a {
    color: var(--text-primary, #F3F5F7);
    text-decoration: none;
    transition: color var(--transition, 0.2s ease);
}
a:hover {
    color: var(--accent-primary, #5EA1FF);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary, #F3F5F7);
    font-weight: var(--weight-semibold, 600);
    line-height: var(--leading-tight, 1.2);
    letter-spacing: var(--tracking-tight, -0.02em);
}

h1 { font-size: var(--heading, 1.5rem); margin-bottom: var(--space-2, 0.5rem); }
h2 { font-size: var(--title, 1.125rem); margin-bottom: var(--space-2, 0.5rem); }
h3 { font-size: var(--body, 0.875rem); margin-bottom: var(--space-1, 0.25rem); }

p { margin-bottom: var(--space-2, 0.5rem); }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

img { max-width: 100%; height: auto; display: block; background: var(--surface-bg, #14181C); color: transparent; }

button, input, select, textarea {
    font-family: var(--font);
}

.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

.app-layout-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-slow);
}

.page-content {
    flex: 1;
    padding: var(--space-6) var(--space-8) var(--space-12);
    max-width: 1200px;
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-center { align-items: center; justify-content: center; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.navbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 var(--space-6);
    max-width: 1100px;
    margin: 0 auto;
}

.nav-brand {
    font-weight: var(--weight-bold);
    font-size: var(--title);
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.nav-toggle:hover {
    background: var(--surface-bg-hover);
}

.nav-toggle:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.nav-link {
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: var(--weight-medium);
    border: 1px solid transparent;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.nav-link:hover {
    background: var(--surface-bg-hover);
    border-color: var(--border);
    color: var(--text-primary);
}

.nav-ext-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1_5);
    padding: var(--space-1_5) var(--space-4);
    border-radius: var(--radius-full);
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    font-weight: var(--weight-semibold);
    font-size: var(--caption);
    border: 1px solid rgba(79, 143, 224, 0.2);
    transition: all var(--transition-smooth);
    text-decoration: none;
}

.nav-ext-link:hover {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(79, 143, 224, 0.3);
}

.nav-ext-link svg {
    width: 14px;
    height: 14px;
}

/* Mobile nav enhancements */
@media (max-width: 600px) {
    .navbar {
        position: relative;
        top: auto;
    }

    .nav-inner {
        padding: 0 var(--space-4);
    }

    .nav-toggle {
        display: flex;
    }

    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border);
        padding: var(--space-2);
        gap: 2px;
        transform: translateY(-8px);
        opacity: 0;
        visibility: hidden;
        transition: transform var(--transition-smooth), opacity var(--transition-smooth), visibility var(--transition-smooth);
        pointer-events: none;
    }

    .nav-links.nav-open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .nav-link {
        padding: var(--space-3) var(--space-4);
        font-size: var(--body);
        width: 100%;
        text-align: center;
    }

    .nav-ext-link {
        margin: var(--space-1) var(--space-2);
        justify-content: center;
    }
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
}

.card-glass {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.card-cover {
    position: relative;
    overflow: hidden;
}

.card-cover img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: var(--radius-lg);
    background: var(--surface-bg);
    display: block;
}

.card-cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(9, 10, 14, 0.85));
    border-radius: var(--radius-lg);
}

.card-body {
    padding: var(--space-3) 0 0;
}

.card-title {
    font-family: var(--font-display);
    font-size: var(--title);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    line-height: var(--leading-tight);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-title a {
    color: var(--text-primary);
    text-decoration: none;
}
.card-title a:hover {
    color: var(--accent-primary);
}

.card-meta {
    font-size: var(--caption);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.chart-card {
    min-height: 0;
}

.card-compact {
    padding: var(--space-3) var(--space-4);
}

.queue-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-2);
    transition: border-color var(--transition);
}

.queue-item:hover {
    border-color: var(--border-hover);
}

.queue-drag-handle {
    cursor: grab;
    color: var(--text-dim);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: var(--space-1);
}

.queue-content {
    flex: 1;
    min-width: 0;
}

.queue-title-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-1);
}

.queue-title {
    font-size: var(--body);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
}

.queue-title:hover {
    color: var(--accent-primary);
}

.queue-meta {
    font-size: var(--caption);
    color: var(--text-muted);
}

.queue-notes {
    font-size: var(--caption);
    color: var(--text-dim);
    margin-top: var(--space-1);
}

.dashboard-bottom-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.settings-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-6) 0;
}

.current-info {
    font-size: var(--caption);
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.token-status-connected {
    color: var(--success);
    font-weight: 600;
}

.token-status-idle {
    color: var(--text-muted);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--caption);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--accent-primary);
}

.period-links {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.active-period {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    border-color: transparent;
}

.chart-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.user-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-3);
}

.collection-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.feed-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    transition: border-color var(--transition);
}

.feed-card:hover {
    border-color: var(--border-hover);
}

.feed-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.pwa-settings {
    margin-top: var(--space-4);
    padding: var(--space-4);
    background: var(--surface-bg);
    border-radius: var(--radius-md);
}

.verify-code-input {
    font-size: var(--heading);
    letter-spacing: 0.3em;
    text-align: center;
    font-weight: var(--weight-bold);
}

.verify-code-input::placeholder {
    font-size: var(--body);
    letter-spacing: normal;
    font-weight: var(--weight-normal);
}

/* Collapsible card — progressive disclosure for reference/maintenance panels
   (cover management, per-novel notification overrides, source metadata) that
   would otherwise compete with reading actions for attention. Uses native
   <details>/<summary> so it works without JS and stays keyboard accessible. */
.card-collapsible > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.card-collapsible > summary::-webkit-details-marker {
    display: none;
}

.card-collapsible > summary::after {
    content: '';
    width: 8px;
    height: 8px;
    flex-shrink: 0;
    border-right: 2px solid var(--text-dim);
    border-bottom: 2px solid var(--text-dim);
    transform: rotate(45deg) translateY(-2px);
    transition: transform var(--transition);
}

.card-collapsible[open] > summary::after {
    transform: rotate(-135deg) translateY(-2px);
}

.card-collapsible > summary:hover::after {
    border-color: var(--text);
}

.card-collapsible > summary:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.card-summary-title {
    margin: 0;
    font-size: inherit;
    display: inline;
}

/* Queue: four classes the markup has always carried and no rule ever defined.
   Implemented from screen spec 09 (Reading Queue), not invented here. */

/* The list is an <ol>. Its markers are replaced by .queue-position, which is
   rendered visibly and hidden from assistive tech — the <ol> already conveys
   position, so announcing both would say every number twice. */
.queue-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Spec §3: position is shown, because "top of your queue" is why Home picks
   it. Spec §11: chapter numbers and ordinals use tabular figures, so the
   column does not jitter as rows reorder. */
.queue-position {
    flex-shrink: 0;
    min-width: 1.5rem;
    font-size: var(--small);
    font-weight: var(--weight-medium);
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
    text-align: right;
}

/* Spec §11: trailing cluster on desktop, and every target at least 44px.
   Wrapping rather than shrinking keeps that floor on a narrow row. */
.queue-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* The add control under the list: a labelled picker and one button. */
.queue-add {
    margin-top: var(--space-4, 1rem);
}

.queue-add-label {
    display: block;
    margin-bottom: var(--space-2, 0.5rem);
    font-size: var(--small, 0.875rem);
    color: var(--text-secondary, #A7AEBB);
}

.queue-add-row {
    display: flex;
    gap: var(--space-2, 0.5rem);
}

.queue-add-select {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
    background: var(--bg-input, #090A0E);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: var(--radius-md, 8px);
    color: var(--text-primary, #EEF0F4);
    font-size: var(--body, 0.9375rem);
}

/* Spec §7 and §10: a caught-up row is not actionable today, so it is
   de-emphasised and offered for removal rather than silently occupying a slot
   the reader thinks is a plan.
   De-emphasis is a lighter surface and dimmer text, not opacity: opacity would
   fade the Remove control the spec asks to keep available, and would drop the
   text below its contrast floor. */
.queue-item--caught-up {
    background: var(--bg-primary);
    border-style: dashed;
}

.queue-item--caught-up .queue-title,
.queue-item--caught-up .queue-meta {
    color: var(--text-muted);
}

/* The queue's facts read as one line: "45 unread chapters · 0 of 45 read". */
.queue-meta > span + span::before {
    content: "\00B7";
    margin: 0 0.3em 0 0.1em;
}

/* On a phone the row had a handle, two arrows, a number and a button beside
   the title, inside a card inside a card, so a title took three lines (UX
   audit 6.3). The arrows do the moving there, so the handle goes, and the
   outer card gives its padding back to the rows. */
@media (max-width: 599px) {
    .queue-list.card {
        padding: 0;
        background: none;
        border: none;
        box-shadow: none;
    }

    .queue-item {
        gap: var(--space-2, 8px);
        padding: var(--space-3, 12px);
    }

    .queue-drag-handle { display: none; }

    .queue-item .reorder-controls { margin-right: 0; }

    .queue-position { min-width: 1rem; }
}

/* --- Novel Card (Library) --- */
.novel-card {
    display: flex;
    gap: var(--space-5);
    align-items: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    box-shadow: var(--shadow);
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth), transform var(--transition-smooth);
    position: relative;
    overflow: hidden;
    /* left accent bar via ::before */
}
.novel-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    border-radius: 0 2px 2px 0;
}
.novel-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg), var(--glow-accent);
    transform: translateY(-1px);
}

/* Accent modifiers for reading status */
.novel-card-accent-reading::before { background: var(--gradient-brand); }
.novel-card-accent-plan_to_read::before { background: var(--accent-violet); }
.novel-card-accent-completed::before { background: var(--success); }
.novel-card-accent-on_hold::before { background: var(--accent-gold); }
.novel-card-accent-dropped::before { background: var(--danger); }
.novel-card-accent-re_reading::before { background: var(--gradient-brand); }

.card-img-wrap {
    flex-shrink: 0;
    width: 72px;
    position: relative;
}

.card-img {
    width: 72px;
    height: 104px;
    object-fit: cover;
    border-radius: var(--radius-md);
    background: var(--surface-bg);
    display: block;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.card-body .flex-between {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
}

.card-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--body);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    line-height: var(--leading-tight);
}
.card-title a {
    color: var(--text-primary);
    text-decoration: none;
}
.card-title a:hover {
    color: var(--accent-primary);
}

.card-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: var(--caption);
}

.card-stat {
    margin: 0;
    font-size: var(--caption);
    color: var(--text-dim);
}

/* --- Novel Card Item (Browse/Discover) --- */
.novel-card-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth), transform var(--transition-smooth);
    overflow: hidden;
}

.novel-card-item:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg), var(--glow-accent);
    transform: translateY(-1px);
}

.novel-card-link {
    display: flex;
    gap: var(--space-5);
    padding: var(--space-4);
    text-decoration: none;
    color: inherit;
}

.novel-card-cover {
    flex-shrink: 0;
    width: 80px;
}

.novel-card-cover img {
    width: 80px;
    height: 116px;
    object-fit: cover;
    border-radius: var(--radius-md);
    background: var(--surface-bg);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    display: block;
}

.novel-card-body {
    flex: 1;
    min-width: 0;
}

.novel-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-1);
}

.novel-card-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--body);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

.novel-card-link:hover .novel-card-title {
    color: var(--accent-primary);
}

.novel-card-header-right {
    display: flex;
    gap: var(--space-1);
    align-items: center;
    flex-shrink: 0;
}

.novel-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    font-size: var(--caption);
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.novel-card-footer {
    margin-top: var(--space-2);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.novel-card-actions {
    margin-top: var(--space-2);
}

/* Grid layout for browse/tag pages */
.novel-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* Tracking count badge */
.tracking-badge {
    font-size: var(--xs);
    color: var(--text-dim);
    background: var(--surface-bg);
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* Tag cloud */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
}

.tag-cloud-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-full);
    background: var(--surface-bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: var(--caption);
    font-weight: var(--weight-medium);
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.tag-cloud-item:hover {
    background: var(--surface-bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.tag-cloud-item.tag-sm {
    font-size: var(--xs);
    padding: 0.2rem 0.5rem;
}

.tag-cloud-item.tag-md {
    font-size: var(--caption);
}

.tag-cloud-item.tag-lg {
    font-size: var(--body);
    font-weight: var(--weight-semibold);
    padding: 0.4rem 1rem;
}

.tag-count {
    font-size: var(--xs);
    color: var(--text-dim);
    background: var(--bg-card);
    padding: 0.05rem 0.35rem;
    border-radius: var(--radius-sm);
}

/* Detail tags in sidebar */
.detail-row-tags {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.detail-tags .tag {
    font-size: var(--xs);
}

/* --- Tracked Novel Card (Dashboard partial) --- */
.tracked-novel-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

.tracked-novel-card:hover {
    box-shadow: var(--shadow-lg);
}

.tracked-novel-cover {
    width: 40px;
    height: 56px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface-bg);
}

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

.tracked-novel-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
}

.tracked-novel-info {
    flex: 1;
    min-width: 0;
}

.tracked-novel-title {
    font-weight: var(--weight-semibold);
    font-size: var(--body);
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tracked-novel-title:hover {
    color: var(--accent-primary);
}

.tracked-novel-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-2);
    font-size: var(--caption);
    color: var(--text-muted);
}

.tracked-novel-chapter {
    text-align: right;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
}

.tracked-novel-link {
    font-weight: var(--weight-bold);
    font-size: var(--body);
    color: var(--accent-primary);
}

.tracked-novel-link:hover {
    color: var(--accent-hover);
}

.tracked-novel-chapter .time {
    font-size: var(--xs);
    color: var(--text-dim);
    white-space: nowrap;
}

.tracked-novel-progress {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.tracked-novel-progress .progress-bar-wrap {
    flex: 1;
    height: 4px;
    background: var(--surface-bg);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.tracked-novel-progress .progress-bar {
    height: 100%;
    background: var(--gradient-brand);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.tracked-novel-progress-label {
    font-size: var(--xs);
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Discover Page Track Button --- */
.novel-card-actions {
    margin-top: var(--space-3);
    display: flex;
    align-items: center;
}

.btn-discover-track {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.25rem 0.75rem;
    font-size: var(--xs);
    font-weight: var(--weight-semibold);
    font-family: var(--font);
    line-height: 1.4;
    background: var(--accent-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.btn-discover-track:hover {
    background: var(--accent-primary-hover);
    box-shadow: none;
    transform: translateY(-1px);
}

.btn-discover-track svg {
    width: 10px;
    height: 10px;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-discover-track:hover svg {
    transform: rotate(90deg) scale(1.15);
}

.badge-tracked {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.65rem;
    font-size: var(--xs);
    font-weight: var(--weight-semibold);
    font-family: var(--font);
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(79, 184, 133, 0.25);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-tracked svg {
    width: 9px;
    height: 9px;
}

.tracked-novel-actions {
    display: flex;
    gap: var(--space-1);
    margin-top: 0;
}

.tracked-novel-actions .btn-sm {
    font-size: var(--xs);
    padding: var(--space-1) var(--space-2);
    min-height: 28px;
}

.tracked-novel-unread {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: var(--accent-subtle);
    color: var(--accent-primary);
    font-size: var(--xs);
    font-weight: var(--weight-bold);
    border-radius: var(--radius-full);
    margin-left: 0.35rem;
}

.discovery-empty {
    text-align: center;
    padding: var(--space-10) var(--space-6);
    margin-bottom: var(--space-6);
}

.discovery-empty-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-4);
    opacity: 0.4;
}

.discovery-empty h3 {
    margin-bottom: var(--space-3);
}

.discovery-empty p {
    max-width: 480px;
    margin: 0 auto var(--space-2);
    line-height: var(--leading-relaxed);
}

.discovery-note {
    text-align: center;
    font-size: var(--caption);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
    padding: var(--space-2) var(--space-3);
    background: var(--surface-bg);
    border-radius: var(--radius-md);
}

.plans-page {
    margin: 0 auto;
    text-align: center;
}

.plans-header {
    margin-bottom: var(--space-8);
}

.plans-header h1 {
    font-size: var(--display);
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-display);
    margin-bottom: var(--space-2);
}

.plans-header p {
    color: var(--text-secondary);
    max-width: 440px;
    margin: 0 auto;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    align-items: stretch;
}

@media (max-width: 860px) {
    .plans-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        max-width: 600px;
    }
}

.plan-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 0;
    overflow: hidden;
    position: relative;
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth), transform var(--transition-smooth);
}

.plan-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.plan-card:nth-child(2) {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.1), var(--shadow-lg);
    transform: scale(1.03);
    z-index: 1;
}

.plan-card:nth-child(2):hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.plan-card-accent {
    height: 3px;
    width: 100%;
    flex-shrink: 0;
}

.plan-card-accent-free {
    background: var(--border);
}

.plan-card-accent-pro {
    background: var(--accent-primary);
}

.plan-card-accent-premium {
    background: var(--accent-violet);
}

.plan-card-body {
    padding: var(--space-6);
    flex: 1;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.plan-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-3);
}

.plan-card-name {
    font-size: var(--heading);
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

.plan-card-price {
    margin-bottom: var(--space-4);
}

.plan-card-amount {
    font-size: 2.5rem;
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
    font-family: var(--font-display);
    line-height: 1.1;
}

.plan-card-interval {
    font-size: var(--body);
    color: var(--text-muted);
    margin-left: var(--space-1);
    font-weight: var(--weight-normal);
}

.plan-card-desc {
    font-size: var(--caption);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
    margin-bottom: var(--space-5);
}

.plan-card-features {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-6);
    flex: 1;
}

.plan-card-feature {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) 0;
    font-size: var(--caption);
    color: var(--text-secondary);
    line-height: var(--leading-normal);
}

.plan-card-feature + .plan-card-feature {
    border-top: 1px solid var(--border);
}

.plan-card-feature-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 11px;
    line-height: 1;
}

.plan-card-feature-icon--yes {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
}

.plan-card-feature-icon--no {
    background: transparent;
    color: var(--text-dim);
}

.plan-card-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

.plan-card-badge--popular {
    background: var(--accent-primary-solid);
    color: #fff;
}

.plan-card-badge--current {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
}

.plan-card-form {
    margin: 0;
    display: contents;
}
.plan-card-cta {
    display: block;
    width: 100%;
    text-align: center;
    padding: var(--space-3) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--body);
    font-weight: var(--weight-semibold);
    font-family: inherit;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition-smooth);
    margin-top: auto;
    letter-spacing: var(--tracking-wide);
}
.plan-card-cta:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.btn-subscribe--loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn-subscribe--loading::after {
    content: '';
    position: absolute;
    inset: 50% auto auto 50%;
    width: 1rem;
    height: 1rem;
    margin: -0.5rem 0 0 -0.5rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

.plan-card-cta--primary {
    background: var(--accent-primary);
    color: #fff;
}

.plan-card-cta--primary:hover {
    background: var(--accent-primary-hover);
    color: #fff;
}

.plan-card-cta--outline {
    border: 1.5px solid var(--border);
    color: var(--text-primary);
    background: transparent;
}

.plan-card-cta--outline:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-primary-subtle);
}

.plan-card-cta--current {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    cursor: default;
    pointer-events: none;
}

.plan-card-cta--danger {
    border: 1px solid var(--danger);
    color: var(--danger);
}

.plan-card-cta--danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* Manage page */
.manage-page {
    max-width: 560px;
    margin: 0 auto;
}

.manage-plan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.manage-plan-accent {
    height: 2px;
    width: 100%;
    background: var(--accent-primary);
}

.manage-plan-body {
    padding: var(--space-5);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.manage-plan-info-name {
    font-size: var(--heading);
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.manage-plan-info-price {
    font-size: var(--body);
    color: var(--text-secondary);
}

.manage-plan-status-area {
    text-align: right;
}

.manage-plan-status {
    display: inline-flex;
    padding: 2px 12px;
    border-radius: var(--radius-full);
    font-size: var(--caption);
    font-weight: var(--weight-medium);
}

.manage-plan-status--active {
    background: var(--success-bg);
    color: var(--success);
}

.manage-plan-status--canceled {
    background: var(--warning-bg);
    color: var(--warning);
}

.manage-plan-status--expired {
    background: var(--danger-bg);
    color: var(--danger);
}

.manage-plan-status--trialing {
    background: var(--info-bg);
    color: var(--info);
}

.manage-plan-renewal {
    font-size: var(--caption);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.manage-plan-days {
    font-size: var(--caption);
    color: var(--text-muted);
    margin-top: var(--space-2);
    padding: 0 var(--space-5);
    padding-bottom: var(--space-3);
}

.manage-section {
    margin-top: var(--space-4);
}

.manage-section h3 {
    font-size: var(--title);
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-3);
}

.manage-section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
}

.manage-feature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.manage-feature-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
}

.manage-feature-row:nth-last-child(-n+2) {
    border-bottom: none;
}

.manage-feature-icon {
    width: 20px;
    flex-shrink: 0;
    text-align: center;
    font-weight: var(--weight-bold);
}

.manage-feature-icon--yes {
    color: var(--accent-primary);
}

.manage-feature-icon--no {
    color: var(--text-dim);
}

.manage-feature-label {
    font-size: var(--caption);
    color: var(--text-secondary);
}

.manage-plan-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.manage-plan-link {
    flex: 1;
    min-width: 140px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--body);
    font-weight: var(--weight-medium);
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--text-primary);
    transition: all var(--transition-smooth);
    cursor: pointer;
}

.manage-plan-link:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.manage-plan-link--danger {
    border-color: var(--danger);
    color: var(--danger);
    background: transparent;
}

.manage-plan-form {
    flex: 1;
    min-width: 140px;
}

.manage-plan-link--danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.manage-cancel-notice {
    margin-top: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--accent-gold-subtle);
    border: 1px solid rgba(200, 155, 60, 0.15);
    border-radius: var(--radius-md);
    font-size: var(--caption);
    color: var(--accent-gold);
}

.manage-expired-card {
    text-align: center;
    padding: var(--space-6);
}

.manage-expired-card h3 {
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.manage-expired-card p {
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

/* Billing toggle (monthly / yearly) */
.billing-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
}

.billing-toggle-label {
    font-size: var(--body);
    color: var(--text-muted);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: color var(--transition-fast);
    user-select: none;
}

.billing-toggle-label--active {
    color: var(--text-primary);
    font-weight: var(--weight-semibold);
}

.billing-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.billing-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.billing-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
}

.billing-toggle-slider::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-primary);
    transition: transform var(--transition-fast);
}

.billing-toggle-switch input:checked + .billing-toggle-slider::before {
    transform: translateX(20px);
}

.billing-toggle-save {
    font-size: var(--xs);
    color: var(--accent-primary);
    font-weight: var(--weight-semibold);
    background: var(--accent-primary-subtle);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

/* Price display */
.plan-card-price {
    position: relative;
}

.plan-card-amount--monthly,
.plan-card-amount--yearly {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-1);
}

.plan-card-amount--monthly[hidden],
.plan-card-amount--yearly[hidden] {
    display: none;
}

.plan-card-interval {
    font-size: var(--body);
    color: var(--text-muted);
    font-weight: var(--weight-normal);
}

@media (max-width: 640px) {
    .billing-toggle {
        flex-wrap: nowrap;
        padding: var(--space-2) var(--space-3);
        gap: var(--space-2);
    }
    .billing-toggle-save {
        display: none;
    }
}
/* Plan-allowance nudge (_quota_notice.html) — surfaces the tracking/collection
   ceiling as it approaches instead of letting it interrupt an action. */
.quota-notice {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent-gold);
    border-radius: var(--radius-lg);
}

.quota-notice--full {
    border-left-color: var(--accent-primary);
}

.quota-notice-body {
    flex: 1;
    min-width: 0;
}

.quota-notice-text {
    display: block;
    font-size: var(--caption);
    color: var(--text);
    margin-bottom: var(--space-2);
}

.quota-notice-bar,
.manage-usage-bar {
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 999px;
    overflow: hidden;
}

.quota-notice-fill,
.manage-usage-fill {
    height: 100%;
    background: var(--accent-gold);
    border-radius: 999px;
    transition: width var(--transition);
}

.quota-notice--full .quota-notice-fill,
.manage-usage-fill--full {
    background: var(--accent-primary);
}

.manage-usage-fill--warn {
    background: var(--accent-gold);
}

.manage-usage-fill {
    background: var(--accent-primary);
}

.quota-notice-cta {
    flex-shrink: 0;
}

/* Plan usage + payment history on the manage page */
.manage-usage-row + .manage-usage-row {
    margin-top: var(--space-4);
}

.manage-usage-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.manage-usage-label {
    font-size: var(--caption);
    color: var(--text-muted);
}

.manage-usage-value {
    font-size: var(--caption);
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.manage-usage-note {
    margin-top: var(--space-2);
    font-size: var(--caption);
    color: var(--text-muted);
}

.manage-invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--caption);
}

.manage-invoice-table th {
    text-align: left;
    padding: var(--space-2);
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

.manage-invoice-table td {
    padding: var(--space-2);
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.manage-invoice-table tr:last-child td {
    border-bottom: none;
}

@media (max-width: 600px) {
    .quota-notice {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
}

/* Plans page: two-tier layout, current-plan marker, feature notes.
   Added with the pricing rebuild — this page and /pricing now render the same
   catalog rather than two hand-maintained lists that disagreed. */
.plan-card--featured {
    border-color: var(--accent-primary, #4F8FE0);
}

.plan-card-badge--current {
    background: var(--success-bg, rgba(79,184,133,0.1));
    color: var(--success, #4FB885);
    border: 1px solid var(--success, #4FB885);
}

.plan-card-feature--inherit {
    font-weight: var(--weight-semibold, 600);
    color: var(--text-primary, #EEF0F4);
}

.plan-card-feature-value {
    color: var(--text-primary, #EEF0F4);
    font-weight: var(--weight-semibold, 600);
    margin-left: 0.25em;
}

.plan-card-feature-note {
    display: block;
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
    font-weight: var(--weight-regular, 400);
    margin-top: 2px;
}

.plan-card-cta--static {
    display: block;
    text-align: center;
    padding: var(--space-3);
    color: var(--text-muted, #8A93A0);
    font-size: var(--caption, 0.8125rem);
    border: 1px dashed var(--border, rgba(255,255,255,0.06));
    border-radius: var(--radius-md, 8px);
}

/* Shown only when the reader arrived from a ceiling they hit ("Advanced
   analytics is part of Pro."). It is the reason they are on this page, so it
   reads as a notice rather than as body copy. inline-block keeps it hugging
   its own text inside the centred .plans-page. */
.plans-context {
    display: inline-block;
    margin: 0 0 var(--space-4);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    font-size: var(--caption, 0.8125rem);
    font-weight: var(--weight-medium);
}

.plans-footnote {
    text-align: center;
    margin-top: var(--space-6);
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
}

/* ===== Locked feature =====
   Every gate returned a bare 403. This is the offer that replaces it. */
.locked-feature {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-5);
    background: var(--bg-card, #0F1319);
    border: 1px solid var(--accent-gold, #C89B3C);
    border-radius: var(--radius-lg, 12px);
}

.locked-feature-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    align-self: flex-start;
    padding: 2px var(--space-2);
    font-size: 0.65rem;
    font-weight: var(--weight-semibold, 600);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent-gold, #C89B3C);
    background: var(--accent-gold-subtle, rgba(200, 155, 60, 0.08));
    border-radius: var(--radius-full, 9999px);
}

/* .locked-feature is a flex column with its own gap, so this wrapper only
   groups the title/blurb/proof into one item of that column. Its last child
   still carried a bottom margin, which stacked on top of the gap before
   .locked-feature-actions. */
.locked-feature-body > :last-child {
    margin-bottom: 0;
}

.locked-feature-title {
    margin: 0 0 var(--space-1);
    font-size: var(--title, 1.1rem);
}

.locked-feature-blurb {
    margin: 0 0 var(--space-1);
    max-width: 56ch;
    color: var(--text-secondary, #B0B8C4);
    line-height: var(--leading-normal, 1.5);
}

.locked-feature-proof {
    margin: 0;
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
}

.locked-feature-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
}

/* `.locked-feature-link` lives in buttons.css — it is applied to a <button>
   ("Not now") as well as an <a>, so it needs the native-chrome reset the
   button styles carry. */

/* ===== Plan change notice =====
   The in-app half of the advance notice. Email alone can be filtered or sent
   to an address nobody reads, and this changes what an account can do. */
.plan-notice {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--warning-bg, rgba(244, 184, 96, 0.1));
    border: 1px solid var(--warning, #F4B860);
    border-radius: var(--radius-md, 8px);
}

.plan-notice[hidden] { display: none; }

.plan-notice-icon {
    flex-shrink: 0;
    color: var(--warning, #F4B860);
}

.plan-notice-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.plan-notice-body strong {
    color: var(--text-primary, #EEF0F4);
    font-size: var(--body, 0.9375rem);
}

.plan-notice-body span {
    font-size: var(--caption, 0.8125rem);
    line-height: var(--leading-normal, 1.5);
    color: var(--text-muted, #8A93A0);
}

.plan-notice-link {
    flex-shrink: 0;
    font-size: var(--caption, 0.8125rem);
    color: var(--warning, #F4B860);
    white-space: nowrap;
}

.plan-notice-dismiss {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    font-size: 1.2rem;
    line-height: 1;
    color: var(--text-dim, #7C8593);
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm, 4px);
}

.plan-notice-dismiss:hover { color: var(--text-primary, #EEF0F4); }

@media (max-width: 600px) {
    .plan-notice { flex-wrap: wrap; }
    .plan-notice-body { flex-basis: 100%; order: 1; }
}

/* ----- Unverified-email notice -----
   Deliberately quieter than .plan-notice: that one warns about something being
   taken away, this one asks for a small action. Same geometry so the two never
   look like competing alert systems when both are present. */
.verify-notice {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card, #0F1319);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-left: 3px solid var(--accent-primary, #4C8DF6);
    border-radius: var(--radius-md, 8px);
}

.verify-notice-icon {
    flex-shrink: 0;
    color: var(--accent-primary, #4C8DF6);
}

.verify-notice-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.verify-notice-body strong {
    font-size: var(--body, 0.9375rem);
    color: var(--text-primary, #EEF0F4);
}

.verify-notice-body span {
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
}

.verify-notice-body b {
    color: var(--text-primary, #EEF0F4);
    font-weight: var(--weight-medium, 500);
    word-break: break-all;
}

.verify-notice-action {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

@media (max-width: 640px) {
    .verify-notice { flex-wrap: wrap; }
    .verify-notice-action { width: 100%; }
    .verify-notice-action .btn,
    .verify-notice-action form { flex: 1; }
    .verify-notice-action .btn { width: 100%; }
}

/* Was an <h1>, which made two of them on a page whose topbar already emits
   one. Demoted to <h2>; this keeps the size it had. */
.plans-title {
    font-size: var(--h1, 1.75rem);
    font-weight: var(--weight-bold, 700);
    line-height: 1.2;
    margin: 0 0 var(--space-2, 0.5rem);
}

/* ===== Checkout hand-off =====

   The page a reader lands on between clicking Upgrade and Paddle's overlay
   appearing. None of it had any CSS: a spinner and "Opening checkout..."
   pinned to the left edge, and — when Paddle is blocked by an ad blocker,
   which is the whole reason the fallback exists — a full-width wall of
   troubleshooting text. That is the last screen before payment. */
.checkout-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: var(--space-6, 2rem) var(--space-4, 1rem);
}

.checkout-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3, 0.75rem);
}

.checkout-loading[hidden],
.checkout-fallback[hidden] {
    display: none;
}

.checkout-loading-text {
    margin: 0;
    color: var(--text-secondary, #B0B8C4);
    font-size: var(--body, 0.9375rem);
}

.checkout-fallback {
    display: flex;
    justify-content: center;
    width: 100%;
}

.checkout-fallback-card {
    width: 100%;
    max-width: 32rem;
    padding: var(--space-5, 1.5rem);
    background: var(--bg-card, #10141B);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-xl, 16px);
    box-shadow: var(--shadow-lg);
}

.checkout-fallback-card h2 {
    margin: 0 0 var(--space-3, 0.75rem);
    font-size: var(--h3, 1.125rem);
}

.checkout-fallback-card p {
    margin: 0 0 var(--space-2, 0.5rem);
    color: var(--text-secondary, #B0B8C4);
}

.checkout-fallback-card ul {
    margin: 0 0 var(--space-4, 1rem);
    padding-left: var(--space-5, 1.5rem);
    color: var(--text-secondary, #B0B8C4);
}

.checkout-fallback-card li + li {
    margin-top: var(--space-1, 0.25rem);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="search"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--body);
    font-family: var(--font);
    height: 36px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-subtle);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-dim);
}

label {
    display: block;
    font-size: var(--caption);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.form-group {
    margin-bottom: var(--space-4);
}

/* The dense variant, used by the public browse filter sidebar where each
   control is one line and space-4 between them was never intended. */
.form-group-sm {
    margin-bottom: var(--space-2);
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.inline-form {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.inline-form input {
    flex: 1;
}

/* ===== Settings =====
   An index of short pages (UX audit 6.9): each row names a page and where it
   stands; `?section=` opens one, with a way back. */
.settings-page {
    max-width: 720px;
}

.settings-index {
    padding: 0;
    overflow: hidden;
}

.settings-index-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3, 12px);
    min-height: 56px;
    padding: var(--space-3, 12px) var(--space-4, 16px);
    color: var(--text-primary, #EEF0F4);
    text-decoration: none;
    border-bottom: 1px solid var(--border-light, rgba(255,255,255,0.03));
}

.settings-index-row:last-child { border-bottom: none; }

.settings-index-row:hover,
.settings-index-row:focus-visible {
    background: var(--surface-bg-hover, rgba(255,255,255,0.04));
}

.settings-index-chevron {
    flex-shrink: 0;
    color: var(--text-muted, #8A93A0);
}

/* The phone has the top bar's back arrow; wider screens get this. */
.settings-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1, 4px);
    min-height: 44px;
    margin-bottom: var(--space-2, 8px);
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
    text-decoration: none;
}

.settings-back:hover { color: var(--text-primary, #EEF0F4); }

@media (max-width: 599px) {
    .settings-back { display: none; }
}

.settings-section {
    margin-bottom: var(--space-5);
    /* Anchor links must not land under the sticky topbar. */
    scroll-margin-top: 72px;
}

.settings-section > h2 {
    margin-bottom: var(--space-1);
}

.settings-section-lead {
    margin-bottom: var(--space-4);
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
}

.settings-subsection {
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-light, rgba(255,255,255,0.03));
}

.settings-subsection > h3 {
    margin-bottom: var(--space-2);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-light, rgba(255,255,255,0.03));
}

.settings-row:last-child { border-bottom: none; }

.settings-row-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.settings-facts {
    display: grid;
    grid-template-columns: minmax(90px, auto) 1fr;
    gap: var(--space-2) var(--space-4);
    margin: 0;
}

.settings-facts dt {
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
}

.settings-facts dd {
    margin: 0;
    color: var(--text-primary, #EEF0F4);
}

.settings-fact-link {
    margin-left: var(--space-2);
    font-size: var(--caption, 0.8125rem);
}

.form-hint {
    margin-top: var(--space-1);
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
}

.form-fieldset {
    margin: var(--space-4) 0;
    padding: var(--space-3);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    border-radius: var(--radius-md, 8px);
}

.form-fieldset legend {
    padding: 0 var(--space-2);
    font-size: var(--caption, 0.8125rem);
    color: var(--text-secondary, #B0B8C4);
}

.form-row {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.form-row .form-group { flex: 1 1 160px; }

.settings-textarea {
    width: 100%;
    resize: vertical;
    font-family: inherit;
}

.settings-feed-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-1);
}

.settings-feed-label {
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
    min-width: 100px;
}

.settings-feed-url {
    flex: 1;
    min-width: 0;
    padding: var(--space-1) var(--space-2);
    font-size: 0.75rem;
    word-break: break-all;
    background: var(--bg-input, #090A0E);
    border: 1px solid var(--border, rgba(255,255,255,0.06));
    border-radius: var(--radius-sm, 4px);
}

.settings-token-reveal {
    margin-bottom: var(--space-3);
    padding: var(--space-3);
    background: var(--success-bg, rgba(79,184,133,0.1));
    border: 1px solid var(--success, #4FB885);
    border-radius: var(--radius-md, 8px);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.settings-token-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.settings-token-row code {
    flex: 1;
    min-width: 0;
    padding: var(--space-2);
    word-break: break-all;
    font-size: 0.8rem;
    background: var(--bg-input, #090A0E);
    border-radius: var(--radius-sm, 4px);
}

.settings-token-list { margin-top: var(--space-3); }

.settings-empty {
    margin-top: var(--space-3);
    font-size: var(--caption, 0.8125rem);
}

/* Danger zone reads as dangerous, rather than being merely the last thing on
   the page with the same weight as "Change username". */
.settings-danger {
    border-color: var(--danger, #FF6B6B);
}

.settings-danger > h2 { color: var(--danger, #FF6B6B); }

.settings-danger-body {
    padding: var(--space-4);
    background: var(--danger-bg, rgba(255,107,107,0.1));
    border-radius: var(--radius-md, 8px);
}

.settings-danger-body h3 { margin-bottom: var(--space-2); }

@media (max-width: 600px) {
    .settings-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .settings-facts { grid-template-columns: 1fr; gap: var(--space-1); }
    .settings-facts dd { margin-bottom: var(--space-2); }
}

.settings-fold > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.settings-fold > summary h2 { margin: 0; }

/* Buttons — 04-design-system.md change-log #9.
   Buttons adopt the badge/tag language: pill radius, flat single-tone fill,
   an explicit 1px outline one step lighter than the fill, 34/40/28px heights,
   weight 600 with +.01em tracking, and no transform on press (background and
   border shift instead).

   Deviation D1: :hover darkens rather than lightens. The design system's own
   hover value drops white labels back under 4.5:1. See
   docs/REDESIGN_IMPLEMENTATION_AUDIT.md §7. */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0 var(--space-5);
    background: var(--accent-primary-solid, #3874C2);
    color: #fff;
    border: 1px solid var(--accent-primary-hover);
    border-radius: var(--radius-full);
    font-size: var(--body);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.01em;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
    height: 34px;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.btn:hover {
    background: var(--accent-primary-solid-hover, #3369B0);
    border-color: var(--accent-primary);
    color: #fff;
}

.btn:active {
    background: var(--accent-primary-solid, #3874C2);
    border-color: var(--accent-primary);
}

.btn-secondary {
    background: var(--accent-violet);
    border-color: var(--accent-violet-hover);
}
.btn-secondary:hover {
    background: var(--accent-violet-hover);
    border-color: #A78FDD;
}

.btn-gold {
    background: var(--accent-gold);
    border-color: var(--accent-gold-hover);
}
.btn-gold:hover {
    background: var(--accent-gold-hover);
    border-color: #E0BC6B;
}

.btn-outline {
    background: var(--surface-bg);
    border: 1px solid var(--border-hover);
    color: var(--text-primary);
    box-shadow: none;
}
.btn-outline:hover {
    background: var(--surface-bg-hover);
    border-color: var(--text-dim);
    color: var(--text-primary);
}
.btn-outline:active {
    background: var(--surface-bg);
}
.btn-outline.active {
    background: var(--accent-primary-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    font-weight: var(--weight-semibold);
    box-shadow: 0 0 0 1px rgba(79, 143, 224, 0.3);
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 0 var(--space-4);
    box-shadow: none;
    font-weight: var(--weight-semibold);
}
.btn-ghost:hover {
    background: var(--surface-bg-hover);
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-block { width: 100%; }

.btn-hero {
    height: 36px;
    padding: 0 var(--space-5);
}

.btn-lg {
    padding: 0 var(--space-6);
    height: 40px;
    font-size: var(--body);
}

/* Combined with .btn this is a size modifier only — the variant keeps its own
   fill. 20+ call sites rely on `btn btn-primary btn-sm` staying primary. */
.btn.btn-sm,
.btn.btn-small {
    gap: var(--space-1_5);
    padding: 0 var(--space-3);
    font-size: var(--caption);
    height: 28px;
}

/* Standalone: btn_small in _macros.html emits .btn-sm without the base .btn,
   so on its own it carries a full neutral treatment. */
.btn-sm:not(.btn),
.btn-small:not(.btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1_5);
    padding: 0 var(--space-3);
    font-size: var(--caption);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.01em;
    height: 28px;
    background: var(--surface-bg);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-sm:not(.btn):hover,
.btn-small:not(.btn):hover {
    background: var(--surface-bg-hover);
    border-color: var(--text-dim);
    color: var(--text-primary);
}
.btn-sm:not(.btn).btn-outline,
.btn-small:not(.btn).btn-outline {
    background: transparent;
}

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

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: #7BCEA5;
}
.btn-success:hover {
    background: #3CB371;
    border-color: var(--success);
}

/* Dark label: white on gold measures 1.77:1. */
.btn-warning {
    background: var(--warning);
    color: #1A1D23;
    border-color: #F8CE8C;
}
.btn-warning:hover {
    background: #D4A017;
    border-color: var(--warning);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: var(--surface-bg);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-icon:hover {
    background: var(--surface-bg-hover);
    border-color: var(--text-dim);
    color: var(--text-primary);
}

.btn-toggle-on {
    background: var(--success);
    color: #fff;
    border: none;
}

.btn-toggle-off {
    background: var(--surface-bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-track-on {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: var(--success);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--space-1) var(--space-3);
    font-size: var(--caption);
    cursor: pointer;
}
.btn-track-on:hover {
    background: var(--success);
    filter: brightness(1.1);
    color: #fff;
}
.btn-track-on svg {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-track-on:hover svg {
    transform: rotate(15deg);
}

.btn-track-off {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: var(--surface-bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-md);
    padding: var(--space-1) var(--space-3);
    font-size: var(--caption);
    cursor: pointer;
}
.btn-track-off:hover {
    background: var(--surface-bg-hover);
    border-color: var(--border-hover);
    color: var(--text-secondary);
}

.btn:disabled,
.btn-loading {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
}

/* `spin` is defined in components/animations.css. */
.btn-loading::after {
    content: '';
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: var(--space-2);
}

.btn-outline.btn-loading::after {
    border-color: rgba(79, 143, 224, 0.3);
    border-top-color: var(--accent-primary);
}

.btn-danger.btn-loading::after {
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
}

/* ===== Buttons that were never styled =====

   A <button> arrives with a grey background, a border and the system font. Ten
   of them across the product carried a class that set colour or size and reset
   none of that, so they rendered as raw form controls — the gate's "Not now"
   was the one that got noticed, but it was not alone.

   `.btn-bare` is the shared reset. Everything below either uses it or is given
   the properties directly, so a <button> and an <a> with the same class look
   the same. */

.btn-bare,
.locked-feature-link,
.collection-remove,
.tag-remove-btn,
.tag-add-btn,
.tag-suggestion-item,
.search-overlay-close,
.search-overlay-submit,
.fab-modal-close {
    appearance: none;
    -webkit-appearance: none;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    text-align: inherit;
    cursor: pointer;
}

/* "Not now" on a premium gate, and "What else is included?" beside it. Both
   read as quiet text links; the button must not shout louder than the anchor
   it sits next to. */
.locked-feature-link {
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.locked-feature-link:hover,
.locked-feature-link:focus-visible {
    color: var(--text-primary, #EEF0F4);
}

/* Standalone ✕ controls — they close an overlay and are the only thing to aim
   at, so they get a full 44px target. */
.search-overlay-close,
.fab-modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: var(--radius-full, 999px);
    color: var(--text-muted, #8A93A0);
    transition: background 150ms ease, color 150ms ease;
}

/* The ✕ inside a chip is a different control despite the same glyph. It sits
   within a badge roughly 24px tall, so a 44px box would set the height of the
   chip around it. It stays small and leans on the chip for spacing. */
.collection-remove,
.tag-remove-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    margin-left: var(--space-1, 0.25rem);
    border-radius: var(--radius-full, 999px);
    font-size: 1rem;
    line-height: 1;
    color: var(--text-muted, #8A93A0);
    opacity: 0.7;
    transition: background 150ms ease, color 150ms ease, opacity 150ms ease;
}

.collection-remove:hover,
.tag-remove-btn:hover,
.collection-remove:focus-visible,
.tag-remove-btn:focus-visible,
.search-overlay-close:hover,
.fab-modal-close:hover,
.search-overlay-close:focus-visible,
.fab-modal-close:focus-visible {
    background: var(--bg-card-hover, #151A22);
    color: var(--text-primary, #EEF0F4);
    opacity: 1;
}

/* Removing a tag is destructive, so the hover reads as danger rather than as
   a neutral highlight. */
.collection-remove:hover,
.tag-remove-btn:hover {
    background: var(--danger-subtle, rgba(224, 90, 90, 0.12));
    color: var(--danger, #E05A5A);
}

/* Tag chips: "add" is an affordance, not a link. */
.tag-add-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1, 0.25rem);
    min-height: 44px;
    padding: 0 var(--space-3, 0.75rem);
    border: 1px dashed var(--border, rgba(255, 255, 255, 0.16));
    border-radius: var(--radius-full, 999px);
    font-size: var(--caption, 0.8125rem);
    color: var(--text-secondary, #B0B8C4);
}

.tag-add-btn:hover,
.tag-add-btn:focus-visible {
    border-style: solid;
    border-color: var(--accent-primary, #4F8FE0);
    color: var(--text-primary, #EEF0F4);
}

/* Autocomplete rows. Full-width targets, because a suggestion list is chosen
   by pointing at a row rather than at its text. */
.tag-suggestion-item {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
    border-radius: var(--radius-md, 8px);
    font-size: var(--body, 0.9375rem);
    color: var(--text-primary, #EEF0F4);
}

.tag-suggestion-item:hover,
.tag-suggestion-item:focus-visible,
.tag-suggestion-item[aria-selected='true'] {
    background: var(--accent-primary-subtle, rgba(79, 143, 224, 0.08));
}

/* The search overlay's submit is a real action, so it keeps button weight. */
.search-overlay-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 var(--space-4, 1rem);
    background: var(--accent-primary-solid, #3874C2);
    color: #fff;
    border-radius: var(--radius-full, 999px);
    font-size: var(--body, 0.9375rem);
    font-weight: var(--weight-semibold, 600);
}

.search-overlay-submit:hover,
.search-overlay-submit:focus-visible {
    background: var(--accent-primary-hover, #6BA3E8);
}

/* `.btn-xs` sat below `.btn-sm` in the size ladder but was never defined, so
   every use of it fell back to native chrome. */
.btn-xs {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1, 0.25rem);
    min-height: 32px;
    padding: 0 var(--space-3, 0.75rem);
    background: transparent;
    color: var(--accent-primary, #4F8FE0);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.16));
    border-radius: var(--radius-full, 999px);
    font-family: var(--font);
    font-size: var(--caption, 0.8125rem);
    font-weight: var(--weight-medium, 500);
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease;
}

.btn-xs:hover,
.btn-xs:focus-visible {
    background: var(--accent-primary-subtle, rgba(79, 143, 224, 0.08));
    border-color: var(--accent-primary, #4F8FE0);
}

/* The mobile floating action button. Visibility belongs to responsive.css,
   which hides it by default and shows it below 600px — so this rule sets
   appearance and placement and deliberately does not touch `display`.

   It had appearance and no placement: nothing made it `position: fixed`, so
   below 600px it rendered in normal flow at the top-left of the layout, on top
   of the menu button, and pushed the whole page 56px to the right — the main
   reason Home scrolled sideways on a 390px phone (458px wide). Above the
   bottom tab bar, bottom-right, where a thumb finds it. */
.fab {
    position: fixed;
    right: var(--space-4, 16px);
    bottom: calc(var(--mobile-nav-height, 64px) + var(--space-4, 16px) + env(safe-area-inset-bottom, 0px));
    /* Over the tab bar (100); under the account menu (120) and modals (900). */
    z-index: 110;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--accent-primary-solid, #3874C2);
    color: #fff;
    border: 0;
    border-radius: var(--radius-full, 999px);
    box-shadow: var(--shadow-3, 0 8px 24px rgba(0, 0, 0, 0.4));
    font: inherit;
    cursor: pointer;
}

.fab:hover,
.fab:focus-visible {
    background: var(--accent-primary-hover, #6BA3E8);
}

@media (prefers-reduced-motion: reduce) {
    .btn-bare,
    .btn-xs,
    .collection-remove,
    .tag-add-btn,
    .tag-remove-btn,
    .tag-suggestion-item,
    .search-overlay-close,
    .search-overlay-submit,
    .fab-modal-close {
        transition: none;
    }
}

/* A compact icon button for dense action rows — the highlight card's favourite
   and delete controls, and the same pair on a journal entry. `.btn-icon` is
   34px, which is right for a toolbar and heavy for a row of two sitting inside
   a card's metadata line.
   Note that neither size reaches the 44px touch target the screen specs ask
   for; that applies to `.btn-icon` itself and is not introduced here. */
.btn-icon-sm {
    width: 28px;
    height: 28px;
}

.btn-icon-sm svg {
    width: 14px;
    height: 14px;
}

/* Delete. `.btn-icon:hover` moves toward `--text-primary`, which reads as
   "this is the active one" — wrong for the only destructive control in the
   row. The resting state stays quiet so the row is not a wall of red; the
   intent appears on hover and focus, which is where the reader is about to
   act. */
.btn-icon-danger:hover,
.btn-icon-danger:focus-visible {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-bg);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    font-size: var(--xs);
    font-weight: var(--weight-semibold);
    border-radius: var(--radius-full);
    background: var(--surface-bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
    line-height: 1.4;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: transparent;
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: transparent;
}

.badge-accent {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    border-color: transparent;
}

.badge-gold {
    background: var(--accent-gold-subtle);
    color: var(--accent-gold);
    border-color: transparent;
}

.badge-favorite {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: transparent;
}

.badge-dim {
    background: var(--surface-bg);
    color: var(--text-dim);
}

.badge-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: transparent;
}

.badge-sent {
    background: var(--success-bg);
    color: var(--success);
    border-color: transparent;
}

.badge-failed {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: transparent;
}

.badge-ongoing {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    border-color: transparent;
}

.badge-reading { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-plan_to_read { background: var(--surface-bg); color: var(--text-muted); }
.badge-completed { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-on_hold { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge-dropped { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-re_reading { background: var(--accent-primary-subtle); color: var(--accent-primary); border-color: transparent; }

.source-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.35rem;
}

.source-badge-royalroad { background: rgba(212, 165, 116, 0.15); color: var(--source-royalroad, #d4a574); }
.source-badge-scribblehub { background: rgba(116, 185, 212, 0.15); color: var(--source-scribblehub, #74b9d4); }
.source-badge-webnovel { background: rgba(165, 116, 212, 0.15); color: var(--source-webnovel, #a574d4); }
.source-badge-wuxiaworld { background: rgba(212, 116, 116, 0.15); color: var(--source-wuxiaworld, #d47474); }
.source-badge-mvlempyr { background: rgba(212, 180, 80, 0.15); color: var(--source-mvlempyr, #d4b450); }

.browse-rating {
    color: var(--warning);
    font-weight: var(--weight-bold);
}

.rec-score {
    font-size: var(--xs);
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-sm);
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.45rem;
    font-size: var(--xs);
    font-weight: var(--weight-medium);
    border-radius: var(--radius-sm);
    background: var(--surface-bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}

.tag:hover {
    background: var(--surface-bg-hover);
    color: var(--text-primary);
}

.tag.active {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    border-color: transparent;
}

/* Four variants the markup uses and this file never defined, so they rendered
   as the plain grey base: an informational chip, an accent chip, a warning,
   and a dense size. Colour mapping follows the design system's own
   foundation/badges.css, where every semantic variant is the same shape —
   `--X-bg` behind `--X`, border removed. */

/* Genre chips, "Milestone" activity, admin analytics, similar-novel reasons.
   Same pairing the design system gives .badge-reading. */
.badge-info {
    background: var(--info-bg);
    color: var(--info);
    border-color: transparent;
}

/* "Streak". The design system spells this .badge-accent; the markup asks for
   .badge-primary, and both name the same accent, so this matches the markup
   rather than renaming templates. */
.badge-primary {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    border-color: transparent;
}

/* Source health "Cooldown" — a source being rested, not an error. Warning
   rather than danger, matching .badge-on_hold in the design system. */
.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: transparent;
}

/* A size, not a colour, so it composes with the variants above — the similar
   novels rail uses `badge badge-info badge-xs` and `badge badge-xs`. The base
   is already at --xs, so this tightens the box rather than shrinking the text
   further, which would drop it below a legible size in a dense rail. */
.badge-xs {
    padding: 0.1rem 0.35rem;
    line-height: 1.3;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--body);
}

th {
    text-align: left;
    padding: var(--space-3) var(--space-3);
    font-size: var(--caption);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: var(--space-3) var(--space-3);
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--surface-bg-hover);
}

.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    font-size: var(--body);
    font-weight: var(--weight-medium);
    pointer-events: auto;
    animation: toast-in 0.3s ease-out;
    max-width: 400px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--info);
}

.toast.warning {
    border-left: 3px solid var(--warning);
}

.toast-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: var(--title);
    flex-shrink: 0;
    border-radius: var(--radius-sm);
}

.toast-close:hover {
    background: var(--surface-bg-hover);
    color: var(--text-primary);
}

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.toast-text {
    flex: 1;
    min-width: 0;
}

/* Errors persist until dismissed, so make the close affordance unmistakable
   rather than the low-contrast dim it inherits. */
.toast[data-persist] .toast-close {
    color: var(--text-secondary, #B0B8C4);
}

.toast-close:focus-visible {
    outline: 2px solid var(--accent-primary, #4F8FE0);
    outline-offset: 2px;
    color: var(--text-primary, #EEF0F4);
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        animation: none;
    }
}

.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-primary { color: var(--text-primary); }
.text-accent { color: var(--accent-primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-xs { font-size: var(--xs); }
.text-2xs { font-size: 0.6rem; }
.text-caption { font-size: var(--caption); }
.text-body { font-size: var(--body); }
.text-title { font-size: var(--title); }
.text-section { font-size: var(--heading); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }
.m-0 { margin: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.w-full { width: 100%; }
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dashboard-header { margin-bottom: var(--space-4); }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.inline { display: inline; }
.inline-flex { display: inline-flex; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.flex-row { display: flex; flex-direction: row; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.gap-xs { gap: 0.25rem; }
.gap-sm,
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }

.p-1 { padding: var(--space-1); }

.input-sm {
    padding: var(--space-1) var(--space-2);
    font-size: var(--caption);
    height: 30px;
}

.input-grow {
    flex: 1;
    min-width: 0;
}

.hidden { display: none !important; }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Keyboard reordering controls (static/js/reorder-a11y.js).
   Drag-and-drop was the only way to reorder the queue and collections. */
.reorder-controls {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    margin-right: var(--space-2);
}

.reorder-btn {
    width: 22px;
    height: 20px;
    padding: 0;
    font-size: 0.6rem;
    line-height: 1;
    color: var(--text-dim, #7C8593);
    background: var(--surface-bg, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
}

.reorder-btn:hover {
    color: var(--text-primary, #EEF0F4);
    border-color: var(--accent-primary, #4F8FE0);
}

@media (pointer: coarse) {
    /* Touch users have drag; keep the buttons small so they do not crowd. */
    .reorder-btn { height: 24px; }
}

/* ========================================
   Browse / Discover Layout
   Premium gallery — full-width, cover-led
   ======================================== */

/* --- Public browse layout (novels_public.html) ---

   Restored from 03c6ceb^. That commit moved browse.html to the horizontal
   filter bar below and deleted this block with it, but novels_public.html was
   never converted and still ships the sidebar markup. Without these rules it
   rendered a borderless filter block above a results column pinned to half
   width — measured at 182px of an available 381px, one card per row.

   Scoped to .browse-layout, which only novels_public.html uses, so the
   redesigned page cannot inherit the sidebar treatment it deliberately drops.

   The old rule also hid the sidebar under 1200px and reopened it via
   .browse-filters-open. That is not restored: this template has no filter
   toggle, so hiding it would leave no way to reach the filters at all. It
   stacks above the results instead. */
.browse-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: var(--space-6);
    align-items: start;
}

.browse-layout .browse-filters {
    position: sticky;
    top: calc(var(--topbar-height) + var(--space-4));
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
}

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

    .browse-layout .browse-filters {
        position: static;
    }
}

/* --- Base results grid (public templates) --- */
.browse-results {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
    min-width: 0;
}

.browse-results > .pagination {
    grid-column: 1 / -1;
}

/* browse.html puts cards straight into the two columns above;
   novels_public.html wraps them in .novel-grid, which then occupied one column
   and left the other empty. Same escape hatch .pagination already uses. */
.browse-results > .novel-grid {
    grid-column: 1 / -1;
}

#filter-toggle,
#filter-close {
    display: none;
}

/* ========================================
   Browse Page UI — Premium Gallery
   ======================================== */

.browse-page-ui {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}

/* --- Editorial Header --- */
.browse-editorial-header {
    display: flex;
    align-items: baseline;
    gap: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.browse-editorial-title {
    font-family: var(--font-display);
    font-size: var(--heading);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    margin: 0;
    letter-spacing: var(--tracking-tight);
}

.browse-editorial-count {
    font-size: var(--caption);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

/* --- Horizontal Filter Bar --- */
.browse-page-ui .browse-filters {
    background: transparent;
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.browse-filters-header-mobile {
    display: none;
}

.browse-filters-inline {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.filter-field select,
.filter-field input,
.filter-search input {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-1_5) var(--space-3);
    font-family: var(--font);
    font-size: var(--caption);
    color: var(--text-secondary);
    min-height: 32px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-field select {
    min-width: 110px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='8' height='6' viewBox='0 0 8 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L4 4.5L7 1.5' stroke='%238A93A0' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.filter-field select:hover,
.filter-field input:hover,
.filter-search input:hover {
    border-color: var(--border-hover);
}

.filter-field select:focus,
.filter-field input:focus,
.filter-search input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-subtle);
    outline: none;
}

.filter-search input {
    min-width: 160px;
}

.filter-search input::placeholder {
    color: var(--text-dim);
}

.filter-actions {
    display: flex;
    gap: var(--space-1_5);
    margin-left: auto;
}

.btn-filter-apply {
    background: var(--accent-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    padding: var(--space-1_5) var(--space-4);
    font-family: var(--font);
    font-size: var(--caption);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
}

.btn-filter-apply:hover {
    background: var(--accent-primary-hover);
    box-shadow: none;
}

.btn-filter-clear {
    color: var(--text-muted);
    text-decoration: none;
    font-size: var(--caption);
    padding: var(--space-1_5) var(--space-3);
    border-radius: var(--radius-lg);
    transition: color var(--transition), background var(--transition);
    display: inline-flex;
    align-items: center;
}

.btn-filter-clear:hover {
    color: var(--text-secondary);
    background: var(--surface-bg);
}

/* --- Result Count (mobile) --- */
.browse-count {
    font-size: var(--caption);
    color: var(--text-muted);
}

/* ========================================
   Responsive
   ======================================== */

/* --- Mobile: filter bar → overlay --- */
@media (max-width: 1100px) {
    .browse-page-ui .browse-filters {
        display: none;
    }
    .browse-page-ui .browse-filters.browse-filters-open {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: var(--mobile-nav-height);
        z-index: 95;
        margin: 0;
        border-radius: 0;
        overflow-y: auto;
        padding: var(--space-5);
        background: var(--bg-surface);
    }
    .browse-filters-header-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: var(--space-4);
        padding-bottom: var(--space-3);
        border-bottom: 1px solid var(--border);
    }
    .browse-filters-header-mobile h2 {
        font-family: var(--font);
        font-size: var(--xs);
        font-weight: var(--weight-semibold);
        text-transform: uppercase;
        letter-spacing: var(--tracking-wide);
        color: var(--text-dim);
        margin: 0;
    }
    .browse-filters-inline {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-field select,
    .filter-field input,
    .filter-search input {
        width: 100%;
    }
    .filter-search input {
        min-width: 0;
    }
    .filter-actions {
        margin-left: 0;
    }
    #filter-toggle {
        display: inline-flex !important;
    }
    #filter-close {
        display: inline-flex !important;
    }
}

/* Sort chips (spec 04 §6). Reuses .journal-filter-chip for the chip itself so
   every filter row in the product looks the same; this only lays them out and
   carries the subhead that says what the list is. */
.browse-sorts {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding-top: var(--space-4);
}

.browse-sort-description {
    margin: var(--space-2) 0 0;
    font-size: var(--caption);
}

/* §10: the sort chips scroll rather than wrap on mobile, so the row never
   pushes the grid below the fold. */
@media (max-width: 599px) {
    .browse-sorts {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .browse-sorts::-webkit-scrollbar { display: none; }
    .browse-sorts .journal-filter-chip { flex: 0 0 auto; }
}

/* A source whose search just failed (search_unavailable). Informational, in
   the muted colour: the results below are still real. */
.search-unavailable {
    margin: 0 0 var(--space-3, 0.75rem);
    padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
    background: var(--bg-card, #0F1319);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-left: 3px solid var(--warning, #F4B860);
    border-radius: var(--radius-md, 8px);
}

/* ===== Result rows (UX audit 6.5) =====
   A card per screen with a large blurred cover made 30 results 15 phone
   screens. A row is cover, title, author and site, one line of genres, Add. */
.browse-page-ui .browse-results {
    display: block;
}

.browse-list {
    margin: 0 0 var(--space-4, 1rem);
    padding: 0;
    list-style: none;
}

.card.browse-list {
    padding: 0;
}

.browse-row {
    display: flex;
    align-items: center;
    gap: var(--space-3, 0.75rem);
    padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
    border-bottom: 1px solid var(--border-light, rgba(255, 255, 255, 0.03));
}

.browse-row:last-child {
    border-bottom: 0;
}

.browse-row-cover {
    flex-shrink: 0;
    width: 48px;
    height: 68px;
    object-fit: cover;
    background: var(--surface-bg, rgba(255, 255, 255, 0.03));
    border-radius: var(--radius-sm, 4px);
}

.browse-row-text {
    flex: 1 1 auto;
    min-width: 0;
}

.browse-row-title {
    margin: 0 0 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font, inherit);
    font-size: var(--body, 0.9375rem);
    font-weight: var(--weight-semibold, 600);
}

.browse-row-title a {
    color: var(--text-primary, #EEF0F4);
}

.browse-row-meta,
.browse-row-genres {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
}

.browse-row-genres {
    color: var(--text-dim, #6B7380);
}

.browse-row-action {
    flex-shrink: 0;
}

.browse-row-action .btn-sm {
    min-width: 64px;
}

.browse-row-added {
    font-size: var(--caption, 0.8125rem);
    color: var(--success, #4FB885);
    white-space: nowrap;
}

@media (pointer: coarse) {
    .browse-row-action .btn-sm {
        min-height: 44px;
    }
}


/* Accessible confirmation dialog (js/confirm-dialog.js) — replaces native
   confirm() on destructive actions, which cannot be styled and is suppressed
   entirely once a user ticks "prevent additional dialogs". */
.confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.confirm-backdrop[hidden] {
    display: none;
}

.confirm-dialog {
    width: 100%;
    max-width: 26rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--space-5);
}

.confirm-title {
    margin: 0 0 var(--space-2);
    font-size: var(--title);
    color: var(--text-primary);
}

.confirm-message {
    margin: 0 0 var(--space-5);
    color: var(--text-muted);
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

/* ===== "Track a novel" dialog =====

   Opened by the mobile FAB and by the command palette's Track action, so it is
   not a mobile-only control despite the `fab-` prefix its markup carries.

   It could not be opened at all. `responsive.css` sets `.fab-modal {
   display: none }` at every width, five places add or remove `fab-modal-open`
   (command-palette.js, _shell/scripts.html, dashboard.html, library.html), and
   no rule ever defined that class. Tapping + did nothing; so did choosing
   Track in the palette. Tracking a novel is the product's primary action.

   The look comes from the `.mobile-more-*` bottom sheet that used to live in
   mobile-nav.css. Redesign §2.5 replaced that popover with this dialog, the
   template was rewritten to `fab-modal-*`, and the stylesheet was not — so the
   design existed the whole time under names nothing rendered. Those rules are
   deleted there and adapted here rather than written afresh.

   `.fab-modal.fab-modal-open` rather than `.fab-modal-open` alone: two classes
   beat the single-class `display: none` in responsive.css on specificity, so
   this does not depend on stylesheet order. */
.fab-modal.fab-modal-open {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: block;
}

.fab-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.fab-modal-content {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 901;
    max-height: 80vh;
    overflow-y: auto;
    padding: var(--space-4) var(--space-4)
             calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
    background: var(--bg-surface, #0F1319);
    border-top: 1px solid var(--border, rgba(255, 255, 255, 0.06));
    border-radius: var(--radius-xl, 16px) var(--radius-xl, 16px) 0 0;
}

/* On a wide screen a sheet welded to the bottom edge reads as a mobile
   artefact, so above the FAB's breakpoint it becomes a centred dialog. */
@media (min-width: 600px) {
    .fab-modal-content {
        left: 50%;
        right: auto;
        bottom: auto;
        top: 15vh;
        width: min(28rem, calc(100vw - 2 * var(--space-4)));
        transform: translateX(-50%);
        border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
        border-radius: var(--radius-xl, 16px);
        box-shadow: var(--shadow-lg);
    }
}

.fab-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
    font-weight: var(--weight-semibold, 600);
    color: var(--text-primary, #EEF0F4);
}

.fab-modal-header h3 {
    margin: 0;
    font-size: var(--h3, 1.125rem);
}

.fab-modal-input {
    display: block;
    width: 100%;
    margin-bottom: var(--space-3);
    padding: var(--space-3);
    color: var(--text-primary, #EEF0F4);
    background: var(--bg-input, #090A0E);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
    border-radius: var(--radius-md, 8px);
    font: inherit;
    font-size: var(--body, 0.9375rem);
}

.fab-modal-input:focus-visible {
    outline: 2px solid var(--accent-primary, #4F8FE0);
    outline-offset: 1px;
}

/* ===================================
   Landing Page — LumiList
   Signature: diamond watermark glow + live ticker
   =================================== */

/* == Body overrides for unauthenticated layout == */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    justify-content: flex-start;
}
body > main.container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.landing {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* == Mobile-only toggle == */
.mob-only {
    display: none;
}

/* == Section Eyebrow == */
.section-eyebrow {
    text-align: center;
    font-size: var(--xs);
    font-weight: var(--weight-bold);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: var(--space-3);
}

/* == Hero Section == */
.hero {
    position: relative;
    text-align: center;
    padding: var(--space-4) var(--space-4) var(--space-6);
    max-width: 780px;
    margin: 0 auto;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    top: -40%;
    left: 50%;
    transform: translateX(-50%);
    width: 700px;
    height: 700px;
    /* The single --gradient-glow this page is allowed (4.1, spec 23 §4).
       Was a hardcoded two-stop radial with a 6s pulse; the pulse is ambient
       looping motion, which 4.8 rule 1 bans outright. */
    background: var(--gradient-glow);
    pointer-events: none;
    z-index: 0;
}

.hero-diamond {
    position: absolute;
    top: -30%;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(10rem, 25vw, 20rem);
    color: transparent;
    -webkit-text-stroke: 1px rgba(79, 143, 224, 0.06);
    pointer-events: none;
    z-index: 0;
    font-family: var(--font-display);
    user-select: none;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 4px 12px 4px 8px;
    border-radius: var(--radius-full);
    background: rgba(79, 184, 133, 0.08);
    color: var(--success);
    font-size: var(--xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    margin-bottom: var(--space-5);
    border: 1px solid rgba(79, 184, 133, 0.15);
}

.hero-badge-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

.hero h1 {
    font-size: clamp(2.5rem, 6vw, 3.75rem);
    font-weight: var(--weight-extrabold);
    letter-spacing: -0.03em;
    line-height: 1.08;
    margin-bottom: var(--space-4);
    color: var(--text-primary);
}

.hero-gradient-text {
    /* Gradient text is not on the 4.1 allowlist. */
    color: var(--accent-primary);
}

.hero-sub {
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    color: var(--text-muted);
    max-width: 540px;
    margin: 0 auto var(--space-6);
    line-height: var(--leading-normal);
}

.hero-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.hero-actions .btn-lg {
    padding: var(--space-3) var(--space-8);
    font-size: var(--body);
    border-radius: var(--radius-full);
}

.hero-actions .btn-primary {
    /* Fill, outline and press behaviour now come from .btn (change-log #9).
       The gradient fill and coloured drop glow are both off-allowlist. */
    transition: background var(--transition), border-color var(--transition);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}
.hero-actions .btn-primary::after {
    content: '\2192';
    display: inline-block;
    transition: transform var(--transition-smooth);
}
/* Hover is a background/border shift only — see .btn (change-log #9). */
.hero-actions .btn-primary:hover::after {
    transform: translateX(3px);
}

.hero-actions .btn-outline {
    border-radius: var(--radius-full);
}

.hero-ext-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    border-radius: var(--radius-full);
    padding: var(--space-3) var(--space-6);
    font-size: var(--body);
}

.hero-ext-btn svg {
    flex-shrink: 0;
}

/* == Scrolling Ticker (ambient activity) == */
.ticker {
    width: 100%;
    overflow: hidden;
    position: relative;
    margin: var(--space-2) auto var(--space-2);
    max-width: 900px;
    padding: 0 var(--space-4);
    height: 28px;
    mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
}

.ticker-track {
    display: flex;
    gap: var(--space-6);
    width: max-content;
    animation: ticker-scroll 40s linear infinite;
}

.ticker-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--xs);
    color: var(--text-dim);
    white-space: nowrap;
    font-weight: var(--weight-medium);
}

.ticker-source {
    font-weight: var(--weight-bold);
    letter-spacing: 0.06em;
}
.ticker-source-mvlempyr { color: var(--accent-primary); }
.ticker-source-royalroad { color: var(--accent-gold); }
.ticker-source-scribblehub { color: var(--accent-violet); }
.ticker-source-wuxiaworld { color: var(--success); }
.ticker-source-webnovel { color: var(--danger); }

.footer-dot-mvlempyr { background: var(--accent-primary); }
.footer-dot-royalroad { background: var(--accent-gold); }
.footer-dot-scribblehub { background: var(--accent-violet); }
.footer-dot-wuxiaworld { background: var(--success); }
.footer-dot-webnovel { background: var(--danger); }

@keyframes ticker-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

.ticker:hover .ticker-track {
    animation-play-state: paused;
}

/* == Live Preview (product-in-action mockup) == */
.live-preview {
    max-width: 640px;
    margin: var(--space-3) auto var(--space-5);
    padding: 0 var(--space-4);
    position: relative;
    z-index: 1;
}

.live-preview-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-4) var(--space-5);
    display: flex;
    flex-direction: column;
    gap: 0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    transition: box-shadow var(--transition-smooth);
}

.live-preview-card:hover {
    box-shadow: 0 12px 48px rgba(0,0,0,0.4);
}

.live-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--xs);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-1);
    border-bottom: 1px solid var(--border-light);
}

.live-preview-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(79, 184, 133, 0.1);
    color: var(--success);
    font-weight: var(--weight-bold);
}

.live-preview-badge .live-preview-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--success);
}

.live-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-1);
    font-size: var(--body);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    transition: background var(--transition-smooth), transform var(--transition-smooth);
    animation: live-item-in 0.4s ease-out both;
}
.live-item:nth-child(2) { animation-delay: 0.08s; }
.live-item:nth-child(3) { animation-delay: 0.16s; }
.live-item:nth-child(4) { animation-delay: 0.24s; }
.live-item:nth-child(5) { animation-delay: 0.32s; }
.live-item:nth-child(6) { animation-delay: 0.40s; }

.live-item:hover {
    background: var(--surface-bg-hover);
    transform: translateX(2px);
}

@keyframes live-item-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.live-item-source {
    flex-shrink: 0;
    font-size: var(--xs);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    line-height: 1.4;
}
.live-item-source-mvlempyr { background: rgba(79, 143, 224, 0.1); color: var(--accent-primary); }
.live-item-source-royalroad { background: rgba(200, 155, 60, 0.1); color: var(--accent-gold); }
.live-item-source-scribblehub { background: rgba(124, 92, 191, 0.08); color: var(--accent-violet); }
.live-item-source-wuxiaworld { background: rgba(79, 184, 133, 0.08); color: var(--success); }
.live-item-source-webnovel { background: rgba(255, 107, 107, 0.08); color: var(--danger); }

.live-item-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-item-chapter {
    flex-shrink: 0;
    font-size: var(--caption);
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.live-item-time {
    flex-shrink: 0;
    font-size: var(--xs);
    color: var(--text-dim);
}

/* == Social Proof == */
.social-proof {
    max-width: 640px;
    margin: 0 auto var(--space-6);
    padding: 0 var(--space-4);
}

.proof-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    text-align: center;
    position: relative;
}

.proof-stats {
    display: flex;
    justify-content: center;
    gap: var(--space-6);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}
.proof-stat {
    text-align: center;
}
.proof-stat-value {
    display: block;
    font-size: var(--2xl);
    font-weight: var(--weight-bold);
    color: var(--accent-primary);
    line-height: 1;
}
.proof-stat-label {
    display: block;
    font-size: var(--caption);
    color: var(--text-dim);
    margin-top: var(--space-1);
}
.proof-caption {
    font-size: var(--caption);
    color: var(--text-dim);
    max-width: 400px;
    margin: 0 auto;
}

/* == How It Works (replaces feature cards) == */
.how-it-works {
    max-width: 800px;
    margin: 0 auto var(--space-10);
    padding: 0 var(--space-4);
}

.steps {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.step {
    display: flex;
    align-items: flex-start;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-6);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--bg-card);
    position: relative;
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

.step:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.step-number {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    font-size: var(--body);
    font-weight: var(--weight-bold);
    font-variant-numeric: tabular-nums;
}

.step-body {
    flex: 1;
    min-width: 0;
}

.step-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--accent-primary);
    margin-bottom: var(--space-2);
}

.step-icon svg {
    width: 16px;
    height: 16px;
}

.step-body h3 {
    font-size: var(--title);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-1);
    font-family: var(--font-display);
    color: var(--text-primary);
}

.step-body p {
    font-size: var(--body);
    color: var(--text-muted);
    line-height: var(--leading-relaxed);
    margin-bottom: 0;
}

.step-connector {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    margin-left: 18px;
    padding-left: var(--space-5);
    opacity: 0.4;
}

.step-connector svg {
    width: 20px;
    height: 20px;
}

/* == Browser Extension Section == */
.ext-section {
    max-width: 800px;
    margin: 0 auto var(--space-8);
    padding: var(--space-8) var(--space-4);
    position: relative;
    text-align: center;
}

.ext-lead {
    font-size: clamp(1.125rem, 3vw, 1.5rem);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-6);
    position: relative;
    font-family: var(--font-display);
}

.ext-flow {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    position: relative;
}

.ext-step {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    /* Glass is permitted on two surfaces only (4.6): the modal scrim and one
       sticky summary bar. On this page that budget goes to .sticky-cta. */
    background: var(--bg-card);
    text-align: left;
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

.ext-step:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.ext-step-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
}

.ext-step-icon svg {
    width: 18px;
    height: 18px;
}

.ext-step-body {
    flex: 1;
    min-width: 0;
}

.ext-step-body h3 {
    font-size: var(--title);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-1);
    font-family: var(--font-display);
    color: var(--text-primary);
}

.ext-step-body p {
    font-size: var(--body);
    color: var(--text-muted);
    line-height: var(--leading-relaxed);
    margin-bottom: 0;
}

.ext-connector {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    margin-left: 20px;
    padding-left: var(--space-5);
    opacity: 0.35;
}

.ext-connector svg {
    width: 18px;
    height: 18px;
}

.ext-cta {
    margin-top: var(--space-6);
    position: relative;
}

.ext-cta .btn-lg {
    padding: var(--space-3) var(--space-8);
    font-size: var(--body);
    border-radius: var(--radius-full);
    transition: background var(--transition), border-color var(--transition);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.ext-cta .btn-lg:hover {
    box-shadow: 0 6px 30px rgba(79, 143, 224, 0.35);
    transform: translateY(-1px);
}

.ext-store-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-3);
    padding: var(--space-2) var(--space-5);
    border-radius: var(--radius-full);
    font-size: var(--body);
    font-weight: var(--weight-semibold);
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: transparent;
    transition: all var(--transition-smooth);
    text-decoration: none;
}

.ext-store-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-primary-subtle);
}

.ext-store-btn svg {
    flex-shrink: 0;
}

/* == Sticky Mobile CTA == */
.sticky-cta {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-glass);
    backdrop-filter: var(--glass-blur-strong);
    -webkit-backdrop-filter: var(--glass-blur-strong);
    border-top: 1px solid var(--glass-border);
    z-index: 100;
    justify-content: center;
}

.sticky-cta .btn {
    width: 100%;
    max-width: 400px;
    padding: var(--space-3) var(--space-6);
    font-size: var(--body);
    font-weight: var(--weight-semibold);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    box-shadow: 0 4px 20px rgba(79, 143, 224, 0.3);
}

/* == Showcase Section == */
.showcase {
    text-align: center;
    padding: var(--space-12) var(--space-4) var(--space-8);
    position: relative;
    overflow: hidden;
}

.showcase-title {
    font-size: var(--heading);
    font-weight: var(--weight-bold);
    margin-bottom: var(--space-2);
    font-family: var(--font-display);
    position: relative;
}

.showcase-sub {
    color: var(--text-muted);
    margin-bottom: var(--space-6);
    position: relative;
}

.showcase-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
    position: relative;
}

.source-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-5);
    border-radius: var(--radius-full);
    font-size: var(--caption);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    text-decoration: none;
    transition: all var(--transition-smooth);
    line-height: 1;
}

.source-btn-mvlempyr {
    background: rgba(79, 143, 224, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(79, 143, 224, 0.2);
}
.source-btn-mvlempyr:hover {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
    box-shadow: 0 0 16px rgba(79, 143, 224, 0.3);
}

.source-btn-royalroad {
    background: rgba(200, 155, 60, 0.1);
    color: var(--accent-gold);
    border: 1px solid rgba(200, 155, 60, 0.2);
}
.source-btn-royalroad:hover {
    background: var(--accent-gold);
    color: #fff;
    border-color: var(--accent-gold);
    box-shadow: 0 0 16px rgba(200, 155, 60, 0.3);
}

.source-btn-scribblehub {
    background: rgba(124, 92, 191, 0.1);
    color: var(--accent-violet);
    border: 1px solid rgba(124, 92, 191, 0.2);
}
.source-btn-scribblehub:hover {
    background: var(--accent-violet);
    color: #fff;
    border-color: var(--accent-violet);
    box-shadow: 0 0 16px rgba(124, 92, 191, 0.3);
}

.source-btn-wuxiaworld {
    background: rgba(79, 184, 133, 0.1);
    color: var(--success);
    border: 1px solid rgba(79, 184, 133, 0.2);
}
.source-btn-wuxiaworld:hover {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
    box-shadow: 0 0 16px rgba(79, 184, 133, 0.3);
}

.source-btn-webnovel {
    background: rgba(255, 107, 107, 0.1);
    color: var(--danger);
    border: 1px solid rgba(255, 107, 107, 0.2);
}
.source-btn-webnovel:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    box-shadow: 0 0 16px rgba(255, 107, 107, 0.3);
}

.showcase-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding: var(--space-3) 0;
    position: relative;
}

.strip-item {
    font-size: var(--caption);
    color: var(--text-dim);
    font-weight: var(--weight-medium);
}

.strip-divider {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    opacity: 0.4;
}

.strip-item strong {
    color: var(--text-primary);
    font-weight: var(--weight-semibold);
}

/* == Landing Footer == */
.landing-footer {
    margin-top: auto;
    padding: var(--space-6) var(--space-4) var(--space-10);
    text-align: center;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    max-width: 960px;
    margin: 0 auto;
    padding-top: var(--space-5);
    border-top: 1px solid var(--border-light);
}

.footer-brand-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.footer-brand-icon {
    font-size: 0.7rem;
    color: var(--accent-primary);
}

.footer-brand {
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    font-size: var(--body);
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
}

.footer-tagline {
    font-size: var(--caption);
    color: var(--text-muted);
}

.footer-source-dots {
    display: flex;
    gap: 4px;
    margin: var(--space-1) 0;
}

.footer-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    opacity: 0.6;
}

.footer-text {
    font-size: var(--xs);
    color: var(--text-dim);
}

/* == Mobile-Only Feature Carousel == */
.mob-features {
    display: none;
    max-width: 100vw;
    overflow: hidden;
    position: relative;
}

.mob-features .section-eyebrow {
    padding: 0 var(--space-4);
    text-align: left;
}

.mob-feature-track {
    display: flex;
    gap: var(--space-3);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding: 0 var(--space-4) var(--space-2);
    scrollbar-width: none;
    -ms-overflow-style: none;
    mask-image: linear-gradient(to right, black 88%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 88%, transparent 100%);
}

.mob-feature-track::-webkit-scrollbar {
    display: none;
}

.mob-feature-card {
    flex-shrink: 0;
    scroll-snap-align: start;
    width: 82vw;
    max-width: 340px;
}

.mob-feature-label {
    font-size: var(--xs);
    font-weight: var(--weight-bold);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-primary);
    margin-bottom: var(--space-2);
}

.mob-feature-preview {
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    background: var(--bg-card);
    overflow: hidden;
    margin-bottom: var(--space-2);
    min-height: 160px;
}

.mob-feature-desc {
    font-size: var(--caption);
    color: var(--text-muted);
    line-height: var(--leading-normal);
    margin-bottom: 0;
}

/* Dashboard preview card */
.mob-dash-preview {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.mob-dash-row {
    display: flex;
    gap: var(--space-3);
}

.mob-dash-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    background: var(--accent-primary-subtle);
    font-size: var(--caption);
    color: var(--text-muted);
}

.mob-dash-num {
    font-size: var(--heading);
    font-weight: var(--weight-bold);
    color: var(--accent-primary);
    line-height: 1;
    margin-bottom: var(--space-1);
}

.mob-dash-progress {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-lg);
    background: var(--surface-bg);
}

.mob-dash-progress-bar {
    flex-shrink: 0;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--gradient-brand);
}

.mob-dash-progress-text {
    font-size: var(--xs);
    color: var(--text-dim);
}

.mob-dash-progress-text strong {
    color: var(--text-primary);
    font-weight: var(--weight-semibold);
}

/* Timeline preview */
.mob-timeline-preview {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.mob-timeline-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.mob-timeline-dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary);
    margin-top: 5px;
}

.mob-timeline-dot-alt {
    background: var(--accent-gold);
}

.mob-timeline-dot-alt2 {
    background: var(--accent-violet);
}

.mob-timeline-body {
    flex: 1;
    min-width: 0;
}

.mob-timeline-title {
    display: block;
    font-size: var(--body);
    font-weight: var(--weight-medium);
    color: var(--text-primary);
    line-height: 1.2;
}

.mob-timeline-meta {
    font-size: var(--xs);
    color: var(--text-dim);
}

/* Journal preview */
.mob-journal-preview {
    padding: var(--space-4);
}

.mob-journal-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.mob-journal-mood {
    font-size: 1.5rem;
    flex-shrink: 0;
    line-height: 1;
}

.mob-journal-meta {
    flex: 1;
    min-width: 0;
}

.mob-journal-title {
    display: block;
    font-size: var(--body);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

.mob-journal-date {
    font-size: var(--xs);
    color: var(--text-dim);
}

.mob-journal-excerpt {
    font-size: var(--caption);
    color: var(--text-muted);
    line-height: var(--leading-relaxed);
    font-style: italic;
    padding: var(--space-2) var(--space-3);
    border-left: 2px solid var(--border-light);
    margin-bottom: 0;
}

/* Highlight preview */
.mob-highlight-preview {
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.mob-highlight-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--caption);
    line-height: var(--leading-normal);
    font-style: italic;
}

.mob-highlight-card svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.mob-highlight-blue {
    background: rgba(79, 143, 224, 0.06);
    border-left: 2px solid var(--accent-primary);
    color: var(--accent-primary);
}

.mob-highlight-gold {
    background: rgba(200, 155, 60, 0.06);
    border-left: 2px solid var(--accent-gold);
    color: var(--accent-gold);
}

/* Stats preview (replaced AI companion preview) */
.mob-stats-preview {
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.mob-stat-row {
    display: flex;
    justify-content: space-around;
    gap: var(--space-2);
}

.mob-stat-item {
    font-size: var(--caption);
    color: var(--text-muted);
}

.mob-stat-item strong {
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: var(--body);
    font-weight: var(--weight-bold);
    font-variant-numeric: tabular-nums;
}

/* == Responsive == */

/* ========== Mobile App-Style Layout (≤768px) ========== */
@media (max-width: 768px) {

    /* ---- Contain overflow (flex min-width:auto in column layout widens beyond viewport) ---- */
    main.container {
        width: 100%;
        box-sizing: border-box;
    }
    .landing {
        width: 100%;
        min-width: 0;
    }
    body:has(.landing) {
        overflow-x: hidden;
    }

    /* ---- Section Reorder ---- */
    .landing > .hero { order: 0; }
    .landing > .ticker { display: none; }
    .landing > .live-preview { display: none; }
    .landing > .ext-section { order: 3; }
    .landing > .social-proof { order: 1; }
    .landing > .mob-features { display: block; order: 2; }
    .landing > .how-it-works { display: none; }
    .landing > .showcase { order: 4; }
    .landing > .landing-footer { order: 5; }

    /* ---- Alternating Section Backgrounds (app-screen rhythm) ---- */
    .landing > .social-proof {
        background: var(--surface-bg);
    }
    .landing > .mob-features {
        background: transparent;
    }
    .landing > .ext-section {
        background: var(--surface-bg);
    }

    /* ---- Sticky CTA (iOS-style bottom bar) ---- */
    .sticky-cta {
        display: flex;
        padding: var(--space-3) var(--space-5);
        padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
        background: rgba(10, 10, 15, 0.92);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }
    body {
        padding-bottom: 72px;
    }

    /* ======== Hero — App Splash ======== */
    .landing .hero {
        min-height: 100dvh;
        max-width: none;
        padding: var(--space-6) var(--space-5) var(--space-3);
        display: flex;
        flex-direction: column;
        justify-content: center;
        text-align: center;
        position: relative;
        overflow: hidden;
    }
    .landing .hero-content {
        display: flex;
        flex-direction: column;
        gap: var(--space-3);
        position: relative;
        z-index: 1;
    }
    .landing .hero-diamond {
        font-size: 4rem;
        top: -5%;
        opacity: 0.25;
        -webkit-text-stroke: 1px rgba(79, 143, 224, 0.06);
    }
    .landing .hero-bg {
        width: 350px;
        height: 350px;
        top: -20%;
    }
    .landing .hero h1 {
        font-size: 1.875rem;
        letter-spacing: -0.03em;
        margin-bottom: var(--space-1);
    }
    .landing .hero-badge {
        align-self: center;
        margin-bottom: var(--space-2);
        font-size: 0.625rem;
        padding: 3px 10px 3px 6px;
    }
    .landing .hero-sub {
        max-width: none;
        margin: 0 auto var(--space-2);
        font-size: 0.875rem;
    }
    .landing .hero-actions {
        flex-direction: column;
        gap: var(--space-2);
        align-items: stretch;
        max-width: 340px;
        margin: 0 auto;
    }
    .landing .hero-actions .btn-lg {
        width: 100%;
        max-width: none;
        justify-content: center;
        min-height: 52px;
        padding: var(--space-3) var(--space-6);
        font-size: 0.9375rem;
    }
    .landing .hero-actions .btn-lg:first-child {
        box-shadow: 0 4px 24px rgba(79, 143, 224, 0.35);
    }
    .landing .hero-actions .btn-lg:nth-child(3) {
        display: none;
    }
    .landing .hero-actions .btn-outline {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(255, 255, 255, 0.08);
        color: var(--text-secondary);
        font-weight: var(--weight-medium);
        min-height: 40px;
        padding: var(--space-2) var(--space-6);
        font-size: 0.8125rem;
    }

    /* ======== Social Proof — iOS Widget Stats ======== */
    .landing .social-proof {
        max-width: none;
        margin: 0;
        padding: var(--space-5) var(--space-5) var(--space-5);
    }
    .landing .proof-card {
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 0;
    }
    .landing .proof-card::before {
        display: none;
    }
    .landing .proof-stats {
        gap: var(--space-3);
        margin-bottom: 0;
        flex-wrap: nowrap;
    }
    .landing .proof-stat {
        flex: 1;
        padding: var(--space-3) var(--space-2);
        border-radius: var(--radius-xl);
        background: var(--bg-card);
        border: 1px solid var(--border);
    }
    .landing .proof-stat-value {
        font-size: 1.25rem;
        line-height: 1.2;
    }
    .landing .proof-stat-label {
        font-size: 0.625rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        margin-top: var(--space-1);
    }
    .landing .proof-caption {
        display: none;
    }

    /* ======== Feature Carousel — App Onboarding Screens ======== */
    .landing .mob-features {
        display: block;
        padding: var(--space-5) 0 var(--space-6);
    }
    .landing .mob-features .section-eyebrow {
        padding: 0 var(--space-5);
        margin-bottom: var(--space-4);
        text-align: left;
        font-size: 0.625rem;
    }
    .landing .mob-only {
        display: block;
    }
    .landing .mob-feature-track {
        gap: var(--space-3);
        padding: 0 var(--space-5) var(--space-3);
        mask-image: none;
        -webkit-mask-image: none;
    }
    .landing .mob-feature-card {
        width: 78vw;
        max-width: 300px;
    }
    .landing .mob-feature-label {
        font-size: 0.6rem;
        margin-bottom: var(--space-2);
    }
    .landing .mob-feature-preview {
        min-height: 150px;
        border-radius: var(--radius-lg);
        border: 1px solid var(--border);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    }
    .landing .mob-feature-desc {
        font-size: 0.75rem;
        color: var(--text-muted);
        line-height: 1.45;
    }

    /* ======== Extension — App Store Download Card ======== */
    .landing .ext-section {
        max-width: none;
        margin: 0;
        padding: var(--space-6) var(--space-5);
        text-align: center;
    }
    .landing .ext-section .section-eyebrow {
        font-size: 0.625rem;
        margin-bottom: var(--space-2);
    }
    .landing .ext-lead {
        font-size: 1.125rem;
        margin-bottom: var(--space-2);
    }
    .landing .ext-flow {
        display: none;
    }
    .landing .ext-cta {
        margin-top: var(--space-4);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--space-3);
    }
    .landing .ext-cta .btn-lg {
        width: 100%;
        max-width: 320px;
        justify-content: center;
        min-height: 50px;
        font-size: 0.9375rem;
        border-radius: var(--radius-full);
    }
    .landing .ext-store-btn {
        margin-top: 0;
        justify-content: center;
        min-height: 44px;
        font-size: 0.875rem;
        border-radius: var(--radius-full);
        padding: var(--space-2) var(--space-6);
    }

    /* ======== Showcase — Source Gallery ======== */
    .landing .showcase {
        padding: var(--space-5) var(--space-5) var(--space-6);
    }
    .landing .showcase-title {
        font-size: 1rem;
    }
    .landing .showcase-sub {
        margin-bottom: var(--space-4);
        font-size: 0.75rem;
    }
    .landing .showcase-grid {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: var(--space-2);
        padding-bottom: var(--space-2);
        justify-content: flex-start;
        scrollbar-width: none;
        mask-image: linear-gradient(to right, black 85%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    }
    .landing .showcase-grid::-webkit-scrollbar {
        display: none;
    }
    .landing .source-btn {
        flex-shrink: 0;
        scroll-snap-align: start;
        min-height: 44px;
        font-size: 0.65rem;
        padding: var(--space-2) var(--space-4);
    }

    /* ======== Footer ======== */
    .landing .landing-footer {
        padding: var(--space-4) var(--space-5) var(--space-8);
    }
    .landing .footer-inner {
        padding-top: var(--space-4);
    }
    .landing .footer-tagline {
        font-size: 0.6875rem;
    }
}

/* ---- Small screens: tighten spacing ---- */
@media (max-width: 400px) {
    .landing .hero {
        padding: var(--space-5) var(--space-4) var(--space-2);
    }
    .landing .hero h1 {
        font-size: 1.5rem;
    }
    .landing .hero-diamond {
        font-size: 3rem;
        top: -3%;
    }
    .landing .hero-sub {
        font-size: 0.8125rem;
    }
    .landing .hero-actions .btn-lg {
        min-height: 48px;
        font-size: 0.875rem;
    }
    .landing .hero-actions .btn-outline {
        min-height: 36px;
        font-size: 0.75rem;
    }
    .landing .proof-stat {
        padding: var(--space-2) var(--space-1);
    }
    .landing .proof-stat-value {
        font-size: 1rem;
    }
    .landing .proof-stat-label {
        font-size: 0.5625rem;
    }
    .landing .social-proof {
        padding: var(--space-3) var(--space-3) var(--space-3);
    }
    .landing .ext-section {
        padding: var(--space-5) var(--space-4);
    }
    .landing .ext-cta .btn-lg {
        min-height: 46px;
        font-size: 0.875rem;
    }
    .landing .showcase {
        padding: var(--space-4) var(--space-4) var(--space-5);
    }
}

/* ---- Mid-range (phablets / small tablets portrait) ---- */
@media (min-width: 401px) and (max-width: 767px) {
    .landing .hero {
        padding: var(--space-6) var(--space-5) var(--space-3);
    }
    .landing .hero h1 {
        font-size: 2rem;
    }
    .landing .hero-diamond {
        font-size: 4.5rem;
    }
    .landing .hero-bg {
        width: 400px;
        height: 400px;
    }
    .landing .hero-sub {
        font-size: 0.9375rem;
        max-width: 440px;
    }
    .landing .hero-actions {
        max-width: 380px;
    }
    .landing .proof-stat-value {
        font-size: 1.375rem;
    }
    .landing .social-proof {
        padding: var(--space-5) var(--space-6) var(--space-5);
    }
    .landing .mob-features {
        padding: var(--space-5) 0 var(--space-6);
    }
    .landing .mob-feature-card {
        width: 65vw;
        max-width: 360px;
    }
    .landing .ext-section {
        padding: var(--space-6) var(--space-6);
    }
    .landing .showcase {
        padding: var(--space-5) var(--space-6) var(--space-6);
    }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .hero-diamond,
    .hero-bg,
    .ticker-track,
    .live-item,
    .hero-badge-dot,
    .live-preview-dot,
    .step, .ext-section, .social-proof, .showcase, .mob-features {
        animation: none !important;
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ===================================
   Auth Pages — Login, Register, etc.
   =================================== */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 56px);
    padding: var(--space-6) var(--space-4);
    position: relative;
    overflow: hidden;
}

.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-8) var(--space-6);
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

.auth-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
}

.auth-brand {
    text-align: center;
    margin-bottom: var(--space-6);
}

.auth-brand-icon {
    font-size: 1.5rem;
    color: var(--accent-primary);
    display: block;
    margin-bottom: var(--space-1);
    line-height: 1;
}

.auth-brand-text {
    font-family: var(--font-display);
    font-size: var(--title);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
}

.auth-card h1,
.auth-card h2 {
    font-family: var(--font-display);
    font-size: var(--heading);
    font-weight: var(--weight-semibold);
    text-align: center;
    margin-bottom: var(--space-1);
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--caption);
    margin-bottom: var(--space-6);
    line-height: var(--leading-normal);
}

.auth-card .form-group {
    margin-bottom: var(--space-4);
}

.auth-card label {
    display: block;
    font-size: var(--caption);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

/* The per-field styling here duplicated components/forms.css declaration for
   declaration, and its extra specificity defeated two things: the 16px mobile
   input size (responsive.css), so auth fields still zoomed on iOS, and the
   :focus-visible ring, via a second `outline: none`. Removed — the base rule
   in forms.css gives the identical appearance. */

.auth-card input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-subtle);
}

.auth-card .btn-block {
    width: 100%;
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--accent-primary-solid);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--body);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: box-shadow var(--transition-smooth), transform var(--transition-smooth);
}

.auth-card .btn-block:hover {
    box-shadow: 0 4px 20px rgba(79, 143, 224, 0.3);
    transform: translateY(-1px);
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-5);
    font-size: var(--caption);
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.auth-footer a {
    color: var(--accent-primary);
    font-weight: var(--weight-medium);
    text-decoration: none;
    transition: color var(--transition-smooth);
}

.auth-footer a:hover {
    color: var(--accent-primary-hover);
    text-decoration: underline;
}

/* Divider line above footer */
.auth-divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--space-5) 0 var(--space-3);
}

/* Error pages */
.error-card {
    text-align: center;
    padding: var(--space-12) var(--space-4);
    max-width: 400px;
    margin: var(--space-12) auto;
}

.error-card h1 {
    font-size: 3rem;
    margin-bottom: var(--space-2);
}

.error-card p {
    font-size: var(--title);
    margin-bottom: var(--space-4);
    color: var(--text-muted);
}

.error-card .text-body {
    font-size: var(--body, 0.9375rem);
    color: var(--text-secondary, #B0B8C4);
}

/* Multiple escape routes now, branched on auth state — see errors/_actions.html */
.error-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    margin-top: var(--space-5);
}

/* The decorative layer `.auth-page` was built to hold — it sets
   `position: relative; overflow: hidden`, and `.auth-card` sits at `z-index: 1`
   to float above this. The div is in the markup on every auth page and had no
   CSS, so the scaffolding was there and the thing it scaffolded was not.

   `--gradient-glow` is the token the dashboard, detail, profile and series
   pages all use for exactly this. Landing is capped at one glow by spec 23 §4;
   that limit is about that page, not this one. */
.auth-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: var(--gradient-glow);
    pointer-events: none;
}

/* One line under Login and Register (UX audit 6.11). */
.auth-page-footer {
    padding: var(--space-6, 24px) var(--space-4, 16px);
    text-align: center;
    font-size: var(--caption, 0.8125rem);
    color: var(--text-dim, #6B7380);
}
.auth-page-footer a { color: inherit; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    margin-top: var(--space-4);
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-md);
    font-size: var(--caption);
    font-weight: var(--weight-medium);
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.pagination a:hover {
    background: var(--surface-bg-hover);
    border-color: var(--surface-border-hover);
    color: var(--text-primary);
}

.pagination .current {
    background: var(--accent-subtle);
    color: var(--accent-primary);
    border-color: transparent;
}

/* --- HTMX Motion System --- */
.htmx-added {
    animation: htmx-enter 0.35s var(--transition-enter, cubic-bezier(0.34, 1.56, 0.64, 1));
}

@keyframes htmx-enter {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.htmx-settling {
    opacity: 0;
}

@keyframes htmx-leave {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-8px) scale(0.97);
    }
}

/* --- Shake for swap errors --- */
.htmx-request {
    opacity: 0.7;
    transition: opacity var(--transition-smooth, 0.25s ease);
}

/* --- Classic fade-in utility --- */
.fade-in {
    animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* The placeholder that fills an hx-swap target until the real content lands.
   Its children (.skeleton-text and friends) already carry their own spacing,
   so the wrapper's only job is to stop the last one adding a trailing gap
   inside the card it is standing in for. */
.skeleton-loading > :last-child {
    margin-bottom: 0;
}

.skeleton {
    background: var(--surface-bg);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--surface-bg-hover), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.skeleton-card {
    height: 160px;
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--space-2);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* Skeleton layout containers.

   `.skeleton` (the shimmer) and the width/height of each bar are set — the
   bars carry inline dimensions from _skeleton.html — but the containers that
   are supposed to lay them out had no CSS. `.skeleton-row` in particular is
   meant to place its bars side by side and, as a plain <div>, stacked them.

   `.skeleton-line`, `.skeleton-inline`, `.skeleton-line-wide` and
   `.skeleton-block` deliberately get only what the inline styles do not
   already supply. */
.skeleton-row {
    display: flex;
    align-items: center;
    gap: var(--space-2, 0.5rem);
    margin-bottom: var(--space-2, 0.5rem);
}

.skeleton-row:last-child {
    margin-bottom: 0;
}

.skeleton-line,
.skeleton-block {
    display: block;
}

.skeleton-line-wide {
    width: 100%;
}

.skeleton-inline {
    display: inline-block;
    flex: 0 0 auto;
}

.skeleton-table {
    display: block;
}

/* htmx's built-in indicator class needs this toggle rule — htmx does not ship it */
.htmx-indicator {
  opacity: 0;
  transition: opacity 150ms ease-in;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* the actual spinner visual */
.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border-subtle, rgba(255, 255, 255, 0.15));
  border-top-color: var(--accent-blue, #4F8FE0);
  border-radius: 50%;
  animation: spinner-rotate 0.6s linear infinite;
  vertical-align: middle;
}

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

/* respect motion preferences instead of forcing the animation on everyone */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    opacity: 0.7;
  }
}

/* The small variant, used in 22 templates and never defined — so every
   `spinner spinner-sm` rendered at the full 1rem. Mostly these sit inside
   buttons and chips, where the base size crowds the label. */
.spinner-sm {
  width: 0.75rem;
  height: 0.75rem;
  border-width: 2px;
}

.social-proof-badge {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3, 12px);
    align-items: center;
    padding: var(--space-2, 8px) var(--space-3, 12px);
    background: var(--color-bg-raised, #242424);
    border: 1px solid var(--color-border, #333);
    border-radius: var(--radius, 8px);
    font-size: var(--font-sm, 13px);
    color: var(--color-text-dim, #999);
}

.social-proof-badge svg {
    opacity: 0.6;
    flex-shrink: 0;
}

.social-proof-trackers,
.social-proof-active {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.social-proof-trackers {
    color: var(--color-text, #e0e0e0);
    font-weight: 500;
}

.social-proof-active {
    color: var(--color-success, #22c55e);
}

.similar-readers-section {
    margin-top: var(--space-4, 24px);
}

.similar-readers-section h3 {
    font-size: var(--font-base, 14px);
    font-weight: 600;
    color: var(--color-text, #e0e0e0);
    margin-bottom: var(--space-3, 12px);
}

.similar-readers-scroll {
    display: flex;
    gap: var(--space-3, 12px);
    overflow-x: auto;
    padding-bottom: var(--space-2, 8px);
    -webkit-overflow-scrolling: touch;
}

.similar-readers-card {
    flex: 0 0 160px;
    display: flex;
    flex-direction: column;
    background: var(--color-bg-raised, #242424);
    border: 1px solid var(--color-border, #333);
    border-radius: var(--radius, 8px);
    overflow: hidden;
    text-decoration: none;
    transition: border-color 0.2s, transform 0.2s;
}

.similar-readers-card:hover {
    border-color: var(--color-accent, #6366f1);
    transform: translateY(-2px);
}

.similar-readers-cover-wrap {
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: var(--color-bg, #1a1a1a);
}

.similar-readers-cover-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.similar-readers-info {
    padding: var(--space-2, 8px);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.similar-readers-title {
    font-size: var(--font-sm, 13px);
    font-weight: 600;
    color: var(--color-text, #e0e0e0);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.similar-readers-author {
    font-size: var(--font-xs, 11px);
    color: var(--color-text-dim, #999);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.similar-readers-score {
    font-size: var(--font-xs, 11px);
    color: var(--color-accent, #6366f1);
    margin-top: auto;
    padding-top: var(--space-1, 4px);
}

.similar-readers-empty {
    font-size: var(--font-sm, 13px);
    padding: var(--space-3, 12px) 0;
}

.pwa-install-banner {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
}

.pwa-install-icon {
    font-size: 1.5rem;
}

.pwa-install-text {
    flex: 1;
    font-size: var(--body);
    color: var(--text-primary);
    font-weight: var(--weight-medium);
}

/* ========================================
   MOBILE-FIRST: default for mobile
   ======================================== */

.fab { display: none; }
.fab-modal { display: none; }
.search-overlay { display: none; }
.search-toggle { display: none !important; }
.desktop-search-form { display: flex; }
.mobile-nav-toggle { display: none; }

/* ========================================
   TABLET (1024px)
   ======================================== */
@media (max-width: 1024px) {
    .tracked-novel-main {
        flex-direction: column;
    }
    .tracked-novel-chapter {
        text-align: left;
    }
    .page-content {
        padding: var(--space-4) var(--space-5) var(--space-8);
    }
}

/* ========================================
   NAVIGATION TIERS — 04-design-system.md §4.4

   sm  ≤599      bottom tab bar; sidebar is an overlay drawer
   md  600–899   sidebar is a persistent rail, collapsed by default but
                 expandable; no bottom tab bar
   lg  ≥900      sidebar expanded

   The nav rules below used to sit in the 768px block together, which coupled
   "sidebar becomes a drawer" to "bottom tab bar appears". Splitting them is
   what gives md its own behaviour.
   ======================================== */
@media (max-width: 599px) {
    /* Single-purpose FAB: track a novel. sm only — at md and up the topbar +
       is in reach (§2.3). It was previously display:none everywhere with no
       rule turning it on, so it never rendered at all. */
    .fab {
        display: inline-flex;
    }

    /* The FAB is the track action at this size, so the topbar's + is a
       duplicate — and the topbar cannot afford it. Every icon control here
       claims 44px for its touch target (see the touch-tier block below), and
       with Home's Focus button the row needed ~410px of a 358px bar. */
    .topbar-actions [data-open-track] {
        display: none;
    }

    .topbar {
        gap: var(--space-2);
        /* The bar is solid now; a hairline says where it ends once the page
           has scrolled under it. */
        border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    }

    /* No menu button on phones. The drawer it opened held the same five
       destinations as the bottom bar plus Settings, which is in the account
       menu — and five icons sharing the row squeezed this one to 11px and cut
       the page title to "The Wande…". `.topbar` raises the specificity past
       the two later rules that turn the button on below 900px. */
    .topbar .mobile-nav-toggle {
        display: none;
    }

    /* Same trade as the 379px block makes, one tier earlier: theme moves into
       the account menu so the title gets the room. */
    .topbar-actions .theme-toggle {
        display: none;
    }

    .account-menu .account-menu-theme,
    .account-menu .account-menu-streak {
        display: block;
    }

    .topbar .topbar-back {
        display: inline-flex;
    }

    /* The + floats over the last rows of a list. Pages that carry it leave
       room for it, so the final row can scroll clear. */
    .fab ~ .main-content {
        padding-bottom: calc(var(--mobile-nav-height, 60px) + 72px);
    }

    .sidebar {
        display: none;
        width: var(--sidebar-width);
    }

    .sidebar-open .sidebar {
        display: flex;
    }

    .sidebar-open .sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding-bottom: var(--mobile-nav-height);
    }

    .mobile-nav {
        display: flex;
    }
}

/* The sidebar toggle is the only collapse control, so it must be reachable
   wherever the sidebar is collapsible — i.e. everywhere below lg. */
@media (max-width: 899px) {
    .mobile-nav-toggle {
        display: flex;
    }
}

/* ========================================
   TABLET & BELOW (768px)
   ======================================== */
@media (max-width: 768px) {
    /* Allow container to shrink below intrinsic content width */
    .container {
        min-width: 0;
    }

    .topbar {
        padding: 0 var(--space-4);
        height: 48px;
    }

    .page-content {
        padding: var(--space-3) var(--space-4) var(--space-8);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .novel-card {
        flex-direction: column;
        text-align: center;
    }

    .card-img-wrap {
        width: 100px;
        margin: 0 auto;
    }

    .card-img {
        width: 100px;
        height: 144px;
        margin: 0 auto;
    }

    .browse-tags {
        justify-content: center;
    }

    .browse-synopsis {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .table-wrap table,
    .table-wrap thead,
    .table-wrap tbody,
    .table-wrap th,
    .table-wrap td,
    .table-wrap tr {
        display: block;
    }

    .table-wrap thead {
        display: none;
    }

    .table-wrap tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin-bottom: var(--space-3);
        padding: var(--space-2) var(--space-3);
        background: var(--bg-card);
    }

    .table-wrap td {
        border: none;
        padding: var(--space-2) 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: var(--space-2);
    }

    .table-wrap td::before {
        content: attr(data-label);
        font-weight: var(--weight-semibold);
        font-size: var(--xs);
        color: var(--text-dim);
        text-transform: uppercase;
        letter-spacing: var(--tracking-wide);
        flex-shrink: 0;
    }

    .auth-card {
        max-width: none;
        margin: var(--space-4) var(--space-2);
        padding: var(--space-5);
    }

    .inline-form {
        flex-direction: column;
        gap: var(--space-2);
    }

    .inline-form .btn {
        width: 100%;
    }

    .search-wrapper input[type="search"],
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="url"],
    select,
    textarea {
        font-size: 16px;
    }

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

    .hero {
        padding: var(--space-6) var(--space-4) var(--space-6);
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero-sub {
        font-size: var(--body);
    }

    .hero-actions {
        flex-direction: column;
        align-items: center;
    }

    .features {
        grid-template-columns: 1fr;
    }

    /* Browse filter overlay */
    .browse-filters.browse-filters-open {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: var(--mobile-nav-height);
        z-index: 95;
        margin: 0;
        border-radius: 0;
        overflow-y: auto;
        padding: var(--space-5);
        background: var(--bg-surface);
        display: block;
    }
}

/* ========================================
   MOBILE (600px)
   ======================================== */
@media (max-width: 600px) {
    .nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border);
        padding: var(--space-2);
        gap: 2px;
    }

    .nav-links.nav-open {
        display: flex;
    }

    .nav-inner {
        position: relative;
        padding: 0 var(--space-4);
    }

    .novel-card-item {
        flex-direction: column;
        text-align: center;
    }

    .novel-card-cover {
        width: 100px;
        margin: 0 auto;
    }

    .novel-card-cover img {
        width: 100px;
        height: 144px;
    }

    .novel-card-meta {
        justify-content: center;
    }

    .novel-card-header {
        flex-direction: column;
        align-items: center;
    }

    .notification-item {
        flex-direction: column;
        align-items: stretch;
        padding: var(--space-3);
    }

    .notification-action {
        text-align: right;
        margin-top: var(--space-1);
    }

    .notification-novel-link {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }

    .notif-filters .filter-row {
        flex-direction: column;
        gap: var(--space-2);
    }

    .notif-filters .form-group {
        min-width: 0;
        width: 100%;
    }

    .filter-actions {
        width: 100%;
    }

    .filter-actions .btn-sm {
        flex: 1;
    }

    .tracked-novel-card {
        padding: var(--space-3);
    }

    .tracked-novel-title {
        font-size: var(--body);
    }

    .tracked-novel-actions {
        flex-direction: row;
        gap: var(--space-1);
    }

    .tracked-novel-actions .btn-sm {
        flex: 1;
        min-height: 36px;
    }
}

/* ========================================
   SMALL PHONES (480px)
   ======================================== */
@media (max-width: 480px) {
    .page-content {
        padding: var(--space-2) var(--space-3) var(--space-8);
    }

    .card {
        padding: var(--space-3);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-2);
    }

    .stat-value {
        font-size: var(--heading);
    }

    .novel-hero {
        padding: var(--space-4);
    }

    .novel-hero-title {
        font-size: var(--heading);
    }

    .novel-hero-stat-value {
        font-size: var(--title);
    }

    .collection-grid {
        grid-template-columns: 1fr;
    }

    .journey-cards {
        grid-template-columns: 1fr 1fr;
    }
}

/* ========================================
   TOUCH TARGETS — 04-design-system.md §4.9

   "minimum 44x44px hit area for anything tappable — including small icon
   buttons, which get padded hit areas rather than bigger glyphs."

   §4.9 (44px) and change-log #9 (34px buttons, 32px icon buttons) conflict
   on size, and the spec resolves it in favour of keeping the glyph small and
   growing the *hit area*. These rules do exactly that with a centred
   pseudo-element, so nothing shifts visually.

   Scoped to the touch tiers (sm + md). On desktop the pointer is precise and
   enlarged hit areas would only create overlap.
   ======================================== */
@media (max-width: 899px) {
    /* Icon-only controls only. `.btn` is deliberately excluded: it already
       owns ::after for the loading spinner (buttons.css) and for the landing
       hero (landing.css), and this file loads later at equal specificity, so
       claiming ::after here would silently destroy both. The 34px vs 44px
       conflict for text buttons is unresolved — see the audit. */
    .theme-toggle,
    .mobile-nav-toggle,
    .topbar-btn,
    .topbar-search,
    .topbar-back,
    .btn-icon {
        position: relative;
    }

    .theme-toggle::after,
    .mobile-nav-toggle::after,
    .topbar-btn::after,
    .topbar-search::after,
    .topbar-back::after,
    .btn-icon::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        min-width: 44px;
        min-height: 44px;
        width: 100%;
        height: 100%;
        /* This has to receive pointer events to be a hit area at all.

           It previously said `pointer-events: none`, which is what you write to
           stop a decorative overlay swallowing clicks — but here the overlay
           *is* the feature. With it, a tap 6px outside the button reached the
           card behind it and the control kept its painted 28px/34px box, so
           the 44px target measured as 44px in the CSS and behaved as 28px
           under a thumb.

           It never intercepts anything meaningful: a pseudo-element is not an
           event target, so a tap anywhere on it is dispatched to the button
           that owns it. Icon buttons contain only an <svg>, so there is no
           nested control for it to cover. */
        pointer-events: auto;
    }

    /* Reserving the space that hit area needs.

       Turning the pseudo-element on is only safe alongside this. The controls
       are 28px and 34px inside rows with a 4px gap, so each 44px area extends
       8px (or 5px) past its own edge and two neighbours would overlap by 12px.
       Overlapping areas do not merge — the one painted later wins the band —
       and in the highlight row the neighbour is Delete, so the fix on its own
       would have made a destructive action easier to hit by accident than it
       was while the target was broken.

       Spacing rather than resizing: a 44px target costs 44px of layout either
       way, but this keeps the control painted at the size the design asks for
       instead of inflating every icon button on small screens. */
    /* 32px controls, and .topbar-actions sets an 8px gap — 6px of reach each
       side would have overlapped a neighbour by 4px. */
    .theme-toggle,
    .mobile-nav-toggle,
    .topbar-btn,
    .topbar-back {
        margin: 6px;
    }

    /* Collapsed to its icon below 760px (topbar.css), where it is ~34px wide
       and had no hit area of its own. Above that it is a 220px field and the
       pseudo-element simply matches it. */
    .topbar-search {
        margin: 6px 5px;
    }

    .btn-icon {
        margin: 5px;
    }

    /* After .btn-icon: these carry both classes, and 28px needs the larger
       reach. Equal specificity, so the order is what decides it. */
    .btn-icon-sm {
        margin: 8px;
    }

    /* Footer and skip links render as 21px blocks with 6px gaps. That fails
       even the WCAG 2.2 AA floor (2.5.8): under 24px, and too close together
       for the spacing exception, which needs a 24px circle that does not
       reach a neighbour. Padding brings each row to ~45px. Touch tiers only,
       so desktop footers keep their density. */
    .site-footer-col a,
    .onboarding-skip-row a {
        padding: var(--space-3) 0;
        /* Padding alone leaves the skip link at 43px, because its text runs
           19px rather than the footer's 21px. Pin the floor instead. */
        min-height: 44px;
        box-sizing: border-box;
    }

    /* Fields are tapped directly, so the box itself grows rather than a
       pseudo-element; 16px text (change-log #4) already sits inside it. */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="url"],
    input[type="search"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    select,
    textarea {
        min-height: 44px;
    }
}

/* The narrowest phones (320–379px: iPhone SE 1st gen, small Androids). With
   the + gone the row still ran 15–30px past a 320px screen on Home and
   Browse, and squeezed the menu button to 11px. Three trades, none of which
   shrinks a touch target: less topbar padding; Home's Focus button keeps its
   flag but hides its word — visually only, so "Focus" stays its accessible
   name; and the theme toggle moves into the account menu, which is the only
   other place theme can be changed.

   Last in the file on purpose: the 768px block sets .topbar padding at equal
   specificity, and the later rule wins. */
@media (max-width: 379px) {
    .topbar {
        padding: 0 var(--space-2);
    }

    .topbar-actions .theme-toggle {
        display: none;
    }

    .account-menu .account-menu-theme {
        display: block;
    }

    .focus-toggle-label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }
}

.landing-footer-wrap .site-footer {
    padding: 4rem 1.5rem 1.5rem;
}
.landing-footer-wrap .site-footer-grid,
.landing-footer-wrap .site-footer-bottom {
    margin-left: auto;
    margin-right: auto;
}
@media (max-width: 1024px) {
    .landing-footer-wrap .site-footer { padding: 3rem 1.25rem 1.25rem; }
}
@media (max-width: 768px) {
    .landing-footer-wrap .site-footer { padding: 2.5rem 1rem 1rem; }
}
@media (max-width: 480px) {
    .landing-footer-wrap .site-footer { padding: 2rem 0.75rem 1rem; }
}

.site-footer {
    margin-top: auto;
    padding: 4rem var(--space-8) 1.5rem;
    width: 100%;
    box-sizing: border-box;
    border-top: 1px solid var(--surface-border);
}
.site-footer-grid {
    max-width: 1200px;
    display: grid;
    grid-template-columns: repeat(4, auto);
    gap: 1.75rem;
}
.site-footer-brand {
    grid-column: 1 / -1;
}
@media (max-width: 1024px) {
    .site-footer {
        padding: 3rem var(--space-5) 1.25rem;
    }
    .site-footer-grid {
        grid-template-columns: repeat(2, auto);
        gap: 1.25rem;
    }
}
@media (max-width: 768px) {
    .site-footer {
        padding: 2.5rem var(--space-4) 1rem;
    }
    .site-footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1.25rem;
    }
    .site-footer-brand::before { margin-left: 0; margin-right: auto; }
    .site-footer-bottom { flex-direction: column; gap: 0.5rem; text-align: center; }
}
@media (max-width: 480px) {
    .site-footer {
        padding: 2rem var(--space-3) 1rem;
    }
    .site-footer-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .site-footer-col {
        text-align: center;
    }
    .site-footer-dots {
        justify-content: center;
    }
}
.site-footer-brand {
    position: relative;
    padding-top: 0;
}
.site-footer-brand::before {
    content: '';
    display: block;
    width: 4rem;
    height: 2px;
    background: var(--accent);
    box-shadow: none;
    margin-bottom: 1.125rem;
    border-radius: 2px;
}
.site-footer-brand .site-footer-brand-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}
.site-footer-brand-icon {
    font-size: 1.25rem;
    color: var(--accent);
}
.site-footer-brand-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--heading);
}
.site-footer-tagline {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 1rem;
    font-style: italic;
    font-weight: 400;
}
.site-footer-dots {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
}
.site-footer-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    display: inline-block;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.site-footer-dot:hover { opacity: 1; }
.site-footer-dot-mvlempyr { background: #6C63FF; }
.site-footer-dot-royalroad { background: #F4A460; }
.site-footer-dot-scribblehub { background: #FF69B4; }
.site-footer-dot-wuxiaworld { background: #E53935; }
.site-footer-dot-webnovel { background: #FFB300; }
.site-footer-col-title {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--heading);
    margin-bottom: 0.75rem;
    display: block;
    opacity: 0.8;
}
.site-footer-col {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}
.site-footer-col a {
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-decoration: none;
    transition: color 0.15s;
    width: fit-content;
}
.site-footer-col a:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}
.site-footer-bottom {
    max-width: 1200px;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}
.site-footer-bottom-tagline {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-style: italic;
}
.site-footer-bottom-diamond {
    color: var(--accent);
    font-size: 0.5rem;
    opacity: 0.6;
}

.page-hero {
    padding: 4rem 1.5rem 3rem;
    text-align: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.page-hero h1 {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: var(--heading);
}
.page-hero p {
    max-width: 600px;
    margin: 0 auto;
    font-size: 1.125rem;
    color: var(--text-muted);
    line-height: 1.6;
}
.page-body {
    max-width: 800px;
    margin: 0 auto;
    padding: 3rem 1.5rem 5rem;
}
.page-body-wide {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 1.5rem 5rem;
}
/* Both are flex items of main.container, and auto side margins make a flex
   item shrink to fit its content. One unbreakable line (a comparison-table
   row, a three-column grid) then set the width of the whole page: /pricing
   was 881px wide on a 390px phone. A stated width keeps them to the screen. */
.page-body,
.page-body-wide {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.page-body h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--heading);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.page-body h2:first-child { margin-top: 0; }
.page-body h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--heading);
    margin-top: 1.75rem;
    margin-bottom: 0.5rem;
}
.page-body p {
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 1rem;
}
.page-body ul, .page-body ol {
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}
.page-body li { margin-bottom: 0.375rem; }
.page-body strong { color: var(--heading); }
.page-body a { color: var(--accent); }
.page-body a:hover { text-decoration: underline; }
.page-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.75rem 1.25rem;
    margin: 1.25rem 0;
    background: var(--surface);
    border-radius: 0 0.5rem 0.5rem 0;
    color: var(--text-muted);
    font-style: italic;
}
.page-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}
.page-body code {
    background: var(--surface);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    color: var(--accent);
}
.last-updated {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-style: italic;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin: 2rem 0;
}
.pricing-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}
.pricing-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.pricing-card--popular {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(108,99,255,0.15);
}
.pricing-card-accent {
    height: 4px;
}
.pricing-card-accent--free { background: var(--text-muted); }
.pricing-card-accent--pro { background: var(--accent); }
.pricing-card-accent--premium { background: var(--accent-gold); }
.pricing-card-body {
    padding: 1.5rem;
}
.pricing-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.pricing-card-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--heading);
}
.pricing-card-badge {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
}
.pricing-card-price {
    margin: 0.75rem 0 1rem;
}
.pricing-card-amount {
    font-size: 2rem;
    font-weight: 800;
    color: var(--heading);
}
.pricing-card-interval {
    font-size: 0.875rem;
    color: var(--text-muted);
}
.pricing-card-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}
.pricing-card-features {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
}
.pricing-card-feature {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text);
    padding: 0.375rem 0;
}
.pricing-card-feature-icon {
    width: 1rem;
    height: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}
.pricing-card-feature-icon--yes { color: #43A047; }
.pricing-card-feature-icon--no { color: var(--text-muted); opacity: 0.4; }
.pricing-card-cta {
    display: block;
    text-align: center;
    padding: 0.625rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.pricing-card-cta--primary {
    background: var(--accent);
    color: #fff;
}
.pricing-card-cta--primary:hover { opacity: 0.9; }
.pricing-card-cta--outline {
    border: 1px solid var(--border);
    color: var(--text);
}
.pricing-card-cta--outline:hover { border-color: var(--accent); color: var(--accent); }
.pricing-card-cta--current {
    background: var(--surface);
    color: var(--text-muted);
    cursor: default;
    text-align: center;
    padding: 0.625rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
}
.pricing-faq-link {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.9375rem;
}
.pricing-faq-link a { color: var(--accent); }

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin: 2rem 0;
}
.feature-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: border-color 0.2s, transform 0.2s;
}
.feature-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}
.feature-card-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.625rem;
    background: rgba(108,99,255,0.1);
    color: var(--accent);
    font-size: 1.25rem;
    margin-bottom: 1rem;
}
.feature-card h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--heading);
    margin-bottom: 0.5rem;
}
.feature-card p {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
}

.faq-list { margin: 2rem 0; }
.faq-item {
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
    overflow: hidden;
    background: var(--card);
}
.faq-question {
    width: 100%;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    color: var(--heading);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    -webkit-appearance: none;
    appearance: none;
}
.faq-question::-webkit-details-marker { display: none; }
.faq-question::after {
    content: '+';
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}
.faq-item[open] .faq-question::after {
    content: '−';
}
.faq-answer {
    padding: 0 1.25rem 1rem;
    font-size: 0.9375rem;
    color: var(--text);
    line-height: 1.7;
}
.faq-answer p { margin-bottom: 0.5rem; }
.faq-answer p:last-child { margin-bottom: 0; }
.faq-answer a { color: var(--accent); }

.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 2rem 0;
}
.contact-methods {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.contact-method {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.contact-method-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.625rem;
    background: rgba(108,99,255,0.1);
    color: var(--accent);
    font-size: 1.125rem;
    flex-shrink: 0;
}
.contact-method h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--heading);
    margin-bottom: 0.25rem;
}
.contact-method p {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}
.contact-method a { color: var(--accent); }

.about-section {
    margin: 2rem 0;
}
.about-section h2 {
    border-bottom: none;
    margin-top: 0;
}
.about-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin: 2rem 0;
}
.about-stat {
    text-align: center;
    padding: 1.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
}
.about-stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
}
.about-stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.security-item {
    margin-bottom: 2rem;
}
.security-item h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.security-item h3 .sec-icon {
    color: var(--accent);
}

.status-indicators {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin: 2rem 0;
}
.status-indicator {
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: var(--card);
    text-align: center;
}
.status-dot {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    margin-right: 0.5rem;
}
.status-dot--operational { background: #43A047; }
.status-dot--degraded { background: #FFB300; }
.status-dot--down { background: #E53935; }
.status-name {
    font-weight: 600;
    color: var(--heading);
    font-size: 0.9375rem;
}
.status-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

@media (max-width: 768px) {
    .pricing-grid { grid-template-columns: 1fr; }
    .features-grid { grid-template-columns: 1fr; }
    .contact-grid { grid-template-columns: 1fr; }
    .about-stats { grid-template-columns: 1fr; }
    .status-indicators { grid-template-columns: 1fr; }
    .page-hero h1 { font-size: 1.75rem; }
    .page-hero { padding: 2.5rem 1rem 2rem; }
    .page-body { padding: 2rem 1rem 3rem; }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .pricing-grid { grid-template-columns: repeat(2, 1fr); }
    .features-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Pricing: tagline, inline values, and the side-by-side comparison table.
   Added with the pricing rebuild — both surfaces now render one catalog. */
.pricing-card-tagline {
    font-size: var(--body, 0.9375rem);
    color: var(--text-primary, #EEF0F4);
    font-weight: var(--weight-medium, 500);
    margin-bottom: var(--space-1);
}

.pricing-card-feature-value {
    color: var(--text-primary, #EEF0F4);
    font-weight: var(--weight-semibold, 600);
    margin-left: 0.25em;
}

.pricing-card-feature--inherit {
    font-weight: var(--weight-semibold, 600);
    color: var(--text-primary, #EEF0F4);
}

.pricing-compare-wrap {
    margin-top: var(--space-10, 4rem);
}

.pricing-compare-title {
    text-align: center;
    margin-bottom: var(--space-5);
}

/* Wide content scrolls inside its own container so the page body never does. */
.pricing-compare-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pricing-compare {
    width: 100%;
    min-width: 480px;
    border-collapse: collapse;
    font-size: var(--body, 0.9375rem);
}

.pricing-compare th,
.pricing-compare td {
    padding: var(--space-3);
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
    text-align: left;
}

.pricing-compare thead th {
    font-size: var(--caption, 0.8125rem);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #8A93A0);
    font-weight: var(--weight-semibold, 600);
}

.pricing-compare thead th:not(:first-child),
.pricing-compare tbody td {
    text-align: center;
    width: 20%;
}

.pricing-compare tbody th {
    font-weight: var(--weight-medium, 500);
    color: var(--text-primary, #EEF0F4);
}

.pricing-compare-note {
    display: block;
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
    font-weight: var(--weight-regular, 400);
    margin-top: 2px;
}

.pricing-compare-yes {
    color: var(--success, #4FB885);
    font-weight: var(--weight-bold, 700);
}

.pricing-compare-no {
    color: var(--text-dim, #6B7380);
}

.pricing-compare-value {
    color: var(--text-primary, #EEF0F4);
    font-weight: var(--weight-semibold, 600);
}

/* Row labels wrap, so a long note cannot push the plan columns off screen. */
.pricing-compare tbody th,
.pricing-compare-note {
    white-space: normal;
}

@media (max-width: 600px) {
    .pricing-compare { min-width: 0; }
    .pricing-compare th,
    .pricing-compare td { padding: var(--space-2); }
    .pricing-compare thead th:not(:first-child),
    .pricing-compare tbody td { width: 22%; }
}

/* Page-body headings demoted from h1 to h2.
   §4.9 wants exactly one h1 per page and the chrome's topbar title is now it,
   so a destination that also headed its own body carried two. Demoting the
   body heading fixes the outline; this class pins the h1 metrics so the tag
   change is visually identical. Templates whose heading already sets its own
   font-size (browse, wrapped) do not need it. */
.page-heading {
    font-size: var(--heading, 1.5rem);
    margin-bottom: var(--space-2, 0.5rem);
}

/* Tag cloud (spec 11). Sized by usage — sm 1-4, md 5-14, lg 15+ — with the
   count always in text beside the name, because size alone would make the
   information visual-only. */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}

.tag-cloud-item {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    color: var(--text-secondary);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--tag-colour, var(--text-dim));
    border-radius: var(--radius-full);
    text-decoration: none;
    /* No size change on hover: resizing would break the usage signal. */
    transition: color var(--transition), border-color var(--transition);
}

.tag-cloud-item:hover,
.tag-cloud-item:focus-visible {
    color: var(--text-primary);
    border-color: var(--accent-primary);
    border-left-color: var(--tag-colour, var(--text-dim));
}

.tag-cloud-count {
    font-size: var(--xs, var(--caption));
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

.tag-cloud-item.tag-sm .tag-cloud-name { font-size: var(--caption); }
.tag-cloud-item.tag-md .tag-cloud-name { font-size: var(--body); }
.tag-cloud-item.tag-lg .tag-cloud-name {
    font-size: var(--subheading, 1.125rem);
    font-weight: var(--weight-medium);
}

/* The clarifying sentence under a feature on the public pricing cards —
   "never plot summaries" on the AI companion, and so on. It matches
   `.plan-card-feature-note` on the signed-in page: the same catalog note
   renders on both, so it must read the same on both. */
.pricing-card-feature-note {
    display: block;
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
    font-weight: var(--weight-regular, 400);
    margin-top: 2px;
}

/* ===== Plain-language summary on legal pages =====

   Screen spec 25 content rule 1: a plain-language summary before the formal
   text, and the spec names this "the design contribution on these pages — what
   makes a legal page read as trustworthy rather than defensive".

   It was an <aside> with a class no stylesheet defined, and nothing styles
   bare <aside>, so on all five legal pages it rendered as an ordinary
   paragraph indistinguishable from the terms it was meant to precede. The
   requirement was implemented in content and never in appearance. */
.legal-summary {
    margin: 0 0 var(--space-6, 2rem);
    padding: var(--space-4, 1rem) var(--space-5, 1.5rem);
    background: var(--bg-card, #10141B);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-left: 3px solid var(--accent-primary, #4F8FE0);
    border-radius: var(--radius-md, 8px);
    color: var(--text-secondary, #B0B8C4);
}

.legal-summary > :first-child {
    margin-top: 0;
}

.legal-summary > :last-child {
    margin-bottom: 0;
}

/* Extension guide: three steps, then questions (UX audit E2). */
.guide-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-3, 0.75rem);
    margin: 0 0 var(--space-5, 1.25rem);
    padding: 0;
    list-style: none;
}

.guide-step {
    display: flex;
    gap: var(--space-3, 0.75rem);
    padding: var(--space-4, 1rem);
    background: var(--bg-card, #0F1319);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
    border-radius: var(--radius-lg, 12px);
}

.guide-step-num {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    font-weight: var(--weight-bold, 700);
    color: #fff;
    background: var(--accent-primary, #4F8FE0);
    border-radius: 50%;
}

.guide-step-title {
    margin: 0 0 var(--space-1, 0.25rem);
    font-size: var(--body, 0.9375rem);
}

.guide-step p {
    margin: 0;
    font-size: var(--caption, 0.8125rem);
    color: var(--text-muted, #8A93A0);
}

.guide-install {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2, 0.5rem);
    margin-bottom: var(--space-2, 0.5rem);
}

/* The steps are cards, not a prose list or section headings. */
.page-body .guide-steps {
    padding-left: 0;
}

.page-body .guide-step {
    margin-bottom: 0;
}

.page-body .guide-step-title {
    margin: 0 0 var(--space-1, 0.25rem);
    padding: 0;
    border: 0;
    font-size: 1rem;
}

.page-body .guide-step p {
    margin: 0;
    line-height: 1.5;
}

.page-body .guide-install .btn {
    color: inherit;
}

.page-body .guide-install .btn:not(.btn-outline) {
    color: #fff;
}

/* Browser-extension pages: welcome, one-click connect, connected browsers. */

.ext-connect {
    display: flex;
    justify-content: center;
    padding: 48px 16px 64px;
}

.ext-connect-card {
    width: 100%;
    max-width: 520px;
    padding: 32px 28px;
    text-align: center;
}

.ext-connect-card h1 {
    font-family: var(--font-display, Inter, -apple-system, sans-serif);
    font-size: 1.6rem;
    margin: 12px 0 8px;
    color: var(--text-primary, #EEF0F4);
}

.ext-connect-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg, 12px);
    background: linear-gradient(135deg, var(--accent-primary, #4F8FE0), var(--accent-violet, #7C5CBF));
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
}

.ext-connect-lead {
    color: var(--text-secondary, #B0B8C4);
    margin: 0 auto 20px;
    max-width: 42ch;
    line-height: 1.55;
}

.ext-connect-state .spinner {
    margin: 12px auto 0;
}

.ext-connect-field {
    display: block;
    text-align: left;
    margin: 0 auto 16px;
    max-width: 320px;
}

.ext-connect-field span {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted, #8A93A0);
    margin-bottom: 4px;
}

.ext-connect-field input {
    width: 100%;
}

.ext-connect-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.ext-connect-subhead {
    font-size: 0.95rem;
    margin: 28px 0 10px;
    color: var(--text-primary, #EEF0F4);
}

.ext-site-list {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.ext-site-list a {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid var(--surface-border, rgba(255, 255, 255, 0.06));
    border-radius: var(--radius-full, 9999px);
    color: var(--text-secondary, #B0B8C4);
    text-decoration: none;
    font-size: 0.85rem;
}

.ext-site-list a:hover {
    border-color: var(--accent-primary, #4F8FE0);
    color: var(--text-primary, #EEF0F4);
}

/* Settings → Browser extension */
.ext-browser-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 10px;
}

@media (max-width: 480px) {
    .ext-connect { padding-top: 24px; }
    .ext-connect-card { padding: 24px 16px; }
    .ext-connect-card h1 { font-size: 1.35rem; }
}

/* ─── Series Page ─── */

.series-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-6) var(--space-16);
}

/* ─── Hero ─── */
.series-hero {
    display: flex;
    gap: var(--space-8);
    padding: var(--space-8);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--space-4);
    position: relative;
    overflow: hidden;
}

.series-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-xl);
    background: var(--gradient-glow);
    pointer-events: none;
}

.series-hero > * { position: relative; }

.series-hero-cover {
    flex-shrink: 0;
    width: 180px;
}

.series-hero-cover img {
    width: 180px;
    height: 260px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    background: var(--surface-bg);
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
    display: block;
    animation: series-cover-in 1s ease-out forwards;
}

@keyframes series-cover-in {
    0% {
        filter: drop-shadow(0 0 0px rgba(79, 143, 224, 0));
        transform: scale(0.98);
    }
    60% {
        filter: drop-shadow(0 0 24px rgba(79, 143, 224, 0.35));
    }
    100% {
        filter: drop-shadow(0 8px 32px rgba(79, 143, 224, 0.2));
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .series-hero-cover img {
        animation: none;
        filter: drop-shadow(0 8px 32px rgba(79, 143, 224, 0.2));
    }
}

.series-hero-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    flex: 1;
}

.series-hero-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
    color: var(--text-primary);
    margin: 0 0 var(--space-1);
}

.series-hero-author {
    font-size: var(--body);
    color: var(--text-secondary);
    margin: 0 0 var(--space-4);
}

.series-hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.series-hero-meta .series-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0.15rem 0.6rem;
    font-size: var(--xs);
    font-weight: var(--weight-semibold);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    line-height: 1.4;
}

.series-badge-ongoing {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(79, 184, 133, 0.2);
}

.series-badge-completed {
    background: var(--accent-primary-subtle);
    color: var(--accent-primary);
    border: 1px solid rgba(79, 143, 224, 0.2);
}

.series-badge-hiatus {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(244, 184, 96, 0.25);
}

.series-hero-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-3);
    flex-wrap: wrap;
}

/* ─── Stats Obi (signature element) ─── */
.series-obi {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    overflow: hidden;
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow);
}

.series-obi-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-2);
    text-align: center;
    position: relative;
    gap: 0.125rem;
}

.series-obi-item + .series-obi-item {
    border-left: 1px solid var(--border);
}

.series-obi-value {
    font-size: var(--heading);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    font-family: var(--font-display);
    letter-spacing: var(--tracking-tight);
    line-height: 1.1;
}

.series-obi-label {
    font-size: var(--xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    font-weight: var(--weight-medium);
}

.series-obi-item--highlight .series-obi-value {
    color: var(--accent-primary);
}

.series-obi-item--gold .series-obi-value {
    color: var(--accent-gold);
}

.series-obi-item--rating .series-obi-value {
    color: var(--accent-gold);
}

.series-obi-item--trackers .series-obi-value {
    color: var(--accent-primary);
}

/* ─── Content Grid ─── */
.series-content {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: var(--space-6);
    align-items: start;
}

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

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

/* ─── Cards ─── */
.series-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
}

.series-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
}

.series-card-icon {
    width: 1.25rem;
    height: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.series-card-title {
    font-size: var(--title);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin: 0;
}

/* ─── Prediction Strip ─── */
.prediction-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.prediction-stat {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.prediction-stat-label {
    font-size: var(--caption);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    font-weight: var(--weight-medium);
}

.prediction-stat-value {
    font-size: 1rem;
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    font-family: var(--font-display);
    letter-spacing: var(--tracking-tight);
}

.prediction-stat-value--highlight {
    color: var(--accent-primary);
}

.prediction-stat-value--gold {
    color: var(--accent-gold);
}

.prediction-confidence-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-1);
}

.prediction-confidence-track {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.prediction-confidence-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    transition: width var(--transition-smooth);
}

.prediction-confidence-label {
    font-size: var(--xs);
    color: var(--text-muted);
    font-weight: var(--weight-medium);
    min-width: 3rem;
    text-align: right;
}

/* ─── Review Summary ─── */
.review-summary {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.review-stars-large {
    font-size: 1.5rem;
    letter-spacing: 0.1em;
    color: var(--accent-gold);
    line-height: 1;
}

.review-stats {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.review-rating-value {
    font-size: var(--heading);
    font-weight: var(--weight-bold);
    color: var(--text-primary);
    font-family: var(--font-display);
    letter-spacing: var(--tracking-tight);
}

.review-count-label {
    font-size: var(--caption);
    color: var(--text-muted);
}

/* ─── Source List ─── */
.source-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    list-style: none;
    padding: 0;
    margin: 0;
}

.source-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1-5);
    padding: var(--space-2) var(--space-3);
    font-size: var(--caption);
    font-weight: var(--weight-semibold);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all var(--transition);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    background: var(--bg-surface);
}

.source-chip:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-primary-subtle);
    transform: translateY(-1px);
}

.source-chip-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.source-chip-dot--royalroad { background: #F4A460; }
.source-chip-dot--scribblehub { background: #FF69B4; }
.source-chip-dot--wuxiaworld { background: #E53935; }
.source-chip-dot--webnovel { background: #FFB300; }
.source-chip-dot--mvlempyr { background: #6C63FF; }

/* ─── Alias List ─── */
.alias-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.alias-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--surface-bg);
    border-radius: var(--radius-md);
    font-size: var(--body);
    color: var(--text-secondary);
}

.alias-lang {
    font-size: var(--xs);
    color: var(--text-muted);
    background: var(--surface-bg);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    font-weight: var(--weight-medium);
    letter-spacing: var(--tracking-wide);
}

.alias-lang--en { color: var(--accent-primary); }
.alias-lang--zh { color: var(--accent-gold); }
.alias-lang--ja { color: var(--accent-violet); }
.alias-lang--ko { color: var(--success); }

/* ─── CTA Card ─── */
.cta-card {
    text-align: center;
    background: var(--surface-bg);
    border-color: var(--accent-primary-subtle);
}

.cta-card-icon {
    font-size: 2rem;
    margin-bottom: var(--space-2);
    display: block;
    color: var(--accent-primary);
}

.cta-card h3 {
    font-size: var(--title);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin: 0 0 var(--space-1);
}

.cta-card p {
    font-size: var(--body);
    color: var(--text-muted);
    margin: 0 0 var(--space-4);
    line-height: var(--leading-normal);
}

.cta-card .btn {
    width: 100%;
}

/* ─── Sidebar Stats ─── */
.sidebar-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
}

.sidebar-stat + .sidebar-stat {
    border-top: 1px solid var(--border);
}

.sidebar-stat-label {
    font-size: var(--body);
    color: var(--text-secondary);
}

.sidebar-stat-value {
    font-size: var(--body);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    font-family: var(--font-display);
}

/* ─── Chapter History Preview ─── */
.chapter-history-preview {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.chapter-row {
    display: flex;
    justify-content: space-between;
    font-size: var(--caption);
    color: var(--text-muted);
    padding: var(--space-1) 0;
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
    .series-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .series-page {
        padding: var(--space-4) var(--space-4) var(--space-8);
    }

    .series-hero {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: var(--space-6);
    }

    .series-hero-cover {
        width: 140px;
    }

    .series-hero-cover img {
        width: 140px;
        height: 200px;
    }

    .series-hero-meta {
        justify-content: center;
    }

    .series-hero-actions {
        justify-content: center;
    }

    .series-obi {
        flex-wrap: wrap;
    }

    .series-obi-item {
        min-width: 50%;
        flex: 1 0 50%;
    }

    .series-obi-item:nth-child(2) {
        border-left: 1px solid var(--border);
    }

    .series-obi-item:nth-child(3) {
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .series-obi-item:nth-child(4) {
        border-top: 1px solid var(--border);
    }

    .series-hero-title {
        font-size: 1.35rem;
    }

    .prediction-grid {
        grid-template-columns: 1fr;
    }

    .review-summary {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .series-page {
        padding: var(--space-3) var(--space-3) var(--space-6);
    }

    .series-hero {
        padding: var(--space-4);
        gap: var(--space-4);
    }

    .series-hero-cover {
        width: 110px;
    }

    .series-hero-cover img {
        width: 110px;
        height: 158px;
    }
}

/* Public shelf (backlog 18). In the public bundle: it opens signed out. */
.shelf-page { width: 100%; min-width: 0; margin: 0 auto; padding: var(--space-4, 16px); box-sizing: border-box; display: flex; flex-direction: column; gap: var(--space-4, 16px); max-width: 760px; }
.shelf-title { margin: 0; font-size: var(--heading, 1.5rem); }
.shelf-group { padding: var(--space-3, 12px) var(--space-4, 16px); }
.shelf-heading { margin: 0 0 var(--space-1, 4px); font-size: var(--body, 1rem); font-weight: var(--weight-semibold, 600); }
.shelf-list { list-style: none; margin: 0; padding: 0; }
.shelf-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2, 8px) 0;
    border-bottom: 1px solid var(--border-light, rgba(255,255,255,0.03));
    min-width: 0;
    overflow-wrap: anywhere;
}
.shelf-row:last-child { border-bottom: none; }
.shelf-row a { color: var(--text-primary, #EEF0F4); text-decoration: none; font-weight: var(--weight-medium, 500); }
.shelf-row a:hover { text-decoration: underline; }
.shelf-row .text-dim { font-size: var(--caption, 0.8125rem); }
.shelf-cta { margin: 0; }

/* ─── Blog Index ─── */

.blog-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0;
}

.blog-hero {
    padding: var(--space-12) var(--space-6) var(--space-10);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.blog-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-glow);
    pointer-events: none;
}

.blog-hero > * { position: relative; }

.blog-hero-eyebrow {
    font-size: var(--section-eyebrow);
    font-weight: var(--section-eyebrow-weight);
    text-transform: uppercase;
    letter-spacing: var(--section-eyebrow-tracking);
    color: var(--accent-primary);
    margin-bottom: var(--space-2);
    display: block;
}

.blog-hero h1 {
    font-family: var(--font-display);
    font-size: var(--display);
    font-weight: var(--weight-extrabold);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-display);
    color: var(--text-primary);
    margin: 0 0 var(--space-3);
}

.blog-hero p {
    max-width: 560px;
    margin: 0 auto;
    font-size: 1.125rem;
    color: var(--text-muted);
    line-height: var(--leading-relaxed);
}

.blog-body {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 var(--space-6) var(--space-16);
}

/* ─── Blog Grid ─── */
.blog-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-5);
}

.blog-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: all var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.blog-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent-primary);
    opacity: 0.4;
    transition: opacity var(--transition-smooth);
}

.blog-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.blog-card:hover::before {
    opacity: 1;
}

.blog-card-tag-accent::before {
    background: var(--accent-gold);
}

.blog-card-tag-guide::before {
    background: var(--accent-violet);
}

.blog-card-tag-release::before {
    background: var(--success);
}

.blog-card-tag-feature::before {
    background: var(--accent-primary);
}

.blog-card-tag-tips::before {
    background: var(--warning);
}

.blog-card-eyebrow {
    font-size: var(--xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-primary);
    margin-bottom: var(--space-2);
    display: block;
}

.blog-card-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: var(--weight-bold);
    margin: 0 0 var(--space-2);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
}

.blog-card-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color var(--transition);
}

.blog-card-title a:hover {
    color: var(--accent-primary);
}

.blog-card-meta {
    font-size: var(--caption);
    color: var(--text-muted);
    margin: 0 0 var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.blog-card-meta-sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-dim);
}

.blog-card-desc {
    font-size: var(--body);
    line-height: var(--leading-relaxed);
    color: var(--text-secondary);
    margin: 0 0 var(--space-4);
}

.blog-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1-5);
}

.blog-tag {
    display: inline-flex;
    align-items: center;
    font-size: var(--xs);
    font-weight: var(--weight-medium);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    background: var(--bg-surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.blog-tag:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ─── Empty State ─── */
.blog-empty {
    text-align: center;
    padding: var(--space-16) var(--space-6);
}

.blog-empty-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-3);
    display: block;
    color: var(--text-dim);
}

.blog-empty h3 {
    font-size: var(--heading);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin: 0 0 var(--space-2);
}

.blog-empty p {
    color: var(--text-muted);
    margin: 0;
}

/* ─── Pagination ─── */
.blog-pagination {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border);
}

.blog-pagination .btn {
    min-width: 140px;
    justify-content: center;
}

/* ─── Single Post ─── */
.blog-post-hero {
    padding: var(--space-10) var(--space-6) var(--space-8);
    position: relative;
    overflow: hidden;
}

.blog-post-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-glow);
    pointer-events: none;
}

.blog-post-hero > * { position: relative; }

.blog-post-breadcrumb {
    font-size: var(--caption);
    color: var(--text-muted);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-1-5);
}

.blog-post-breadcrumb a {
    color: var(--accent-primary);
    text-decoration: none;
}

.blog-post-breadcrumb a:hover {
    text-decoration: underline;
}

.blog-post-hero h1 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: var(--weight-extrabold);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-display);
    color: var(--text-primary);
    margin: 0 0 var(--space-3);
    max-width: 720px;
}

.blog-post-meta {
    font-size: var(--body);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: 0;
}

.blog-post-meta-sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-dim);
    display: inline-block;
}

.blog-post-body {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 var(--space-6) var(--space-16);
}

.blog-post-body h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-tight);
    color: var(--text-primary);
    margin-top: var(--space-10);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
}

.blog-post-body h3 {
    font-family: var(--font-display);
    font-size: 1.125rem;
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    margin-top: var(--space-8);
    margin-bottom: var(--space-2);
}

.blog-post-body p {
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

.blog-post-body ul,
.blog-post-body ol {
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
    padding-left: var(--space-5);
}

.blog-post-body li { margin-bottom: var(--space-1); }
.blog-post-body strong { color: var(--text-primary); }
.blog-post-body a { color: var(--accent-primary); }
.blog-post-body a:hover { text-decoration: underline; }

.blog-post-body blockquote {
    border-left: 3px solid var(--accent-primary);
    padding: var(--space-4) var(--space-5);
    margin: var(--space-6) 0;
    background: var(--accent-primary-subtle);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.blog-post-body blockquote p:last-child {
    margin-bottom: 0;
}

.blog-post-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-8) 0;
}

.blog-post-body code {
    background: var(--bg-surface);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.875em;
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

.blog-post-body pre {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    overflow-x: auto;
    margin: var(--space-5) 0;
}

.blog-post-body pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
}

.blog-post-footer {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-6) var(--space-10);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
}

.blog-post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1-5);
}

.blog-post-back {
    font-size: var(--body);
    color: var(--accent-primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1-5);
    font-weight: var(--weight-medium);
    transition: color var(--transition);
}

.blog-post-back:hover {
    color: var(--accent-primary-hover);
}

/* ─── Responsive ─── */
@media (min-width: 640px) {
    .blog-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1024px) {
    .blog-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .blog-hero {
        padding: var(--space-8) var(--space-4) var(--space-6);
    }

    .blog-hero h1 {
        font-size: 1.75rem;
    }

    .blog-body {
        padding: 0 var(--space-4) var(--space-8);
    }

    .blog-post-hero {
        padding: var(--space-6) var(--space-4) var(--space-6);
    }

    .blog-post-hero h1 {
        font-size: 1.5rem;
    }

    .blog-post-body {
        padding: 0 var(--space-4) var(--space-8);
    }

    .blog-post-footer {
        padding: var(--space-4) var(--space-4) var(--space-6);
        flex-direction: column;
        text-align: center;
    }

    .blog-pagination .btn {
        min-width: 120px;
        font-size: var(--caption);
    }
}

@media (max-width: 480px) {
    .blog-card {
        padding: var(--space-4);
    }

    .blog-card-title {
        font-size: 1.1rem;
    }
}

/* Series cross-links and signup CTA on a post. Both exist to give a reader
   arriving from search somewhere to go besides the back button. */
.blog-series-links {
    margin: var(--space-8) 0 var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border);
}

.blog-series-links-title,
.blog-cta-title {
    font-size: var(--caption);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: var(--space-3);
}

.blog-series-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-3);
}

.blog-series-card {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-3);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition);
}

.blog-series-card:hover {
    border-color: var(--border-hover);
}

.blog-series-cover {
    width: 44px;
    height: 62px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.blog-series-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.blog-series-name {
    color: var(--text-primary);
    font-weight: 600;
}

.blog-series-author,
.blog-series-count {
    font-size: var(--caption);
    color: var(--text-muted);
}

.blog-cta {
    margin: var(--space-6) 0;
    padding: var(--space-6);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    text-align: center;
}

.blog-cta-text {
    color: var(--text-muted);
    max-width: 44ch;
    margin: 0 auto var(--space-4);
    line-height: 1.6;
}

.blog-cta-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== Accessibility baseline =====
 *
 * Loaded last so it wins over component styles.
 *
 * Two problems this fixes globally rather than file by file:
 *
 * 1. FOCUS VISIBILITY. base.css had a single :focus-visible rule and only 3 of
 *    54 stylesheets referenced focus at all. Every custom-styled interactive
 *    element — tabs, sidebar links, the FAB, mobile nav, tool cards, plan CTAs,
 *    notification-channel cards, agenda items, queue rows — relied on that one
 *    generic rule against wildly varying backgrounds. Keyboard users could not
 *    reliably tell where they were.
 *
 * 2. REDUCED MOTION. prefers-reduced-motion appeared in 7 of 54 files, and not
 *    in the animation-heavy ones: animations.css, dashboard.css, daily-hub.css,
 *    milestones.css, completion.css, onboarding.css. The count-up animations,
 *    the completion ceremony, milestone toasts and page transitions all ignored
 *    the preference entirely.
 *
 * See docs/PRODUCT_UX_AUDIT.md K2a, K2b.
 */

/* ---------- Focus ---------- */

:where(a, button, input, select, textarea, summary, [tabindex], [role="button"],
       [role="tab"], [role="option"], [role="menuitem"]):focus-visible {
    outline: 2px solid var(--accent-primary, #4F8FE0);
    outline-offset: 2px;
    /* A second ring in the page background keeps the outline legible against
       accent-coloured and image backgrounds. */
    box-shadow: 0 0 0 4px var(--bg-primary, #090A0E);
    border-radius: var(--radius-sm, 4px);
}

/* Never remove the ring without replacing it. */
:focus-visible {
    outline-color: var(--accent-primary, #4F8FE0);
}

/* Inputs already carry a border, so an offset ring reads as doubled. */
:where(input, select, textarea):focus-visible {
    outline-offset: 1px;
    box-shadow: 0 0 0 3px var(--accent-primary-subtle, rgba(79, 143, 224, 0.08));
}

/* The skip link must be visible the moment it receives focus. */
.skip-link:focus,
.skip-link:focus-visible {
    position: fixed;
    top: var(--space-2, 0.5rem);
    left: var(--space-2, 0.5rem);
    z-index: 10000;
    width: auto;
    height: auto;
    padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
    clip: auto;
    clip-path: none;
    color: var(--text-primary, #EEF0F4);
    background: var(--bg-surface, #0F1319);
    border: 1px solid var(--accent-primary, #4F8FE0);
    border-radius: var(--radius-md, 8px);
}

/* ---------- Touch targets ---------- */

/* WCAG 2.5.8 asks for 24x24 minimum; 44px is the comfortable mobile figure. */
@media (pointer: coarse) {
    :where(button, a.btn, .btn, .mobile-nav-link, .lib-view-btn, .toast-close,
           .mobile-more-item, .ext-nudge-dismiss) {
        min-height: 44px;
    }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    /* Blanket rule: anything that animates stops, whatever file declared it.
       Not `animation: none` — some components rely on an animation's end state
       for their final layout, so collapse the duration instead and let the
       end state apply immediately. */
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }

    /* Purely decorative motion can go entirely. */
    .ticker-track,
    .hero-diamond,
    .skeleton,
    .live-preview-dot,
    .hero-badge-dot {
        animation: none !important;
    }
}

/* ---------- Contrast ---------- */

/*
 * Measured, not estimated. Ratios below are against the surface each colour is
 * actually used on — --bg-card for cards, --bg-primary for the page.
 *
 * DARK, before:  --text-dim #6B7380 on #0F1319 = 3.89:1  (AA needs 4.5)
 * DARK, after:   --text-dim #7C8593 on #0F1319 = 5.00:1
 *
 * LIGHT was considerably worse, and had escaped notice because the theme is
 * rarely exercised:
 *   --text-dim   #A0A6B0 on #FFFFFF = 2.45:1   badly failing
 *   --text-muted #7A808A on #FFFFFF = 3.98:1   failing
 *
 * Both are used pervasively for captions, metadata, timestamps and helper
 * copy, so this was not an edge case.
 *
 * Scoped per theme deliberately. A single :root override would leak into the
 * light theme — :root and [data-theme="light"] have equal specificity, and
 * this file loads later, so :root would win and leave light at 3.73:1.
 */
:root,
[data-theme="dark"] {
    --text-dim: #7C8593;   /* 5.00:1 on card, 5.31:1 on page */
}

[data-theme="light"] {
    --text-dim: #666D78;   /* 5.22:1 on card, 4.83:1 on page */
    --text-muted: #5F6670; /* 5.80:1 on card */
}

@media (prefers-contrast: more) {
    :root,
    [data-theme="dark"] {
        --text-dim: #9AA3B0;
        --text-muted: #C2C9D4;
        --border: rgba(255, 255, 255, 0.16);
        --border-hover: rgba(255, 255, 255, 0.28);
    }
    [data-theme="light"] {
        --text-dim: #4A505A;
        --text-muted: #3A404A;
        --border: rgba(0, 0, 0, 0.18);
        --border-hover: rgba(0, 0, 0, 0.3);
    }
}

/* ---------- Screen-reader utility ---------- */

.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;
}
