html {
    background-color: var(--bg-color);
    /* Matches the overscroll to your theme */
    font-size: 100%; /* CRITICAL: 1rem = user's OS font size, not always 16px */
}


:root,
body.theme-dark {
    --bg-color: #0d1321;
    --bg-gradient: radial-gradient(at 0% 0%, rgba(168, 85, 247, 0.06) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(59, 130, 246, 0.06) 0px, transparent 50%),
        #0d1321;
    --surface-color: #172033;
    --surface-hover: #243049;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #a855f7, #3b82f6);
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --glass-bg: rgba(23, 32, 51, 0.45);
    --glass-border: rgba(255, 255, 255, 0.08);
    --radius: 12px;
    --radius-lg: 20px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.45);
    /* Fluid spacing tokens â€” scale with viewport, respect OS font size */
    --space-xs:  clamp(0.25rem, 1vw, 0.5rem);
    --space-sm:  clamp(0.5rem,  2vw, 1rem);
    --space-md:  clamp(0.75rem, 2.5vw, 1.25rem);
    --space-lg:  clamp(1rem,    3vw, 2rem);
    --space-xl:  clamp(1.5rem,  4vw, 3rem);
    --container-pad: clamp(1rem, 4vw, 2.5rem);
}

body.theme-light {
    --bg-color: #f8fafc;
    --bg-gradient: radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.04) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(37, 99, 235, 0.04) 0px, transparent 50%),
        #f8fafc;
    --surface-color: #ffffff;
    --surface-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent-color: #2563eb;
    --accent-gradient: linear-gradient(135deg, #8b5cf6, #2563eb);
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(0, 0, 0, 0.05);
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent !important;
    overflow-wrap: break-word;
    word-break: normal;
    /* THE critical flex/grid fix: every element can shrink below its content size */
    min-width: 0;
}

img, video, canvas, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    /* Adapts to mobile URL bar expanding/collapsing */
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
    overscroll-behavior-y: none;
    /* Disables Chrome/Safari pull-to-refresh */
    min-width: 320px;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-color);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

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

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

.tool-view {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tool-view.active {
    display: block;
    opacity: 1;
}

/* Layout container */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--container-pad);
}

/* Navbar Container & Navbar */
.navbar-container {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--space-sm) var(--container-pad) var(--space-xs);
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    background: transparent;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(0.5rem, 1.5vw, 0.75rem) clamp(0.75rem, 2vw, 1.5rem);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    gap: clamp(0.25rem, 1vw, 0.75rem);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: clamp(0.375rem, 1.5vw, 0.625rem);
    text-decoration: none;
    font-weight: 700;
    font-size: clamp(1rem, 3.5vw, 1.375rem);
    flex-shrink: 1;
    min-width: 0;
}

.brand-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-icon {
    -webkit-text-fill-color: initial;
    color: #a855f7;
    font-size: 1.5rem;
    filter: drop-shadow(0 0 4px rgba(168, 85, 247, 0.4));
    animation: pulseGlow 2s infinite ease-in-out;
}

.brand-logo-img {
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    min-height: 2rem;
    flex-shrink: 0;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(139, 92, 246, 0.3));
    transition: transform var(--transition);
}

.brand-logo:hover .brand-logo-img {
    transform: scale(1.08) rotate(5deg);
}

@keyframes pulseGlow {

    0%,
    100% {
        filter: drop-shadow(0 0 4px rgba(168, 85, 247, 0.4));
    }

    50% {
        filter: drop-shadow(0 0 10px rgba(168, 85, 247, 0.8));
    }
}

.nav-right {
    display: flex;
    align-items: center;
    gap: clamp(0.25rem, 1vw, 0.75rem);
    flex-shrink: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 clamp(0.625rem, 2vw, 1.125rem);
    height: auto;
    min-height: 2.75rem; /* 44px accessible tap target */
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: clamp(0.8rem, 1.5vw, 0.9375rem);
    border-radius: 25px;
    transition: var(--transition);
    white-space: nowrap;
}

button.nav-link {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.nav-link i {
    font-size: 16px;
}

.nav-link.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

body.theme-light .nav-link.active {
    background: rgba(0, 0, 0, 0.04);
}

@media (hover: hover) and (pointer: fine) {
    .nav-link:hover {
        color: var(--text-primary);
        background: rgba(255, 255, 255, 0.05);
    }

    body.theme-light .nav-link:hover {
        background: rgba(0, 0, 0, 0.04);
    }
}

.nav-link.active {
    background: rgba(59, 130, 246, 0.1) !important;
    color: var(--accent-color);
}

/* Categories Dropdown */
.dropdown {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    min-width: 480px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 20px;
    z-index: 101;
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s;
}

.dropdown-content::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    width: 100%;
    height: 20px;
}

.dropdown:hover .dropdown-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.dropdown.dropdown-right .dropdown-content {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(10px);
    min-width: 180px;
    padding: 8px;
}

