/* Global Styles */
:root {
    /* Colors */
    --bg-color: #ffffff;
    --text-color: #1f2937;
    --primary-color: #3b82f6;
    --secondary-color: #6b7280;
    --link-color: #2563eb;
    --border-color: #e5e7eb;
    --card-bg: #f9fafb;
    --code-bg: #f3f4f6;
    --bg-gradient: linear-gradient(135deg, #f0f7ff 0%, #ffffff 100%);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

    /* Fonts */
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
}

body {
    font-family: var(--font-body);
    line-height: 1.6;
    color: var(--text-color);
    background: var(--bg-gradient);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
}

code,
pre,
.category-tree {
    font-family: var(--font-code) !important;
}

/* Layout */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background: var(--header-bg);
    /* backdrop-filter: blur(10px); Removed for solid bg */
    border-bottom: 1px solid var(--border-color);
    /* position: sticky; Removed */
    /* top: 0; Removed */
    z-index: 100;
}

nav {
    max-width: 1400px;
    /* Expand Navbar Width */
    width: 100%;
    /* Ensure full width usage */
    margin: 0 auto;
    padding: 1rem 2rem;
    /* Add side padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    /* Include padding in width */
}

.logo {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    line-height: 1.1;
    /* Tight line height for 2 lines */
    font-size: 1.1rem;
    /* Slightly smaller font */
    font-weight: 800;
    background: linear-gradient(90deg, var(--primary-color), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

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

/* --- Responsive Layout & Main Frame --- */
main {
    flex: 1;
    max-width: 1200px;
    /* Expanded Width */
    width: 100%;
    margin: 0 auto;
    padding: 3rem 2rem;
    /* Better Padding */
    box-sizing: border-box;
}

/* ... (omitted) ... */

/* Consolidated Metadata Styles */
.post-meta-top {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.post-category-label,
.post-author-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    /* Precise Fixed Height */
    line-height: normal;
    font-size: 0.75rem;
    font-family: var(--font-code), monospace;
    /* Unified Font */
    padding: 0 10px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-sizing: border-box;
}

.post-category-label {
    color: var(--primary-color);
    background: rgba(187, 134, 252, 0.1);
    border: 1px solid rgba(187, 134, 252, 0.1);
}

.post-author-label {
    color: var(--secondary-color);
    background: var(--code-bg);
    border: 1px solid var(--code-bg);
}

footer {
    text-align: center;
    padding: 0.6rem;
    color: var(--secondary-color);
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
    margin-top: auto;
}

/* Components */
/* --- Modern Tree Explorer Styles --- */
.category-tree-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
}

.tree-list {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

/* Indentation Guide Line */
.tree-item .tree-list {
    padding-left: 1.5rem;
    margin-left: 0.75rem;
    border-left: 1px solid var(--border-color);
}

.tree-item {
    margin: 2px 0;
}

.tree-content {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-color);
}

.tree-content:hover {
    background-color: rgba(255, 255, 255, 0.05);
    /* Subtle hover in dark mode */
}

/* Link Style */
.tree-label {
    flex-grow: 1;
    color: inherit;
    text-decoration: none;
    font-weight: 500;
    margin-left: 8px;
}

.tree-label:hover {
    text-decoration: underline;
}

/* Icons and Toggles */
.tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 4px;
    border-radius: 4px;
    transition: transform 0.2s ease;
    color: var(--secondary-color);
    /* Assuming --muted is similar to --secondary-color */
}

.tree-toggle:hover {
    background-color: rgba(128, 128, 128, 0.2);
    color: var(--text-color);
}

.tree-toggle.hidden {
    visibility: hidden;
}

.tree-icon {
    display: flex;
    align-items: center;
    color: var(--primary-color);
    /* Folder color */
}

/* Badge */
.tree-badge {
    font-size: 0.75rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--secondary-color);
    /* Assuming --muted is similar to --secondary-color */
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: auto;
}

