:root {
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --border-color: rgba(148, 163, 184, 0.1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.site-header {
    background-color: var(--sidebar-bg);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-logo {
    height: 40px;
    vertical-align: bottom;
    /* Adjust size as needed */
    width: auto;
}

.site-header h1 {
    padding-top: 5px;
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    line-height: 1;
    /* Fix vertical alignment */
    transform: translateY(1px);
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 1rem;
}

.version-info {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-secondary);
    opacity: 0.8;
}

.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: var(--sidebar-bg);
    padding: 2rem;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    /* Scroll if content exceeds height */
    height: 100%;
    /* Fill the app-container height specifically */
    /* Remove sticky if it was checking viewport anyway, or keep it if scrolling the main content page */
    /* Assuming fixed sidebar design: */
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent-color);
    margin-bottom: 2rem;
}

.filter-section {
    margin-bottom: 2rem;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 600;
}

.reset-btn {
    background: transparent;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.reset-btn:hover {
    background: rgba(56, 189, 248, 0.1);
}


.filter-section h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.checkbox-label:hover {
    color: var(--text-primary);
}

.checkbox-label input {
    accent-color: var(--accent-color);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 2rem;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

#search-input {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    width: 300px;
    font-size: 0.9rem;
}

#search-input::placeholder {
    color: var(--text-secondary);
}

.stats {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-left: 1rem;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    overflow-y: auto;
    padding-bottom: 2rem;
    padding-top: 5px;
}

.grid-container.text-view-mode {
    display: block;
    width: 100%;
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    transition: transform 0.2s, border-color 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
}

