/* =============================================================================
    ENHANCED ROOT CSS VARIABLES WITH COMPACT VIEW SUPPORT & DESIGN TOKENS
    ============================================================================= */
:root { 
    /* Base Color Palette */
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    
    /* Hierarchy Colors */
    --grandparent-color: #2e455d;
    --parent-color: #3498db;
    --child-color: #27ae60;
    --grandchild-color: #f39c12;
    
    /* Hierarchy Color Variations */
    --grandparent-hover: #34495e;
    --parent-hover: #2980b9;
    --child-hover: #229954;
    --grandchild-hover: #e67e22;
    
    /* Background Colors (Light Theme) */
    --body-bg: #f8f9fa;
    --content-bg: #ffffff;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --file-item-bg: #f8f9fa;
    --code-bg: #1e1e1e;
    --table-bg: #ffffff;
    --table-header-bg: #f6f8fa;
    
    /* Text Colors (Light Theme) */
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #999;
    --text-on-dark: #ffffff;
    --text-on-light: #333333;
    --header-text: #2c3e50;
    
    /* Border Colors */
    --border-color: #ddd;
    --border-light: #e9ecef;
    --border-dark: #333;
    --table-border: #e1e5e9;
    
    /* Layout & Spacing - FULL VIEW (Default) */
    --content-padding: 1rem;
    --border-radius: 8px;
    --border-radius-small: 3px;
    --border-radius-large: 15px;
    --transition-speed: 0.2s;
    --transition-fast: 0.1s;
    --transition-slow: 0.3s;
    
    /* Shadows */
    --shadow-light: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 8px rgba(0,0,0,0.15);
    --shadow-heavy: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-inset: inset 0 2px 4px rgba(0,0,0,0.1);
    
    /* Hierarchy Layout - FULL VIEW */
    --hierarchy-border-width: 4px;
    --hierarchy-inner-radius: 12px;
    --hierarchy-content-bg: var(--content-bg);
    --hierarchy-margin-parent: 0.29rem;
    --hierarchy-margin-child: 0.30rem;
    --hierarchy-margin-grandchild: 0.31rem;
    --hierarchy-spacing: 0px;
    --hierarchy-header-padding: 1rem;
    --hierarchy-meta-font-size: 0.85rem;
    --hierarchy-title-font-size: 1rem;
    --hierarchy-toggle-size: 1.2rem;
    
    /* Compact View Variables */
    --compact-hierarchy-header-padding: 0.2rem;
    --compact-hierarchy-meta-font-size: 0.75rem;
    --compact-hierarchy-title-font-size: 0.9rem;
    --compact-hierarchy-toggle-size: 1rem;
    --compact-content-padding: 0.75rem;
    --compact-hierarchy-border-width: 3px;
    --compact-hierarchy-inner-radius: 12px;
    --compact-hierarchy-spacing: 0px;
    --compact-hierarchy-margin-reduction: 0rem;
    
    /* Typography */
    --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-family-mono: 'Monaco', 'Consolas', 'SF Mono', 'Courier New', monospace;
    --font-size-base: 1rem;
    --font-size-small: 0.85rem;
    --font-size-tiny: 0.75rem;
    --font-size-large: 1.2rem;
    --line-height-base: 1.6;
    --line-height-tight: 1.4;
    --line-height-loose: 1.2;
    
    /* Code & Syntax */
    --code-bg-primary: #1e1e1e;
    --code-bg-secondary: linear-gradient(135deg, #2d2d30, #383838);
    --code-text: #d4d4d4;
    --code-comment: #6a9955;
    --code-keyword: #569cd6;
    --code-string: #ce9178;
    --code-number: #b5cea8;
    --code-function: #dcdcaa;
    --code-variable: #9cdcfe;
    --inline-code-bg: #f6f8fa;
    --inline-code-text: #24292f;
    --inline-code-border: #d1d9e0;
    
    /* Form Elements */
    --input-border: #ddd;
    --input-focus: var(--primary-color);
    --input-padding: 0.75rem;
    
    /* Back to Top Colors (Child Level Logic) */
    --back-to-top-grandparent: var(--parent-color);
    --back-to-top-parent: var(--child-color);
    --back-to-top-child: var(--grandchild-color);
    --back-to-top-grandchild: var(--content-bg);
    
    /* Back to Top Last Level Logic */
    --back-to-top-last-level-bg: var(--hierarchy-content-bg);
    --back-to-top-last-level-text: var(--text-primary);
    
    /* Animation Variables */
    --hover-scale: 1.02;
    --hover-lift: -2px;
    --compact-hover-scale: 1.01;
    --compact-hover-lift: -1px;
    
    /* Button & Control Variables */
    --button-padding: 0.75rem 1.5rem;
    --button-small-padding: 0.25rem 0.5rem;
    --compact-button-padding: 0.5rem 1rem;
    --compact-button-small-padding: 0.2rem 0.4rem;
}

/* Dark Theme Variables */
:root[data-theme="dark"],
body.dark-theme {
    --body-bg: #1a202c;
    --content-bg: #2d3748;
    --card-bg: #2d3748;
    --input-bg: #4a5568;
    --file-item-bg: #4a5568;
    --table-bg: #2d3748;
    --table-header-bg: #4a5568;
    --hierarchy-content-bg: #2d3748;
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --text-muted: #718096;
    --text-on-dark: #ffffff;
    --text-on-light: #e2e8f0;
    --header-text: #f7fafc;
    --border-color: #4a5568;
    --border-light: #2d3748;
    --input-border: #2d3748;
    --table-border: #4a5568;
    --back-to-top-grandparent: #2471a3;
    --back-to-top-parent: #1e8449;
    --back-to-top-child: #d68910;
    --back-to-top-grandchild: #2d3748;
    --inline-code-bg: #282c34;
    --inline-code-text: #abb2bf;
    --inline-code-border: #3e4451;
    --back-to-top-last-level-bg: var(--hierarchy-content-bg);
    --back-to-top-last-level-text: var(--text-primary);
}

/* COMPACT VIEW OVERRIDE VARIABLES */
.project-navigation.compact-view {
    --hierarchy-header-padding: var(--compact-hierarchy-header-padding);
    --hierarchy-meta-font-size: var(--compact-hierarchy-meta-font-size);
    --hierarchy-title-font-size: var(--compact-hierarchy-title-font-size);
    --hierarchy-toggle-size: var(--compact-hierarchy-toggle-size);
    --content-padding: var(--compact-content-padding);
    --hierarchy-border-width: var(--compact-hierarchy-border-width);
    --hierarchy-inner-radius: var(--compact-hierarchy-inner-radius);
    --hierarchy-spacing: var(--compact-hierarchy-spacing);
    --hover-scale: var(--compact-hover-scale);
    --hover-lift: var(--compact-hover-lift);
    --hierarchy-margin-parent: calc(0.22rem - var(--compact-hierarchy-margin-reduction));
    --hierarchy-margin-child: calc(0.22rem - var(--compact-hierarchy-margin-reduction));
    --hierarchy-margin-grandchild: calc(0.24rem - var(--compact-hierarchy-margin-reduction));
}

/* =============================================================================
    RESET & BASE STYLES
    ============================================================================= */

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

body {
    font-family: var(--font-family-base);
    line-height: var(--line-height-base);
    background: var(--body-bg);
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

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

/* =============================================================================
    HEADER & NAVIGATION
    ============================================================================= */

.header {
    background: var(--secondary-color);
    color: var(--text-on-dark);
    /* padding: 1rem 0; */
    /* margin-bottom: 2rem; */
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
}

.header h1 {
    text-align: center;
    margin: 0;
}

.logout-btn {
    position: absolute;
    top: 1rem;
    right: 2rem;
    background: var(--danger-color);
    color: var(--text-on-dark);
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: var(--border-radius-small);
    font-size: 0.9rem;
    transition: background-color var(--transition-speed);
}

.logout-btn:hover {
    background: #c0392b;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 1rem;
    left: 2rem;
    background: var(--primary-color);
    color: var(--text-on-dark);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    z-index: 1000;
    transition: all var(--transition-slow);
    box-shadow: var(--shadow-light);
    will-change: transform;
}

.theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.theme-toggle.dark-mode {
    background: #4a5568;
}

/* =============================================================================
    FORMS & BUTTONS
    ============================================================================= */

.login-form {
    max-width: 400px;
    margin: 50px auto;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

.login-form h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--header-text);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: var(--input-padding);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-small);
    font-size: var(--font-size-base);
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color var(--transition-speed);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--input-focus);
}