/* Grid menu button - rounded square style */
.grid-menu-btn {
    width: 40px;
    height: 40px;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 12px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    padding: 0 !important;
    box-sizing: border-box;
}

.grid-menu-btn:hover {
    background: var(--surface-hover);
    border-color: var(--accent-color);
}

/* 3x3 dot grid icon */
.grid-3x3 {
    display: grid;
    grid-template-columns: repeat(3, auto);
    gap: 4px;
    margin: 0 !important;
    padding: 0 !important;
    justify-content: center;
    align-content: center;
}

.grid-3x3 span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-primary);
    transition: var(--transition);
}

.grid-menu-btn:hover .grid-3x3 span {
    background: var(--accent-color);
}

/* Click-to-toggle dropdown (overrides hover) */
.dropdown.dropdown-right .dropdown-content {
    display: flex;
    flex-direction: column;
    visibility: hidden;
    opacity: 0;
    transform: translateX(0) translateY(10px);
}

.dropdown.dropdown-right:hover .dropdown-content {
    display: flex;
    grid-template-columns: none;
    gap: 0;
    transform: translateX(0) translateY(10px);
    opacity: 0;
    visibility: hidden;
}

.dropdown.dropdown-right.open .dropdown-content {
    display: flex !important;
    flex-direction: column;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(0) translateY(0) !important;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-size: 14px;
    transition: var(--transition);
}

@media (hover: hover) and (pointer: fine) {
    .dropdown-item:hover {
        color: var(--text-primary);
        background: var(--surface-hover);
        transform: translateX(4px);
    }
}

.dropdown-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    color: var(--accent-color);
}

.chevron {
    font-size: 10px !important;
    transition: transform 0.3s ease;
}

.dropdown:hover .chevron {
    transform: rotate(180deg);
}

/* Actions in navbar */
.search-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    padding: 0 16px;
    background: var(--surface-color);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.search-trigger:hover {
    border-color: var(--accent-color);
    color: var(--text-primary);
}

.shortcut-kbd {
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-family: inherit;
    color: var(--text-secondary);
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

@media (hover: hover) and (pointer: fine) {
    .icon-btn:hover {
        background: var(--surface-hover);
        border-color: var(--accent-color);
        color: var(--accent-color);
    }
}

.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

@media (hover: hover) and (pointer: fine) {
    .mobile-menu-toggle:hover {
        background: var(--surface-hover);
    }
}

/* Mobile Nav Backdrop to intercept clicks */
.mobile-nav-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    /* Just below the nav which is 1000 */
    background: transparent;
}

.mobile-nav-backdrop.active {
    display: block;
}

/* Mobile Nav Drawer */
.mobile-nav {
    display: none;
    flex-direction: column;
    gap: 10px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: slideDown 0.3s ease forwards;
    position: absolute;
    top: calc(100% + 10px);
    left: 20px;
    right: 20px;
    z-index: 1000;
    will-change: transform, opacity;

    /* Prevent overflow on landscape mobile */
    max-height: calc(100vh - 80px);
    /* Leaves room for the header */
    overflow-y: auto;
    overscroll-behavior: contain;
    /* Prevents background scrolling when menu hits the bottom */
}

.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
}

.mobile-nav-link.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
}

.mobile-nav-divider {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
    margin: 10px 0 5px 16px;
    font-weight: 600;
}

.mobile-nav-divider.toggle-more {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 16px;
    user-select: none;
    transition: color var(--transition);
}

@media (hover: hover) and (pointer: fine) {
    .mobile-nav-divider.toggle-more:hover {
        color: var(--text-primary);
        background: rgba(255, 255, 255, 0.03);
    }
}

.mobile-nav-divider.toggle-more i {
    font-size: 10px;
    transition: transform var(--transition);
}

.mobile-nav-divider.toggle-more.active i {
    transform: rotate(180deg);
}

.mobile-nav-categories {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.mobile-cat-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.02);
}

/* Active state styling */
.mobile-cat-link.active {
    color: var(--accent-color) !important;
    background: rgba(59, 130, 246, 0.08) !important;
    border-color: rgba(59, 130, 246, 0.2);
}

@media (hover: hover) and (pointer: fine) {
    .mobile-cat-link:hover {
        color: var(--text-primary);
        background: rgba(255, 255, 255, 0.05);
    }
}

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

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

/* Hero Section */
.hero-section {
    text-align: center;
    padding: var(--space-xl) var(--space-md) var(--space-lg);
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: clamp(1.75rem, 5vw + 0.5rem, 3.5rem);
    font-weight: 800;
    margin-bottom: var(--space-sm);
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.15;
}

.hero-desc {
    color: var(--text-secondary);
    font-size: clamp(0.9rem, 2vw + 0.4rem, 1.0625rem);
    line-height: 1.6;
}

