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

:root {
    /* Light Mode - Creamy Theme */
    --primary-color: #8b6f47;
    --primary-hover: #6d563a;
    --secondary-color: #9a8472;
    --success-color: #6b8e5a;
    --danger-color: #c85a54;
    --bg-color: #faf7f2;
    --sidebar-bg: #fff9f0;
    --editor-bg: #fffcf7;
    --card-bg: #ffffff;
    --border-color: #e8dcc8;
    --hover-bg: #f5ede0;
    --text-primary: #3d3026;
    --text-secondary: #8b7b6a;
    --shadow: 0 1px 3px rgba(61, 48, 38, 0.08);
    --shadow-lg: 0 10px 15px -3px rgba(61, 48, 38, 0.1);
    --accent-warm: #d4a574;
    
    /* Font Configuration */
    --font-header: 'Fredericka the Great', cursive;
    --font-body: 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-dyslexic: 'OpenDyslexic', 'Comic Sans MS', cursive;
    --font-editor-mono: 'Courier New', 'Consolas', monospace;
    --font-editor-sans: 'Lexend Deca', 'Arial', sans-serif;
    --font-editor-serif: 'Merriweather', 'Georgia', serif;
    --font-editor: var(--font-editor-mono);
}

/* Dark Mode - Dark Chocolate Theme */
body.dark-mode {
    --primary-color: #d4a574;
    --primary-hover: #c49563;
    --secondary-color: #9a8472;
    --success-color: #7fa368;
    --danger-color: #d47570;
    --bg-color: #2b1f17;
    --sidebar-bg: #362820;
    --editor-bg: #3d2e23;
    --card-bg: #453529;
    --border-color: #4d3d2f;
    --hover-bg: #4d3d2f;
    --text-primary: #f5e6d3;
    --text-secondary: #c4b5a3;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --accent-warm: #d4a574;
}

/* Dyslexia Font Mode */
body.dyslexia-font {
    --font-body: var(--font-dyslexic);
}

body.dyslexia-font .form-textarea,
body.dyslexia-font textarea,
body.dyslexia-font input[type="text"],
body.dyslexia-font .tab {
    font-family: var(--font-dyslexic) !important;
}

/* Editor Font Modes */
body.editor-font-mono {
    --font-editor: var(--font-editor-mono);
}

body.editor-font-sans {
    --font-editor: var(--font-editor-sans);
}

body.editor-font-serif {
    --font-editor: var(--font-editor-serif);
}

/* Apply editor font to editable text areas */
.form-textarea,
textarea {
    font-family: var(--font-editor) !important;
}

/* OpenDyslexic Font Face */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/ttf/OpenDyslexic-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/ttf/OpenDyslexic-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--sidebar-bg);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease, padding 0.3s ease;
}

/* Collapsed Header State */
.app-header.collapsed {
    padding: 0.25rem 0.5rem;
}

.app-header.collapsed .header-left,
.app-header.collapsed .header-right,
.app-header.collapsed .accessibility-column {
    display: none;
}

.header-expand-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.app-header.collapsed .header-expand-btn {
    display: flex;
}

.header-expand-btn:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
}

.header-expand-btn .material-symbols-outlined {
    font-size: 1.25rem;
}

.header-left {
    flex: 0 0 auto;
}

.header-right {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-end;
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: var(--font-header);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 100%;
    min-height: 3.5rem;
}

.logo-light, .logo-dark {
    height: 5rem;
    width: auto;
    margin-right: 0.5rem;
    max-height: 100%;
    vertical-align: middle;
}

/* Show light logo in light mode, dark logo in dark mode */
.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

body.dark-mode .logo-light {
    display: none;
}

body.dark-mode .logo-dark {
    display: block;
}

.header-icon {
    font-size: 2.25rem;
}

/* Material Symbols styling */
.material-symbols-outlined {
    font-size: 1.25rem;
    vertical-align: middle;
    line-height: 1;
}

