* {
    box-sizing: border-box;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color var(--ui-motion-slow) ease, color var(--ui-motion-slow) ease;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
}

body.animations-disabled #app-header,
body.animations-disabled #options-bar,
body.animations-disabled #floating-dock,
body.animations-disabled .dropdown-menu,
body.animations-disabled .modal-overlay,
body.animations-disabled .modal,
body.animations-disabled .cloud-modal,
body.animations-disabled .cloud-modal-content,
body.animations-disabled #context-menu,
body.animations-disabled #text-format-toolbar,
body.animations-disabled .cloud-account-menu,
body.animations-disabled .pill-button,
body.animations-disabled .visibility-pill-item,
body.animations-disabled .btn {
    animation: none !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
}

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

::-webkit-scrollbar-track {
    background: var(--sb-track);
}

::-webkit-scrollbar-thumb {
    background: var(--sb-thumb);
    border-radius: 10px;
}

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

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

.icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
    flex-shrink: 0;
}

/* HEADER */
#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--header-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-3) 0 var(--space-3);
    z-index: var(--z-header);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Subtle divider after logo, before menu items */
.header-left > img.icon {
    margin-right: 6px;
    position: relative;
}

.header-left > img.icon::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 20px;
    background: var(--border-color);
}

/* Use a real divider element instead since ::after on img won't work */
.header-menu-divider {
    width: 1px;
    height: 18px;
    background: var(--border-color);
    flex-shrink: 0;
    opacity: 0.6;
}

