/* ═══════════════════════════════════════════════════════════════════
   StoryCut — Design Token System (Single Source of Truth)

   ALL colors, spacing, radius, shadows, and typography tokens live here.
   The brand colour itself is set in brand.js (repo root) and written into the generated block below by
   scripts/brand-assets.js: to rebrand, change BRAND there and run that script; never type a brand hex here.

   Inspired by Linear / Raycast / Vercel premium design systems.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Brand (generated) ───────────────────────────────────────────── */
/* brand:start: written by scripts/brand-assets.js from brand.js (the ONE place the brand colour is set).
   Do not edit by hand: change BRAND in brand.js, then run `node scripts/brand-assets.js`. */
:root {
    --primary-rgb: 198, 244, 50;
    --sc-primary: #C6F432;
    --sc-primary-hover: #B5E100;
    --sc-primary-active: #A5CE00;
    --sc-primary-glow: #D2FB69;
    --sc-primary-soft: rgba(198, 244, 50, 0.12);
    --sc-primary-soft-hover: rgba(198, 244, 50, 0.18);
    --sc-primary-shadow: rgba(198, 244, 50, 0.25);
    /* text, icons and spinners ON a brand fill (a button, a badge, a dot): ink on lime, never white */
    --sc-on-primary: #0B0B0D;
    --sc-gradient: linear-gradient(135deg, #C6F432, #D2FB69);
    --sc-gradient-hover: linear-gradient(135deg, #B5E100, #CCF74D);
    /* the 10 shades (= the Mantine palette "brand", theme-config.js): 6 = the brand, 7 hover, 8 active */
    --primary-0: #F6FEE8;
    --primary-1: #EEFED0;
    --primary-2: #E4FEAF;
    --primary-3: #DAFD8A;
    --primary-4: #D2FB69;
    --primary-5: #CCF74D;
    --primary-6: #C6F432;
    --primary-7: #B5E100;
    --primary-8: #A5CE00;
    --primary-9: #8CAF00;
}
/* brand-coloured TEXT and thin icons, and focus rings: on light surfaces the brand darkened until it reads 7:1
   (the brand itself is a fill there), on dark surfaces the brand itself */
:root,
[data-mantine-color-scheme="light"] {
    --sc-primary-text: #445600;
    /* thin brand lines (hover borders, underlines, a slider thumb's ring): 3:1, the non-text minimum */
    --sc-primary-line: #769400;
    --sc-focus-ring: #445600;
}
[data-mantine-color-scheme="dark"] {
    --sc-primary-text: #C6F432;
    --sc-primary-line: #C6F432;
    --sc-focus-ring: #C6F432;
}
/* brand:end */

/* ─── Mode-Independent Tokens (Layout) ───────────────────────────── */
:root {
    /* Feedback — SAME in both modes */
    --sc-success: #22C55E;
    --sc-success-soft: rgba(34, 197, 94, 0.12);
    /* the time-limited offer's panel (DealParts.js): black in both themes, lime for what is saved */
    --sc-deal-bg: #0B0B0D;
    --sc-deal-bg-2: #17171C;
    --sc-deal-text: #F5F5F7;
    --sc-deal-muted: rgba(245, 245, 247, 0.72);
    --sc-deal-line: rgba(255, 255, 255, 0.14);
    --sc-deal-border: #0B0B0D;
    --sc-deal-accent: var(--sc-primary);
    --sc-deal-accent-hover: var(--sc-primary-glow);
    --sc-deal-on-accent: var(--sc-on-primary);
    --sc-deal-glow: rgba(var(--primary-rgb), 0.18);
    --sc-error: #EF4444;
    --sc-error-soft: rgba(239, 68, 68, 0.12);
    --sc-warning: #F59E0B;
    --sc-warning-soft: rgba(245, 158, 11, 0.12);

    /* Radius System */
    --sc-radius-xs: 6px;
    --sc-radius-sm: 8px;
    --sc-radius-md: 10px;
    --sc-radius-lg: 12px;
    --sc-radius-xl: 16px;
    --sc-radius-2xl: 20px;
    --sc-radius-full: 999px;

    /* Spacing System (strict multiples) */
    --sc-space-1: 4px;
    --sc-space-2: 8px;
    --sc-space-3: 12px;
    --sc-space-4: 16px;
    --sc-space-6: 24px;
    --sc-space-8: 32px;
    --sc-space-12: 48px;
    --sc-space-16: 64px;

    /* Typography */
    --sc-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
    --sc-font-display: 48px;
    --sc-font-h1: 36px;
    --sc-font-h2: 28px;
    --sc-font-h3: 20px;
    --sc-font-body: 14px;
    --sc-font-small: 12px;

    /* Shadows */
    --sc-shadow-sm: 0px 4px 14px rgba(0, 0, 0, 0.16);
    --sc-shadow-md: 0px 10px 30px rgba(0, 0, 0, 0.25);
    --sc-shadow-glow: 0 0 20px rgba(var(--primary-rgb), 0.25);

    /* On a video frame (project thumbnails: status, length, progress): the same in both modes, the frame is a picture */
    --sc-media-chip-bg: rgba(10, 10, 14, 0.62);
    --sc-media-chip-text: #FFFFFF;
    --sc-media-chip-text-dim: rgba(255, 255, 255, 0.72);
    --sc-media-scrim: rgba(10, 10, 14, 0.78);
    --sc-media-track: rgba(255, 255, 255, 0.24);
    --sc-media-backdrop: #101014;

    /* Component Heights */
    --sc-height-input: 42px;
    --sc-height-topbar: 64px;
    --sc-height-sidebar-item: 40px;
    --sc-height-icon-btn: 36px;
}

/* ─── Light Mode Tokens ───────────────────────────────────────────── */
:root,
[data-mantine-color-scheme="light"] {
    --sc-bg: #FFFFFF;
    --sc-surface: #F6F6F8;
    --sc-surface-hover: #EEEEF2;
    --sc-surface-elevated: #FFFFFF;
    --sc-border: #E4E4E7;
    --sc-border-subtle: rgba(0, 0, 0, 0.06);
    --sc-text: #09090B;
    --sc-text-secondary: #52525B;
    /* Small grey text (notes, terms, captions under titles). #A1A1AA was 2.6:1 on white and unreadable
       (Oct 2026, the upgrade window); #66666F is 5.7:1 on white, 5.3:1 on the brand tints (WCAG AA) */
    --sc-text-muted: #66666F;
    /* Plan comparison tables: included / not included (Oct 2026: the pale check and the half-transparent grey cross
       on pink looked disabled) */
    --sc-mark-yes: #16A34A;
    --sc-mark-yes-soft: rgba(22, 163, 74, 0.12);
    /* the comparison tables' "included" mark: a solid green disc with a white check (the soft one looked faded) */
    --sc-mark-yes-solid: #16A34A;
    --sc-mark-no: #8E8E98;
    --sc-overlay: rgba(0, 0, 0, 0.5);
    --sc-bg-hover: rgba(0, 0, 0, 0.02);
    --sc-bg-active: rgba(0, 0, 0, 0.04);
    --sc-dot-pattern: rgba(0, 0, 0, 0.08);
    --sc-upload-gradient: linear-gradient(135deg, var(--primary-0) 0%, #F6F6F8 60%, #F4F4F6 100%);
    --sc-overlay-btn-bg: rgba(255, 255, 255, 0.9);
    --sc-overlay-btn-text: #09090B;
    --sc-overlay-btn-border: rgba(0, 0, 0, 0.1);
    --sc-overlay-btn-shadow: rgba(0, 0, 0, 0.15);
    --sc-style-preview-bg: #6B6C70;      /* caption style cards: a mid-grey stage, like a video frame: white text 5.2:1,
                                          yellow 3.7:1, and the 44 dark-text styles ~3:1 (a near-black stage hid them: 1.0-1.3:1) */
    --sc-logo-tile-bg: #6B6C70;          /* a brand kit's logo tile (Brand Kits page): mid grey in both themes, so a white
                                          logo and a black one both show */
    --sc-success-text: #15803D;          /* green words on white ("Save 22% with yearly billing"): 5.0:1; #10B981 was 2.5:1 */
    --sc-sidebar-active-bg: rgba(var(--primary-rgb), 0.14);
    --sc-toggle-off: #D4D4D8;
    --sc-input-placeholder: #A1A1AA;
    --sc-timeline-bg: #F3F4F6;
    --sc-timeline-clip: #EEEEF2;
    --sc-timeline-clip-border: #E4E4E7;
    --sc-card-hover-transform: translateY(-2px);
    --sc-scrollbar-thumb: rgba(0, 0, 0, 0.15);
    --sc-scrollbar-thumb-hover: rgba(0, 0, 0, 0.25);
    /* The one raised object of a page (the dashboard's start box), segmented controls on the page background, and a
       neutral focus halo (2026-11-04) */
    --sc-raise-shadow: 0 1px 2px rgba(9, 9, 11, 0.04), 0 12px 32px -14px rgba(9, 9, 11, 0.16);
    --sc-segment-track: rgba(9, 9, 11, 0.05);
    --sc-segment-thumb: #FFFFFF;
    --sc-segment-thumb-shadow: 0 0 0 1px rgba(9, 9, 11, 0.07), 0 1px 3px rgba(9, 9, 11, 0.10);
    --sc-focus-halo: rgba(9, 9, 11, 0.07);
}

/* ─── Dark Mode Tokens ────────────────────────────────────────────── */
[data-mantine-color-scheme="dark"] {
    --sc-bg: #0F0F14;
    --sc-surface: #18181F;
    --sc-surface-hover: #1F1F27;
    --sc-surface-elevated: #1F1F27;
    --sc-border: #26262F;
    --sc-border-subtle: rgba(255, 255, 255, 0.06);
    --sc-text: #F5F5F7;
    --sc-text-secondary: #A1A1AA;
    /* #6B6B75 was 3.3:1 on the dark surface; #8E8E99 is 5.5:1 (WCAG AA) */
    --sc-text-muted: #8E8E99;
    --sc-mark-yes: #4ADE80;
    --sc-mark-yes-soft: rgba(74, 222, 128, 0.14);
    --sc-mark-yes-solid: #22C55E;
    --sc-mark-no: #7C7C86;
    --sc-overlay: rgba(0, 0, 0, 0.6);
    --sc-bg-hover: rgba(255, 255, 255, 0.04);
    --sc-bg-active: rgba(255, 255, 255, 0.07);
    --sc-dot-pattern: rgba(255, 255, 255, 0.06);
    --sc-upload-gradient: linear-gradient(135deg, #1A1D14 0%, #17181A 55%, #141418 100%);
    /* the offer's panel on a dark page: true black, set off by a lime hairline */
    --sc-deal-bg: #000000;
    --sc-deal-bg-2: #101013;
    --sc-deal-border: rgba(var(--primary-rgb), 0.38);
    --sc-overlay-btn-bg: rgba(255, 255, 255, 0.12);
    --sc-overlay-btn-text: rgba(255, 255, 255, 0.9);
    --sc-overlay-btn-border: rgba(255, 255, 255, 0.15);
    --sc-overlay-btn-shadow: rgba(0, 0, 0, 0.3);
    --sc-style-preview-bg: #141418;      /* what dark mode always showed */
    --sc-logo-tile-bg: #5A5B60;          /* a black logo (3.1:1) and a white one (6.9:1) both show on dark surfaces */
    --sc-success-text: #34D399;          /* the same on dark surfaces: 9:1 */
    --sc-sidebar-active-bg: rgba(var(--primary-rgb), 0.12);
    --sc-toggle-off: #26262F;
    --sc-input-placeholder: #6B6B75;
    --sc-timeline-bg: #141419;
    --sc-timeline-clip: #2A2A33;
    --sc-timeline-clip-border: #34343D;
    --sc-card-hover-transform: translateY(-2px);
    --sc-scrollbar-thumb: rgba(255, 255, 255, 0.12);
    --sc-scrollbar-thumb-hover: rgba(255, 255, 255, 0.2);
    --sc-raise-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 14px 36px -14px rgba(0, 0, 0, 0.75);
    --sc-segment-track: rgba(255, 255, 255, 0.05);
    --sc-segment-thumb: #2A2A33;
    --sc-segment-thumb-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 1px 2px rgba(0, 0, 0, 0.45);
    --sc-focus-halo: rgba(255, 255, 255, 0.09);
}

/* ─── Backward-Compat Aliases ───────────────────────────────────────
   Maps old variable names → new tokens so existing CSS keeps working
   while we migrate. Can be removed once migration is complete. */
:root,
[data-mantine-color-scheme="light"] {
    --primary-color: var(--sc-primary);
    --primary-hover: var(--sc-primary-hover);
    --primary-light: var(--sc-primary-soft);
    --primary-light-hover: var(--sc-primary-soft-hover);
    --primary-light-color: var(--sc-primary-text);
    --success-color: var(--sc-success);
    --warning-color: var(--sc-warning);
    --danger-color: var(--sc-error);
    --text-primary: var(--sc-text);
    --text-secondary: var(--sc-text-secondary);
    --text-tertiary: var(--sc-text-muted);
    --bg-primary: var(--sc-bg);
    --bg-secondary: var(--sc-surface);
    --bg-tertiary: var(--sc-surface-hover);
    --border-color: var(--sc-border);
    --border-radius: var(--sc-radius-md);
    --border-radius-lg: var(--sc-radius-lg);
    --border-radius-xl: var(--sc-radius-xl);
    --app-surface: var(--sc-bg);
    --app-surface-alt: var(--sc-surface);
    --app-surface-dim: var(--sc-surface-hover);
    --app-text: var(--sc-text);
    --app-text-secondary: var(--sc-text-secondary);
    --app-text-dimmed: var(--sc-text-muted);
    --app-border: var(--sc-border);
    --app-border-light: var(--sc-border);
    --app-border-subtle: var(--sc-border-subtle);
    --app-border-subtler: var(--sc-border-subtle);
    --app-bg-hover: var(--sc-bg-hover);
    --app-bg-active: var(--sc-bg-active);
    --app-shadow-subtle: rgba(0, 0, 0, 0.06);
    --app-overlay-btn-bg: var(--sc-overlay-btn-bg);
    --app-overlay-btn-text: var(--sc-overlay-btn-text);
    --app-overlay-btn-border: var(--sc-overlay-btn-border);
    --app-overlay-btn-shadow: var(--sc-overlay-btn-shadow);
    --app-style-preview-bg: var(--sc-style-preview-bg);
    --app-logo-tile-bg: var(--sc-logo-tile-bg);
    --app-dot-pattern: var(--sc-dot-pattern);
    --app-upload-gradient: var(--sc-upload-gradient);
}

[data-mantine-color-scheme="dark"] {
    --primary-color: var(--sc-primary);
    --primary-hover: var(--sc-primary-hover);
    --primary-light: var(--sc-primary-soft);
    --primary-light-hover: var(--sc-primary-soft-hover);
    --primary-light-color: var(--sc-primary-text);
    --success-color: var(--sc-success);
    --warning-color: var(--sc-warning);
    --danger-color: var(--sc-error);
    --text-primary: var(--sc-text);
    --text-secondary: var(--sc-text-secondary);
    --text-tertiary: var(--sc-text-muted);
    --bg-primary: var(--sc-bg);
    --bg-secondary: var(--sc-surface);
    --bg-tertiary: var(--sc-surface-hover);
    --border-color: var(--sc-border);
    --app-surface: var(--sc-surface);
    --app-surface-alt: var(--sc-bg);
    --app-surface-dim: var(--sc-surface-hover);
    --app-text: var(--sc-text);
    --app-text-secondary: var(--sc-text-secondary);
    --app-text-dimmed: var(--sc-text-muted);
    --app-border: var(--sc-border);
    --app-border-light: var(--sc-surface-hover);
    --app-border-subtle: var(--sc-border-subtle);
    --app-border-subtler: var(--sc-border-subtle);
    --app-bg-hover: var(--sc-bg-hover);
    --app-bg-active: var(--sc-bg-active);
    --app-shadow-subtle: rgba(0, 0, 0, 0.2);
    --app-overlay-btn-bg: var(--sc-overlay-btn-bg);
    --app-overlay-btn-text: var(--sc-overlay-btn-text);
    --app-overlay-btn-border: var(--sc-overlay-btn-border);
    --app-overlay-btn-shadow: var(--sc-overlay-btn-shadow);
    --app-style-preview-bg: var(--sc-style-preview-bg);
    --app-logo-tile-bg: var(--sc-logo-tile-bg);
    --app-dot-pattern: var(--sc-dot-pattern);
    --app-upload-gradient: var(--sc-upload-gradient);
}

/* Mantine's c="dimmed" text: its default grey (#868E96, 3.3:1 on white) failed contrast like the old muted token.
   Same readable values (html:root beats the provider's own :root[data-mantine-color-scheme] variables) */
html:root[data-mantine-color-scheme="light"] {
    --mantine-color-dimmed: var(--sc-text-muted);
    /* Brand-coloured TEXT on light surfaces (links, c="brand", the light and outline variants' words): the readable
       olive of brand.js, never the lime fill (1.3:1 on white). Fills (filled buttons, badges, bars) keep the lime. */
    --mantine-color-anchor: var(--sc-primary-text);
    --mantine-color-brand-text: var(--sc-primary-text);
    --mantine-color-brand-light-color: var(--sc-primary-text);
    --mantine-color-brand-outline: var(--sc-primary-text);
    --mantine-primary-color-light-color: var(--sc-primary-text);
}
html:root[data-mantine-color-scheme="dark"] {
    --mantine-color-dimmed: var(--sc-text-muted);
}

/* Bottom space bars keep under them: the safe area, or on an iPhone whose toolbars slid away the home indicator's
   area (iOS reports 0 for the safe area then; --sc-chrome-bottom comes from viewportInset.js) */
:root {
    --sc-bottom-inset: max(env(safe-area-inset-bottom, 0px), var(--sc-chrome-bottom, 0px));
}
/* The phone editor: the page can't scroll or bounce, so the browser keeps its toolbars (app.js ProjectEditor) */
html.sc-screen-locked,
html.sc-screen-locked body {
    overflow: hidden;
    overscroll-behavior: none;
}

/* Disable Mantine button scale/translate animation globally */
.mantine-Button-root:hover,
.mantine-Button-root:active {
    transform: none !important;
}

/* Pulse animation for processing status indicators */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Design system — all tokens defined in theme-tokens.css (single source of truth).
   Backward-compatible aliases are provided there. This section only overrides
   Mantine's built-in gray scale for dark mode so existing var(--mantine-color-gray-X)
   references in JS components auto-adapt. */

/* Remap Mantine gray scale in dark mode → premium dark neutrals */
[data-mantine-color-scheme="dark"] {
    --mantine-color-gray-0: #0F0F14;
    --mantine-color-gray-1: #18181F;
    --mantine-color-gray-2: #1F1F27;
    --mantine-color-gray-3: #26262F;
    --mantine-color-gray-4: #26262F;
    --mantine-color-gray-5: #6B6B75;
    --mantine-color-gray-6: #A1A1AA;
    --mantine-color-gray-7: #C4C4CC;
    --mantine-color-gray-8: #E4E4E7;
    --mantine-color-gray-9: #F5F5F7;

    /* Remap Mantine dark scale to new premium palette */
    --mantine-color-dark-0: #F5F5F7;
    --mantine-color-dark-1: #C4C4CC;
    --mantine-color-dark-2: #A1A1AA;
    --mantine-color-dark-3: #6B6B75;
    --mantine-color-dark-4: #26262F;
    --mantine-color-dark-5: #1F1F27;
    --mantine-color-dark-6: #18181F;
    --mantine-color-dark-7: #0F0F14;
    --mantine-color-dark-8: #0A0A0F;
    --mantine-color-dark-9: #050508;
}

/* Fix gray variant text/icon color in dark mode. :root:root outranks Mantine's own dark block, injected after this
   file with the same selector: it set the grey text to gray-1, which index.html inverts to #18181F, so subtle/light
   grey buttons and badges ("Cancel subscription", "All runs") were black on black (mobile audit, 2026-10-28). */
:root:root[data-mantine-color-scheme="dark"] {
    --mantine-color-gray-light-color: #C4C4CC;
    --mantine-color-gray-light-hover: rgba(166, 167, 171, 0.15);
    --mantine-color-gray-filled: #C4C4CC;
    --mantine-color-gray-filled-hover: #E4E4E7;
}

/* Fix ALL ActionIcon/Button gray variants visible in dark mode */
[data-mantine-color-scheme="dark"] .mantine-ActionIcon-root {
    --ai-color: #C4C4CC !important;
    color: #C4C4CC;
}
[data-mantine-color-scheme="dark"] .mantine-ActionIcon-root:hover {
    --ai-hover: rgba(166, 167, 171, 0.15) !important;
    color: #E4E4E7;
    background-color: rgba(166, 167, 171, 0.15);
}
[data-mantine-color-scheme="dark"] .mantine-Button-root[data-variant="default"] {
    color: #C4C4CC;
}

/* Fix Tooltip in dark mode */
[data-mantine-color-scheme="dark"] .mantine-Tooltip-tooltip {
    background-color: #26262F;
    color: #F5F5F7;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

/* Clean spinner in the brand colour (a thin mark: the readable brand text colour, olive on light, lime on dark) */
.spinner {
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top: 2px solid var(--sc-primary-text);
    width: 32px;
    height: 32px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Progress animation */
.progress-animation {
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% {
        width: 0%;
    }

    100% {
        width: 100%;
    }
}

/* Clean focus states with theme color */
*:focus {
    outline: none;
}

input:not([class*="epr_"]):focus,
select:focus,
textarea:focus {
    border-color: var(--sc-focus-ring) !important;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15) !important;
}

/* Form elements — exclude Mantine-managed inputs to avoid double borders */
input[type="text"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]),
input[type="email"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]),
input[type="password"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]),
input[type="number"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]),
select:not([class*="mantine-"]),
textarea:not(.mantine-Textarea-input):not([class*="mantine-"]) {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.15s ease;
}

input[type="text"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]):hover,
input[type="email"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]):hover,
input[type="password"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]):hover,
input[type="number"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]):hover,
select:not([class*="mantine-"]):hover,
textarea:not(.mantine-Textarea-input):not([class*="mantine-"]):hover {
    background-color: var(--bg-secondary);
    border-color: var(--sc-primary-text);
}

