/* Terminal Calendar Styles */

/* === CSS Variables === */
:root {
    /* Color palette - bright (text) and dim (background) variants */
    --term-green: #33ff33;
    --term-green-dim: #1a3d1a;
    --term-red: #ff4444;
    --term-red-dim: #3d1a1a;
    --term-orange: #ff9933;
    --term-orange-dim: #3d2a1a;
    --term-yellow: #ffff33;
    --term-yellow-dim: #3d3d1a;
    --term-blue: #44aaff;
    --term-blue-dim: #1a2a3d;
}

/* === Terminal Theme === */
[data-theme="terminal"] {
    --bg-color: #0a0a0a;
    --border: 1px solid #33ff33;
    --header-bg: #1a3d1a;
    --header-text: #0a0a0a;
    --text-color: #33ff33;
    --empty-bg: #111;
    --font-family: 'Courier New', Courier, monospace;

    --accent-color: var(--term-green);
    --accent-color-dim: var(--term-green-dim);
    --cell-hover-bg: #0f220f;
    --hour-divider: rgba(51, 255, 51, 0.15);
    --both-free-bg: rgba(51, 255, 51, 0.06);
}

/* === Custom Theme (generated from image) - Terminal style base === */
[data-theme^="custom"] {
    --bg-color: #0a0a0a;
    --border: 1px solid var(--accent-color);
    --header-bg: var(--accent-color-dim);
    --header-text: var(--accent-color);
    --text-color: var(--accent-color);
    --empty-bg: #111;
    --font-family: 'Courier New', Courier, monospace;

    --accent-color: #33ff33;
    --accent-color-dim: #1a3d1a;
    --cell-hover-bg: #0f220f;
    --hour-divider: rgba(51, 255, 51, 0.15);
    --both-free-bg: rgba(51, 255, 51, 0.06);
}

/* === Custom Theme Light Mode === */
[data-theme^="custom"][data-light="true"] {
    --bg-color: #f5f5f0;
    --header-text: #f5f5f0;
    --empty-bg: #e8e8e3;
    --cell-hover-bg: rgba(0, 0, 0, 0.05);
    --hour-divider: rgba(0, 0, 0, 0.1);
    --both-free-bg: rgba(0, 0, 0, 0.03);
}

/* Light mode buttons */
[data-theme^="custom"][data-light="true"] .theme-btn,
[data-theme^="custom"][data-light="true"] .toggle-btn {
    background: #f5f5f0;
    border-color: var(--accent-color);
    color: var(--text-color);
}

[data-theme^="custom"][data-light="true"] .theme-btn:hover,
[data-theme^="custom"][data-light="true"] .toggle-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme^="custom"][data-light="true"] .theme-btn.active,
[data-theme^="custom"][data-light="true"] .toggle-btn.active {
    background: var(--accent-color);
    color: #111;
}

[data-theme^="custom"][data-light="true"] .add-theme-btn {
    background: transparent;
    border-color: var(--accent-color);
    color: var(--text-color);
}

[data-theme^="custom"][data-light="true"] .add-theme-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Light mode context menus */
[data-theme^="custom"][data-light="true"] #context-menu,
[data-theme^="custom"][data-light="true"] #hour-context-menu,
[data-theme^="custom"][data-light="true"] #theme-context-menu,
[data-theme^="custom"][data-light="true"] #notes-editor-context-menu,
[data-theme^="custom"][data-light="true"] #notes-folder-context-menu {
    background-color: #f5f5f0;
    box-shadow: 3px 3px 0px rgba(0, 0, 0, 0.15);
}

/* Light mode day headers */
[data-theme^="custom"][data-light="true"] .day-header {
    background: color-mix(in srgb, var(--accent-color) 20%, white);
    color: var(--text-color);
}

/* Light mode cell states */
[data-theme^="custom"][data-light="true"] .day-cell {
    background: #f5f5f0;
}

/* Light mode swatch clear */
[data-theme^="custom"][data-light="true"] .swatch-clear {
    background: linear-gradient(
        135deg,
        #f5f5f0 40%,
        var(--accent-color) 40%,
        var(--accent-color) 60%,
        #f5f5f0 60%
    );
}

[data-theme^="custom"][data-light="true"] .hour-slot.both-free {
    background-color: color-mix(in srgb, var(--accent-color) 8%, white);
}

/* Light mode highlights - pastel tinted backgrounds */
[data-light="true"] .day-cell[data-highlight="green"] {
    background-color: color-mix(in srgb, var(--term-green) 35%, white);
}
[data-light="true"] .day-cell[data-highlight="red"] {
    background-color: color-mix(in srgb, var(--term-red) 35%, white);
}
[data-light="true"] .day-cell[data-highlight="orange"] {
    background-color: color-mix(in srgb, var(--term-orange) 35%, white);
}
[data-light="true"] .day-cell[data-highlight="yellow"] {
    background-color: color-mix(in srgb, var(--term-yellow) 35%, white);
}
[data-light="true"] .day-cell[data-highlight="blue"] {
    background-color: color-mix(in srgb, var(--term-blue) 35%, white);
}

[data-light="true"] .hour-slot[data-highlight="green"] {
    background-color: color-mix(in srgb, var(--term-green) 35%, white);
}
[data-light="true"] .hour-slot[data-highlight="red"] {
    background-color: color-mix(in srgb, var(--term-red) 35%, white);
}
[data-light="true"] .hour-slot[data-highlight="orange"] {
    background-color: color-mix(in srgb, var(--term-orange) 35%, white);
}
[data-light="true"] .hour-slot[data-highlight="yellow"] {
    background-color: color-mix(in srgb, var(--term-yellow) 35%, white);
}
[data-light="true"] .hour-slot[data-highlight="blue"] {
    background-color: color-mix(in srgb, var(--term-blue) 35%, white);
}

/* Light mode scrollbar */
[data-light="true"] ::-webkit-scrollbar-track {
    background: #f5f5f0;
}

[data-light="true"] ::-webkit-scrollbar-thumb {
    background: #999;
    border-color: #f5f5f0;
}

[data-light="true"] ::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* === Global Selection & Scrollbar === */
::selection {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

::-moz-selection {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

/* Custom Scrollbar - Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

::-webkit-scrollbar-track {
    background: #0a0a0a;
}

::-webkit-scrollbar-thumb {
    background: #1a3d1a;
    border: 2px solid #0a0a0a;
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: #33ff33;
}

::-webkit-scrollbar-corner {
    background: #0a0a0a;
}

/* Hide scrollbar */
html {
    scrollbar-width: none; /* Firefox */
    overflow-y: auto;
}

html::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

/* === Body === */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    margin: 0;
    transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3 {
    text-transform: uppercase;
    letter-spacing: 5px;
    margin-bottom: 30px;
}


/* === Calendar Grid === */
.calendar-grid-wrapper {
    position: relative;
    width: 100%;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    width: 100%;
    border-left: var(--border);
    border-top: var(--border);
    user-select: none;
    transition: border-color 0.3s;
}


.day-header {
    text-align: center;
    padding: 10px;
    background: var(--header-bg);
    color: var(--header-text);
    font-weight: bold;
    border-right: var(--border);
    border-bottom: var(--border);
    transition: background-color 0.3s, color 0.3s;
}


.day-cell {
    min-height: 150px;
    border-right: var(--border);
    border-bottom: var(--border);
    display: flex;
    flex-direction: column;
    transition: background 0.2s, border-color 0.3s;
    cursor: text;
    background: var(--bg-color);
    position: relative;
}

.day-cell.selected-cell {
    z-index: 1;
}

.day-cell.empty {
    background: var(--empty-bg);
    cursor: default;
}


.date-number {
    font-size: 0.9em;
    padding: 5px 8px;
    opacity: 0.8;
    pointer-events: none;
    transition: color 0.3s;
}


/* === Task Area === */
.task-area {
    flex-grow: 1;
    padding: 0 8px 10px 8px;
    white-space: pre-wrap;
    outline: none;
    color: var(--text-color);
    font-family: inherit;
    user-select: text;
    transition: color 0.3s;
}

.task-area b,
.task-area strong {
    font-weight: 900;
}


/* === Context Menu === */
#context-menu,
#hour-context-menu {
    position: fixed;
    display: none;
    background-color: var(--bg-color);
    border: var(--border);
    color: var(--text-color);
    z-index: 1000;
    min-width: 160px;
    box-shadow: 5px 5px 0px var(--accent-color-dim);
    transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
    /* GPU acceleration for smooth show/hide */
    will-change: transform, opacity;
}


.menu-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.85em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--accent-color-dim);
    transition: background-color 0.2s, color 0.2s;
}


.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background-color: var(--accent-color);
    color: var(--bg-color);
}


/* === Color Swatches === */
.color-presets {
    display: flex;
    gap: 8px;
    padding: 10px 15px;
    border-bottom: 1px solid var(--accent-color-dim);
    transition: border-color 0.3s;
}