.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.project-title-chip {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 32px;
    max-width: min(56vw, 520px);
    padding: 5px 14px 5px 11px;
    border-radius: var(--radius-pill);
    border: 1px solid color-mix(in srgb, var(--border-color) 70%, transparent);
    background: color-mix(in srgb, var(--surface-1) 70%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: all var(--ui-motion-medium) cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.project-title-chip:hover {
    background: color-mix(in srgb, var(--hover-bg) 80%, transparent);
    border-color: var(--border-color-hover);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(var(--accent-rgb), 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: translateY(-0.5px);
}

.project-title-chip:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

#project-title-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sync status dot */
.project-sync-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #71717a;
    flex-shrink: 0;
    transition: background var(--ui-motion-medium) ease, box-shadow var(--ui-motion-medium) ease;
}

.project-sync-dot.synced {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.project-sync-dot.unsynced {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.project-sync-dot.syncing {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
    animation: sync-pulse 1.2s ease-in-out infinite;
}

@keyframes sync-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Sync status button - appears next to project title on sync issues */
.sync-status-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    margin-left: 4px;
    color: #ef4444;
    transition: background 0.15s ease, opacity 0.4s ease;
}
.sync-status-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}
.sync-status-btn.sync-error {
    display: inline-flex;
    animation: sync-error-flash 0.8s ease-in-out 3;
}
.sync-status-btn.sync-ok {
    display: inline-flex;
    color: #22c55e;
    animation: sync-ok-fade 2s ease-out forwards;
}
@keyframes sync-error-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
@keyframes sync-ok-fade {
    0% { opacity: 1; color: #22c55e; }
    60% { opacity: 1; color: #22c55e; }
    100% { opacity: 0; }
}

/* Project title icon - flat SVG */
.project-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 13px;
    height: 13px;
    line-height: 1;
    opacity: 0.45;
    flex-shrink: 0;
    transition: opacity var(--ui-motion-medium) ease;
}

.project-title-icon svg {
    width: 13px;
    height: 13px;
}

.project-title-chip:hover .project-title-icon {
    opacity: 0.7;
}

/* Hide the icon's pseudo-element since we use SVGs now */
.project-title-icon.lock::before,
.project-title-icon.link::before {
    content: none;
}

.project-chat-btn {
    margin-left: 6px;
}

.project-chat-icon {
    width: 16px;
    height: 16px;
    display: block;
    opacity: 0.85;
    transition: opacity 0.2s, filter 0.2s;
}

.project-chat-btn:hover .project-chat-icon {
    opacity: 1;
}

/* Ensure chat icon is visible in dark modes */
body.dark-mode .project-chat-icon,
body.midnight-mode .project-chat-icon,
body.amoled-mode .project-chat-icon,
body.high-contrast-mode .project-chat-icon,
body.neon-mode .project-chat-icon {
    filter: invert(1) brightness(1.2);
}

@media (max-width: 900px) {
    .header-center {
        display: none;
    }
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    margin-right: 24px;
    color: var(--text-primary);
}

.menu-txt {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 5px 11px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: background-color var(--ui-motion-medium) ease, color var(--ui-motion-medium) ease, border-color var(--ui-motion-medium) ease, transform var(--ui-motion-fast) ease, box-shadow var(--ui-motion-medium) ease;
    position: relative;
    overflow: hidden;
}

.menu-txt:hover {
    color: var(--text-primary);
    background: var(--surface-2);
    border-color: var(--border-color);
}

.menu-txt:active {
    transform: scale(0.97);
    background: var(--surface-3);
    border-color: var(--border-color-hover);
}

.menu-txt:focus-visible {
    box-shadow: var(--focus-ring);
    border-color: var(--accent-color);
}

.menu-txt.active,
body:has(#file-menu.visible) .menu-txt[onclick*="toggleFileMenu"],
body:has(#edit-menu.visible) .menu-txt[onclick*="toggleEditMenu"],
body:has(#history-menu.visible) .menu-txt[onclick*="toggleHistoryMenu"] {
    background: var(--surface-2);
    border-color: var(--border-color-hover);
    color: var(--text-primary);
}

/* Header Divider */
.header-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 4px;
}

/* Icon Buttons (Undo/Redo) */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    transition: background-color var(--ui-motion-medium) ease, color var(--ui-motion-medium) ease, border-color var(--ui-motion-medium) ease, box-shadow var(--ui-motion-medium) ease;
}

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

body.dark-mode .icon-btn,
body.midnight-mode .icon-btn,
body.amoled-mode .icon-btn {
    background: var(--surface-1);
}

body.dark-mode .icon-btn:hover,
body.midnight-mode .icon-btn:hover,
body.amoled-mode .icon-btn:hover {
    background: var(--hover-bg);
}

.icon-btn:focus-visible {
    box-shadow: var(--focus-ring);
    border-color: var(--accent-color);
}

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

/* OPTIONS BAR */
#options-bar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    height: 44px;
    background: var(--header-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-4);
    z-index: var(--z-options);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    overflow-x: auto;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

/* Compact labels — subtle, lowercase, smaller weight */
#options-bar .control-group > span {
    font-size: 0.68rem !important;
    font-weight: 500 !important;
    text-transform: none !important;
    letter-spacing: 0.01em !important;
    opacity: 0.55;
}

/* Vertical divider between control groups */
.opt-divider {
    width: 1px;
    height: 18px;
    background: var(--border-color);
    flex-shrink: 0;
    opacity: 0.5;
}

#options-bar.closed {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.opt-group {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    height: 100%;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 28px;
    height: 28px;
}

#options-bar .control-group>span,
#options-bar .control-group>label {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: var(--text-xs) !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em;
    color: color-mix(in srgb, var(--text-secondary) 88%, var(--text-primary));
    text-transform: uppercase;
    white-space: nowrap;
}

#options-bar .input-spinner-group input[type="number"] {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 400;
    letter-spacing: -0.01em;
}

/* Styling Inputs in Options Bar */
/* Unified slider styles — used in options bar, modals, and settings */
.control-group input[type="range"],
.modal input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 5px;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    /* Dynamic fill using CSS variable --value (0-100) set by JS */
    --value: 50;
    background: linear-gradient(to right,
            var(--accent-color) 0%,
            var(--accent-color) calc(var(--value) * 1%),
            color-mix(in srgb, var(--text-secondary) 25%, transparent) calc(var(--value) * 1%),
            color-mix(in srgb, var(--text-secondary) 25%, transparent) 100%);
}

.control-group input[type="range"]::-webkit-slider-thumb,
.modal input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: grab;
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    -webkit-user-drag: none;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover,
.modal input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.control-group input[type="range"]::-webkit-slider-thumb:active,
.modal input[type="range"]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.2);
}

/* Firefox support */
.control-group input[type="range"]::-moz-range-thumb,
.modal input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: grab;
    border: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.control-group input[type="range"]::-moz-range-thumb:active,
