:root {
        --bg: #fafafa;
        --text: #222;
        --muted: #666;
        --nav-bg: #ffffff;
        --card-bg: #ffffff;
        --link: #2563eb;
        --link-hover: #1d4ed8;
        --border: #e5e7eb;
        --accent: #f59e0b;
        --shadow: 0 1px 3px rgba(0,0,0,0.1);
        --shadow-hover: 0 4px 12px rgba(0,0,0,0.15);
        --radius: 8px;
        --max-width: 900px;
        --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    }
    
    [data-theme="dark"] {
        --bg: #0f172a;
        --text: #e2e8f0;
        --muted: #94a3b8;
        --nav-bg: #1e293b;
        --card-bg: #1e293b;
        --link: #60a5fa;
        --link-hover: #93c5fd;
        --border: #334155;
        --shadow: 0 1px 3px rgba(0,0,0,0.4);
        --shadow-hover: 0 4px 12px rgba(0,0,0,0.5);
    }
[data-theme="terminal"] {
    --bg: #0a0e0a;
    --text: #00ff41;
    --muted: #00b32d;
    --nav-bg: #050805;
    --card-bg: #0a0e0a;
    --link: #00ff41;
    --link-hover: #b6ffb6;
    --border: #00b32d;
    --shadow: 0 0 8px rgba(0, 255, 65, 0.3);
    --shadow-hover: 0 0 16px rgba(0, 255, 65, 0.6);
}

[data-theme="terminal"] body {
    font-family: "Courier New", monospace;
    text-shadow: 0 0 2px rgba(0, 255, 65, 0.5);
}

    
    * { box-sizing: border-box; }
    
    body {
        background: var(--bg);
        color: var(--text);
        font-family: var(--font);
        line-height: 1.6;
        margin: 0;
        padding: 0;
        transition: background 0.3s, color 0.3s;
    }
    
    main {
        max-width: var(--max-width);
        margin: 0 auto;
        padding: 1.5rem 1rem;
    }
    
    header.site {
        background: var(--nav-bg);
        border-bottom: 1px solid var(--border);
        padding: 1rem;
        position: sticky;
        top: 0;
        z-index: 100;
        box-shadow: var(--shadow);
    }
    
    .site-nav {
        max-width: var(--max-width);
        margin: 0 auto;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.75rem;
    }
    
    .site-nav a, .site-nav button {
        color: var(--text);
        text-decoration: none;
        padding: 0.4rem 0.8rem;
        border-radius: var(--radius);
        transition: background 0.2s, color 0.2s;
        font-size: 0.95rem;
    }
    
    .site-nav a:hover, .site-nav button:hover {
        background: var(--bg);
        color: var(--link);
    }
    
    .site-brand {
        font-weight: 700;
        font-size: 1.2rem;
        margin-right: auto;
        color: var(--accent) !important;
    }
    
    .theme-toggle {
        background: var(--bg);
        border: 1px solid var(--border);
        cursor: pointer;
    }
    
    h1 { font-size: 1.8rem; margin-top: 0; }
    h2 { font-size: 1.3rem; }
    
    .articles {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 1.5rem;
    }
    
    @media (min-width: 640px) {
        .articles { grid-template-columns: repeat(2, 1fr); }
    }
    
    @media (min-width: 900px) {
        .articles { grid-template-columns: repeat(3, 1fr); }
    }
    
    .card {
        display: block;
        padding: 1.2rem;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        text-decoration: none;
        color: var(--text);
        background: var(--card-bg);
        box-shadow: var(--shadow);
        transition: transform 0.2s, box-shadow 0.2s;
    }
    
    .card:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow-hover);
        color: var(--link);
    }
    
    .card h2 { margin: 0 0 0.5rem; color: var(--text); }
    .card:hover h2 { color: var(--link); }
    
    .card .date {
        color: var(--muted);
        font-size: 0.85rem;
        margin: 0.5rem 0;
    }
    
    .card .excerpt { color: var(--text); margin-bottom: 0; }
    
    article.content {
        background: var(--card-bg);
        padding: 2rem;
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        border: 1px solid var(--border);
    }
    
    article.content p { margin: 1rem 0; }
    
    form input, form textarea, form button {
        font-family: inherit;
        font-size: 1rem;
    }
    
    form input, form textarea {
        width: 100%;
        padding: 0.6rem;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: var(--card-bg);
        color: var(--text);
        margin-top: 0.3rem;
    }
    
    form input:focus, form textarea:focus {
        outline: 2px solid var(--link);
        outline-offset: 2px;
    }
    
    form button {
        background: var(--link);
        color: white;
        border: none;
        padding: 0.6rem 1.2rem;
        border-radius: var(--radius);
        cursor: pointer;
        font-weight: 600;
    }
    
    form button:hover { background: var(--link-hover); }
    
    .guestbook-entry {
        border: 1px solid var(--border);
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: var(--radius);
        background: var(--card-bg);
    }
    
    .guestbook-entry p { margin: 0.3rem 0; }
    .guestbook-entry small { color: var(--muted); }
    
    a { color: var(--link); }
    a:hover { color: var(--link-hover); }
    
    hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

.theme-select {
    background: var(--nav-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    margin-left: auto;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}

.theme-select:focus {
    outline: 2px solid var(--link);
}

.article-cover, .card img, .articles img {
    max-width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
    border-radius: var(--radius);
}

.articles .card {
    display: block;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--card-bg, #fff);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
}

[data-theme="terminal"] .card,
[data-theme="terminal"] .articles .card {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

[data-theme="terminal"] .article-cover,
[data-theme="terminal"] .card img {
    background: #000;
    border: 1px solid var(--border);
}

[data-theme="terminal"] input,
[data-theme="terminal"] textarea,
[data-theme="terminal"] select,
[data-theme="terminal"] .form-control,
[data-theme="terminal"] .theme-select {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

[data-theme="terminal"] a {
    color: var(--link);
}

[data-theme="terminal"] .alert-success,
[data-theme="terminal"] .alert-danger {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

[data-theme="terminal"] .kifs-toc {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

[data-theme="terminal"] .kifs-toc .chip {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

[data-theme="terminal"] .kifs-toc .chip.active,
[data-theme="terminal"] .kifs-toc .chip:hover {
    background: var(--link);
    color: #000;
}