/* Buttons — exclude Mantine-managed buttons and emoji picker buttons */
button:not([class*="mantine-"]):not([class*="epr-"]) {
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s ease;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    font-family: inherit;
    border-radius: var(--border-radius);
}

button:not([class*="mantine-"]):not([class*="epr-"]):disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

button:not([class*="mantine-"]):not([class*="epr-"]):hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--sc-primary-text);
}

/* Primary buttons */
.button-primary {
    background-color: var(--primary-color);
    color: var(--sc-on-primary);
    border-color: var(--primary-color);
}

.button-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Secondary buttons */
.button-secondary {
    background-color: var(--primary-0);
    color: var(--sc-primary-text);
    border-color: var(--primary-2);
}

.button-secondary:hover:not(:disabled) {
    background-color: var(--primary-1);
    border-color: var(--primary-3);
}

/* Caption preview - keep text shadow for visibility */
.caption-preview {
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8) !important;
}

/* Animations */
@keyframes pop {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    80% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.animate-pop {
    animation: pop 0.3s ease-out;
    animation-fill-mode: forwards;
}

/* Range slider styles in the brand colour */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--border-color);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 2px solid white;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid white;
    transition: all 0.15s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

/* Video styles */
video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

video:not(.native-player)::-webkit-media-controls {
    background: transparent;
}