.modal input[type="range"]::-moz-range-thumb:active {
    cursor: grabbing;
}

.control-group input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    padding: 3px;
    background: var(--header-bg);
    border: 1px solid var(--border-color-strong);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.control-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.control-group input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: calc(var(--radius-md) - 4px);
}

.control-group input[type="color"]::-moz-color-swatch {
    border: none;
    border-radius: calc(var(--radius-md) - 4px);
}

.control-group input[type="color"]:hover {
    border-color: color-mix(in srgb, var(--border-color-strong) 70%, var(--accent-color));
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.control-group input[type="color"]:focus-visible {
    box-shadow: var(--focus-ring), 0 0 0 1px rgba(15, 23, 42, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    border-color: var(--accent-color);
}

/* Custom Number Inputs */
.input-spinner-group {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-1);
    overflow: hidden;
    height: 28px;
}

.input-spinner-group.small {
    height: 28px;
}

.input-spinner-group input[type="number"] {
    border: none;
    background: transparent;
    padding: 0;
    text-align: center;
    width: 36px;
    height: 100%;
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 400;
    -moz-appearance: textfield;
    appearance: textfield;
}

.input-spinner-group input[type="number"]::-webkit-inner-spin-button,
.input-spinner-group input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* +/− spin buttons flanking the input: [−] input [+] */
.spin-btn {
    border: none;
    background: transparent;
    padding: 0 0 2px 0; /* nudge text up - font metrics place +/− below visual center */
    width: 28px;
    height: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1;
    user-select: none;
    flex-shrink: 0;
    transition: background-color var(--ui-motion-fast) ease, color var(--ui-motion-fast) ease;
}

.spin-btn.down {
    border-right: 1px solid var(--border-color);
}

.spin-btn.up {
    border-left: 1px solid var(--border-color);
}

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

.spin-btn:active {
    background: var(--accent-subtle);
    color: var(--accent-color);
}

.control-group input[type="number"]:focus {
    outline: none;
}

.input-spinner-group:focus-within {
    border-color: var(--accent-color);
    box-shadow: var(--focus-ring);
    background: var(--surface-2);
}

/* Reset View button — compact to match spinner height */
#options-bar .reset-view-btn.btn.btn-secondary {
    height: 25px;
    min-height: 25px;
    max-height: 25px;
    padding: 0 8px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    line-height: 1;
}

.toggle-icon {
    appearance: none;
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    background: var(--surface-1);
    transition: background-color var(--ui-motion-medium) ease, color var(--ui-motion-medium) ease, border-color var(--ui-motion-medium) ease, box-shadow var(--ui-motion-medium) ease;
}

/* Toggle group — groups toggle icons with consistent spacing */
.toggle-group {
    gap: 4px;
}

.icon-mask {
    width: 18px;
    height: 18px;
    display: block;
    flex-shrink: 0;
    background-color: currentColor;
}

.icon-vertex-mode {
    -webkit-mask: url('../../assets/vertexmode.svg') no-repeat center / contain;
    mask: url('../../assets/vertexmode.svg') no-repeat center / contain;
}

.toggle-icon:hover {
    background: var(--hover-bg);
    border-color: var(--border-color-hover);
    color: var(--accent-color);
}

.toggle-icon.active {
    background: rgba(var(--accent-rgb), 0.12);
    border-color: rgba(var(--accent-rgb), 0.36);
    color: var(--accent-color);
}

.toggle-icon:focus-visible {
    box-shadow: var(--focus-ring);
    border-color: var(--accent-color);
}

/* Dark theme: brighten options-bar SVG icons for visibility */
body.dark-mode #options-bar .toggle-icon,
body.midnight-mode #options-bar .toggle-icon,
body.amoled-mode #options-bar .toggle-icon,
body.neon-mode #options-bar .toggle-icon {
    color: var(--text-primary);
}

body.dark-mode #options-bar .toggle-icon:hover,
body.midnight-mode #options-bar .toggle-icon:hover,
body.amoled-mode #options-bar .toggle-icon:hover,
body.neon-mode #options-bar .toggle-icon:hover {
    color: var(--accent-color);
}

/* HIDE UI STATES */
body.hide-ui #app-header {
    transform: translateY(-100%);
}

