/* ============================================================
   TOOLCLOUD DESIGN SYSTEM 2.0
   Mobile-First · Dark by Default · Glassmorphic
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    /* Backgrounds */
    --bg-base:      #09090b;
    --bg-surface:   #111113;
    --bg-surface-2: #18181b;
    --bg-surface-3: #27272a;

    /* Borders */
    --border:        rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.13);

    /* Brand */
    --accent:      #8b5cf6;
    --accent-2:    #3b82f6;
    --accent-glow: rgba(139, 92, 246, 0.30);
    --gradient:    linear-gradient(135deg, #8b5cf6, #3b82f6);
    --grad-text:   linear-gradient(135deg, #c4b5fd, #93c5fd);

    /* Status */
    --green:  #22c55e;
    --yellow: #f59e0b;
    --red:    #ef4444;

    /* Text */
    --text:       #f4f4f5;
    --text-muted: #a1a1aa;
    --text-dim:   #71717a;

    /* Shadows */
    --shadow-sm: 0 2px 8px  rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.55);

    /* Glass */
    --glass-bg:     rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.07);
    --glass-blur:   blur(20px);

    /* Radius */
    --r-sm:   6px;
    --r-md:   10px;
    --r-lg:   14px;
    --r-xl:   20px;
    --r-full: 9999px;

    /* Transitions */
    --t-fast: all 0.15s ease;
    --t-base: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --t-slow: all 0.4s  cubic-bezier(0.4, 0, 0.2, 1);

    /* Category Accent Colors */
    --cat-developer:  #6366f1;
    --cat-text:       #8b5cf6;
    --cat-image:      #ec4899;
    --cat-pdf:        #ef4444;
    --cat-generator:  #10b981;
    --cat-calculator: #f59e0b;
    --cat-seo:        #06b6d4;
    --cat-ai:         #a855f7;
    --cat-utility:    #3b82f6;

    /* Legacy compatibility aliases */
    --primary-bg:    var(--bg-base);
    --secondary-bg:  var(--bg-surface-2);
    --accent-color:  var(--accent);
    --text-main:     var(--text);
    --transition:    var(--t-base);
    --card-shadow:   var(--shadow-md);
}

/* ── Light Mode ────────────────────────────────────────────── */
body.light-mode {
    --bg-base:       #f8fafc;
    --bg-surface:    #ffffff;
    --bg-surface-2:  #f1f5f9;
    --bg-surface-3:  #e2e8f0;
    --border:        rgba(0, 0, 0, 0.07);
    --border-strong: rgba(0, 0, 0, 0.13);
    --glass-bg:      rgba(255, 255, 255, 0.75);
    --glass-border:  rgba(0, 0, 0, 0.08);
    --text:          #0f172a;
    --text-muted:    #475569;
    --text-dim:      #94a3b8;
    --shadow-sm:     0 2px 8px  rgba(0, 0, 0, 0.07);
    --shadow-md:     0 4px 20px rgba(0, 0, 0, 0.10);
    --shadow-lg:     0 8px 40px rgba(0, 0, 0, 0.13);
    --secondary-bg:  var(--bg-surface-2);
    --text-main:     var(--text);
}

body.light-mode header {
    background: rgba(248, 250, 252, 0.90);
}

body.light-mode .mobile-menu {
    background: var(--bg-surface);
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a     { color: inherit; text-decoration: none; }
img   { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
ul, ol { list-style: none; }

/* ── Animated Background Shapes ───────────────────────────── */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
    will-change: transform;
    animation: drift 20s infinite alternate ease-in-out;
}
.shape-1 {
    width: 70vw; height: 70vw;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.10) 0%, transparent 70%);
    filter: blur(80px);
    top: -30vw; left: -20vw;
    animation-delay: 0s;
}
.shape-2 {
    width: 55vw; height: 55vw;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.09) 0%, transparent 70%);
    filter: blur(80px);
    bottom: -20vw; right: -15vw;
    animation-delay: -7s;
}
.shape-3 {
    width: 45vw; height: 45vw;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.07) 0%, transparent 70%);
    filter: blur(80px);
    top: 40vh; left: 35vw;
    animation-delay: -14s;
}
@keyframes drift {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, -40px) scale(1.08); }
}

/* ── Keyframes ─────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes cardAppear {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}
@keyframes slideInUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
@keyframes copyFlash {
    0%   { box-shadow: 0 0 0 0   rgba(34, 197, 94, 0.50); }
    50%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0   rgba(34, 197, 94, 0); }
}
@keyframes shimmer {
    0%   { background-position: -400px 0; }
    100% { background-position:  400px 0; }
}
@keyframes searchPulse {
    from { box-shadow: 0 0 0 0   rgba(139, 92, 246, 0.40); }
    to   { box-shadow: 0 0 0 10px rgba(139, 92, 246, 0); }
}
@keyframes toastOut {
    to { opacity: 0; transform: translateX(20px); }
}

/* ── Glass Panel ───────────────────────────────────────────── */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
}

/* ── Typography Helpers ────────────────────────────────────── */
.text-gradient {
    background: var(--gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ── Copy Success ──────────────────────────────────────────── */
.copy-success {
    animation: copyFlash 0.5s ease-out;
    border-color: rgba(34, 197, 94, 0.50) !important;
}

/* ── Shimmer Skeleton ──────────────────────────────────────── */
.shimmer {
    background: linear-gradient(90deg, var(--border) 0%, var(--bg-surface-2) 40%, var(--border) 80%);
    background-size: 400px 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: var(--r-sm);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.glow-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: var(--gradient);
    color: #fff;
    padding: 11px 22px;
    border-radius: var(--r-md);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--t-base);
    box-shadow: 0 0 20px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.15);
    position: relative;
    isolation: isolate;
    overflow: hidden;
    white-space: nowrap;
    min-height: 44px;
}
.glow-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}
.glow-btn > * { position: relative; z-index: 1; }
.glow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.2);
}
.glow-btn:hover::before { opacity: 1; }
.glow-btn:active { transform: translateY(0); }