.swatch {
    width: 20px;
    height: 20px;
    border: 1px solid var(--accent-color);
    cursor: pointer;
    transition: transform 0.1s, border-color 0.3s;
}


.swatch:hover {
    outline: 1px solid white;
}

.swatch-clear {
    background: linear-gradient(
        135deg,
        var(--bg-color) 40%,
        var(--accent-color) 40%,
        var(--accent-color) 60%,
        var(--bg-color) 60%
    );
}

/* === Theme Buttons (inside view-controls) === */
.theme-sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 400px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color-dim) transparent;
}

.theme-sidebar::-webkit-scrollbar {
    width: 3px;
}

.theme-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.theme-sidebar::-webkit-scrollbar-thumb {
    background: var(--accent-color-dim);
    border-radius: 2px;
}

.theme-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

.sidebar-divider {
    width: 28px;
    height: 1px;
    background: var(--accent-color-dim);
    align-self: center;
    margin: 2px 0;
}

/* Base button styles */
.theme-btn {
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    position: relative;
}

/* Terminal theme button styles */
[data-theme="terminal"] .theme-btn {
    border: 2px solid #33ff33;
    border-radius: 0;
    background: #0a0a0a;
    color: #33ff33;
    font-family: 'Courier New', Courier, monospace;
}

[data-theme="terminal"] .theme-btn:hover {
    background: #1a3d1a;
}

[data-theme="terminal"] .theme-btn.active {
    background: #33ff33;
    border-color: #33ff33;
    color: #0a0a0a;
}

/* Custom theme button styles (terminal-based) */
[data-theme^="custom"] .theme-btn {
    border: 2px solid var(--accent-color);
    border-radius: 0;
    background: #0a0a0a;
    color: var(--text-color);
    font-family: 'Courier New', Courier, monospace;
}

[data-theme^="custom"] .theme-btn:hover {
    background: var(--accent-color-dim);
}

[data-theme^="custom"] .theme-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--bg-color);
}

/* Add theme button (plus button) */
.add-theme-btn {
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    transition: all 0.2s;
    margin-top: 4px;
}

[data-theme="terminal"] .add-theme-btn {
    border: 2px dashed #33ff33;
    border-radius: 0;
    background: transparent;
    color: #33ff33;
    font-family: 'Courier New', Courier, monospace;
}

[data-theme="terminal"] .add-theme-btn:hover {
    background: #1a3d1a;
    border-style: solid;
}

/* Custom theme add button styles (terminal-based) */
[data-theme^="custom"] .add-theme-btn {
    border: 2px dashed var(--accent-color);
    border-radius: 0;
    background: transparent;
    color: var(--text-color);
    font-family: 'Courier New', Courier, monospace;
}

[data-theme^="custom"] .add-theme-btn:hover {
    background: var(--accent-color-dim);
    border-style: solid;
}

/* Hidden file inputs for image upload */
#theme-image-input,
#bg-image-input,
#theme-regenerate-input {
    display: none;
}

/* Theme button drag and drop */
.theme-btn {
    transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1),
                opacity 0.2s ease,
                box-shadow 0.2s ease,
                background 0.2s ease;
    cursor: grab;
}

.theme-btn:active:not(.dragging) {
    cursor: grabbing;
}

.theme-btn.dragging {
    opacity: 0.3;
    transform: scale(0.9);
    cursor: grabbing;
}

/* Drag indicator - highlight the target button */
.theme-btn.drag-over {
    box-shadow: 0 0 8px var(--accent-color, #33ff33);
    border-color: var(--accent-color, #33ff33) !important;
}

/* Theme Context Menu */
#theme-context-menu {
    position: fixed;
    display: none;
    background-color: var(--bg-color);
    border: var(--border);
    color: var(--text-color);
    z-index: 1001;
    min-width: 120px;
    box-shadow: 5px 5px 0px var(--accent-color-dim);
}

#theme-context-menu .menu-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.85em;
    text-transform: uppercase;
    transition: background-color 0.2s, color 0.2s;
}

#theme-context-menu .menu-item:hover {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

/* === Sticky Month Header === */
.month-header-sticky {
    position: sticky;
    top: 10px;
    z-index: 50;
    background: var(--bg-color);
    opacity: 0.7;
    text-align: center;
    padding: 10px 0;
    transition: border-color 0.3s;
}

.month-header-sticky h3 {
    margin: 0;
    min-width: 280px;
    transition: opacity 0.1s ease;
}

.month-header-sticky h3.fading {
    opacity: 0;
}

/* === Calendar Container (multi-month scroll) === */
.calendar-container {
    width: 95vw;
    max-width: 1200px;
    margin: 0 auto;
    padding-bottom: 50vh;
}

.calendar-container[data-view="expanded"] {
    max-width: 1600px;
    width: 90vw;
}

.month-section {
    margin-bottom: 20px;
    position: relative;
    overflow-anchor: none;
}

.month-section-title {
    text-align: center;
    padding: 15px 0;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 5px;
    font-size: 0.9em;
    opacity: 0.5;
}

/* === View Controls === */
/* === View Controls (Fixed Sidebar) === */
.view-controls {
    position: fixed;
    top: 0;
    bottom: 0;
    right: -60px;
    padding-right: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    z-index: 100;
    transition: right 0.3s ease, z-index 0s 0.3s;
}

.view-controls::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 160px;
    z-index: -1;
}

.view-controls:hover,
.view-controls.edge-hover {
    right: 0;
    z-index: 102;
    transition: right 0.3s ease, z-index 0s 0s;
}

.toggle-btn {
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.2s;
}

.toggle-value {
    font-weight: bold;
}

/* Terminal theme toggle styles */
[data-theme="terminal"] .toggle-btn {
    border: 2px solid #33ff33;
    border-radius: 0;
    background: #0a0a0a;
    color: #33ff33;
    font-family: 'Courier New', Courier, monospace;
    text-transform: uppercase;
}

[data-theme="terminal"] .toggle-btn:hover {
    background: #1a3d1a;
}

[data-theme="terminal"] .toggle-btn.active {
    background: #33ff33;
    color: #0a0a0a;
}

/* Custom theme toggle styles (terminal-based) */
[data-theme^="custom"] .toggle-btn {
    border: 2px solid var(--accent-color);
    border-radius: 0;
    background: #0a0a0a;
    color: var(--text-color);
    font-family: 'Courier New', Courier, monospace;
    text-transform: uppercase;
}

[data-theme^="custom"] .toggle-btn:hover {
    background: var(--accent-color-dim);
}

[data-theme^="custom"] .toggle-btn.active {
    background: var(--accent-color);
    color: var(--bg-color);
}

/* === Sync Status Indicator === */
.sync-status {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-color, #0a0a0a);
    border: 1px solid var(--accent-color, #33ff33);
    font-family: var(--font-family, 'Courier New', monospace);
    font-size: 12px;
    color: var(--text-color, #33ff33);
    z-index: 102;
}

#sync-status-icon {
    font-size: 10px;
    transition: color 0.3s;
}

#sync-status-icon.synced { color: var(--term-green); }
#sync-status-icon.pending { color: var(--term-yellow); }
#sync-status-icon.syncing { color: var(--term-blue); animation: pulse 1s infinite; }
#sync-status-icon.offline { color: var(--term-red); }
#sync-status-icon.error { color: var(--term-red); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


/* === Expanded Hourly View === */
.calendar-container[data-view="expanded"] .day-cell:not(.empty) {
    /* Fixed height prevents layout shift during hourly slot virtualization */
    /* Dynamically set via --expanded-cell-height (hourRange.length * 50px) */
    min-height: var(--expanded-cell-height, 900px);
    min-width: 0;
    overflow: hidden;
}

/* Disable day cell hover in expanded view */
.calendar-container[data-view="expanded"] .day-cell:not(.empty):hover {
    background-color: transparent;
}


.hourly-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
    overflow: hidden;
}

/* Disable ALL transitions during initial page load (except body fade-in) */
.no-transitions * {
    transition: none !important;
}

.no-transitions {
    transition: opacity 0.3s ease !important;
}

/* Grid transition for view/person switching */
.calendar-container.transitioning {
    transition: opacity 0.15s ease-out;
}

.calendar-container.fade-out {
    opacity: 0;
}

.calendar-container.content-swap {
    visibility: hidden;
}


.hour-slot {
    display: flex;
    min-height: 50px;
    align-items: stretch;
    min-width: 0;
    border-top: 1px solid var(--hour-divider);
    cursor: text;
    transition: background-color 0.2s ease;
}

.hour-slot:first-child {
    border-top: none;
}

.hour-slot.selected-hour {
    z-index: 1;
    position: relative;
}

.hour-label {
    width: 50px;
    min-width: 50px;
    flex-shrink: 0;
    padding: 4px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    pointer-events: none;
    line-height: 1.1;
}

.hour-primary {
    opacity: 0.7;
    font-size: 0.9em;
}

.hour-secondary {
    opacity: 0.35;
    font-size: 0.7em;
}

