/* File: css/base.css */
/* --- User Provided Fonts --- */
@font-face {
  font-family: 'Noto Serif SC';
  src: url('https://static.tian14.com/fonts/NotoSerifSC-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Noto Serif SC';
  src: url('https://static.tian14.com/fonts/NotoSerifSC-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Noto Serif SC';
  src: url('https://static.tian14.com/fonts/NotoSerifSC-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

/* --- "Modern Dark" Theme (Default) --- */
:root {
    --color-bg: #121212; /* Standard Dark Grey */
    --color-bg-transparent: rgba(18, 18, 18, 0.8);
    --color-bg-input: #2d2d2d;
    --color-bg-input-focus: #3d3d3d;
    --color-footer-bg: #181818;
    --color-text: #e0e0e0; /* Soft White */
    --color-text-muted: #a0a0a0;
    --color-placeholder: #666666;
    --color-card-bg: #1e1e1e; /* Slightly lighter grey for cards */
    --color-border: #333333;
    --color-border-strong: #444444;
    --color-primary: #3cc2f5; /* Keep Icy Blue for accent */
    --color-primary-dark: #2aabd9;
    --color-accent-pink: #ff6b81;
    --color-accent-pink-dark: #ff4757;
    --color-accent-pink-glow: rgba(255, 107, 129, 0.5);
    --color-error: #ff7675;
    --color-success: #55efc4;
    --glow-color-default: #3cc2f5;

    /* Tooltip Variables (Dark Theme Default -> White Tooltip) */
    --color-tooltip-bg: #ffffff;
    --color-tooltip-text: #121212;
    
    /* Deprecated login variables, kept for reference but mapped to new theme */
    --color-login-overlay: rgba(0, 0, 0, 0.6);
    --color-login-box: #1e1e1e;
    --color-border-login: #333333;

    /* Button Variables (Dark Theme) */
    --btn-bg: #101010;
    --btn-text: #ffffff;
    --btn-text-dim: rgba(255, 255, 255, 0.35);
    --btn-border: rgba(255, 255, 255, 0.15);
    --btn-icon-fill: #e8e8e8;
    --btn-shadow-inset-1: rgba(255, 255, 255, 0.2);
    --btn-shadow-inset-2: rgba(255, 255, 255, 0.05);
    --btn-shadow-drop: rgba(0, 0, 0, 0.05);
    --btn-pseudo-bg: rgba(0,0,0,0.2); /* For the ::before element */
    --featured-card-highlight: var(--color-primary); /* Default to primary for dark theme */
}

html, body, a, button, input, select, textarea {
    /* cursor: none; Removed to restore default cursor */
}

/* --- "Arctic Ice" Light Theme --- */
html[data-theme="light"] {
    --color-bg: #f0f8ff; /* Alice Blue */
    --color-bg-transparent: rgba(255, 255, 255, 0.7);
    --color-bg-input: rgba(0, 0, 0, 0.05);
    --color-bg-input-focus: rgba(0, 0, 0, 0.08);
    --color-footer-bg: #e3f2fd;
    --color-text: #0b132b; /* Dark Blue */
    --color-text-muted: #3a506b;
    --color-placeholder: #6a7c95;
    --color-card-bg: #ffffff;
    --color-border: rgba(0, 0, 0, 0.1);
    --color-border-strong: rgba(0, 0, 0, 0.2);
    --color-primary: #0077b6; /* Saturated Blue */
    --color-primary-dark: #005f9e;
    --color-accent-pink: #ff8fa3;
    --color-accent-pink-dark: #ff6b81;
    --color-accent-pink-glow: rgba(255, 143, 163, 0.5);

    /* Tooltip Variables (Light Theme -> Dark Tooltip) */
    --color-tooltip-bg: #2c3e50;
    --color-tooltip-text: #ffffff;

    /* Login/Modal Variables for Light Theme */
    --color-login-box: #ffffff;
    --color-border-login: rgba(0, 0, 0, 0.1);
    --color-login-overlay: rgba(240, 248, 255, 0.6);

    /* Button Variables (Light Theme) */
    --btn-bg: #ffffff;
    --btn-text: #0b132b;
    --btn-text-dim: rgba(11, 19, 43, 0.4);
    --btn-border: rgba(0, 0, 0, 0.1);
    --btn-icon-fill: #0b132b;
    --btn-shadow-inset-1: rgba(0, 0, 0, 0.05); /* Subtle dark inset for light mode */
    --btn-shadow-inset-2: rgba(0, 0, 0, 0.02);
    --btn-shadow-drop: rgba(0, 0, 0, 0.1);
    --btn-pseudo-bg: rgba(0,0,0,0.05);
    --featured-card-highlight: #FFA500; /* Orange for light theme */
}

html { 
    scroll-behavior: smooth; 
    background-color: var(--color-bg);
}

body {
    /* Updated Font */
    font-family: 'Noto Serif SC', serif;
    font-weight: 400;
    line-height: 1.6;
    margin: 0;
    /* Removed padding: 20px 0; to allow flexbox to control the full height */
    color: var(--color-text);
    min-height: 100vh;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Ensure form elements inherit the global font */
button, input, select, textarea {
    font-family: inherit;
}

#password-overlay,
header, 
main, 
footer, 
#scroll-to-top-btn, 
.logout-btn,
.login-btn, /* Added login-btn */
.theme-btn, 
#search-input,
.tool-list a,
.control-btn,
.category-title,
.login-container,
.back-to-home,
#side-dock {
    pointer-events: auto;
}

/* File: css/layout.css */
header, main { 
    opacity: 0; 
    transition: opacity 0.5s ease-in-out;
}

header {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%;
    padding: 15px 5%;
    z-index: 1000;
    background: var(--color-bg-transparent);
    border-bottom: 1px solid var(--color-border);
    box-sizing: border-box;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

main {
    max-width: 900px;
    width: 90%;
    margin: 20px auto;
    flex-grow: 1;
}

footer {
    text-align: center;
    padding: 15px 30px;
    margin: 40px auto 0;
    font-size: 1rem;
    color: var(--color-text-muted);
    background: var(--color-footer-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid var(--color-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
    transition: background-color 0.3s ease, color 0.3s ease;
    width: 70%;
}

#password-overlay {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    z-index: 9999;
    background: var(--color-login-overlay);
    backdrop-filter: blur(20px);
    display: flex; 
    justify-content: center; 
    align-items: center;
    opacity: 0;
    animation: fadeIn 0.5s forwards;
    transition: background-color 0.3s ease;
}

.login-box {
    background: var(--color-login-box);
    padding: 30px 40px;
    border-radius: 16px;
    border: 1px solid var(--color-border-login);
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.2);
    text-align: center;
    width: 90%;
    max-width: 350px;
    display: flex; 
    flex-direction: column;
    transform: scale(0.95);
    animation: fadeInScale 0.5s 0.2s forwards;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

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

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* --- Settings Dropdown --- */
.settings-btn {
    position: relative;
    z-index: 1002; /* Ensure button is above dropdown and its pseudo-elements */
}

.settings-dropdown {
    position: absolute;
    top: 100%;
    right: -40px; /* Desktop default: slightly right */
    margin-top: 25px; /* Spacing from button */
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    padding: 15px;
    min-width: 220px; 
    opacity: 0;
    visibility: hidden; /* Reverted to visibility */
    transform: translateY(-20px) scale(0.95); /* Start slightly higher and smaller */
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    
    display: flex;
    flex-direction: column;
}

/* Simple Bridge: Only fills the vertical gap between button and menu */
.settings-dropdown::before {
    content: '';
    position: absolute;
    top: -30px;
    left: 0;
    width: 100%;
    height: 30px;
    background: transparent;
}

.settings-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Mobile Responsive Styles for Dropdown */
@media (max-width: 768px) {
    .settings-dropdown {
        position: fixed;
        top: 75px; /* Below header */
        left: 50%; /* Center horizontally */
        right: auto;
        margin-top: 0;
        transform: translateX(-50%) translateY(-10px); /* Combine centering with animation start */
        width: 90%; /* Responsive width */
        max-width: 320px;
    }

    .settings-dropdown.active {
        transform: translateX(-50%) translateY(0); /* Combine centering with animation end */
    }
}

/* Style for buttons inside the menu */
.settings-menu-btn {
    width: 100%;
    justify-content: flex-start; /* Align text left */
    margin-bottom: 10px;
    margin-left: 0 !important; /* Override header sibling margin */
    height: 45px; /* Slightly taller for menu comfort */
    font-size: 0.95rem;
}

.settings-menu-btn:last-child {
    margin-bottom: 0;
}

.settings-menu-btn .btn-svg {
    margin-right: 12px; /* More space between icon and text */
}

.settings-divider {
    height: 1px;
    background-color: var(--color-border);
    margin: 5px 0 15px 0;
    opacity: 0.5;
    width: 100%;
}

#initial-loader {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background-color: #1a1a1a;
    display: flex; 
    flex-direction: column;
    justify-content: center; 
    align-items: center; 
    z-index: 10000;
}

.spinner {
    width: 40px; 
    height: 40px; 
    border: 4px solid #444;
    border-top: 4px solid #fff; 
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* --- Footer Content Styling --- */
.footer-inner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
}

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

/* Footer Responsive Adjustments */
@media (max-width: 768px) {
    footer {
        width: 90%; /* Matching main width */
        padding: 15px;
        margin-bottom: 20px; /* Add some bottom space on mobile */
    }
}


/* File: css/components.css */
.password-box {
    width: 90%;
    max-width: 400px;
    padding: 30px 40px;
    background: var(--color-login-box);
    backdrop-filter: blur(10px);
    border: 1px solid var(--color-border-login);
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    text-align: center;
    transform: scale(0.95);
    animation: fadeInScale 0.5s 0.2s forwards;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.password-box h1 {
    margin: 0 0 30px;
    padding: 0;
    color: var(--color-text);
    font-size: 2em;
    font-weight: 600;
}

.password-box .input-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.password-box .input-wrapper {
    position: relative;
    width: 100%;
}

.password-box .input-wrapper i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-placeholder);
    transition: color 0.3s ease, transform 0.3s ease;
    z-index: 1; 
}

.password-box input {
    width: 100%;
    padding: 15px 20px 15px 45px; 
    font-size: 1rem;
    color: var(--color-text);
    background-color: var(--color-bg-input);
    border: 1px solid var(--color-border-login);
    border-radius: 8px;
    outline: none;
    box-sizing: border-box;
    transition: all 0.3s ease;
    font-family: inherit;
}

.password-box input::placeholder {
    color: var(--color-placeholder);
}

.password-box input:focus {
    border-color: var(--color-primary);
    background-color: var(--color-bg-input-focus);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.password-box .input-wrapper:focus-within i {
    color: var(--color-primary);
    transform: translateY(-50%) scale(1.1); 
}

.password-box button {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 8px;
    background-image: linear-gradient(to right, var(--color-primary), var(--color-primary-dark));
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 10px;
    font-family: inherit;
}

.password-box button:hover {
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    transform: translateY(-2px);
}

.password-box button:active {
    transform: translateY(0) scale(0.98);
    box-shadow: none;
}

.password-box button:disabled {
    background-image: none;
    background: #555;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.password-box .error-message {
    min-height: 20px;
    color: var(--color-error);
    font-weight: 500;
    margin-top: -15px;
    margin-bottom: 15px;
    transition: opacity 0.3s;
    opacity: 0;
}
.password-box .error-message.show {
    opacity: 1;
}

.password-box .form-switcher {
    margin-top: 20px;
    font-size: 14px;
    color: var(--color-text-muted);
}

.password-box .form-switcher a {
    color: var(--color-primary);
    text-decoration: none;
}
.password-box .form-switcher a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

/* --- Header Components --- */
.logo-title {
    font-size: 1.5em; 
    margin: 0 20px;
    text-shadow: 0 0 5px var(--color-text-muted);
}

.logout-btn {
    background: transparent; 
    border: 1px solid var(--color-border-strong);
    color: var(--color-text-muted); 
    padding: 8px 16px; 
    border-radius: 20px;
    cursor: pointer; 
    font-family: inherit; 
    transition: all 0.2s ease; 
    margin: 0;
}

.logout-btn:hover { 
    background: var(--color-card-bg); 
    color: var(--color-text); 
    border-color: var(--color-text); 
}

/* --- Featured Tools Section --- */
.featured-tools {
    margin-bottom: 40px;
    padding: 10px;
    background: rgba(0,0,0,0.1);
    border-radius: 12px;
    position: relative; /* Ensure positioning context */
    z-index: 1; /* Ensure content is above the pseudo-element */
}

.featured-tools::before {
    content: '';
    position: absolute;
    top: -8px; left: -8px; right: -8px; bottom: -8px; /* Outside spacing */
    border-radius: 16px; /* Slightly larger radius */
    pointer-events: none; /* Don't block clicks */
    z-index: -1; /* Behind content */
    
    /* The 4 corners using gradients - ELONGATED */
    background: 
        /* Top Left (Horizontal long, Vertical short) */
        linear-gradient(to right, var(--color-primary) 2px, transparent 2px) top left / 40px 20px no-repeat,
        linear-gradient(to bottom, var(--color-primary) 2px, transparent 2px) top left / 40px 20px no-repeat,
        /* Top Right (Pink Accent) */
        linear-gradient(to left, var(--color-accent-pink) 2px, transparent 2px) top right / 40px 20px no-repeat,
        linear-gradient(to bottom, var(--color-accent-pink) 2px, transparent 2px) top right / 40px 20px no-repeat,
        /* Bottom Right */
        linear-gradient(to left, var(--color-primary) 2px, transparent 2px) bottom right / 40px 20px no-repeat,
        linear-gradient(to top, var(--color-primary) 2px, transparent 2px) bottom right / 40px 20px no-repeat,
        /* Bottom Left (Pink Accent) */
        linear-gradient(to right, var(--color-accent-pink) 2px, transparent 2px) bottom left / 40px 20px no-repeat,
        linear-gradient(to top, var(--color-accent-pink) 2px, transparent 2px) bottom left / 40px 20px no-repeat;
        
    /* Glow effect - Mixed Blue and Pink */
    filter: drop-shadow(-2px -2px 4px var(--color-primary)) drop-shadow(2px 2px 4px var(--color-accent-pink));
    opacity: 0.6;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.featured-tools:hover::before {
    opacity: 1;
    transform: scale(1.01);
    filter: drop-shadow(-2px -2px 8px var(--color-primary)) drop-shadow(2px 2px 8px var(--color-accent-pink));
}

.featured-tools h2 {
    font-size: 1.2rem;
    margin: 0 10px 10px;
    color: var(--color-text-muted);
}

.featured-scroll-container {
    display: flex;
    overflow-x: auto;
    gap: 20px;
    padding: 10px 10px 18px 10px; /* Extra bottom padding for scrollbar */
    /* Removed scrollbar hiding properties to allow custom scrollbar */
}
/* Custom Scrollbar for Featured Tools */
.featured-scroll-container::-webkit-scrollbar {
    height: 6px;
}
.featured-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}
.featured-scroll-container::-webkit-scrollbar-thumb {
    background-color: var(--color-border-strong);
    border-radius: 3px;
}
.featured-scroll-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-text-muted);
}

.featured-item-wrapper {
    flex: 0 0 220px;
    position: relative;
}

.featured-card {
    display: block;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 15px;
    text-decoration: none;
    color: var(--color-text);
    background: var(--color-border-strong); /* Acts as static border color initially */
    border-radius: 12px;
    position: relative;
    z-index: 0;
    overflow: hidden;
    transition: transform 0.2s ease-out;
    padding: 1px; /* The border width */
}

/* The Content Container (Simulated by the ::after pseudo) */
.featured-card::after {
    content: '';
    position: absolute;
    inset: 1px; /* Match padding/border width */
    background: var(--color-card-bg);
    border-radius: 11px; /* 12px - 1px */
    z-index: -1;
}

/* The Rotating Light Border (Hidden by default) */
.featured-card::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 250%;
    height: 250%;
    background: conic-gradient(
        transparent 0deg,
        var(--featured-card-highlight) 50deg,
        transparent 90deg,
        transparent 180deg,
        var(--featured-card-highlight) 230deg,
        transparent 270deg
    );
    transform: translate(-50%, -50%);
    z-index: -2;
    opacity: 0; /* Hidden normally */
    transition: opacity 0.3s ease;
}

.featured-card:hover {
    transform: translateY(-5px);
    /* border-color: transparent; handled by background */
}

.featured-card:hover::before {
    opacity: 1;
    animation: rotateBorder 4s linear infinite;
}

/* Edit Mode Overrides for Featured Cards */
body.edit-mode-active .featured-card:hover {
    transform: translateY(0); /* Disable float effect */
    cursor: pointer;
}
body.edit-mode-active .featured-card:hover::before {
    opacity: 0; /* Disable rotating border */
    animation: none;
}
body.edit-mode-active .featured-item-wrapper:hover .tool-item-controls {
    opacity: 1;
    pointer-events: auto;
}

@keyframes rotateBorder {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Ensure content is above the background */
.featured-card .tool-name,
.featured-card .tool-description {
    position: relative;
    z-index: 2;
}

/* Reset padding for the inner content visual alignment */
.featured-card .tool-name {
    display: flex;
    align-items: center;
    font-size: 1rem;
    font-weight: 600;
    margin: 14px 14px 10px; /* Re-apply padding visually */
}

.featured-card .tool-description {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0 14px 14px; /* Re-apply padding visually */
}

.featured-card .tool-name i {
    font-size: 1.2rem;
    margin-right: 15px;
    color: var(--color-primary);
    width: 30px;
    text-align: center;
}


.tool-category { 
    margin-bottom: 40px; 
    scroll-margin-top: 100px; /* Ensure scrolling stops before the fixed header covers it */
}


.category-title {
    font-size: 1.6rem; 
    padding: 10px 0 10px 20px; /* Added left padding for the beam */
    margin-bottom: 25px;
    position: relative;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    color: var(--color-text);
    font-weight: 600;
    /* Gradient bottom border fading to right */
    background-image: linear-gradient(to right, var(--color-border-strong), transparent);
    background-size: 100% 1px;
    background-position: bottom;
    background-repeat: no-repeat;
    transition: color 0.3s ease;
}

/* The "Quantum Beam" - Glowing Left Bar */
.category-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 24px; /* Slightly shorter than text height */
    background: linear-gradient(to bottom, var(--color-primary), var(--color-accent-pink));
    border-radius: 2px;
    box-shadow: 0 0 10px var(--color-primary); /* The glow effect */
    transition: height 0.3s ease, box-shadow 0.3s ease;
}

/* Hover Effect */
.category-title:hover {
    color: var(--color-primary); /* Text lights up */
}

.category-title:hover::before {
    height: 32px; /* Beam expands */
    box-shadow: 0 -5px 15px var(--color-primary), 0 5px 15px var(--color-accent-pink), 0 0 5px #fff; /* Glow intensifies with pink */
}

/* The Count Badge (number inside span) */
.category-title span {
    font-size: 0.85rem;
    font-weight: normal;
    margin-left: 12px;
    padding: 2px 8px;
    background: rgba(128, 128, 128, 0.2); /* Subtle background */
    border-radius: 12px;
    color: var(--color-text-muted);
    border: 1px solid rgba(128, 128, 128, 0.1);
    transition: all 0.3s ease;
}

.category-title:hover span {
    color: var(--color-text);
    background: rgba(var(--rgb-primary), 0.15);
    border-color: rgba(var(--rgb-primary), 0.3);
}

/* The Arrow Indicator (Re-styled) */
.category-title::after {
    content: '';
    margin-left: auto; /* Push to the far right */
    width: 8px;
    height: 8px;
    border-style: solid;
    border-width: 0 2px 2px 0;
    border-color: var(--color-text-muted);
    transform: rotate(45deg);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
    opacity: 0.7;
}

.category-title:hover::after {
    border-color: var(--color-primary);
    opacity: 1;
}

.tool-category.collapsed .category-title::after {
    transform: rotate(-135deg);
}

/* When collapsed, dim the beam slightly to indicate inactive state */
.tool-category.collapsed .category-title::before {
    background: var(--color-text-muted);
    box-shadow: none;
    height: 16px;
}

.tool-list-wrapper {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                margin-top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 20px;
    overflow: visible; /* Allow tooltips and shadows to extend outside */
}

.tool-category.collapsed .tool-list-wrapper {
    grid-template-rows: 0fr;
    margin-top: 0;
    overflow: hidden; /* Clip content only when collapsed */
}

.tool-list {
    list-style: none;
    padding: 0;
    min-height: 0;
    overflow: visible;
    
    /* Create a reasonable buffer for shadows/hovers */
    padding: 20px;
    margin: -20px;
    
    box-sizing: content-box;
    transition: opacity 0.3s ease-out 0.1s, 
                visibility 0s linear 0.1s;
}

.tool-category.collapsed .tool-list {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease-in, 
                visibility 0s linear 0.25s;
}

.tool-list li {
    position: relative; 
    opacity: 0;
    transform: translateY(20px);
    width: 100%; /* Ensure li fills grid cell */
    display: flex; /* Allow child anchor to fill height/width */
}

.tool-list li.in-view {
    animation: cardFadeIn 0.5s ease-out forwards;
}

.tool-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 20px;
}

.tool-list a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%; /* Ensure it fills the grid cell */
    flex: 1; /* Grow to fill li */
    box-sizing: border-box; /* Include padding in width */
    height: 90px;
    padding: 10px;
    text-decoration: none;
    color: var(--color-text); 
    background: var(--color-card-bg);
    border: 1px solid var(--color-border); 
    border-radius: 12px;
    transition: all 0.2s ease-out;
    will-change: transform; /* Hint for browser optimization */
    position: relative; /* Ensure z-index works */
    z-index: 1;
}