.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: var(--bg-surface-2);
    color: var(--text);
    border: 1px solid var(--border-strong);
    padding: 10px 18px;
    border-radius: var(--r-md);
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--t-base);
    white-space: nowrap;
    min-height: 44px;
}
.secondary-btn:hover {
    background: var(--bg-surface-3);
    border-color: var(--accent);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--r-md);
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 1rem;
    transition: var(--t-base);
    flex-shrink: 0;
}
.icon-btn:hover {
    background: var(--bg-surface-3);
    color: var(--text);
    border-color: var(--border-strong);
}

/* ============================================================
   FORM ELEMENTS (consistent across all tools)
   ============================================================ */

input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="url"],
input[type="password"],
select {
    width: 100%;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 11px 14px;
    color: var(--text);
    font-size: 0.9375rem;
    outline: none;
    transition: var(--t-base);
    min-height: 44px;
    -webkit-appearance: none;
    appearance: none;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
    background: var(--bg-surface);
}

textarea {
    width: 100%;
    height: 360px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    padding: 14px;
    color: var(--text);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    line-height: 1.65;
    resize: vertical;
    outline: none;
    transition: var(--t-base);
    min-height: 44px;
}
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
    background: var(--bg-surface);
}

input::placeholder,
textarea::placeholder { color: var(--text-dim); }
select option         { background: var(--bg-surface-2); }

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

input[type="range"]    { accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }
input[type="color"] {
    width: 44px;
    height: 44px;
    padding: 2px;
    border-radius: var(--r-sm);
    cursor: pointer;
}

/* ── Special output textarea ──── */
#jsonOutput { background: #000; }
body.light-mode #jsonOutput { background: #f1f5f9 !important; }

/* ============================================================
   HEADER
   ============================================================ */

header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(9, 9, 11, 0.90);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    gap: 10px;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 800;
    background: var(--grad-text);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}
.logo img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    flex-shrink: 0;
}

/* Dev badge */
#devBadge {
    display: none;
    background: #fbbf24;
    color: #000;
    -webkit-text-fill-color: #000;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
    text-transform: uppercase;
    margin-left: 2px;
}

/* Header Search (hidden on mobile by default) */
.search-container {
    display: none;
    position: relative;
    flex: 1;
    max-width: 460px;
}
.search-container input {
    background: rgba(255, 255, 255, 0.07) !important;
    border: 1.5px solid var(--border-strong) !important;
    border-radius: var(--r-full) !important;
    padding: 9px 16px 9px 42px !important;
    font-size: 0.875rem !important;
    height: 40px !important;
    min-height: unset !important;
}
.search-container input:focus {
    background: rgba(139, 92, 246, 0.08) !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15) !important;
    animation: searchPulse 0.4s ease-out;
}
.search-container input::placeholder {
    color: var(--text-dim) !important;
    font-size: 0.8rem !important;
}
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 0.8rem;
    pointer-events: none;
    transition: color 0.2s;
    z-index: 1;
}
.search-container:focus-within .search-icon { color: var(--accent); }

/* Header Nav */
.header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-browse-btn {
    display: none;
    padding: 9px 18px;
    font-size: 0.8rem;
    min-height: 38px;
}

.hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--r-md);
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.05rem;
    transition: var(--t-base);
}
.hamburger:hover {
    background: var(--bg-surface-3);
    border-color: var(--border-strong);
}

/* Dark Mode Toggle */
.dark-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--r-md);
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 1rem;
    transition: var(--t-base);
}
.dark-mode-toggle:hover {
    background: var(--bg-surface-3);
    color: var(--text);
    border-color: var(--border-strong);
}

/* ============================================================
   MOBILE OVERLAY / SLIDE-IN MENU
   ============================================================ */

.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.mobile-overlay.open {
    display: flex;
    justify-content: flex-end;
    opacity: 1;
}

.mobile-menu {
    width: 290px;
    max-width: 85vw;
    height: 100dvh;
    height: 100vh;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0;
    backdrop-filter: none;
    box-shadow: var(--shadow-lg);
}
.mobile-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    transition: var(--t-fast);
}
.mobile-close:hover { background: var(--bg-surface-3); }

.mobile-categories { margin-top: 6px; }
.mobile-categories li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    color: var(--text-muted);
    font-size: 0.9375rem;
    cursor: pointer;
    transition: var(--t-base);
    margin-bottom: 2px;
}
.mobile-categories li i {
    width: 18px;
    text-align: center;
    font-size: 0.875rem;
}
.mobile-categories li:hover,
.mobile-categories li.active {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent);
}

/* ── Mobile search inside overlay ── */
.mobile-search .search-container {
    display: flex !important;
    width: 100% !important;
}
.mobile-search .search-container input {
    width: 100% !important;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */

main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 14px;
}

/* ============================================================
   HERO SECTION
   ============================================================ */

.hero {
    text-align: center;
    padding: 28px 0 36px;
    position: relative;
    animation: fadeInUp 0.55s ease;
}

.hero h1 {
    font-size: clamp(1.85rem, 7vw, 4.2rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    background: linear-gradient(to bottom, var(--text) 0%, rgba(244, 244, 245, 0.65) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.hero h2 {
    font-size: clamp(0.9rem, 2.5vw, 1.15rem);
    font-weight: 400;
    color: var(--text-muted);
    margin-top: -4px;
    margin-bottom: 18px;
}

.hero p {
    color: var(--text-muted);
    font-size: clamp(0.875rem, 2vw, 1rem);
    max-width: 580px;
    margin: 0 auto 24px;
    line-height: 1.65;
}

/* Hero search bar (larger, more prominent) */
.hero .search-container {
    display: flex !important;
    width: 100% !important;
    max-width: 600px;
    margin: 0 auto 24px;
}
.hero .search-container input {
    height: 52px !important;
    font-size: 0.975rem !important;
    padding: 14px 20px 14px 52px !important;
    background: rgba(255, 255, 255, 0.07) !important;
    border: 1.5px solid var(--border-strong) !important;
}
.hero .search-container input:focus {
    background: rgba(139, 92, 246, 0.08) !important;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15), 0 8px 30px rgba(0, 0, 0, 0.25) !important;
}
.hero .search-icon {
    left: 18px;
    font-size: 0.95rem;
}

/* Trust Signals */
.trust-signals {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 0;
}
.trust-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.775rem;
    color: var(--text-muted);
    padding: 7px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    white-space: nowrap;
}
.trust-item strong { color: var(--text); font-weight: 600; }

/* ============================================================
   CATEGORY CHIPS  (mobile / tablet — horizontal scroll)
   ============================================================ */

.category-chips-wrapper {
    margin-bottom: 20px;
}

.category-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.category-chips::-webkit-scrollbar { display: none; }

.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 15px;
    border-radius: var(--r-full);
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--t-base);
    min-height: 36px;
    flex-shrink: 0;
}
.category-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(139, 92, 246, 0.07);
}
.category-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 14px rgba(139, 92, 246, 0.35);
}

