/* Zab Notes — Components */

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 8px;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8125rem;
}

.btn-full {
    width: 100%;
}

.btn-icon {
    padding: 6px;
    border-radius: var(--radius-md);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

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

/* Field captions in dialogs use the shared field label (Projects style:
   small, upper-case, muted). A label that wraps its own checkbox or control
   is a sentence, not a caption, and keeps normal case. */
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-group label:has(input, select, textarea) {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: normal;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-error {
    color: var(--color-danger);
    font-size: 0.8125rem;
    margin-top: 4px;
    min-height: 20px;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    transform: translateY(10px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 0 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    font-size: 0.875rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastSlideIn 0.3s ease;
    max-width: 380px;
}

.toast.toast-success {
    border-left: 4px solid var(--color-success);
}

.toast.toast-error {
    border-left: 4px solid var(--color-danger);
}

.toast.toast-warning {
    border-left: 4px solid var(--color-warning);
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    z-index: 500;
    display: none;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-sans);
    transition: background var(--transition-fast);
}

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

.dropdown-item.danger {
    color: var(--color-danger);
}

.dropdown-item:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.dropdown-divider {
    border-top: 1px solid var(--border-color);
    margin: 4px 0;
}

.dropdown-label {
    padding: 6px 16px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Tags ── */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: default;
}

.tag-removable {
    cursor: pointer;
}

.tag-removable:hover {
    opacity: 0.8;
}

/* ── Context Menu (right-click) ── */
.context-menu {
    position: fixed;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    z-index: 1500;
    display: none;
}

.context-menu.active {
    display: block;
}

.context-menu .dropdown-item.has-submenu {
    justify-content: space-between;
    cursor: default;
}

.context-menu .dropdown-item.has-submenu::after {
    content: '\25B6';
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-left: 12px;
    flex-shrink: 0;
}

.context-menu .dropdown-item.has-submenu:hover::after {
    color: var(--text-primary);
}

.context-menu .context-submenu {
    position: fixed;
}

.context-menu .dropdown-item .ctx-check {
    width: 16px;
    flex-shrink: 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--color-primary);
    margin-right: 4px;
}

.context-menu .dropdown-item .ctx-label { flex: 1; min-width: 0; }

.context-menu .dropdown-item .ctx-shortcut {
    margin-left: 18px;
    flex-shrink: 0;
    font-size: 0.6875rem;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.context-menu .dropdown-item.text-menu-strong { font-weight: 600; color: var(--text-primary); }

.context-menu .dropdown-item.disabled {
    opacity: 0.45;
    cursor: default;
}

.context-menu .dropdown-item.disabled:hover { background: transparent; }

/* ── Loading Spinner ── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

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

/* ── Selection ── */
::selection {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

/* ── Theme Editor ── */
.theme-editor-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal-overlay);
    z-index: 1100;
    display: none;
    justify-content: flex-end;
}

.theme-editor-overlay.active {
    display: flex;
}

.theme-editor {
    width: 360px;
    max-width: 90vw;
    height: 100%;
    max-height: 100dvh;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

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

.theme-editor-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.theme-editor-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.theme-section {
    margin-bottom: 20px;
}

.theme-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color-light);
}

.theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.theme-row label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.theme-row input[type="color"] {
    width: 36px;
    height: 28px;
    padding: 1px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
}

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

.theme-select {
    width: 180px;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: var(--font-sans);
    cursor: pointer;
}

.theme-editor-footer {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* ── Settings Controls ── */

.settings-value {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 44px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.theme-row input[type="range"] {
    flex: 1;
    max-width: 120px;
    accent-color: var(--color-primary);
    margin: 0 8px;
}

.settings-toggle {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    cursor: pointer;
}

.settings-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.settings-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: 11px;
    transition: background var(--transition-fast);
}

.settings-toggle-track::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: var(--bg-main);
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.settings-toggle input:checked + .settings-toggle-track {
    background: var(--color-primary);
}

.settings-toggle input:checked + .settings-toggle-track::after {
    transform: translateX(16px);
}

.theme-section-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0 20px;
    position: relative;
}