.tool-list a:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--color-primary);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    z-index: 10; /* Bring to front on hover */
}

.tool-list a i {
    font-size: 1.5rem;
    color: var(--color-primary);
    transition: transform 0.2s ease-out;
    /* Metrics matching image icons for consistent layout */
    height: 32px;
    width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px; /* Reduced from 12px to closer to text */
}

.tool-list a:hover i {
    transform: scale(1.1);
}

/* Tooltip for Full Name */
.tool-list a[data-fullname]:hover::after {
    content: attr(data-fullname);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease-out forwards;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    font-weight: normal;
}

/* Triangle for tooltip */
.tool-list a[data-fullname]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(1px); /* Slightly overlap to avoid gap */
    border-width: 6px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
    z-index: 1000;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease-out forwards;
}

@keyframes tooltipFadeIn {
    to { opacity: 1; transform: translateX(-50%) translateY(-8px); }
}

.tool-list a .tool-name {
    font-size: 0.85rem;
    font-weight: 500;
    
    /* Text Truncation Logic */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: block;
    padding: 0 4px; /* Slight padding to prevent text touching edges */
    box-sizing: border-box;
}

/* Edit Mode Overrides */
body.edit-mode-active .tool-list a:hover {
    transform: translateY(0); /* Disable float effect */
    box-shadow: none; /* Disable box-shadow on hover */
    border-color: var(--color-border); /* Revert border color */
    background: var(--color-card-bg); /* Revert background */
    cursor: pointer; /* Keep cursor as pointer */
}