/* Vertical videos: use contain in fullscreen so they aren't cropped to landscape */
/* !important needed to override inline objectFit: cover on video elements */
video:fullscreen {
    object-fit: contain !important;
    width: 100% !important;
    height: 100% !important;
}
video:-webkit-full-screen {
    object-fit: contain !important;
    width: 100% !important;
    height: 100% !important;
}
video::-webkit-media-controls-fullscreen-button {
    display: initial;
}

/* Scrollbars — premium subtle */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--sc-scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--sc-scrollbar-thumb-hover);
}

/* Utility classes */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.transition {
    transition-property: background-color, border-color, color, fill, stroke, opacity, transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Font faces */
@font-face {
    font-family: 'Arial Black';
    src: local('Arial Black');
    font-weight: 900;
}

/* Layout utilities */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Card styles */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    transition: all 0.15s ease;
}

.card:hover {
    border-color: var(--sc-primary-text);
}

/* Modal backdrop */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

/* Toggle switch styles in the brand colour */
.toggle-switch {
    position: relative;
    display: inline-flex;
    height: 1.5rem;
    width: 2.75rem;
    cursor: pointer;
    align-items: center;
    border-radius: 9999px;
    transition: background-color 0.2s;
    border: 1px solid var(--border-color);
}

.toggle-switch.checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.toggle-switch:not(.checked) {
    background-color: var(--border-color);
}

.toggle-switch-handle {
    display: inline-block;
    height: 1rem;
    width: 1rem;
    border-radius: 9999px;
    background-color: white;
    transition: transform 0.2s;
}

.toggle-switch.checked .toggle-switch-handle {
    transform: translateX(1.5rem);
}

.toggle-switch:not(.checked) .toggle-switch-handle {
    transform: translateX(0.25rem);
}

