/* ===== CSS Variables & Reset ===== */
:root {
    --primary: #1557D6;
    --primary-dark: #0B2A7A;
    --secondary: #6D28D9;
    --accent: #22C55E;
    --bg: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-dark: #0F172A;
    --bg-card-dark: #1E293B;
    --text: #111827;
    --text-secondary: #64748B;
    --text-dark: #F1F5F9;
    --text-dark-secondary: #94A3B8;
    --border: #E2E8F0;
    --border-dark: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;
    --transition: all .3s cubic-bezier(.4,0,.2,1);
    --font: 'Inter', sans-serif;
    --max-width: 1280px;
    --header-h: 72px;
}

[data-theme="dark"] {
    --primary: #3D7DF0;
    --primary-dark: #2A63D4;
    --secondary: #8B5CF6;
    --bg: var(--bg-dark);
    --bg-card: var(--bg-card-dark);
    --text: var(--text-dark);
    --text-secondary: var(--text-dark-secondary);
    --border: var(--border-dark);
    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    transition: background .3s, color .3s;
    overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
ul { list-style: none; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* ===== Header ===== */
.site-header {
    position: sticky; top: 0; z-index: 1000;
    background: rgba(255,255,255,.88);
    backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
    height: var(--header-h);
    transition: box-shadow .25s ease, background .25s ease;
}
.site-header.scrolled { box-shadow: 0 6px 24px -12px rgba(11,42,122,.28); }
[data-theme="dark"] .site-header { background: rgba(15,23,42,.88); }
[data-theme="dark"] .site-header.scrolled { box-shadow: 0 6px 24px -10px rgba(0,0,0,.6); }

.header-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    height: var(--header-h); max-width: var(--max-width); margin: 0 auto; padding: 0 20px;
    position: relative;
}
.logo { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); flex-shrink: 0; }
.logo span { background: linear-gradient(120deg, var(--primary-dark) 0%, var(--primary) 45%, var(--secondary) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
[data-theme="dark"] .logo span { background-image: linear-gradient(120deg, #7FAEFF 0%, var(--primary) 45%, var(--secondary) 100%); }
.logo svg { width: 34px; height: 34px; flex-shrink: 0; }

.nav-menu { display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; margin: 0 auto; }
.nav-menu a {
    padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-secondary);
    font-weight: 500; font-size: .9rem; transition: var(--transition);
    white-space: nowrap;
}
.nav-menu a:hover, .nav-menu a.active { color: var(--primary); background: rgba(21,87,214,.08); }
.nav-chevron { width: 14px; height: 14px; flex-shrink: 0; opacity: .7; transition: transform .2s ease; }
.nav-dropdown-wrapper:hover .nav-dropdown-toggle .nav-chevron { transform: rotate(180deg); }

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.header-icon-btn {
    width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg-card); color: var(--text-secondary); cursor: pointer; display: flex;
    align-items: center; justify-content: center; transition: var(--transition); padding: 0;
}
.header-icon-btn svg { width: 20px; height: 20px; }
.header-icon-btn:hover, .header-icon-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(21,87,214,.06); }
.header-icon-btn:focus-visible, .nav-menu a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

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

.mobile-toggle { display: none; }
.mobile-toggle .icon-close { display: none; }
.mobile-toggle.active .icon-close { display: block; }
.mobile-toggle.active .icon-menu { display: none; }

/* Header search panel (opens under the header) */
.header-search-panel {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg); padding: 16px 20px;
}
.header-search-panel.active { display: block; animation: slideDown .2s ease; }
.header-search-form {
    display: flex; align-items: center; gap: 10px; max-width: 720px; margin: 0 auto;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-full);
    padding: 6px 6px 6px 16px; transition: var(--transition);
}
.header-search-form:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21,87,214,.15); }
.header-search-form svg { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
.header-search-form input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; color: var(--text); font-size: .95rem; padding: 8px 0; }
.header-search-form .btn { border-radius: var(--radius-full); flex-shrink: 0; }
.header-search-panel .search-results-dropdown { position: static; max-width: 720px; margin: 10px auto 0; min-width: 0; }