.form-group textarea {
    min-height: 400px;
    resize: vertical;
}

/* Checkbox Exceptions */
.form-group input[type="checkbox"],
.form-group input[type="radio"],
.existing-file-item input[type="checkbox"],
.file-checkbox {
    width: auto;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
}

/* Button System */
.btn {
    background: var(--grandparent-color);
    color: var(--text-on-dark);
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    font-size: var(--font-size-base);
    text-decoration: none;
    display: inline-block;
    transition: all var(--transition-speed);
    will-change: transform;
}

.btn:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success-color);
}

.btn-success:hover {
    background: var(--child-hover);
}

.btn-danger {
    background: var(--danger-color);
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* =============================================================================
    ALERTS & NOTIFICATIONS
    ============================================================================= */

.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius-small);
    border: 1px solid transparent;
    animation: fadeIn 0.5s ease-out;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* =============================================================================
    HIERARCHY NAVIGATION SYSTEM
    ============================================================================= */

.project-navigation {
    border-radius: var(--border-radius-large);
    margin-bottom: 2rem;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 0 0 1px rgba(0, 0, 0, 0.15), inset 0 1px 0 0 rgba(255, 255, 255, 0.25), inset 0 -1px 0 0 rgba(255, 255, 255, 0.25), inset 1px 0 0 0 rgba(0, 0, 0, 0.08), inset -1px 0 0 0 rgba(0, 0, 0, 0.08), inset 0 0 0 2px rgba(255, 255, 255, 0.06);
}