/* Color picker styles */
input[type="color"] {
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    padding: 0;
    background: none;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* Badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.badge-primary {
    background-color: var(--primary-0);
    color: var(--sc-primary-text);
    border-color: var(--primary-2);
}

.badge-success {
    background-color: #dcfce7;
    color: #16a34a;
    border-color: #bbf7d0;
}

.badge-warning {
    background-color: #fef3c7;
    color: #d97706;
    border-color: #fde68a;
}

.badge-danger {
    background-color: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

/* Alert styles */
.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.alert-info {
    background-color: var(--primary-0);
    color: var(--sc-primary-text);
    border-color: var(--primary-2);
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Progress bar styles */
.progress-bar {
    width: 100%;
    height: 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

/* Dropdown styles */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    min-width: 200px;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.dropdown-item {
    padding: 0.75rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dropdown-item:hover {
    background-color: var(--primary-0);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding: 0 0.75rem;
    }

    .card {
        padding: 1rem;
    }

    .template-grid-item {
        aspect-ratio: 3/2;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
        color: black;
    }

    .no-print {
        display: none !important;
    }
}

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

/* Custom animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

.animate-slideIn {
    animation: slideIn 0.3s ease-out;
}

/* Template grid styling */
.template-grid-item {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.template-grid-item:hover {
    transform: translateY(-2px);
    border-color: var(--sc-primary-text);
}

.template-grid-item.selected {
    border-color: var(--primary-color);
    border-width: 2px;
}

/* Fieldset styling */
.fieldset {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin: 1rem 0;
}

.fieldset legend {
    padding: 0 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Tab styling */
.tab-list {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.tab-button {
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
}

.tab-button.active {
    border-bottom-color: var(--primary-color);
    color: var(--sc-primary-text);
}

.tab-button:hover {
    background-color: var(--primary-0);
}

/* Premium Button Overrides */
.mantine-Button-root {
    border-radius: var(--sc-radius-md) !important;
    font-weight: 600 !important;
}

.mantine-Button-root[data-size="lg"] {
    border-radius: var(--sc-radius-lg) !important;
    padding: 12px 24px !important;
}

.mantine-Button-root[data-size="xl"] {
    border-radius: var(--sc-radius-xl) !important;
}

/* Badge Styling */
/* Sidebar NavLink — neutral background, the icon in the brand colour when active */
.sidebar-nav-link[data-active] {
    background-color: var(--mantine-color-gray-1) !important;
    color: var(--mantine-color-text) !important;
}
.sidebar-nav-link[data-active] .mantine-NavLink-section {
    color: var(--sc-primary-text) !important;
}
[data-mantine-color-scheme="dark"] .sidebar-nav-link[data-active] {
    background-color: var(--mantine-color-dark-5) !important;
    color: var(--mantine-color-text) !important;
}
[data-mantine-color-scheme="dark"] .sidebar-nav-link[data-active] .mantine-NavLink-section {
    color: var(--primary-color) !important;
}

.mantine-Badge-root {
    font-weight: 500 !important;
}
[data-mantine-color-scheme="dark"] .mantine-Badge-root {
    --badge-color: #fff !important;
    color: #fff !important;
}
[data-mantine-color-scheme="dark"] .mantine-Badge-label {
    color: #fff !important;
}

/* Category filter chips — matches Customize / Create theme button style */
.category-chip {
    border-radius: var(--sc-radius-md);
    background-color: #f8f9fa;
    color: #111827;
    border: 1px solid var(--mantine-color-gray-3);
}
.category-chip:hover {
    background-color: #f3f4f6;
}
.category-chip[data-active] {
    background-color: rgba(var(--primary-rgb), 0.14);
    color: var(--sc-primary-text);
    border-color: var(--sc-primary-text);
}
.category-chip[data-active]:hover {
    background-color: rgba(var(--primary-rgb), 0.2);
    border-color: var(--sc-primary-text);
}

[data-mantine-color-scheme="dark"] .category-chip {
    background-color: #121216 !important;
    color: #d1d5db !important;
    border-color: #1F1F27 !important;
}
[data-mantine-color-scheme="dark"] .category-chip:hover {
    background-color: #18181F !important;
}
[data-mantine-color-scheme="dark"] .category-chip[data-active] {
    background-color: rgba(var(--primary-rgb), 0.15) !important;
    color: #FFFFFF !important;
    border-color: rgba(var(--primary-rgb), 0.4) !important;
}
[data-mantine-color-scheme="dark"] .category-chip[data-active]:hover {
    background-color: rgba(var(--primary-rgb), 0.22) !important;
    border-color: rgba(var(--primary-rgb), 0.5) !important;
}

/* Modal Styling */
.mantine-Modal-content {
    border-radius: var(--sc-radius-xl) !important;
}


/* Paper/Card border — prevents inline hover borders from showing the brand colour */
.mantine-Paper-root {
    border-color: var(--app-border) !important;
}

/* Input Fields */
.mantine-TextInput-input,
.mantine-Select-input,
.mantine-Textarea-input {
    border-radius: var(--sc-radius-md) !important;
    border-color: var(--sc-border) !important;
}

.mantine-TextInput-input:focus,
.mantine-Select-input:focus,
.mantine-Textarea-input:focus {
    border-color: var(--sc-focus-ring) !important;
    box-shadow: 0 0 0 3px var(--sc-primary-soft) !important;
}

/* Progress Bar */
.mantine-Progress-root {
    background-color: var(--app-surface-dim) !important;
}

/* Dark mode styles - triggered by Mantine color scheme toggle */
[data-mantine-color-scheme="dark"] body {
    background-color: #0F0F14;
    color: #F5F5F7;
}

[data-mantine-color-scheme="dark"] .card {
    background: #242424;
    border-color: var(--sc-border);
}

[data-mantine-color-scheme="dark"] .template-grid-item {
    border-color: var(--sc-border);
}

[data-mantine-color-scheme="dark"] .template-grid-item:hover {
    border-color: var(--sc-primary);
}

[data-mantine-color-scheme="dark"] h1,
[data-mantine-color-scheme="dark"] h2,
[data-mantine-color-scheme="dark"] h3,
[data-mantine-color-scheme="dark"] h4,
[data-mantine-color-scheme="dark"] h5,
[data-mantine-color-scheme="dark"] h6 {
    color: #F5F5F7;
}

[data-mantine-color-scheme="dark"] input[type="text"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]),
[data-mantine-color-scheme="dark"] input[type="email"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]),
[data-mantine-color-scheme="dark"] input[type="password"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]),
[data-mantine-color-scheme="dark"] input[type="number"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]),
[data-mantine-color-scheme="dark"] select:not([class*="mantine-"]),
[data-mantine-color-scheme="dark"] textarea:not([class*="mantine-"]) {
    color: #F5F5F7;
    background-color: #18181F;
    border-color: #26262F;
}

[data-mantine-color-scheme="dark"] input[type="text"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]):hover,
[data-mantine-color-scheme="dark"] input[type="email"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]):hover,
[data-mantine-color-scheme="dark"] input[type="password"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]):hover,
[data-mantine-color-scheme="dark"] input[type="number"]:not(.mantine-Input-input):not([class*="mantine-"]):not([class*="epr-"]):not([class*="epr_"]):hover,
[data-mantine-color-scheme="dark"] select:not([class*="mantine-"]):hover,
[data-mantine-color-scheme="dark"] textarea:not([class*="mantine-"]):hover {
    background-color: #1F1F27;
    border-color: var(--sc-primary);
}

[data-mantine-color-scheme="dark"] button:not([class*="mantine-"]):not([class*="epr-"]) {
    border-color: #26262F;
    background: #18181F;
    color: #F5F5F7;
}

[data-mantine-color-scheme="dark"] button:not([class*="mantine-"]):not([class*="epr-"]):hover:not(:disabled) {
    border-color: var(--sc-primary);
}

[data-mantine-color-scheme="dark"] .button-secondary {
    background-color: #18181F;
    color: var(--sc-primary);
    border-color: #26262F;
}

[data-mantine-color-scheme="dark"] .button-secondary:hover:not(:disabled) {
    background-color: #1F1F27;
    border-color: var(--sc-primary);
}

[data-mantine-color-scheme="dark"] .dropdown-menu {
    background: #18181F;
    border-color: #26262F;
    box-shadow: var(--sc-shadow-md);
}

[data-mantine-color-scheme="dark"] .dropdown-item:hover {
    background-color: #1F1F27;
}

[data-mantine-color-scheme="dark"] .badge {
    border-color: #26262F;
}

[data-mantine-color-scheme="dark"] .badge-success {
    background-color: rgba(34, 197, 94, 0.12);
    color: #22C55E;
    border-color: rgba(34, 197, 94, 0.2);
}

[data-mantine-color-scheme="dark"] .badge-warning {
    background-color: rgba(245, 158, 11, 0.12);
    color: #F59E0B;
    border-color: rgba(245, 158, 11, 0.2);
}

[data-mantine-color-scheme="dark"] .badge-danger {
    background-color: rgba(239, 68, 68, 0.12);
    color: #EF4444;
    border-color: rgba(239, 68, 68, 0.2);
}

[data-mantine-color-scheme="dark"] .badge-primary {
    background-color: var(--sc-primary-soft);
    color: var(--sc-primary);
    border-color: rgba(var(--primary-rgb), 0.2);
}

[data-mantine-color-scheme="dark"] .alert {
    border-color: #26262F;
}

[data-mantine-color-scheme="dark"] .alert-info {
    background-color: var(--sc-primary-soft);
    color: var(--sc-primary);
    border-color: rgba(var(--primary-rgb), 0.2);
}

[data-mantine-color-scheme="dark"] .alert-success {
    background-color: rgba(34, 197, 94, 0.12);
    color: #22C55E;
    border-color: rgba(34, 197, 94, 0.2);
}

[data-mantine-color-scheme="dark"] .alert-warning {
    background-color: rgba(245, 158, 11, 0.12);
    color: #F59E0B;
    border-color: rgba(245, 158, 11, 0.2);
}

[data-mantine-color-scheme="dark"] .alert-danger {
    background-color: rgba(239, 68, 68, 0.12);
    color: #EF4444;
    border-color: rgba(239, 68, 68, 0.2);
}

[data-mantine-color-scheme="dark"] .fieldset {
    border-color: #26262F;
}

[data-mantine-color-scheme="dark"] .fieldset legend {
    color: #F5F5F7;
}

[data-mantine-color-scheme="dark"] .tab-list {
    border-bottom-color: #26262F;
}

[data-mantine-color-scheme="dark"] .tab-button:hover {
    background-color: #1F1F27;
}

[data-mantine-color-scheme="dark"] input[type="range"] {
    background: #26262F;
}

[data-mantine-color-scheme="dark"] input[type="range"]::-webkit-slider-thumb {
    border-color: #26262F;
}