body.hide-ui #options-bar {
    transform: translateY(-100%);
    transform: translateY(-100%);
    opacity: 0;
}

/* Note: Selection is now controlled in canvas.css - disabled by default, enabled only for focused editors */

/* NAVIGATION MENU */
#nav-menu {
    position: fixed;
    z-index: var(--z-dropdown);
    min-width: 160px;
    background: var(--header-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
    overflow: hidden;
    isolation: isolate;
}

#nav-menu.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#nav-menu.visible.hiding {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
}

.nav-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

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

body.dark-mode .nav-menu-item:hover,
body.midnight-mode .nav-menu-item:hover,
body.amoled-mode .nav-menu-item:hover,
body.neon-mode .nav-menu-item:hover {
    background: var(--hover-bg);
}

.nav-menu-item.active {
    color: var(--accent-color);
}

.nav-menu-item .icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* =============================================
   DROPDOWN MENUS (File & Edit)
   ============================================= */
.dropdown-menu {
    position: fixed;
    background: var(--header-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 8px;
    box-shadow: var(--shadow-xl);
    z-index: var(--z-dropdown);
    min-width: 200px;
    display: none;
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    animation: fade-in 0.15s ease-out;
    overflow: hidden;
    isolation: isolate;
}

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

.dropdown-menu.visible.hiding {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 36px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color var(--ui-motion-fast) ease, color var(--ui-motion-fast) ease, transform var(--ui-motion-fast) ease, box-shadow var(--ui-motion-fast) ease;
    font-size: var(--text-base);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    outline: none;
}

.dropdown-item:hover {
    background: var(--accent-subtle);
    color: var(--accent-color);
}

.dropdown-item:focus-visible {
    box-shadow: var(--focus-ring);
    background: var(--accent-subtle);
    color: var(--accent-color);
}

.dropdown-item:active {
    transform: scale(0.99);
    background: rgba(var(--accent-rgb), 0.18);
    color: var(--accent-color);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.76;
}

.dropdown-separator {
    height: 1px;
    margin: 4px 8px;
    background: var(--border-color);
}

.dropdown-item-danger {
    color: #ef4444;
}

.dropdown-item-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.dropdown-item-danger:active {
    background: rgba(239, 68, 68, 0.18);
    color: #dc2626;
}

.dropdown-item .shortcut {
    margin-left: auto;
    padding: 2px 6px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--surface-1);
    font-family: 'Consolas', monospace;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    opacity: 1;
}

.history-dropdown-menu {
    min-width: 280px;
    max-width: 360px;
    max-height: min(64vh, 460px);
    overflow-y: auto;
}

.history-dropdown-item {
    gap: 10px;
}

.history-dropdown-item .history-icon {
    width: 16px;
    height: 16px;
    opacity: 0.75;
    flex-shrink: 0;
}

.history-dropdown-empty {
    cursor: default;
    color: var(--text-secondary);
    padding: 20px 12px;
    text-align: center;
    font-style: normal;
    font-size: var(--text-sm);
}

.history-dropdown-empty:hover {
    background: transparent;
    color: var(--text-secondary);
}

/* =============================================
   BOTTOM RIGHT TOOLBAR (Feature 5)
   ============================================= */
#bottom-toolbar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--header-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 4px 7px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: var(--z-bottom-toolbar);
}

#bottom-toolbar .toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

#bottom-toolbar .toolbar-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s, color 0.2s;
}

#bottom-toolbar .toolbar-btn:hover {
    background: var(--hover-bg);
}

#bottom-toolbar .toolbar-btn:active {
    background: var(--accent-subtle);
}

#bottom-toolbar .toolbar-btn:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}

#bottom-toolbar .toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 4px;
}

#bottom-toolbar #scale-display {
    min-width: 45px;
    text-align: center;
    font-size: 12px;
    color: var(--text-color);
    font-weight: 500;
}

/* =============================================
   PERF STATS PANEL
   ============================================= */
#perf-stats {
    background: var(--header-bg);
    backdrop-filter: var(--backdrop-blur);
    -webkit-backdrop-filter: var(--backdrop-blur);
    color: var(--text-secondary);
    padding: 5px 10px;
    font-size: 0.7rem;
    pointer-events: none;
    z-index: 9999;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