/* ============================================================
   LAYOUT WRAPPER  (sidebar + content)
   ============================================================ */

.layout-wrapper {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* ── Sidebar ── */
.sidebar {
    display: none;
    width: 210px;
    flex-shrink: 0;
    padding: 18px 14px;
    position: sticky;
    top: 74px;
    height: fit-content;
}

.sidebar-category h4 {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.3px;
    color: var(--text-dim);
    margin-bottom: 10px;
    padding: 0 8px;
}
.sidebar-category ul { margin-bottom: 18px; }
.sidebar-category li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r-md);
    color: var(--text-muted);
    font-size: 0.8375rem;
    cursor: pointer;
    transition: var(--t-base);
    margin-bottom: 2px;
}
.sidebar-category li i {
    width: 17px;
    text-align: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.sidebar-category li:hover {
    background: var(--bg-surface-2);
    color: var(--text);
}
.sidebar-category li.active {
    background: rgba(139, 92, 246, 0.14);
    color: var(--accent);
    font-weight: 500;
}

/* Sidebar Ad */
.sidebar-ad { margin-top: 20px; }
.sidebar-ad .ad-placeholder { height: 250px; }

/* Content Area */
.content-area { flex: 1; min-width: 0; }

/* Grid Title */
#gridTitle {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text);
}

/* ============================================================
   TOOL CARDS GRID
   ============================================================ */

.category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    animation: fadeInUp 0.4s ease;
}

/* Tool Card */
.tool-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 14px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    overflow: hidden;
    border-radius: var(--r-lg);
    transition: var(--t-base);
    animation: cardAppear 0.35s ease forwards;
}
.tool-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--gradient);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.tool-card:hover {
    transform: translateY(-3px);
    border-color: rgba(139, 92, 246, 0.35) !important;
    background: rgba(255, 255, 255, 0.055) !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4), 0 0 14px rgba(139, 92, 246, 0.12);
}
.tool-card:hover::before { opacity: 1; }
.tool-card:active { transform: translateY(-1px) scale(0.988); transition: transform 0.1s ease; }

.tool-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139, 92, 246, 0.14);
    color: var(--accent);
    font-size: 0.9rem;
    margin-bottom: 10px;
    flex-shrink: 0;
    transition: var(--t-base);
}
.tool-card:hover .tool-icon {
    background: rgba(139, 92, 246, 0.24);
    box-shadow: 0 0 14px rgba(139, 92, 246, 0.2);
}

.tool-card h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 5px;
    line-height: 1.3;
}

.tool-card p {
    color: var(--text-muted);
    font-size: 0.75rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Ad feed card */
.ad-feed-card { cursor: default; }
.ad-feed-card:hover {
    transform: none !important;
    background: var(--glass-bg) !important;
    box-shadow: var(--shadow-md) !important;
    border-color: var(--glass-border) !important;
}

/* ============================================================
   ACTIVE TOOL STATE  (hide grid, show tool)
   ============================================================ */

.active-tool .layout-wrapper,
.active-tool .hero,
.active-tool .category-chips-wrapper,
.active-tool #gridTitle {
    display: none;
}

.tool-container {
    display: none;
    animation: fadeInUp 0.4s ease;
}

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

/* Back Button */
#backBtn {
    margin-bottom: 20px;
    padding: 10px 18px;
    font-size: 0.875rem;
    gap: 8px;
}

/* ── Tool Page Grid (content + sidebar ad) ── */
.tool-page-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
}

/* Sidebar Ads */
.sidebar-ads { position: sticky; top: 78px; }
.sidebar-ads .ad-placeholder { height: 580px; border-radius: var(--r-lg); }

/* ============================================================
   BREADCRUMBS
   ============================================================ */

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 0.775rem;
    color: var(--text-dim);
    flex-wrap: wrap;
}
.breadcrumbs a { color: var(--text-dim); transition: color 0.2s; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs i { font-size: 0.5rem; opacity: 0.6; }
.breadcrumbs span { color: var(--text); font-weight: 500; }

/* ============================================================
   TOOL HEADER
   ============================================================ */

.tool-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
    padding: 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
}

.tool-header-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent);
    font-size: 1.2rem;
    flex-shrink: 0;
    box-shadow: 0 0 18px rgba(139, 92, 246, 0.18);
}

.tool-header h2 {
    font-size: clamp(1.1rem, 3.5vw, 1.5rem);
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.2;
}

.tool-header p {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ============================================================
   TOOL LAYOUT  (input / output two-column)
   ============================================================ */

.tool-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.tool-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.label-row label { margin-bottom: 0; }

/* Tool Actions */
.tool-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

/* ============================================================
   HOW TO USE
   ============================================================ */

.tool-how-to {
    margin-top: 20px;
    padding: 18px 22px;
}
.tool-how-to h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tool-how-to h3 i { color: var(--accent); }
.tool-how-to ol {
    padding-left: 18px;
    display: grid;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.65;
    list-style: decimal;
}
.tool-how-to li::marker { color: var(--accent); font-weight: 700; }

/* ============================================================
   FAQ
   ============================================================ */

.tool-faq {
    margin-top: 14px;
    padding: 18px 22px;
}
.tool-faq h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tool-faq h3 i { color: var(--accent); }

.faq-item {
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.faq-item:last-child { border-bottom: none; padding-bottom: 0; }

.faq-item h4 {
    font-size: 0.8375rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
    line-height: 1.4;
}
.faq-item p {
    color: var(--text-muted);
    font-size: 0.8125rem;
    line-height: 1.7;
}

/* ============================================================
   RELATED TOOLS
   ============================================================ */

.related-tools { margin-top: 20px; }
.related-tools h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.related-tools h3 i { color: var(--accent); }

.related-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.related-card {
    padding: 14px;
    cursor: pointer;
    display: block;
    color: inherit;
    text-decoration: none;
    transition: var(--t-base);
    border-radius: var(--r-lg);
}
.related-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent) !important;
    background: rgba(255, 255, 255, 0.055) !important;
}

