/* ============================================
   Useful Tool Hub - Design System
   Modern dark theme with glassmorphism & gradients
   ============================================ */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================
   Design tokens

   Hues are stored as bare RGB CHANNELS, not colours, so a tint can be written
   `rgb(var(--primary-rgb) / 0.08)` and still follow the theme. Forty-odd
   hardcoded `rgba(99, 102, 241, …)` literals used to be scattered through this
   file, which is why light mode was impossible without touching all of them.

   Everything below the channel block is semantic: rules should ask for
   --bg-surface or --text-muted, never for a raw colour. [data-theme="light"]
   then only has to restate the semantic layer.
   ============================================ */

:root {
    color-scheme: dark;

    /* Hue channels. Shared by both themes. */
    --primary-rgb: 99 102 241;
    --primary-light-rgb: 129 140 248;
    --primary-dark-rgb: 79 70 229;
    --accent-rgb: 6 182 212;
    --accent-light-rgb: 34 211 238;
    --success-rgb: 34 197 94;
    --error-rgb: 239 68 68;
    --warning-rgb: 245 158 11;

    /* Core palette */
    --primary: rgb(var(--primary-rgb));
    --primary-light: rgb(var(--primary-light-rgb));
    --primary-dark: rgb(var(--primary-dark-rgb));
    --primary-glow: rgb(var(--primary-rgb) / 0.15);
    /* The brand colour when used as TEXT. --primary-light is tuned for a dark
       surface and falls to ~3:1 on white, so the light theme darkens it. */
    --primary-readable: var(--primary-light);
    --accent-readable: var(--accent-light);
    --accent: rgb(var(--accent-rgb));
    --accent-light: rgb(var(--accent-light-rgb));

    /* Surfaces */
    --bg-base: #09090b;
    --bg-surface: #18181b;
    --bg-elevated: #27272a;
    --bg-glass: rgb(24 24 27 / 0.7);

    /* Text */
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    /* Text sitting on a filled --primary button. */
    --text-on-primary: #ffffff;

    /* Borders */
    --border: rgb(63 63 70 / 0.5);
    --border-hover: rgb(var(--primary-rgb) / 0.4);
    --border-strong: rgb(63 63 70 / 0.9);

    /* Status */
    --success: rgb(var(--success-rgb));
    --error: rgb(var(--error-rgb));
    --warning: rgb(var(--warning-rgb));
    /* Readable status text. On dark these lighten; on light they darken. */
    --success-text: #86efac;
    --error-text: #fca5a5;
    --warning-text: #fcd34d;

    /* Alpha tints, so a rule never has to know the hue. */
    --tint-primary-weak: rgb(var(--primary-rgb) / 0.06);
    --tint-primary: rgb(var(--primary-rgb) / 0.12);
    --tint-success: rgb(var(--success-rgb) / 0.12);
    --tint-error: rgb(var(--error-rgb) / 0.12);
    --tint-warning: rgb(var(--warning-rgb) / 0.12);

    /* The checkerboard behind anything that can be transparent. */
    --checker: #2a2a2e;

    /* Per-tool accent tones. These were inline `style="color: #f87171"` on every
       icon, which light mode could not reach: a pale tone that reads well on
       near-black is far too weak on white, so the light theme darkens each. */
    --tone-red-rgb: 239 68 68;
    --tone-amber-rgb: 245 158 11;
    --tone-green-rgb: 34 197 94;
    --tone-emerald-rgb: 16 185 129;
    --tone-cyan-rgb: 6 182 212;
    --tone-indigo-rgb: 99 102 241;
    --tone-purple-rgb: 168 85 247;
    --tone-pink-rgb: 236 72 153;

    --tone-red: #f87171;
    --tone-amber: #fbbf24;
    --tone-green: #4ade80;
    --tone-emerald: #34d399;
    --tone-cyan: #22d3ee;
    --tone-indigo: #818cf8;
    --tone-purple: #c084fc;
    --tone-pink: #e879f9;

    /* Spacing scale. Older rules hardcode px; new work should use these. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 48px;

    /* Misc */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    /* Unprefixed alias. Two eyedropper rules referenced it before it existed,
       so those corners silently rendered square. */
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 12px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 8px 32px rgb(0 0 0 / 0.5);
    --shadow-glow: 0 0 40px rgb(var(--primary-rgb) / 0.1);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Light theme

   Only the semantic layer is restated. The hue channels are unchanged, so every
   `rgb(var(--primary-rgb) / …)` tint follows automatically.

   Status text flips direction: the pale #86efac that reads well on near-black
   is close to invisible on white, so these darken instead of lightening.
   ============================================ */

:root[data-theme="light"] {
    color-scheme: light;

    --bg-base: #ffffff;
    --bg-surface: #f7f7f8;
    --bg-elevated: #ececed;
    --bg-glass: rgb(255 255 255 / 0.75);

    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #71717a;
    --text-on-primary: #ffffff;

    --border: rgb(24 24 27 / 0.12);
    --border-hover: rgb(var(--primary-rgb) / 0.5);
    --border-strong: rgb(24 24 27 / 0.22);

    --primary-readable: #4338ca;
    --accent-readable: #0e7490;

    --success-text: #15803d;
    --error-text: #b91c1c;
    --warning-text: #a16207;

    --checker: #dcdce0;

    /* Darkened so each tone stays legible on a pale tint. */
    --tone-red: #dc2626;
    --tone-amber: #b45309;
    --tone-green: #15803d;
    --tone-emerald: #047857;
    --tone-cyan: #0e7490;
    --tone-indigo: #4f46e5;
    --tone-purple: #7e22ce;
    --tone-pink: #be185d;

    /* Softer than the dark theme's: a heavy shadow on white looks like dirt. */
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.06);
    --shadow-md: 0 4px 12px rgb(0 0 0 / 0.08);
    --shadow-lg: 0 8px 32px rgb(0 0 0 / 0.10);
    --shadow-glow: 0 0 40px rgb(var(--primary-rgb) / 0.12);
}