body.edit-mode-active .tool-list a:hover i {
    transform: none; /* Disable icon scale effect */
}


.edit-controls,
.category-controls,
.add-category-btn {
    display: none;
}

.edit-mode-active .edit-controls {
    display: inline-flex;
    gap: 6px; 
}
.edit-mode-active .category-controls {
    display: inline-flex;
    font-size: 0.8em;
    align-items: center;
    gap: 15px;
    margin-left: 15px;
}
.edit-mode-active .add-category-btn {
    display: block;
    margin: 40px auto;
    padding: 10px 25px;
    font-size: 1.1rem;
    font-family: inherit;
    border-radius: 20px;
    border: 1px solid var(--color-border-strong);
    background-color: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    width: auto;
}
.edit-mode-active .add-category-btn:hover {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.tool-item-controls {
    position: absolute;
    top: 12px;
    right: 10px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    visibility: hidden; /* Ensure it doesn't block mouse events */
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}
.edit-mode-active .tool-list li:hover .tool-item-controls {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.control-btn {
    background: rgba(128, 128, 128, 0.3);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}
.control-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 0 8px var(--color-primary), 0 0 8px var(--color-accent-pink-glow); /* Mixed glow */
}
.control-btn.delete:hover {
    background: #e74c3c;
    border-color: #e74c3c;
    box-shadow: 0 0 8px #e74c3c, 0 0 8px rgba(231, 76, 60, 0.4); /* Red glow */
}
.control-btn.delete:hover {
    background: #e74c3c;
    border-color: #e74c3c;
}

.favorite-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 11; 
    color: var(--color-text-muted);
}
.favorite-btn:hover {
    color: var(--color-accent-pink);
    background-color: transparent;
    border-color: transparent;
}
.favorite-btn.favorited {
    color: var(--color-accent-pink-dark);
    background-color: var(--color-accent-pink-glow); /* Using the transparent pink variable */
    border-color: var(--color-accent-pink-dark);
}
.favorite-btn.favorited:hover {
    color: #fff;
    background-color: var(--color-accent-pink-dark);
    border-color: var(--color-accent-pink-dark);
}
.favorite-btn svg {
    transition: all 0.2s ease-in-out;
}
.favorite-btn.favorited svg {
    filter: drop-shadow(0 0 3px var(--color-accent-pink-dark));
}

#scroll-to-top-btn {
    position: fixed; 
    bottom: 90px; 
    right: 30px; 
    z-index: 999;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent-pink-dark));
    color: white;
    border: none; 
    border-radius: 50%; 
    width: 50px; 
    height: 50px;
    display: flex; 
    justify-content: center; 
    align-items: center;
    cursor: pointer; 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0; 
    transform: translateY(20px); 
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