.hour-task {
    flex: 1 1 0;
    width: 0;
    padding: 4px 6px;
    outline: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-color);
    font-family: inherit;
    user-select: text;
}

.hour-slot.both-free {
    background-color: var(--both-free-bg, rgba(51, 255, 51, 0.06));
}


/* Free Legend */
.free-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 20px;
    font-size: 0.85em;
    opacity: 0.7;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-free::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background-color: rgba(51, 255, 51, 0.15);
    border: 1px solid rgba(51, 255, 51, 0.3);
}


.hour-slot:not(.merged-start) .hour-task:focus {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: visible;
    text-overflow: clip;
}

.hour-slot.expanded:not(.merged-start) .hour-task {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: visible;
    text-overflow: clip;
    position: relative;
    background: var(--bg-color);
    z-index: 5;
}

.hour-slot.expanded:not(.merged-start) {
    z-index: 10;
    position: relative;
}


/* Hide regular task-area in expanded view */
.calendar-container[data-view="expanded"] .task-area {
    display: none;
}

/* === Hour Context Menu === */
#hour-context-menu {
    position: fixed;
    display: none;
    background-color: var(--bg-color);
    border: var(--border);
    color: var(--text-color);
    z-index: 1000;
    min-width: 140px;
    box-shadow: 5px 5px 0px var(--accent-color-dim);
    transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
}


#hour-context-menu .menu-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.85em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--accent-color-dim);
    transition: background-color 0.2s, color 0.2s;
}


#hour-context-menu .menu-item:last-child {
    border-bottom: none;
}

#hour-context-menu .menu-item:hover {
    background-color: var(--accent-color);
    color: var(--bg-color);
}


#hour-context-menu .menu-item.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* === Merged Hour Slots === */
.hour-slot.merged-start {
    border-bottom: none;
    align-items: flex-start;
    overflow: hidden;
}

.hour-slot.merged-continuation {
    display: none;
}

/* Merged cells: allow wrapping, truncate at merged bounds */
.hour-slot.merged-start .hour-task {
    height: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
}

/* Merged cells: show full text when selected or focused */
.hour-slot.merged-start.selected-hour,
.hour-slot.merged-start:focus-within {
    height: auto !important;
    min-height: var(--merge-height);
    z-index: 10;
}

.hour-slot.merged-start.selected-hour .hour-task,
.hour-slot.merged-start .hour-task:focus {
    height: auto;
    overflow: visible;
}

/* === Task Checkboxes === */
.task-item {
    display: inline-flex;
    align-items: flex-start;
    gap: 4px;
    line-height: 1.2;
    margin: 0;
}

.task-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    min-width: 12px;
    min-height: 12px;
    border: 1px solid var(--accent-color);
    background: transparent;
    cursor: pointer;
    margin-top: 4px;
    position: relative;
    flex-shrink: 0;
}

/* Only enable transitions after checkbox is ready (class added via JS) */
.task-checkbox.transitions-enabled {
    transition: background 0.2s ease, border-color 0.2s ease;
}

.task-checkbox:hover {
    border-color: var(--accent-color);
    background: var(--accent-color-dim);
}

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

.task-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0px;
    width: 3px;
    height: 7px;
    border: solid var(--bg-color);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Light mode checkbox */
[data-light="true"] .task-checkbox:hover {
    background: color-mix(in srgb, var(--accent-color) 25%, white);
}

[data-light="true"] .task-checkbox:checked {
    background: var(--accent-color);
}

[data-light="true"] .task-checkbox:checked::after {
    border-color: #f5f5f0;
}

/* Bullet point items (-text with no space) */
.bullet-item {
    display: inline-flex;
    align-items: flex-start;
    gap: 4px;
    line-height: 1.2;
    margin: 0;
}

.bullet-marker {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--accent-color);
}


.task-text {
    flex: 1;
}

/* Only enable transitions after checkbox is ready (class added via JS) */
.transitions-enabled + .task-text {
    transition: opacity 0.2s ease;
}

.task-item.checked .task-text {
    opacity: 0.4;
    text-decoration: line-through;
}

/* === Cell Highlights (applied via data-highlight attribute) === */
.day-cell[data-highlight="green"] {
    background-color: var(--term-green-dim);
}
.day-cell[data-highlight="green"] .date-number,
.day-cell[data-highlight="green"] .task-area {
    color: var(--term-green);
}
.day-cell[data-highlight="green"] .task-checkbox {
    border-color: var(--term-green);
}
.day-cell[data-highlight="green"] .task-checkbox:checked {
    background: var(--term-green);
}
.day-cell[data-highlight="green"] .bullet-marker {
    color: var(--term-green);
}

.day-cell[data-highlight="red"] {
    background-color: var(--term-red-dim);
}
.day-cell[data-highlight="red"] .date-number,
.day-cell[data-highlight="red"] .task-area {
    color: var(--term-red);
}
.day-cell[data-highlight="red"] .task-checkbox {
    border-color: var(--term-red);
}
.day-cell[data-highlight="red"] .task-checkbox:checked {
    background: var(--term-red);
}
.day-cell[data-highlight="red"] .bullet-marker {
    color: var(--term-red);
}

.day-cell[data-highlight="orange"] {
    background-color: var(--term-orange-dim);
}
.day-cell[data-highlight="orange"] .date-number,
.day-cell[data-highlight="orange"] .task-area {
    color: var(--term-orange);
}
.day-cell[data-highlight="orange"] .task-checkbox {
    border-color: var(--term-orange);
}
.day-cell[data-highlight="orange"] .task-checkbox:checked {
    background: var(--term-orange);
}
.day-cell[data-highlight="orange"] .bullet-marker {
    color: var(--term-orange);
}

.day-cell[data-highlight="yellow"] {
    background-color: var(--term-yellow-dim);
}
.day-cell[data-highlight="yellow"] .date-number,
.day-cell[data-highlight="yellow"] .task-area {
    color: var(--term-yellow);
}
.day-cell[data-highlight="yellow"] .task-checkbox {
    border-color: var(--term-yellow);
}
.day-cell[data-highlight="yellow"] .task-checkbox:checked {
    background: var(--term-yellow);
}
.day-cell[data-highlight="yellow"] .bullet-marker {
    color: var(--term-yellow);
}

.day-cell[data-highlight="blue"] {
    background-color: var(--term-blue-dim);
}
.day-cell[data-highlight="blue"] .date-number,
.day-cell[data-highlight="blue"] .task-area {
    color: var(--term-blue);
}
.day-cell[data-highlight="blue"] .task-checkbox {
    border-color: var(--term-blue);
}
.day-cell[data-highlight="blue"] .task-checkbox:checked {
    background: var(--term-blue);
}
.day-cell[data-highlight="blue"] .bullet-marker {
    color: var(--term-blue);
}

/* === Hour Slot Highlights === */
.hour-slot[data-highlight="green"] {
    background-color: var(--term-green-dim);
}
.hour-slot[data-highlight="green"] .hour-label,
.hour-slot[data-highlight="green"] .hour-task {
    color: var(--term-green);
}

.hour-slot[data-highlight="red"] {
    background-color: var(--term-red-dim);
}
.hour-slot[data-highlight="red"] .hour-label,
.hour-slot[data-highlight="red"] .hour-task {
    color: var(--term-red);
}

.hour-slot[data-highlight="orange"] {
    background-color: var(--term-orange-dim);
}
.hour-slot[data-highlight="orange"] .hour-label,
.hour-slot[data-highlight="orange"] .hour-task {
    color: var(--term-orange);
}

.hour-slot[data-highlight="yellow"] {
    background-color: var(--term-yellow-dim);
}
.hour-slot[data-highlight="yellow"] .hour-label,
.hour-slot[data-highlight="yellow"] .hour-task {
    color: var(--term-yellow);
}

.hour-slot[data-highlight="blue"] {
    background-color: var(--term-blue-dim);
}
.hour-slot[data-highlight="blue"] .hour-label,
.hour-slot[data-highlight="blue"] .hour-task {
    color: var(--term-blue);
}

/* === Confetti Effect === */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 9999;
}

.confetti {
    position: absolute;
    opacity: 0;
    font-size: 16px;
    line-height: 1;
    /* GPU acceleration for smooth animation */
    will-change: transform, opacity;
}

.confetti.small {
    font-size: 12px;
}

.confetti.large {
    font-size: 22px;
}

/* Explosive burst animation */
@keyframes confetti-explode {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) rotate(var(--rot)) scale(0.6);
    }
}

/* Screen flash for big celebrations */
.confetti-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--accent-color);
    pointer-events: none;
    z-index: 9998;
    animation: flash-burst 0.3s ease-out forwards;
}

@keyframes flash-burst {
    0% {
        opacity: 0.3;
    }
    100% {
        opacity: 0;
    }
}

/* === Settings Modal === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transition: opacity 0.35s ease;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 80px 0;
    box-sizing: border-box;
    /* GPU acceleration for smooth show/hide */
    will-change: opacity;
}