/* Follow the OS until the user picks a theme explicitly, at which point
   data-theme is set on <html> and wins on specificity. */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        color-scheme: light;

        --bg-base: #ffffff;
        --bg-surface: #f7f7f8;
        --bg-elevated: #ececed;
        --bg-glass: rgb(255 255 255 / 0.75);

        --text-primary: #18181b;
        --text-secondary: #52525b;
        --text-muted: #71717a;

        --border: rgb(24 24 27 / 0.12);
        --border-hover: rgb(var(--primary-rgb) / 0.5);
        --border-strong: rgb(24 24 27 / 0.22);

        --primary-readable: #4338ca;

        --accent-readable: #0e7490;

        

        --success-text: #15803d;
        --error-text: #b91c1c;
        --warning-text: #a16207;

        --checker: #dcdce0;

    /* Darkened so each tone stays legible on a pale tint. */
    --tone-red: #dc2626;
    --tone-amber: #b45309;
    --tone-green: #15803d;
    --tone-emerald: #047857;
    --tone-cyan: #0e7490;
    --tone-indigo: #4f46e5;
    --tone-purple: #7e22ce;
    --tone-pink: #be185d;

        --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.06);
        --shadow-md: 0 4px 12px rgb(0 0 0 / 0.08);
        --shadow-lg: 0 8px 32px rgb(0 0 0 / 0.10);
        --shadow-glow: 0 0 40px rgb(var(--primary-rgb) / 0.12);
    }
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-base);
    font-size: 16px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Animated gradient background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 100vh;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgb(var(--primary-rgb) / 0.12), transparent),
        radial-gradient(ellipse 60% 40% at 80% 50%, rgb(var(--accent-rgb) / 0.06), transparent),
        radial-gradient(ellipse 50% 30% at 20% 80%, rgb(var(--primary-rgb) / 0.06), transparent);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   Layout
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

/* ============================================
   Navigation / Header
   ============================================ */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.nav-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
}

.nav-title {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
}

/* ============================================
   Theme toggle
   ============================================ */

.theme-toggle {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
    border-color: var(--border);
}

/* Both icons occupy the same cell; only one is shown. Showing the icon of the
   theme you would switch TO is the convention users expect. */
.theme-toggle svg {
    grid-area: 1 / 1;
}

.theme-toggle .theme-icon-moon { display: none; }
.theme-toggle[data-active-theme="light"] .theme-icon-sun { display: none; }
.theme-toggle[data-active-theme="light"] .theme-icon-moon { display: block; }

/* ============================================
   Mobile nav trigger

   Hidden on desktop. Below the breakpoint it is the only way to reach the nav
   links, which were previously just `display: none` with no replacement.
   ============================================ */

.nav-toggle {
    display: none;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.nav-toggle:hover { color: var(--text-primary); }
.nav-toggle svg { grid-area: 1 / 1; }
.nav-toggle .nav-toggle-close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle-close { display: block; }
.nav-toggle[aria-expanded="true"] svg:first-of-type { display: none; }

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

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

.nav-link.active {
    color: var(--primary-readable);
    background: var(--primary-glow);
}

/* ============================================
   Hero Section (Homepage)
   ============================================ */
.hero {
    padding: 80px 0 40px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--primary-glow);
    border: 1px solid rgb(var(--primary-rgb) / 0.2);
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-readable);
    margin-bottom: 24px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.hero-badge-dot {
    width: 6px;
    height: 6px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.hero h1 {
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 16px;
    letter-spacing: -0.03em;
}

.hero h1 .gradient-text {
    background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto 40px;
    line-height: 1.7;
}

/* Stats */
.hero-stats {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================
   Search Bar
   ============================================ */
.search-wrapper {
    max-width: 560px;
    margin: 0 auto;
    position: relative;
}

.search-bar {
    width: 100%;
    padding: 14px 20px 14px 48px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.search-bar:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-md), 0 0 0 3px var(--primary-glow);
}

.search-bar::placeholder {
    color: var(--text-muted);
}

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

.search-kbd {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
}

.search-kbd kbd {
    padding: 2px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.75rem;
    font-family: inherit;
    color: var(--text-muted);
}

/* ============================================
   Tool Cards Grid
   ============================================ */
.tools-section {
    padding: 40px 0 80px;
    position: relative;
    z-index: 1;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 4px 12px;
    border-radius: 100px;
}

.tools-grid {
    display: grid;
    /* 260px fits three across in the ~900px column beside the rail, and falls
       back to two then one on its own. */
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-3);
}

.tool-card {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    /* Not `all`: transitioning every property means the browser animates
       things like border-color on theme switch too. */
    transition: border-color var(--transition), background var(--transition),
                transform var(--transition), box-shadow var(--transition);
    cursor: pointer;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0;
    transition: opacity var(--transition);
}

.tool-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-elevated);
}

.tool-card:hover::before {
    opacity: 1;
}

.tool-card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.tool-card-icon.youtube {
    background: rgb(var(--error-rgb) / 0.12);
    color: #f87171;
}

.tool-card-icon.instagram {
    background: linear-gradient(135deg, rgb(236 72 153 / 0.12), rgb(168 85 247 / 0.12));
    color: #e879f9;
}

.tool-card-icon.image {
    background: rgb(var(--success-rgb) / 0.12);
    color: #4ade80;
}

