/* CSS Custom Properties for Theme */
        :root {
            /* Dark Theme (Default) */
            --bg-primary: #0A0A0F;
            --bg-secondary: #16161D;
            --bg-tertiary: #1E1E28;
            --text-primary: #F5F5F7;
            --text-secondary: #A0A0AB;
            --text-tertiary: #6E6E78;
            --accent-primary: #6B2FFF;
            --accent-secondary: #FF3DFF;
            --border-default: #2A2A35;
            --gradient-start: #4600E7;
            --gradient-end: #FF00FF;
            --success: #00D9A3;
            --warning: #FFB800;
            --error: #FF3D71;
            --shadow-hover: rgba(70, 0, 231, 0.15);
            --logo-shadow: rgba(255, 61, 255, 1);
            --header-height: 74px;
        }

        [data-theme="light"] {
            --bg-primary: #FFFFFF;
            --bg-secondary: #F7F7F9;
            --bg-tertiary: #EEEFF3;
            --text-primary: #1A1A1F;
            --text-secondary: #52525E;
            --text-tertiary: #85858F;
            --accent-primary: #5200CC;
            /* --accent-secondary: #7700e0; */
            --border-default: #E1E1E6;
            --shadow-hover: rgba(70, 0, 231, 0.1);
            /* --logo-shadow: rgba(255, 61, 255, 1); */
        }

        /* Reset & Base Styles */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        /* In Dark Mode, hide the dark button and show the light button */
        html[data-theme="dark"] .icon-dark { display: none; }
        html[data-theme="dark"] .icon-light { display: block; }

        /* In Light Mode, hide the light button and show the dark button */
        html[data-theme="light"] .icon-light { display: none; }
        html[data-theme="light"] .icon-dark { display: block; }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            background-color: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.6;
            transition: background-color 300ms ease, color 300ms ease;
            height: 100vh; /* Fallback */
            height: 100dvh; /* Mobile friendly */
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* Reduced Motion Support */
        @media (prefers-reduced-motion: reduce) {
            *,
            *::before,
            *::after {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
            }
        }

        ::-webkit-scrollbar { width: 8px; }
        ::-webkit-scrollbar-track { background: var(--bg-primary); border-radius: 500px; }
        ::-webkit-scrollbar-thumb { background: var(--accent-primary); border-radius: 500px; }
        ::-webkit-scrollbar-thumb:hover { background: var(--accent-secondary); }
        ::-webkit-scrollbar-corner { background: var(--bg-primary); }

        .button-reset {
            all: unset;
        }

        .button-reset:focus {
            outline: none;
        }

        .button-reset::-moz-focus-inner {
            border: 0;
        }

        /* Skip to Content Link */
        .skip-link {
            position: absolute;
            top: -100px;
            left: 0;
            background: var(--accent-primary);
            color: white;
            padding: 0.5rem 1rem;
            text-decoration: none;
            z-index: 10000;
            border-radius: 0 0 8px 0;
        }

        .skip-link:focus {
            top: 0;
            outline: 3px solid;
            outline-color: var(--gradient-start);
            outline-offset: 2px;
        }

        /* Header Styles */
        .header {
            /* position: fixed; */
            top: 0;
            left: 0;
            right: 0;
            height: var(--header-height);
            display: flex;
            flex-shrink: 0;
            align-items: center;
            padding: 1rem 1.5rem;
            background-color: var(--bg-secondary);
            backdrop-filter: blur(8px);
            border-bottom: 1px solid var(--border-default);
            z-index: 500;
            transition: background-color 300ms ease;
        }

        @media (min-width: 1024px) {
             :root {
                --header-height: 72px; /* Removes the value so fallback is used */
            }
        }

        .header__logo {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: 700;
            font-size: 1.25rem;
            flex-shrink: 0;
        }

        .header__name {
            font-size: 1.5rem;
            font-weight: 600;
            margin-left: 1rem;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        @media (max-width: 639px) {
            .header__name {
                font-size: 1.25rem;
            }
        }

        .header__spacer {
            flex-grow: 1;
        }

        .header__back-btn {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            padding: 0.5rem 1rem;
            background: transparent;
            border: 1px solid var(--border-default);
            border-radius: 8px;
            color: var(--text-secondary);
            font-size: 0.875rem;
            cursor: pointer;
            transition: all 150ms ease;
            text-decoration: none;
        }

        .header__back-btn:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .header__back-btn:focus {
            outline: 3px solid var(--accent-primary);
            outline-offset: 2px;
        }

        @media (max-width: 639px) {
            .header__back-btn-text {
                display: none;
            }
        }

        .header__theme-toggle {
            width: 40px;
            height: 40px;
            margin-left: 1rem;
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            color: var(--text-primary);
            transition: background 150ms ease;
        }

        .header__theme-toggle:hover {
            background: var(--bg-tertiary);
        }

        .header__theme-toggle:focus {
            outline: 3px solid var(--accent-primary);
            outline-offset: 2px;
        }

        .header__theme-icon {
            width: 24px;
            height: 24px;
        }



        /* Main Content */
        .main {
            flex-grow: 1;
            width: 100%;
            height: 100%;
            display: block;
            border: none;
        }

        .view {
            display: block;
            height: 100%;
        }
        .dash-scroll {
            overflow-y: scroll;
            height: calc(100vh - var(--header-height));
        }

        /* Dashboard View */
        .dashboard {
            padding: 2rem 1.5rem;
            margin: auto;
            min-height: 80dvh;
            display: block;
        }

        /* Search & Filter Bar */
        .filter-bar {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 1rem;
            margin-bottom: 2rem;
        }

        @media (min-width: 1024px) {
            .filter-bar {
                flex-direction: row;
                justify-content: flex-end;
            }
        }

        .search-input {
            width: 100%;
            height: 44px;
            padding: 0.5rem 2.75rem 0.5rem 2.75rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-default);
            border-radius: 8px;
            color: var(--text-primary);
            font-size: 0.875rem;
            transition: border 200ms ease, background 200ms ease;
            position: relative;
        }

        @media (min-width: 1024px) {
            .search-input {
                width: 320px;
            }
        }

        .search-input:focus {
            outline: none;
            border: 2px solid var(--accent-primary);
            background: var(--bg-secondary);
        }

        .search-input::placeholder {
            color: var(--text-tertiary);
        }

        .search-wrapper {
            position: relative;
            width: 100%;
        }

        .search-clear {
            position: absolute;
            right: 0.75rem;
            top: 50%;
            transform: translateY(-50%);
            width: 24px;
            height: 24px;
            background: transparent;
            border: none;
            color: var(--text-tertiary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            border-radius: 4px;
            transition: color 150ms ease, background 150ms ease;
        }

        .search-clear:hover {
            color: var(--text-primary);
            background: var(--bg-secondary);
        }

        .search-clear svg {
            width: 16px;
            height: 16px;
        }

        @media (min-width: 1024px) {
            .search-wrapper {
                width: 320px;
            }
        }

        .search-icon {
            position: absolute;
            left: 0.8rem;
            z-index: 1;
            top: 50%;
            transform: translateY(-50%);
            width: 25px;
            height: 25px;
            color: var(--text-tertiary);
            pointer-events: none;
        }

        .filter-trigger {
            display: flex;
            justify-content: space-between;
            min-width: 280px;
            align-items: center;
            gap: 0.5rem;
            height: 44px;
            padding: 0 1rem;
            background: var(--bg-secondary);
            border: 1px solid var(--border-default);
            border-radius: 8px;
            color: var(--text-primary);
            font-size: 0.875rem;
            cursor: pointer;
            transition: all 150ms ease;
            position: relative;
        }

        .filter-trigger:hover {
            background: var(--bg-tertiary);
        }

        .filter-trigger:focus {
            outline: 3px solid var(--accent-primary);
            outline-offset: 2px;
        }

        .filter-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 20px;
            height: 20px;
            padding: 0 0.375rem;
            background: var(--accent-primary);
            color: white;
            border-radius: 10px;
            font-size: 0.75rem;
            font-weight: 500;
        }

        .filter-chevron {
            width: 16px;
            height: 16px;
            transition: transform 200ms ease;
        }

        .filter-trigger[aria-expanded="true"] .filter-chevron {
            transform: rotate(180deg);
        }

        /* Filter Panel - Desktop Dropdown */
        .filter-panel {
            display: none;
            position: absolute;
            top: 100%;
            right: 0;
            margin-top: 0.5rem;
            width: 280px;
            max-height: 400px;
            overflow-y: auto;
            background: var(--bg-secondary);
            border: 1px solid var(--border-default);
            border-radius: 12px;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
            padding: 1rem;
            z-index: 501;
        }

        @media (min-width: 640px) {
            .filter-panel--active {
                display: block;
            }
        }

        /* Filter Panel - Mobile Slide-out */
        .filter-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(10, 10, 15, 0.4);
            z-index: 1000;
        }

        @media (max-width: 639px) {
            .filter-overlay--active {
                display: block;
            }

            .filter-panel {
                position: fixed;
                top: 0;
                right: 0;
                bottom: 0;
                width: 85%;
                max-width: 320px;
                max-height: 100vh;
                margin: 0;
                display: block;
                border-radius: 0;
                z-index: 1100;
                transform: translateX(100%);
                transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
            }

            .filter-panel.filter-panel--active {
                transform: translateX(0);
            }
        }

        .filter-close {
            display: none;
            position: absolute;
            top: 1rem;
            right: 1rem;
            width: 32px;
            height: 32px;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            color: var(--text-primary);
            cursor: pointer;
            border-radius: 4px;
        }

        @media (max-width: 639px) {
            .filter-close {
                display: flex;
            }
        }

        .filter-close:hover {
            background: var(--bg-tertiary);
        }

        .filter-group {
            margin-bottom: 1.5rem;
        }

        .filter-group:last-of-type {
            margin-bottom: 1rem;
        }

        .filter-group__label {
            display: block;
            font-size: 0.8125rem;
            font-weight: 500;
            letter-spacing: 0.02em;
            color: var(--text-tertiary);
            margin-bottom: 0.5rem;
            text-transform: uppercase;
        }

        .filter-option {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.5rem;
            border-radius: 6px;
            cursor: pointer;
            transition: background 150ms ease;
            margin-bottom: 0.25rem;
        }

        .filter-option:hover {
            background: var(--bg-tertiary);
        }

        .filter-checkbox {
            width: 20px;
            height: 20px;
            border: 2px solid var(--border-default);
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 200ms ease;
            flex-shrink: 0;
        }

        .filter-option input[type="checkbox"]:checked + .filter-checkbox {
            background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
            border-color: transparent;
        }

        .filter-option input[type="checkbox"]:focus + .filter-checkbox {
            outline: 2px solid var(--accent-primary);
            outline-offset: 2px;
        }

        .filter-checkbox::after {
            content: '✓';
            color: white;
            font-size: 0.875rem;
            display: none;
        }

        .filter-option input[type="checkbox"]:checked + .filter-checkbox::after {
            display: block;
        }

        .filter-option input[type="checkbox"] {
            position: absolute;
            opacity: 0;
            pointer-events: none;
        }

        .filter-option__label {
            font-size: 0.875rem;
            color: var(--text-primary);
            cursor: pointer;
        }

        .filter-actions {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            padding-top: 1rem;
            border-top: 1px solid var(--border-default);
        }

        .filter-clear {
            background: transparent;
            border: none;
            color: var(--text-secondary);
            font-size: 0.875rem;
            cursor: pointer;
            padding: 0.5rem;
            text-align: center;
            transition: color 150ms ease;
        }

        .filter-clear:hover {
            color: var(--text-primary);
        }

        .filter-apply {
            width: 100%;
            padding: 0.75rem 1.5rem;
            background: var(--accent-primary);
            border: none;
            border-radius: 8px;
            color: white;
            font-size: 0.875rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 150ms ease;
        }

        .filter-apply:hover {
            background: var(--accent-secondary);
            transform: scale(1.02);
        }

        .filter-apply:active {
            transform: scale(0.98);
        }

        .filter-apply:focus {
            outline: 3px solid var(--accent-primary);
            outline-offset: 2px;
        }

        /* Tool Card Grid */
        .tool-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            grid-auto-rows: 1fr;
            gap: 1.5rem;
            margin-bottom: 3rem;
        }

        /* Tool Card */
        .tool-card-wrap {
            height: 100%;
            display: block;
        }

        .tool-card {
            background: var(--bg-secondary);
            border: 1px solid var(--border-default);
            border-radius: 25px;
            padding: 1.5rem;
            transition: all 400ms ease;
            text-decoration: none;
            color: inherit;
            display: block;
            position: relative;
            min-width: 0;
            width: 100%;
            height: 100%;
            box-sizing: border-box;
            cursor: pointer;
        }

        .tool-card:hover {
            border: 1px solid #ac00e0; 
            box-shadow: 0 12px 32px var(--shadow-hover);
            border-radius: 1px;
        }

        .tool-card:hover .tool-card__logo {
            filter: 
                drop-shadow(0 0 5px var(--logo-shadow))
                drop-shadow(0 0 10px var(--logo-shadow));
        }

        .tool-card:focus {
            outline: 3px solid var(--accent-primary);
            outline-offset: 2px;
        }

        .tool-card__logo {
            width: 64px;
            height: 64px;
            border-radius: 50%;
            background: var(--bg-primary);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 1rem;
            transition: all 500ms ease-out;
            overflow: hidden;
        }

        .letter-fallback {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 32px;
            font-weight: bold;
            margin: auto;
        }


        .tool-card__logo img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: none;
        }

        .tool-card__title {
            font-size: 1.125rem;
            font-weight: 600;
            line-height: 1.4;
            color: var(--text-primary);
            margin-bottom: 0.25rem;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .tool-card__description {
            font-size: 0.875rem;
            line-height: 1.6;
            color: var(--text-secondary);
            margin-bottom: 1rem;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .tool-card__link-icon {
            position: absolute;
            top: 1.5rem;
            right: 1.5rem;
            width: 24px;
            height: 24px;
            color: var(--accent-primary);
            transition: color 150ms ease;
        }

        .tool-card:hover .tool-card__link-icon {
            color: var(--accent-secondary);
        }

        /* Tool Page View */
        .tool-view {
            background-color: var(--bg-primary);
            display: block;
            width: 100%;
        }

        @media (min-width: 1024px) {
            .tool-view {
                height: calc(100vh - 72px);
            }
        }

        .tool-loader-wrap {
            width: 100%;
            height: 100%;
            background-color: var(--bg-primary);
            position: relative;
            z-index: 50;
        }

        .tool-loader {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .tool-loader__spinner {
            width: 48px;
            height: 48px;
            border: 4px solid var(--bg-tertiary);
            border-top-color: var(--accent-primary);
            border-right-color: var(--accent-secondary);
            border-radius: 50%;
            animation: spin 1.2s linear infinite;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        .tool-loader__text {
            font-size: 0.875rem;
            color: var(--text-secondary);
        }

        .tool-iframe {
            width: 100%;
            height: 100%;
            border: none;
            background: var(--bg-secondary);
            opacity: 0;
            transition: opacity 300ms ease;
        }

        .tool-iframe--loaded {
            opacity: 1;
        }

        /* Empty State */
        .empty-state {
            display: none;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            text-align: center;
            padding: 1.5rem;
            min-height: 50vh;
        }

        .empty-state--visible {
            display: flex;
        }

        .empty-state__icon {
            width: 50px;
            height: 50px;
            color: var(--text-tertiary);
            margin-bottom: 1rem;
        }

        .empty-state__title {
            font-size: 1.5rem;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 0.5rem;
        }

        .empty-state__description {
            font-size: 0.875rem;
            color: var(--text-secondary);
            margin-bottom: 1.5rem;
            max-width: 400px;
        }

        .empty-state__action {
            padding: 0.75rem 1.5rem;
            background: var(--accent-primary);
            border: none;
            border-radius: 8px;
            color: white;
            font-size: 0.875rem;
            font-weight: 500;
            cursor: pointer;
            transition: all 150ms ease;
        }

        .empty-state__action:hover {
            background: var(--accent-secondary);
            transform: scale(1.02);
        }

        /* Footer */
        .footer {
            display: block;
            padding: 2rem 1.5rem;
            background: var(--bg-primary);
            border-top: 1px solid var(--border-default);
            text-align: center;
        }

        .footer__text {
            font-size: 0.75rem;
            color: var(--text-tertiary);
        }

        .footer__link {
            color: var(--text-secondary);
            text-decoration: none;
            transition: color 150ms ease;
        }

        .footer__link:hover {
            color: var(--text-primary);
            text-decoration: underline;
        }

        /* Utilities */
        .visually-hidden {
            position: absolute;
            width: 1px;
            height: 1px;
            padding: 0;
            margin: -1px;
            overflow: hidden;
            clip: rect(0, 0, 0, 0);
            white-space: nowrap;
            border-width: 0;
        }

        /* Results Count */
        .results-count {
            font-size: 0.875rem;
            color: var(--text-secondary);
            margin-bottom: 1rem;
        }

        /* Last so it is not overwritten by other rules */
        .hidden {
            display: none; 
        }