/* Category Filters Pills */
.category-filters-container {
    width: 100%;
    margin-bottom: 30px;
    overflow: hidden;
}

.category-filters {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 5px;
    scrollbar-width: none;
    /* Firefox */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.category-filters::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.filter-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 30px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition);
    flex-shrink: 0;
}

.filter-pill.active {
    color: var(--text-primary);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

@media (hover: hover) and (pointer: fine) {
    .filter-pill:hover {
        color: var(--text-primary);
        border-color: var(--accent-color);
        transform: translateY(-1px);
    }
}

.filter-pill.active {
    background: var(--accent-gradient);
    color: #ffffff !important;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.25);
}

.filter-pill i {
    font-size: 14px;
}

.content-area {
    padding: 20px 0;
    flex: 1;
}

/* Tool View */
.tool-view {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.tool-view.active {
    display: block;
}

.tool-header {
    margin-bottom: 40px;
}

.tool-title {
    font-size: clamp(1.25rem, 4vw, 2rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.tool-desc {
    color: var(--text-secondary);
    font-size: clamp(0.875rem, 2vw, 1rem);
    max-width: 600px;
    line-height: 1.6;
}

/* Tool Container styling */
.tool-container {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 4vw, 2rem);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    width: 100%;
    box-sizing: border-box;
}

/* File Upload Area */
.file-drop-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: clamp(1.5rem, 5vw, 2.5rem);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.02);
    width: 100%;
    box-sizing: border-box;
}

.file-drop-area:hover,
.file-drop-area.dragover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
}

.file-drop-area i {
    font-size: 48px;
    color: var(--accent-color);
    margin-bottom: 16px;
}

/* Buttons */
.btn {
    padding: clamp(0.5rem, 2vw, 0.75rem) clamp(1rem, 3vw, 1.5rem);
    height: auto;
    min-height: 2.75rem; /* 44px accessible tap target */
    border-radius: var(--radius);
    border: none;
    font-weight: 600;
    font-size: clamp(0.875rem, 2vw, 1rem);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    user-select: none;
    outline: none;
    white-space: normal;  /* allow text to wrap inside button */
}

.btn:focus-visible {
    box-shadow: var(--focus-ring) !important;
}

.btn:active {
    transform: scale(0.97) !important;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

@media (hover: hover) and (pointer: fine) {
    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    }
}

.btn-primary:active {
    transform: translateY(0) scale(0.97) !important;
}

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

@media (hover: hover) and (pointer: fine) {
    .btn-secondary:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Inputs */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.input-group input,
.input-group select,
.input-group textarea,
.custom-select,
.custom-input {
    width: 100%;
    padding: clamp(0.5rem, 2vw, 0.75rem) clamp(0.75rem, 2vw, 1rem);
    min-height: 2.75rem; /* 44px accessible tap target */
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: clamp(0.875rem, 2vw, 1rem);
    font-family: 'Outfit';
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
    outline: none;
    box-sizing: border-box;
}

select,
.custom-select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    padding-right: 40px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233b82f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 16px center !important;
    background-size: 16px !important;
    cursor: pointer !important;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus,
.custom-select:focus,
.custom-input:focus {
    border-color: var(--accent-color);
    box-shadow: var(--focus-ring);
    background: var(--surface-hover);
}

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

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.flex {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.gap-4 {
    gap: var(--space-sm);
}

/* Fluid Typography â€” mobile-first, no breakpoints needed */
h1 { font-size: clamp(1.5rem, 5vw + 0.5rem, 3rem); line-height: 1.15; }
h2 { font-size: clamp(1.25rem, 4vw + 0.25rem, 2.5rem); line-height: 1.2; }
h3 { font-size: clamp(1.1rem, 3vw, 2rem); line-height: 1.25; }
h4, h5, h6 { font-size: clamp(0.9375rem, 2.5vw, 1.5rem); line-height: 1.3; }

/* Override inline min-width/height in tool panels */
#toolSpecificContent [style*="min-width"] { min-width: 0 !important; }
#toolSpecificContent [style*="height"] { height: auto !important; }

/* Ensure tool panels use full width */
#toolSpecificContent .tool-container,
#toolSpecificContent .control-panel,
#toolSpecificContent .preview-panel {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 100% !important;
}

/* Grid for cards â€” auto-fill with minmax: zero media queries needed */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: clamp(0.75rem, 2.5vw, 1.5rem);
}

.tool-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: clamp(1rem, 3vw, 1.5rem);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    text-decoration: none;
    color: inherit;
    position: relative;
    height: auto;  /* never fixed height */
    min-height: 0;
}

@media (hover: hover) and (pointer: fine) {
    .tool-card:hover {
        transform: translateY(-5px);
        border-color: var(--accent-color);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    }
}