#scroll-to-top-btn.visible { 
    opacity: 1; 
    transform: translateY(0); 
    pointer-events: auto; 
}

#scroll-to-top-btn:hover { 
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-accent-pink));
    box-shadow: 0 6px 16px rgba(255, 107, 129, 0.4);
}

#info-menu-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent-pink-dark));
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

#info-menu-btn:hover {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-accent-pink));
    box-shadow: 0 6px 16px rgba(255, 107, 129, 0.4);
    transform: scale(1.05);
}

#footer-menu-popover {
    position: fixed;
    bottom: 30px;
    right: 90px;
    background: var(--color-card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 5px 0; /* Reduced padding top/bottom */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0; /* Remove gap for separators */
    min-width: 180px;
    
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
}

#footer-menu-popover.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0) scale(1);
}

#footer-menu-popover a,
#footer-menu-popover button {
    display: block;
    padding: 12px 15px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: 0; /* Remove radius for stacking */
    transition: background-color 0.2s ease;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px dashed var(--color-border); /* Dashed separator */
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

/* Remove separator from the last item */
#footer-menu-popover > *:last-child {
    border-bottom: none;
}

/* Round top corners of first item */
#footer-menu-popover > *:first-child {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

/* Round bottom corners of last item */
#footer-menu-popover > *:last-child {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

#footer-menu-popover a:hover,
#footer-menu-popover button:hover {
    background-color: rgba(var(--rgb-primary), 0.1); 
    color: var(--color-primary);
}
#footer-menu-popover button {
    text-align: left;
}

.search-container {
    position: relative;
    flex-grow: 1;
    max-width: 400px;
    margin: 0 25px;
}

.search-icon {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
    transition: color 0.3s ease, filter 0.3s ease;
}

.search-container:focus-within .search-icon {
    color: var(--color-primary);
    filter: drop-shadow(0 0 5px rgba(52, 152, 219, 0.4));
}

#search-input {
    width: 100%;
    padding: 10px 15px 10px 45px;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    background-color: var(--color-bg-input);
    color: var(--color-text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-sizing: border-box;
}

#search-input::placeholder {
    color: var(--color-placeholder);
}

#search-input:hover {
    border-color: var(--color-border-strong);
    background-color: var(--color-bg-input-focus); 
}

#search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background-color: var(--color-bg-input-focus);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15), 0 4px 15px rgba(0, 0, 0, 0.1);
}

.search-clear-btn {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.search-clear-btn:hover {
    color: var(--color-text);
    background-color: rgba(128, 128, 128, 0.2);
}

/* --- Theme Toggle Button --- */
.theme-btn {
    background: transparent;
    border: 1px solid var(--color-border-strong);
    color: var(--color-text-muted);
    width: 38px;
    height: 33px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: all 0.2s ease;
    font-family: inherit;
}

.theme-btn:hover {
    background: var(--color-card-bg);
    color: var(--color-text);
    border-color: var(--color-text);
}

.theme-btn svg {
    transition: transform 0.3s ease-out;
}

/* --- Modal Dialog --- */
#modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#modal-container.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--color-login-box);
    padding: 25px 30px;
    border-radius: 16px;
    border: 1px solid var(--color-border-login);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 450px;
    position: relative;
    transform: scale(0.95) translateY(-20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#modal-container.active .modal-box {
    transform: scale(1) translateY(0);
    opacity: 1;
}

#modal-title {
    margin: 0 0 20px 0;
    font-size: 1.6rem;
    color: var(--color-text);
    text-align: center;
}

#modal-body {
    margin-bottom: 30px;
}

#modal-body form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#modal-body .form-group {
    display: flex;
    flex-direction: column;
}

#modal-body label {
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* --- Form Elements in Modal --- */

/* Shared base styles (except Select which needs special handling) */
#modal-body input[type="text"],
#modal-body input[type="number"],
#modal-body input[type="url"],
#modal-body textarea {
    display: block;
    width: 100%;
    height: 46px;
    box-sizing: border-box;
    padding: 12px 15px;
    margin: 0;
    border: 1px solid var(--color-border-login);
    border-radius: 8px;
    background-color: var(--color-bg-input);
    color: var(--color-text);
    font-size: 1rem;
    line-height: 1.5;
    transition: all 0.2s ease;
    font-family: 'Noto Serif SC', serif;
}

#modal-body textarea {
    height: auto;
    min-height: 100px;
    resize: vertical;
}

/* Select Element - Custom Styling to Match Inputs */
#modal-body select {
    display: block;
    width: 100%;
    height: 46px; /* Match input height exactly */
    box-sizing: border-box;
    padding: 12px 40px 12px 15px; /* Extra right padding for arrow */
    margin: 0;
    border: 1px solid var(--color-border-login);
    border-radius: 8px;
    background-color: var(--color-bg-input);
    color: var(--color-text);
    font-size: 1rem;
    line-height: 1.5;
    transition: all 0.2s ease;
    font-family: 'Noto Serif SC', serif;
    
    /* Remove default system appearance */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    
    /* Custom Arrow */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0a0a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    cursor: pointer;
}

#modal-body select option {
    background-color: var(--color-login-box);
    color: var(--color-text);
    font-family: 'Noto Serif SC', serif;
    padding: 10px;
}

#modal-body select:focus {
    outline: none;
    border-color: var(--color-primary);
    background-color: var(--color-bg-input-focus);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

#modal-body input:focus,
#modal-body textarea:focus,
#modal-body select:focus {
    outline: none;
    border-color: var(--color-primary);
    background-color: var(--color-bg-input-focus);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

#modal-body .checkbox-group {
    display: flex;
    align-items: flex-start; /* Align to top if text wraps */
    gap: 10px;
    cursor: pointer;
    user-select: none;
    padding: 8px 0;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

#modal-body .checkbox-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    margin-top: 2px; /* Slight offset for visual alignment with text */
    flex-shrink: 0; /* Prevent shrinking */
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border-login);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

#modal-body .checkbox-group input[type="checkbox"]:checked {
    /* 3. 选中时的样式 */
    background-color: var(--color-primary); /* Keep primary background */
    border-color: var(--color-primary);
}

#modal-body .checkbox-group input[type="checkbox"]:checked::before {
    content: '';
    position: absolute;
    top: 1px; /* Adjusted for better centering */
    left: 4px; /* Adjusted for better centering */
    width: 4px;
    height: 9px;
    border-style: solid;
    border-color: #fff; /* White checkmark for high contrast against primary color */
    border-width: 0 3px 3px 0; /* Thicker checkmark */
    transform: rotate(45deg);
}

#modal-body .checkbox-group label {
    font-size: 0.95rem;
    color: var(--color-text);
    line-height: 1.4;
    padding-top: 1px; /* Micro-adjustment */
    cursor: pointer;
}

#modal-body p {
    color: var(--color-text);
    text-align: center;
    font-size: 1.1rem;
    line-height: 1.5;
    margin: 10px 0;
}

.modal-footer {
    display: flex;
    justify-content: center; /* Center align buttons */
    gap: 40px; /* Increase gap */
}

/* When cancel button is hidden (e.g. via inline style or class), center the confirm button */
.modal-footer:has(#modal-cancel-btn[style*="display: none"]) {
    justify-content: center;
}

/* Fallback for browsers not supporting :has() or if JS doesn't trigger it perfectly:
   We can add a class `.single-button` to modal-footer via JS in modal.js 
   But :has is widely supported now. Let's stick to :has for simplicity or add a specific class.
*/
.modal-footer.single-button {
    justify-content: center;
}

.modal-btn {
    padding: 10px 25px;
    border-radius: 8px;
    border: none;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn-confirm {
    background-image: linear-gradient(to right, var(--color-primary), var(--color-primary-dark));
    color: white;
}
.modal-btn-confirm:hover {
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4), 0 4px 15px var(--color-accent-pink-glow);
    transform: translateY(-2px);
}
.modal-btn-confirm.delete {
    background-image: linear-gradient(to right, #e74c3c, #c0392b);
}
.modal-btn-confirm.delete:hover {
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.modal-btn-cancel {
    background: var(--color-card-bg);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}
.modal-btn-cancel:hover {
    background: var(--color-bg-input);
    color: var(--color-text);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2), 0 0 5px rgba(255, 255, 255, 0.1); /* Subtle neutral glow */
    transform: translateY(-1px);
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--color-text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s ease, transform 0.2s ease;
}
.modal-close-btn:hover {
    color: var(--color-text);
    transform: rotate(90deg);
}

#new-tool-name, #new-tool-name {
    font-family: inherit;
}

.header-action-btn {
    background-color: transparent;
    border: 1px solid var(--color-border-strong);
    color: var(--color-text);
    padding: 6px 16px; 
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit; 
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
}