.theme-section-divider::after {
    content: 'THEME COLORS';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    padding: 0 10px;
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* ── Folder Drag-and-Drop ── */
.folder-dragging {
    opacity: 0.5;
}

.folder-drag-over-before {
    box-shadow: inset 0 2px 0 0 var(--color-primary);
}

.folder-drag-over-inside {
    background: var(--color-primary-light) !important;
}

.folder-drag-over-after {
    box-shadow: inset 0 -2px 0 0 var(--color-primary);
}

/* Note card while it's being dragged into a folder. Source card dims so
   users can see the drag is in flight. The floating clone for touch
   dragging is styled inline by notes.js. */
.note-card-dragging {
    opacity: 0.45;
}

/* ── Detail Popup (click-driven info popup with click-origin animation) ──
   Animates from the point the user clicked toward viewport center, growing
   into a card. Used by Overview / Kanban Progress / Activity heatmap. */
.detail-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0);
    transition: background 250ms ease;
    /* pointer-events disabled by default so a stale / closing overlay
       can't swallow right-clicks (or any other event) on the dashboard
       underneath. Re-enabled only while the popup is actively open. */
    pointer-events: none;
}
.detail-popup-overlay.open {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    pointer-events: auto;
}
.detail-popup-card {
    position: fixed;
    width: min(520px, calc(100vw - 32px));
    max-height: 80vh;
    overflow-y: auto;
    /* ~60% opaque, theme-aware. `color-mix` blends the theme's --bg-card
       with transparency so the dashboard behind shows through softly.
       The backdrop-filter blur on the card itself frosts whatever is
       behind so text stays legible. */
    background: color-mix(in srgb, var(--bg-card, #ffffff) 60%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.5),
        0 4px 12px rgba(0, 0, 0, 0.28);
    /* Both `top/left` and `transform` are transitioned so the card travels
       from click point → center while scaling up. The cubic-bezier with
       slight overshoot gives the "fluid" feel. */
    transition:
        left 420ms cubic-bezier(0.34, 1.4, 0.64, 1),
        top  420ms cubic-bezier(0.34, 1.4, 0.64, 1),
        transform 420ms cubic-bezier(0.34, 1.4, 0.64, 1),
        opacity 220ms ease;
    will-change: transform, top, left, opacity;
}
.detail-popup-card::before {
    /* Accent stripe at the top of the card, color set per-popup via the
       --detail-accent custom property */
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--detail-accent, var(--color-primary));
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}
.detail-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 10px;
    border-bottom: 1px solid var(--border-color);
}
.detail-popup-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}
.detail-popup-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
    border-radius: 4px;
}
.detail-popup-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}
.detail-popup-body {
    padding: 16px 20px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.55;
}
.detail-popup-body h4 {
    margin: 16px 0 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.detail-popup-body h4:first-child { margin-top: 0; }
.detail-popup-body .dp-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    margin: 8px 0;
}
.detail-popup-body .dp-stat {
    display: flex;
    flex-direction: column;
    background: var(--bg-hover, #f1f5f9);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
}
.detail-popup-body .dp-stat-num {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.detail-popup-body .dp-stat-lbl {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.detail-popup-body .dp-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dashed var(--border-color);
}
.detail-popup-body .dp-row:last-child { border-bottom: none; }
.detail-popup-body .dp-row-label { color: var(--text-secondary); }
.detail-popup-body .dp-row-value { color: var(--text-primary); font-weight: 500; }
.detail-popup-body .dp-empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 20px 0;
}
.detail-popup-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-hover, #f1f5f9);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

/* Make Overview / Kanban progress / heatmap items obviously clickable */
.ov-tool-row,
.ov-extra,
.ov-hero-row,
.ov-donut-wrap,
.kanban-progress-item,
.heatmap-cell:not(.empty):not(.level-0) {
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.ov-tool-row:hover,
.ov-extra:hover,
.ov-hero-row:hover,
.kanban-progress-item:hover {
    background: var(--hover-bg);
    border-radius: 6px;
}
.ov-donut-wrap:hover { transform: scale(1.02); }
.heatmap-cell:not(.empty):not(.level-0):hover {
    outline: 1px solid var(--color-primary);
    outline-offset: 1px;
}

/* ── Shared user color palette for folders ─────────────────────────
   Used by both the notes folder modal and the feature-folder edit
   dialog (Charts, Roadmaps). Visual matches kanban-palette-swatch. */
.folder-palette-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
    min-height: 24px;
    align-items: center;
}
.folder-palette-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s, border-color 0.15s;
}
.folder-palette-swatch:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.4);
}
.folder-palette-swatch.active {
    border-color: var(--color-primary, #6366f1);
    box-shadow: 0 0 0 1px var(--color-primary, #6366f1);
}
.folder-palette-empty {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ─── Theme editor: editing modes (Quick / Colour Mixer / Advanced) ──── */

.theme-mode-toggle {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm, 6px);
}

.theme-mode-toggle button {
    flex: 1;
    padding: 6px 10px;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.theme-mode-toggle button:hover { background: var(--bg-hover); color: var(--text-primary); }

.theme-mode-toggle button.active {
    background: var(--color-primary);
    color: var(--color-primary-text, #fff);
    font-weight: 600;
}

.theme-mode-toggle-sm { flex: 0 0 auto; }
.theme-mode-toggle-sm button { flex: 0 0 auto; padding: 4px 12px; font-size: 0.75rem; }

.theme-mode-hint {
    margin: 8px 0 0;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--text-muted);
}

/* ─── Quick themes ──────────────────────────────────────────────────── */

.theme-preset-group { margin-bottom: 14px; }

.theme-preset-group-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.theme-preset-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    gap: 8px;
}

.theme-preset-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    text-align: left;
}

.theme-preset-card:hover { border-color: var(--color-primary); }

.theme-preset-card.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-light);
}