[data-mantine-color-scheme="dark"] input[type="range"]::-moz-range-thumb {
    border-color: #26262F;
}

[data-mantine-color-scheme="dark"] ::-webkit-scrollbar-track {
    background: transparent;
}

[data-mantine-color-scheme="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
}

[data-mantine-color-scheme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

[data-mantine-color-scheme="dark"] .toggle-switch:not(.checked) {
    background-color: #26262F;
    border-color: #26262F;
}

[data-mantine-color-scheme="dark"] .toggle-switch {
    border-color: #26262F;
}

[data-mantine-color-scheme="dark"] input[type="color"] {
    border-color: #26262F;
}

[data-mantine-color-scheme="dark"] .modal-backdrop {
    background: rgba(0, 0, 0, 0.6);
}


/* ===== Collapsible Sidebar Transitions ===== */
.mantine-AppShell-navbar {
    transition: width 0.2s ease, min-width 0.2s ease, padding 0.2s ease !important;
}
.mantine-AppShell-main {
    transition: padding-left 0.2s ease !important;
}


/* Compact button styling for header */
.header-tab-button {
    height: 32px !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
    white-space: nowrap;
}

.header-tab-button .mantine-Button-inner {
    gap: 6px !important;
}

.header-tab-button .mantine-Button-section {
    font-size: 12px !important;
}


/* Gold texture animation */
@keyframes goldSheen {
    0%, 100% {
        background-position: 0% 50%;
        filter: contrast(1.1) saturate(1.3) brightness(1.1) drop-shadow(0 2px 4px rgba(139, 69, 19, 0.3));
    }
    25% {
        background-position: 100% 50%;
        filter: contrast(1.15) saturate(1.4) brightness(1.2) drop-shadow(0 3px 6px rgba(139, 69, 19, 0.4));
    }
    50% {
        background-position: 50% 100%;
        filter: contrast(1.2) saturate(1.5) brightness(1.25) drop-shadow(0 4px 8px rgba(139, 69, 19, 0.5));
    }
    75% {
        background-position: 50% 0%;
        filter: contrast(1.15) saturate(1.4) brightness(1.2) drop-shadow(0 3px 6px rgba(139, 69, 19, 0.4));
    }
}


/* ============================================================
   COMPREHENSIVE DARK MODE - INLINE STYLE CSS OVERRIDES
   ============================================================
   Strategy: Override React inline styles using CSS attribute
   selectors + !important. ZERO changes to JS files.

   All colors reference --app-* CSS variables for theme-ability.
   To create a new theme, just redefine --app-* variable values.
   ============================================================ */

/* ---- SECTION A: White & Light Background Overrides ---- */
/* IMPORTANT: .EmojiPickerReact handles its own dark/light theme via JS prop — exclude it */

/* backgroundColor: 'white' → dark surface */
[data-mantine-color-scheme="dark"] [style*="background-color: white"],
[data-mantine-color-scheme="dark"] [style*="background: white"] {
    background-color: #141418 !important;
}

/* backgroundColor: '#fff' / '#ffffff' → rgb(255,255,255) in DOM */
[data-mantine-color-scheme="dark"] [style*="background-color: rgb(255, 255, 255)"],
[data-mantine-color-scheme="dark"] [style*="background: rgb(255, 255, 255)"] {
    background-color: #141418 !important;
}

/* backgroundColor: '#f8f9fa' → rgb(248,249,250) → alt surface */
[data-mantine-color-scheme="dark"] [style*="background-color: rgb(248, 249, 250)"] {
    background-color: var(--app-surface-alt) !important;
}

/* backgroundColor: '#f9fafb' → rgb(249,250,251) → alt surface */
[data-mantine-color-scheme="dark"] [style*="background-color: rgb(249, 250, 251)"] {
    background-color: var(--app-surface-alt) !important;
}

/* backgroundColor: '#fafafa' → rgb(250,250,250) → alt surface */
[data-mantine-color-scheme="dark"] [style*="background-color: rgb(250, 250, 250)"] {
    background-color: var(--app-surface-alt) !important;
}

/* backgroundColor: '#f3f4f6' → rgb(243,244,246) → dim surface */
[data-mantine-color-scheme="dark"] [style*="background-color: rgb(243, 244, 246)"] {
    background-color: var(--app-surface-dim) !important;
}

/* backgroundColor: '#f0f0f0' → rgb(240,240,240) → dim surface */
[data-mantine-color-scheme="dark"] [style*="background-color: rgb(240, 240, 240)"] {
    background-color: var(--app-surface-dim) !important;
}

/* Semi-transparent white backgrounds → premium dark equivalents */
[data-mantine-color-scheme="dark"] [style*="background-color: rgba(255, 255, 255, 0.9)"] {
    background-color: rgba(24, 24, 31, 0.95) !important;
}

[data-mantine-color-scheme="dark"] [style*="background-color: rgba(255, 255, 255, 0.7)"] {
    background-color: rgba(24, 24, 31, 0.85) !important;
}

[data-mantine-color-scheme="dark"] [style*="background-color: rgba(255, 255, 255, 0.5)"] {
    background-color: rgba(24, 24, 31, 0.65) !important;
}

[data-mantine-color-scheme="dark"] [style*="background-color: rgba(255, 255, 255, 0.2)"] {
    background-color: rgba(24, 24, 31, 0.3) !important;
}

[data-mantine-color-scheme="dark"] [style*="background-color: rgba(255, 255, 255, 0.15)"] {
    background-color: rgba(24, 24, 31, 0.25) !important;
}

/* Subtle black bg tints → subtle white tints (hover/active states) */
[data-mantine-color-scheme="dark"] [style*="background-color: rgba(0, 0, 0, 0.02)"] {
    background-color: rgba(255, 255, 255, 0.03) !important;
}

[data-mantine-color-scheme="dark"] [style*="background-color: rgba(0, 0, 0, 0.03)"] {
    background-color: rgba(255, 255, 255, 0.04) !important;
}

[data-mantine-color-scheme="dark"] [style*="background-color: rgba(0, 0, 0, 0.06)"] {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

[data-mantine-color-scheme="dark"] [style*="background-color: rgba(0, 0, 0, 0.1)"] {
    background-color: rgba(255, 255, 255, 0.06) !important;
}

[data-mantine-color-scheme="dark"] [style*="background-color: rgba(0, 0, 0, 0.015)"] {
    background-color: rgba(255, 255, 255, 0.02) !important;
}


/* ---- SECTION B: Dark Text Color Overrides ---- */

/* #111827 → rgb(17,24,39) - primary dark text → light */
[data-mantine-color-scheme="dark"] [style*="color: rgb(17, 24, 39)"] {
    color: var(--app-text) !important;
}

/* #1f2937 → rgb(31,41,55) */
[data-mantine-color-scheme="dark"] [style*="color: rgb(31, 41, 55)"] {
    color: var(--app-text) !important;
}

/* #1F1F1F → rgb(31,31,31) */
[data-mantine-color-scheme="dark"] [style*="color: rgb(31, 31, 31)"] {
    color: var(--app-text) !important;
}

/* #2A2A2A → rgb(42,42,42) */
[data-mantine-color-scheme="dark"] [style*="color: rgb(42, 42, 42)"] {
    color: var(--app-text) !important;
}

/* #374151 → rgb(55,65,81) */
[data-mantine-color-scheme="dark"] [style*="color: rgb(55, 65, 81)"] {
    color: var(--app-text) !important;
}

/* #6b7280 → rgb(107,114,128) - secondary text */
[data-mantine-color-scheme="dark"] [style*="color: rgb(107, 114, 128)"] {
    color: var(--app-text-secondary) !important;
}

/* #9ca3af → rgb(156,163,175) - dimmed text */
[data-mantine-color-scheme="dark"] [style*="color: rgb(156, 163, 175)"] {
    color: var(--app-text-dimmed) !important;
}

/* #868e96 → rgb(134,142,150) - Mantine gray-6 equiv */
[data-mantine-color-scheme="dark"] [style*="color: rgb(134, 142, 150)"] {
    color: var(--app-text-secondary) !important;
}

/* Dark transparent text → light transparent text */
[data-mantine-color-scheme="dark"] [style*="color: rgba(0, 0, 0, 0.6)"] {
    color: rgba(255, 255, 255, 0.7) !important;
}

[data-mantine-color-scheme="dark"] [style*="color: rgba(0, 0, 0, 0.7)"] {
    color: rgba(255, 255, 255, 0.8) !important;
}

[data-mantine-color-scheme="dark"] [style*="color: rgba(0, 0, 0, 0.8)"] {
    color: rgba(255, 255, 255, 0.85) !important;
}

[data-mantine-color-scheme="dark"] [style*="color: rgba(0, 0, 0, 0.5)"] {
    color: rgba(255, 255, 255, 0.6) !important;
}

[data-mantine-color-scheme="dark"] [style*="color: rgba(0, 0, 0, 0.45)"] {
    color: rgba(255, 255, 255, 0.55) !important;
}

/* Dark transparent text (no spaces variant - React source format) */
[data-mantine-color-scheme="dark"] [style*="color: rgba(17, 24, 39, 0.6)"] {
    color: rgba(193, 194, 197, 0.7) !important;
}

[data-mantine-color-scheme="dark"] [style*="color: rgba(31, 41, 55, 0.6)"] {
    color: rgba(193, 194, 197, 0.7) !important;
}


/* ---- SECTION C: Border Color Overrides ---- */

/* All subtle black rgba borders → visible white borders */
/* Catches: rgba(0,0,0, 0.05) through rgba(0,0,0, 0.09) */
[data-mantine-color-scheme="dark"] [style*="solid rgba(0, 0, 0, 0.0"] {
    border-color: var(--app-border-subtle) !important;
}

/* Catches: rgba(0,0,0, 0.1) and rgba(0,0,0, 0.15) */
[data-mantine-color-scheme="dark"] [style*="solid rgba(0, 0, 0, 0.1"] {
    border-color: rgba(255, 255, 255, 0.12) !important;
}

/* Dashed borders with rgba */
[data-mantine-color-scheme="dark"] [style*="dashed rgba(0, 0, 0, 0."] {
    border-color: var(--app-border-subtle) !important;
}

/* #e5e7eb hex borders → rgb(229,231,235) in DOM */
[data-mantine-color-scheme="dark"] [style*="solid rgb(229, 231, 235)"] {
    border-color: var(--app-border) !important;
}

[data-mantine-color-scheme="dark"] [style*="dashed rgb(229, 231, 235)"] {
    border-color: var(--app-border) !important;
}

/* #F3F4F6 borders → rgb(243,244,246) in DOM */
[data-mantine-color-scheme="dark"] [style*="solid rgb(243, 244, 246)"] {
    border-color: var(--app-border-light) !important;
}

/* Colored tinted borders - keep hue but increase opacity for dark mode */
[data-mantine-color-scheme="dark"] [style*="solid rgba(230, 73, 128, 0.2)"] {
    border-color: rgba(230, 73, 128, 0.3) !important;
}

[data-mantine-color-scheme="dark"] [style*="solid rgba(18, 184, 134, 0.2)"] {
    border-color: rgba(18, 184, 134, 0.3) !important;
}

[data-mantine-color-scheme="dark"] [style*="solid rgba(34, 139, 230, 0.2)"] {
    border-color: rgba(34, 139, 230, 0.3) !important;
}


/* ---- SECTION D: Gradient & Special Background Overrides ---- */

/* Upload area pastel gradient → dark equivalent */
[data-mantine-color-scheme="dark"] [style*="linear-gradient(135deg, rgb(255, 245, 242)"] {
    background: var(--app-upload-gradient) !important;
}

/* Dot pattern backgrounds - override the radial-gradient dots */
[data-mantine-color-scheme="dark"] [style*="radial-gradient(rgb(229, 231, 235)"],
[data-mantine-color-scheme="dark"] [style*="radial-gradient(rgba(0, 0, 0"] {
    background-image: radial-gradient(var(--app-dot-pattern) 0.5px, transparent 0.5px) !important;
}

/* Light checkerboard pattern → dark checkerboard (image/logo transparency previews) */
[data-mantine-color-scheme="dark"] [style*="repeating-conic-gradient(rgb(238, 241, 245)"] {
    background: repeating-conic-gradient(#1F1F27 0% 25%, #18181F 0% 50%) 50% / 20px 20px !important;
}

/* Dark mode: Remove watermark text matches TikTok/9:16 pill text color */
[data-mantine-color-scheme="dark"] .watermark-pill-text {
    color: var(--mantine-color-gray-7) !important;
}

/* Light mode style cards: header slightly darker */
[data-mantine-color-scheme="light"] .style-preview-card > [style*="background-color: rgb(243, 244, 246)"] {
    background-color: #ecedf0 !important;
}
[data-mantine-color-scheme="light"] .style-preview-card > [style*="background-color: rgb(232, 233, 236)"] {
    background-color: #e4e5e8 !important;
}

/* Dark mode community/style card: header text + creator badge visible */
[data-mantine-color-scheme="dark"] .style-preview-card [style*="color: rgb(17, 24, 39)"] {
    color: #F5F5F7 !important;
}
[data-mantine-color-scheme="dark"] .style-preview-card .mantine-Badge-root {
    --badge-color: #C4C4CC !important;
    color: #C4C4CC !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Dark mode style cards: header, selected header, preview */
[data-mantine-color-scheme="dark"] .style-preview-card > [style*="background-color: rgb(243, 244, 246)"] {
    background-color: #1F1F27 !important;
}
[data-mantine-color-scheme="dark"] .style-preview-card > [style*="background-color: rgb(232, 233, 236)"] {
    background-color: #26262F !important;
}
/* Dark mode override: caption style preview card background (the preview area showing sample caption text) */
[data-mantine-color-scheme="dark"] .style-preview-card > [style*="background: rgb(107, 108, 112)"] {
    background: #141418 !important;
}

/* Dark mode style cards: footer (description/tags area) */
[data-mantine-color-scheme="dark"] .style-preview-card .community-card-footer {
    background-color: #1F1F27 !important;
}
[data-mantine-color-scheme="dark"] .style-preview-card .community-card-footer .mantine-Text-root {
    color: #A1A1AA !important;
}

/* Light mode style cards: footer matches header */
[data-mantine-color-scheme="light"] .style-preview-card .community-card-footer {
    background-color: #ecedf0 !important;
}

/* Semi-transparent white gradient overlays → premium dark equivalents */
[data-mantine-color-scheme="dark"] [style*="linear-gradient(160deg, rgba(255, 255, 255, 0.95)"] {
    background: linear-gradient(160deg, rgba(24, 24, 31, 0.95) 0%, rgba(15, 15, 20, 0.9) 40%, rgba(24, 24, 31, 0.85) 100%) !important;
}

/* Fade-to-background gradients */
[data-mantine-color-scheme="dark"] [style*="linear-gradient(to right, transparent, rgba(249, 250, 251"] {
    background: linear-gradient(to right, transparent, rgba(15, 15, 20, 0.95)) !important;
}

/* Subtle accent-tinted gradients - boost opacity for dark mode visibility */
[data-mantine-color-scheme="dark"] [style*="linear-gradient(90deg, rgba(21, 170, 191, 0.08)"] {
    background: linear-gradient(90deg, rgba(21, 170, 191, 0.12) 0%, rgba(18, 184, 134, 0.15) 100%) !important;
}

[data-mantine-color-scheme="dark"] [style*="linear-gradient(90deg, rgba(18, 184, 134, 0.08)"] {
    background: linear-gradient(90deg, rgba(18, 184, 134, 0.12) 0%, rgba(21, 170, 191, 0.15) 100%) !important;
}

[data-mantine-color-scheme="dark"] [style*="linear-gradient(90deg, rgba(34, 139, 230, 0.08)"] {
    background: linear-gradient(90deg, rgba(34, 139, 230, 0.12) 0%, rgba(21, 170, 191, 0.15) 100%) !important;
}

/* White radial glow overlays → remove in dark mode */
[data-mantine-color-scheme="dark"] [style*="radial-gradient(600px 300px"] {
    background: none !important;
}

[data-mantine-color-scheme="dark"] [style*="radial-gradient(500px 250px"] {
    background: none !important;
}

[data-mantine-color-scheme="dark"] [style*="radial-gradient(400px 200px"] {
    background: none !important;
}

/* Semi-transparent white-to-transparent gradient → dark equivalent */
[data-mantine-color-scheme="dark"] [style*="linear-gradient(135deg, rgba(255, 255, 255, 0.9)"] {
    background: linear-gradient(135deg, rgba(24, 24, 31, 0.9), rgba(15, 15, 20, 0.8)) !important;
}


/* ---- SECTION E: Box Shadow Enhancements ---- */

/* Make subtle light-mode shadows more visible on dark backgrounds */
[data-mantine-color-scheme="dark"] [style*="box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05)"] {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

[data-mantine-color-scheme="dark"] [style*="box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1)"] {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35) !important;
}

[data-mantine-color-scheme="dark"] [style*="box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06)"] {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

[data-mantine-color-scheme="dark"] [style*="box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1)"] {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35) !important;
}

[data-mantine-color-scheme="dark"] [style*="box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1)"] {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35) !important;
}

/* Inset shadows (used as subtle borders) → invert to white */
[data-mantine-color-scheme="dark"] [style*="inset 0 0 0 1px rgba(0, 0, 0, 0.06)"] {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1) !important;
}


/* ---- SECTION F: Additional Element Overrides ---- */

/* Ensure inputs have proper dark mode borders */
[data-mantine-color-scheme="dark"] .mantine-TextInput-input,
[data-mantine-color-scheme="dark"] .mantine-Select-input,
[data-mantine-color-scheme="dark"] .mantine-Textarea-input,
[data-mantine-color-scheme="dark"] .mantine-NumberInput-input,
[data-mantine-color-scheme="dark"] .mantine-PasswordInput-input,
[data-mantine-color-scheme="dark"] .mantine-JsonInput-input {
    border-color: #26262F !important;
}

/* Focus state for inputs — a glow in the brand colour */
[data-mantine-color-scheme="dark"] .mantine-TextInput-input:focus,
[data-mantine-color-scheme="dark"] .mantine-Select-input:focus,
[data-mantine-color-scheme="dark"] .mantine-Textarea-input:focus,
[data-mantine-color-scheme="dark"] .mantine-NumberInput-input:focus,
[data-mantine-color-scheme="dark"] .mantine-PasswordInput-input:focus {
    border-color: var(--sc-primary) !important;
    box-shadow: 0 0 0 3px var(--sc-primary-soft) !important;
}

/* Progress bar track in dark mode */
[data-mantine-color-scheme="dark"] .mantine-Progress-root {
    background-color: #1F1F27 !important;
}

/* Gradient variant buttons & theme icons - ensure gradient displays in dark mode.
   Mantine's internal background: var(--button-bg) can be overridden by browser
   dark color-scheme defaults. Re-assert with !important to guarantee visibility. */
[data-mantine-color-scheme="dark"] .mantine-Button-root[data-variant="gradient"] {
    background: var(--button-bg) !important;
    color: var(--button-color, var(--mantine-color-white)) !important;
}

[data-mantine-color-scheme="dark"] .mantine-ThemeIcon-root[data-variant="gradient"] {
    background: var(--ti-bg) !important;
}

/* AI enhancement panels (Sound FX, Remove Silence, Clean Audio, Eye Contact, Zoom)
   use 2px solid border + cursor pointer. In dark mode, make background transparent
   so they blend with the parent - border alone provides visual separation. */
[data-mantine-color-scheme="dark"] .mantine-Paper-root[style*="cursor: pointer"][style*="2px solid"] {
    background: transparent !important;
}

/* ---- Emoji Picker Styling ---- */
/* Base: remove border/shadow when embedded in popover */
.EmojiPickerReact {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}
.EmojiPickerReact .epr-search-container {
    margin: 4px 8px !important;
}
/* Category nav: tighter spacing, subtle hover */
.EmojiPickerReact .epr-category-nav {
    padding: 4px 8px !important;
    gap: 2px;
}
.EmojiPickerReact .epr-cat-btn {
    border-radius: 8px !important;
    opacity: 0.5;
    transition: all 0.15s ease !important;
}
.EmojiPickerReact .epr-cat-btn:hover {
    opacity: 0.8;
    background-color: rgba(0,0,0,0.05);
}
.EmojiPickerReact .epr-cat-btn.epr-active {
    opacity: 1;
}
/* Category labels */
.EmojiPickerReact .epr-emoji-category-label {
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    padding: 6px 8px !important;
}
/* Search input — cosmetic tweaks */
.EmojiPickerReact input {
    border-radius: 8px !important;
    font-size: 13px !important;
}
/* Emoji buttons: subtle hover */
.EmojiPickerReact .epr-emoji-category-content button.epr-btn {
    border-radius: 8px !important;
    transition: transform 0.1s ease !important;
}
.EmojiPickerReact .epr-emoji-category-content button.epr-btn:hover {
    transform: scale(1.15);
}
/* Dark mode adjustments */
[data-mantine-color-scheme="dark"] .EmojiPickerReact .epr-cat-btn:hover {
    background-color: rgba(255,255,255,0.08);
}

/* ============================================================
   MOBILE EDITOR REDESIGN
   All styles scoped to max-width: 768px so desktop is untouched.
   ============================================================ */

@media (max-width: 768px) {

    .mobile-export-btn.mantine-Button-root,
    .mobile-header-btn.mantine-Button-root {
        border-radius: 6px !important;
    }

    .mobile-download-btn.mantine-Button-root {
        border-radius: 6px !important;
        height: 28px !important;
        padding: 0 8px !important;
        font-size: 11px !important;
        font-weight: 600 !important;
    }

    /* --- Bottom Tab Bar --- */
    .mobile-bottom-tab-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(56px + var(--sc-bottom-inset, 0px));
        padding-bottom: var(--sc-bottom-inset, 0px);
        background: var(--app-surface, #ffffff);
        border-top: 1px solid var(--app-border, #e5e7eb);
        display: flex;
        align-items: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        z-index: 100;
        gap: 0;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .mobile-bottom-tab-bar::-webkit-scrollbar {
        display: none;
    }

    .mobile-tab-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 64px;
        height: 56px;
        padding: 6px 10px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.15s ease, opacity 0.15s ease;
        flex-shrink: 0;
        user-select: none;
        position: relative;
    }
    .mobile-tab-item:active {
        transform: scale(0.92);
    }
    /* Narrow phones: 5.5 tabs across, so half a tab always shows that the row scrolls. At 390 px the 8 × 64 px tabs
       ended exactly after Brand and Thumbnail / Adjust looked missing (mobile audit, 2026-10-28) */
    @media (max-width: 480px) {
        .mobile-tab-item {
            min-width: 0;
            flex: 0 0 calc(100% / 5.5);
            padding: 6px 4px;
        }
    }

    .mobile-tab-icon {
        font-size: 18px;
        color: var(--mantine-color-gray-6, #9ca3af);
        transition: color 0.2s ease;
    }
    .mobile-tab-item.active .mobile-tab-icon {
        color: var(--sc-primary-text);
    }

    .mobile-tab-label {
        font-size: 10px;
        font-weight: 500;
        color: var(--mantine-color-gray-6, #9ca3af);
        white-space: nowrap;
        transition: color 0.2s ease;
    }
    .mobile-tab-item.active .mobile-tab-label {
        color: var(--sc-primary-text);
        font-weight: 600;
    }

    .mobile-tab-item.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 24px;
        height: 2px;
        border-radius: 0 0 2px 2px;
        background: var(--sc-primary-text);
    }

    /* --- Bottom Sheet --- */
    .mobile-sheet-backdrop {
        position: fixed;
        inset: 0;
        z-index: 999;
        background-color: rgba(0, 0, 0, 0.4);
        animation: mobileSheetFadeIn 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-sheet-container {
        position: fixed;
        z-index: 1000;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: var(--app-surface, #ffffff);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: column;
        animation: mobileSheetSlideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
        padding-bottom: var(--sc-bottom-inset, 0px);
    }

    .mobile-sheet-handle {
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: var(--mantine-color-gray-4, #d1d5db);
        margin: 8px auto 4px;
        flex-shrink: 0;
    }

    .mobile-sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 16px 10px;
        border-bottom: 1px solid var(--app-border, #e5e7eb);
        flex-shrink: 0;
    }

    .mobile-sheet-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0;

        /* Compact sizing: override Mantine CSS variables for tighter mobile layout */
        --mantine-font-size-xs: 0.6875rem;  /* 11px instead of 12px */
        --mantine-font-size-sm: 0.75rem;     /* 12px instead of 14px */
        --mantine-font-size-md: 0.8125rem;   /* 13px instead of 16px */
        --mantine-font-size-lg: 0.875rem;    /* 14px instead of 18px */
    }

    /* Override inline font-size on section titles */
    .mobile-sheet-body .mantine-Title-root {
        font-size: 13px !important;
        line-height: 1.3;
    }

    /* Tighter section headers: icons smaller */
    .mobile-sheet-body .mantine-Group-root > .fas,
    .mobile-sheet-body .mantine-Group-root > .fab,
    .mobile-sheet-body .mantine-Group-root > i.fas,
    .mobile-sheet-body .mantine-Group-root > i.fab {
        font-size: 13px !important;
    }

    /* ThemeIcon compact */
    .mobile-sheet-body .mantine-ThemeIcon-root[data-size="md"] {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
        min-height: 26px !important;
    }
    .mobile-sheet-body .mantine-ThemeIcon-root .fas {
        font-size: 11px !important;
    }

    /* Dividers: no extra margin (let parent Stack gap handle spacing) */
    .mobile-sheet-body .mantine-Divider-root {
        margin-top: 0;
        margin-bottom: 0;
    }

    /* Paper sections: tighter padding */
    .mobile-sheet-body .mantine-Paper-root[data-with-border] {
        padding: 6px 8px !important;
    }

    /* Collapse panels: tighter inner Paper */
    .mobile-sheet-body .mantine-Collapse-root .mantine-Paper-root {
        padding: 8px !important;
    }

    /* Button compact on mobile */
    .mobile-sheet-body .mantine-Button-root {
        font-size: 12px;
        height: 30px;
        padding-left: 10px;
        padding-right: 10px;
    }

    /* --- Mobile Video Container --- */
    .mobile-video-container {
        height: calc(100vh - 48px - 56px - var(--sc-bottom-inset, 0px));
        height: calc(100dvh - 48px - 56px - var(--sc-bottom-inset, 0px));
        display: flex;
        flex-direction: column;
        overflow: hidden;
        position: relative;
        transition: height 0.3s ease;
    }

    /* --- Sticky Export bar (bottom-most, under the thumb) --- */
    .mobile-action-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 101;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px calc(8px + var(--sc-bottom-inset, 0px));
        background: var(--app-surface);
        border-top: 1px solid var(--app-border);
    }
    .mobile-action-bar .mantine-Button-root {
        height: 48px;
        border-radius: 12px;
        font-size: 16px;
        font-weight: 700;
    }
    .mobile-action-bar .mobile-action-primary {
        flex: 1;
        border: none;
        color: var(--sc-on-primary);
        background: var(--sc-primary);
        box-shadow: 0 4px 14px var(--sc-primary-shadow);
    }
    .mobile-action-bar .mobile-action-primary.mobile-action-success {
        background: var(--sc-success);
        color: var(--mantine-color-white);
        box-shadow: none;
    }
    /* Export progress fills the button */
    .mobile-action-bar .mobile-action-primary.is-exporting {
        background: linear-gradient(90deg, var(--primary-color) var(--export-progress, 0%), var(--primary-1) var(--export-progress, 0%));
    }
    .mobile-action-bar .mobile-action-primary[data-disabled] {
        background: var(--app-surface-alt);
        color: var(--app-text-dimmed);
        box-shadow: none;
    }
    /* Auto Edit: the first action on phones, next to Export. A plain secondary button (owner, 2026-10-29: the purple
       outline + sparkle wand "looks AI-made"): hairline border, text colour, a line icon; Export stays the one brand-coloured button */
    .mobile-action-bar .mobile-action-autoedit {
        flex: 0 0 auto;
        font-size: 15px;
        font-weight: 600;
        padding: 0 16px;
        background: var(--app-surface);
        border: 1px solid var(--app-border);
        color: var(--app-text);
    }
    .mobile-action-bar .mobile-action-autoedit:active { background: var(--app-bg-hover); }
    .mobile-action-bar .mobile-action-secondary {
        flex: 0 0 auto;
        font-size: 14px;
        padding: 0 14px;
    }
    /* The tab bar sits on top of the Export bar */
    .mobile-bottom-tab-bar.with-action-bar {
        bottom: calc(64px + var(--sc-bottom-inset, 0px));
        height: 56px;
        padding-bottom: 0;
    }
    .mobile-video-container.with-action-bar {
        height: calc(100vh - 48px - 56px - 64px - var(--sc-bottom-inset, 0px));
        height: calc(100dvh - 48px - 56px - 64px - var(--sc-bottom-inset, 0px));
    }
    /* Export sheet keeps normal-size controls (the generic sheet compacts buttons to 30px) */
    .mobile-sheet-body .export-sheet .mantine-Button-root.export-sheet-primary {
        height: 48px;
        font-size: 16px;
        border-radius: 12px;
    }
    .mobile-sheet-body .export-sheet .mantine-Button-root {
        height: 40px;
        font-size: 14px;
    }

    /* Shrink video to top half when Caption Style sheet is open */
    /* Caption Style sheet open: the player gives up its chips row (TikTok / Safe zone / 9:16) and 8% of the screen,
       so the sheet shows more than one row of styles on a small iPhone (one row and a bit at 393 × 661, 2026-10-28) */
    .mobile-video-container.video-compact {
        height: calc(42vh - 48px);
        height: calc(42dvh - 48px);
    }
    .mobile-video-container.video-compact .sc-player-chips {
        display: none !important;
    }

    .mobile-video-area {
        flex: 1;
        min-height: 0;
        display: flex;
        align-items: stretch;
        justify-content: center;
        padding: 0;
        overflow: hidden;
    }

    .mobile-playback-bar {
        height: 44px;
        padding: 0 12px;
        display: flex;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
        border-top: 1px solid var(--app-border, #e5e7eb);
        background: var(--app-surface, #ffffff);
    }

    /* --- Animations --- */
    @keyframes mobileSheetSlideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    @keyframes mobileSheetFadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
}

/* Dark mode for mobile editor */
@media (max-width: 768px) {
    [data-mantine-color-scheme="dark"] .mobile-bottom-tab-bar {
        background: var(--app-surface, var(--mantine-color-dark-7));
        border-top-color: var(--app-border, var(--mantine-color-dark-4));
    }
    [data-mantine-color-scheme="dark"] .mobile-tab-icon,
    [data-mantine-color-scheme="dark"] .mobile-tab-label {
        color: var(--mantine-color-dark-2, #909296);
    }
    [data-mantine-color-scheme="dark"] .mobile-tab-item.active .mobile-tab-icon,
    [data-mantine-color-scheme="dark"] .mobile-tab-item.active .mobile-tab-label {
        color: var(--sc-primary);
    }
    [data-mantine-color-scheme="dark"] .mobile-sheet-container {
        background-color: var(--app-surface, var(--mantine-color-dark-7));
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.4);
    }
    [data-mantine-color-scheme="dark"] .mobile-sheet-handle {
        background: var(--mantine-color-dark-3, #5c5f66);
    }
    [data-mantine-color-scheme="dark"] .mobile-sheet-header {
        border-bottom-color: var(--app-border, var(--mantine-color-dark-4));
    }
    [data-mantine-color-scheme="dark"] .mobile-playback-bar {
        background: var(--app-surface, var(--mantine-color-dark-7));
        border-top-color: var(--app-border, var(--mantine-color-dark-4));
    }

    /* --- All popovers/menus inside sheets → bottom sheet on mobile --- */
    .mobile-popover-sheet {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15) !important;
        padding: 16px !important;
        padding-bottom: calc(16px + var(--sc-bottom-inset, 0px)) !important;
        animation: mobileSheetSlideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    }
}

/* Side-by-side illustration layout */
.illust-side-by-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: center;
    padding-top: 40px;
}
@media (max-width: 768px) {
    .illust-side-by-side {
        grid-template-columns: 1fr;
        gap: 28px;
    }
    .illust-side-by-side > div:first-child {
        text-align: center !important;
    }
}


/* AI Clips results: the "make this preview" button grows a little on hover (DashboardPages.js ClipPreviewOverlay) */
@media (hover: hover) {
    button:hover > .sc-preview-make { transform: scale(1.06); background: rgba(var(--primary-rgb), 0.72) !important; }
    button:hover > .sc-lock-disc { transform: scale(1.06); }
}

/* Export panel: the "every video, no watermark" row of the watermark offer (app.js ExportPanel) */
.sc-wm-plan-row { transition: background-color 140ms ease; }
@media (hover: hover) {
    .sc-wm-plan-row:hover { background: rgba(var(--primary-rgb), 0.08) !important; }
}

/* Upgrade window: the option that isn't chosen shows it can be picked (UpgradeModal.js ChoiceCard) */
@media (hover: hover) {
    .sc-choice-card[aria-checked="false"]:hover { border-color: var(--app-text-secondary) !important; }
}

/* Pro look shared by the editor's windows (Auto Edit, Edit style...): the dark ink primary button, inverted per theme
   (Mantine color="dark" is dark on dark in dark mode), and an ink switch (owner, 2026-11-02: "icons black, minimum purple") */
.sc-btn-primary { background: var(--app-text) !important; color: var(--app-surface) !important; border: 0 !important; }
.sc-btn-primary:hover { opacity: .88; }
.sc-btn-primary[data-disabled], .sc-btn-primary:disabled { opacity: .35; cursor: not-allowed; }
.sc-btn-primary .mantine-Button-loader { color: var(--app-surface); }
.sc-ink-switch .mantine-Switch-input:checked + .mantine-Switch-track { background: var(--app-text); border-color: var(--app-text); }
.sc-ink-switch .mantine-Switch-input:checked + .mantine-Switch-track .mantine-Switch-thumb { background: var(--app-surface); border-color: var(--app-surface); }
/* Ink chips (edit style groups): the picked one is solid ink, not the brand colour; no check mark (it shifts the label) */
.sc-ink-chip .mantine-Chip-label { color: var(--app-text-secondary); border-color: var(--app-border); background: transparent; }
.sc-ink-chip .mantine-Chip-label[data-checked] { background: var(--app-text); border-color: var(--app-text); color: var(--app-surface); padding-left: calc(var(--chip-padding, 12px)); }
.sc-ink-chip .mantine-Chip-iconWrapper { display: none; }
/* A window's or sheet's header icon: ink line icon on a hairline tile (frontend/editor/editorPanelCss.js .sc-ep-tile is
   the same). Replaced the purple→pink gradient tiles with white icons (owner, 2026-11-04: "pro grade") */
.sc-head-tile { width: 30px; height: 30px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
  border: 1px solid var(--app-border); color: var(--app-text); background: transparent; }

/* Custom Video Player Styles */
.video-fullscreen-wrapper {
    transition: all 0.3s ease;
}


/* Container queries for responsive captions */
@container (max-width: 400px) {
    .caption-overlay {
        font-size: 0.8em;
    }
}

@container (min-width: 401px) and (max-width: 600px) {
    .caption-overlay {
        font-size: 0.9em;
    }
}

/* Caption overlay */
.caption-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    container-type: size;
    contain: layout style paint;
}


/* Fullscreen mode — JS handles sizing via inline styles (aspect-ratio-aware).
   Only keep caption overlay containment here. */
.video-fullscreen-wrapper[data-fullscreen="true"] .caption-overlay {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    overflow: hidden !important;
}

/* Webkit fullscreen — caption overlay containment */
.video-fullscreen-wrapper:-webkit-full-screen .caption-overlay {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    overflow: hidden !important;
}