.dropdown-item .material-symbols-outlined {
    font-size: 1.125rem;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.btn-icon .material-symbols-outlined {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.app-nickname {
    font-family: var(--font-body);
    font-size: 0.7em;
    font-weight: 500;
    color: var(--text-secondary);
    font-style: italic;
}

.lorebook-name-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lorebook-name-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.lorebook-name-input {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    width: 200px;
    transition: border-color 0.2s;
    background: var(--card-bg);
    color: var(--text-primary);
}

.lorebook-name-input::placeholder {
    color: var(--text-secondary);
}


.lorebook-name-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Accessibility Column - L shape layout (two on top, two on bottom forming 2x2 grid) */
.accessibility-column {
    display: grid;
    grid-template-columns: repeat(2, 2.6rem);
    grid-auto-rows: 2.6rem;
    column-gap: 0.35rem;
    row-gap: 0.35rem;
    margin-right: 1.25rem;
    padding-top: 0.15rem;
    align-content: start;
}

.accessibility-column #themeToggle { grid-column: 1; grid-row: 1; }
.accessibility-column #fontToggle { grid-column: 2; grid-row: 1; }
.accessibility-column #editorFontToggle { grid-column: 1; grid-row: 2; }
.accessibility-column #headerCollapseToggle { grid-column: 2; grid-row: 2; }

.accessibility-column .btn-icon {
    width: 2.6rem; /* Slightly wider to avoid icon clipping */
    height: 2.6rem;
    min-width: 2.6rem;
    min-height: 2.6rem;
    font-size: 1rem;
    line-height: 1;
}

.accessibility-column .btn-icon .material-symbols-outlined {
    font-size: 1.55rem; /* Ensure full glyph visibility */
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem; /* Override fallback width/height to prevent clipping */
    height: 1.55rem;
    overflow: visible;
}

/* Dyslexia toggle shows opposite font */
.dyslexia-toggle {
    font-family: var(--font-dyslexic);
    font-weight: 700;
    font-size: 1rem;
}

body.dyslexia-font .dyslexia-toggle {
    font-family: 'Noto Sans', sans-serif;
    font-weight: 600;
}

/* Dropdown Menus */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 1000;
    overflow: hidden;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

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

.dropdown-item:active {
    background: var(--border-color);
}

.btn-icon {
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    min-height: 3rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    overflow: visible;
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
}


/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
    background: var(--hover-bg);
}

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

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

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

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

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

.btn-success:hover {
    background-color: var(--success-color);
    filter: brightness(0.9);
}

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

.btn-danger:hover {
    background-color: var(--danger-color);
    filter: brightness(0.9);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.813rem;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Sidebar Controls */
.sidebar-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-color);
    border-radius: 0.375rem;
}

.zoom-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    background: var(--editor-bg);
    border-radius: 0.25rem;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.zoom-level {
    font-size: 0.813rem;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: center;
}

.search-input {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: var(--card-bg);
    color: var(--text-primary);
}

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


.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.entry-count {
    padding: 0.75rem 1.5rem;
    font-size: 0.813rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.entry-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

/* ===== ENTRY ITEMS & ACTIONS ===== */

/* Base entry item styling */
.entry-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative; /* Required for absolute positioning of children */
}

.entry-item:hover {
    background-color: #f1f5f9;
}

.entry-item.active {
    background-color: #e0e7ff;
    border-left: 3px solid var(--primary-color);
}

.entry-item.selected {
    background-color: #fef3c7;
    border-left: 3px solid #f59e0b;
}

.entry-item.selected.active {
    background-color: #fde68a;
}

/* Entry header elements */
.entry-item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.entry-item-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    flex: 1;
}

.entry-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid var(--border-color);
    border-radius: 0.25rem;
    background: var(--bg-color);
    transition: all 0.2s ease;
    position: relative;
}

.entry-checkbox:hover {
    border-color: var(--primary-color);
}

.entry-checkbox:checked {
    background: var(--accent-warm);
    border-color: var(--accent-warm);
}