.project-controls {
    background: #34495e;
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Hierarchy Headers - Consolidated */
.hierarchy-header {
    padding: var(--hierarchy-header-padding);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: visible;
    /*backdrop-filter: blur(10px);*/
    z-index: 1;
}

.hierarchy-header:hover {
    filter: brightness(105%);
}

.hierarchy-toggle {
    font-size: var(--hierarchy-toggle-size);
    width: 1.5rem;
    text-align: center;
    transition: transform var(--transition-speed);
    will-change: transform;
}

.hierarchy-title {
    flex-grow: 1;
    font-size: var(--hierarchy-title-font-size);
}

.hierarchy-meta {
    font-size: var(--hierarchy-meta-font-size);
    opacity: 0.8;
    font-weight: normal;
}

.hierarchy-actions {
    display: flex;
    gap: 0.25rem;
}

/* Level-specific Header Styling */
.grandparent-header {
    color: var(--text-on-dark);
    background: linear-gradient(
92deg, #2c3e50 0%, #5e789d 50%, #2c3e50 100%);
}

.parent-header {
    color: var(--text-on-dark);
    margin-left: var(--hierarchy-margin-parent);
    margin-right: var(--hierarchy-margin-parent);
    background: linear-gradient(90deg, #1b85cb 0%, #40b2ff 50%, #178ddc 100%);
}

.child-header {
    color: var(--text-on-dark);
    margin-left: var(--hierarchy-margin-child);
    margin-right: var(--hierarchy-margin-child);
    background: linear-gradient(90deg, #1fa055 0%, #49be7b 50%, #1b9e53 100%);
}

.grandchild-header {
    color: var(--text-on-dark);
    margin-left: var(--hierarchy-margin-grandchild);
    margin-right: var(--hierarchy-margin-grandchild);
    background: linear-gradient(
90deg, #f39c12 0%, #ffb43d 50%, #f39c12 100%);
}

/* =============================================================================
    ENHANCED HIERARCHY CONTENT SYSTEM
    ============================================================================= */

.hierarchy-content {
    padding: 0;
    position: relative;
    margin-bottom: 0;
    margin-top: -1px; /* Slight overlap to hide gaps */
    box-shadow: var(--shadow-light);
    padding-bottom: calc(0.03rem + var(--hierarchy-border-width));
    animation: slideInFromTop var(--transition-slow) ease-out;
    will-change: transform;
}

/* Outer Colored Rectangle */
.hierarchy-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background: var(--secondary-color);
}

/* Inner White Rounded Content Area */
.hierarchy-content::after {
    content: '';
    position: absolute;
    top: var(--hierarchy-border-width);
    left: var(--hierarchy-border-width);
    right: var(--hierarchy-border-width);
    bottom: var(--hierarchy-border-width);
    background: var(--hierarchy-content-bg);
    border-radius: var(--hierarchy-inner-radius);
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding-bottom: calc(0.03rem + var(--hierarchy-border-width));
}

/* Content Positioning */
.hierarchy-content > * {
    position: relative;
    z-index: 3;
}

.hierarchy-content > .entry-markdown,
.hierarchy-content > .entry-files {
    padding: calc(var(--content-padding) + 2px);
}

.hierarchy-content > .entry-files {
    margin-top: 0;
    padding-top: 0;
}

.hierarchy-content .hierarchy-item {
    margin-left: 0;
    margin-right: 0;
}

/* Level-specific Content Colors */
.grandparent-item > .hierarchy-content::before {
    background: linear-gradient(90deg, #2c3e50f7 0%, #5e789d 50%, #233547f7 100%);
}

.parent-item > .hierarchy-content {
    margin-left: var(--hierarchy-margin-parent);
    margin-right: var(--hierarchy-margin-parent);
}

.parent-item > .hierarchy-content::before {background: linear-gradient(90deg, #1b85cb 0%, #40b2ff 50%, #178ddc 100%);}

.child-item > .hierarchy-content {
    margin-left: var(--hierarchy-margin-child);
    margin-right: var(--hierarchy-margin-child);
}

.child-item > .hierarchy-content::before {
    background: linear-gradient(90deg, #1fa055 0%, #49be7b 50%, #1b9e53 100%);
}

.grandchild-item > .hierarchy-content {
    margin-left: var(--hierarchy-margin-grandchild);
    margin-right: var(--hierarchy-margin-grandchild);
}

.grandchild-item > .hierarchy-content::before {
    background: linear-gradient(90deg, #f39c12 0%, #ffb43d 50%, #f39c12 100%);
}

/* =============================================================================
    BACK TO TOP SYSTEM (Child Level Colors)
    ============================================================================= */

.back-to-top {
    text-align: center;
    border-bottom-left-radius: calc(var(--border-radius-large) - var(--border-radius-small));
    border-bottom-right-radius: calc(var(--border-radius-large) - var(--border-radius-small));
    cursor: pointer;
    transition: all var(--transition-speed);
    user-select: none;
    padding: 1.5rem;
}

.back-to-top:hover {
    filter: brightness(95%);
    transform: translateY(-1px);
}

.back-to-top:active {
    transform: translateY(0);
}

/* Child Level Color Logic */
.grandparent-item .back-to-top {
    margin-left: var(--hierarchy-margin-parent);
    margin-right: var(--hierarchy-margin-parent);
    background: linear-gradient(90deg, #1b85cb 0%, #40b2ff 50%, #178ddc 100%);
}

.parent-item .back-to-top {
    margin-left: var(--hierarchy-margin-child);
    margin-right: var(--hierarchy-margin-child);
    background: linear-gradient(90deg, #1fa055 0%, #49be7b 50%, #1b9e53 100%);
}

.child-item .back-to-top {
    margin-left: var(--hierarchy-margin-grandchild);
    margin-right: var(--hierarchy-margin-grandchild);
    background: linear-gradient(90deg, #f39c12 0%, #ffb43d 50%, #f39c12 100%);
}

.grandchild-item .back-to-top {
    background: var(--back-to-top-last-level-bg);
    margin-left: var(--hierarchy-margin-grandchild);
    margin-right: var(--hierarchy-margin-grandchild);
}

/* Last level (no children) styling */
.hierarchy-item.grandparent-item.no-children .back-to-top,
.hierarchy-item.parent-item.no-children .back-to-top,
.hierarchy-item.child-item.no-children .back-to-top {
    background: var(--back-to-top-last-level-bg) !important;
    filter: brightness(95%);
}

/* =============================================================================
    MARKDOWN & CONTENT STYLING
    ============================================================================= */

.entry-markdown {
    line-height: var(--line-height-tight);
    font-size: var(--font-size-small);
    color: var(--text-primary);
}

.entry-markdown h1,
.entry-markdown h2,
.entry-markdown h3,
.entry-markdown h4 {
    color: var(--header-text);
    line-height: var(--line-height-loose);
}

.entry-markdown h1 { font-size: 1.3rem; margin: 1.6rem 0 0.4rem 0; }
.entry-markdown h2 { font-size: 1.2rem; margin: 1.4rem 0 0.4rem 0; }
.entry-markdown h3 { font-size: 1.1rem; margin: 2rem 0 0.4rem 0; }
.entry-markdown h4 { font-size: 1rem; margin: 1.5rem 0 0.4rem 0; }

.entry-markdown .text-line {
    margin: 0.3rem 0;
    line-height: var(--line-height-tight);
    color: var(--text-primary);
}

/* Empty Line Spacing */
.markdown-empty-line {
    height: 0.75rem;
    display: block;
}

.markdown-empty-line + .markdown-empty-line {
    height: 1.5rem;
}

.text-line + .markdown-empty-line {
    height: 0.5rem;
}

.markdown-empty-line:first-child {
    display: none;
}

/* Bullet Points */
.bullet-point {
    margin: 0.3rem 0;
    margin-left: 1.5rem;
    line-height: var(--line-height-tight);
    position: relative;
    padding-left: 0.5rem;
    color: var(--text-primary);
}

.bullet-point::before {
    color: var(--primary-color);
    font-weight: bold;
}

.bullet-point-indent-1 {
    margin: 0.2rem 0;
    margin-left: 2.5rem;
    line-height: var(--line-height-tight);
    color: var(--text-secondary);
}

.bullet-point-indent-2 {
    margin: 0.2rem 0;
    margin-left: 4rem;
    line-height: var(--line-height-tight);
    color: var(--text-secondary);
}

.bullet-point-indent-3 {
    margin: 0.2rem 0;
    margin-left: 5.5rem;
    line-height: var(--line-height-tight);
    color: var(--text-muted);
}

.bullet-point-indent-4 {
    margin: 0.2rem 0;
    margin-left: 7rem;
    line-height: var(--line-height-tight);
    color: var(--text-muted);
}

/* Strong/Bold text */
.entry-markdown strong,
.entry-markdown b {
    color: var(--text-primary); /* ADDED */
    font-weight: 600;
}

/* =============================================================================
    CODE BLOCKS & SYNTAX HIGHLIGHTING
    ============================================================================= */

.code-container {
    margin: 1rem 0;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border-dark);
    background: var(--code-bg-primary);
    box-shadow: var(--shadow-heavy);
}

.code-header {
    background: var(--code-bg-primary);
    padding: 0.6rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #404040;
}

.code-language {
    color: var(--code-keyword);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(52, 152, 219, 0.2);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
}

.copy-btn {
    background: transparent;
    border: 1px solid #555;
    color: #cccccc;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    opacity: 0.7;
    transition: all var(--transition-speed);
    will-change: transform;
}

.copy-btn:hover {
    opacity: 1;
    background: #404040;
    border-color: #666;
    transform: translateY(-1px);
}

.copy-btn.copied {
    background: #0e639c;
    border-color: #1177bb;
    color: white;
}

.code-block {
    background: var(--code-bg-secondary);
    color: var(--code-text);
    padding: 1rem;
    margin: 0;
    overflow-x: auto;
    font-family: var(--font-family-mono);
    font-size: 0.7rem;
    line-height: var(--line-height-tight);
    border: none;
    display: block;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Code Line Types */
.code-line-normal { color: var(--code-text); margin: 0; padding: 0; white-space: pre; }
.code-line-comment { color: var(--code-comment); margin: 0; padding: 0; white-space: pre; font-style: italic; }
.code-line-keyword { color: var(--code-keyword); margin: 0; padding: 0; white-space: pre; font-weight: 500; }
.code-line-string { color: var(--code-string); margin: 0; padding: 0; white-space: pre; }
.code-line-number { color: var(--code-number); margin: 0; padding: 0; white-space: pre; }
.code-line-function { color: var(--code-function); margin: 0; padding: 0; white-space: pre; font-weight: 500; }
.code-line-variable { color: var(--code-variable); margin: 0; padding: 0; white-space: pre; }
.code-line-empty { margin: 0; padding: 0; height: 1.4em; }

/* Inline Code */
.inline-code {
    background: var(--inline-code-bg);
    color: var(--inline-code-text);
    padding: 0.15rem 0.4rem;
    border-radius: var(--border-radius-small);
    font-family: var(--font-family-mono);
    font-size: 0.9em;
    font-weight: 500;
    border: 1px solid var(--inline-code-border);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Code Scrollbar Styling */
.code-block::-webkit-scrollbar {
    height: 8px;
}

.code-block::-webkit-scrollbar-track {
    background: #2d2d30;
}

.code-block::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: var(--border-radius-small);
}

.code-block::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* =============================================================================
    BLOCKQUOTES
    ============================================================================= */

.markdown-blockquote {
    margin: 1.5rem 0;
    padding: 1.25rem 1.5rem;
    border-left: 4px solid var(--primary-color);
    background: var(--file-item-bg);
    border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0;
    position: relative;
    box-shadow: var(--shadow-light);
    color: var(--text-primary);
}

.markdown-blockquote::before {
    content: '"';
    position: absolute;
    top: -10px;
    left: 10px;
    font-size: 3rem;
    color: var(--primary-color);
    opacity: 0.2;
    font-family: Georgia, serif;
    line-height: 1;
}

.blockquote-header {
    color: var(--text-primary) !important;
    margin: 0.75rem 0 0.5rem 0 !important;
    font-weight: 600;
}

.blockquote-header:first-child {
    margin-top: 0 !important;
}

.blockquote-text {
    margin: 0.5rem 0;
    line-height: var(--line-height-tight);
    color: var(--text-secondary);
    font-style: italic;
}

.blockquote-text:first-child {
    margin-top: 0;
}

.blockquote-text:last-child {
    margin-bottom: 0;
}

.blockquote-list {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
    list-style-type: disc;
}

.blockquote-list li {
    margin: 0.4rem 0;
    padding-left: 0.5rem;
    line-height: var(--line-height-tight);
    color: var(--text-secondary);
    font-style: normal;
}

.blockquote-list li::marker {
    color: var(--primary-color);
}

.markdown-blockquote .markdown-empty-line {
    height: 0.5rem;
}

.markdown-blockquote code {
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.markdown-blockquote strong {
    color: var(--text-primary);
    font-weight: 700;
}

.markdown-blockquote em {
    color: var(--text-secondary);
}

.markdown-blockquote a {
    color: var(--primary-color);
    font-weight: 500;
}

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

.markdown-blockquote .markdown-blockquote {
    margin: 0.75rem 0;
    padding: 0.75rem 1rem;
    border-left-width: 3px;
    background: rgba(0, 0, 0, 0.03);
}

/* =============================================================================
    FILE MANAGEMENT
    ============================================================================= */

.entry-files {
    padding-top: 1rem;
}

.file-item {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--file-item-bg);
    border-radius: var(--border-radius-small);
    border: 1px solid var(--border-light);
}

.file-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.file-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
}

.file-name {
    word-break: break-word;
    flex-grow: 1;
}

.file-size {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.25rem;
    margin-left: 1.6rem;
}

.file-content {
    margin-top: 1rem;
}

.code-viewer {
    background: var(--code-bg-primary);
    color: var(--code-text);
    padding: 0.8rem;
    border-radius: var(--border-radius-small);
    overflow-x: auto;
    font-family: var(--font-family-mono);
    font-size: 0.85rem;
    line-height: 1.3;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-dark);
}

.image-viewer img,
.video-viewer video {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius-small);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
}

.download-link {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: var(--text-on-dark);
    border-radius: var(--border-radius-small);
    font-size: 0.9rem;
    text-decoration: none;
    transition: background-color var(--transition-speed);
}

.download-link:hover {
    background: var(--parent-hover);
}

.file-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed);
}

.file-link:hover {
    text-decoration: underline;
    color: var(--parent-hover);
}

/* =============================================================================
    FORM INSIDE NAVIGATION - NEW LAYOUT
    ============================================================================= */

.project-navigation .submit-form {
    background: var(--card-bg);
    border-radius: 0;
    box-shadow: none;
    margin: 0;
}

.project-navigation .form-content {
    padding: 1.5rem;
    /* Add the hiding here instead */
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.4s ease-out, opacity 0.3s ease-out;
}

/* Expanded state - this now matches what toggleForm() does */
.project-navigation .form-content.expanded {
    max-height: 2000px;
    opacity: 1;
}

/* Make all control buttons same width */
.project-controls .btn-small {
    min-width: 120px;
    text-align: center;
}


/* Button styling */
#addEntryToggle {
    background: var(--success-color);
}

#addEntryToggle:hover {
    background: var(--child-hover);
}

/* =============================================================================
    FORM COMPONENTS
    ============================================================================= */

.submit-form {
    background: var(--card-bg);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-light);
    margin-top: 2rem;
}

.form-header {
    background: var(--success-color);
    color: var(--text-on-dark);
    padding: 1rem;
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    transition: background-color var(--transition-speed);
}

.form-header:hover {
    background: var(--child-hover);
}

.form-content {
    padding: 1.5rem;
    display: none;
}

.form-content.expanded {
    display: block;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* File Upload */
.file-input {
    border: 2px dashed var(--border-color);
    padding: 2rem;
    text-align: center;
    border-radius: var(--border-radius-small);
    margin-bottom: 1rem;
    transition: all var(--transition-speed);
}

.file-input:hover {
    border-color: var(--primary-color);
    background: var(--file-item-bg);
}

.existing-files-container {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-small);
    padding: 1rem;
    background: var(--file-item-bg);
}

.existing-files-header {
    margin-bottom: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.existing-file-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border-radius: var(--border-radius-small);
    border: 1px solid var(--border-light);
    transition: background-color var(--transition-speed);
}

.existing-file-item:hover {
    background: var(--file-item-bg);
}

.file-info {
    flex-grow: 1;
    min-width: 0;
}

.file-label {
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.3;
    color: var(--text-primary);
}

.file-view-btn {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    border: 1px solid var(--primary-color);
    white-space: nowrap;
    flex-shrink: 0;
    align-self: flex-start;
    transition: all var(--transition-speed);
}

.file-view-btn:hover {
    background: var(--primary-color);
    color: var(--text-on-dark);
}

.file-upload-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #e8f4fd;
    border-radius: var(--border-radius-small);
    font-size: 0.9rem;
    line-height: var(--line-height-tight);
}

.no-files-message {
    color: var(--text-secondary);
    margin: 0;
    text-align: center;
    padding: 1rem;
}

/* =============================================================================
    MARKDOWN TABLES
    ============================================================================= */

.markdown-table-wrapper {
    overflow-x: auto;
    margin: 1rem 0;
    border-radius: 6px;
    border: 1px solid var(--table-border);
}

.markdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    background: var(--table-bg);
    margin: 0;
}

.markdown-table th {
    background: var(--table-header-bg);
    font-weight: 600;
    padding: 0.75rem;
    text-align: left;
    border-bottom: 2px solid var(--table-border);
    border-right: 1px solid var(--table-border);
    color: var(--text-primary);
}

.markdown-table th:last-child {
    border-right: none;
}

.markdown-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--table-border);
    border-right: 1px solid var(--table-border);
    vertical-align: top;
    line-height: var(--line-height-tight);
    color: var(--text-primary);
}