.tool-card-icon.default {
    background: var(--primary-glow);
    color: var(--primary-readable);
}

.tool-card-content {
    flex: 1;
}

.tool-card-title {
    font-size: 0.98rem;
    font-weight: 650;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.tool-card-desc {
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.55;
}

.tool-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Pins the footer to the bottom so cards in a row line up regardless of
       how long each description runs. */
    margin-top: auto;
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
}

.tool-card-tag {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 4px 10px;
    border-radius: 100px;
}

.tool-card-arrow {
    color: var(--text-muted);
    transition: all var(--transition);
    width: 20px;
    height: 20px;
}

.tool-card:hover .tool-card-arrow {
    color: var(--primary-readable);
    transform: translateX(4px);
}

.tool-card-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 100px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.tool-card-status.live {
    background: rgb(var(--success-rgb) / 0.12);
    color: var(--success);
}

.tool-card-status.soon {
    background: rgb(var(--warning-rgb) / 0.12);
    color: var(--warning);
}

/* ============================================
   Tool Page Layout (shared for all tool pages)
   ============================================ */
.tool-page {
    padding: 32px 0 80px;
    position: relative;
    z-index: 1;
}

.tool-page-container {
    max-width: 800px;
    margin: 0 auto;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
    font-size: 0.9rem;
}

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

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

.breadcrumb-sep {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.breadcrumb-current {
    color: var(--text-secondary);
}

/* Tool Header */
.tool-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 32px;
}

.tool-header-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.tool-header-text h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.tool-header-text p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Tool Panel */
.tool-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
}

/* A tool that cannot run on this host says why, in prose. */
.retired-notice h2 {
    margin: 0 0 12px;
    font-size: 1.25rem;
}

.retired-notice p {
    margin: 0 0 16px;
    color: var(--text-secondary);
    line-height: 1.65;
}

.tool-panel-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    background: var(--primary-glow);
    border: 1px solid rgb(var(--primary-rgb) / 0.2);
    border-radius: var(--radius-md);
    margin-bottom: 28px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.tool-panel-notice svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--primary-readable);
    margin-top: 2px;
}

/* Input Group */
.input-group {
    margin-bottom: 0;
}

.input-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

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

.input-field {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-field::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 2px 8px rgb(var(--primary-rgb) / 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    box-shadow: 0 4px 16px rgb(var(--primary-rgb) / 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    border-color: var(--text-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 16px;
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

/* Loading Spinner */
.loading-state {
    text-align: center;
    padding: 48px 24px;
    display: none;
}

.loading-state.active {
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

.loading-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Results */
.results-container {
    display: none;
    margin-top: 28px;
}

.results-container.active {
    display: block;
}

/* Error State */
.error-msg {
    display: none;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    background: rgb(var(--error-rgb) / 0.08);
    border: 1px solid rgb(var(--error-rgb) / 0.25);
    border-radius: var(--radius-md);
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--error-text);
    line-height: 1.6;
}

.error-msg.active {
    display: flex;
}

.error-msg svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--error);
    margin-top: 2px;
}

/* ============================================
   Video Info (YouTube)
   ============================================ */
.video-info-card {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 24px;
}

.video-thumbnail-wrap {
    position: relative;
    overflow: hidden;
}

.video-thumbnail-wrap img {
    width: 100%;
    display: block;
}

.video-meta {
    padding: 20px;
}

.video-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.video-details-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.video-detail {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.video-detail svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

/* Quality Options */
.quality-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quality-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.quality-item:hover {
    border-color: var(--border-hover);
    background: rgb(var(--primary-rgb) / 0.04);
}

.quality-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.quality-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.quality-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============================================
   Instagram-specific
   ============================================ */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

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

.quality-notice {
    display: flex;
    gap: 10px;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-secondary);
    background: rgb(var(--warning-rgb) / 0.08);
    border: 1px solid rgb(var(--warning-rgb) / 0.3);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 20px;
}

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

.download-hint {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-top: 14px;
}

.download-hint a {
    color: var(--primary-readable);
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.media-item {
    position: relative;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-base);
    cursor: pointer;
    transition: all var(--transition);
}

.media-item:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.media-item.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.media-item img,
.media-item video {
    width: 100%;
    height: auto;
    display: block;
}

.media-checkbox {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 22px;
    height: 22px;
    cursor: pointer;
    z-index: 10;
    accent-color: var(--primary);
}

.media-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgb(0 0 0 / 0.75);
    backdrop-filter: blur(8px);
    color: white;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Download Section */
.download-panel {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
}

.download-panel h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

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

.format-select {
    padding: 10px 36px 10px 16px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><path fill="%236366f1" d="M6 9L1 4h10z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
}

.format-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.format-select:hover {
    border-color: var(--border-hover);
}

.format-select option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.format-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.format-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

/* ============================================
   Footer
   ============================================ */
.footer {
    position: relative;
    z-index: 1;
    border-top: 1px solid var(--border);
    padding: 32px 0;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 20px;
    list-style: none;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--primary-readable);
}

/* ============================================
   Feedback Form
   ============================================ */
.feedback-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
}

.feedback-panel h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.feedback-panel > p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition);
}