.modal.opening {
    display: flex;
    opacity: 0;
}

.modal.open {
    display: flex;
    opacity: 1;
}

.modal.closing {
    display: flex;
    opacity: 0;
}

.modal-content {
    background: var(--bg-color);
    border: var(--border);
    max-width: 400px;
    width: 90%;
    max-height: 100%;
    overflow-y: auto;
    font-family: var(--font-family);
    transform: scale(0.95) translateY(-10px);
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
}

.modal.open .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal.closing .modal-content {
    transform: scale(0.95) translateY(-10px);
    opacity: 0;
}

/* Minimal scrollbar for settings modal - uses theme accent color */
.modal-content::-webkit-scrollbar {
    width: 3px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--accent-color-dim);
    border-radius: 2px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

.modal-content::-webkit-scrollbar-button {
    display: none;
}

/* Firefox scrollbar */
.modal-content {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color-dim) transparent;
}

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

.modal-header h3 {
    margin: 0;
    color: var(--text-color);
    letter-spacing: 2px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 20px;
}

.settings-section {
    margin-bottom: 25px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h4 {
    color: var(--text-color);
    margin: 0 0 15px 0;
    font-size: 0.85em;
    letter-spacing: 2px;
    opacity: 0.7;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--accent-color-dim);
    color: var(--text-color);
    cursor: pointer;
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-row span {
    font-size: 0.9em;
}

/* Setting Toggle (Checkbox) */
.setting-toggle {
    appearance: none;
    -webkit-appearance: none;
    width: 40px;
    height: 20px;
    background: var(--accent-color-dim);
    border: 1px solid var(--accent-color);
    border-radius: 0;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
}

.setting-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--accent-color);
    transition: left 0.2s;
}

.setting-toggle:checked {
    background: var(--accent-color);
}

.setting-toggle:checked::after {
    left: 22px;
    background: var(--bg-color);
}

/* Setting Slider */
.setting-slider {
    width: 100px;
    height: 6px;
    appearance: none;
    -webkit-appearance: none;
    background: var(--accent-color-dim);
    border: 1px solid var(--accent-color);
    cursor: pointer;
}

.setting-slider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-color);
    cursor: pointer;
}

.setting-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent-color);
    border: none;
    cursor: pointer;
}

/* Setting Select — hidden native select, replaced by custom dropdown */
.setting-select {
    display: none;
}

/* Custom dropdown trigger */
.custom-select {
    display: inline-flex;
    align-items: center;
    position: relative;
    min-width: 100px;
}

.custom-select-trigger {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--accent-color);
    padding: 4px 8px;
    padding-right: 24px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.custom-select-trigger:hover {
    box-shadow: 0 0 5px var(--accent-color);
}

/* Chevron arrow — matches notes folder arrow style */
.custom-select-arrow {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
    color: var(--accent-color);
    line-height: 0;
    pointer-events: none;
    transition: transform 0.15s ease;
}

.custom-select.open .custom-select-arrow {
    transform: translateY(-50%) rotate(-90deg);
}

/* Dropdown panel — absolute inside wrapper, overlays content below */
.custom-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    max-height: 180px;
    overflow-y: auto;
    background: var(--bg-color);
    border: 1px solid var(--accent-color);
    border-top: none;
    z-index: 10;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color-dim) var(--bg-color);
}

.custom-select-dropdown.visible {
    display: block;
}

.custom-select-dropdown::-webkit-scrollbar {
    width: 3px;
}

.custom-select-dropdown::-webkit-scrollbar-track {
    background: var(--bg-color);
}

.custom-select-dropdown::-webkit-scrollbar-thumb {
    background: var(--accent-color-dim);
    border-radius: 2px;
}

.custom-select-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Dropdown items */
.custom-select-item {
    padding: 4px 8px;
    font-family: inherit;
    font-size: 12px;
    color: var(--text-color);
    cursor: pointer;
    white-space: nowrap;
}

.custom-select-item:hover {
    background: var(--accent-color-dim);
}

.custom-select-item.selected {
    color: var(--accent-color);
}

/* Setting Input (text) */
.setting-input {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--accent-color);
    padding: 4px 8px;
    font-family: inherit;
    font-size: 12px;
    width: 80px;
}

.setting-input:focus {
    outline: none;
    box-shadow: 0 0 5px var(--accent-color);
}

/* Wider inputs for tokens/passwords */
.setting-input.wide { width: 140px; }

/* Compact timezone label inputs */
.setting-input.tz-label { width: 60px; text-transform: uppercase; text-align: center; }

/* Hide number input spinners */
.setting-input[type="number"] { -moz-appearance: textfield; }
.setting-input[type="number"]::-webkit-inner-spin-button,
.setting-input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* GitHub status row */
.github-status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    margin: 4px 0;
    font-size: 0.8em;
}
.github-status-bar .status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.github-status-bar .status-dot.connected { background: var(--term-green); }
.github-status-bar .status-dot.disconnected { background: var(--term-red); }
.github-status-bar .status-dot.testing { background: var(--term-yellow); animation: pulse 1s infinite; }

/* Green connect button */
.setting-btn.connect { border-color: var(--term-green); color: var(--term-green); }
.setting-btn.connect:hover { background: var(--term-green); color: var(--bg-color); }

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.setting-btn-small {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--text-color);
    width: 24px;
    height: 24px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
}

.setting-btn-small:hover {
    background: var(--accent-color);
    color: var(--bg-color);
}

/* Color Swatch Button */
.color-swatch {
    width: 32px;
    height: 24px;
    border: 1px solid var(--accent-color);
    background: var(--accent-color);
    cursor: pointer;
    padding: 0;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.color-swatch:hover {
    transform: scale(1.05);
    box-shadow: 0 0 8px currentColor;
}

/* Custom Color Picker Popup */
.color-picker-popup {
    position: fixed;
    z-index: 3000;
    background: var(--bg-color);
    border: 1px solid var(--accent-color);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5), 0 0 10px var(--accent-color-dim);
    font-family: var(--font-family);
    min-width: 220px;
    opacity: 0;
    transform: scale(0.9) translateY(-10px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.color-picker-popup.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

.color-picker-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--accent-color-dim);
}

.color-picker-title {
    color: var(--text-color);
    font-size: 0.8em;
    letter-spacing: 1px;
}

.color-picker-body {
    padding: 12px;
}

.color-picker-gradient {
    width: 100%;
    height: 120px;
    position: relative;
    cursor: crosshair;
    border: 1px solid var(--accent-color-dim);
    background: linear-gradient(to bottom, transparent, #000),
                linear-gradient(to right, #fff, hsl(120, 100%, 50%));
}

.color-picker-cursor {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid #fff;
    box-shadow: 0 0 2px #000, inset 0 0 2px #000;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.color-picker-hue-wrap {
    margin-top: 10px;
}

.color-picker-hue {
    width: 100%;
    height: 12px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right,
        hsl(0, 100%, 50%),
        hsl(60, 100%, 50%),
        hsl(120, 100%, 50%),
        hsl(180, 100%, 50%),
        hsl(240, 100%, 50%),
        hsl(300, 100%, 50%),
        hsl(360, 100%, 50%)
    );
    border: 1px solid var(--accent-color-dim);
    cursor: pointer;
}

.color-picker-hue::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 6px;
    height: 16px;
    background: #fff;
    border: 1px solid #000;
    cursor: pointer;
}

.color-picker-hue::-moz-range-thumb {
    width: 6px;
    height: 16px;
    background: #fff;
    border: 1px solid #000;
    cursor: pointer;
}

.color-picker-preview-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    align-items: center;
}

.color-picker-preview {
    width: 40px;
    height: 28px;
    border: 1px solid var(--accent-color);
    background: #33ff33;
}

.color-picker-hex {
    flex: 1;
    background: var(--bg-color);
    border: 1px solid var(--accent-color-dim);
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 0.9em;
    padding: 5px 8px;
    text-transform: uppercase;
}

.color-picker-hex:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 5px var(--accent-color-dim);
}

.color-picker-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--accent-color-dim);
}

/* Setting Button */
.setting-btn {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--text-color);
    padding: 5px 12px;
    font-family: var(--font-family);
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.2s;
}

.setting-btn:hover {
    background: var(--accent-color);
    color: var(--bg-color);
}

.setting-btn.primary {
    border-color: var(--term-red);
    color: var(--term-red);
    background: transparent;
}

.setting-btn.primary:hover {
    background: var(--term-red);
    color: var(--bg-color);
}

.setting-btn.danger {
    border-color: var(--term-red);
    color: var(--term-red);
    margin-top: 10px;
    width: 100%;
}

.setting-btn.danger:hover {
    background: var(--term-red);
    color: var(--bg-color);
}

/* === Confirm Dialog === */
.confirm-dialog {
    max-width: 320px;
}

.confirm-dialog .modal-body p {
    color: var(--text-color);
    margin: 0 0 20px 0;
    font-size: 13px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 10px;
}