.markdown-table td:last-child {
    border-right: none;
}

.markdown-table tr:hover {
    background: var(--file-item-bg);
}

.markdown-table tr:last-child td {
    border-bottom: none;
}

.markdown-table code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
}

/* =============================================================================
    TABLE OF CONTENTS & NAVIGATION
    ============================================================================= */

.toc-item {
    margin: 0.2rem 0;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border-light);
}

.toc-item a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-speed);
}

.toc-item a:hover {
    text-decoration: underline;
    color: var(--parent-hover);
}

.toc-item a.broken-link {
    color: var(--danger-color);
    font-style: italic;
}

.toc-item a.broken-link::after {
    content: " (not found)";
    font-size: 0.8em;
    color: var(--text-secondary);
}

h1[id], h2[id], h3[id], h4[id] {
    scroll-margin-top: 2rem;
    position: relative;
}

h1[id]:hover::after,
h2[id]:hover::after,
h3[id]:hover::after,
h4[id]:hover::after {
    content: " ÃƒÆ’Ã‚Â°Ãƒâ€¦Ã‚Â¸ÃƒÂ¢Ã¢â€šÂ¬Ã‚ÂÃƒÂ¢Ã¢â€šÂ¬Ã¢â‚¬Â";
    opacity: 0.4;
    font-size: 0.6em;
    margin-left: 0.5rem;
    transition: opacity var(--transition-speed);
}

h1[id]:target,
h2[id]:target,
h3[id]:target,
h4[id]:target {
    animation: targetHighlight 2s ease;
}

.back-to-toc {
    font-size: 0.7em;
    text-decoration: none;
    opacity: 0.6;
    margin-left: 0.5rem;
    transition: opacity var(--transition-speed);
    color: var(--primary-color) !important;
}

.back-to-toc:hover {
    opacity: 1;
    text-decoration: none;
}