/* Expand/Collapse Logic */
.tree-item>.tree-list {
    display: none;
    /* Collapsed by default */
}

.tree-item.expanded>.tree-list {
    display: block;
    /* Expanded */
}

/* Rotate Chevron when Expanded */
.tree-item.expanded>.tree-content .chevron-icon {
    transform: rotate(90deg);
}

.chevron-icon {
    transition: transform 0.2s ease;
}

.post-list {
    display: grid;
    gap: 2rem;
}

.post-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--card-shadow);
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s;
}

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

/* Typography (Markdown Optimized) */
.markdown-body {
    font-size: 1.05rem;
    line-height: 1.8;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin-top: 2em;
    margin-bottom: 1rem;
    font-weight: 700;
    line-height: 1.25;
}

.markdown-body h1 {
    font-size: 2.2em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}

.markdown-body h2 {
    font-size: 1.75em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}

.markdown-body h3 {
    font-size: 1.4em;
}

.markdown-body p {
    margin-bottom: 1.5em;
}

.markdown-body a {
    color: var(--link-color);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.markdown-body blockquote {
    color: var(--secondary-color);
    border-left: 4px solid var(--primary-color);
    padding: 0.5em 1em;
    background-color: var(--card-bg);
    border-radius: 0 8px 8px 0;
    margin: 1.5em 0;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 1.5em;
    margin-bottom: 1.5em;
}

.markdown-body li {
    margin-bottom: 0.5em;
}

.markdown-body img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    margin: 2rem 0;
}

/* Inline Code */
.markdown-body code:not([class*="language-"]) {
    background-color: var(--code-bg);
    color: #e01e5a;
    /* Slack-like code color or match theme */
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.9em;
}

/* Dark Mode Overrides (Assumes classes added by dark.css or variable shifts) */
[data-theme="dark"] .markdown-body code:not([class*="language-"]) {
    color: #ff79c6;
    background-color: #2d3748;
}

/* Table Styles */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
    overflow-x: auto;
    display: block;
}

.markdown-body th,
.markdown-body td {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
}

.markdown-body th {
    background-color: var(--card-bg);
    font-weight: 600;
}

/* Post Detail Styles */
.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    /* No background to blend in */
}

/* Old .post-category-label removed */

.post-title {
    margin: 0 0 0.5rem 0;
    font-size: 2.2rem;
    line-height: 1.3;
    color: var(--text-color);
}

.post-meta-info {
    color: var(--secondary-color);
    font-size: 0.95rem;
}

.back-link-container {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.back-link {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}

.back-link:hover {
    background-color: var(--border-color);
    transform: translateY(-1px);
    box-shadow: var(--card-shadow);
}

/* --- Header & Navigation --- */
header {
    background-color: var(--header-bg);
    /* Opacity fix */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    /* Remove sticky */
    z-index: 100;
}

/* ... (omitted) ... */

/* Removed Duplicate Metadata Styles (Consolidated above) */

/* Responsive Mobile Layout */
@media (max-width: 768px) {
    main {
        padding: 1rem;
        /* Compact padding */
    }

    nav {
        padding: 1rem;
        /* Compact nav padding on mobile */
    }

    .markdown-body h1 {
        font-size: 1.8rem;
    }

    .post-title {
        font-size: 1.6rem;
    }

    .post-header {
        margin-bottom: 1.5rem;
    }
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.5rem 0 1rem 0;
}

.tag-badge {
    font-size: 0.8rem;
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
    /* Light Blue Tint */
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 500;
}

/* Cache Reset Button in Footer */
.reset-cache-btn {
    background: none;
    border: none;
    color: var(--secondary-color);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.6;
    margin-top: 0.5rem;
    padding: 0.5rem;
    transition: opacity 0.2s;
}

.reset-cache-btn:hover {
    opacity: 1;
    color: var(--text-color);
}

/* Utility */
.error {
    color: #ef4444;
    font-weight: bold;
}