/* =============================================
   PERF STATS SYNC CHIP
   ============================================= */
#perf-stats .perf-sync-chip {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border: 1px solid transparent;
}

#perf-stats .perf-sync-synced {
    color: #16a34a;
    background: rgba(22, 163, 74, 0.12);
    border-color: rgba(22, 163, 74, 0.25);
}

#perf-stats .perf-sync-syncing {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.12);
    border-color: rgba(37, 99, 235, 0.25);
}

#perf-stats .perf-sync-queued {
    color: #d97706;
    background: rgba(217, 119, 6, 0.12);
    border-color: rgba(217, 119, 6, 0.25);
}

#perf-stats .perf-sync-offline {
    color: var(--text-secondary);
    background: var(--surface-2);
    border-color: var(--border-color);
}

#perf-stats .perf-sync-error {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.25);
}

#perf-stats .perf-sync-local {
    color: var(--text-secondary);
    background: var(--surface-1);
    border-color: var(--border-color);
}

/* Dark theme overrides for sync chips (better contrast on dark bg) */
body.dark-mode #perf-stats .perf-sync-synced,
body.midnight-mode #perf-stats .perf-sync-synced,
body.amoled-mode #perf-stats .perf-sync-synced,
body.neon-mode #perf-stats .perf-sync-synced {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.15);
    border-color: rgba(74, 222, 128, 0.3);
}

body.dark-mode #perf-stats .perf-sync-syncing,
body.midnight-mode #perf-stats .perf-sync-syncing,
body.amoled-mode #perf-stats .perf-sync-syncing,
body.neon-mode #perf-stats .perf-sync-syncing {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.15);
    border-color: rgba(96, 165, 250, 0.3);
}

body.dark-mode #perf-stats .perf-sync-queued,
body.midnight-mode #perf-stats .perf-sync-queued,
body.amoled-mode #perf-stats .perf-sync-queued,
body.neon-mode #perf-stats .perf-sync-queued {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.15);
    border-color: rgba(251, 191, 36, 0.3);
}

body.dark-mode #perf-stats .perf-sync-error,
body.midnight-mode #perf-stats .perf-sync-error,
body.amoled-mode #perf-stats .perf-sync-error,
body.neon-mode #perf-stats .perf-sync-error {
    color: #f87171;
    background: rgba(248, 113, 113, 0.15);
    border-color: rgba(248, 113, 113, 0.3);
}

/* ── Theme-dependent logo tinting ──
   The Noteroom logo SVG is natively blue (#2e60a5 bg, #007cf1→white ribbon).
   CSS filters shift its hue/brightness per theme so it feels integrated.
   Applied to all <img> elements using noteroom.svg as source. */

.noteroom-logo-themed {
    transition: filter 0.3s ease;
}

/* Light (default) — original blue, no filter needed */

/* Dark — slightly desaturated, dimmed */
body.dark-mode .noteroom-logo-themed {
    filter: brightness(0.8) saturate(0.85);
}

/* Midnight — cooler blue-purple shift, dimmed */
body.midnight-mode .noteroom-logo-themed {
    filter: brightness(0.75) saturate(0.9) hue-rotate(15deg);
}

/* AMOLED — deep dim, high contrast */
body.amoled-mode .noteroom-logo-themed {
    filter: brightness(0.65) saturate(0.8) contrast(1.1);
}

/* High Contrast — vivid, punchy */
body.high-contrast-mode .noteroom-logo-themed {
    filter: brightness(0.9) saturate(1.3) contrast(1.15);
}

/* Sepia — warm golden shift */
body.sepia-mode .noteroom-logo-themed {
    filter: sepia(0.35) hue-rotate(-10deg) saturate(0.8) brightness(0.95);
}

/* Neon — vibrant purple shift */
body.neon-mode .noteroom-logo-themed {
    filter: hue-rotate(40deg) saturate(1.4) brightness(0.85);
}

/* Blush — warm pink shift */
body.blush-mode .noteroom-logo-themed {
    filter: hue-rotate(-30deg) saturate(0.75) brightness(0.95);
}

/* Mint — cool green-teal shift */
body.mint-mode .noteroom-logo-themed {
    filter: hue-rotate(80deg) saturate(0.7) brightness(0.95);
}
