/* ============================================================
   NoteCTL v2 — Main Stylesheet
   Light mode default | Dark mode via [data-theme="dark"]
   ============================================================ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
    --color-primary:        #4B3DDB;
    --color-primary-hover:  #3B2ECC;
    --color-accent:         #7C6BFF;
    --color-light:          #E9EBFF;

    --color-bg:             #F7F7FF;
    --color-surface:        #FFFFFF;
    --color-surface-2:      #F0F0FA;
    --color-sidebar:        #FFFFFF;
    --color-sidebar-active: #E9EBFF;

    --color-text:           #1E1E2F;
    --color-text-muted:     #6B6B8A;
    --color-text-inverse:   #FFFFFF;

    --color-border:         #E2E2F0;
    --color-border-strong:  #C8C8E8;

    --color-success:        #22c55e;
    --color-error:          #ef4444;
    --color-warning:        #f59e0b;

    --color-danger:         #ef4444;
    --color-danger-hover:   #dc2626;

    --shadow-sm:   0 1px 3px rgba(75, 61, 219, 0.08);
    --shadow-md:   0 4px 12px rgba(75, 61, 219, 0.12);
    --shadow-lg:   0 8px 32px rgba(75, 61, 219, 0.16);

    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   16px;

    --font-sans:   'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono:   'Cascadia Code', 'Fira Code', monospace;

    --sidebar-w:   240px;
    --panel-w:     220px;
    --header-h:    56px;
    --transition:  0.18s ease;
}

[data-theme="dark"] {
    --color-bg:             #1E1E2F;
    --color-surface:        #252538;
    --color-surface-2:      #2D2D46;
    --color-sidebar:        #16162A;
    --color-sidebar-active: #2D2D50;

    --color-text:           #EEEEFF;
    --color-text-muted:     #9898BB;
    --color-text-inverse:   #FFFFFF;

    --color-border:         #2D2D4A;
    --color-border-strong:  #3D3D62;

    --color-primary:        #7C6BFF;
    --color-primary-hover:  #9080FF;
    --color-accent:         #4B3DDB;
    --color-light:          #2D2D50;

    --shadow-sm:   0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md:   0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg:   0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    overflow: hidden;
    height: 100dvh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
input, button, select, textarea { font: inherit; }
img { max-width: 100%; }

/* Theme-aware logo — show light logo by default, dark logo in dark mode */
.logo-dark  { display: none; }
.logo-light { display: block; }
[data-theme="dark"] .logo-dark  { display: block; }
[data-theme="dark"] .logo-light { display: none; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ============================================================
   AUTH PAGES
   ============================================================ */

body.auth-page {
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px 16px;
    background: var(--color-bg);
}

.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-md);
}

.auth-card--centered { text-align: center; }

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.logo-img { height: 40px; width: auto; }
.logo-img--sm { height: 28px; }

.logo-text {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.5px;
}

.logo-text span,
.logo-text b { color: var(--color-primary); }

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.4px;
}

.auth-subtitle {
    color: var(--color-text-muted);
    margin-bottom: 20px;
}

.auth-subtitle.muted { color: var(--color-text-muted); margin-top: 8px; }

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.auth-form { margin-top: 24px; }

/* ── Form ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--color-text);
}

.field-hint {
    font-weight: 400;
    color: var(--color-text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(75, 61, 219, 0.12);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-remember {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    grid-template-columns: unset;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.link-muted {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.link-muted:hover { color: var(--color-primary); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s, box-shadow var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: var(--shadow-sm); text-decoration: none; color: #fff; }

.btn-secondary {
    background: var(--color-surface-2);
    color: var(--color-text);
    border: 1.5px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-light); }

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

.btn-full { width: 100%; }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--color-surface-2); color: var(--color-text); }
.icon-btn svg { width: 18px; height: 18px; }

.icon-btn--danger:hover { background: rgba(239, 68, 68, 0.1); color: var(--color-danger); }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 16px;
    border-left: 3px solid;
}
.alert-success { background: rgba(34, 197, 94, 0.1); border-color: var(--color-success); color: #166534; }
.alert-error   { background: rgba(239, 68, 68, 0.1); border-color: var(--color-error);   color: #991b1b; }

[data-theme="dark"] .alert-success { color: #86efac; }
[data-theme="dark"] .alert-error   { color: #fca5a5; }

/* ── Turnstile ───────────────────────────────────────────── */
.cf-turnstile { margin-bottom: 16px; }