h1:hover .back-to-toc,
h2:hover .back-to-toc,
h3:hover .back-to-toc,
h4:hover .back-to-toc {
    opacity: 1;
}

/* =============================================================================
    COLLABORATION INDICATORS
    ============================================================================= */

.collab-indicator.shared {
    color: var(--primary-color);
}

.collab-indicator.shared-read {
    color: var(--text-secondary);
}

.collab-indicator.shared-admin {
    color: var(--warning-color);
}

.collab-indicator.public {
    color: var(--success-color);
}

.collab-indicator.department {
    color: var(--secondary-color);
}

.sharing-section {
    border-left: 3px solid var(--primary-color);
}

/* =============================================================================
    UTILITIES & COMPONENTS
    ============================================================================= */

.markdown-separator {
    width: 100%;
    margin: 2rem auto;
    border: none;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    position: relative;
}

.markdown-separator::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 30%;
    height: 3px;
    background: linear-gradient(to right, #a6cbe3, var(--secondary-color), #a6cbe3);
    border-radius: 2px;
}

/* =============================================================================
    PRINT ICON & PRINT STYLES
    ============================================================================= */

.print-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: rgba(52, 152, 219, 0.9);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
    font-size: 16px;
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 100;
}

.print-icon:hover {
    background: rgba(52, 152, 219, 1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.entry-markdown:hover .print-icon {
    opacity: 1;
}

#print-container {
    display: none;
}

@media print {
    .header,
    .project-navigation,
    .project-controls,
    .submit-form,
    .hierarchy-actions,
    .print-icon,
    .copy-btn,
    .back-to-toc,
    .theme-toggle,
    .logout-btn,
    .file-header button,
    .btn,
    nav,
    aside,
    footer,
    .public-footer,
    title,
    .page-title,
    h1.title {
        display: none !important;
    }
    
    body {
        margin: 0;
        padding: 0;
        background: white;
        color: black;
    }
    
    #print-container {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 15mm 10mm !important;
        box-sizing: border-box;
        font-family: Georgia, 'Times New Roman', serif;
        font-size: 11pt;
        line-height: 1.4;
        color: #000;
        background: white;
    }
    
    @page {
        size: A4;
        margin: 20mm 10mm;
    }
    
    #print-container h1 {
        font-size: 16pt !important;
        font-weight: bold !important;
        margin-bottom: 12pt !important;
        border-bottom: 0.5pt solid #333 !important;
        padding-bottom: 6pt !important;
        color: #000 !important;
    }
    
    #print-container h2 {
        font-size: 14pt !important;
        font-weight: bold !important;
        margin: 18pt 0 8pt 0 !important;
        color: #000 !important;
    }
    
    #print-container h3 {
        font-size: 12pt !important;
        font-weight: bold !important;
        margin: 14pt 0 6pt 0 !important;
        color: #000 !important;
    }
    
    #print-container h4 {
        font-size: 11pt !important;
        font-weight: bold !important;
        margin: 12pt 0 4pt 0 !important;
        color: #000 !important;
    }
    
    #print-container p {
        margin: 0 0 8pt 0 !important;
        text-align: justify !important;
        color: #000 !important;
    }
    
    #print-container ul, #print-container ol {
        margin: 8pt 0 8pt 18pt !important;
    }
    
    #print-container li {
        margin: 2pt 0 !important;
        color: #000 !important;
    }
    
    #print-container code {
        font-family: 'Courier New', monospace !important;
        font-size: 9pt !important;
        background: #f5f5f5 !important;
        padding: 1pt 2pt !important;
        border: 0.25pt solid #ddd !important;
        color: #000 !important;
    }
    
    #print-container pre {
        font-family: 'Courier New', monospace !important;
        font-size: 9pt !important;
        background: #f8f8f8 !important;
        border: 0.5pt solid #ddd !important;
        padding: 8pt !important;
        margin: 8pt 0 !important;
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
        color: #000 !important;
    }
    
    #print-container blockquote {
        margin: 12pt 0 12pt 24pt !important;
        padding: 8pt 12pt !important;
        border-left: 2pt solid #ccc !important;
        font-style: italic !important;
        color: #000 !important;
    }
    
    #print-container table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin: 12pt 0 !important;
    }
    
    #print-container th,
    #print-container td {
        border: 0.5pt solid #333 !important;
        padding: 4pt 6pt !important;
        text-align: left !important;
        color: #000 !important;
    }
    
    #print-container th {
        background: #f0f0f0 !important;
        font-weight: bold !important;
    }
    
    #print-container h1,
    #print-container h2 {
        page-break-after: avoid;
    }
    
    #print-container pre,
    #print-container table {
        page-break-inside: avoid;
    }
    
    #print-container img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    .markdown-blockquote {
        border-color: #000;
        background: #f5f5f5;
        page-break-inside: avoid;
    }
    
    .markdown-blockquote::before {
        display: none;
    }
    
    .blockquote-header {
        color: #000 !important;
    }
    
    .blockquote-text {
        color: #333;
    }
    
    .markdown-empty-line {
        height: 0.5rem;
    }
}

/* =============================================================================
    FILE UPLOAD PROGRESS & VALIDATION STYLES
    ============================================================================= */

.upload-progress-container {
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 1rem 0;
    box-shadow: var(--shadow-medium);
    animation: slideIn 0.3s ease-out;
}

.upload-progress-container.error {
    border-color: var(--danger-color);
}

.upload-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.upload-progress-header strong {
    font-size: 1.1rem;
    color: var(--primary-color);
}

.upload-cancel {
    cursor: pointer;
    color: var(--danger-color);
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color var(--transition-speed);
}

.upload-cancel:hover {
    background: rgba(231, 76, 60, 0.1);
}

.upload-progress-bar {
    width: 100%;
    height: 30px;
    background: var(--file-item-bg);
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
}

.upload-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    transition: width 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
}

.upload-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

.upload-progress-text {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.upload-percent {
    font-weight: bold;
    color: var(--primary-color);
}

.upload-size {
    font-family: var(--font-family-mono);
}

.upload-progress-status {
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: var(--file-item-bg);
    border-radius: var(--border-radius-small);
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

.upload-error-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: var(--danger-color);
}

.upload-error-header strong {
    font-size: 1.1rem;
}

.upload-error-header span {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color var(--transition-speed);
}

.upload-error-header span:hover {
    background: rgba(231, 76, 60, 0.1);
}

.upload-error-message {
    padding: 1rem;
    background: rgba(231, 76, 60, 0.1);
    border-left: 4px solid var(--danger-color);
    border-radius: var(--border-radius-small);
    margin-bottom: 1rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.upload-error-tips {
    background: var(--file-item-bg);
    padding: 1rem;
    border-radius: var(--border-radius-small);
}

.upload-error-tips strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-error-tips ul {
    margin: 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.upload-error-tips li {
    margin: 0.25rem 0;
}

.file-validation-error {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid var(--danger-color);
    border-radius: var(--border-radius-small);
    padding: 1rem;
    margin: 0.5rem 0;
    color: var(--text-primary);
}

.file-validation-error strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--danger-color);
}

.file-validation-error ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.file-validation-error li {
    margin: 0.25rem 0;
    color: var(--text-secondary);
}

.file-validation-error button {
    margin-top: 0.5rem;
}

.file-validation-info {
    background: rgba(39, 174, 96, 0.1);
    border: 1px solid var(--success-color);
    border-radius: var(--border-radius-small);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    color: var(--success-color);
    font-size: 0.9rem;
}

.upload-size-warning {
    background: rgba(243, 156, 18, 0.1);
    border: 1px solid var(--warning-color);
    border-radius: var(--border-radius-small);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    color: var(--warning-color);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.upload-size-warning::before {
    content: 'ÃƒÆ’Ã‚Â¢Ãƒâ€¦Ã‚Â¡Ãƒâ€šÃ‚Â ÃƒÆ’Ã‚Â¯Ãƒâ€šÃ‚Â¸Ãƒâ€šÃ‚Â';
    font-size: 1.2rem;
}

/* =============================================================================
    FILE DOWNLOAD STATISTICS STYLES
    ============================================================================= */

.file-download-stats {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
    padding: 0.2rem 0.5rem;
    background: var(--file-item-bg);
    border-radius: 12px;
    display: inline-block;
}

.file-download-stats:hover {
    background: var(--primary-color);
    color: white;
}

.secure-download-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--success-color);
    margin-left: 0.5rem;
}