.tool-icon {
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    min-height: 3rem;
    flex-shrink: 0;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.tool-card h3 {
    font-size: clamp(0.9375rem, 2vw, 1.25rem);
    font-weight: 600;
    line-height: 1.3;
}

.tool-card p {
    color: var(--text-secondary);
    font-size: clamp(0.8rem, 1.8vw, 0.9375rem);
    line-height: 1.5;
}

/* Card Favorite Star Button */
.fav-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: var(--transition);
    z-index: 2;
    padding: 5px;
}

body.theme-light .fav-btn {
    color: rgba(0, 0, 0, 0.15);
}

@media (hover: hover) and (pointer: fine) {
    .fav-btn:hover {
        color: #eab308;
        transform: scale(1.2);
    }
}

.fav-btn.active {
    color: #eab308;
    filter: drop-shadow(0 0 4px rgba(234, 179, 8, 0.4));
}

/* Recently Used Chips */
.recent-section {
    max-width: 1400px;
    margin: 0 auto 30px auto;
    padding: 0 5px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.recent-chips {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.recent-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
}

@media (hover: hover) and (pointer: fine) {
    .recent-chip:hover {
        border-color: var(--accent-color);
        transform: translateY(-1px);
    }
}

.recent-chip i {
    color: var(--accent-color);
}

/* Command Palette Modal */
.cmd-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.cmd-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.cmd-modal {
    width: 100%;
    max-width: 600px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.cmd-modal-overlay.active .cmd-modal {
    transform: translateY(0);
}

.cmd-modal-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    gap: 15px;
}

.cmd-search-icon {
    font-size: 18px;
    color: var(--text-secondary);
}

#cmdSearchInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
}

.cmd-close-btn {
    font-size: 28px;
    /* Slightly larger visual */
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);

    /* Enforce a minimum 44x44px touch target */
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: -10px;
    /* Offset the padding so it aligns flush with the right edge */
}

button.cmd-close-btn {
    background: none;
    border: none;
    font-family: inherit;
    line-height: 1;
    padding: 0;
}

.cmd-close-btn:hover {
    color: var(--text-primary);
}

.cmd-modal-results {
    max-height: 380px;
    overflow-y: auto;
    padding: 10px;
}

.cmd-result-group-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 8px 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.cmd-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.cmd-result-item:hover,
.cmd-result-item.selected {
    background: var(--surface-hover);
}

.cmd-result-item.selected {
    border-left: 3px solid var(--accent-color);
}

.cmd-result-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cmd-result-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.cmd-result-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.cmd-result-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.cmd-result-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.cmd-modal-footer {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--border-color);
    gap: 15px;
}

.cmd-footer-tip {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.cmd-footer-tip kbd {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 1px 4px;
}

/* Responsiveness adjustments */
@media (max-width: 1024px) {

    #navHomeBtn,
    #navFavoritesBtn,
    .nav-right .dropdown {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .navbar-container {
        padding: 10px 10px 5px 10px;
    }

    .navbar {
        padding: 8px 12px;
    }

    .brand-text {
        font-size: 18px;
    }

    .search-trigger span,
    .search-trigger kbd {
        display: none;
    }

    .search-trigger {
        width: 40px;
        /* Lock width */
        height: 40px;
        /* Lock height */
        padding: 0;
        /* Remove padding */
        justify-content: center;
        /* Center the icon */
        border-radius: 50%;
    }
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 28px;
    }

    .hero-desc {
        font-size: 14px;
    }

    .hero-section {
        padding: 30px 10px 20px 10px;
    }

    .content-area {
        padding: 20px 0;
    }

    .tools-grid {
        /* If screen is < 240px, shrink to 100% width safely */
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
        gap: 16px;
    }

    .cmd-modal {
        max-width: 95% !important;
        margin: 0 auto !important;
    }

    .cmd-modal-overlay {
        padding-top: 10px !important;
        /* Remove the 15vh gap */
        align-items: flex-start !important;
    }

    .cmd-modal-results {
        max-height: 250px !important;
        /* Shrink max-height to respect keyboard space */
    }

    /* Prevent iOS Safari & Android Auto-Zoom */
    input,
    select,
    textarea,
    .custom-input,
    #cmdSearchInput {
        font-size: 16px !important;
    }

    /* Reduce blur stress on older/mobile GPUs */
    .navbar {
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
    }

    body.theme-dark .navbar {
        background: rgba(23, 32, 51, 0.85) !important;
    }

    body.theme-light .navbar {
        background: rgba(255, 255, 255, 0.85) !important;
    }
}

/* Footer styling */
.app-footer {
    margin-top: 60px;
    padding: 30px 20px;
    padding-bottom: calc(30px + env(safe-area-inset-bottom));
    /* Push footer links above iOS home swipe bar */
    border-top: 1px solid var(--border-color);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px 30px;
}

