:root {
    --bg: #f0f4ff;
    --card-bg: #ffffff;
    --header-bg: rgba(244, 247, 251, 0.95);
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition: all 0.2s ease;
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    --cat-encoding: #10b981;
    --cat-crypto: #8b5cf6;
    --cat-text: #6366f1;
    --cat-time: #0ea5e9;
    --cat-math: #f59e0b;
    --cat-network: #06b6d4;
    --cat-developer: #2563eb;
    --cat-frontend: #ec4899;
    --cat-image: #f472b6;
    --cat-generator: #a855f7;
    --cat-video: #e11d48;
    --cat-dev-env: #1d4ed8;
    --cat-infra: #14b8a6;
    --cat-database: #0891b2;
    --cat-messaging: #d97706;
    --cat-net-sec: #dc2626;
    --cat-os: #475569;
    --cat-api-test: #ef4444;
    --cat-pkg-build: #7c3aed;
    --cat-server-mgmt: #0d9488;
    --cat-ai: #9333ea;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
}

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    padding: 0 1.5rem;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    height: 62px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.logo i {
    font-size: 1.5rem;
}

.search-box {
    justify-self: center;
    max-width: 400px;
    width: 100%;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.search-box input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--card-bg);
    font-size: 0.875rem;
    color: var(--text);
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.header-nav a i {
    font-size: 0.8125rem;
}

.header-nav a:hover {
    color: var(--primary);
}

.nav-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    flex-shrink: 0;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 1.5rem;
    min-height: calc(100vh - 62px - 100px);
}

.footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    text-align: center;
}

.footer-inner p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

.footer-brand {
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-sep {
    color: var(--text-muted);
}

.footer-legal {
    font-size: 0.8125rem;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

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

.btn-secondary:hover {
    background: var(--border);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.related-card {
    display: block;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    text-decoration: none;
    transition: var(--transition);
}

.related-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.related-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.related-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tool-page .feature-card .feature-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem !important;
    margin-right: 0.5rem !important;
    margin-bottom: 0 !important;
    vertical-align: middle;
}

.tool-page .feature-card h3 {
    display: inline !important;
    vertical-align: middle;
    margin-bottom: 0.25rem !important;
}

.tool-page .feature-card h3::after {
    content: "";
    display: block;
    margin-bottom: 0.5rem;
}

.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-code {
    font-size: 6rem;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.error-page p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin: 1rem 0 2rem;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@media (max-width: 768px) {
    .header-inner {
        grid-template-columns: auto auto;
        height: auto;
        padding: 0.75rem 0;
    }
    .search-box {
        grid-column: 1 / -1;
        justify-self: stretch;
        max-width: 100%;
        order: 3;
    }
}

@media (max-width: 640px) {
    .header-nav a {
        display: none;
    }
    .nav-divider {
        display: none;
    }
}