/* ── Theme toggle (auth pages) ───────────────────────────── */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: all var(--transition);
}
.theme-toggle:hover { color: var(--color-primary); box-shadow: var(--shadow-md); }
.theme-toggle svg { width: 18px; height: 18px; }

/* ── Verify page icons ───────────────────────────────────── */
.verify-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    margin: 0 auto 20px;
}
.verify-icon svg { width: 36px; height: 36px; }
.verify-icon--success { background: rgba(34, 197, 94, 0.1); color: var(--color-success); }
.verify-icon--error   { background: rgba(239, 68, 68, 0.1); color: var(--color-error); }

/* ============================================================
   APP LAYOUT — Three-pane desktop / drawer mobile
   ============================================================ */

.app-body {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

/* ── Mobile Header ───────────────────────────────────────── */
.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 8px 0 12px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    z-index: 10;
}

.mobile-header-title {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.3px;
    color: var(--color-text);
    flex: 1;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 4px;
}

/* Pull-to-refresh indicator */
#ptrIndicator {
    display: none;
    position: fixed;
    top: calc(var(--header-h) + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: transform 0.1s ease, opacity 0.1s ease;
    opacity: 0;
}
#ptrIndicator svg { width: 20px; height: 20px; color: var(--color-primary); }
#ptrIndicator.ptr-pulling { display: flex; }
#ptrIndicator.ptr-refreshing {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    animation: ptr-spin 0.7s linear infinite;
}
@keyframes ptr-spin { to { transform: translateX(-50%) translateY(0) rotate(360deg); } }

/* ── Layout container ────────────────────────────────────── */
.app-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: transform var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 10px;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-close { display: none; }

.sidebar-search {
    padding: 0 10px 10px;
    flex-shrink: 0;
}

.search-wrap {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--color-text-muted);
    pointer-events: none;
}

.search-wrap input {
    width: 100%;
    padding: 8px 10px 8px 32px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    color: var(--color-text);
    font-size: 0.875rem;
    outline: none;
    transition: border-color var(--transition);
}

.search-wrap input:focus {
    border-color: var(--color-primary);
    background: var(--color-surface);
}

.sections-nav {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.sections-list { display: flex; flex-direction: column; gap: 2px; }

.section-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    transition: background var(--transition);
    position: relative;
    user-select: none;
}

.section-item:hover { background: var(--color-surface-2); }
.section-item.active { background: var(--color-sidebar-active); color: var(--color-primary); font-weight: 600; }

.section-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.section-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.section-menu-btn {
    opacity: 0;
    transition: opacity var(--transition);
}
.section-item:hover .section-menu-btn { opacity: 1; }

.btn-add-section {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: 1.5px dashed var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    margin-top: 8px;
    transition: all var(--transition);
}
.btn-add-section:hover { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-light); }
.btn-add-section svg { width: 15px; height: 15px; }

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 10px;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

.user-chip {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Subsections Panel ───────────────────────────────────── */
.subsections-panel {
    width: var(--panel-w);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width var(--transition), opacity var(--transition), border-color var(--transition);
}


.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 12px 10px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-border);
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.subsections-list {
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--color-border);
}

.subsection-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text);
    transition: background var(--transition);
    user-select: none;
}
.subsection-item:hover { background: var(--color-surface-2); }
.subsection-item.active { background: var(--color-light); color: var(--color-primary); font-weight: 600; }

.subsection-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.subsection-menu-btn { opacity: 0; transition: opacity var(--transition); }
.subsection-item:hover .subsection-menu-btn { opacity: 1; }

/* ── Note Editor ─────────────────────────────────────────── */
.note-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-surface);
}

.note-editor-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}


.note-title-input {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 700;
    border: none;
    background: transparent;
    color: var(--color-text);
    outline: none;
    letter-spacing: -0.3px;
    min-width: 0;
}

.note-title-input::placeholder { color: var(--color-text-muted); font-weight: 400; }

.note-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.autosave-status {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    min-width: 60px;
    text-align: right;
}

#editorWrap {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* TinyMCE fills the editor area */
.tox-tinymce {
    border: none !important;
    border-radius: 0 !important;
    flex: 1;
}