.related-card .tool-icon {
    width: 34px;
    height: 34px;
    font-size: 0.8rem;
    margin-bottom: 9px;
}
.related-card h4 {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.3;
}
.related-card p {
    color: var(--text-muted);
    font-size: 0.73rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============================================================
   AD PLACEHOLDERS
   ============================================================ */

.ad-placeholder {
    background: rgba(255, 255, 255, 0.015);
    border: 1px dashed var(--border);
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 0.62rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
    padding: 10px;
}
.ad-horizontal { margin: 28px 0; }
.ad-horizontal .ad-placeholder { height: 90px; }
.ad-in-content  { margin: 22px 0; }
.ad-in-content .ad-placeholder { height: 100px; }

/* Mobile Sticky Ad */
.mobile-sticky-ad {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background: var(--bg-surface-2);
    border-top: 1px solid var(--border);
    padding: 4px 12px;
}

/* ============================================================
   TOAST / NOTIFICATION SYSTEM
   ============================================================ */

.toast-container {
    position: fixed;
    bottom: 80px;
    right: 14px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 320px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 15px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    color: var(--text);
    font-size: 0.8375rem;
    font-weight: 500;
    pointer-events: auto;
    animation: slideInUp 0.3s ease;
    min-width: 200px;
}
.toast.toast-success { border-color: rgba(34, 197, 94, 0.45); }
.toast.toast-error   { border-color: rgba(239, 68, 68, 0.45); }
.toast.toast-info    { border-color: rgba(139, 92, 246, 0.45); }
.toast.dismissing    { animation: toastOut 0.3s ease forwards; }
.toast i { font-size: 0.9rem; flex-shrink: 0; }
.toast-success i { color: var(--green); }
.toast-error i   { color: var(--red); }
.toast-info i    { color: var(--accent); }

/* ============================================================
   FOOTER
   ============================================================ */

footer {
    margin-top: 56px;
    padding: 40px 14px 24px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    max-width: 1440px;
    margin: 0 auto;
}

.footer-brand { grid-column: span 2; }
.footer-brand .logo { margin-bottom: 12px; font-size: 1.1rem; }
.footer-brand p {
    color: var(--text-muted);
    font-size: 0.825rem;
    line-height: 1.65;
    max-width: 280px;
}

.footer-grid h4 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 12px;
}
.footer-links { display: grid; gap: 8px; }
.footer-links a {
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: color 0.2s;
}
.footer-links a:hover { color: var(--accent); }

.footer-bottom {
    max-width: 1440px;
    margin: 28px auto 0;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-dim);
    font-size: 0.775rem;
}

/* ============================================================
   BLOG STYLES
   ============================================================ */