.footer-link,
.footer-link:visited {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.footer-link i {
    font-size: 16px;
}

.copyright {
    font-size: 13px;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* Loading Overlay Styling */
.tool-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
    border-radius: var(--radius);
    color: var(--accent-color);
    backdrop-filter: blur(4px);
}

.tool-loading-overlay i {
    font-size: 40px;
    margin-bottom: 15px;
}

.tool-loading-overlay p {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 600;
}

/* Global Mobile/Tablet Fixes for Tool SEO Content & Collapsible V-Cards */
@media (max-width: 1024px) {
    .seo-timeline-container {
        padding: 20px 15px !important;
    }

    .vertical-timeline::before {
        left: 28px !important;
    }

    .v-card {
        padding: 24px 20px 24px 70px !important;
    }

    .v-icon {
        left: 8px !important;
        width: 40px !important;
        height: 40px !important;
        top: 24px !important;
        font-size: 16px !important;
        box-shadow: 0 0 0 6px var(--bg-color) !important;
    }

    .v-card-chevron {
        right: 16px !important;
        top: 28px !important;
        width: 30px !important;
        height: 30px !important;
    }
}

@media (max-width: 600px) {
    .vertical-timeline::before {
        left: 20px !important;
    }

    .v-card {
        padding: 18px 16px 18px 52px !important;
    }

    .v-icon {
        left: 6px !important;
        width: 28px !important;
        height: 28px !important;
        top: 18px !important;
        font-size: 12px !important;
        border-radius: 8px !important;
        box-shadow: 0 0 0 4px var(--bg-color) !important;
    }

    .v-card-chevron {
        right: 12px !important;
        top: 20px !important;
        width: 24px !important;
        height: 24px !important;
        font-size: 10px !important;
    }

    .v-card.collapsible-v-card h3 {
        padding-right: 32px !important;
        font-size: 17px !important;
    }
}

/* Custom Global Stepper Component for Number Inputs */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

.custom-stepper-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    height: 40px;
    transition: border 0.2s, box-shadow 0.2s;
    width: 100%;
}

.custom-stepper-wrapper:focus-within {
    border-color: var(--accent-color);
}

.custom-stepper-wrapper input[type="number"] {
    border: none !important;
    background: transparent !important;
    border-radius: 0 !important;
    text-align: center;
    padding-left: 0 !important;
    padding-right: 0 !important;
    flex: 1;
    min-width: 0;
    outline: none !important;
    box-shadow: none !important;
}

.stepper-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    width: 40px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    user-select: none;
    flex-shrink: 0;
}

.stepper-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.04);
}

.stepper-btn:active {
    background: rgba(0, 0, 0, 0.08);
}

/* Custom Number Input wrapper and button styling */
.number-input-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    /* This keeps the buttons cleanly inside the rounded corners */
    height: 40px;
}

.number-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
}

.number-input-wrapper input {
    flex: 1;
    text-align: center;
    border: none;
    outline: none;
}

/* Step Icon container and alignment rules */
.step-card-container {
    padding-left: 24px;
    /* Increase this to push contents to the right */
    position: relative;
    overflow: hidden;
    /* Forces the blue box to obey the parent's rounded corners */
}

.step-icon-blue {
    margin-left: 0;
    position: relative;
    left: 0;
}

