:root {
    --bg-color: #f4f5f7;
    --text-color: #2c3e50;
    --card-bg: #ffffff;
    --primary-color: #3498db;
    --border-color: #e2e8f0;
    --header-bg: #ffffff;
    --footer-bg: #f8fafc;
    --link-color: #2980b9;
    --code-bg: #f1f5f9;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        --text-color: #e2e8f0;
        --card-bg: #1e293b;
        --primary-color: #38bdf8;
        --border-color: #334155;
        --header-bg: #1e293b;
        --footer-bg: #0f172a;
        --link-color: #7dd3fc;
        --code-bg: #0f172a;
    }
}

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

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

a { color: var(--link-color); text-decoration: none; transition: opacity 0.2s; }
a:hover { opacity: 0.8; text-decoration: underline; }

.container { max-width: 900px; margin: 0 auto; padding: 0 20px; }

/* Main Content */
.main-content {
    background-color: var(--card-bg);
    padding: 40px;
    margin-top: 30px;
    margin-bottom: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
@media (max-width: 600px) {
    .main-content { padding: 20px; margin-top: 15px; border-radius: 8px; }
}

/* Typography */
h1, h2, h3, h4 { margin-top: 1.5em; margin-bottom: 0.5em; font-weight: 700; color: var(--text-color); }
h1 { font-size: 2rem; border-bottom: 2px solid var(--border-color); padding-bottom: 8px; }
h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 6px; }
h3 { font-size: 1.25rem; }
p { margin-bottom: 1em; }

/* Lists */
ul, ol { margin-bottom: 1em; padding-left: 24px; }
li { margin-bottom: 0.5em; }

/* Blockquotes */
blockquote {
    border-left: 4px solid var(--primary-color);
    padding: 12px 16px;
    margin: 0 0 1em 0;
    background-color: var(--code-bg);
    border-radius: 0 8px 8px 0;
}

/* Code */
code {
    background-color: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: Consolas, Monaco, monospace;
    font-size: 0.9em;
}

/* Tables */
table { width: 100%; border-collapse: collapse; margin-bottom: 1.5em; }
th, td { padding: 12px; border: 1px solid var(--border-color); text-align: left; }
th { background-color: var(--code-bg); font-weight: 600; }

/* Images */
img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 16px 0;
    display: block;
}

/* Footer */
.site-footer {
    background-color: var(--footer-bg);
    padding: 30px 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: var(--text-color);
    opacity: 0.8;
}

/* Homepage Cards */
.category-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 24px;
}
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    border-color: var(--primary-color);
}
.card h3 { margin-top: 0; margin-bottom: 12px; font-size: 1.25rem; border: none; padding-bottom: 0; }
.card h3 a { color: var(--text-color); }
.card h3 a:hover { color: var(--primary-color); text-decoration: none; }
.card p { flex-grow: 1; color: var(--text-muted); font-size: 0.95rem; margin-bottom: 20px; }
.btn {
    display: inline-block;
    background-color: var(--primary-color);
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
    transition: background-color 0.2s;
}
.btn:hover { background-color: var(--hover-color); color: #fff; text-decoration: none; }


/* Navbar UI Module */
.navbar-wrapper {
    position: sticky;
    top: 16px;
    z-index: 100;
    max-width: 1050px;
    margin: 16px auto;
    padding: 0 16px;
}
.navbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(22, 27, 34, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 12px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
@media (prefers-color-scheme: light) {
    .navbar-inner {
        background: rgba(248, 250, 252, 0.85);
        border: 1px solid rgba(0, 0, 0, 0.06);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.6);
    }
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand-icon {
    width: 36px;
    height: 36px;
    background: rgba(56, 189, 248, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 1px solid rgba(56, 189, 248, 0.2);
}
@media (prefers-color-scheme: light) {
    .brand-icon { background: rgba(52, 152, 219, 0.1); border-color: rgba(52, 152, 219, 0.2); }
}
.brand-text {
    display: flex;
    flex-direction: column;
}
.brand-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-color);
}
.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted, #94a3b8);
    margin-top: 2px;
}
.nav-links {
    display: flex;
    gap: 8px;
    align-items: center;
}
.nav-item {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    transition: all 0.2s ease;
    border: 1px solid transparent;
}
.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--primary-color);
    text-decoration: none;
    transform: translateY(-1px);
}
@media (prefers-color-scheme: light) {
    .nav-item:hover { background: rgba(0, 0, 0, 0.04); }
}
.nav-item.active {
    background: rgba(56, 189, 248, 0.12);
    color: var(--primary-color);
    border-color: rgba(56, 189, 248, 0.2);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
@media (prefers-color-scheme: light) {
    .nav-item.active {
        background: rgba(52, 152, 219, 0.1);
        border-color: rgba(52, 152, 219, 0.2);
    }
}
.nav-special {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(56, 189, 248, 0.4);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.nav-special:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.6);
}
@media (prefers-color-scheme: light) {
    .nav-special {
        background: rgba(255, 255, 255, 0.5);
        border-color: rgba(52, 152, 219, 0.5);
    }
    .nav-special:hover {
        background: rgba(52, 152, 219, 0.15);
        border-color: rgba(52, 152, 219, 0.7);
    }
}

/* Tablet & Mobile Navigation */
@media (max-width: 992px) {
    .navbar-wrapper { margin: 10px auto; top: 10px; padding: 0 10px; }
    .brand-subtitle { display: none; }
    .nav-links { gap: 4px; }
    .nav-item { padding: 8px 10px; font-size: 0.85rem; }
}

@media (max-width: 768px) {
    .navbar-inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px;
        gap: 12px;
    }
    .nav-links {
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }
    .nav-links::-webkit-scrollbar { display: none; }
}