.header-action-btn:hover {
    background: linear-gradient(to right, var(--color-primary), var(--color-accent-pink)); /* Blue to Pink Gradient */
    border-color: var(--color-primary); /* Keep primary border for clarity */
    color: #fff;
    box-shadow: 0 0 10px var(--color-primary), 0 0 10px var(--color-accent-pink-glow); /* Mixed glow */
}

.login-btn {
    display: inline-block;
    background-color: transparent;
    border: 1px solid var(--color-border-strong);
    color: var(--color-text);
    padding: 6px 16px; 
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit; 
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.login-btn:hover {
    background: linear-gradient(to right, var(--color-primary), var(--color-accent-pink));
    border-color: var(--color-primary);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3), 0 4px 15px var(--color-accent-pink-glow);
}

.empty-state-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-secondary);
}


/* --- Toast / Notification --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10002; /* Above modal */
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 320px;
}

.toast {
    background: var(--color-card-bg);
    color: var(--color-text);
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    animation: toast-fade-in 0.3s ease-out forwards;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.toast.hiding {
    animation: toast-fade-out 0.3s ease-in forwards;
}

.toast-success {
    border-left: 5px solid var(--color-success);
}
.toast-success .toast-progress {
    background-color: var(--color-success);
}

.toast-error {
    border-left: 5px solid var(--color-error);
}
.toast-error .toast-progress {
    background-color: var(--color-error);
}

.toast-info {
    border-left: 5px solid var(--color-primary);
}
.toast-info .toast-progress {
    background-color: var(--color-primary);
}


.toast p {
    margin: 0;
    padding: 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    width: 100%;
    background-color: #fff;
    animation: toast-countdown linear forwards;
}

@keyframes toast-countdown {
    from { width: 100%; }
    to { width: 0%; }
}

@keyframes toast-fade-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-fade-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(120%);
    }
}

/* --- Split Layout for Tool Form (Restored) --- */
.tool-form-layout {
    display: grid;
    grid-template-columns: 1fr 300px; /* Form | Preview */
    gap: 40px;
    align-items: start;
}

@media (max-width: 768px) {
    .tool-form-layout {
        grid-template-columns: 1fr;
    }
    .preview-column {
        order: -1;
        margin-bottom: 20px;
    }
}

/* Preview Section */
.preview-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preview-label {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    text-align: center;
    margin-bottom: 10px;
}

.preview-card-wrapper {
    background: var(--color-bg-input);
    padding: 30px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px dashed var(--color-border);
}

.preview-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 120px;
    height: 110px; /* Match .tool-list a height */
    width: 100%;
    max-width: 160px;
    box-sizing: border-box;
}

.preview-card i {
    font-size: 2rem;
    color: var(--color-primary);
    transition: transform 0.2s ease-out;
}

.preview-card:hover i {
    transform: scale(1.1);
}

.preview-card .tool-name {
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    text-align: center;
}

/* --- Custom Tooltip (Restored) --- */
.tool-list li {
    position: relative; /* Ensure parent is relative */
}

.custom-tooltip {
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    background-color: var(--color-tooltip-bg);
    color: var(--color-tooltip-text);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    max-width: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    margin-top: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    text-align: left;
    line-height: 1.4;
    font-weight: normal;
    display: none;
}

.tool-list li:hover .custom-tooltip {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 15px;
    right: auto;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent var(--color-tooltip-bg) transparent;
}

.modal-box.modal-large {
    max-width: 850px;
    width: 95%;
}

/* Edit Mode Draggable Cursors */
body.edit-mode-active .tool-category .category-title {
    cursor: grab;
}
body.edit-mode-active .tool-category .category-title:active {
    cursor: grabbing;
}

body.edit-mode-active .tool-list a {
    cursor: grab !important; /* Override existing pointer */
}
body.edit-mode-active .tool-list a:active {
    cursor: grabbing !important;
}

/* Hide Empty System Categories by default */
.tool-category.system-category.empty-category {
    display: none;
}

/* --- Link Check Status Badge --- */
.tool-status-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #ff4757;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    z-index: 5;
    pointer-events: auto;
}

/* Ensure icon color overrides parent link styles */
.tool-status-badge i {
    color: #ff4757 !important;
    font-size: 9px !important;
    line-height: 1 !important;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
    display: block !important;
    transform: none !important; /* Prevent hover scaling inherited from link */
}

[data-theme="dark"] .tool-status-badge {
    background: rgba(30, 30, 30, 0.9);
}

/* Make badge larger for regular tool list items */
.tool-list .tool-status-badge {
    width: 24px;
    height: 24px;
    top: 6px;
    left: 6px;
}

.tool-list .tool-status-badge i {
    font-size: 11px !important;
}

/* --- Fix: Edit Mode Controls --- */
.tool-item-controls {
    z-index: 20;
}

/* Ensure controls are clickable in edit mode for both lists */
body.edit-mode-active .featured-item-wrapper:hover .tool-item-controls,
body.edit-mode-active .tool-list li:hover .tool-item-controls {
    opacity: 1;
    pointer-events: auto !important;
}

/* Removed: Show them when in Edit Mode logic */

/* File: css/cookie_banner.css */
/* Cookie Banner Styles */
.cookie-banner {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(50px);
    width: 90%;
    max-width: 500px;
    background: var(--color-card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.cookie-banner.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.cookie-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cookie-content h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cookie-content p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--color-text-muted);
    line-height: 1.6;
}

.cookie-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.cookie-btn {
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    border: none;
}

.cookie-btn.accept {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.25);
}

.cookie-btn.accept:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.35);
}

.cookie-btn.reject {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border-strong);
}

.cookie-btn.reject:hover {
    border-color: var(--color-text);
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.05);
}

/* Dark Theme Adjustments if specific overrides are needed */
/* (Variables handle most of it) */

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .cookie-banner {
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        transform: translateY(100%);
        box-sizing: border-box; /* Ensure padding doesn't overflow width */
    }
    
    .cookie-banner.visible {
        transform: translateY(0);
    }

    .cookie-actions {
        width: 100%;
    }

    .cookie-btn {
        flex: 1;
        text-align: center;
    }
}


/* File: css/dock.css */
/* --- Side Dock Navigation --- */
#side-dock {
    position: fixed;
    left: 15px; /* Slightly closer to the edge */
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px; /* Reduced gap between items */
    padding: 10px 6px; /* Reduced padding for a narrower dock */
    background: var(--color-bg-transparent); /* Use existing transparent header background for consistency */
    backdrop-filter: blur(10px); /* Slightly less blur */
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--color-border); /* Consistent border color */
    border-radius: 20px; /* Slightly smaller radius for smaller size */
    z-index: 900;
    transition: all 0.3s ease;
    opacity: 0;
    animation: dockFadeIn 0.8s ease-out 0.5s forwards;
}

@keyframes dockFadeIn {
    from { opacity: 0; transform: translate(-20px, -50%); }
    to { opacity: 1; transform: translate(0, -50%); }
}

.dock-item {
    position: relative;
    width: 32px; /* Reduced width */
    height: 32px; /* Reduced height */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Faster transition */
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
}

.dock-item i {
    font-size: 1rem; /* Reduced icon size */
    transition: transform 0.2s ease;
}

/* Hover State */
.dock-item:hover {
    color: var(--color-accent-pink); /* Pink color on hover */
    background: var(--color-accent-pink-glow); /* Pink background tint */
    transform: scale(1.1);
}

/* Active State (Current Section) */
.dock-item.active {
    color: white; /* White icon on active */
    background: var(--color-primary); /* Solid primary background */
    box-shadow: 0 0 10px rgba(var(--rgb-primary), 0.4); /* Reduced and softer glow */
    border-color: var(--color-primary); /* Border matches background */
    transform: scale(1.15);
}

/* Tooltip for Dock Items */
.dock-tooltip {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    background: var(--color-tooltip-bg);
    color: var(--color-tooltip-text);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.2s ease;
    margin-left: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.dock-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    margin-top: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent var(--color-tooltip-bg) transparent transparent;
}

.dock-item:hover .dock-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

/* Hide on smaller screens (tablets and mobile) */
@media (max-width: 1024px) {
    #side-dock {
        display: none !important; /* Force hide to prevent any overlap issues */
    }
}


/* File: css/cosmic_search.css */
/* Cosmic Search Bar Styles - Adapted */

.search-container {
    /* Ensure the container handles the absolute positioning of cosmic elements */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Existing max-width from components.css is 400px, which is perfect */
}

/* Background Layers */
.cosmic-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 24px; /* Match input border radius */
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
    filter: blur(3px);
}

.cosmic-input-wrapper {
    position: relative;
    width: 100%;
    z-index: 1;
}

