/* --- CSS Custom Properties & Design Tokens --- */
:root {
    /* Obsidian Dark Theme */
    --bg-primary: #07070a;
    --bg-secondary: #0f0f15;
    --bg-secondary-elevated: #151520;
    --bg-tertiary: #1e1e2d;
    --bg-glass: rgba(15, 15, 21, 0.7);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-color-focus: rgba(124, 58, 237, 0.4);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    
    --accent: #7c3aed; /* Indigo Violet */
    --accent-light: #9f67ff;
    --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
    --accent-gradient-hover: linear-gradient(135deg, #904eff 0%, #ec4899 100%);
    --accent-glow: rgba(124, 58, 237, 0.3);
    
    --success: #10b981;
    --danger: #f43f5e;
    --warning: #f59e0b;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 15px rgba(124, 58, 237, 0.25);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;
    
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Fira Code', monospace;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

[data-theme="light"] {
    /* Crystal Light Theme */
    --bg-primary: #f3f4f6;
    --bg-secondary: #ffffff;
    --bg-secondary-elevated: #f9fafb;
    --bg-tertiary: #e5e7eb;
    --bg-glass: rgba(255, 255, 255, 0.8);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-color-focus: rgba(99, 102, 241, 0.5);
    
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-tertiary: #9ca3af;
    
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    --accent-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #db2777 100%);
    --accent-glow: rgba(99, 102, 241, 0.2);
    
    --success: #059669;
    --danger: #e11d48;
    --warning: #d97706;
    
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 12px rgba(99, 102, 241, 0.15);
}

/* --- Resets & Setup --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    user-select: none;
    position: relative;
}

/* Safe areas support for modern phones */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* --- Scrollbars --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* --- Layout Grid System --- */
.app-layout {
    display: flex;
    width: 100vw;
    height: 100dvh;
    position: relative;
    overflow: hidden;
}

/* --- Left Navigation Sidebar (Desktop Only) --- */
.sidebar-nav {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
    z-index: 10;
    transition: var(--transition-smooth);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.brand-logo {
    font-size: 24px;
    filter: drop-shadow(0 0 6px var(--accent));
    animation: pulseGlow 3s infinite ease-in-out;
}

.brand-name {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-smooth);
}

.nav-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: var(--shadow-glow);
}

.nav-icon {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.nav-footer-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: transparent;
    border: none;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.nav-footer-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-footer-btn .icon {
    width: 20px;
    height: 20px;
}

/* Theme Icons Visibility */
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }


/* --- Middle Notes List Panel --- */
.notes-panel {
    width: 350px;
    background-color: var(--bg-secondary-elevated);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 8;
    transition: var(--transition-smooth);
}

.panel-header {
    padding: 24px 20px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.search-sort-bar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    position: relative;
    transition: var(--transition-smooth);
}

.search-wrapper:focus-within {
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.search-icon {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    margin-right: 8px;
    flex-shrink: 0;
}

.search-wrapper input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    width: 100%;
}

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

.clear-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
}

.icon-sm {
    width: 16px;
    height: 16px;
}

.icon-xs {
    width: 12px;
    height: 12px;
}

/* Active tag filter */
.active-tag-filter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-tertiary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    border-left: 3px solid var(--accent);
}

.remove-tag-btn {
    background: transparent;
    border: none;
    color: var(--danger);
    font-weight: bold;
    cursor: pointer;
}

/* Notes Cards Container */
.notes-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Note Card Styling */
.note-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    position: relative;
    user-select: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition-spring);
}

.note-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow-sm);
}

.note-card.active {
    background-color: var(--bg-tertiary);
    border-color: var(--accent);
    box-shadow: var(--shadow-sm), 0 0 10px rgba(124, 58, 237, 0.1);
}

/* Highlight border on card left for pinned notes */
.note-card.pinned::before {
    content: '';
    position: absolute;
    top: 12px;
    bottom: 12px;
    left: 0;
    width: 3px;
    background-color: var(--warning);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.note-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.note-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.note-card-icons {
    display: flex;
    gap: 4px;
    align-items: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.card-icon {
    width: 14px;
    height: 14px;
}

.card-icon.star {
    color: var(--warning);
    fill: var(--warning);
}

.note-card-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.note-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.note-card-tags {
    display: flex;
    gap: 4px;
    overflow: hidden;
}

.tag-badge {
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 700;
    color: #ffffff;
    max-width: 60px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* --- Right Main Editor Pane --- */
.editor-pane {
    flex-grow: 1;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    transition: var(--transition-smooth);
}

/* Empty State */
.editor-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px;
    background-color: var(--bg-primary);
    z-index: 5;
    animation: fadeIn 0.4s ease-out;
}

.empty-illustration {
    margin-bottom: 24px;
    color: var(--accent);
    filter: drop-shadow(0 0 10px rgba(124, 58, 237, 0.15));
}

.illustration-svg {
    width: 96px;
    height: 96px;
    stroke-width: 1;
}

.editor-empty-state h3 {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 8px;
}

.editor-empty-state p {
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 320px;
    margin-bottom: 24px;
}

/* Active Mode Container */
.editor-active-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.editor-header {
    height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-secondary);
}

.editor-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.save-status {
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
    transition: var(--transition-smooth);
}

.editor-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toggle mode controls */
.editor-mode-toggle {
    display: flex;
    background-color: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-right: 8px;
}

.toggle-btn {
    background: transparent;
    border: none;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
}

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

.toggle-btn.active {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* Star Note Button */
.star-icon {
    width: 20px;
    height: 20px;
    transition: var(--transition-spring);
}

.star-icon.active {
    color: var(--warning);
    fill: var(--warning);
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.5));
}