.confirm-actions .setting-btn {
    flex: 1;
    width: auto;
    margin-top: 0;
}

/* Prompt Dialog Input */
.prompt-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font-size: 13px;
}

/* === Custom Background === */
.custom-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    /* Prevent selection/interaction */
    pointer-events: none;
    user-select: none;
}

/* === Ambient Particles === */

/* Canvas-based particle system (high performance) */
.particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    /* Force GPU compositing - transform is lighter than contents */
    transform: translateZ(0);
}

/* Legacy DOM-based particle container (fallback) */
.particle-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
    /* Performance: isolate particles from rest of document */
    contain: strict;
    /* Promote to compositor layer */
    transform: translateZ(0);
}

.ambient-particle {
    position: absolute;
    opacity: 0.4;
    /* Performance: hint browser for animation optimization */
    will-change: transform, opacity;
    /* Isolate layout calculations */
    contain: layout style;
    /* Force GPU acceleration */
    backface-visibility: hidden;
}

/* Circle particles */
.ambient-particle.particle-circle {
    border-radius: 50%;
}

/* Text/Emoji particles */
.ambient-particle.particle-text {
    background: none;
    border-radius: 0;
    line-height: 1;
    white-space: nowrap;
    user-select: none;
}

/* Image particles */
.ambient-particle.particle-image {
    background: none;
    border-radius: 0;
    object-fit: contain;
}

/* Float Up - default movement */
.ambient-particle.particle-float {
    animation: particle-float linear infinite;
}

@keyframes particle-float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.4;
    }
    90% {
        opacity: 0.4;
    }
    100% {
        transform: translateY(-20px) rotate(360deg);
        opacity: 0;
    }
}

/* Fall Down */
.ambient-particle.particle-fall {
    animation: particle-fall linear infinite;
}

@keyframes particle-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.4;
    }
    90% {
        opacity: 0.4;
    }
    100% {
        transform: translateY(100vh) rotate(-360deg);
        opacity: 0;
    }
}

/* Drift Sideways */
.ambient-particle.particle-drift {
    animation: particle-drift linear infinite;
}

@keyframes particle-drift {
    0% {
        transform: translateX(0) translateY(0);
        opacity: 0;
    }
    10% {
        opacity: 0.4;
    }
    50% {
        transform: translateX(50vw) translateY(-30px);
    }
    90% {
        opacity: 0.4;
    }
    100% {
        transform: translateX(100vw) translateY(0);
        opacity: 0;
    }
}

/* Swirl */
.ambient-particle.particle-swirl {
    animation: particle-swirl ease-in-out infinite;
}

@keyframes particle-swirl {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 0;
    }
    10% {
        opacity: 0.4;
    }
    25% {
        transform: translate(50px, -30px) rotate(90deg) scale(1.2);
    }
    50% {
        transform: translate(0, -60px) rotate(180deg) scale(1);
    }
    75% {
        transform: translate(-50px, -30px) rotate(270deg) scale(1.2);
    }
    90% {
        opacity: 0.4;
    }
    100% {
        transform: translate(0, 0) rotate(360deg) scale(1);
        opacity: 0;
    }
}

/* Pulse */
.ambient-particle.particle-pulse {
    animation: particle-pulse ease-in-out infinite;
}

@keyframes particle-pulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    25% {
        transform: scale(1.5);
        opacity: 0.6;
    }
    50% {
        transform: scale(1);
        opacity: 0.3;
    }
    75% {
        transform: scale(1.8);
        opacity: 0.5;
    }
    100% {
        transform: scale(0.5);
        opacity: 0;
    }
}

/* Light mode settings modal */
[data-light="true"] .modal-content {
    background: #f5f5f0;
    scrollbar-color: color-mix(in srgb, var(--accent-color) 30%, transparent) transparent;
}

[data-light="true"] .modal-content::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--accent-color) 30%, transparent);
}

[data-light="true"] .modal-content::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--accent-color) 60%, transparent);
}

[data-light="true"] .setting-toggle {
    background: #ddd;
}

[data-light="true"] .setting-toggle:checked {
    background: var(--accent-color);
}

[data-light="true"] .setting-slider {
    background: #ddd;
}

[data-light="true"] .custom-select-trigger {
    background: #f5f5f0;
}

[data-light="true"] .custom-select-dropdown {
    background: #f5f5f0;
    scrollbar-color: color-mix(in srgb, var(--accent-color) 30%, transparent) #f5f5f0;
}

[data-light="true"] .custom-select-dropdown::-webkit-scrollbar-track {
    background: #f5f5f0;
}

[data-light="true"] .custom-select-dropdown::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--accent-color) 30%, transparent);
}

[data-light="true"] .setting-input {
    background: #f5f5f0;
}

/* === Tamagotchi Pet === */
.tamagotchi {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-color);
    border: 1px solid var(--accent-color);
    font-family: var(--font-family);
    z-index: 1000;
    min-width: 140px;
    box-shadow: 0 0 15px var(--accent-color-dim);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.tamagotchi.minimized .tama-body {
    display: none;
}

.tama-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid var(--accent-color-dim);
    cursor: move;
}

.tama-title {
    color: var(--text-color);
    font-size: 0.75em;
    letter-spacing: 1px;
}

.tama-toggle {
    background: none;
    border: none;
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 0.9em;
    cursor: pointer;
    padding: 0 4px;
}

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

.tama-body {
    padding: 10px;
}

.tama-display {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60px;
    margin-bottom: 8px;
}

.tama-sprite {
    color: var(--text-color);
    font-size: 16px;
    line-height: 1.2;
    margin: 0;
    text-align: center;
    transition: color 0.3s ease, transform 0.15s ease;
    animation: tama-breathe 3s ease-in-out infinite;
    white-space: nowrap;
}

/* Pause animation when minimized to save CPU */
.tamagotchi.minimized .tama-sprite {
    animation-play-state: paused;
}

@keyframes tama-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.tama-stats {
    border-top: 1px solid var(--accent-color-dim);
    padding-top: 8px;
}

.tama-stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.75em;
    margin-bottom: 4px;
}

.tama-label {
    color: var(--text-color);
    opacity: 0.6;
}

.tama-value {
    color: var(--text-color);
}

.tama-xp-bar {
    height: 4px;
    background: var(--accent-color-dim);
    margin-top: 4px;
    overflow: hidden;
}

.tama-xp-fill {
    height: 100%;
    background: var(--text-color);
    width: 0%;
    transition: width 0.3s ease;
}

.tama-mood {
    text-align: center;
    font-size: 0.7em;
    color: var(--text-color);
    opacity: 0.6;
    margin-top: 8px;
    font-style: italic;
}

/* Level up animation */
.tamagotchi.level-up {
    animation: tama-levelup 0.5s ease;
}

@keyframes tama-levelup {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.1); }
    50% { transform: scale(1.05); }
    75% { transform: scale(1.1); }
}

/* Feed animation */
.tamagotchi.feeding .tama-sprite {
    animation: tama-feed 0.3s ease forwards;
}

@keyframes tama-feed {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Sleeping animation - gentle sway */
.tamagotchi.sleeping .tama-sprite {
    animation: tama-sleep 2s ease-in-out infinite;
}

@keyframes tama-sleep {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(2px); }
}

/* Light mode */
[data-light="true"] .tamagotchi {
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
}

/* === Notes Panel === */
.notes-panel {
    position: fixed;
    top: 20px;
    bottom: 20px;
    left: 76px;
    right: 76px;
    z-index: 90;
    display: flex;
    background: var(--bg-color);
    border-radius: 4px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}
.notes-panel.notes-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    z-index: 101;
}

/* Calendar fade when switching to/from notes */
.calendar-container.notes-anim {
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.calendar-container.notes-hiding {
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
}
.month-header-sticky.notes-anim {
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.month-header-sticky.notes-hiding {
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
}

.notes-sidebar {
    position: relative;
    width: 220px;
    min-width: 220px;
    border-right: var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s ease, min-width 0.25s ease;
}

.notes-sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    border-right: none;
}
.notes-sidebar.collapsed .notes-sidebar-header,
.notes-sidebar.collapsed .notes-list {
    display: none;
}
.notes-sidebar.no-transition {
    transition: none;
}

.notes-sidebar-resize {
    width: 0;
    position: relative;
    cursor: col-resize;
    z-index: 3;
    flex-shrink: 0;
}
.notes-sidebar-resize::after {
    content: '';
    position: absolute;
    left: -6px;
    top: 0;
    bottom: 0;
    width: 12px;
    cursor: col-resize;
}
.notes-sidebar-resize::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: transparent;
    transition: background-color 0.15s;
    z-index: 1;
}
.notes-sidebar-resize:hover::before,
.notes-sidebar-resize.dragging::before {
    background: var(--text-color);
}

.notes-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 12px;
    border-bottom: 1px solid var(--accent-color-dim);
    overflow: hidden;
    min-width: 0;
    gap: 8px;
}