/* Nav Dropdown (Mega Menu Style) */
.nav-dropdown-wrapper { position: relative; display: inline-block; }
.nav-dropdown-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding-bottom: 24px !important; margin-bottom: -16px; }
.nav-dropdown-menu {
    position: absolute; top: calc(100% + 15px); left: 50%; transform: translateX(-50%) translateY(10px);
    background: #ffffff; border: 1px solid var(--border); border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08); min-width: 300px; padding: 24px;
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); z-index: 9999;
}
[data-theme="dark"] .nav-dropdown-menu { background: #1e293b; border-color: #334155; box-shadow: 0 20px 40px rgba(0,0,0,0.4); }
.nav-dropdown-menu.mega-menu { display: block; width: max-content; min-width: 460px; max-width: min(720px, calc(100vw - 40px)); }
.nav-dropdown-menu.mega-menu > div { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; }
.nav-dropdown-menu:not(.mega-menu) { display: block; width: max-content; min-width: 260px; max-width: calc(100vw - 40px); padding: 16px; }
/* Tool rows: compact spacing so the name gets the width (beats the generic .nav-dropdown-menu a rule) */
.nav-dropdown-menu a.atc-tool-link { padding: 8px 8px !important; gap: 10px !important; font-size: .875rem !important; font-weight: 500; }
.nav-dropdown-menu:not(.all-tools-mega-menu) a.atc-tool-link { padding: 9px 28px 9px 10px !important; font-size: .92rem !important; }
/* Category dropdowns: each tool name on one line, using the full menu width */
.nav-dropdown-menu:not(.all-tools-mega-menu) .atc-tool-link,
.nav-dropdown-menu:not(.all-tools-mega-menu) .atc-tool-name { white-space: nowrap !important; }
/* Keep the last two dropdowns inside the screen */
.nav-menu > .nav-dropdown-wrapper:nth-last-child(-n+2) .nav-dropdown-menu:not(.all-tools-mega-menu) { left: auto; right: 0; transform: translateY(10px); }
.nav-menu > .nav-dropdown-wrapper:nth-last-child(-n+2):hover .nav-dropdown-menu:not(.all-tools-mega-menu) { transform: translateY(0); }
.nav-menu > .nav-dropdown-wrapper:nth-last-child(-n+2) .nav-dropdown-menu:not(.all-tools-mega-menu)::before { left: auto; right: 40px; transform: rotate(45deg); }
.nav-dropdown-wrapper:hover .nav-dropdown-menu { opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.nav-dropdown-menu::before {
    content: ''; position: absolute; top: -7px; left: 50%; transform: translateX(-50%) rotate(45deg);
    width: 14px; height: 14px; background: #ffffff; border-top: 1px solid var(--border); border-left: 1px solid var(--border);
}
[data-theme="dark"] .nav-dropdown-menu::before { background: #1e293b; border-color: #334155; }
.nav-dropdown-menu a {
    display: flex !important; align-items: center; gap: 16px; padding: 12px 16px !important;
    color: var(--text) !important; border-radius: 10px; font-size: 0.95rem !important;
    transition: all 0.2s ease; text-decoration: none; font-weight: 600;
}
.nav-dropdown-menu a:hover { background: rgba(21,87,214,0.06) !important; color: var(--primary) !important; transform: translateX(4px); }
.nav-dropdown-menu .dropdown-icon {
    display: flex; align-items: center; justify-content: center; width: 40px; height: 40px;
    background: linear-gradient(135deg, rgba(21,87,214,0.1), rgba(109,40,217,0.1));
    border-radius: 10px; color: var(--primary); flex-shrink: 0;
}
[data-theme="dark"] .nav-dropdown-menu .dropdown-icon { background: linear-gradient(135deg, rgba(21,87,214,0.2), rgba(109,40,217,0.2)); }
.nav-dropdown-menu .dropdown-icon svg { width: 22px !important; height: 22px !important; max-width: 22px; stroke: currentColor; fill: none; stroke-width: 2; }

/* All Tools Mega Menu */
.nav-dropdown-wrapper.has-mega-menu {
    position: static;
}

.nav-dropdown-menu.all-tools-mega-menu {
    position: absolute;
    top: 100%;
    left: 20px;
    right: 20px;
    width: auto;
    max-width: none;
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 16px;
    padding: 28px 20px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transform: translateY(10px);
    overflow: visible;
}

.nav-dropdown-menu.all-tools-mega-menu::before {
    display: none;
}

.nav-dropdown-wrapper:hover .nav-dropdown-menu.all-tools-mega-menu {
    transform: translateY(0);
}

.all-tools-col {
    padding: 0;
    border-right: none;
}

/* Category header row */
.atc-header {
    display: flex !important;
    align-items: center;
    gap: 10px;
    font-size: .9rem !important;
    font-weight: 700 !important;
    color: var(--text) !important;
    margin-bottom: 16px !important;
    padding-bottom: 12px !important;
    border-bottom: 2px solid transparent !important;
    border-image: linear-gradient(90deg, var(--c1), var(--c2)) 1 !important;
}

.atc-cat-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 8px; font-size: 1rem;
    background: linear-gradient(135deg, var(--c1), var(--c2));
    color: #ffffff;
    flex-shrink: 0;
}

/* Tool link rows */
.atc-tool-link {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 8px !important;
    border-radius: 8px !important;
    margin-bottom: 4px !important;
    color: var(--text-secondary) !important;
    font-size: .85rem !important;
    font-weight: 500 !important;
    transition: all .2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    text-decoration: none !important;
    position: relative;
    white-space: normal !important;
}

.atc-tool-name {
    flex: 1;
    white-space: normal !important;
    line-height: 1.3;
}

.atc-tool-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 7px;
    font-size: .85rem; flex-shrink: 0;
    background: color-mix(in srgb, var(--c1) 12%, transparent);
    color: var(--c1);
    transition: all .2s ease;
}

/* Tool icons take the category color instead of each icon's own color */
.atc-tool-icon svg { width: 16px; height: 16px; stroke: currentColor; }

.atc-arrow {
    position: absolute; right: 6px; top: 50%; margin-top: -.6em; line-height: 1.2;
    opacity: 0; font-size: .8rem;
    transition: opacity .15s, transform .15s;
    transform: translateX(-4px);
    color: var(--c1);
}

.atc-tool-link:hover {
    background: color-mix(in srgb, var(--c1) 8%, transparent) !important;
    color: var(--text) !important;
    transform: translateX(3px) !important;
}

.atc-tool-link:hover .atc-tool-icon {
    background: var(--c1);
    color: #ffffff;
    transform: scale(1.05);
}

.atc-tool-link:hover .atc-arrow {
    opacity: 1; transform: translateX(0);
}



/* Mobile nav (slide-in drawer) */
.mobile-nav-overlay {
    position: fixed; inset: var(--header-h) 0 0 0; background: rgba(8,15,40,.5);
    opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s; z-index: 998;
}
.mobile-nav-overlay.active { opacity: 1; visibility: visible; }
.mobile-nav {
    position: fixed; top: var(--header-h); right: 0; bottom: 0; width: min(380px, 100%);
    background: var(--bg-card); border-left: 1px solid var(--border); z-index: 999;
    padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    transform: translateX(100%); visibility: hidden;
    transition: transform .28s cubic-bezier(.4,0,.2,1), visibility .28s;
    box-shadow: -16px 0 40px -20px rgba(0,0,0,.35);
}
.mobile-nav.active { transform: translateX(0); visibility: visible; }
.mobile-nav-search {
    display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 0 14px;
}
.mobile-nav-search:focus-within { border-color: var(--primary); }
.mobile-nav-search svg { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
.mobile-nav-search input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; color: var(--text); font-size: 1rem; padding: 13px 0; }
.mobile-nav-links > a, .mobile-nav-group > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 48px; padding: 12px 14px; color: var(--text); font-weight: 600; font-size: 1rem;
    border-radius: 10px; cursor: pointer; list-style: none;
}
.mobile-nav-group > summary::-webkit-details-marker { display: none; }
.mobile-nav-links > a:hover, .mobile-nav-group > summary:hover { background: rgba(21,87,214,.08); color: var(--primary); }
.mobile-nav-group[open] > summary { color: var(--primary); }
.mobile-nav-group[open] > summary .nav-chevron { transform: rotate(180deg); }
.mobile-nav-group .nav-chevron { width: 18px; height: 18px; }
.mobile-nav-sub { margin: 2px 0 8px 14px; padding-left: 12px; border-left: 2px solid var(--border); }
.mobile-nav-sub a {
    display: flex; align-items: center; min-height: 44px; padding: 10px 12px;
    color: var(--text-secondary); font-size: .95rem; font-weight: 500; border-radius: 8px;
}
.mobile-nav-sub a:hover { background: rgba(21,87,214,.06); color: var(--primary); }
.mobile-nav-sub a.mobile-nav-all { color: var(--primary); font-weight: 600; }

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