.secure-download-indicator::before {
    content: 'ÃƒÆ’Ã‚Â°Ãƒâ€¦Ã‚Â¸ÃƒÂ¢Ã¢â€šÂ¬Ã‚ÂÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢';
}

.text-file-download {
    padding: 1rem;
    background: var(--file-item-bg);
    border-radius: var(--border-radius-small);
    text-align: center;
}

.text-file-download .btn {
    margin-bottom: 0.5rem;
}

/* =============================================================================
    LAZY MEDIA LOADING STYLES
    ============================================================================= */

.video-placeholder {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed);
    position: relative;
    overflow: hidden;
}

.video-placeholder::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.video-placeholder:hover::before {
    left: 100%;
}

.video-placeholder:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.3);
}

.video-placeholder h4 {
    color: white;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.video-placeholder p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 1rem;
}

.audio-placeholder {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed);
    position: relative;
    overflow: hidden;
}

.audio-placeholder::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.audio-placeholder:hover::before {
    left: 100%;
}

.audio-placeholder:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(155, 89, 182, 0.3);
}

.audio-placeholder h4 {
    color: white;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.audio-placeholder p {
    color: rgba(255, 255, 255, 0.9);
}

.video-viewer video,
.audio-viewer audio {
    border-radius: var(--border-radius-small);
    background: #000;
}

.video-placeholder.loading,
.audio-placeholder.loading {
    animation: pulse 1.5s ease-in-out infinite;
    pointer-events: none;
}

/* Search Match Highlighting - Dual Gradient Blend */
.hierarchy-item.search-matched {
    animation: searchPulse 0.5s ease-out;
}

/* Grandparent: Dark Blue Ã¢â€ â€™ Yellow (preserving horizontal variation) */
.hierarchy-item.grandparent-item.search-matched > .hierarchy-header {
    background: 
        /* Vertical gradient: transparent bottom Ã¢â€ â€™ yellow top */
        linear-gradient(to top, 
            rgba(44, 62, 80, 0) 0%,           /* Transparent at bottom */
            rgba(255, 152, 0, 0.3) 40%,       /* Start yellow tint */
            rgba(255, 193, 7, 0.7) 70%,       /* Strong yellow */
            rgba(255, 193, 7, 0.95) 100%      /* Almost solid yellow top */
        ),
        /* Original horizontal gradient (preserved underneath) */
        linear-gradient(90deg, #2c3e50 0%, #5e789d 50%, #2c3e50 100%) !important;
}

/* Parent: Blue Ã¢â€ â€™ Yellow (preserving horizontal variation) */
.hierarchy-item.parent-item.search-matched > .hierarchy-header {
    background: 
        /* Vertical gradient: transparent bottom Ã¢â€ â€™ yellow top */
        linear-gradient(to top, 
            rgba(27, 133, 203, 0) 0%,         /* Transparent at bottom */
            rgba(255, 152, 0, 0.3) 40%,       /* Start yellow tint */
            rgba(255, 193, 7, 0.7) 70%,       /* Strong yellow */
            rgba(255, 193, 7, 0.95) 100%      /* Almost solid yellow top */
        ),
        /* Original horizontal gradient (preserved underneath) */
        linear-gradient(90deg, #1b85cb 0%, #40b2ff 50%, #178ddc 100%) !important;
}

/* Child: Green Ã¢â€ â€™ Yellow (preserving horizontal variation) */
.hierarchy-item.child-item.search-matched > .hierarchy-header {
    background: 
        /* Vertical gradient: transparent bottom Ã¢â€ â€™ yellow top */
        linear-gradient(to top, 
            rgba(31, 160, 85, 0) 0%,          /* Transparent at bottom */
            rgba(255, 152, 0, 0.3) 40%,       /* Start yellow tint */
            rgba(255, 193, 7, 0.7) 70%,       /* Strong yellow */
            rgba(255, 193, 7, 0.95) 100%      /* Almost solid yellow top */
        ),
        /* Original horizontal gradient (preserved underneath) */
        linear-gradient(90deg, #1fa055 0%, #49be7b 50%, #1b9e53 100%) !important;
}

/* Grandchild: Orange Ã¢â€ â€™ Yellow (preserving horizontal variation) */
.hierarchy-item.grandchild-item.search-matched > .hierarchy-header {
    background: 
        /* Vertical gradient: transparent bottom Ã¢â€ â€™ yellow top */
        linear-gradient(to top, 
            rgba(243, 156, 18, 0) 0%,         /* Transparent at bottom */
            rgba(255, 180, 61, 0.4) 50%,      /* Mid orange-yellow */
            rgba(255, 193, 7, 0.8) 100%       /* Solid yellow top */
        ),
        /* Original horizontal gradient (preserved underneath) */
        linear-gradient(90deg, #f39c12 0%, #ffb43d 50%, #f39c12 100%) !important;
}

/* Outline button variant */
.btn-outline-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-outline-secondary:hover {
    background: var(--file-item-bg);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
}

/* =============================================================================
    SEARCH & FILTER SYSTEM (Bootstrap-like Grid)
    ============================================================================= */

.search-container {
    background: var(--body-bg);
    padding: 1rem;
    border-radius: var(--border-radius-large);
}

/* Row system (like Bootstrap) */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -0.5rem;
    margin-right: -0.5rem;
}

.row.g-3 > * {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    margin-bottom: 1rem;
}

.row.align-items-end {
    align-items: flex-end;
}

/* Column system (responsive) */
.col-md-1 { flex: 0 0 8.333%; max-width: 8.333%; }
.col-md-2 { flex: 0 0 16.666%; max-width: 16.666%; }
.col-md-3 { flex: 0 0 25%; max-width: 25%; }
.col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-md-6 { flex: 0 0 50%; max-width: 50%; }
.col-md-12 { flex: 0 0 100%; max-width: 100%; }

/* Form styling */
.form-label {
    display: block;
    margin-bottom: 0.375rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-label.small {
    font-size: 0.8rem;
}

.form-label.fw-bold,
.form-label.small.fw-bold {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control,
.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--border-radius-small);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Search stats styling */
#searchStats {
    margin-top: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--file-item-bg);
    border-radius: var(--border-radius-small);
    border-left: 3px solid var(--success-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Button adjustments in search context */
.search-container .btn {
    white-space: nowrap;
}

.search-container .btn.w-100 {
    width: 100%;
}

/* Mobile responsive (< 768px) */
@media (max-width: 767px) {
    .col-md-1,
    .col-md-2,
    .col-md-3,
    .col-md-4,
    .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .row.g-3 > * {
        margin-bottom: 0.75rem;
    }
    
    .search-container {
        padding: 0.75rem;
    }
    
    .form-label {
        margin-bottom: 0.25rem;
    }
    
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .col-md-3 { flex: 0 0 50%; max-width: 50%; }
    .col-md-4 { flex: 0 0 50%; max-width: 50%; }
}

/* =============================================================================
    ENHANCED MARKDOWN FEATURES
    ============================================================================= */

.markdown-ordered-list {
    padding-left: 2rem;
    list-style-type: decimal;
    color: var(--text-primary);
}

.markdown-ordered-list li {
    margin: 0.5rem 0;
    padding-left: 0.5rem;
    line-height: var(--line-height-tight);
    color: var(--text-primary);
}

.markdown-ordered-list li::marker {
    color: var(--primary-color);
    font-weight: bold;
}

.markdown-ordered-list .markdown-ordered-list {
    margin: 0.25rem 0;
    padding-left: 1.5rem;
}

.markdown-ordered-list .markdown-ordered-list li {
    margin: 0.25rem 0;
    font-size: 0.95em;
}

.markdown-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius-small);
    margin: 1rem 0;
    display: block;
    box-shadow: var(--shadow-light);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    animation: imageLoad 0.3s ease-out;
}

.markdown-image:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-medium);
}

.entry-markdown div:has(.markdown-image) {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
}

del {
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.7;
}

.markdown-highlight,
mark.markdown-highlight {
    background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
    color: #374151;
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
    font-weight: 500;
}

sub, sup {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

sub {
    bottom: -0.25em;
}

sup {
    top: -0.5em;
}

.markdown-footnotes {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-light);
}

.markdown-footnotes h4 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.markdown-footnotes ol {
    margin: 0;
    padding-left: 2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.markdown-footnotes li {
    margin: 0.5rem 0;
    line-height: 1.5;
}

.footnote-ref {
    font-size: 0.8em;
}

.footnote-ref a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    padding: 0 0.2rem;
}

.footnote-ref a:hover {
    text-decoration: underline;
}

.footnote-backref {
    color: var(--primary-color);
    text-decoration: none;
    margin-left: 0.5rem;
    font-size: 0.9em;
}

.footnote-backref:hover {
    text-decoration: underline;
}

.footnotes-separator {
    border: none;
    border-top: 2px solid var(--border-light);
    margin: 2rem 0 1rem 0;
}

.task-list-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin: 0.5rem 0;
    padding: 0.5rem;
    border-radius: var(--border-radius-small);
    transition: background-color var(--transition-speed);
}