.notes-sidebar-title {
    color: var(--text-color);
    font-size: 0.8em;
    letter-spacing: 2px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.notes-new-btn {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--text-color);
    width: 26px;
    height: 26px;
    min-width: 26px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-family);
    transition: all 0.2s;
    flex-shrink: 0;
}

.notes-new-btn:hover {
    background: var(--accent-color);
    color: var(--bg-color);
}

.notes-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color-dim) transparent;
}

.notes-list::-webkit-scrollbar {
    width: 3px;
}

.notes-list::-webkit-scrollbar-track {
    background: transparent;
}

.notes-list::-webkit-scrollbar-thumb {
    background: var(--accent-color-dim);
}

.notes-list-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.85em;
    color: var(--text-color);
    transition: background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.7;
}

.notes-list-item:hover {
    background: var(--accent-color-dim);
    opacity: 1;
}

.notes-list-item.active {
    background: var(--accent-color-dim);
    opacity: 1;
    border-left: 2px solid var(--accent-color);
    padding-left: 14px;
}

/* Notes folder items */
.notes-folder-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.85em;
    color: var(--text-color);
    transition: background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    opacity: 0.7;
    user-select: none;
}

.notes-folder-item:hover {
    background: var(--accent-color-dim);
    opacity: 1;
}

.notes-folder-arrow {
    width: 14px;
    min-width: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    color: var(--text-color);
    opacity: 0.5;
    transition: transform 0.2s ease;
    transform: rotate(0deg);
}

.notes-folder-arrow.expanded {
    transform: rotate(90deg);
}

.notes-folder-arrow svg {
    display: block;
}

.notes-folder-content {
    position: relative;
}

.notes-folder-content::before {
    content: '';
    position: absolute;
    left: var(--guide-left, 18px);
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--accent-color);
    opacity: 0.15;
    pointer-events: none;
}

.notes-folder-icon {
    margin-right: 6px;
    opacity: 0.4;
    font-size: 0.9em;
}

.notes-folder-name {
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* Inline rename */
.inline-rename-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--accent-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: inherit;
    outline: none;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

/* Drag and drop */
.notes-list-item[draggable="true"] {
    cursor: grab;
}

.notes-list-item.dragging {
    opacity: 0.3;
    cursor: grabbing;
}

.notes-folder-item.drag-over {
    background: var(--accent-color-dim);
    outline: 1px solid var(--accent-color);
    outline-offset: -1px;
    opacity: 1;
}

.notes-list.drag-over {
    background: var(--accent-color-dim);
}

/* Notes Folder Context Menu */
#notes-folder-context-menu {
    position: fixed;
    display: none;
    background-color: var(--bg-color);
    border: var(--border);
    color: var(--text-color);
    z-index: 1001;
    min-width: 140px;
    box-shadow: 5px 5px 0px var(--accent-color-dim);
}

#notes-folder-context-menu .menu-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.85em;
    text-transform: uppercase;
    transition: background-color 0.2s, color 0.2s;
}

#notes-folder-context-menu .menu-item:hover {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

/* Notes Editor */
.notes-editor-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.notes-editor-header {
    padding: 16px 24px 12px;
    border-bottom: 1px solid var(--accent-color-dim);
    margin-bottom: 8px;
}

.notes-title-input {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 1.1em;
    font-weight: bold;
    letter-spacing: 1px;
    width: 100%;
    outline: none;
}

.notes-title-input::placeholder {
    color: var(--text-color);
    opacity: 0.3;
}

.notes-editor {
    flex: 1;
    padding: 20px 32px;
    overflow-y: auto;
    outline: none;
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 1.05em;
    line-height: 1.75;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color-dim) transparent;
}

.notes-editor::-webkit-scrollbar {
    width: 3px;
}

.notes-editor::-webkit-scrollbar-track {
    background: transparent;
}

.notes-editor::-webkit-scrollbar-thumb {
    background: var(--accent-color-dim);
}

.notes-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    opacity: 0.25;
    font-size: 0.9em;
    letter-spacing: 1px;
}

/* Notes Context Menu */
#notes-context-menu {
    position: fixed;
    display: none;
    background-color: var(--bg-color);
    border: var(--border);
    color: var(--text-color);
    z-index: 1001;
    min-width: 120px;
    box-shadow: 5px 5px 0px var(--accent-color-dim);
}

#notes-context-menu .menu-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.85em;
    text-transform: uppercase;
    transition: background-color 0.2s, color 0.2s;
}

#notes-context-menu .menu-item:hover {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

/* Notes Editor Context Menu */
#notes-editor-context-menu {
    position: fixed;
    display: none;
    background-color: var(--bg-color);
    border: var(--border);
    color: var(--text-color);
    z-index: 1002;
    min-width: 180px;
    box-shadow: 5px 5px 0px var(--accent-color-dim);
}

#notes-editor-context-menu .menu-item {
    padding: 8px 15px;
    cursor: pointer;
    font-size: 0.85em;
    text-transform: uppercase;
    transition: background-color 0.2s, color 0.2s;
}

#notes-editor-context-menu .menu-item:hover {
    background-color: var(--accent-color);
    color: var(--bg-color);
}

.nctx-divider {
    height: 1px;
    background: var(--accent-color-dim);
}

.nctx-hl-section {
    padding: 6px 15px 8px;
}

.nctx-hl-label {
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
    display: block;
    margin-bottom: 6px;
}

#notes-editor-context-menu .color-presets {
    display: flex;
    gap: 8px;
    padding: 0;
    border-bottom: none;
}

[data-light="true"] #notes-editor-context-menu,
[data-light="true"] #notes-folder-context-menu {
    background-color: #f5f5f0;
    box-shadow: 3px 3px 0px rgba(0, 0, 0, 0.15);
}

/* === Notes Editor - Word-level Live Preview === */

/* Line container */
.notes-editor .md-line {
    min-height: 1.5em;
    padding: 0 4px;
    position: relative;
    white-space: pre-wrap;
}

/* Hidden syntax characters (word-level) */
.md-syn {
    display: none;
}

/* Reveal syntax when cursor is on the formatted span */
.md-fmt.md-active .md-syn {
    display: inline;
    opacity: 0.4;
    color: var(--accent-color);
}

/* Neutralize formatting when active (showing raw) */
.md-fmt.md-active strong { font-weight: normal; }
.md-fmt.md-active em { font-style: normal; }
.md-fmt.md-active del { text-decoration: none; }
.md-fmt.md-active u { text-decoration: none; }
.md-fmt.md-active mark { background: none; color: inherit; }
.md-fmt.md-active code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}
.md-fmt.md-active a {
    color: inherit;
    text-decoration: none;
    pointer-events: none;
}

/* Inline math toggle */
.md-fmt-math .md-raw { display: none; }
.md-fmt-math .md-rendered { display: inline; }
.md-fmt-math.md-active .md-rendered { display: none; }
.md-fmt-math.md-active .md-raw { display: inline; }

/* Display math $$...$$ on a single line */
.md-fmt-math-display { display: block; }
.md-fmt-math-display .md-rendered { display: block; overflow-x: auto; }
.md-fmt-math-display.md-active .md-raw { display: block; }

/* Image toggle – image always visible; active shows truncated syntax above */
.md-fmt-img { display: block; max-width: 100%; overflow: hidden; }
.md-fmt-img .md-img-preview { display: block; }
.md-fmt-img .md-img-preview img { display: block; max-width: 100%; }
.md-fmt-img.md-active .md-syn {
    display: block;
    font-size: 0.75em;
    opacity: 0.5;
    color: var(--accent-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: rgba(0,0,0,0.2);
    padding: 2px 6px;
    border: 1px solid var(--accent-color-dim);
    border-bottom: none;
    border-radius: 2px 2px 0 0;
}

/* Hidden line-level syntax (heading #, list -, blockquote >) */
.md-line-syn { display: none; }
.md-line-active .md-line-syn {
    display: inline;
    opacity: 0.35;
    color: var(--accent-color);
}

/* When line-level syntax is visible, hide the rendered alternatives */
.md-line-active .md-list-bullet,
.md-line-active .md-list-num,
.md-line-active .md-hr-rule { display: none; }

/* Heading styles */
.md-h1 { font-size: 1.6em; font-weight: bold; letter-spacing: 1px; }
.md-h2 { font-size: 1.3em; font-weight: bold; letter-spacing: 1px; }
.md-h3 { font-size: 1.1em; font-weight: bold; letter-spacing: 1px; }
.md-h4, .md-h5, .md-h6 { font-size: 1em; font-weight: bold; letter-spacing: 1px; }

/* When heading line is active, reset size so raw text is uniform */
.md-line-active .md-h1,
.md-line-active .md-h2,
.md-line-active .md-h3,
.md-line-active .md-h4,
.md-line-active .md-h5,
.md-line-active .md-h6 {
    font-size: inherit;
    font-weight: inherit;
}

/* ── Code block lines ─────────────────────────────────────────── */
.notes-editor .md-line.md-ctx-fence,
.notes-editor .md-line.md-ctx-code {
    background: rgba(0, 0, 0, 0.3);
    padding-left: 16px;
    padding-right: 16px;
}

.notes-editor .md-line.md-code-start {
    border: 1px solid var(--accent-color-dim);
    border-bottom: none;
    padding-top: 8px;
    margin-top: 8px;
    border-radius: 2px 2px 0 0;
    position: relative;
}

.notes-editor .md-line.md-code-end {
    border: 1px solid var(--accent-color-dim);
    border-top: none;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-radius: 0 0 2px 2px;
}

.notes-editor .md-line.md-ctx-code {
    border-left: 1px solid var(--accent-color-dim);
    border-right: 1px solid var(--accent-color-dim);
}

/* Fence text (```, $$) */
.md-fence-text {
    opacity: 0.4;
    font-size: 0.85em;
}

/* Language label on opening code fence */
.notes-editor .md-line.md-code-start[data-lang]::after {
    content: attr(data-lang);
    position: absolute;
    right: 16px;
    top: 8px;
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-color);
    opacity: 0.5;
    pointer-events: none;
}