/* Miniature of the theme: its page colour, with accent, card and text on top. */
.theme-preset-swatch {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 32px;
    padding: 0 6px;
    border: 1px solid;
    border-radius: 4px;
}

.theme-preset-swatch i {
    display: block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.theme-preset-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.theme-inline-check {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* ─── Colour mixer ──────────────────────────────────────────────────── */

.theme-slider {
    flex: 1;
    min-width: 140px;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    appearance: none;
    cursor: pointer;
}

.theme-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--color-primary);
    cursor: pointer;
}

.theme-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--color-primary);
    cursor: pointer;
}

/* The hue slider shows the wheel it is scrubbing through. */
.theme-hue-slider {
    background: linear-gradient(to right,
        hsl(0, 70%, 50%), hsl(60, 70%, 50%), hsl(120, 70%, 50%),
        hsl(180, 70%, 50%), hsl(240, 70%, 50%), hsl(300, 70%, 50%), hsl(360, 70%, 50%));
}

.theme-mix-actions { display: flex; gap: 8px; margin: 12px 0 10px; }

.theme-swatches {
    display: flex;
    gap: 4px;
    height: 26px;
}

.theme-swatches span {
    flex: 1;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* ─── Readability read-out ──────────────────────────────────────────── */

.theme-contrast-report { display: flex; flex-direction: column; gap: 3px; }

.theme-contrast-row {
    display: grid;
    grid-template-columns: 30px 1fr auto 16px;
    gap: 8px;
    align-items: center;
    padding: 3px 5px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* A failing pairing is called out rather than quietly listed. */
.theme-contrast-row.failing {
    background: color-mix(in srgb, var(--color-danger) 14%, transparent);
    color: var(--text-primary);
}

.theme-contrast-chip {
    display: grid;
    place-items: center;
    height: 20px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    font-size: 0.6875rem;
    font-weight: 600;
}

.theme-contrast-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-contrast-ratio { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.theme-contrast-row.failing .theme-contrast-mark { color: var(--color-danger); }
.theme-contrast-mark { color: var(--color-success); font-weight: 700; }

/* ── Library encryption migration progress ── */
.e2e-progress { height: 8px; border-radius: 4px; background: var(--bg-tertiary, rgba(127,127,127,0.2)); overflow: hidden; margin: 12px 0 8px; }
.e2e-progress-bar { height: 100%; width: 0; background: var(--color-primary); transition: width 0.2s ease; }
.e2e-progress-text { font-size: 0.8rem; color: var(--text-muted); }

/* The unlock and migration dialogs must outrank the page loader (99999):
   boot blocks on them, so they can never be hidden behind it. */
#e2eUnlockModal, #e2eMigrateModal { z-index: 100000; }

/* Modal close (×): larger glyph for human eyes, same thin stroke. */
.modal-header .btn-icon {
    font-size: 30px;
    font-weight: 300;
    line-height: 1;
    padding: 2px 10px;
}

/* ─── Dropdowns: one look across the whole app ───────────────────────
   The Projects field style: a quiet box (input background, hairline
   border, 6px corners) with a single chevron, the same in every browser
   (appearance: none, so iPad Safari draws what Chrome draws). The editor's
   Font / Size / Paragraph / Styles pickers copy this look in editor.css.

   The look is !important on purpose: about eighty dropdowns across the
   modules (and inline styles in JS-built forms) each carried their own
   background shorthand, padding and radius, and a `background:` shorthand
   silently removes the chevron. Modules still choose the SIZE (font-size,
   padding top/bottom/left, height, width). A dropdown that must stand out
   sets --select-bg / --select-fg / --select-border instead of fighting
   these rules (Admin Hub ticket status, Kanban history speed). */
:root {
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.25 6 7.75l3.5-3.5' fill='none' stroke='%238b93a1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

select {
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1.3;
    padding: 5px 28px 5px 8px;
    cursor: pointer;
    -webkit-appearance: none !important;
    appearance: none !important;
    color: var(--select-fg, var(--text-primary)) !important;
    background-color: var(--select-bg, var(--bg-input)) !important;
    background-image: var(--select-chevron) !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 12px 12px !important;
    border: 1px solid var(--select-border, var(--border-color)) !important;
    border-radius: 6px !important;
    padding-right: 28px !important;
    transition: border-color var(--transition-fast, 0.15s), box-shadow var(--transition-fast, 0.15s);
}

select:hover:not(:disabled) {
    border-color: var(--select-border, var(--text-muted)) !important;
}

select:focus,
select:focus-visible {
    outline: none;
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* List boxes (several rows visible) have no chevron. */
select[multiple],
select[size]:not([size="1"]) {
    background-image: none !important;
    padding-right: 8px !important;
}

/* The popup list follows the theme, so options are never white-on-white. */
html[data-theme="dark"] select { color-scheme: dark; }
html[data-theme="light"] select { color-scheme: light; }
select option,
select optgroup {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

/* A field label above its control, as in Projects (STATUS / PRIORITY / HEALTH). */
.field-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ─── Sidebar tree rows: every folder and file, in every workspace ────
   Notes folders (folders.js) and the shared tree used by Kanban, Mind Maps,
   Drawings, Charts, Projects and the Planner (feature-folders.js) draw each
   row as a small box in its folder's colour: a hairline border and a faint
   shade. A folder uses its own colour; a file uses the colour of the folder
   it sits in; no colour = neutral grey. Rows step in by depth (--depth).
   The selected row keeps the app's selected look (accent fill + bar) so it
   always stands out from the tinted rows around it. */
:is(.ff-item, .sidebar-nav-item[data-folder-id]) {
    --rc: var(--row-color, var(--text-muted));
    box-sizing: border-box;
    /* explicit: Notes rows are <button>s, which shrink to their text under width:auto */
    width: calc(100% - 16px - var(--depth, 0) * 14px) !important;
    margin: 2px 8px 2px calc(8px + var(--depth, 0) * 14px) !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    border: 1px solid color-mix(in srgb, var(--rc) 38%, transparent) !important;
    border-radius: 6px !important;
    background: color-mix(in srgb, var(--rc) 8%, transparent) !important;
    transition: background var(--transition-fast, 0.15s), border-color var(--transition-fast, 0.15s);
}
:is(.ff-item, .sidebar-nav-item[data-folder-id]):hover {
    border-color: color-mix(in srgb, var(--rc) 65%, transparent) !important;
    background: color-mix(in srgb, var(--rc) 16%, transparent) !important;
    color: var(--text-primary);
}
:is(.ff-item, .sidebar-nav-item[data-folder-id]).active {
    background: var(--bg-active, rgba(59, 130, 246, 0.12)) !important;
    border-color: var(--text-active, var(--color-primary)) !important;
    box-shadow: inset 3px 0 0 var(--text-active, var(--color-primary));
    color: var(--text-active, var(--color-primary)) !important;
    font-weight: 500;
}
/* Drag-and-drop still shows where a row will land */
:is(.ff-item, .sidebar-nav-item[data-folder-id]):is(.ff-drag-over-before, .folder-drag-over-before) {
    box-shadow: inset 0 2px 0 0 var(--color-primary);
}
:is(.ff-item, .sidebar-nav-item[data-folder-id]):is(.ff-drag-over-after, .folder-drag-over-after) {
    box-shadow: inset 0 -2px 0 0 var(--color-primary);
}
:is(.ff-item, .sidebar-nav-item[data-folder-id]):is(.ff-drag-over-inside, .folder-drag-over-inside) {
    border-color: var(--color-primary) !important;
    background: var(--color-primary-light) !important;
}