/* Search dropdown */
.search-results-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; margin-top: 8px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); max-height: 400px; overflow-y: auto; display: none; z-index: 100;
    min-width: 320px;
}
.search-results-dropdown.active { display: block; }
.search-result-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    border-bottom: 1px solid var(--border); cursor: pointer; transition: var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: rgba(21,87,214,.05); }
.search-result-item .sri-icon { font-size: 1.5rem; width: 40px; text-align: center; }
.search-result-item .sri-info h4 { font-size: .9rem; font-weight: 600; }
.search-result-item .sri-info p { font-size: .8rem; color: var(--text-secondary); }

/* ===== Hero Section ===== */
.hero {
    padding: 80px 0 60px; text-align: center;
    background: linear-gradient(135deg, rgba(21,87,214,.05) 0%, rgba(109,40,217,.05) 50%, rgba(34,197,94,.05) 100%);
    position: relative; overflow: hidden;
}
.hero::before {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(21,87,214,.06) 0%, transparent 50%),
                radial-gradient(circle at 70% 50%, rgba(109,40,217,.06) 0%, transparent 50%);
    animation: heroFloat 20s ease-in-out infinite;
}
@keyframes heroFloat { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-20px, -10px); } }

.hero-content { position: relative; z-index: 1; }
.hero h1 {
    font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; line-height: 1.2; margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.hero p { font-size: 1.15rem; color: var(--text-secondary); max-width: 600px; margin: 0 auto 32px; }

.hero-search {
    max-width: 560px; margin: 0 auto 24px; position: relative;
}
.hero-search input {
    width: 100%; padding: 16px 60px 16px 24px; border: 2px solid var(--border);
    border-radius: var(--radius-full); font-size: 1rem; background: var(--bg-card);
    color: var(--text); outline: none; transition: var(--transition);
    box-shadow: var(--shadow-md);
}
.hero-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(21,87,214,.15); }
.hero-search button {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 44px; height: 44px; border: none; border-radius: 50%;
    background: var(--primary); color: #fff; cursor: pointer; font-size: 1.1rem;
    transition: var(--transition);
}
.hero-search button:hover { background: var(--primary-dark); transform: translateY(-50%) scale(1.05); }