/* Code content */
.md-code-content {
    font-family: var(--font-family);
    font-size: 0.88em;
    line-height: 1.5;
}

/* ── Math block lines ─────────────────────────────────────────── */

/* Rendered KaTeX preview on the opening fence */
.md-math-block-rendered {
    display: block;
    text-align: center;
    padding: 12px 16px;
    overflow-x: auto;
    cursor: text;
}

/* When NOT editing: show rendered, collapse raw content + closing fence */
.notes-editor .md-line.md-math-start {
    margin-top: 8px;
    border: 1px solid var(--accent-color-dim);
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.15);
    padding: 0;
}
.notes-editor .md-line.md-math-start .md-fence-text {
    display: none;
}
.notes-editor .md-line.md-math-end:not(.md-math-editing) {
    display: none;
}
.notes-editor .md-line.md-ctx-math:not(.md-math-editing) {
    display: none;
}

/* When editing: show raw fences + content, hide rendered preview */
.notes-editor .md-line.md-math-start.md-math-editing {
    border-bottom: none;
    border-radius: 2px 2px 0 0;
    padding: 4px 16px 0;
}
.notes-editor .md-line.md-math-start.md-math-editing .md-fence-text {
    display: inline;
    opacity: 0.4;
    font-size: 0.85em;
}
.notes-editor .md-line.md-math-start.md-math-editing .md-math-block-rendered {
    display: none;
}

.notes-editor .md-line.md-math-end.md-math-editing {
    display: block;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--accent-color-dim);
    border-top: none;
    padding: 0 16px 4px;
    margin-bottom: 8px;
    border-radius: 0 0 2px 2px;
}

.notes-editor .md-line.md-ctx-math.md-math-editing {
    display: block;
    background: rgba(0, 0, 0, 0.15);
    border-left: 1px solid var(--accent-color-dim);
    border-right: 1px solid var(--accent-color-dim);
    padding-left: 16px;
    padding-right: 16px;
}

.md-math-content {
    font-style: italic;
    opacity: 0.9;
}

/* ── Inline elements in normal lines ──────────────────────────── */

/* Inline code */
.notes-editor .md-fmt-code code {
    background: rgba(0, 0, 0, 0.3);
    padding: 1px 5px;
    font-size: 0.9em;
    border: 1px solid var(--accent-color-dim);
}