.blog-tag-btn {
    background: var(--bg-surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: var(--r-full);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--t-base);
    white-space: nowrap;
}
.blog-tag-btn:hover  { border-color: var(--accent); color: var(--accent); }
.blog-tag-btn.active-tag { background: var(--accent); color: #fff; border-color: var(--accent); }
.blog-card:hover     { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.blog-sidebar-tag {
    font-size: 0.78rem; padding: 4px 10px; border-radius: 12px;
    background: var(--bg-surface-2); color: var(--accent);
    cursor: pointer; border: 1px solid var(--border); transition: var(--t-base);
}
.blog-sidebar-tag:hover { background: var(--accent); color: #fff; }

.blog-article-body h1,.blog-article-body h2,.blog-article-body h3,.blog-article-body h4 {
    color: var(--text); margin: 1.4em 0 0.6em; line-height: 1.3;
}
.blog-article-body p  { margin-bottom: 1em; }
.blog-article-body a  { color: var(--accent); text-decoration: underline; }
.blog-article-body code {
    background: var(--bg-surface-2); padding: 2px 6px; border-radius: 4px;
    font-family: monospace; font-size: 0.875em; color: #e879f9;
}
.blog-article-body pre {
    background: var(--bg-surface-2); padding: 16px; border-radius: var(--r-md);
    overflow-x: auto; margin: 1em 0; border: 1px solid var(--border);
}
.blog-article-body pre code { background: none; padding: 0; color: #a5f3fc; }
.blog-article-body img   { max-width: 100%; border-radius: var(--r-md); margin: 1em 0; }
.blog-article-body ul,
.blog-article-body ol    { padding-left: 1.5em; margin-bottom: 1em; }
.blog-article-body li    { margin-bottom: 0.4em; }
.blog-article-body blockquote {
    border-left: 3px solid var(--accent); padding-left: 16px;
    margin: 1em 0; font-style: italic; color: var(--text-muted);
}
.blog-article-body hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

/* ============================================================
   CUSTOM SCROLLBAR
   ============================================================ */

::-webkit-scrollbar              { width: 5px; height: 5px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: var(--border-strong); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover  { background: var(--text-dim); }

/* ============================================================
   RESPONSIVE  ─  Tablet  ≥ 480px
   ============================================================ */

@media (min-width: 480px) {
    .category-grid { gap: 12px; }
    .tool-card     { padding: 16px; }
    .tool-card h3  { font-size: 0.875rem; }
    .tool-card p   { font-size: 0.775rem; }
}

/* ============================================================
   RESPONSIVE  ─  Small Laptop  ≥ 640px
   ============================================================ */

@media (min-width: 640px) {
    header { padding: 0 20px; height: 64px; }
    .search-container { display: flex; align-items: center; }

    main { padding: 28px 20px; }

    .category-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }

    .tool-layout { grid-template-columns: 1fr 1fr; gap: 16px; }

    .related-grid { grid-template-columns: repeat(3, 1fr); }

    .footer-grid {
        grid-template-columns: 1.4fr 1fr 1fr 1fr;
        gap: 36px;
    }
    .footer-brand { grid-column: span 1; }
}

/* ============================================================
   RESPONSIVE  ─  Desktop  ≥ 1024px
   ============================================================ */

@media (min-width: 1024px) {
    header { padding: 0 32px; }
    .header-browse-btn { display: inline-flex; }
    .hamburger { display: none; }
    .logo { font-size: 1.3rem; }

    main { padding: 36px 32px; }

    .sidebar { display: block; }
    .category-chips-wrapper { display: none; }

    .category-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }

    .tool-card { padding: 18px; }
    .tool-card h3 { font-size: 0.9rem; }
    .tool-card p  { font-size: 0.8rem; }
    .tool-icon { width: 42px; height: 42px; font-size: 1rem; }

    .related-grid { grid-template-columns: repeat(4, 1fr); }

    footer { padding: 52px 32px 30px; }
}

/* ============================================================
   RESPONSIVE  ─  Wide Desktop  ≥ 1280px
   ============================================================ */

@media (min-width: 1280px) {
    header { padding: 0 40px; }
    main   { padding: 40px; }

    .category-grid { grid-template-columns: repeat(4, 1fr); }

    .tool-page-grid {
        grid-template-columns: 1fr 280px;
    }
}

/* ── Mobile sticky ad + body padding ── */
@media (max-width: 639px) {
    .mobile-sticky-ad { display: block; }
    body { padding-bottom: 58px; }
    .ad-horizontal { margin: 20px 0; }

    .hero { padding: 18px 0 28px; }
    .trust-signals { gap: 7px; }
    .trust-item { font-size: 0.72rem; padding: 6px 11px; }
}

/* ============================================================
   TOOL INTERIOR COMPONENTS (tc-*)
   ============================================================ */

.tc-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tc-section {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tc-section-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.tc-section-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.9px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tc-section-title i { color: var(--accent); }

.tc-example-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--accent);
    border: 1px solid rgba(139,92,246,0.3);
    background: rgba(139,92,246,0.07);
    padding: 5px 10px;
    border-radius: var(--r-full);
    cursor: pointer;
    transition: var(--t-base);
    font-family: inherit;
    white-space: nowrap;
}
.tc-example-btn:hover {
    background: rgba(139,92,246,0.15);
    border-color: var(--accent);
}

.tc-status {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.tc-error {
    padding: 10px 14px;
    background: rgba(239,68,68,0.09);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: var(--r-md);
    color: #fca5a5;
    font-size: 0.825rem;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.tc-error i { color: #ef4444; flex-shrink: 0; margin-top: 1px; }

.tc-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    color: var(--text-muted);
    font-size: 0.875rem;
}
.tc-loading i { color: var(--accent); }

/* Inputs inside tc-section lose double borders */
.tc-section > textarea,
.tc-section > input,
.tc-section > select { margin-bottom: 0; }

/* Output textarea — terminal style in dark, clean surface in light */
:root {
    --tc-out-bg:    rgba(0,0,0,0.55);
    --tc-out-color: #4ade80;
    --tc-out-border: var(--border);
}
body.light-mode {
    --tc-out-bg:    #f1f5f9;
    --tc-out-color: #166534;
    --tc-out-border: rgba(0,0,0,0.1);
}
.tc-output {
    background: var(--tc-out-bg) !important;
    border: 1px solid var(--tc-out-border) !important;
    color: var(--tc-out-color) !important;
    font-family: 'Courier New', monospace !important;
    font-size: 0.85rem !important;
    min-height: 180px;
}

/* Stats grid (word counter) */
.tc-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
}
.tc-stat {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 8px;
    text-align: center;
}
.tc-stat-value {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 4px;
}
.tc-stat-label {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
}

/* Checkbox options grid */
.tc-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.tc-option {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: var(--t-base);
    font-size: 0.85rem;
    user-select: none;
}
.tc-option:hover { border-color: var(--accent); background: rgba(139,92,246,0.06); }
.tc-option input[type="checkbox"] { width:16px; height:16px; min-height:unset; margin:0; flex-shrink:0; }

/* Password display */
.tc-pass-display {
    font-family: 'Courier New', monospace;
    font-size: 1.05rem;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    word-break: break-all;
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 1.5px;
    color: var(--text);
    transition: var(--t-base);
}

/* Strength bar */
.tc-strength-bar {
    height: 5px;
    border-radius: var(--r-full);
    background: var(--bg-surface-3);
    overflow: hidden;
}
.tc-strength-fill {
    height: 100%;
    border-radius: var(--r-full);
    transition: width 0.4s ease, background 0.3s ease;
    width: 0%;
}
.tc-strength-label {
    text-align: center;
    font-size: 0.73rem;
    color: var(--text-dim);
    font-weight: 500;
}

/* Slider row */
.tc-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.tc-slider-row label { margin-bottom: 0; flex-shrink: 0; }
.tc-slider-value {
    color: var(--accent);
    font-weight: 700;
    font-size: 1rem;
    min-width: 32px;
    text-align: right;
    flex-shrink: 0;
}
.tc-slider-row input[type="range"] { flex: 1; }

/* Drag-drop zone */
.tc-dropzone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--r-lg);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--t-base);
    position: relative;
    overflow: hidden;
}
.tc-dropzone:hover, .tc-dropzone.drag-over {
    border-color: var(--accent);
    background: rgba(139,92,246,0.05);
}
.tc-dropzone i { font-size: 2rem; color: var(--accent); display: block; margin-bottom: 8px; }
.tc-dropzone p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 10px; }
.tc-dropzone input[type="file"] {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    opacity: 0; cursor: pointer; min-height: unset;
}

/* UUID list */
.tc-uuid-list {
    font-family: 'Courier New', monospace;
    font-size: 0.825rem;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
}
.tc-uuid-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background 0.15s;
    gap: 8px;
}
.tc-uuid-item:hover { background: rgba(139,92,246,0.1); }
.tc-uuid-item span { flex: 1; word-break: break-all; }
.tc-uuid-item i { color: var(--text-dim); font-size: 0.7rem; flex-shrink: 0; }