.task-list-item:hover {
    background: var(--file-item-bg);
}

.task-checkbox {
    margin-top: 0.25rem;
    width: 18px;
    height: 18px;
    cursor: default;
    flex-shrink: 0;
    accent-color: var(--success-color);
}

.task-text {
    flex: 1;
    line-height: var(--line-height-tight);
    color: var(--text-primary);
}

.task-list-item:has(.task-checkbox:checked) .task-text {
    text-decoration: line-through;
    color: var(--text-muted);
    opacity: 0.7;
}

.definition-term {
    font-weight: bold;
    color: var(--text-primary);
    margin: 1rem 0 0.25rem 0;
    font-size: 1.05em;
}

dt.definition-term:first-of-type {
    margin-top: 0;
}

.definition-description {
    margin: 0.25rem 0 1rem 2rem;
    padding-left: 1rem;
    border-left: 3px solid var(--border-light);
    color: var(--text-secondary);
    line-height: var(--line-height-tight);
}

dd.definition-description:last-of-type {
    margin-bottom: 0;
}

.entry-markdown a[href^="http"]::after {
    content: " ÃƒÆ’Ã‚Â¢ÃƒÂ¢Ã¢â€šÂ¬Ã‚Â ÃƒÂ¢Ã¢â€šÂ¬Ã¢â‚¬Â";
    font-size: 0.8em;
    opacity: 0.6;
}

.entry-markdown a[href^="#"]::after {
    content: "";
}

.entry-markdown img.emoji {
    display: inline;
    height: 1.2em;
    width: 1.2em;
    margin: 0 0.1em;
    vertical-align: -0.2em;
}

.entry-markdown p {
    color: var(--text-primary); /* ADDED */
    margin: 0.3rem 0;
}

/* =============================================================================
    COMPACT VIEW ADJUSTMENTS
    ============================================================================= */

.project-navigation.compact-view .hierarchy-header {
    gap: 0.5rem;
}

.project-navigation.compact-view .hierarchy-actions {
    gap: 0.15rem;
}

.project-navigation.compact-view .btn-small {
    padding: var(--compact-button-small-padding);
    font-size: 0.7rem;
}

.project-navigation.compact-view .hierarchy-content {
    box-shadow: var(--shadow-light);
}

.project-navigation.compact-view .entry-markdown {
    font-size: 0.8rem;
    line-height: 1.3;
}

.project-navigation.compact-view .entry-markdown h1 { font-size: 1.1rem; }
.project-navigation.compact-view .entry-markdown h2 { font-size: 1.05rem; }
.project-navigation.compact-view .entry-markdown h3 { font-size: 1rem; }
.project-navigation.compact-view .entry-markdown h4 { font-size: 0.95rem; }

.project-navigation.compact-view .markdown-blockquote {
    padding: 0.75rem 1rem;
    margin: 1rem 0;
}

.project-navigation.compact-view .markdown-blockquote::before {
    font-size: 2rem;
    top: -8px;
}

.project-navigation.compact-view .blockquote-header {
    font-size: 0.95em !important;
    margin: 0.5rem 0 0.3rem 0 !important;
}

.project-navigation.compact-view .blockquote-text {
    font-size: 0.85rem;
    margin: 0.3rem 0;
}

.project-navigation.compact-view .blockquote-list {
    font-size: 0.85rem;
    margin: 0.5rem 0;
}

.project-navigation.compact-view .markdown-empty-line {
    height: 0.4rem;
}

.project-navigation.compact-view .markdown-ordered-list {
    font-size: 0.85rem;
    padding-left: 1.5rem;
}

.project-navigation.compact-view .task-list-item {
    padding: 0.3rem;
    font-size: 0.85rem;
}

.project-navigation.compact-view .markdown-image {
    margin: 0.5rem 0;
}

.project-navigation.compact-view .markdown-footnotes {
    font-size: 0.8rem;
    margin-top: 2rem;
}

/* =============================================================================
    CUSTOM ANIMATIONS
    ============================================================================= */