/* Metadata tag bar */
.note-meta-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: var(--bg-secondary-elevated);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    white-space: nowrap;
}

.note-tags-container {
    display: flex;
    gap: 6px;
}

.note-tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    cursor: pointer;
}

.remove-note-tag-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 800;
    font-size: 10px;
    cursor: pointer;
}

.add-tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.add-tag-pill:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

/* Formatting toolbar styling */
.format-toolbar {
    display: flex;
    gap: 6px;
    padding: 8px 24px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    white-space: nowrap;
}

.format-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
}

.format-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Workspace Wrapper splits preview and edit */
.workspace-wrapper {
    flex-grow: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Editor Input Area */
.editor-pane-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
    background-color: var(--bg-primary);
}

.note-title-input {
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-sans);
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 16px;
    width: 100%;
}

.note-title-input::placeholder {
    color: var(--text-tertiary);
    opacity: 0.5;
}

.note-content-input {
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    width: 100%;
    flex-grow: 1;
    transition: font-size 0.2s;
}

.note-content-input::placeholder {
    color: var(--text-tertiary);
    opacity: 0.4;
}

/* Custom Font classes */
.font-sans-editor { font-family: var(--font-sans) !important; }
.font-serif-editor { font-family: Georgia, serif !important; }
.font-mono-editor { font-family: var(--font-mono) !important; }

/* Markdown Preview Pane */
.preview-pane-inner {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background-color: var(--bg-primary);
    border-left: 1px solid var(--border-color);
}

.preview-title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.preview-content {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-primary);
}

/* Markdown Render Elements */
.preview-content h1,
.preview-content h2,
.preview-content h3 {
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 800;
}

.preview-content h1 { font-size: 22px; }
.preview-content h2 { font-size: 18px; }
.preview-content h3 { font-size: 16px; }

.preview-content p {
    margin-bottom: 14px;
}

.preview-content strong {
    font-weight: 700;
}

.preview-content em {
    font-style: italic;
}

.preview-content blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.preview-content pre {
    background-color: var(--bg-secondary-elevated);
    border: 1px solid var(--border-color);
    padding: 14px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 16px 0;
    position: relative;
}