.card-header {
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

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

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.field-group {
    font-size: 0.9rem;
}

.field-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    /* Visible track against dark backgrounds */
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Tabs */
.tab-nav {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 1rem;
    font-family: inherit;
    position: relative;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-btn.active {
    color: var(--accent-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-color);
}

.tab-btn:hover {
    color: var(--text-primary);
}

/* Hierarchy Styling */
.section-h1 {
    grid-column: 1 / -1;
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

h1 {
    padding-top: 0px;
}

.section-h1 h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.section-h2 {
    grid-column: 1 / -1;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.section-h2 h3 {
    font-size: 1.25rem;
    color: var(--accent-color);
    font-weight: 500;
}

/* Tooltips */
.tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.8rem 1rem;
    border-radius: 6px;
    max-width: 350px;
    font-size: 0.9rem;
    line-height: 1.5;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip.visible {
    opacity: 1;
}

/* Utilities */
.hidden {
    display: none !important;
}

.mobile-only {
    display: none !important;
}

/* Force override Google Doc styles in Introduction */
.intro-block,
.intro-block * {
    color: var(--text-primary) !important;
    background-color: transparent !important;
    font-family: 'Inter', sans-serif !important;
    /* Optional: force consistent font */
}

.intro-block a {
    color: var(--accent-color) !important;
    text-decoration: underline;
}

/* Global override for Google Doc styles in other tabs (Scope, Specs) */
.main-content [class^="c"],
.main-content p,
.main-content li,
.main-content h1,
.main-content h2,
.main-content h3,
.main-content h4,
.main-content h5,
.main-content h6,
.main-content td,
.main-content th {
    color: var(--text-primary) !important;
    background-color: transparent !important;
}

.main-content p {
    margin-bottom: 1rem !important;
}

.main-content .c17 {
    line-height: inherit !important;
}

.text-content {
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    grid-column: 1 / -1 !important;
    padding: 0 1rem;
}

.text-content a {
    color: #7dd3fc;
    /* Light blue (Sky 300) for better contrast on dark bg */
    text-decoration: underline;
    transition: color 0.2s;
}

.text-content a:hover {
    color: #bae6fd;
    /* Very light blue (Sky 200) on hover */
}

.text-content ul,
.text-content ol {
    padding-left: 2rem;
    margin-bottom: 1rem;
    list-style-position: outside;
}

.text-content li {
    margin-bottom: 0.5rem;
}

/* Tree View Styles */
.tree-root,
.tree-children {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

.tree-view-container {
    /* Layout: Center in grid */
    grid-column: 1 / -1;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;

    /* Style */
    background-color: var(--card-bg);
    padding: 30px 60px 30px 40px;
    /* Top Right Bottom Left - Extra right padding */
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.tree-children {
    padding-left: 30px !important;
    border-left: 2px solid rgba(148, 163, 184, 0.3) !important;
    margin-left: 10px !important;
    /* Removed display: block !important to allow toggling via .hidden class */
}

.tree-node {
    margin: 4px 0;
}

.tree-content {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-primary);
    transition: background-color 0.2s;
    /* font-family: monospace; Removed per user request */
    font-size: 0.9em;
}

.tree-content:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.tree-icon {
    margin-right: 8px;
    font-size: 1.1em;
    opacity: 0.7;
}

.tree-toggle {
    margin-right: 5px;
    width: 14px;
    text-align: center;
    font-size: 0.8em;
    color: var(--text-secondary);
}

.tree-toggle.empty {
    opacity: 0;
    pointer-events: none;
}

@media print {

    /* Hide non-printable elements */
    .sidebar,
    .top-bar,
    .tab-nav,
    #filter-container,
    .tree-controls {
        display: none !important;
    }

    /* Repeat header on every page */
    .site-header {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        background: white;
        border-bottom: 2px solid black;
        z-index: 1000;
        padding-left: 0;
        border-bottom: 2px solid black;
    }

    .site-header h1 {
        color: black !important;
    }

    .version-info {
        color: black !important;
        opacity: 1;
    }

    /* Tree View Styles */
    .tree-root,
    .tree-children {
        list-style-type: none;
        padding-left: 0;
        margin: 0;
    }

    .tree-view-container {
        /* DEBUG: Dark red background to verify styles are loading */
        background-color: rgba(50, 20, 20, 0.5);
        padding: 10px;
        border-radius: 8px;
    }

    .tree-children {
        /* Indent the container of children */
        padding-left: 30px !important;
        /* Add a visible border line */
        border-left: 2px solid rgba(255, 255, 255, 0.3) !important;
        margin-left: 10px !important;
        display: block !important;
    }

    .tree-node {
        margin: 4px 0;
    }

    .tree-content {
        display: flex;
        align-items: center;
        padding: 6px 10px;
        cursor: pointer;
        border-radius: 4px;
        color: var(--text-color);
        transition: background-color 0.2s;
        font-family: var(--font-mono);
        /* Use monospace for file names */
        font-size: 0.9em;
    }

    .tree-content:hover {
        background-color: var(--bg-hover);
    }

    .tree-icon {
        margin-right: 8px;
        font-size: 1.1em;
        opacity: 0.7;
    }

    .tree-toggle {
        margin-right: 5px;
        width: 14px;
        text-align: center;
        font-size: 0.8em;
        color: var(--text-muted);
    }

    .tree-toggle.empty {
        opacity: 0;
        pointer-events: none;
    }

    /* Folder/File Icons can be refined here if we distinguish files later */
    /* Layout adjustments */
    body {
        height: auto;
        overflow: visible;
        background-color: white;
        color: black;
        margin-top: 4rem;
        /* Make space for fixed header */
    }

    .app-container {
        display: block;
        height: auto;
        overflow: visible;
    }

    .main-content {
        padding: 0;
        overflow: visible;
        display: block;
    }

    .grid-container {
        display: block;
        /* Print as list usually better */
        grid-template-columns: 1fr;
        padding-bottom: 0;
    }

    /* Card styling for print */
    .card {
        border: 1px solid #ccc;
        background: white;
        box-shadow: none;
        margin-bottom: 1rem;
        break-inside: avoid;
        color: black;
    }

    .card-title {
        color: black;
        font-weight: bold;
    }

    .card-body p,
    .card-body li {
        color: black;
    }

    /* Introduction Text */
    .text-content {
        width: 100%;
        max-width: 100%;
        color: black;
    }

    .intro-block,
    .intro-block * {
        color: black !important;
    }

    /* Ensure links are handled effectively? Optional: show href */

    /* Global Text overrides */
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    p,
    li,
    td,
    th {
        color: black !important;
    }
}

/* Original styles continued */
.text-block-directory-structure p {
    margin-bottom: 0 !important;
    font-family: monospace !important;
    white-space: pre-wrap;
    /* or pre, but pre-wrap safer for mobile */
    line-height: 1.2;
}

.filter-toggle {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
    margin-top: 0.5rem;
    text-decoration: underline;
}

.filter-toggle:hover {
    color: var(--text-primary);
}

.action-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    margin-left: auto;
    /* Push to right */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.action-btn:hover {
    background: var(--background-hover);
    color: var(--text-primary);
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    .mobile-only {
        display: inline-flex !important;
    }

    body.filter-modal-open {
        overflow: hidden;
    }

    .app-container {
        display: block;
        overflow: auto;
    }

    .sidebar {
        display: none;
        /* Hidden by default on mobile */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 9999;
        background-color: var(--bg-color);
        /* Opaque background */
        border: none;
        padding: 1.5rem;
        overflow-y: auto;
    }

    .sidebar.modal-open {
        display: block;
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 2rem;
        padding-bottom: 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-actions {
        display: flex;
        gap: 1rem;
        align-items: center;
    }

    .sidebar-header h2 {
        font-size: 1.25rem;
        margin: 0;
    }

    .filter-section {
        margin-bottom: 1rem;
    }

    .filter-section h3 {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }

    .main-content {
        padding: 1rem;
        overflow: visible;
    }

    .top-bar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    #search-input {
        width: calc(100% - 130px);
        /* Leave room for print/filter buttons */
    }

    #stats-display {
        flex-basis: 100%;
        margin-left: 0;
        order: 3;
        /* Push below search and buttons */
    }

    #mobile-filter-btn {
        margin-left: auto;
    }

    .action-btn {
        margin-left: 0;
    }

    .tab-bar-container {
        padding: 0 1rem !important;
    }

    .tab-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
        margin-bottom: 1rem;
    }

    .site-header {
        padding: 0.5rem 1rem;
        /* Smaller padding for mobile/landscape */
    }

    .site-header h1 {
        font-size: 1rem;
        /* Smaller font for title */
        gap: 0.5rem;
    }

    .header-logo {
        height: 20px;
        /* Smaller logo */
    }

    .grid-container {
        grid-template-columns: 1fr;
    }
}