/* Premium Collapsible V-Cards */
.v-card.collapsible-v-card {
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.v-card.collapsible-v-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.v-card-chevron {
    position: absolute;
    right: 24px;
    top: 30px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease, color 0.2s ease;
    z-index: 3;
}

.v-card.collapsible-v-card:hover .v-card-chevron {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.v-card.collapsible-v-card.collapsed .v-card-chevron {
    transform: none;
}

.v-card.collapsible-v-card:not(.collapsed) .v-card-chevron {
    transform: rotate(180deg);
}

/* Hide all children when collapsed, except .v-icon, h3, and the chevron */
.v-card.collapsible-v-card.collapsed>*:not(.v-icon):not(h3):not(.v-card-chevron) {
    display: none !important;
}

/* Make h3 occupy less space on the right to prevent overlap with chevron */
.v-card.collapsible-v-card h3 {
    padding-right: 40px;
}

@media (max-width: 768px) {
    .v-card-chevron {
        right: 16px;
        top: 22px;
        width: 28px;
        height: 28px;
    }
}


@media (max-width: 768px) {
    .tool-header {
        margin-bottom: 24px !important;
    }

    .tool-title {
        font-size: 24px !important;
    }

    .tool-desc {
        font-size: 14px !important;
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    .tool-title {
        font-size: 20px !important;
    }

    .tool-desc {
        font-size: 13px !important;
    }
}

/* SEO Timeline Header Responsive Overrides */
.seo-header h2 {
    font-size: 28px !important;
    font-weight: 800;
    line-height: 1.3;
}

.seo-header p {
    font-size: 15px !important;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .seo-header h2 {
        font-size: 22px !important;
    }

    .seo-header p {
        font-size: 13px !important;
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    .seo-header h2 {
        font-size: 18px !important;
    }
}

/* PWA App Shell Mobile Padding Optimizations */
@media (max-width: 600px) {
    .tool-container {
        padding: 16px !important;
        border-radius: var(--radius) !important;
    }

    .main-container {
        padding: 0 12px !important;
    }

    .workspace-grid {
        gap: 16px !important;
    }

    .cmd-modal-footer {
        display: none !important;
    }
}

/* Premium Material Ripple Effect Styles */
.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: ripple-animation 0.6s cubic-bezier(0.1, 0.8, 0.3, 1);
    pointer-events: none;
    z-index: 99;
}

/* Contrast ripples for light theme buttons/links */
body.theme-light .btn-secondary .ripple-effect,
body.theme-light .nav-link .ripple-effect,
body.theme-light .filter-pill .ripple-effect,
body.theme-light .mobile-cat-link .ripple-effect,
body.theme-light .mobile-nav-link .ripple-effect,
body.theme-light .fav-btn .ripple-effect {
    background: rgba(0, 0, 0, 0.12);
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* PWA Safe Area Notch Clash Fix */
@media (max-width: 1024px) {
    .navbar-container {
        padding: calc(10px + env(safe-area-inset-top)) 10px 5px 10px;
    }
}

/* Sticky Header + Virtual Keyboard Screen Crush Fix */
@media (max-width: 768px) {
    body:has(.tool-view.active #toolSpecificContent) .navbar-container {
        position: relative;
    }
}

/* Category Filters Horizontal Scroll Cutoff Fix */
.category-filters::after {
    content: '';
    display: block;
    padding-right: 15px;
}

/* Responsive SW Update Banner Styles */
.pwa-update-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    color: #f8fafc;
    padding: 16px 20px;
    border-radius: 12px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 16px;
    font-family: system-ui, -apple-system, sans-serif;
}

@media (max-width: 600px) {
    .pwa-update-banner {
        bottom: calc(16px + env(safe-area-inset-bottom));
        /* Keep the banner safe from iOS swipe zone */
        right: 16px;
        left: 16px;
        width: calc(100% - 32px);
        justify-content: space-between;
    }
}

button,
.btn,
.icon-btn,
.nav-link,
.mobile-menu-toggle,
.mobile-nav-link,
.filter-pill,
.stepper-btn,
.fav-btn {
    /* Instantly registers taps without the 300ms delay */
    touch-action: manipulation;
}

/* Native App Illusion Breaker: Accidental Text Selection Fix */
.filter-pill,
.tool-card,
.nav-link,
.mobile-nav-link,
.recent-chip,
.stepper-btn {
    -webkit-user-select: none;
    /* Safari/iOS */
    user-select: none;
    /* Standard */
    -webkit-touch-callout: none;
    /* Disables the long-press popup menu on iOS */
}

/* Hide raw SEO links from human users before JS loads */
.seo-link {
    display: none !important;
}

/* Fallback: Show them only if the user's browser has JavaScript completely disabled */
noscript .seo-link {
    display: block !important;
}

/* ==========================================================================
   ACCESSIBILITY & FLUID TYPOGRAPHY OVERRIDES 
   (Fixes text overflow on large system fonts and small screens)
   ========================================================================== */

/* 1. Convert Fixed Heights to Min-Heights */
/* Allows buttons and nav links to expand vertically if the text wraps to two lines */
/* NOTE: .search-trigger and .icon-btn are EXCLUDED â€” they need fixed 40px sizing on mobile */
.btn,
.nav-link,
.custom-stepper-wrapper {
    min-height: 44px;
    height: auto;
    padding-top: 10px;
    padding-bottom: 10px;
    white-space: normal;
}

/* 2. Fix Icon Buttons (Circles/Squares) */
/* Keep fixed sizing so they stay perfectly circular; only add flex centering */
.icon-btn,
.mobile-menu-toggle,
.grid-menu-btn {
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* 3. Prevent Text Blowout in Cards & Headings */
/* Forces long words or massive text to break cleanly instead of spilling out */
.tool-title,
.tool-desc,
.tool-card h3,
.tool-card p,
.hero-title,
.hero-desc,
.section-title {
    word-break: break-word;
    overflow-wrap: break-word;
    -webkit-hyphens: auto;
    hyphens: auto;
}

/* 4. Fluid Mobile Nav Grid */
/* Replaces the strict 'repeat(2, 1fr)' which crushes text on narrow phones */
.mobile-nav-categories {
    display: grid;
    /* Adapts to 1 column on ultra-narrow phones, 2 on normal phones */
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
    gap: 10px;
}

/* 5. Mobile Nav Link Wrapping */
/* Ensures long category names in the mobile drawer wrap neatly */
.mobile-nav-link,
.mobile-cat-link {
    height: auto;
    min-height: 44px;
    white-space: normal;
    line-height: 1.4;
    align-items: flex-start;
    /* Aligns icon with the top line if text wraps */
}

/* Fix Icon alignment when text wraps to multiple lines */
.mobile-nav-link i,
.mobile-cat-link i {
    margin-top: 3px;
}

/* ==========================================================================
   FOUC & LAZY PAINT BLANK GRAPHICS SOLUTION
   (Eliminates the empty 1-2 second lag on initial app grid mounting)
   ========================================================================== */

/* 1. Pre-size the grid area so it doesn't cause layout shifting */
.tools-grid {
    content-visibility: auto;
    contain-intrinsic-size: 1000px;
    /* Estimates rendering boundary to prevent page jumping */
}

/* 2. Build CSS Skeleton Backdrops directly into the empty parent grid container */
#toolsGrid:empty {
    display: grid;
    /* Respects your responsive column configurations naturally */
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 24px;
    width: 100%;
    min-height: 600px;
    pointer-events: none;
}

/* 3. Generate 6 pseudo-elements that act as dark premium placeholder cards while JS loads */
#toolsGrid:empty::before,
#toolsGrid:empty::after {
    content: "";
    height: 160px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    animation: pulseSkeleton 1.5s ease-in-out infinite;
}

/* Add extra placeholders to simulate a real grid dashboard */
#toolsGrid:empty {
    background-image:
        linear-gradient(var(--surface-color) 160px, transparent 0),
        linear-gradient(var(--surface-color) 160px, transparent 0),
        linear-gradient(var(--surface-color) 160px, transparent 0),
        linear-gradient(var(--surface-color) 160px, transparent 0);
    background-size: 100% 100%;
    background-repeat: no-repeat;
}

/* 4. A gentle shimmering fade animation to transition seamlessly when cards attach */
@keyframes pulseSkeleton {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 0.3;
    }
}