.hero-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.hero-tags a {
    padding: 6px 14px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-full); font-size: .8rem; color: var(--text-secondary);
    transition: var(--transition);
}
.hero-tags a:hover { border-color: var(--primary); color: var(--primary); background: rgba(21,87,214,.05); }

/* ===== Section Styles ===== */
.section { padding: 60px 0; }
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 32px; flex-wrap: wrap; gap: 12px;
}
.section-header h2, .section-header h1 { font-size: 1.75rem; font-weight: 700; }
.section-header .view-all {
    padding: 8px 20px; border: 1px solid var(--border); border-radius: var(--radius-full);
    color: var(--text-secondary); font-size: .875rem; font-weight: 500; transition: var(--transition);
}
.section-header .view-all:hover { border-color: var(--primary); color: var(--primary); }

/* ===== Tool Cards Grid ===== */
.tools-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
}
.tool-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; transition: var(--transition); position: relative; overflow: hidden; cursor: pointer;
}
.tool-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transform: scaleX(0); transition: transform .3s ease; transform-origin: left;
}
.tool-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: transparent; }
.tool-card:hover::before { transform: scaleX(1); }

.tool-card .tc-icon {
    width: 48px; height: 48px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(21,87,214,.1), rgba(109,40,217,.1));
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; margin-bottom: 16px;
}
.tc-img-wrap {
    width: 72px; height: 72px; border-radius: 16px; overflow: hidden;
    margin-bottom: 16px; box-shadow: 0 6px 20px rgba(0,0,0,.13);
    transition: var(--transition); flex-shrink: 0;
}
.tc-img-wrap img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    transition: transform .35s ease;
}
.tool-card:hover .tc-img-wrap { box-shadow: 0 10px 28px rgba(0,0,0,.2); }
.tool-card:hover .tc-img-wrap img { transform: scale(1.1); }
.tool-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.tool-card p { font-size: .85rem; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.5; }
.tool-card .tc-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px;
    background: var(--primary); color: #fff; border-radius: var(--radius-sm);
    font-size: .85rem; font-weight: 500; transition: var(--transition);
}
.tool-card .tc-btn:hover { background: var(--primary-dark); color: #fff; transform: translateX(2px); }

/* ===== Categories Section ===== */
.categories-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.category-card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 28px; text-align: center; transition: var(--transition); cursor: pointer; position: relative; overflow: hidden;
}
.category-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transform: scaleX(0); transition: transform .3s ease; transform-origin: left;
}
.category-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: transparent; }
.category-card:hover::before { transform: scaleX(1); }
.category-card .cc-icon { font-size: 2.5rem; margin-bottom: 12px; }
.cc-img-wrap {
    width: 90px; height: 90px; margin: 0 auto 16px;
    border-radius: 20px; overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    transition: var(--transition);
}
.cc-img-wrap img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    transition: transform .4s ease;
}
.category-card:hover .cc-img-wrap { box-shadow: 0 12px 32px rgba(0,0,0,.18); }
.category-card:hover .cc-img-wrap img { transform: scale(1.08); }
.category-card h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.category-card p { font-size: .85rem; color: var(--text-secondary); margin-bottom: 12px; }
.category-card .cc-count {
    display: inline-block; padding: 4px 12px; background: rgba(21,87,214,.08);
    color: var(--primary); border-radius: var(--radius-full); font-size: .8rem; font-weight: 500;
}