/* The Input Field */
#search-input.cosmic-input {
    width: 100%;
    height: 50px; /* Slightly reduced from 56px to fit header better */
    background-color: #05071b;
    border: 1px solid rgba(77, 109, 255, 0.3);
    border-radius: 24px;
    color: #a9c7ff;
    padding: 0 50px; /* Space for icons */
    font-size: 1rem;
    transition: all 0.3s ease;
    box-sizing: border-box; /* Ensure padding doesn't increase width */
    font-family: inherit;
}

#search-input.cosmic-input::placeholder {
    color: rgba(110, 140, 255, 0.6);
}

#search-input.cosmic-input:focus {
    outline: none;
    border-color: #4d6dff;
    box-shadow: 0 0 15px rgba(77, 109, 255, 0.2);
}

/* Icons */
.cosmic-icon-left {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    pointer-events: none;
    z-index: 2;
}

.cosmic-icon-right {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    border-radius: 50%;
    background: linear-gradient(180deg, #1c2452, #05071b, #2a3875);
    overflow: hidden;
}

/* Animations and Effects */
.cosmic-glow {
    pointer-events: none;
    width: 40px;
    height: 20px;
    position: absolute;
    background: #4d6dff;
    top: 5px;
    left: 10px;
    filter: blur(15px);
    opacity: 0.6;
    transition: opacity 0.5s;
    z-index: 2;
}

.cosmic-input-wrapper:hover .cosmic-glow {
    opacity: 0;
}

/* Input Mask (Top Highlight) */
.input-mask {
    pointer-events: none;
    width: 30%;
    height: 2px;
    position: absolute;
    background: linear-gradient(90deg, transparent, #4d6dff, transparent);
    top: 0;
    left: 20%;
    z-index: 3;
    opacity: 0.5;
}

/* Rotating Gradients for Background Layers */
.cosmic-layer::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%; /* Make it large enough to cover rotation */
    height: 200%;
    transform: translate(-50%, -50%) rotate(0deg);
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 2s ease-out;
}

/* Define gradients for each layer */
.cosmic-starfield::before {
    background-image: conic-gradient(transparent 0%, #1c2452 20%, transparent 40%);
}

.cosmic-nebula::before {
    background-image: conic-gradient(transparent 0%, #4d6dff 10%, transparent 50%, #6e8cff 80%, transparent 100%);
    opacity: 0.5;
}

.cosmic-stardust::before {
    background-image: conic-gradient(transparent 0%, #6e8cff 20%, transparent 60%);
    filter: brightness(1.2);
}

.cosmic-ring::before {
    background-image: conic-gradient(#05071b, #4d6dff 5%, #05071b 20%);
}

/* Hover/Focus Animations */
.search-container:hover .cosmic-layer::before {
    transform: translate(-50%, -50%) rotate(180deg);
    transition: transform 4s linear;
}

.search-container:focus-within .cosmic-layer::before {
    transform: translate(-50%, -50%) rotate(360deg);
    transition: transform 6s linear;
}

/* Wormhole Icon Animation */
.wormhole-border {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(transparent, var(--color-primary), transparent 50%, var(--color-accent-pink), transparent);
    animation: rotateWormhole 4s linear infinite;
    opacity: 0.8;
}

@keyframes rotateWormhole {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Adjust Clear Button to fit new design */
.search-clear-btn {
    right: 50px !important; /* Move it left of the wormhole icon */
    color: #a9c7ff !important;
    z-index: 10;
}

.search-clear-btn:hover {
    background-color: rgba(255,255,255,0.1) !important;
}

/* --- Light Mode Adaptation (Daylight Nebula) --- */
html[data-theme="light"] #search-input.cosmic-input {
    background-color: #f0f4f8; /* Very light grey-blue */
    border-color: rgba(77, 109, 255, 0.2);
    color: #1c2452; /* Dark blue text */
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.02);
}

html[data-theme="light"] #search-input.cosmic-input::placeholder {
    color: #8ca0b3;
}

html[data-theme="light"] #search-input.cosmic-input:focus {
    background-color: #ffffff;
    border-color: #4d6dff;
    box-shadow: 0 0 15px rgba(77, 109, 255, 0.15);
}

/* Adjust Background Layers for Light Mode */
html[data-theme="light"] .cosmic-starfield::before {
    background-image: conic-gradient(transparent 0%, #e1e8ed 20%, transparent 40%);
}

html[data-theme="light"] .cosmic-nebula::before {
    /* Softer, lighter blues */
    background-image: conic-gradient(transparent 0%, #d0e1ff 10%, transparent 50%, #e6f0ff 80%, transparent 100%);
    opacity: 0.8;
}

html[data-theme="light"] .cosmic-stardust::before {
    background-image: conic-gradient(transparent 0%, #aec5ff 20%, transparent 60%);
    filter: brightness(1);
}

html[data-theme="light"] .cosmic-ring::before {
    background-image: conic-gradient(#f0f4f8, #4d6dff 5%, #f0f4f8 20%);
}

/* Icons in Light Mode */
html[data-theme="light"] .cosmic-icon-right {
    background: linear-gradient(180deg, #e6f0ff, #ffffff, #d0e1ff);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

html[data-theme="light"] .cosmic-icon-right svg {
    stroke: #4d6dff; /* Darker stroke for visibility */
}

html[data-theme="light"] .search-clear-btn {
    color: #4d6dff !important;
}

html[data-theme="light"] .search-clear-btn:hover {
    background-color: rgba(77, 109, 255, 0.1) !important;
}


/* File: css/modern_button.css */
/* --- Modern Header Button Style (Cyberpunk/Neon Effect) --- */

.header-modern-btn {
  --border-radius: 24px;
  --padding: 4px; /* Spread of the glow/border effect */
  --transition: 0.4s;
  --highlight-color-hue: 210deg; /* Blue-ish */
  --btn-text-dim: rgba(255, 255, 255, 0.65); /* Increased default visibility */
  
  position: relative; /* Established positioning context for pseudo-elements */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5em 1.5em; /* Adjusted padding for header text */
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--btn-text);

  background-color: var(--btn-bg);

  /* Inner bevel/shadow effects removed */
  box-shadow: none;

  border: solid 1px var(--btn-border);
  border-radius: var(--border-radius);
  cursor: pointer;
  text-decoration: none; /* For <a> tags */
  user-select: none;
  white-space: nowrap;
  box-sizing: border-box;
  height: 40px; /* Fixed height for consistency */

  transition:
    box-shadow var(--transition),
    border var(--transition),
    background-color var(--transition),
    color var(--transition),
    transform 0.2s ease;
}

/* Spacing between buttons in header */
.header-modern-btn + .header-modern-btn,
.header-modern-btn + span {
    margin-left: 12px;
}

/* The dark halo/border surrounding the button (Pseudo-element) */
.header-modern-btn::before {
  content: "";
  position: absolute;
  top: calc(0px - var(--padding));
  left: calc(0px - var(--padding));
  width: calc(100% + var(--padding) * 2);
  height: calc(100% + var(--padding) * 2);
  border-radius: calc(var(--border-radius) + var(--padding));
  pointer-events: none;
  background-image: none;

  z-index: -1;
  transition:
    box-shadow var(--transition),
    filter var(--transition);
  box-shadow: none;
}

/* The shine/highlight effect (Pseudo-element) */
.header-modern-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
  background-image: linear-gradient(
    0deg,
    #fff,
    hsl(var(--highlight-color-hue), 100%, 70%),
    hsla(var(--highlight-color-hue), 100%, 70%, 50%),
    8%,
    transparent
  );
  background-position: 0 0;
  opacity: 0;
  transition:
    opacity var(--transition),
    filter var(--transition);
}

/* --- Text Animation --- */

.btn-letter {
  position: relative;
  display: inline-block;
  color: var(--btn-text-dim); /* Use variable for dimmed text */
  font-style: normal; /* Reset i tag style if used */
  transition:
    color var(--transition),
    text-shadow var(--transition),
    opacity var(--transition);
}

/* Constant pulsing animation for letters */
.header-modern-btn .btn-letter {
    animation: letter-anim 3s ease-in-out infinite;
}

@keyframes letter-anim {
  0%, 100% {
      text-shadow: none;
      color: var(--btn-text-dim);
  }
  50% {
    text-shadow: none;
    color: var(--btn-text);
  }
}

/* --- Icon Styling --- */
.btn-svg {
  flex-shrink: 0; /* Prevent icon shrinking */
  height: 18px;
  width: 18px; /* Fixed width for icons */
  margin-right: 0.6rem;
  
  display: flex; /* Added for centering internal icon */
  align-items: center; /* Added for centering internal icon */
  justify-content: center; /* Added for centering internal icon */

  /* Properties for SVGs */
  fill: var(--btn-icon-fill);
  
  /* Properties for FontAwesome (<i>) */
  color: var(--btn-icon-fill);
  
  filter: none;
  
  transition:
    fill var(--transition),
    color var(--transition),
    filter var(--transition),
    opacity var(--transition);

  /* Flicker animation */
  animation: flicker 3s linear infinite;
  animation-delay: 0.5s;
}

/* Theme Toggle Specifics (Icon Only) */
.header-modern-btn.icon-only {
    padding: 0; /* Remove padding */
    width: 40px; /* Make it a square button */
    height: 40px; /* Ensure it's square */
    
    /* Switch to Flexbox for reliable centering */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    
    min-width: unset; /* Remove min-width from text buttons */
    font-size: 0; /* Remove text baseline influence */
    line-height: 0; /* Remove text line-height influence */
}
.header-modern-btn.icon-only .btn-svg {
    margin: 0; /* Remove icon margin */
    flex: none; /* Ensure icon doesn't grow/shrink */
    width: auto; /* Allow natural size */
    height: auto;
    font-size: 1.2rem; /* Larger icon for icon-only buttons */
    line-height: 1;
    display: inline-block;
    text-align: center;
}


@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
  52% { opacity: 1; }
  54% { opacity: 0.5; }
  56% { opacity: 1; }
}

/* --- Text Swap Wrapper --- */
.txt-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  height: 20px; /* Fixed height to prevent layout jump */
  /* min-width set dynamically or by content */
}

.txt-1,
.txt-2 {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  width: 100%;
  text-align: center; /* Center text if width allows */
}

.txt-1 {
  animation: appear-anim 0.5s ease-in-out forwards;
}
.txt-2 {
  opacity: 0;
  pointer-events: none;
}

@keyframes appear-anim {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

/* --- Focus/Hover Text Swap Interaction --- */

/* Trigger on Hover OR Focus for better UX */
.header-modern-btn:hover .txt-1,
.header-modern-btn:focus .txt-1 {
  animation: opacity-anim 0.3s ease-in-out forwards;
}

.header-modern-btn:hover .txt-2,
.header-modern-btn:focus .txt-2 {
  animation: opacity-anim 0.3s ease-in-out reverse forwards;
  animation-delay: 0.1s; /* Slight delay for effect */
}

@keyframes opacity-anim {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Text Blur/Explosion Effect on Hover/Focus */
.header-modern-btn:hover .btn-letter,
.header-modern-btn:focus .btn-letter {
  animation:
    focused-letter-anim 0.6s ease-in-out forwards, /* Quick blur pop */
    letter-anim 2s ease-in-out infinite; /* Resume pulse */
}

@keyframes focused-letter-anim {
  0% {
      filter: blur(0px);
      transform: scale(1);
  }
  50% {
    transform: scale(1.2);
    filter: blur(4px) brightness(150%);
    color: var(--btn-text);
  }
  100% {
      filter: blur(0px);
      transform: scale(1);
      color: var(--btn-text);
  }
}

/* Icon Hover State */
.header-modern-btn:hover .btn-svg,
.header-modern-btn:focus .btn-svg {
  animation-duration: 0.5s; /* Speed up flicker or stop it */
  animation: none; /* Stop flicker on hover */
  
  fill: var(--btn-text); /* Ensure hover state uses text color (usually contrasting) */
  color: var(--btn-text);
  filter: none;
}

/* Button Container Hover States */
.header-modern-btn:hover,
.header-modern-btn:focus {
  border-color: hsla(var(--highlight-color-hue), 100%, 80%, 40%);
  box-shadow: 0 0 10px hsla(var(--highlight-color-hue), 100%, 70%, 0.4), 0 0 10px var(--color-accent-pink-glow);
}

.header-modern-btn:hover::before,
.header-modern-btn:focus::before {
  box-shadow: none;
}

.header-modern-btn:hover::after,
.header-modern-btn:focus::after {
  opacity: 0.6;
  mask-image: linear-gradient(0deg, #fff, transparent);
}

/* --- Animation Delays for Letters (Staggered effect) --- */
/* We generate delays for up to 15 characters */
.btn-letter:nth-child(1) { animation-delay: 0.0s; }
.btn-letter:nth-child(2) { animation-delay: 0.1s; }
.btn-letter:nth-child(3) { animation-delay: 0.2s; }
.btn-letter:nth-child(4) { animation-delay: 0.3s; }
.btn-letter:nth-child(5) { animation-delay: 0.4s; }
.btn-letter:nth-child(6) { animation-delay: 0.5s; }
.btn-letter:nth-child(7) { animation-delay: 0.6s; }
.btn-letter:nth-child(8) { animation-delay: 0.7s; }
.btn-letter:nth-child(9) { animation-delay: 0.8s; }
.btn-letter:nth-child(10) { animation-delay: 0.9s; }
.btn-letter:nth-child(11) { animation-delay: 1.0s; }
.btn-letter:nth-child(12) { animation-delay: 1.1s; }
.btn-letter:nth-child(13) { animation-delay: 1.2s; }
.btn-letter:nth-child(14) { animation-delay: 1.3s; }
.btn-letter:nth-child(15) { animation-delay: 1.4s; }

/* --- Active (Click) State --- */
.header-modern-btn:active {
  border: solid 1px hsla(var(--highlight-color-hue), 100%, 80%, 70%);
  background-color: hsla(var(--highlight-color-hue), 50%, 20%, 0.5);
  transform: scale(0.98); /* Slight press effect */
}

.header-modern-btn:active::after {
  opacity: 1;
  mask-image: linear-gradient(0deg, #fff, transparent);
  filter: brightness(200%);
}

/* --- Modal Button Overrides --- */

/* Delete Action (Red Warning) */
.header-modern-btn.delete {
    --btn-border: var(--color-error);
    --btn-text: var(--color-error);
    --btn-text-dim: rgba(255, 118, 117, 0.8); /* Significantly increased visibility */
    --btn-icon-fill: var(--color-error);
    --highlight-color-hue: 0deg; /* Red */
}

.header-modern-btn.delete:hover {
    border-color: var(--color-error);
    box-shadow: 0 0 15px rgba(255, 118, 117, 0.3);
}

/* Cancel Action (Subtle/Grey) */
.header-modern-btn.modal-btn-cancel {
    --btn-border: var(--color-border-strong);
    --btn-text: var(--color-text); /* Use standard text color for better visibility */
    --btn-text-dim: rgba(224, 224, 224, 0.6); /* Increased visibility */
    --btn-icon-fill: var(--color-text-muted);
    --highlight-color-hue: 0deg; /* White/Grey */
}

.header-modern-btn.modal-btn-cancel:hover {
    --btn-text: var(--color-text); /* Brighten on hover */
    --btn-icon-fill: var(--color-text);
    border-color: var(--color-text);
}


/* File: css/animations.css */
.shake { 
    animation: shake 0.5s ease-in-out; 
}

#tsparticles {
    position: fixed; 
    top: 0; 
    left: 0;
    width: 100%; 
    height: 100%;
    z-index: -1;
}

.cursor-dot, .cursor-outline {
    pointer-events: none; 
    position: fixed; 
    top: 50%; 
    left: 50%;
    border-radius: 50%; 
    opacity: 0;
    transform: translate(-50%, -50%);
    transition: opacity 0.3s ease-in-out, transform 0.2s ease-in-out;
    z-index: 99999;
}

.cursor-dot { 
    width: 8px; 
    height: 8px; 
    background-color: var(--color-primary); 
}

.cursor-outline {
    width: 20px; 
    height: 20px; 
    background-color: rgba(52, 152, 219, 0.2);
    transition: all 0.1s ease-out;
}

body:hover .cursor-dot, 
body:hover .cursor-outline { 
    opacity: 1; 
}

body.modal-open .cursor-dot,
body.modal-open .cursor-outline,
body.hide-custom-cursor .cursor-dot,
body.hide-custom-cursor .cursor-outline {
    opacity: 0 !important;
}

.floating-text {
    position: absolute; 
    font-size: 12px; 
    font-weight: bold;
    pointer-events: none; 
    user-select: none; 
    white-space: nowrap;
    animation: floatUp 2s ease-out forwards;
}

.animations-paused * {
    animation-play-state: paused !important;
}

@keyframes spin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}

@keyframes fadeIn { 
    to { opacity: 1; } 
}

@keyframes fadeInScale { 
    to { opacity: 1; transform: scale(1); } 
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-80px); }
}

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


@keyframes breathing-glow {
    0% { box-shadow: 0 0 8px -2px var(--glow-color); }
    25% { box-shadow: 0 0 12px -1px var(--glow-color); }
    50% { box-shadow: 0 0 16px 0px var(--glow-color); }
    75% { box-shadow: 0 0 12px -1px var(--glow-color); }
    100% { box-shadow: 0 0 8px -2px var(--glow-color); }
}

/* Search Particles */
.search-particle {
    position: fixed; 
    width: 4px;
    height: 4px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transition: transform 0.1s linear;
}

/* File: css/highlight.css */
.highlight-text {
    background-color: rgba(255, 107, 129, 0.4); /* Pink accent transparent */
    color: white;
    border-radius: 2px;
    padding: 0 2px;
    box-shadow: 0 0 2px rgba(255, 107, 129, 0.6);
}

html[data-theme="light"] .highlight-text {
    background-color: rgba(255, 143, 163, 0.5);
    color: #000;
}


/* File: css/skeleton.css */
/* --- Skeleton Loading Styles --- */

.skeleton-category {
    margin-bottom: 40px;
    animation: skeleton-fade-in 0.3s ease-out forwards;
}

.skeleton-title {
    height: 30px;
    width: 200px;
    background-color: var(--color-border);
    border-radius: 6px;
    margin-bottom: 25px;
    position: relative;
    overflow: hidden;
}

/* The "shimmer" effect */
.skeleton-title::after,
.skeleton-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.05),
        transparent
    );
    animation: skeleton-shimmer 1.5s infinite;
}

html[data-theme="light"] .skeleton-title::after,
html[data-theme="light"] .skeleton-card::after {
    background: linear-gradient(
        90deg,
        transparent,
        rgba(0, 0, 0, 0.05),
        transparent
    );
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 20px;
    padding: 0;
    margin: 0;
}

.skeleton-card {
    height: 110px;
    background-color: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.skeleton-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--color-border);
}