.form-group textarea {
    min-height: 150px;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group select option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

/* Messages */
.message-box {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    display: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.message-box.success {
    background: rgb(var(--success-rgb) / 0.08);
    border: 1px solid rgb(var(--success-rgb) / 0.25);
    color: var(--success-text);
}

.message-box.error {
    background: rgb(var(--error-rgb) / 0.08);
    border: 1px solid rgb(var(--error-rgb) / 0.25);
    color: var(--error-text);
}

.message-box.active {
    display: block;
}

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

    .hero {
        padding: 48px 0 24px;
    }

    .hero-stats {
        gap: 24px;
        flex-wrap: wrap;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .tool-panel {
        padding: 24px;
    }

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

    /* The links become a drawer under the bar rather than vanishing. */
    .nav-toggle {
        display: grid;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: var(--space-2);
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links .nav-link {
        display: block;
        padding: var(--space-3) var(--space-4);
    }

    /* The theme toggle reads as a labelled row in the drawer, not a bare icon. */
    .nav-links .theme-toggle {
        width: 100%;
        height: auto;
        justify-content: flex-start;
        padding: var(--space-3) var(--space-4);
    }

    .nav-links .theme-toggle::after {
        content: 'Switch theme';
        margin-left: var(--space-3);
        font-size: 0.9rem;
        font-weight: 500;
    }

    .footer-inner {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .download-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .tool-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .search-kbd {
        display: none;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.8rem;
    }

    .hero-subtitle {
        font-size: 0.95rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .tool-header-text h1 {
        font-size: 1.4rem;
    }

    .feedback-panel {
        padding: 24px;
    }

    .feedback-panel h1 {
        font-size: 1.4rem;
    }
}

/* ============================================
   Converter Tools — Shared Styles
   ============================================ */

/* Dropzone */
.converter-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    transition: all var(--transition);
    cursor: pointer;
    background: rgb(var(--primary-rgb) / 0.02);
}

.converter-dropzone:hover {
    border-color: var(--border-hover);
    background: rgb(var(--primary-rgb) / 0.04);
}

.converter-dropzone.dragover {
    border-color: var(--primary);
    background: rgb(var(--primary-rgb) / 0.08);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.converter-dropzone svg {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.dropzone-text {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.dropzone-browse {
    background: none;
    border: none;
    color: var(--primary-readable);
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.dropzone-browse:hover {
    color: var(--primary);
}

.dropzone-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Settings Panel */
.converter-settings {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.settings-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.setting-group {
    flex: 1;
    min-width: 160px;
}

.setting-group .input-label {
    margin-bottom: 8px;
}

.quality-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-elevated);
    border-radius: 3px;
    outline: none;
    margin-top: 8px;
}

.quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgb(var(--primary-rgb) / 0.4);
}

.quality-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgb(var(--primary-rgb) / 0.4);
}

.quality-slider::-moz-range-track {
    background: var(--bg-elevated);
    border-radius: 3px;
    height: 6px;
}

.resize-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.resize-x {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-sm {
    width: 90px;
    padding: 10px 12px;
    font-size: 0.9rem;
}

.settings-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* File List */
.converter-file-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

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

.file-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.file-item-info svg {
    flex-shrink: 0;
    color: var(--text-muted);
}

.file-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item-size {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.file-item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
}

.file-item-remove:hover {
    color: var(--error);
    background: rgb(var(--error-rgb) / 0.1);
}

/* File Info Card (single file) */
.file-info-card {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.file-info-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-info-row svg {
    flex-shrink: 0;
    color: var(--primary-readable);
}

.file-info-details {
    flex: 1;
    min-width: 0;
}

.file-info-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-info-size {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Converter Results */
.converter-results {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.converter-output-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.output-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

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

.output-item.output-error {
    border-color: rgb(var(--error-rgb) / 0.25);
    background: rgb(var(--error-rgb) / 0.04);
}

.output-item-preview {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-elevated);
}

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

.output-item-info {
    flex: 1;
    min-width: 0;
}

.output-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.output-item-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.output-savings.positive {
    color: var(--success);
}

.output-savings.negative {
    color: var(--error);
}

/* "Same size" is a normal outcome, not a failure. The image editor mapped
   savings() to a two-way ternary on 'smaller', so a byte-identical re-encode
   was painted in the error colour. */
.output-savings.neutral {
    color: var(--text-muted);
}

/* Extra buttons on a result row (js/shared/result-card.js). Kept off the
   download button's own spacing so a row with no actions looks unchanged. */
.output-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* Progress Bar */
.converter-progress {
    margin-top: 24px;
    text-align: center;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Work with no measurable progress (a Whisper run): full width, pulsing. */
.progress-bar-fill.is-indeterminate {
    width: 100%;
    animation: progress-pulse 1.4s ease-in-out infinite;
}

@keyframes progress-pulse {
    50% { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
    .progress-bar-fill.is-indeterminate { animation: none; }
}

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

/* ============================================
   Editor Workspace — Image & Video Editors
   ============================================ */
.editor-workspace {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.editor-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.editor-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.editor-filename {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.editor-file-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Canvas / Video Preview Area */
.editor-canvas-area {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgb(0 0 0 / 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    min-height: 200px;
    margin-bottom: 16px;
}

.editor-canvas-wrapper {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.editor-canvas-wrapper canvas {
    max-width: 100%;
    max-height: 500px;
    display: block;
}

.video-preview-player {
    width: 100%;
    max-height: 500px;
    display: block;
    background: #000;
    outline: none;
}

/* Editor Toolbar */
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.toolbar-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: rgb(var(--primary-rgb) / 0.06);
}

.toolbar-btn.active {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary-readable);
}

.toolbar-btn svg {
    flex-shrink: 0;
}

/* Crop Overlay */
.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    z-index: 10;
}

.crop-selection {
    position: absolute;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.5);
    cursor: move;
    z-index: 11;
}

.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: 2px;
    z-index: 12;
}

.crop-handle-nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle-ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle-se { bottom: -6px; right: -6px; cursor: se-resize; }
.crop-handle-n { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.crop-handle-s { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.crop-handle-e { right: -6px; top: 50%; transform: translateY(-50%); cursor: e-resize; }
.crop-handle-w { left: -6px; top: 50%; transform: translateY(-50%); cursor: w-resize; }

.crop-size-label {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgb(0 0 0 / 0.75);
    color: var(--text-on-primary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
}

.crop-confirm-bar {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--primary-glow);
    border: 1px solid rgb(var(--primary-rgb) / 0.3);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-4);
}

.crop-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
}

.crop-aspect-field,
.crop-custom-ratio,
.crop-numeric {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2);
}

.crop-aspect-field {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
}

.crop-numeric {
    flex-wrap: wrap;
}

.crop-numeric .input-label {
    margin: 0 0 var(--space-1) 0;
}

/* Four numeric crop fields on one line need to stay narrow. */
.crop-numeric .input-field {
    width: 5.5rem;
}

.crop-custom-ratio .input-field {
    width: 4.5rem;
}

.crop-confirm-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.crop-info {
    font-size: 0.85rem;
    color: var(--primary-readable);
    font-weight: 600;
}

.crop-confirm-actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   Image Editor — batch, metadata, export extras
   ============================================ */

.editor-info-actions {
    display: flex;
    gap: var(--space-2);
}

.batch-strip {
    margin-bottom: var(--space-4);
    padding: var(--space-3);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.batch-strip-header {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-3);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.batch-strip-hint {
    font-weight: 400;
    color: var(--text-muted);
}

.batch-list {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding-bottom: var(--space-1);
}

.batch-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 0 0 auto;
    max-width: 260px;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
}

.batch-item:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.batch-item.active {
    border-color: var(--primary);
    color: var(--text-primary);
    background: var(--primary-glow);
}

.batch-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.batch-item-meta {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.batch-item-remove {
    flex: 0 0 auto;
    padding: 0 var(--space-1);
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
}

.batch-item-remove:hover {
    color: var(--error);
}

/* Canvas re-encoding always drops EXIF; this says what is being lost. */
.metadata-notice {
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: rgb(var(--warning-rgb) / 0.08);
    border: 1px solid rgb(var(--warning-rgb) / 0.3);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.metadata-notice ul {
    margin: var(--space-1) 0 0 var(--space-5);
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-2);
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
}

.matte-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.matte-picker {
    width: 48px;
    height: 34px;
    flex: 0 0 auto;
}

.matte-hint,
.resize-hint {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.resize-hint {
    margin-top: var(--space-3);
}

.export-progress {
    margin-top: var(--space-4);
}

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

.editor-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.editor-section-head .editor-section-title {
    margin-bottom: 0;
}

/* ============================================
   Homepage app shell

   A rail of categories beside the tool list, rather than a marketing hero.
   The rail is plain anchor links, so it still navigates with JavaScript off.
   ============================================ */

.app {
    padding: var(--space-7) 0 var(--space-8);
}

.app-inner {
    display: grid;
    grid-template-columns: 208px minmax(0, 1fr);
    gap: var(--space-8);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.app-sidebar-inner {
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* Nav is 64px tall and sticky, so the rail parks just below it. */
    position: sticky;
    top: 84px;
}

.cat-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

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

.cat-link.is-active {
    color: var(--primary-readable);
    background: var(--tint-primary);
}

.cat-count {
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.sidebar-divider {
    height: 1px;
    margin: var(--space-3) var(--space-3);
    background: var(--border);
}

.app-head {
    margin-bottom: var(--space-7);
}

.app-title {
    font-size: clamp(1.6rem, 3.4vw, 2.3rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--text-primary);
}

.app-sub {
    max-width: 62ch;
    margin-top: var(--space-3);
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--text-secondary);
}

.app-head .search-wrapper {
    margin: var(--space-5) 0 0;
}

.app-meta {
    margin-top: var(--space-3);
    font-size: 0.82rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.cat-section + .cat-section {
    margin-top: var(--space-8);
}

.cat-header {
    margin-bottom: var(--space-4);
}

.cat-title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.cat-blurb {
    margin-top: var(--space-1);
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* Says where the work happens, which is the thing users actually care about. */
.tool-card-runs {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 3px 8px;
    border-radius: 999px;
    color: var(--success-text);
    background: var(--tint-success);
}

.tool-card-runs.is-server {
    color: var(--warning-text);
    background: var(--tint-warning);
}

.results-heading {
    margin-bottom: var(--space-4);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

/* Near misses. Visually quieter than the real results, because they are a
   guess — presenting them identically would be a lie about confidence. */
.related-block {
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 1px dashed var(--border);
}

.related-block .tool-card {
    background: transparent;
}

.spelling-hint {
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    font-size: 0.88rem;
    color: var(--text-secondary);
    background: var(--tint-primary-weak);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.spelling-hint strong {
    color: var(--primary-readable);
}

.no-results {
    padding: var(--space-7) 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.no-results code {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-elevated);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.86em;
}

/**
 * `hidden` must actually hide.
 *
 * The user-agent rule is `[hidden] { display: none }` at the lowest possible
 * specificity, so ANY author rule setting `display` beats it. `.tool-card`
 * computes to `display: flex`, which meant search results were filtered
 * correctly and then rendered anyway. js/shared/dom.js's show()/hide() and
 * notify() both toggle this attribute, so it has to be reliable everywhere.
 */
[hidden] {
    display: none !important;
}

@media (max-width: 900px) {
    .app-inner {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-6);
    }

    /* The rail becomes a horizontal strip of chips above the list. */
    .app-sidebar-inner {
        position: static;
        flex-direction: row;
        gap: var(--space-2);
        overflow-x: auto;
        padding-bottom: var(--space-2);
    }

    .cat-link {
        flex: 0 0 auto;
        border: 1px solid var(--border);
    }

    .sidebar-divider {
        display: none;
    }

    /* Feedback and GitHub are already in the nav; the rail is for categories. */
    .app-sidebar-inner > .cat-link[href$="feedback.html"],
    .app-sidebar-inner > .cat-link[target="_blank"] {
        display: none;
    }
}

/* ============================================
   Troubleshooting / help pages

   These lived in an inline <style> on the Instagram help page, referencing
   --bg-secondary, --border-color, --primary-color and --bg-color, none of
   which have ever existed — so the cards rendered with no background and no
   border at all.
   ============================================ */

.troubleshooting-section {
    max-width: 820px;
}

.error-card {
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.error-card h2 {
    margin-bottom: var(--space-3);
    font-size: 1.15rem;
    font-weight: 650;
    color: var(--text-primary);
}

.error-card h3 {
    margin: var(--space-4) 0 var(--space-2);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.error-card p,
.error-card li {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.7;
}

.error-card p {
    margin-bottom: var(--space-2);
}

.error-card ul {
    margin: 0 0 var(--space-2) var(--space-5);
}

.error-card a {
    color: var(--primary-readable);
}

.error-card code {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-elevated);
    color: var(--primary-readable);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88em;
}

/* ============================================
   Tool accent tones

   Applied as `class="tool-card-icon tone-cyan"` rather than an inline style, so
   both themes can restyle them. Every tone is a 12% tint of its own hue with a
   foreground that flips between themes.
   ============================================ */

.tone-red,
.tone-amber,
.tone-green,
.tone-emerald,
.tone-cyan,
.tone-indigo,
.tone-purple,
.tone-pink {
    background: rgb(var(--tone-rgb) / 0.12);
    color: var(--tone-fg);
}

.tone-red { --tone-rgb: var(--tone-red-rgb); --tone-fg: var(--tone-red); }
.tone-amber { --tone-rgb: var(--tone-amber-rgb); --tone-fg: var(--tone-amber); }
.tone-green { --tone-rgb: var(--tone-green-rgb); --tone-fg: var(--tone-green); }
.tone-emerald { --tone-rgb: var(--tone-emerald-rgb); --tone-fg: var(--tone-emerald); }
.tone-cyan { --tone-rgb: var(--tone-cyan-rgb); --tone-fg: var(--tone-cyan); }
.tone-indigo { --tone-rgb: var(--tone-indigo-rgb); --tone-fg: var(--tone-indigo); }
.tone-purple { --tone-rgb: var(--tone-purple-rgb); --tone-fg: var(--tone-purple); }
.tone-pink { --tone-rgb: var(--tone-pink-rgb); --tone-fg: var(--tone-pink); }

/* Instagram's mark is a gradient, so it is the one exception. */
.tone-instagram {
    background: linear-gradient(135deg,
        rgb(var(--tone-pink-rgb) / 0.14), rgb(var(--tone-purple-rgb) / 0.14));
    color: var(--tone-pink);
}

/* YouTube's is red, and the old .youtube/.image class names are kept as
   aliases so nothing that still uses them breaks. */
.tool-card-icon.youtube { background: rgb(var(--tone-red-rgb) / 0.12); color: var(--tone-red); }
.tool-card-icon.image { background: rgb(var(--tone-green-rgb) / 0.12); color: var(--tone-green); }
.tool-card-icon.instagram {
    background: linear-gradient(135deg,
        rgb(var(--tone-pink-rgb) / 0.14), rgb(var(--tone-purple-rgb) / 0.14));
    color: var(--tone-pink);
}

/* ============================================
   Favicon Generator
   ============================================ */

.favicon-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-5);
    align-items: flex-end;
}

.favicon-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    text-align: center;
}

/* The canvas keeps its real pixel size — a 16px preview shows exactly the
   detail a 16px favicon has — but is capped so 512 sits beside it. */
.favicon-preview-canvas {
    display: block;
    max-width: 96px;
    max-height: 96px;
    background:
        linear-gradient(45deg, var(--checker) 25%, transparent 25%, transparent 75%, var(--checker) 75%) 0 0 / 12px 12px,
        linear-gradient(45deg, var(--checker) 25%, transparent 25%, transparent 75%, var(--checker) 75%) 6px 6px / 12px 12px,
        var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    image-rendering: pixelated;
}

.favicon-preview-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.favicon-preview-purpose {
    font-size: 0.72rem;
    color: var(--text-muted);
    max-width: 100px;
    line-height: 1.35;
}

.code-snippet {
    padding: var(--space-4);
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-secondary);
    overflow-x: auto;
    white-space: pre;
}

.option-hint {
    margin-top: var(--space-1);
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-muted);
}

/* Editor Sections */
.editor-section {
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
}

.editor-section:last-of-type {
    border-bottom: none;
}

.editor-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* Adjustment Grid */
.adjustment-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.adjustment-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.adjustment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.adjustment-header label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.adjustment-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-readable);
    min-width: 28px;
    text-align: right;
}

/* Resize Row */
.resize-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 12px;
}

.resize-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.resize-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.preset-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.preset-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: rgb(var(--primary-rgb) / 0.06);
}

/* A preset that is currently in force. The target-size chips in convert/ are
   a toggle, so "which one am I on" has to be visible. */
.preset-btn.is-active {
    border-color: var(--primary);
    color: var(--primary-readable);
    background: rgb(var(--primary-rgb) / 0.12);
}

/* Aspect Ratio Lock Button */
.aspect-lock-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    align-self: flex-end;
    margin-bottom: 2px;
    padding: 0;
}

.aspect-lock-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.aspect-lock-btn.active {
    color: var(--primary);
    border-color: var(--primary);
    background: rgb(var(--primary-rgb) / 0.08);
}

/* Toolbar button disabled state */
.toolbar-btn:disabled,
.toolbar-btn[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Export Grid */
.export-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

/* PDF tools: page thumbnails and signing */
.pdf-thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 10px;
    max-height: 340px;
    overflow-y: auto;
    margin-top: 12px;
    padding: 4px;
}

.pdf-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: none;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}

.pdf-thumb[aria-pressed="true"] {
    border-color: var(--primary);
    color: var(--text-primary);
}

.pdf-thumb:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.pdf-thumb-page {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 4;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.pdf-thumb[data-state="done"] .pdf-thumb-page {
    aspect-ratio: auto;
    background: none;
}

.pdf-thumb-canvas {
    display: block;
    width: 100%;
    height: auto;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
}

.pdf-thumb[aria-pressed="false"] .pdf-thumb-canvas {
    opacity: 0.45;
}

/* Spans the two-column option grid: the page needs the room. */
.sign-field {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Paper, in both themes: ink is dark and so is a signature on a PDF. */
.sign-pad {
    width: 100%;
    height: 140px;
    background: #ffffff;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    touch-action: none;
    cursor: crosshair;
}

.sign-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.sign-tools .input-field {
    flex: 1;
    min-width: 160px;
}

.sign-page-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sign-page-row .input-label {
    margin: 0;
}

.sign-page-row .input-field {
    width: 96px;
    flex: none;
}

.sign-stage {
    position: relative;
    max-width: 520px;
    border: 1px solid var(--border);
    background: #ffffff;
    user-select: none;
}

.sign-stage canvas {
    display: block;
    width: 100%;
    height: auto;
}

.sign-box {
    position: absolute;
    outline: 1px dashed var(--primary);
    cursor: move;
    touch-action: none;
}

.sign-box:focus-visible {
    outline: 2px solid var(--primary);
}

.sign-box img {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.sign-handle {
    position: absolute;
    right: -7px;
    bottom: -7px;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border: 2px solid #ffffff;
    border-radius: 50%;
    cursor: nwse-resize;
}

/* Text from image: the recognised text, editable before copying */
.ocr-output {
    width: 100%;
    min-height: 240px;
    margin-top: 12px;
    resize: vertical;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Photo privacy: what each photo gives away */
.privacy-card {
    padding: 16px 18px;
    margin-bottom: 12px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.privacy-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.privacy-headline {
    margin: 10px 0 0;
    font-weight: 600;
    color: var(--text-primary);
}

.privacy-headline.is-location,
.privacy-headline.is-error {
    color: var(--error-text);
}

.privacy-headline.is-none {
    color: var(--success-text);
}

.privacy-facts {
    display: grid;
    grid-template-columns: minmax(96px, max-content) 1fr;
    gap: 6px 16px;
    margin: 12px 0 0;
    font-size: 0.9rem;
}

.privacy-facts dt {
    color: var(--text-muted);
}

.privacy-facts dd {
    margin: 0;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.privacy-facts dd.is-sensitive {
    color: var(--text-primary);
    font-weight: 600;
}

.privacy-facts a {
    color: var(--primary-readable);
}

.privacy-blocks {
    margin: 12px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.privacy-all {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.privacy-all summary {
    cursor: pointer;
}

.export-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.export-estimate {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Target size row */
.target-size-row {
    display: flex;
    gap: 8px;
}

.target-size-row .input-field {
    flex: 1;
}

.target-size-row .format-select {
    width: 80px;
    flex-shrink: 0;
}

.target-size-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Trim Controls */
.trim-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.trim-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

.trim-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.trim-duration {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-readable);
    padding: 8px 0;
}

.trim-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.trim-quick-btns {
    display: flex;
    gap: 8px;
}

/* ============================================
   Color Converter — Specific Styles
   ============================================ */
.color-top-row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 28px;
}

.color-swatch-large {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    flex-shrink: 0;
    background: var(--primary);
    box-shadow: var(--shadow-md);
    transition: background 0.15s ease;
}

.color-picker-wrap {
    flex: 1;
}

.color-picker-input {
    width: 100%;
    height: 48px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-base);
    cursor: pointer;
    transition: all var(--transition);
}

.color-picker-input:hover {
    border-color: var(--border-hover);
}

.color-picker-input::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker-input::-webkit-color-swatch {
    border-radius: 6px;
    border: none;
}

.color-picker-input::-moz-color-swatch {
    border-radius: 6px;
    border: none;
}

.color-picker-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.color-format-group {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.color-format-group:last-of-type {
    border-bottom: none;
}

.color-format-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.color-format-header .input-label {
    margin-bottom: 0;
}

.color-inputs-row {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.color-input-group {
    flex: 1;
}

.color-input-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.color-text-output {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 10px 14px;
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.color-history-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.color-history {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 32px;
}

.color-history-item {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
}

.color-history-item:hover {
    transform: scale(1.15);
    border-color: var(--text-secondary);
    box-shadow: var(--shadow-md);
}

/* ============================================
   Eyedropper / Image Color Picker
   ============================================ */
.eyedropper-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.eyedropper-upload-area:hover,
.eyedropper-upload-area.dragover {
    border-color: var(--primary);
    background: rgb(var(--primary-rgb) / 0.04);
}

.eyedropper-canvas-area {
    margin-top: 12px;
}

.eyedropper-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.eyedropper-filename {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.eyedropper-canvas-wrapper {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: crosshair;
    background: repeating-conic-gradient(var(--bg-elevated) 0% 25%, transparent 0% 50%) 50% / 16px 16px;
}

.eyedropper-canvas-wrapper canvas {
    display: block;
    width: 100%;
    height: auto;
}

.eyedropper-magnifier {
    position: absolute;
    width: 110px;
    height: 130px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    z-index: 10;
}

.eyedropper-magnifier canvas {
    display: block;
    border-radius: 0;
    image-rendering: pixelated;
}

.magnifier-crosshair {
    position: absolute;
    top: 44px;
    left: 49px;
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgb(0 0 0 / 0.4);
    pointer-events: none;
}

.magnifier-color-label {
    width: 100%;
    text-align: center;
    padding: 4px 0;
    font-family: monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
}

.eyedropper-hint {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ============================================
   Responsive — Converters
   ============================================ */
@media (max-width: 768px) {
    .settings-row {
        flex-direction: column;
    }

    .settings-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .color-top-row {
        flex-direction: column;
        align-items: center;
    }

    .color-swatch-large {
        width: 80px;
        height: 80px;
    }

    .color-picker-wrap {
        width: 100%;
    }

    .color-inputs-row {
        gap: 8px;
    }

    .resize-inputs {
        flex-wrap: wrap;
    }

    .editor-toolbar {
        gap: 4px;
    }

    .toolbar-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .toolbar-btn span {
        display: none;
    }

    .adjustment-grid {
        grid-template-columns: 1fr;
    }

    .export-grid {
        grid-template-columns: 1fr;
    }

    .resize-row {
        flex-wrap: wrap;
    }

    .trim-row {
        flex-direction: column;
        gap: 12px;
    }

    .crop-confirm-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .editor-filename {
        max-width: 150px;
    }
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

/* js/shared/notify.js `announce()` builds its live region with the
   visually-hidden class, so the two names must stay in sync. */
.sr-only,
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Focus

   There were no focus styles at all, so a keyboard user could not tell where
   they were. :focus-visible rather than :focus so a mouse click does not leave
   a ring behind on buttons.
   ============================================ */

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* A range thumb cannot take an outline, so the whole track is highlighted. */
.quality-slider:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 4px;
}

/* Skip link: the first thing a keyboard user reaches, invisible until focused. */
.skip-link {
    position: absolute;
    left: var(--space-4);
    top: var(--space-4);
    z-index: 200;
    padding: var(--space-3) var(--space-4);
    color: var(--text-on-primary);
    background: var(--primary);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-200%);
}

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

/* ============================================
   Reduced motion

   This site animates a lot — gradients, transforms, spinners. Respect the
   preference rather than overriding it: `1ms` instead of `0s` keeps
   transitionend/animationend firing, which some of the JS relies on to clean up.
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
        scroll-behavior: auto !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* ============================================
   Notices — js/shared/notify.js
   ============================================ */

/* The page supplies `class="notice" hidden`; notify() adds a level class plus
   `active`, and clearNotice() removes both and re-sets hidden.

   The :not([hidden]) is load-bearing. An author rule beats the user-agent
   `[hidden] { display: none }`, so keying the reveal on `.active` alone would
   leave a notice visible for anything that sets `hidden` without also
   clearing `active`. */
.notice {
    display: none;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 0.9rem;
    line-height: 1.5;
}

.notice.active:not([hidden]) {
    display: flex;
}

.notice-error {
    background: rgb(var(--error-rgb) / 0.10);
    border-color: rgb(var(--error-rgb) / 0.35);
    color: var(--error);
}

.notice-success {
    background: rgb(var(--success-rgb) / 0.10);
    border-color: rgb(var(--success-rgb) / 0.35);
    color: var(--success);
}

.notice-info {
    background: rgb(var(--primary-rgb) / 0.10);
    border-color: rgb(var(--primary-rgb) / 0.35);
    color: var(--text-secondary);
}

/* js/shared/clipboard.js flashes this on the button after a successful copy. */
.copied {
    background: var(--success) !important;
    border-color: var(--success) !important;
    color: var(--text-on-primary) !important;
}

/* createDropzone toggles .dragover on whatever host it is handed. That was
   only styled as .converter-dropzone.dragover, so any other host got no
   feedback at all. */
[data-dropzone].dragover {
    border-color: var(--primary);
    background: rgb(var(--primary-rgb) / 0.08);
}

/* ============================================
   Audio Converter
   ============================================ */

.audio-preview-player {
    width: 100%;
    margin: 12px 0;
    border-radius: var(--radius-md);
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.checkbox-field input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ============================================
   QR Code Generator
   ============================================ */

.qr-textarea {
    min-height: 84px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

.qr-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.qr-preview-area {
    display: flex;
    justify-content: center;
    padding: 24px;
    margin: 20px 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

/* The canvas is sized in device pixels for a sharp export; cap the displayed
   size so a 2048px code does not blow out the layout. crisp-edges keeps the
   modules square instead of blurring them when it is scaled down. */
.qr-canvas {
    max-width: 100%;
    max-height: 340px;
    height: auto;
    image-rendering: pixelated;
    border-radius: var(--radius-sm);
}

/* ============================================
   file:// guard — pages that load ES modules
   ============================================ */

/* A module is CORS-blocked on file://, so such a page renders blank when opened
   straight from disk. A classic inline <head> script sets .needs-http on
   <html>; this hides the real page and shows the explanation instead. The
   script cannot itself be a module — a module would never run to set the flag. */
.file-protocol-notice {
    display: none;
}

.needs-http body > *:not(.file-protocol-notice) {
    display: none !important;
}

.needs-http .file-protocol-notice {
    display: block;
    max-width: 640px;
    margin: 15vh auto;
    padding: 32px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.65;
}

.file-protocol-notice h1 {
    margin: 0 0 12px;
    font-size: 1.25rem;
}

.file-protocol-notice code {
    padding: 2px 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    color: var(--accent-readable);
}