/* ===== Tool Page ===== */
.tool-page { padding: 40px 0; }
.tool-page-header { margin-bottom: 32px; }
.tool-page-header h1 { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.tool-page-header p { color: var(--text-secondary); font-size: 1.05rem; }

.tool-interface {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 32px; margin-bottom: 32px; position: relative; overflow: hidden; transition: var(--transition);
}
.tool-interface::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transform: scaleX(0); transition: transform .3s ease; transform-origin: left;
}
.tool-interface:hover { border-color: transparent; box-shadow: var(--shadow-lg); }
.tool-interface:hover::before { transform: scaleX(1); }

.tool-upload-area {
    border: 2px dashed var(--border); border-radius: var(--radius); padding: 48px;
    text-align: center; cursor: pointer; transition: var(--transition);
}
.tool-upload-area:hover { border-color: var(--primary); background: rgba(21,87,214,.03); }
.tool-upload-area .upload-icon { font-size: 3rem; margin-bottom: 12px; color: var(--primary); }
.tool-upload-area h3 { font-size: 1.1rem; margin-bottom: 4px; }
.tool-upload-area p { font-size: .85rem; color: var(--text-secondary); }

.tool-textarea {
    width: 100%; min-height: 200px; padding: 16px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg); color: var(--text);
    font-family: inherit; font-size: .95rem; resize: vertical; outline: none;
    transition: var(--transition);
}
.tool-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21,87,214,.1); }

.tool-result {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; margin-top: 20px; position: relative; overflow: hidden; transition: var(--transition);
}
.tool-result::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transform: scaleX(0); transition: transform .3s ease; transform-origin: left;
}
.tool-result:hover { border-color: transparent; box-shadow: var(--shadow-lg); }
.tool-result:hover::before { transform: scaleX(1); }
.tool-result h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 16px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 12px 24px;
    border: none; border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem;
    cursor: pointer; transition: var(--transition); text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }
.btn-secondary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-secondary:hover { background: var(--primary); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #16A34A; color: #fff; }
.btn-danger { background: #EF4444; color: #fff; }
.btn-danger:hover { background: #DC2626; color: #fff; }
.btn-sm { padding: 8px 16px; font-size: .8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Newsletter ===== */
.newsletter {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius);
    padding: 48px 40px;
    text-align: center;
    color: #fff;
    margin: 40px 0;
    box-shadow: var(--shadow-md);
}
.newsletter-icon-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    margin-bottom: 18px;
    color: #fff;
}
.newsletter-icon-container svg {
    display: block;
    width: 28px;
    height: 28px;
}
.newsletter h2 {
    font-size: 1.65rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #fff;
}
.newsletter p {
    font-size: 0.95rem;
    opacity: 0.9;
    margin-bottom: 24px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}
.newsletter-form-wrap {
    max-width: 480px;
    margin: 0 auto;
}
.newsletter-form {
    display: flex;
    gap: 12px;
}
.newsletter-form input {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    outline: none;
    background: #fff;
    color: var(--text);
    transition: var(--transition);
}
.newsletter-form input:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}
.newsletter-form button {
    padding: 12px 28px;
    background: #fff;
    color: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}
.newsletter-form button:hover {
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.newsletter-form button:active {
    transform: translateY(0);
}
.newsletter-message {
    margin-top: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(4px);
    transition: var(--transition);
    display: none;
}
.newsletter-message.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}
.newsletter-message.success {
    color: #4ade80;
}
.newsletter-message.error {
    color: #fca5a5;
}

/* ===== Footer (dark brand footer in both themes) ===== */
.site-footer {
    position: relative; margin-top: 40px; padding: 64px 0 28px;
    background: linear-gradient(160deg, #0A1436 0%, #0B1F5C 55%, #1B1554 100%);
    color: #C7D2EA;
}
.site-footer::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, #1E88E5, var(--primary), var(--secondary));
}
.footer-grid { display: grid; grid-template-columns: minmax(240px, 1.8fr) repeat(auto-fit, minmax(140px, 1fr)); gap: 40px 32px; margin-bottom: 44px; }
.footer-brand .logo { color: #fff; }
.footer-brand .logo span,
[data-theme="dark"] .footer-brand .logo span { background: none; -webkit-text-fill-color: #fff; color: #fff; }
.footer-brand p { color: #A9B6D6; font-size: .92rem; margin-top: 16px; line-height: 1.7; max-width: 360px; }
.footer-social { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.footer-social a {
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: 10px; background: rgba(255,255,255,.08); color: #DCE4F7; transition: var(--transition);
}
.footer-social a:hover { background: var(--primary); color: #fff; transform: translateY(-2px); }
.footer-social svg { width: 18px; height: 18px; }
.footer-col h4 { color: #fff; font-size: .8rem; font-weight: 700; margin-bottom: 16px; text-transform: uppercase; letter-spacing: .08em; }
.footer-col a { display: block; color: #A9B6D6; font-size: .92rem; padding: 6px 0; transition: var(--transition); }
.footer-col a:hover { color: #fff; transform: translateX(3px); }
.footer-bottom {
    padding-top: 24px; border-top: 1px solid rgba(255,255,255,.12);
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 24px;
}
.footer-bottom p { font-size: .85rem; color: #8FA0C6; }
.footer-company a { color: #fff; font-weight: 600; }
.footer-company a:hover { text-decoration: underline; }

/* ===== Breadcrumb ===== */
.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 16px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    list-style: none;
}
.breadcrumb li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.breadcrumb li::after {
    display: none !important;
    content: none !important;
}
.breadcrumb a {
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}
.breadcrumb a:hover {
    color: var(--primary);
}
.breadcrumb span {
    color: var(--text);
    font-weight: 500;
}

/* ===== FAQ ===== */
.faq-item {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin-bottom: 8px; overflow: hidden;
}
.faq-question {
    width: 100%; padding: 16px 20px; background: none; border: none; color: var(--text);
    font-size: .95rem; font-weight: 600; cursor: pointer; display: flex;
    justify-content: space-between; align-items: center; text-align: left;
}
.faq-question::after { content: '+'; font-size: 1.2rem; transition: var(--transition); }
.faq-item.active .faq-question::after { content: '−'; }
.faq-answer { padding: 0 20px; max-height: 0; overflow: hidden; transition: max-height .3s ease; }
.faq-item.active .faq-answer { max-height: 500px; padding-bottom: 16px; }
.faq-answer p { color: var(--text-secondary); font-size: .9rem; line-height: 1.7; }

/* ===== Ad Zones ===== */
.ad-zone { text-align: center; margin: 20px 0; }
.ad-zone img { max-width: 100%; border-radius: var(--radius-sm); }

/* ===== Static Page ===== */
.static-page { padding: 40px 0; max-width: 800px; margin: 0 auto; }
.static-page h1 { font-size: 2rem; margin-bottom: 24px; }
.page-content { line-height: 1.8; font-size: 1rem; }
.page-content h2 { margin: 24px 0 12px; font-size: 1.5rem; }
.page-content h3 { margin: 20px 0 10px; font-size: 1.2rem; }
.page-content p { margin-bottom: 16px; }
.page-content ul, .page-content ol { margin: 12px 0; padding-left: 24px; }
.page-content li { margin-bottom: 8px; }

/* ===== Responsive ===== */
/* Never let media or form controls push the page wider than the screen */
video, iframe { max-width: 100%; }
input, select, textarea, button { max-width: 100%; }
.tool-interface, .tool-result, .page-content { overflow-wrap: anywhere; }
.tool-interface pre, .tool-result pre, .page-content pre, .page-content table { max-width: 100%; overflow-x: auto; }

/* Large laptops: tighter nav so every item fits */
@media (max-width: 1439px) {
    .nav-menu a { padding: 8px 9px; font-size: .875rem; }
    .logo { font-size: 1.25rem; }
}
/* Below 1280px the full menu no longer fits: switch to the drawer */
@media (max-width: 1279px) {
    .nav-menu { display: none; }
    .mobile-toggle { display: flex; }
}
@media (min-width: 1280px) {
    .mobile-nav, .mobile-nav-overlay { display: none; }
}
@media (max-width: 1024px) {
    .tools-grid { grid-template-columns: repeat(2, 1fr); }
    .categories-grid { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: repeat(3, 1fr); }
    .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 768px) {
    :root { --header-h: 64px; }
    .container, .header-inner { padding-left: 16px; padding-right: 16px; }
    .hero { padding: 48px 0 40px; }
    .hero h1 { font-size: 1.9rem; line-height: 1.2; }
    .hero p { font-size: 1rem; }
    .section { padding: 40px 0; }
    .section-header { flex-wrap: wrap; gap: 12px; }
    .section-header h2, .section-header h1 { font-size: 1.4rem; }
    .newsletter { padding: 40px 20px; }
    .tool-page { padding: 24px 0; }
    .tool-page-header { margin-bottom: 20px; }
    .tool-page-header h1 { font-size: 1.6rem; line-height: 1.25; }
    .tool-page-header p { font-size: .95rem; }
    .tool-interface, .tool-result { padding: 20px 16px; }
    .tool-upload-area { padding: 32px 16px; }
    .static-page { padding: 24px 16px; }
    .static-page h1 { font-size: 1.6rem; }
    .page-content h2 { font-size: 1.25rem; }
    .site-footer { padding: 44px 0 24px; }
    .footer-grid { grid-template-columns: repeat(2, 1fr); gap: 28px 20px; margin-bottom: 32px; }
    .footer-bottom { flex-direction: column; text-align: center; }
    /* 16px inputs stop iOS from zooming the page on focus */
    input[type="text"], input[type="search"], input[type="url"], input[type="email"], input[type="number"], select, textarea { font-size: 16px; }
}
@media (max-width: 576px) {
    .tools-grid { grid-template-columns: 1fr; }
    .categories-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.65rem; }
    .hero-search input { padding: 14px 54px 14px 18px; }
    .btn { padding: 11px 18px; }
    .btn-lg { padding: 13px 22px; }
    .search-hero-form { padding: 5px 5px 5px 14px; }
    .search-hero-form input { min-width: 0; padding: 8px 8px; }
    .sh-btn { padding: 10px 16px; flex-shrink: 0; }
    .newsletter-form {
        flex-direction: column;
        border-radius: 16px;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
        gap: 12px;
    }
    .newsletter-form input {
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 14px 20px;
    }
    [data-theme="dark"] .newsletter-form input {
        background: var(--bg-card-dark);
        border-color: var(--border-dark);
    }
    .newsletter-form button {
        width: 100%;
        border-radius: 12px;
        padding: 14px 20px;
    }
}
@media (max-width: 400px) {
    .logo { font-size: 1.15rem; gap: 8px; }
    .logo svg { width: 30px; height: 30px; }
    .header-actions { gap: 6px; }
}
@media (max-width: 339px) {
    .footer-grid { grid-template-columns: 1fr; }
    .footer-brand { grid-column: auto; }
}

/* ===== Loading Spinner ===== */
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Search Results Page ===== */
.search-results-page { padding-top: 32px; }

.search-hero-bar {
    margin-bottom: 24px;
}
.search-hero-form {
    display: flex; align-items: center; gap: 0;
    background: var(--bg-card); border: 2px solid var(--border);
    border-radius: var(--radius-full); padding: 6px 6px 6px 20px;
    box-shadow: var(--shadow-md); transition: var(--transition);
    max-width: 680px;
}
.search-hero-form:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(21,87,214,.12); }
.sh-icon { font-size: 1.1rem; color: var(--text-secondary); flex-shrink: 0; }
.search-hero-form input {
    flex: 1; border: none; background: transparent; outline: none;
    font-size: 1rem; color: var(--text); padding: 8px 14px;
}
.sh-btn {
    padding: 10px 24px; background: var(--primary); color: #fff;
    border: none; border-radius: var(--radius-full); font-weight: 600;
    font-size: .9rem; cursor: pointer; transition: var(--transition); flex-shrink: 0;
}
.sh-btn:hover { background: var(--primary-dark); }

.search-meta {
    font-size: .95rem; color: var(--text-secondary); margin-bottom: 20px;
}
.search-meta strong { color: var(--text); }
.search-query-tag {
    display: inline-block; background: rgba(21,87,214,.1); color: var(--primary);
    padding: 2px 10px; border-radius: var(--radius-full); font-weight: 600;
}

/* Filter Tabs */
.search-filters {
    display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px;
}
.filter-tab {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 16px; border-radius: var(--radius-full);
    border: 1px solid var(--border); background: var(--bg-card);
    color: var(--text-secondary); font-size: .85rem; font-weight: 500;
    cursor: pointer; transition: var(--transition); text-decoration: none;
}
.filter-tab:hover { border-color: var(--primary); color: var(--primary); background: rgba(21,87,214,.05); }
.filter-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-tab.active:hover { background: var(--primary-dark); color: #fff; }
.filter-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px;
    background: rgba(255,255,255,.25); border-radius: 999px;
    font-size: .72rem; font-weight: 700;
}
.filter-tab:not(.active) .filter-count {
    background: rgba(21,87,214,.1); color: var(--primary);
}

/* Category label on tool card in search */
.tc-cat-label {
    font-size: .72rem; font-weight: 600; color: var(--primary);
    text-transform: uppercase; letter-spacing: .06em;
    margin-bottom: 6px; opacity: .8;
}

/* No results */
.search-empty {
    text-align: center; padding: 64px 20px;
}
.search-empty-icon {
    font-size: 4rem; margin-bottom: 16px;
    filter: grayscale(1); opacity: .4;
}
.search-empty h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 12px; }
.search-empty p { color: var(--text-secondary); max-width: 480px; margin: 0 auto 28px; line-height: 1.7; }
.search-empty-cats {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 20px;
}


/* ===== Utility ===== */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.flex { display: flex; } .flex-wrap { flex-wrap: wrap; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.badge {
    display: inline-block; padding: 3px 10px; border-radius: var(--radius-full);
    font-size: .75rem; font-weight: 600;
}
.badge-primary { background: rgba(21,87,214,.1); color: var(--primary); }
.badge-accent { background: rgba(34,197,94,.1); color: var(--accent); }