/* Links */
.notes-editor .md-fmt-link a {
    color: var(--accent-color);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Images */
.notes-editor .md-fmt-img .md-img-preview img {
    max-width: 100%;
    border: 1px solid var(--accent-color-dim);
    margin: 4px 0;
}

/* Blockquote text */
.md-bq-text {
    border-left: 3px solid var(--accent-color);
    padding-left: 12px;
    opacity: 0.8;
    font-style: italic;
    display: inline-block;
}

/* List bullets */
.md-list-bullet { color: var(--accent-color); }
.md-list-num { color: var(--accent-color); }

/* Highlight ==text== */
.md-hl {
    background: var(--accent-color-dim);
    color: var(--accent-color);
    padding: 0 2px;
    border-radius: 2px;
}
.md-hl-green { background: var(--term-green-dim); color: var(--term-green); }
.md-hl-red { background: var(--term-red-dim); color: var(--term-red); }
.md-hl-orange { background: var(--term-orange-dim); color: var(--term-orange); }
.md-hl-yellow { background: var(--term-yellow-dim); color: var(--term-yellow); }
.md-hl-blue { background: var(--term-blue-dim); color: var(--term-blue); }

[data-light="true"] .md-hl { background: color-mix(in srgb, var(--accent-color) 25%, white); color: #222; }
[data-light="true"] .md-hl-green { background: color-mix(in srgb, var(--term-green) 25%, white); color: #222; }
[data-light="true"] .md-hl-red { background: color-mix(in srgb, var(--term-red) 25%, white); color: #222; }
[data-light="true"] .md-hl-orange { background: color-mix(in srgb, var(--term-orange) 25%, white); color: #222; }
[data-light="true"] .md-hl-yellow { background: color-mix(in srgb, var(--term-yellow) 25%, white); color: #222; }
[data-light="true"] .md-hl-blue { background: color-mix(in srgb, var(--term-blue) 25%, white); color: #222; }

/* Underline ++text++ */
.md-fmt-ul u {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Task checked */
.md-task-checked {
    opacity: 0.5;
    text-decoration: line-through;
}

/* Horizontal rule */
.md-hr-text { display: none; }
.md-line-active .md-hr-text { display: inline; opacity: 0.4; }
.md-hr-rule {
    border: none;
    border-top: 1px solid var(--accent-color-dim);
    margin: 4px 0;
}

/* KaTeX */
.notes-editor .katex {
    color: var(--text-color);
}

/* ── Syntax Highlighting (theme-aware) ───────────────────────── */
.notes-editor .hljs {
    color: var(--text-color);
    background: transparent;
}

.notes-editor .hljs-keyword,
.notes-editor .hljs-selector-tag,
.notes-editor .hljs-meta .hljs-keyword {
    color: var(--accent-color);
    font-weight: bold;
}

.notes-editor .hljs-string,
.notes-editor .hljs-addition,
.notes-editor .hljs-selector-attr,
.notes-editor .hljs-selector-pseudo {
    color: var(--term-green);
}

.notes-editor .hljs-number,
.notes-editor .hljs-literal {
    color: var(--term-orange);
}

.notes-editor .hljs-title,
.notes-editor .hljs-title\.function_,
.notes-editor .hljs-section {
    color: var(--term-blue);
}

.notes-editor .hljs-type,
.notes-editor .hljs-built_in,
.notes-editor .hljs-title\.class_ {
    color: var(--term-yellow);
}

.notes-editor .hljs-comment,
.notes-editor .hljs-quote {
    color: var(--accent-color);
    opacity: 0.4;
    font-style: italic;
}

.notes-editor .hljs-variable,
.notes-editor .hljs-template-variable,
.notes-editor .hljs-deletion {
    color: var(--term-red);
}

.notes-editor .hljs-attr,
.notes-editor .hljs-attribute {
    color: var(--term-orange);
}

.notes-editor .hljs-name,
.notes-editor .hljs-tag {
    color: var(--term-red);
}

.notes-editor .hljs-regexp,
.notes-editor .hljs-symbol {
    color: var(--term-green);
}

.notes-editor .hljs-meta,
.notes-editor .hljs-doctag {
    color: var(--term-yellow);
    opacity: 0.7;
}

.notes-editor .hljs-params {
    color: var(--text-color);
}

.notes-editor .hljs-selector-class {
    color: var(--term-yellow);
}

.notes-editor .hljs-selector-id {
    color: var(--term-blue);
}

.notes-editor .hljs-emphasis { font-style: italic; }
.notes-editor .hljs-strong { font-weight: bold; }

/* ── Light mode notes ─────────────────────────────────────────── */

[data-light="true"] .notes-editor .md-line.md-ctx-fence,
[data-light="true"] .notes-editor .md-line.md-ctx-code {
    background: rgba(0, 0, 0, 0.05);
}

[data-light="true"] .notes-editor .md-line.md-code-start,
[data-light="true"] .notes-editor .md-line.md-code-end,
[data-light="true"] .notes-editor .md-line.md-ctx-code {
    border-color: rgba(0, 0, 0, 0.12);
}

[data-light="true"] .notes-editor .md-fmt-code code {
    background: rgba(0, 0, 0, 0.06);
}

[data-light="true"] .notes-editor .hljs-keyword,
[data-light="true"] .notes-editor .hljs-selector-tag,
[data-light="true"] .notes-editor .hljs-meta .hljs-keyword {
    color: color-mix(in srgb, var(--accent-color) 80%, black);
}

[data-light="true"] .notes-editor .hljs-string,
[data-light="true"] .notes-editor .hljs-addition {
    color: #1a7a1a;
}

[data-light="true"] .notes-editor .hljs-number,
[data-light="true"] .notes-editor .hljs-literal {
    color: #b35900;
}

[data-light="true"] .notes-editor .hljs-title,
[data-light="true"] .notes-editor .hljs-section {
    color: #1a6699;
}

[data-light="true"] .notes-editor .hljs-type,
[data-light="true"] .notes-editor .hljs-built_in {
    color: #7a7a00;
}

[data-light="true"] .notes-editor .hljs-comment,
[data-light="true"] .notes-editor .hljs-quote {
    color: #888;
    opacity: 1;
}

[data-light="true"] .notes-editor .hljs-variable,
[data-light="true"] .notes-editor .hljs-template-variable,
[data-light="true"] .notes-editor .hljs-deletion {
    color: #cc2222;
}

[data-light="true"] .notes-editor .hljs-name,
[data-light="true"] .notes-editor .hljs-tag {
    color: #cc2222;
}

[data-light="true"] .notes-editor .hljs-attr,
[data-light="true"] .notes-editor .hljs-attribute {
    color: #b35900;
}

[data-light="true"] .notes-editor .hljs-meta,
[data-light="true"] .notes-editor .hljs-doctag {
    color: #7a7a00;
    opacity: 1;
}

[data-light="true"] .notes-editor .hljs-selector-class {
    color: #7a7a00;
}

[data-light="true"] .notes-editor .hljs-selector-id {
    color: #1a6699;
}

[data-light="true"] #notes-context-menu,
[data-light="true"] #notes-folder-context-menu {
    background-color: #f5f5f0;
    box-shadow: 3px 3px 0px rgba(0, 0, 0, 0.15);
}

/* Responsive notes panel for half-screen usage */
@media (max-width: 1000px) {
    .notes-panel {
        left: 8px;
        right: 8px;
        top: 8px;
        bottom: 8px;
    }
    .notes-editor {
        padding: 16px 20px;
    }
    .notes-editor-header {
        padding: 12px 16px 10px;
    }
}

/* Toast notifications */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--accent-color-dim);
    padding: 10px 16px;
    font-family: inherit;
    font-size: 0.82em;
    max-width: 320px;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-error {
    border-color: #c0392b;
}

.toast.toast-warning {
    border-color: #f39c12;
}

/* === Mobile Back Button (hidden on desktop) === */
.notes-mobile-back {
    display: none;
}

/* === Mobile Bottom Nav (hidden on desktop) === */
.mobile-nav {
    display: none;
}

/* ============================================================
   MOBILE RESPONSIVE — max-width: 768px
   ============================================================ */
@media (max-width: 768px) {

    /* --- Phase 1C: Mobile nav bar --- */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--bg-color);
        border-top: 1px solid var(--accent-color-dim);
        z-index: 200;
        justify-content: space-around;
        align-items: center;
    }

    .mobile-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        background: none;
        border: none;
        color: var(--text-color);
        font-family: var(--font-family);
        font-size: 10px;
        cursor: pointer;
        padding: 6px 12px;
        opacity: 0.6;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-btn.active {
        opacity: 1;
    }

    .mobile-nav-icon {
        font-size: 16px;
        font-weight: bold;
        line-height: 1;
    }

    .mobile-nav-label {
        font-size: 9px;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    /* Hide desktop sidebar */
    .view-controls {
        display: none !important;
    }

    /* Body padding for nav bar */
    body {
        padding: 10px 8px calc(56px + env(safe-area-inset-bottom, 0px) + 10px);
    }

    /* --- Phase 2A: Calendar grid responsive --- */
    .calendar-container {
        width: 100vw;
        max-width: 100vw;
        margin: 0 -8px;
    }

    .calendar-container[data-view="expanded"] {
        width: 100vw;
        max-width: 100vw;
    }

    .calendar-grid-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .calendar-grid {
        grid-template-columns: repeat(7, minmax(120px, 1fr));
        min-width: calc(7 * 120px);
    }

    .day-cell {
        min-height: 100px;
    }

    .day-header {
        padding: 6px 4px;
        font-size: 0.8em;
        position: sticky;
        top: 0;
        z-index: 2;
    }

    .date-number {
        font-size: 0.8em;
        padding: 3px 6px;
    }

    .task-area {
        font-size: 0.85em;
        padding: 0 6px 6px;
    }

    .month-header-sticky {
        top: 0;
        padding: 6px 0;
    }

    .month-header-sticky h3 {
        letter-spacing: 3px;
        font-size: 0.85em;
        margin-bottom: 0;
    }

    .month-section-title {
        letter-spacing: 3px;
        font-size: 0.8em;
    }

    /* Hour view adjustments */
    .hour-label {
        width: 35px;
        min-width: 35px;
        font-size: 0.8em;
    }

    .hour-slot {
        min-height: 40px;
    }

    .hour-task {
        font-size: 0.85em;
    }

    h1, h2, h3 {
        letter-spacing: 3px;
        margin-bottom: 15px;
    }

    /* --- Phase 4A: Notes panel full-screen --- */
    .notes-panel {
        top: 0;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        left: 0;
        right: 0;
        border-radius: 0;
        padding-top: env(safe-area-inset-top, 0px);
    }

    .notes-sidebar {
        width: 100% !important;
        min-width: 100% !important;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 5;
    }

    .notes-sidebar-header {
        padding-top: calc(14px + env(safe-area-inset-top, 0px));
    }

    .notes-panel.note-open .notes-sidebar {
        display: none;
    }

    .notes-panel:not(.note-open) .notes-editor-wrap {
        display: none;
    }

    .notes-sidebar-resize {
        display: none;
    }

    .notes-mobile-back {
        display: block;
        background: none;
        border: none;
        color: var(--text-color);
        font-size: 32px;
        line-height: 1;
        cursor: pointer;
        padding: 4px 12px 4px 4px;
        font-family: var(--font-family);
        -webkit-tap-highlight-color: transparent;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .notes-editor {
        padding: 16px;
    }

    .notes-editor-header {
        padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 10px;
        display: flex;
        align-items: center;
    }

    /* --- Phase 5A: Context menus as bottom sheets --- */
    #context-menu,
    #hour-context-menu,
    #notes-context-menu,
    #notes-folder-context-menu,
    #notes-editor-context-menu,
    #theme-context-menu {
        position: fixed !important;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    .menu-item {
        padding: 14px 20px;
        font-size: 0.9em;
    }

    .color-presets {
        padding: 14px 20px;
        gap: 12px;
    }

    .swatch {
        width: 36px;
        height: 36px;
    }

    /* --- Phase 5C: Tamagotchi, sync, toasts --- */
    .tamagotchi {
        display: none !important;
    }

    .sync-status {
        top: 4px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        font-size: 10px;
        padding: 4px 10px;
    }

    #toast-container {
        bottom: calc(64px + env(safe-area-inset-bottom, 0px));
        right: 10px;
        left: 10px;
    }

    .toast {
        max-width: 100%;
    }

    /* --- Phase 6: Settings modal bottom sheet --- */
    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: calc(100vh - 56px - env(safe-area-inset-bottom, 0px));
        border-left: none;
        border-right: none;
        border-bottom: none;
        transform: translateY(20px);
        opacity: 0;
    }

    .modal.open .modal-content {
        transform: translateY(0);
        opacity: 1;
    }

    .modal.closing .modal-content {
        transform: translateY(20px);
        opacity: 0;
    }

    .modal-header {
        position: sticky;
        top: 0;
        background: var(--bg-color);
        z-index: 1;
    }

    [data-light="true"] .modal-header {
        background: #f5f5f0;
    }

    .setting-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .setting-input.wide {
        width: 100%;
    }

    .confirm-dialog {
        max-width: 100%;
    }

    /* Show theme section in settings on mobile */
    .settings-theme-section {
        display: block !important;
    }

    .settings-theme-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 4px 0;
    }

    .settings-theme-grid .theme-btn {
        width: 40px;
        height: 40px;
    }

    .settings-theme-grid .add-theme-btn {
        width: 40px;
        height: 40px;
        margin-top: 0;
    }

    .color-picker-popup {
        position: fixed !important;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        min-width: 100% !important;
        transform: none !important;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    .color-picker-popup.open {
        transform: none !important;
    }

    /* --- Phase 7A: Touch behavior --- */
    .mobile-nav-btn,
    .toggle-btn,
    .theme-btn,
    .setting-btn,
    .setting-toggle,
    .notes-new-btn,
    .notes-mobile-back,
    .modal-close,
    .menu-item,
    .swatch,
    .notes-list-item,
    .notes-folder-item {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .calendar-grid {
        user-select: none;
    }

    .task-area,
    .hour-task,
    .notes-editor {
        user-select: text;
    }

    /* --- Phase 8: PWA standalone polish --- */
    @media (display-mode: standalone) {
        .month-header-sticky {
            top: env(safe-area-inset-top, 0px);
        }

        body {
            padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
        }
    }
}