@keyframes slideInFromTop {
    0% {
        transform: translateY(-10px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes imageLoad {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes targetHighlight {
    0% {
        background: transparent;
    }
    15% {
        background: rgba(52, 152, 219, 0.2);
    }
    85% {
        background: rgba(52, 152, 219, 0.2);
    }
    100% {
        background: transparent;
    }
}

@keyframes tocHighlight {
    0% {
        background: linear-gradient(90deg, var(--primary-color), transparent);
        transform: scale(1.02);
    }
    100% {
        background: transparent;
        transform: scale(1);
    }
}

@keyframes textGlow {
    0% { text-shadow: none; }
    15% { text-shadow: 0 0 3px rgba(52, 152, 219, 0.5); }
    50% { 
        text-shadow: 
            0 0 5px rgba(52, 152, 219, 0.8),
            0 0 10px rgba(52, 152, 219, 0.6),
            0 0 15px rgba(52, 152, 219, 0.4);
    }
    85% { text-shadow: 0 0 3px rgba(52, 152, 219, 0.5); }
    100% { text-shadow: none; }
}

.toc-highlight {
    background: linear-gradient(90deg, var(--primary-color), transparent);
    animation: tocHighlight 2s ease-out;
}

.toc-glow a {
    animation: textGlow 1.2s ease-out;
}

/* =============================================================================
    RESPONSIVE DESIGN
    ============================================================================= */

@media (max-width: 768px) {
    :root {
        --hierarchy-border-width: 6px;
        --hierarchy-inner-radius: 12px;
        --content-padding: 0.75rem;
        --font-size-small: 0.8rem;
        --font-size-tiny: 0.75rem;
        --compact-hierarchy-border-width: 4px;
        --compact-hierarchy-inner-radius: 12px;
        --compact-content-padding: 0.5rem;
        --compact-hierarchy-header-padding: 0.4rem;
    }
    
    .container {
        padding: 10px;
    }
    
    .logout-btn,
    .theme-toggle {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        display: block;
        text-align: center;
        margin: 1rem auto;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .project-controls {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .hierarchy-meta {
        font-size: var(--font-size-tiny);
    }
    
    .back-to-toc {
        display: none;
    }
    
    .markdown-table {
        font-size: 0.8rem;
    }
    
    .markdown-table th,
    .markdown-table td {
        padding: 0.5rem;
    }
    
    .markdown-blockquote {
        padding: 1rem;
        margin: 1rem 0;
    }
    
    .markdown-blockquote::before {
        font-size: 2rem;
        top: -5px;
        left: 8px;
    }
    
    .blockquote-list {
        padding-left: 1.25rem;
    }
    
    .markdown-empty-line {
        height: 0.5rem;
    }
    
    .upload-progress-container {
        padding: 1rem;
    }
    
    .upload-progress-bar {
        height: 25px;
    }
    
    .upload-progress-text {
        font-size: 0.8rem;
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .upload-error-tips ul {
        font-size: 0.85rem;
    }
    
    .video-placeholder {
        padding: 2rem 1rem;
    }
    
    .video-placeholder h4 {
        font-size: 1rem;
    }
    
    .audio-placeholder {
        padding: 1.5rem 1rem;
    }
    
    .audio-placeholder h4 {
        font-size: 0.95rem;
    }
    
    .back-to-top:hover {
        padding: 0.2rem 0.4rem;
        margin: -0.2rem -0.4rem;
    }
}

@media (max-width: 640px) {
    .hierarchy-header {
        flex-wrap: wrap;
    }

    .hierarchy-title {
        order: 1;
        flex-basis: 100%;
    }

    .hierarchy-meta {
        order: 2;
        flex-basis: 100%;
    }

    .hierarchy-toggle,
    .collab-indicator {
        order: 3;
    }

    .hierarchy-actions {
        order: 3;
        margin-left: auto;
    }
}

@media (max-width: 480px) {
    :root {
        --hierarchy-border-width: 4px;
        --hierarchy-inner-radius: 12px;
        --content-padding: 0.6rem;
        --font-size-small: 0.75rem;
        --compact-hierarchy-border-width: 3px;
        --compact-hierarchy-inner-radius: 12px;
        --compact-content-padding: 0.4rem;
        --compact-hierarchy-header-padding: 0.3rem;
    }
    
    .hierarchy-header {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .file-input {
        padding: 1rem;
    }
    
    .code-header {
        padding: 0.5rem;
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .entry-markdown {
        font-size: 0.8rem;
    }
    
    .back-to-top a {
        padding: 0.5rem 0.6rem;
        font-size: var(--font-size-tiny);
    }
    
    .markdown-blockquote {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .markdown-blockquote::before {
        font-size: 1.5rem;
        top: -2px;
        left: 5px;
    }
    
    .blockquote-header {
        font-size: 0.95em !important;
    }
    
    .blockquote-list {
        font-size: 0.9rem;
        padding-left: 1rem;
    }
}

/* =============================================================================
    ACCESSIBILITY ENHANCEMENTS
    ============================================================================= */

.hierarchy-header:focus,
.btn:focus,
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.back-to-top a:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.task-checkbox:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.footnote-ref a:focus,
.footnote-backref:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

@media (prefers-contrast: high) {
    .hierarchy-content::before {
        border: 2px solid currentColor;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .code-container,
    .file-item {
        border: 2px solid var(--border-dark);
    }
    
    .back-to-top a {
        border: 2px solid currentColor;
    }
    
    .markdown-blockquote {
        border-left-width: 6px;
        border-left-color: #000;
    }
    
    body.dark-theme .markdown-blockquote {
        border-left-color: #fff;
    }
    
    .blockquote-text,
    .blockquote-list li {
        color: var(--text-primary);
    }
    
    .markdown-highlight {
        background: #ffff00;
        color: #000;
        border: 1px solid #000;
    }
    
    .task-list-item {
        border: 1px solid currentColor;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .hierarchy-toggle {
        transition: none;
    }
    
    .back-to-top,
    .back-to-top::before,
    .back-to-top::after {
        animation: none !important;
        transition: none !important;
    }
    
    .back-to-top:hover {
        transform: none !important;
    }
    
    .markdown-blockquote {
        transition: none;
    }
}

/* =============================================================================
    DARK THEME ADJUSTMENTS
    ============================================================================= */

body.dark-theme .markdown-blockquote {
    border-left-color: #3498db;
    background: rgba(52, 152, 219, 0.08);
}

body.dark-theme .markdown-blockquote::before {
    color: #5dade2;
    opacity: 0.15;
}

body.dark-theme .markdown-blockquote code {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-theme .markdown-blockquote .markdown-blockquote {
    background: rgba(255, 255, 255, 0.03);
}

body.dark-theme .markdown-ordered-list li::marker {
    color: #5dade2;
}

body.dark-theme .markdown-highlight,
body.dark-theme mark.markdown-highlight {
    background: linear-gradient(120deg, #854d0e 0%, #a16207 100%);
    color: #fef3c7;
}

body.dark-theme .definition-description {
    border-left-color: #4a5568;
}

body.dark-theme .task-list-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-theme .markdown-table code {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-theme .upload-progress-container {
    border-color: var(--primary-color);
}

body.dark-theme .upload-progress-fill {
    background: linear-gradient(90deg, #2471a3, #1e8449);
}

body.dark-theme .upload-error-message {
    background: rgba(231, 76, 60, 0.2);
}

body.dark-theme .file-validation-error {
    background: rgba(231, 76, 60, 0.15);
}

body.dark-theme .file-validation-info {
    background: rgba(39, 174, 96, 0.15);
}

body.dark-theme .video-placeholder {
    background: linear-gradient(135deg, #2471a3 0%, #1a5276 100%);
}

body.dark-theme .audio-placeholder {
    background: linear-gradient(135deg, #7d3c98 0%, #633974 100%);
}

/* =============================================================================
    PERFORMANCE OPTIMIZATIONS
    ============================================================================= */

html {
    scroll-behavior: smooth;
}

/* GPU Acceleration for Smooth Animations */
.hierarchy-toggle,
.btn,
.copy-btn,
.hierarchy-content,
.theme-toggle {
    will-change: transform;
}

/* =============================================================================
    LEGACY BROWSER SUPPORT
    ============================================================================= */

.hierarchy-content {
    background: #f8f9fa;
}

.hierarchy-content::before {
    background: #2c3e50;
    background: var(--secondary-color);
}

@supports not (display: grid) {
    .form-row {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .form-row > * {
        flex: 1;
        min-width: 200px;
    }
}