/* Calculator result */
.tc-result {
    padding: 12px 16px;
    background: rgba(139,92,246,0.1);
    border: 1px solid rgba(139,92,246,0.25);
    border-radius: var(--r-md);
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent);
    min-height: 44px;
    display: flex;
    align-items: center;
}

/* Calc input inline row */
.tc-calc-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.9rem;
}
.tc-calc-row span { white-space: nowrap; color: var(--text-muted); }
.tc-calc-row input { width: 100px; text-align: center; min-height: 40px; }

/* QR preview */
.tc-qr-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px;
    gap: 14px;
    text-align: center;
}
.tc-qr-preview canvas { border-radius: 8px; background: white; padding: 10px; }

/* ============================================================
   FAVORITES SYSTEM
   ============================================================ */

.fav-btn {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 28px;
    height: 28px;
    border-radius: var(--r-full);
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--t-base);
    z-index: 2;
    opacity: 0;
    min-height: unset;
    padding: 0;
}
.tool-card:hover .fav-btn { opacity: 1; }
.tool-card .fav-btn.is-fav {
    opacity: 1;
    color: #f43f5e;
    border-color: rgba(244,63,94,0.4);
    background: rgba(244,63,94,0.08);
}
.fav-btn:hover { color: #f43f5e !important; transform: scale(1.2); border-color: rgba(244,63,94,0.4) !important; }

.fav-chip-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f43f5e;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: var(--r-full);
    padding: 0 4px;
    margin-left: 2px;
}

/* ============================================================
   ADDITIONAL TC COMPONENTS (Phase 3)
   ============================================================ */

/* Select & input shared styling */
.tc-select,
.tc-input {
    padding: 10px 13px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: 0.875rem;
    transition: var(--t-fast);
    width: 100%;
    min-height: unset;
}
.tc-select:focus,
.tc-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }

/* Inline number inputs */
.tc-num-input {
    width: 90px;
    text-align: center;
    padding: 9px 8px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text);
    font-size: 0.9rem;
    min-height: unset;
    transition: var(--t-fast);
}
.tc-num-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-glow); }

/* Percentage calculator card grid */
.tc-calc-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.tc-calc-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: var(--t-base);
}
.tc-calc-card:hover { border-color: var(--border-strong); }
.tc-calc-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tc-calc-inputs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-muted);
}
.tc-calc-result {
    padding: 10px 14px;
    background: rgba(139,92,246,0.1);
    border: 1px solid rgba(139,92,246,0.25);
    border-radius: var(--r-md);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent);
    display: none;
}

/* UUID item copied flash */
.tc-uuid-item.copied { background: rgba(74,222,128,0.12) !important; }

/* Slider row span value */
.tc-slider-row span { color: var(--accent); font-weight: 700; min-width: 36px; text-align: right; flex-shrink: 0; }

/* ============================================================
   SEO ANALYZER COMPONENTS
   ============================================================ */

/* Character count bar */
.seo-bar-wrap {
    height: 4px;
    background: var(--bg-surface-3);
    border-radius: var(--r-full);
    margin-top: 5px;
    overflow: hidden;
}
.seo-bar {
    height: 100%;
    border-radius: var(--r-full);
    transition: width 0.3s ease, background 0.3s ease;
    width: 0%;
    background: #22c55e;
}

/* Score circle */
.seo-score-wrap {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 0;
}
.seo-score-circle {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 4px solid var(--accent);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
    transition: border-color 0.4s, color 0.4s;
}
.seo-score-circle span { font-size: 1.8rem; line-height: 1; }
.seo-score-circle small { font-size: 0.65rem; color: var(--text-muted); }
.seo-score-label { font-size: 1.1rem; font-weight: 700; }