/* Ensure smooth opacity fading when .animate-fade-in elements are injected by app.js */
.tools-grid .tool-card {
    will-change: transform, opacity;
}

/* ==========================================================================
   STABLE INITIAL LOAD
   (Hides raw text instantly and prevents the footer from jumping up)
   ========================================================================== */

/* 1. Give the grid a minimum height so the screen doesn't collapse while empty */
.tools-grid {
    min-height: 60vh;
}

/* 2. Hide the raw HTML text links from human eyes instantly */
.seo-link {
    display: none !important;
}

/* 3. Fallback: Only show the raw links if JavaScript is completely disabled */
noscript .seo-link {
    display: block !important;
    padding: 10px;
    background: var(--surface-color);
    border-radius: var(--radius);
}

/* ==========================================================================
   FINAL MOBILE RESPONSIVE FIXES 
   (Fixes Stepper SVG Overflow & File Name Text Truncation)
   ========================================================================== */

/* 1. FIX THE STEPPER SVG OVERFLOW */
.number-input-wrapper {
    padding: 0 !important;
    /* Removes the padding that crushed the SVGs */
    height: 48px !important;
    /* Restores a stable, tappable height */
}

.stepper-btn {
    flex-shrink: 0 !important;
    /* Prevents the button from being squished */
    width: 48px !important;
    min-width: 48px !important;
}

.stepper-btn svg {
    flex-shrink: 0;
    max-width: 16px;
    height: auto;
    display: block;
}

/* 2. FIX FILE NAME TEXT OVERFLOW (e.g. "download (1).jpg") */
#fileList>div {
    display: flex !important;
    width: 100%;
    box-sizing: border-box;
}

#fileList>div>div {
    min-width: 0;
    /* CRITICAL: Allows flex children to truncate text */
    overflow: hidden;
}

#fileList>div>div>p:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Adds the "..." when text is too long */
    width: 100%;
}