.tox .tox-editor-header { border-bottom: 1px solid var(--color-border) !important; }

/* ── Attachments Bar ─────────────────────────────────────── */
.attachments-bar {
    border-top: 1px solid var(--color-border);
    padding: 10px 16px;
    background: var(--color-surface-2);
    flex-shrink: 0;
}

.attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 99px;
    font-size: 0.8rem;
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition);
    max-width: 200px;
}
.attachment-chip:hover { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-light); }
.attachment-chip svg { width: 14px; height: 14px; flex-shrink: 0; }
.attachment-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.attachment-remove {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-text-muted);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    border: none;
    flex-shrink: 0;
    transition: background var(--transition);
}
.attachment-remove:hover { background: var(--color-danger); }

/* ── Editor Empty State ──────────────────────────────────── */
.editor-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--color-text-muted);
}
.editor-empty svg { width: 64px; height: 64px; opacity: 0.3; }
.editor-empty p { font-size: 0.9rem; }

/* ── Notes List (within subsection) ─────────────────────── */
.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.note-item {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    user-select: none;
}
.note-item:hover { background: var(--color-surface-2); }
.note-item.active { background: var(--color-light); }

.note-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.note-item.active .note-item-title { color: var(--color-primary); font-weight: 600; }

.note-item-date {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* ── Sidebar Overlay (mobile) ────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

/* ── Context Menu ────────────────────────────────────────── */
.context-menu {
    position: fixed;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 160px;
    overflow: hidden;
    animation: fadeIn 0.1s ease;
}

.context-menu-list { list-style: none; padding: 4px; }

.context-menu-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text);
    transition: background var(--transition);
}
.context-menu-list li:hover { background: var(--color-surface-2); }
.context-menu-list li.danger { color: var(--color-danger); }
.context-menu-list li.danger:hover { background: rgba(239, 68, 68, 0.08); }
.context-menu-list li svg { width: 15px; height: 15px; }
.context-menu-divider { height: 1px; background: var(--color-border); margin: 4px 0; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.15s ease;
}

.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.18s ease;
}

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

.modal-title { font-weight: 700; font-size: 1rem; }

.modal-body { padding: 20px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--color-border);
}

/* ── Search Overlay ──────────────────────────────────────── */
.search-overlay {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    bottom: 0;
    background: var(--color-surface);
    z-index: 200;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.15s ease;
}

.search-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-border);
}

.search-overlay-header h3 { font-weight: 700; }

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

.search-result-item {
    padding: 12px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition);
    border: 1px solid transparent;
    margin-bottom: 6px;
}
.search-result-item:hover { background: var(--color-surface-2); border-color: var(--color-border); }

.search-result-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 2px; }
.search-result-path  { font-size: 0.75rem; color: var(--color-primary); margin-bottom: 6px; }
.search-result-excerpt { font-size: 0.8rem; color: var(--color-text-muted); line-height: 1.5; }

.search-empty { text-align: center; padding: 40px; color: var(--color-text-muted); }

/* ── Color Picker (section) ──────────────────────────────── */
.color-picker-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
}
.color-swatch:hover,
.color-swatch.selected { transform: scale(1.2); border-color: var(--color-text); }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; }              to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Toast notifications ─────────────────────────────────── */
#toastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--color-text);
    color: var(--color-surface);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s ease;
    pointer-events: auto;
    max-width: 300px;
}
.toast.success { background: var(--color-success); }
.toast.error   { background: var(--color-error); }

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */

@media (max-width: 768px) {
    .mobile-header { display: flex; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        width: min(var(--sidebar-w), 80vw);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .sidebar-close { display: flex; }

    .subsections-panel {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 101;
        transform: translateX(-100%);
        width: min(var(--panel-w), 80vw);
        box-shadow: var(--shadow-lg);
    }

    .subsections-panel.open { transform: translateX(0); }

    .note-editor { padding-top: 0; }

    .app-layout { flex-direction: column; }

    .search-overlay {
        left: 0;
        top: var(--header-h);
    }
}

@media (min-width: 769px) {
    .mobile-header { display: none; }
    .sidebar-overlay { display: none !important; }
}

/* ── Tablet adjustments ──────────────────────────────────── */
@media (max-width: 1024px) and (min-width: 769px) {
    :root {
        --sidebar-w: 200px;
        --panel-w: 180px;
    }
}
