/*
==================================================================
STYLE: Sidey Minimalist Replica
==================================================================
*/

:root {
    /* Palette - Strict Minimalist */
    --bg-body: #ffffff;
    --bg-sidebar: #f7f9fb;
    /* Very light cool gray */
    --border-color: #e2e8f0;
    --bg-input: #ffffff;
    --bg-card: #ffffff;
    --bg-quote: #f8fafc;
    --bg-tag: #f1f5f9;
    --bg-code-inline: #f1f5f9;
    --bg-code-block: #1e293b;

    --text-primary: #1e293b;
    /* Slate 800 */
    --text-secondary: #64748b;
    /* Slate 500 */
    --text-accent: #2563eb;
    /* Blue 600 - The only color pop */
    --text-muted: #334155;
    --code-text: #d63384;
    --text-code-block: #f1f5f9;

    --font-main:
        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        sans-serif;
    --radius: 8px;
}

body[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-sidebar: #0b1220;
    --border-color: #1f2937;
    --bg-input: #111827;
    --bg-card: #0b1220;
    --bg-quote: #1e293b;
    --bg-tag: #1e293b;
    --bg-code-inline: #1e293b;
    --bg-code-block: #111827;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-accent: #60a5fa;
    --text-muted: #cbd5e1;
    --code-text: #f472b6;
    --text-code-block: #e2e8f0;
}

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

body {
    font-family: var(--font-main);
    color: var(--text-primary);
    background-color: var(--bg-body);
    display: flex;
    height: 100vh;
    overflow: hidden;
    line-height: 1.6;
}

/* --- Sidebar (The "Sidey" Look) --- */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
}

.sidebar-header {
    padding: 24px 24px 10px 24px;
    /* More top padding */
    position: relative;
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.search-box {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--text-accent);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.theme-toggle {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--text-accent);
    transform: rotate(15deg);
}

.theme-toggle .fa-sun {
    display: none;
}

body[data-theme="dark"] .theme-toggle .fa-sun {
    display: inline-block;
}

body[data-theme="dark"] .theme-toggle .fa-moon {
    display: none;
}

.nav-tree {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0 30px 0;
}

/* Custom Scrollbar for Sidebar */
.nav-tree::-webkit-scrollbar {
    width: 6px;
    /* Slightly thinner for sidebar */
}

.nav-tree::-webkit-scrollbar-track {
    background: transparent;
}

.nav-tree::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 20px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.nav-tree::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary);
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    padding: 0 24px 8px;
    font-weight: 600;
}

.nav-item {
    padding: 6px 24px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    /* Side marker */
}

.nav-item:hover {
    color: var(--text-primary);
    transform: translateX(4px);
}

/* Active State: Minimalist (Bold + Color, no background block) */
.nav-item.active {
    color: var(--text-accent);
    font-weight: 600;
    background-color: transparent;
    /* Removed blocky background */
    border-left-color: var(--text-accent);
    transform: translateX(4px);
}

.nav-item i {
    width: 16px;
    text-align: center;
    font-size: 0.9em;
    opacity: 0.8;
}

/* --- BREADCRUMBS --- */
.breadcrumbs {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.breadcrumb-item {
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
}

.breadcrumb-item:hover {
    color: var(--text-accent);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
    cursor: default;
    pointer-events: none;
}

.breadcrumb-separator {
    color: var(--border-color);
    font-size: 0.8em;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 60px 80px;
    /* Generous whitespace */
    /* max-width removed to fix scrollbar position */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Custom Scrollbar */
.main-content::-webkit-scrollbar {
    width: 8px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 20px;
    border: 3px solid transparent;
    background-clip: content-box;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary);
}

/* Back Button Style */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-decoration: none;
    margin-bottom: 30px;
    transition: color 0.2s;
    cursor: pointer;
    align-self: flex-start;
    width: 100%;
    max-width: 1000px;
}

.back-link:hover {
    color: var(--text-accent);
}

/* --- Typography (Marked.js Output) --- */
.markdown-body {
    color: var(--text-primary);
    width: 100%;
    max-width: 1000px;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    display: block;
    margin: 1.5rem 0;
}

/* ... existing typography styles ... */

/* --- News Container (Log Renderer) --- */
.log-section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 32px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--text-accent);
    display: inline-block;
}

.log-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.news-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.news-header-box {
    display: flex;
    align-items: center;
    padding: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    gap: 16px;
}

.news-header-box:hover {
    background-color: var(--bg-quote);
}

.news-thumb-small {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
}

.news-title-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.news-title-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.news-date-badge {
    font-size: 0.8rem;
    color: var(--text-accent);
    font-weight: 500;
}

.news-toggle-icon {
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.news-body-content {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-body);
}

.news-body-content .markdown-body {
    padding: 0;
}



.landing-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

.markdown-body h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 1rem;
    border-bottom: none;
    /* Cleaner look */
    line-height: 1.2;
}