.skeleton-text {
    width: 70%;
    height: 14px;
    background-color: var(--color-border);
    border-radius: 4px;
}

@keyframes skeleton-shimmer {
    100% {
        transform: translateX(100%);
    }
}

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


/* File: css/responsive.css */
/* --- Responsive Design Overrides --- */

/* 1. Medium-Large Screens (1025px - 1300px) - The "Awkward" Range */
/* Side dock is visible, but space is tight. */
@media (min-width: 1025px) and (max-width: 1300px) {
    main {
        /* Balance margins: 80px left (clears dock) and 80px right (symmetry) */
        margin: 20px 80px !important; 
        width: auto;
        max-width: none; /* Allow it to fill the calculated space */
    }
    
    header {
        padding: 15px 20px; /* Reduce side padding */
    }

    /* Compact "Add Tool" button earlier to prevent header crowding */
    #add-tool-btn .txt-wrapper {
        display: none;
    }
    #add-tool-btn {
        padding: 10px;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        justify-content: center;
    }
    #add-tool-btn i {
        margin: 0;
        font-size: 1.1rem;
    }
}

/* 2. Tablet / Narrow Desktop (1024px and below) */
/* Dock is hidden via dock.css, restore standard layout */
@media (max-width: 1024px) {
    main {
        margin: 20px auto;
        width: 92%;
    }

    .header-content {
        gap: 20px;
    }

    /* Make search bar flexible */
    .search-container {
        flex: 1;
        max-width: none;
        margin: 0 15px;
    }

    /* Hide "Add Tool" text, show icon only if needed, or keep as is if space permits */
    #add-tool-btn .txt-wrapper {
        display: none;
    }
    #add-tool-btn {
        padding: 10px;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        justify-content: center;
    }
    #add-tool-btn i {
        margin: 0;
        font-size: 1.1rem;
    }
}