/* SERP preview */
.seo-serp {
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 20px;
    font-family: arial, sans-serif;
}
.seo-serp-url {
    font-size: 0.78rem;
    color: #198754;
    margin-bottom: 3px;
}
.seo-serp-title {
    font-size: 1.1rem;
    color: #1a73e8;
    font-weight: 500;
    margin-bottom: 4px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    cursor: pointer;
}
.seo-serp-title:hover { text-decoration: underline; }
.seo-serp-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.55;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Checklist */
.seo-checklist { display: flex; flex-direction: column; gap: 8px; }
.seo-check-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--r-md);
    font-size: 0.875rem;
    border: 1px solid;
}
.seo-check-item.pass {
    background: rgba(34,197,94,0.07);
    border-color: rgba(34,197,94,0.25);
    color: var(--text);
}
.seo-check-item.pass i { color: #22c55e; font-size: 1rem; margin-top: 1px; flex-shrink: 0; }
.seo-check-item.fail {
    background: rgba(239,68,68,0.07);
    border-color: rgba(239,68,68,0.2);
    color: var(--text);
}
.seo-check-item.fail i { color: #ef4444; font-size: 1rem; margin-top: 1px; flex-shrink: 0; }
.seo-check-label { font-weight: 600; }
.seo-check-tip { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }

/* ============================================================
   LIGHT MODE OVERRIDES — Full redesign for clean white UI
   ============================================================ */

/* ── Body background ── */
body.light-mode { background: #f4f6fb; }

/* ── Header ── */
body.light-mode header {
    background: rgba(255,255,255,0.95) !important;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 1px 12px rgba(0,0,0,0.06);
}
body.light-mode .logo { color: #1e293b; }
body.light-mode .hamburger,
body.light-mode .dark-mode-toggle {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
    box-shadow: none;
}
body.light-mode .hamburger:hover,
body.light-mode .dark-mode-toggle:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
}

/* ── Hero section ── */
body.light-mode .hero-title { color: #0f172a; }
body.light-mode .hero-subtitle { color: #475569; }
body.light-mode .hero-desc { color: #64748b; }
body.light-mode .stat-pill {
    background: #fff;
    border-color: #e2e8f0;
    color: #334155;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* ── Search bar ── */
body.light-mode #searchInput,
body.light-mode .search-input {
    background: #fff !important;
    border-color: #e2e8f0 !important;
    color: #0f172a !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06) !important;
}
body.light-mode #searchInput::placeholder { color: #94a3b8; }

/* ── Glass panels ── */
body.light-mode .glass-panel {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* ── Category filter chips ── */
body.light-mode .category-chip {
    background: #fff;
    border-color: #e2e8f0;
    color: #475569;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
body.light-mode .category-chip:hover:not(.active) {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #334155;
}
body.light-mode .category-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(139,92,246,0.3);
}

/* ── Tool cards ── */
body.light-mode .tool-card {
    background: #ffffff;
    border-color: #e8edf5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
body.light-mode .tool-card:hover {
    background: #ffffff !important;
    border-color: rgba(139,92,246,0.4) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1), 0 0 14px rgba(139,92,246,0.1) !important;
}
body.light-mode .tool-card h3 { color: #1e293b; }
body.light-mode .tool-card p { color: #64748b; }

/* ── Section headings (Popular Tools, etc.) ── */
body.light-mode .section-title,
body.light-mode .cat-section h2,
body.light-mode h2.section-label { color: #0f172a; }

/* ── Tool interior — back btn / breadcrumb ── */
body.light-mode .back-btn {
    background: #fff;
    border-color: #e2e8f0;
    color: #475569;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
body.light-mode .back-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #1e293b;
}
body.light-mode .breadcrumb { color: #64748b; }
body.light-mode .breadcrumb a { color: #64748b; }
body.light-mode .breadcrumb a:hover { color: var(--accent); }
body.light-mode .breadcrumb .current { color: #0f172a; font-weight: 600; }

/* ── Tool header card ── */
body.light-mode .tool-header {
    background: #fff;
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
body.light-mode .tool-header h2 { color: #0f172a; }
body.light-mode .tool-header p { color: #64748b; }

/* ── tc-section (input/output panels) ── */
body.light-mode .tc-section {
    background: #fff;
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
body.light-mode .tc-section-title { color: #64748b; }

/* ── Textareas and inputs in light ── */
body.light-mode textarea,
body.light-mode input[type="text"],
body.light-mode input[type="number"],
body.light-mode input[type="email"],
body.light-mode input[type="url"],
body.light-mode select {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
    color: #0f172a !important;
}
body.light-mode textarea::placeholder,
body.light-mode input::placeholder { color: #94a3b8 !important; }
body.light-mode textarea:focus,
body.light-mode input:focus,
body.light-mode select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(139,92,246,0.1) !important;
    background: #fff !important;
}

/* ── Secondary buttons in light ── */
body.light-mode .secondary-btn {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #334155;
}
body.light-mode .secondary-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #cbd5e1;
}
body.light-mode .icon-btn {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #475569;
}
body.light-mode .icon-btn:hover { background: #e2e8f0; color: #0f172a; }

/* ── Try Example button ── */
body.light-mode .tc-example-btn {
    background: rgba(139,92,246,0.08);
    border-color: rgba(139,92,246,0.25);
    color: var(--accent);
}
body.light-mode .tc-example-btn:hover {
    background: rgba(139,92,246,0.15);
    border-color: var(--accent);
}

/* ── Copy button ── */
body.light-mode .tc-copy-btn {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #475569;
}
body.light-mode .tc-copy-btn:hover { background: #e2e8f0; color: #0f172a; }

/* ── Tool actions row ── */
body.light-mode .tc-actions {
    background: #f8fafc;
    border-color: #e2e8f0;
}

/* ── Password display ── */
body.light-mode .tc-pass-display {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #0f172a;
}

/* ── UUID list ── */
body.light-mode .tc-uuid-list { background: #f8fafc; border-color: #e2e8f0; }
body.light-mode .tc-uuid-item { border-color: #e2e8f0; color: #334155; }
body.light-mode .tc-uuid-item:hover { background: rgba(139,92,246,0.06); }

/* ── Calc cards ── */
body.light-mode .tc-calc-card {
    background: #fff;
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
body.light-mode .tc-calc-title { color: #64748b; }
body.light-mode .tc-calc-result { color: var(--accent); }

/* ── SEO analyzer ── */
body.light-mode .seo-serp { background: #fff; border-color: #e2e8f0; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
body.light-mode .seo-serp-url { color: #188038; }
body.light-mode .seo-serp-title { color: #1a0dab; }
body.light-mode .seo-serp-desc { color: #4d5156; }
body.light-mode .seo-score-circle { border-color: var(--accent); color: var(--accent); }
body.light-mode .seo-bar { background: #e2e8f0; }
body.light-mode .seo-check-item { border-color: #e2e8f0; }

/* ── Related tools ── */
body.light-mode .related-card {
    background: #fff;
    border-color: #e2e8f0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
body.light-mode .related-card:hover {
    background: #fff !important;
    border-color: var(--accent) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08) !important;
}

/* ── Sidebar ── */
body.light-mode .sidebar-category li { color: #475569; }
body.light-mode .sidebar-category li:hover,
body.light-mode .sidebar-category li.active { color: var(--accent); }

/* ── Ad slots ── */
body.light-mode .ad-slot { background: #f8fafc; border-color: #e2e8f0; }

/* ── Footer ── */
body.light-mode footer { background: #fff; border-top-color: #e2e8f0; }
body.light-mode .footer-links a { color: #64748b; }
body.light-mode .footer-links a:hover { color: var(--accent); }

/* ── Mobile menu ── */
body.light-mode .mobile-menu { background: #fff; border-color: #e2e8f0; }
body.light-mode .mobile-categories li { color: #475569; border-bottom-color: #f1f5f9; }
body.light-mode .mobile-close { color: #475569; }

/* ── Fav button ── */
body.light-mode .fav-btn { background: #fff; border-color: #e2e8f0; color: #94a3b8; }
body.light-mode .fav-btn.is-fav { color: #f43f5e; }

/* ============================================================
   PDF TOOLS — MOBILE RESPONSIVE
   All PDF tool pages share: glass-panel outer container,
   drop-zone (padding: 40px), file-info rows, option grids.
   These rules make every PDF tool fully responsive on mobile
   without touching JavaScript or desktop layout.
   ============================================================ */

/* ── 1. Fix grid-item overflow (min-width: auto default breaks 1fr) ── */
.tool-page-grid > div:first-child {
    min-width: 0;
    overflow-x: hidden;
}

/* ── 2. Hide sidebar ad column on mobile — saves vertical space ── */
@media (max-width: 639px) {
    .sidebar-ads { display: none; }
}

/* ============================================================
   Mobile  ≤ 639px
   ============================================================ */
@media (max-width: 639px) {

    /* ── Layout: main padding ── */
    main { padding-left: 12px; padding-right: 12px; }

    /* ── Back button: full-width, easy tap target ── */
    #backBtn {
        width: 100%;
        justify-content: center;
        margin-bottom: 14px;
        min-height: 44px;
    }

    /* ─────────────────────────────────────────────
       PDF TOOL OUTER PANEL
       All PDF tools render:
         <div class="glass-panel" style="padding: 30px; text-align: center;">
       We reduce that 30px → 14px on mobile.
    ───────────────────────────────────────────── */
    #toolContent > .glass-panel[style*="padding: 30px"] {
        padding: 14px !important;
    }

    /* ─────────────────────────────────────────────
       DROP ZONES
       Outer drop zones carry inline padding: 40px.
       Targets: pdfDropZone (merge), and every
       [id$="Drop"] (rotateDrop, splitDrop, wordDrop,
       watermarkDrop, signDrop, editDrop, organizeDrop,
       protectDrop, jpgDrop, pngDrop, excelDrop, pptDrop,
       pdfaDrop, wordToPdfDrop, htmlToPdfDrop, jpgToPdfDrop,
       pptToPdfDrop, excelToPdfDrop, scanDrop, unlockDrop,
       redactDrop, repairDrop, compareDrop, ocrDrop).
    ───────────────────────────────────────────── */
    #pdfDropZone,
    [id$="Drop"] {
        padding: 22px 14px !important;
    }

    /* Drop-zone upload icon: slightly smaller */
    #pdfDropZone > i,
    [id$="Drop"] > i {
        font-size: 2.2rem !important;
        margin-bottom: 10px !important;
    }

    /* Drop-zone text */
    #pdfDropZone > p,
    [id$="Drop"] > p {
        font-size: 0.85rem;
        margin-bottom: 8px !important;
    }

    /* ─────────────────────────────────────────────
       FILE INFO CARDS
       After a file is selected, tools show a flex row:
         icon | filename + size | ✕ button
       We tighten padding and allow wrapping on tiny screens.
    ───────────────────────────────────────────── */
    [id$="FileInfo"] > .glass-panel {
        padding: 10px 12px !important;
        gap: 8px !important;
    }

    /* ─────────────────────────────────────────────
       MERGE PDF — FILE LIST ITEMS
       Rendered as glass-panel flex rows inside #pdfList.
    ───────────────────────────────────────────── */
    #pdfList > .glass-panel {
        padding: 10px 12px !important;
        gap: 8px !important;
    }

    /* Merge PDF status hint */
    #pdfStatus {
        font-size: 0.85rem;
        word-break: break-word;
    }

    /* ─────────────────────────────────────────────
       OPTION GRIDS
       Rotate PDF uses: grid-template-columns: 1fr 1fr 1fr
       Watermark, Sign, etc. use: grid-template-columns: 1fr 1fr
       Collapse all to single column on mobile.
    ───────────────────────────────────────────── */
    [id$="Options"] > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    /* Rotate angle buttons: fill full width */
    .rotate-angle {
        width: 100%;
        min-height: 44px;
        font-size: 0.9rem !important;
    }

    /* ─────────────────────────────────────────────
       FORM INPUTS INSIDE PDF TOOLS
       font-size: 16px prevents iOS auto-zoom on focus.
    ───────────────────────────────────────────── */
    #toolContent input[type="text"],
    #toolContent input[type="number"],
    #toolContent input[type="email"],
    #toolContent input[type="password"],
    #toolContent textarea,
    #toolContent select {
        font-size: 16px !important;
        padding: 10px 12px !important;
    }

    /* ─────────────────────────────────────────────
       ACTION BUTTONS
       All PDF tools end with a full-width glow-btn.
       Ensure comfortable touch target height.
    ───────────────────────────────────────────── */
    #toolContent .glow-btn {
        min-height: 48px;
        font-size: 0.95rem;
        width: 100% !important;
    }

    /* Status messages below action buttons */
    [id$="Status"] {
        font-size: 0.85rem;
        word-break: break-word;
        margin-top: 12px !important;
    }

    /* ─────────────────────────────────────────────
       TOOL HEADER
       Reduce padding and icon size on mobile.
    ───────────────────────────────────────────── */
    .tool-header {
        padding: 14px !important;
        gap: 12px !important;
        margin-bottom: 14px !important;
    }
    .tool-header-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
        flex-shrink: 0;
    }
    .tool-header h2 { font-size: 1.05rem !important; }
    .tool-header p  { font-size: 0.8rem !important;  }

    /* ─────────────────────────────────────────────
       HOW TO USE & FAQ PANELS
    ───────────────────────────────────────────── */
    .tool-how-to { padding: 14px 16px !important; }
    .tool-faq    { padding: 14px 16px !important; }

    /* ─────────────────────────────────────────────
       RELATED TOOLS
    ───────────────────────────────────────────── */
    .related-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .related-card { padding: 10px !important; }
}

/* ============================================================
   Extra-small phones  ≤ 400px
   ============================================================ */
@media (max-width: 400px) {

    main { padding-left: 10px; padding-right: 10px; }

    /* Tool header: stack icon + text vertically */
    .tool-header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Drop zones: even more compact */
    #pdfDropZone,
    [id$="Drop"] { padding: 16px 10px !important; }

    /* Merge PDF file list items: wrap controls to new row */
    #pdfList > .glass-panel {
        flex-wrap: wrap !important;
    }
    #pdfList > .glass-panel > div:last-child {
        width: 100%;
        justify-content: flex-end;
        padding-top: 6px;
        border-top: 1px solid var(--border);
        margin-top: 4px;
    }

    /* Related tools: single column */
    .related-grid { grid-template-columns: 1fr; }
}