.entry-checkbox:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

.entry-number-input {
    width: 50px;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.813rem;
    font-weight: 600;
    text-align: center;
    background: #f8fafc;
    color: var(--primary-color);
}

.entry-number-input:hover {
    border-color: var(--primary-color);
    background: white;
}

.entry-number-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

/* Entry keywords and status */
.entry-item-keywords {
    font-size: 0.813rem;
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
}

.keyword-tag {
    background-color: #f1f5f9;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.entry-item-status {
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.status-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

.status-constant {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-disabled {
    background-color: #fee2e2;
    color: #991b1b;
}

/* ===== ENTRY ACTIONS ===== */

/* Base action button styling */
.entry-action-btn {
    flex: 1;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    background: var(--editor-bg);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.entry-action-btn:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.entry-action-delete:hover {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

/* ALL ZOOM LEVELS - Hide by default, show on hover */
.entry-item-actions {
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    pointer-events: none; /* Prevent interaction when hidden */
}

.entry-item:hover .entry-item-actions {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto; /* Enable interaction when visible */
}

/* COMPACT VIEW - Overlay on hover */
.sidebar.zoomed-out .entry-item {
    padding: 0.5rem 1.5rem;
    padding-right: 3rem; /* Space for overlay on hover */
}

.sidebar.zoomed-out .entry-item-keywords,
.sidebar.zoomed-out .entry-item-status {
    display: none;
}

.sidebar.zoomed-out .entry-item-actions {
    position: absolute;
    right: 0.5rem;
    top: 0.25rem;
    background: var(--editor-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.5rem;
    display: flex;
    gap: 0.25rem;
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.sidebar.zoomed-out .entry-item-actions .entry-action-btn {
    padding: 0.25rem 0.375rem;
    font-size: 0.875rem;
}

/* Compact view indicator */
.sidebar.zoomed-out .entry-item-header::after {
    content: "...";
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-weight: bold;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.sidebar.zoomed-out .entry-item:hover .entry-item-header::after {
    opacity: 0;
}

/* NORMAL & DETAILED VIEW - Inline on hover */
.sidebar:not(.zoomed-out) .entry-item-actions {
    position: static; /* Normal flow for other zoom levels */
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    display: flex;
}

.sidebar:not(.zoomed-out) .entry-item-actions .entry-action-btn {
    padding: 0.375rem 0.5rem;
    font-size: 1rem;
}

/* DETAILED VIEW - Content preview */
.sidebar.zoomed-in .entry-item {
    padding: 1.25rem 1.5rem;
}

.sidebar.zoomed-in .entry-item-content-preview {
    font-size: 0.813rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    
    /* Modern line-clamp implementation with fallbacks */
    display: -webkit-box;
    display: -moz-box;
    display: box;
    
    /* Standard line-clamp properties */
    -webkit-line-clamp: 3;
    -moz-line-clamp: 3;
    line-clamp: 3;
    
    /* Box orientation for proper text flow */
    -webkit-box-orient: vertical;
    -moz-box-orient: vertical;
    box-orient: vertical;
    
    /* Fallback properties for older browsers */
    max-height: 4.8em; /* 3 lines × 1.6 line-height */
    overflow: hidden;
    text-overflow: ellipsis;
    
    /* Performance optimizations */
    will-change: contents;
    contain: content;
    
    /* Responsive line-clamp */
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    
    /* Accessibility improvements */
    position: relative;
    
    /* Add gradient fade for better visual indication */
    background: linear-gradient(
        to bottom,
        transparent 90%,
        var(--editor-bg) 100%
    );
    background-clip: text;
    -webkit-background-clip: text;
    
    /* Ensure proper text rendering */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Fallback for browsers that don't support line-clamp */
@supports not (-webkit-line-clamp: 3) {
    .sidebar.zoomed-in .entry-item-content-preview {
        position: relative;
        padding-bottom: 1.2em; /* Space for ellipsis */
    }
    
    .sidebar.zoomed-in .entry-item-content-preview::after {
        content: "...";
        position: absolute;
        bottom: 0;
        right: 0;
        background: var(--editor-bg);
        padding-left: 0.5em;
    }
}

/* Responsive adjustments for different screen sizes */
@media (max-width: 1200px) {
    .sidebar.zoomed-in .entry-item-content-preview {
        -webkit-line-clamp: 2;
        -moz-line-clamp: 2;
        line-clamp: 2;
        max-height: 3.2em; /* 2 lines × 1.6 line-height */
    }
}

@media (max-width: 768px) {
    .sidebar.zoomed-in .entry-item-content-preview {
        -webkit-line-clamp: 4;
        -moz-line-clamp: 4;
        line-clamp: 4;
        max-height: 6.4em; /* 4 lines × 1.6 line-height */
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .sidebar.zoomed-in .entry-item-content-preview {
        text-rendering: geometricPrecision;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .sidebar.zoomed-in .entry-item-content-preview {
        will-change: auto;
    }
}

/* ===== DARK MODE ENHANCEMENTS ===== */

body.dark-mode .entry-item:hover {
    background-color: rgba(0, 0, 0, 0.15); /* Darker than background */
}

body.dark-mode .entry-item.active {
    background-color: rgba(0, 0, 0, 0.2); /* Even darker for active */
}

body.dark-mode .entry-item.selected {
    background-color: rgba(0, 0, 0, 0.12); /* Slightly darker than background */
}

body.dark-mode .entry-item.selected.active {
    background-color: rgba(0, 0, 0, 0.18); /* Combine selected and active */
}

body.dark-mode .search-input,
body.dark-mode .form-input,
body.dark-mode .form-textarea {
    background-color: rgba(0, 0, 0, 0.3); /* Darker input fields */
    border-color: rgba(255, 255, 255, 0.1); /* Slightly visible border */
}

body.dark-mode .search-input:focus,
body.dark-mode .form-input:focus,
body.dark-mode .form-textarea:focus {
    background-color: rgba(0, 0, 0, 0.4); /* Even darker when focused */
    border-color: var(--primary-color);
}

body.dark-mode .entry-item-actions {
    background-color: rgba(0, 0, 0, 0.6); /* Darker overlay */
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .entry-number-input {
    background-color: rgba(0, 0, 0, 0.3);
    color: var(--primary-color);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .entry-number-input:hover,
body.dark-mode .entry-number-input:focus {
    background-color: rgba(0, 0, 0, 0.4);
    border-color: var(--primary-color);
}

/* Dark mode keyword tags */
body.dark-mode .keyword-tag {
    background-color: rgba(0, 0, 0, 0.3);
}

/* Dark mode tab hover */
body.dark-mode .tab:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Dark mode scrollbar */
body.dark-mode ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

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

/* Dark mode modal close hover */
body.dark-mode .modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Dark mode modal body code */
body.dark-mode .modal-body code {
    background: rgba(255, 255, 255, 0.1);
}

/* Editor Area */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--editor-bg);
}

.tabs-container {
    border-bottom: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.view-controls {
    display: flex;
    gap: 0.5rem;
    padding: 0 1rem;
    flex: 0 0 auto;
}

.btn-icon {
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 0.375rem;
    font-size: 1.125rem;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.btn-icon:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
}

.btn-icon span {
    font-size: 0.875rem;
}

.tab-bar {
    display: flex;
    flex: 1 1 0%;
    min-width: 0;
    padding: 0 1rem;
    overflow-x: auto;
}

.tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tab:hover {
    color: var(--text-primary);
    background: #f8fafc;
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-close {
    margin-left: 0.5rem;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-size: 1rem;
    line-height: 1;
}

.tab-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.editor-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.editor-content.editor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
    padding: 2rem;
}

.editor-panel {
    background: var(--editor-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    gap: 1rem;
    text-align: center;
}

.empty-state p {
    font-size: 1.125rem;
    margin: 0;
}

/* Entry Editor Form */
.entry-editor {
    max-width: 900px;
    margin: 0 auto;
}

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

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

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

.form-input,
.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.938rem;
    font-family: inherit;
    transition: border-color 0.2s, background-color 0.3s ease, color 0.3s ease;
    background: var(--editor-bg);
    color: var(--text-primary);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

/* Keywords Row Layout */
.keywords-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.keyword-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.keyword-logic {
    width: 140px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.keyword-field input,
.keyword-logic select {
    width: 100%;
}

@media (max-width: 768px) {
    .keywords-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .keyword-logic {
        width: 100%;
    }
}

.keywords-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    min-height: 50px;
}

.keyword-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background-color: #e0e7ff;
    color: var(--primary-color);
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.keyword-remove {
    cursor: pointer;
    font-weight: bold;
    opacity: 0.7;
}

.keyword-remove:hover {
    opacity: 1;
}

.keyword-input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 120px;
    padding: 0.375rem;
    font-size: 0.875rem;
}

/* Advanced Settings */
.advanced-settings {
    margin-top: 2rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.advanced-settings-header {
    background: var(--bg-color);
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background-color 0.3s ease;
}

.advanced-settings-header:hover {
    background: var(--sidebar-bg);
}

.advanced-settings-title {
    font-weight: 600;
    color: var(--text-primary);
}

.advanced-settings-toggle {
    font-size: 1.25rem;
    transition: transform 0.2s;
}

.advanced-settings-toggle.open {
    transform: rotate(180deg);
}

.advanced-settings-content {
    padding: 1.5rem;
    display: none;
    background: var(--editor-bg);
    transition: background-color 0.3s ease;
}

.advanced-settings-content.open {
    display: block;
}

.advanced-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid var(--border-color);
    border-radius: 0.25rem;
    background: var(--bg-color);
    transition: all 0.2s ease;
    position: relative;
}

.checkbox-group input[type="checkbox"]:hover {
    border-color: var(--primary-color);
}

.checkbox-group input[type="checkbox"]:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-group input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.875rem;
    font-weight: bold;
}

.form-input-number {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.938rem;
}

/* Editor Actions */
.editor-actions {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
}

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

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-content {
    background: var(--editor-bg);
    border-radius: 0.75rem;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transition: background-color 0.3s ease;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: background-color 0.2s;
}

.modal-close:hover {
    background: #f1f5f9;
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-body h1,
.modal-body h2,
.modal-body h3 {
    color: var(--text-primary);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.modal-body h1 {
    font-size: 1.75rem;
}

.modal-body h2 {
    font-size: 1.5rem;
}

.modal-body h3 {
    font-size: 1.25rem;
}

.modal-body ul,
.modal-body ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

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

.modal-body p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.modal-body code {
    background: #f1f5f9;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.modal-body strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* Merge Modal Styles */
.modal-large {
    max-width: 900px;
}

.merge-info {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.merge-info p {
    margin-bottom: 0.5rem;
}

.merge-info p:last-child {
    margin-bottom: 0;
}

.merge-instructions {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.merge-actions-top {
    display: flex;
    gap: 0.5rem;
    padding: 0 1rem;
    flex: 0 0 auto;
    margin-left: auto;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.merge-count {
    margin-left: auto;
    font-weight: 600;
    color: var(--primary-color);
}

.merge-entry-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-color);
}

.merge-entry-item {
    background: var(--editor-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s;
}

.merge-entry-item:last-child {
    margin-bottom: 0;
}

.merge-entry-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.merge-entry-item.selected {
    background: var(--bg-color);
    border-color: var(--primary-color);
}

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

.merge-entry-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

.merge-entry-uid {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.813rem;
    font-weight: 600;
    min-width: 45px;
    text-align: center;
}

.merge-entry-title {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.merge-entry-keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
    padding-left: 2.5rem;
}

.merge-entry-status {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-left: 2.5rem;
}

.merge-actions-bottom {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
/* Search & Replace Modal */
.search-replace-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.search-replace-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
}

.search-replace-options .form-group {
    margin-bottom: 0;
}

.search-replace-options .form-label {
    font-size: 0.875rem;
    margin-bottom: 0.375rem;
}

.search-replace-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-results {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.25rem;
    max-height: 400px;
    overflow-y: auto;
}

.search-results h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.result-item {
    padding: 0.75rem;
    background: var(--editor-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-item:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.result-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-item-location {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-left: 1rem;
    white-space: nowrap;
}

.search-replace-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Material Symbols Outlined - Google Font */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'liga';
  -moz-font-feature-settings: 'liga';
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
}

/* Fallback for Material Symbols */
.material-symbols-outlined:not(:root) {
  overflow: hidden;
  display: inline-block;
  width: 1em;
  height: 1em;
}

/* Documentation Link */
.documentation-link {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 100;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.documentation-link:hover {
    opacity: 1;
}

.documentation-link a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.documentation-link a:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

body.dark-mode .documentation-link a {
    background: var(--accent-warm);
    color: var(--text-primary);
}

body.dark-mode .documentation-link a:hover {
    background: var(--primary-color);
}

/* README Content Styling */
.readme-content {
    padding: 2rem;
    height: 100%;
    overflow-y: auto;
    background: var(--editor-bg);
}

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

.readme-header h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-family: var(--font-header);
}

.readme-header p {
    color: var(--text-secondary);
    font-style: italic;
}

.readme-body {
    line-height: 1.6;
    color: var(--text-primary);
}

.readme-body h1 {
    color: var(--primary-color);
    font-family: var(--font-header);
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
}

.readme-body h2 {
    color: var(--primary-color);
    font-family: var(--font-header);
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

.readme-body h3 {
    color: var(--text-primary);
    margin: 1.25rem 0 0.5rem 0;
}

.readme-body p {
    margin-bottom: 1rem;
}

.readme-body ul, .readme-body ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

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

.readme-body code {
    background: var(--border-color);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.readme-body pre {
    background: var(--border-color);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}

.readme-body pre code {
    background: none;
    padding: 0;
}

.readme-body strong {
    color: var(--primary-color);
    font-weight: 600;
}

.readme-body em {
    font-style: italic;
    color: var(--text-secondary);
}

.readme-body a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.readme-body a:hover {
    border-bottom-color: var(--primary-color);
}

/* Dark mode README adjustments */
body.dark-mode .readme-content {
    background: var(--editor-bg);
}

body.dark-mode .readme-header h2,
body.dark-mode .readme-body h1,
body.dark-mode .readme-body h2 {
    color: var(--accent-warm);
}

body.dark-mode .readme-body strong {
    color: var(--accent-warm);
}

body.dark-mode .readme-body code,
body.dark-mode .readme-body pre {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Error message styling for README */
.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
}

.error-message h3 {
    color: #dc2626;
    margin-bottom: 1rem;
}

.error-message h4 {
    color: var(--primary-color);
    margin: 1.5rem 0 0.5rem 0;
}

.error-message p {
    margin-bottom: 1rem;
}

.error-message strong {
    color: #dc2626;
}

.error-message kbd {
    background: var(--border-color);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    border: 1px solid #d1d5db;
}

body.dark-mode .error-message {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.3);
}

body.dark-mode .error-message h3 {
    color: #f87171;
}

body.dark-mode .error-message strong {
    color: #f87171;
}

body.dark-mode .error-message kbd {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Export Options Modal Styling */
.export-options-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.export-options h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.export-options .checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.export-options .checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.export-options .checkbox-group label {
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
}

.export-options .form-group {
    margin-top: 1rem;
}

.export-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Dark mode adjustments for export modal */
body.dark-mode .export-options h3 {
    color: var(--text-primary);
}

body.dark-mode .export-options .checkbox-group label {
    color: var(--text-primary);
}