/* 3. Mobile Layout (< 768px) - Major Restructuring */
@media (max-width: 768px) {
    header {
        padding: 10px 15px;
        position: sticky; /* Change to sticky for better mobile feel? Or keep fixed. */
    }

    .header-content {
        display: grid;
        grid-template-columns: auto auto; /* Logo | Actions */
        grid-template-rows: auto auto; /* Row 1 | Row 2 (Search) */
        gap: 10px;
        align-items: center;
    }

    /* Row 1: Logo */
    .logo-title {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
        font-size: 1.3rem;
        margin: 0;
        text-align: left;
    }

    /* Row 1: Actions (Right aligned) */
    .header-actions {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        justify-content: flex-end;
        width: 100%;
        gap: 10px;
        position: static; /* Reset absolute positioning */
    }

    /* Row 2: Search Bar (Full Width) */
    .search-container {
        grid-column: 1 / 3;
        grid-row: 2 / 3;
        width: 100%;
        margin: 5px 0 0 0;
    }

    /* Adjust Main padding for the taller header */
    main {
        /* Header is approx 110px tall now with 2 rows */
        padding-top: 130px !important; 
    }

    /* Adjust Grid for Mobile */
    .tool-list-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); /* Smaller cards */
        gap: 15px;
    }

        .tool-list a {

            height: 80px; /* Smaller card height */

            padding: 7px;    }

    .tool-list a i {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }
    
    .tool-list a .tool-name {
        font-size: 0.75rem;
        /* Ensure truncation inherits or is enforced on mobile */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
        display: block;
    }

    /* Featured Tools Horizontal Scroll Improvement */
    .featured-card {
        flex: 0 0 160px; /* Smaller featured cards */
    }
    
    /* Footer adjustments */
    footer {
        width: 90%;
        margin-bottom: 20px;
    }
}

/* 4. Very Small Screens (< 380px) */
@media (max-width: 380px) {
    .logo-title {
        font-size: 1.1rem;
    }
    .header-modern-btn {
        padding: 8px;
    }
}


/* File: css/empty_states.css */
/* --- Empty Category State (Logged In) --- */
.empty-category-state {
    grid-column: 1 / -1; /* Span full width of grid */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background: rgba(128, 128, 128, 0.05); /* Very subtle background */
    border-radius: 12px;
    border: 2px dashed var(--color-border);
    color: var(--color-text-muted);
    text-align: center;
    
    /* Enhanced Transition */
    transition: 
        min-height 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s ease,
        border-width 0.3s ease,
        margin 0.3s ease,
        transform 0.3s ease, /* For hover */
        background-color 0.3s ease; /* For hover */

    min-height: 150px;
    height: auto;
    margin-top: 10px; /* Buffer for hover effect */
    opacity: 1;
    visibility: visible;
    overflow: hidden; /* Clip content immediately */
    box-sizing: border-box;
}

.empty-category-state:hover {
    background: rgba(128, 128, 128, 0.08);
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

/* Hiding Logic for Collapsed State */
.tool-category.collapsed .empty-category-state {
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: none; /* Reset hover transform */
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    opacity: 0.6;
    color: var(--color-text-muted);
    transition: color 0.3s ease, transform 0.3s ease, opacity 0.2s ease;
}

/* Scale down icon when collapsed to prevent layout push */
.tool-category.collapsed .empty-state-icon {
    transform: scale(0);
    opacity: 0;
}

.empty-category-state:hover .empty-state-icon {
    color: var(--color-primary);
    transform: scale(1.1) rotate(-10deg);
}

.empty-category-state p {
    margin: 0 0 15px 0;
    font-size: 0.95rem;
    transition: opacity 0.2s ease;
}
.tool-category.collapsed .empty-category-state p {
    opacity: 0;
}

.btn-text {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.2s ease;
    font-family: inherit;
}
.tool-category.collapsed .btn-text {
    opacity: 0;
}

.btn-text:hover {
    background: rgba(52, 152, 219, 0.1);
    color: var(--color-primary-dark);
}

/* File: css/icons.css */
/* --- Tool Icons (Image Support) --- */
.tool-icon-img {
    width: 32px;
    height: 32px;
    object-fit: contain; /* Ensures aspect ratio is kept */
    display: block; 
    border-radius: 4px;
    transition: transform 0.2s ease-out;
}

/* Apply margin only when inside the tool grid, matching FontAwesome icons */
.tool-list a .tool-icon-img {
    margin-bottom: 8px;
    object-position: bottom;
}

/* Consistent Height Container for FontAwesome Icons */
.tool-list a i {
    height: 32px; 
    width: 32px; /* Fixed width for alignment */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px; /* Match image margin (Unified to 8px) */
    font-size: 2rem; /* Ensure visual size matches */
}

.tool-list a:hover .tool-icon-img {
    transform: scale(1.1);
}

/* Preview Card Specifics - Reset Margins as it uses flex gap */
.preview-card .tool-icon-img {
    width: 32px;
    height: 32px;
    margin: 0;
    object-fit: contain;
}

/* Featured Card Specifics */
.featured-card .tool-icon-img.featured-icon {
    width: 24px; 
    height: 24px;
    margin-bottom: 0; 
    margin-right: 15px; 
    transform: translateY(1px); 
}

/* Edit Mode Override */
body.edit-mode-active .tool-list a:hover .tool-icon-img {
    transform: none;
}