/* 3. PREVENT INPUT CRUSHING ON ULTRA-NARROW PHONES (< 400px) */
@media (max-width: 400px) {

    /* Targets the Image Compressor Target Size layout */
    .input-group>div[style*="display: flex"],
    .input-group>div[style*="display:flex"] {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .input-group>div>div[style*="display: flex"],
    .input-group>div>div[style*="display:flex"] {
        width: 100%;
    }

    /* Forces the KB/MB dropdown to stack neatly below the number input */
    .dropdown-wrapper {
        width: 100% !important;
        flex: none !important;
    }
}


/* ==========================================================================
   MODERN PWA RESPONSIVE SYSTEM
   Built with: fluid clamp(), min-width:0 flex fix, auto-fit grid,
   container-aware overrides. Zero !important hacks needed below this line.
   ========================================================================== */

/* ---------- GLOBAL OVERFLOW CONTAINMENT ---------- */
body {
    overflow-x: hidden;
    max-width: 100vw;
}

.main-container,
.tool-container,
.tool-header,
.content-area,
#toolSpecificContent,
#toolAppArea {
    overflow-x: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

/* ---------- ALL TEXT: SAFE OVERFLOW ---------- */
h1, h2, h3, h4, h5, h6, p, span, label, a, button, li {
    max-width: 100%;
    overflow-wrap: break-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

/* ---------- IMAGES & MEDIA: ALWAYS CONTAINED ---------- */
img, video, canvas, svg, iframe {
    max-width: 100%;
    height: auto;
}

/* ---------- INPUTS & SELECTS: FULL-WIDTH, FLUID ---------- */
input, select, textarea {
    max-width: 100%;
    box-sizing: border-box;
}

/* ---------- NAVBAR: FLUID FLEX ---------- */
.navbar {
    overflow: visible;
    height: auto;
    min-height: 2.75rem;
}

.nav-left {
    flex: 1 1 auto;
    min-width: 0;
}

.brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- TOOL HEADER ICON: CONTAINED ---------- */
.tool-icon,
.tool-header-icon {
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    min-height: 3rem;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.tool-header-icon i {
    font-size: inherit;
    line-height: 1;
}

/* Tool header row: flex-wrap so icon + title stay together */
.tool-header > div {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 2vw, 0.875rem);
    flex-wrap: wrap;
    min-width: 0;
}

/* ---------- TOOL PANELS: NUCLEAR MIN-WIDTH OVERRIDE ---------- */
/* JS injects inline min-width: 300px â€” this kills it globally */
#toolSpecificContent * {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

#toolSpecificContent [style*="min-width"] { min-width: 0 !important; }
#toolSpecificContent [style*="height:"]   { height: auto !important; }
#toolSpecificContent [style*="height: "]  { height: auto !important; }

/* All inline flex containers from JS: allow wrapping */
#toolSpecificContent div[style*="display: flex"],
#toolSpecificContent div[style*="display:flex"] {
    flex-wrap: wrap !important;
    min-width: 0;
    max-width: 100%;
}

#toolSpecificContent div[style*="display: flex"] > *,
#toolSpecificContent div[style*="display:flex"] > * {
    min-width: 0;
    flex-shrink: 1;
}

/* Textareas and code: scroll locally, never break page layout */
#toolSpecificContent textarea,
#toolSpecificContent pre,
#toolSpecificContent code {
    max-width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
}

/* Workspace grid */
.workspace-grid {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

.workspace-grid > * {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* ---------- SEARCH TRIGGER: ICON-ONLY ON MEDIUM SCREENS ---------- */
@media (max-width: 1024px) {
    .search-trigger {
        width: 2.5rem;
        height: 2.5rem;
        min-width: 2.5rem;
        padding: 0;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .search-trigger span,
    .search-trigger kbd {
        display: none;
    }
}

/* ---------- MOBILE: â‰¤768px â€” STACK TOOL PANELS ---------- */
@media (max-width: 768px) {

    /* All .flex utility containers in tool content: go vertical */
    #toolSpecificContent .flex,
    #toolSpecificContent > div[style*="flex-wrap"],
    #toolSpecificContent > div[style*="display: flex"],
    #toolSpecificContent > div[style*="display:flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: var(--space-sm) !important;
    }

    /* Every direct child panel fills full width */
    #toolSpecificContent .flex > *,
    #toolSpecificContent > div[style*="flex-wrap"] > *,
    #toolSpecificContent > div[style*="display: flex"] > *,
    #toolSpecificContent > div[style*="display:flex"] > * {
        width: 100% !important;
        min-width: 0 !important;
        flex: 1 1 100% !important;
    }

    /* Workspace grid stacks vertically */
    .workspace-grid {
        flex-direction: column !important;
        gap: var(--space-sm) !important;
    }

    .workspace-grid > *,
    .control-panel,
    .preview-panel {
        width: 100% !important;
        min-width: 0 !important;
        flex: 1 1 100% !important;
    }

    /* Metrics: 2 columns on mobile */
    .metrics-widget-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-xs);
    }

    /* Stat values: fluid font */
    .metric-num {
        font-size: clamp(1rem, 5vw, 1.25rem);
    }

    .metric-tag {
        font-size: clamp(0.625rem, 2vw, 0.75rem);
        overflow-wrap: break-word;
    }

    /* Tool header: icon + title wrap to separate lines if needed */
    .tool-header > div {
        align-items: flex-start;
    }
}

/* ---------- TINY PHONE: â‰¤400px â€” FURTHER TIGHTEN ---------- */
@media (max-width: 400px) {

    /* Navbar padding shrinks */
    .navbar {
        padding: 0.375rem 0.625rem;
    }

    /* Icon buttons: min 36px tap */
    .icon-btn,
    .mobile-menu-toggle,
    .search-trigger {
        width: 2.25rem;
        height: 2.25rem;
        min-width: 2.25rem;
    }

    /* Stat grid: 1 column on ultra-narrow */
    .metrics-widget-grid {
        grid-template-columns: 1fr;
    }

    /* Input groups with inline layout: stack vertically */
    .input-group > div[style*="display: flex"],
    .input-group > div[style*="display:flex"] {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }

    .dropdown-wrapper {
        width: 100%;
    }
}