.markdown-body h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.markdown-body p {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
    /* Slightly softer than pure black */
}

.markdown-body a {
    color: var(--text-accent);
    text-decoration: none;
    font-weight: 500;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body blockquote {
    border-left: 3px solid var(--text-accent);
    background: var(--bg-quote);
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    margin: 2rem 0;
    font-style: italic;
}

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

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

/* --- TABLE STYLES --- */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
    overflow-x: auto;
    display: block;
    /* Ensures responsive scrolling on small screens if needed */
}

/* Restore table display on larger screens */
@media (min-width: 640px) {
    .markdown-body table {
        display: table;
    }
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    text-align: left;
}

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

/* Zebra Striping using existing tag background variable */
.markdown-body tr:nth-child(even) {
    background-color: var(--bg-tag);
}

/* Code Blocks */
.markdown-body pre {
    background: var(--bg-code-block);
    color: var(--text-code-block);
    padding: 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.markdown-body code {
    background: var(--bg-code-inline);
    color: var(--code-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: monospace;
}

.tag-pill {
    display: inline-block;
    background: var(--bg-tag);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-right: 8px;
    margin-bottom: 24px;
    font-weight: 500;
}

/* --- THE SHELF GRID (Updated for Minimal Look) --- */
.shelf-header {
    margin-bottom: 20px;
}

.shelf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.shelf-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    flex-direction: column;
}

.shelf-card:hover {
    border-color: var(--text-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    /* Softer shadow */
}

.shelf-icon {
    font-size: 1.8rem;
    color: var(--text-accent);
    margin-bottom: 16px;
}

.shelf-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.shelf-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* --- LIST VIEW (Minimal & Stacked) --- */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* Removed gap for stacked border style */
    margin-top: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card);
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    gap: 12px;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover {
    background-color: var(--bg-sidebar);
    border-bottom-color: var(--text-accent);
    transform: translateX(4px);
}

/* Removed list-icon-container and list-icon styles */

.list-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Stack title and desc */
    justify-content: center;
}

.list-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0;
}

.list-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;

}

.list-arrow {
    font-size: 0.9rem;
    color: var(--border-color);
    transition: color 0.2s;
}

.list-item:hover .list-arrow {
    color: var(--text-accent);
}

/* --- LANDING PAGE --- */
.landing-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

.landing-hero {
    text-align: center;
    margin-bottom: 60px;
}

.landing-hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.landing-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

.landing-section {
    margin-bottom: 40px;
}

.landing-section-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/* --- MOBILE HEADER & LAYOUT --- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(255, 255, 255, 0.85);
    /* Fallback */
    background: var(--bg-body);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

body[data-theme="dark"] .mobile-header {
    background: rgba(15, 23, 42, 0.85);
}

.mobile-brand {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.header-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.sidebar-backdrop.visible {
    opacity: 1;
    visibility: visible;
}

/* --- MOBILE SEARCH OVERLAY --- */
.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-body);
    z-index: 2000;
    display: none;
    flex-direction: column;
}

.mobile-search-overlay.open {
    display: flex;
}

.mobile-search-bar {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.mobile-search-bar input {
    flex: 1;
    background: transparent;
    border: none;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
}

.close-search-btn {
    background: transparent;
    border: none;
    color: var(--text-accent);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
}

.mobile-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* --- RESPONSIVE MEDIA QUERIES --- */
@media (max-width: 768px) {

    /* Show Header */
    .mobile-header {
        display: flex;
    }

    /* Adjust Sidebar for Mobile */
    .sidebar {
        position: fixed;
        top: 0;
        /* Align to top, header is overlay or sibling? */
        bottom: 0;
        left: 0;
        width: 280px;
        /* Slightly wider */
        z-index: 1001;
        /* Above header */
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        /* Shadow handled by backdrop? Or add distinct shadow */
        border-right: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    }

    /* Adjust Main Content */
    .main-content {
        padding: 80px 20px 40px 20px;
        width: 100%;
        margin-left: 0;
    }

    /* Hide Search in Sidebar on Mobile to avoid redundancy? 
       Actually, keep it as fallback or hide it. 
       User said: "search bar is in the sidebar... cumbersome".
       We are solving this with top bar. We can hide the sidebar search on mobile.
    */
    .sidebar .search-box {
        display: none;
    }
}

/* --- LINK LIBRARY (Visual Gallery) --- */
.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.link-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    text-decoration: none;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.link-card:hover {
    border-color: var(--text-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.link-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0 !important;
    margin-bottom: 8px !important;
    border: none !important;
}

.link-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0 !important;
    flex-grow: 1;
}

.card-icon {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

/* --- Sidebar Footer (Force Add) --- */
.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    background-color: var(--bg-sidebar);
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    padding: 4px 0;
}

.footer-link:hover {
    color: var(--text-accent);
}

.footer-link i {
    width: 16px;
    text-align: center;
    font-size: 0.9em;
    opacity: 0.8;
}