.preview-content code {
    font-family: var(--font-mono);
    font-size: 14px;
    background-color: var(--bg-secondary-elevated);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.preview-content pre code {
    background-color: transparent;
    padding: 0;
}

.preview-content ul,
.preview-content ol {
    margin-left: 24px;
    margin-bottom: 14px;
}

.preview-content li {
    margin-bottom: 6px;
}

.preview-content a {
    color: var(--accent-light);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Task checkbox markdown */
.preview-todo-item {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    margin-bottom: 6px;
}

.preview-todo-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.preview-todo-text.checked {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

/* Editor Bottom Info panel */
.editor-footer {
    height: 48px;
    padding: 0 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-tertiary);
    background-color: var(--bg-secondary);
}


/* --- Buttons & UI Elements --- */
.btn-primary {
    background: var(--accent-gradient);
    color: #ffffff;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-spring);
}

.btn-primary:hover {
    background: var(--accent-gradient-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-primary-sm {
    background: var(--accent-gradient);
    color: #ffffff;
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary-sm:hover {
    background: var(--accent-gradient-hover);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

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

.icon-btn.danger:hover {
    color: var(--danger);
    background-color: rgba(244, 63, 94, 0.1);
}

.icon-btn-secondary {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 10px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.icon-btn-secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.icon {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}


/* --- Mobile Bottom Nav Bar --- */
.mobile-tab-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background-color: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    justify-content: space-around;
    align-items: center;
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
}

.tab-btn {
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    gap: 4px;
    flex: 1;
    height: 100%;
    transition: var(--transition-smooth);
}

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

.tab-icon {
    width: 20px;
    height: 20px;
    stroke-width: 2.2;
}

/* FAB on tab bar */
#mobileAddFab {
    position: relative;
    overflow: visible;
}

.fab-circle {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px var(--accent-glow);
    position: absolute;
    top: -16px;
    transition: var(--transition-spring);
}

.fab-circle:active {
    transform: scale(0.9);
}

.fab-icon {
    color: #ffffff;
    width: 22px;
    height: 22px;
}


/* --- Bottom Sheets System --- */
.bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.bottom-sheet.show {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.bottom-sheet-content {
    position: relative;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-top: 1px solid var(--border-color);
    max-height: 80dvh;
    width: 100%;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-sheet.show .bottom-sheet-content {
    transform: translateY(0);
}

.bottom-sheet-drag-handle {
    width: 40px;
    height: 4px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-full);
    margin: 12px auto 6px auto;
}

.bottom-sheet-header {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 800;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.bottom-sheet-body {
    padding: 16px 24px 24px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sheet-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-smooth);
}

.sheet-action-btn:hover {
    background-color: var(--bg-secondary-elevated);
    border-color: var(--accent);
}

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

.sheet-action-btn.danger:hover {
    background-color: rgba(244, 63, 94, 0.08);
    border-color: var(--danger);
}

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

.sheet-action-btn.success:hover {
    background-color: rgba(16, 185, 129, 0.08);
    border-color: var(--success);
}


/* --- Settings UI Components --- */
.settings-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px;
    overflow-y: auto;
    height: 100%;
}

.settings-section {
    background-color: var(--bg-secondary-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-section h3 {
    font-size: 15px;
    font-weight: 800;
    color: var(--accent-light);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-title {
    font-size: 14px;
    font-weight: 700;
}

.setting-desc {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Theme Toggle Button custom layout */
.setting-theme-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

/* Typography settings controls */
.setting-select {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.font-size-slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.font-size-slider-row input[type="range"] {
    flex-grow: 1;
    accent-color: var(--accent);
    cursor: pointer;
}

.font-size-val {
    font-size: 13px;
    font-weight: bold;
    width: 32px;
    text-align: right;
}

/* Import/Export buttons */
.backup-actions {
    display: flex;
    gap: 10px;
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

.btn-secondary:hover {
    border-color: var(--text-secondary);
}

/* Stats list styling */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card {
    background-color: var(--bg-tertiary);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    text-align: center;
}

.stat-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--accent-light);
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* About Section */
.about-box {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 12px;
    padding: 16px;
}


/* --- Tags Screen Component --- */
.tags-screen-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
    overflow-y: auto;
    height: 100%;
}

.tags-list-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag-editor-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition-spring);
}

.tag-editor-badge:hover {
    transform: scale(1.05);
}

.tag-delete-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-weight: bold;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border-radius: var(--radius-full);
}

.tag-delete-btn:hover {
    background-color: rgba(0, 0, 0, 0.15);
}

.tag-selector-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tag-select-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.tag-select-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tag-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
}

.tag-checkmark {
    color: var(--accent-light);
    display: none;
}

.tag-select-item.selected .tag-checkmark {
    display: block;
}

/* Empty tags indicator */
.empty-tags-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px;
    font-size: 14px;
}


/* --- CSS Animations --- */
@keyframes pulseGlow {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 6px rgba(124, 58, 237, 0.3));
    }
    50% {
        transform: scale(1.06);
        filter: drop-shadow(0 0 16px rgba(124, 58, 237, 0.6));
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}


/* --- Split Screen (Desktop Only) --- */
@media (min-width: 901px) {
    /* If in split screen mode */
    .app-layout.split-view .editor-pane-inner {
        flex: 1;
    }
    .app-layout.split-view .preview-pane-inner {
        display: block !important;
        flex: 1;
    }
}


/* --- Responsive & Mobile Layout Logic --- */
@media (max-width: 900px) {
    /* Disable left navigation menu & replace with bottom tabs */
    .sidebar-nav {
        display: none;
    }
    
    /* On mobile, tab switches changes panel content */
    .notes-panel {
        width: 100vw;
        height: calc(100dvh - 64px);
    }
    
    .mobile-tab-bar {
        display: flex;
    }
    
    /* Editor acts as full screen slide-in modal on mobile */
    .editor-pane {
        position: fixed;
        inset: 0;
        z-index: 100;
        width: 100vw;
        height: 100dvh;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
    }
    
    /* Trigger editor slide-in when body has note-open class */
    body.note-open .editor-pane {
        transform: translateX(0);
    }
    
    .note-title-input {
        font-size: 24px;
    }
    
    /* Hide split toggle button on mobile */
    .desktop-only {
        display: none !important;
    }
    
    .panel-header {
        padding: 16px 16px 12px 16px;
    }
    
    .notes-list {
        padding: 8px;
    }
    
    .editor-header {
        padding: 0 16px;
    }
    
    .workspace-wrapper {
        flex-direction: column;
    }
    
    .preview-pane-inner {
        border-left: none;
    }
}

/* --- PWA Installation Styling --- */
.ios-install-guide {
    background-color: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ios-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.ios-step-num {
    background-color: var(--accent);
    color: #ffffff;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
}

.ios-icon-helper {
    background-color: var(--bg-secondary-elevated);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.ios-icon-helper svg {
    width: 16px;
    height: 16px;
    color: var(--accent-light);
}