* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Dark theme (default) */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --border: #2a2a4a;
    --success: #4ecca3;

    /* Mood colors */
    --mood-great: #4ecca3;
    --mood-good: #7ed957;
    --mood-meh: #ffd93d;
    --mood-bad: #ff8c42;
    --mood-awful: #e94560;
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8ed;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --accent: #d63050;
    --accent-hover: #e94560;
    --border: #d2d2d7;
    --success: #34c759;
}

/* System preference for light mode (when no user preference is set) */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg-primary: #f5f5f7;
        --bg-secondary: #ffffff;
        --bg-tertiary: #e8e8ed;
        --text-primary: #1d1d1f;
        --text-secondary: #6e6e73;
        --accent: #d63050;
        --accent-hover: #e94560;
        --border: #d2d2d7;
        --success: #34c759;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    line-height: 1.6;
}

/* Screen reader only - visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Remove default outline since we're using focus-visible */
:focus:not(:focus-visible) {
    outline: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    padding: 20px 0 30px;
}

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

.header-text {
    text-align: center;
    flex: 1;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.theme-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Show sun icon in dark mode, moon icon in light mode */
.icon-moon {
    display: none;
}

[data-theme="light"] .icon-sun {
    display: none;
}

[data-theme="light"] .icon-moon {
    display: block;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .icon-sun {
        display: none;
    }
    :root:not([data-theme="dark"]) .icon-moon {
        display: block;
    }
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.05);
}

.dropzone-content svg {
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.dropzone-content p {
    margin: 5px 0;
}

.dropzone-content code {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* App Container */
.app {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 140px);
}

.hidden {
    display: none !important;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 15px;
}

.stats {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.separator {
    margin: 0 10px;
    opacity: 0.5;
}

.version-badge {
    font-family: monospace;
    font-size: 0.8rem;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    cursor: help;
    position: relative;
}

.version-badge::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 6px;
    padding: 6px 10px;
    background: #1a1a2e;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
    white-space: nowrap;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s;
    z-index: 100;
    pointer-events: none;
}

.version-badge:hover::after {
    opacity: 1;
    visibility: visible;
}

.version-badge.version-warning {
    background: #ff8c42;
    color: #1a1a2e;
    font-weight: bold;
}

.actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.checkbox-label input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--success);
    color: #1a1a2e;
    font-weight: 600;
}

.btn-primary:hover {
    background: #3db890;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

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

.export-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    min-width: 160px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 4px 0;
    margin-top: 4px;
}

.export-dropdown.open .export-menu {
    display: block;
}

.export-option {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.export-option:hover {
    background: var(--bg-tertiary);
}

.export-option:focus {
    outline: none;
    background: var(--bg-tertiary);
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 15px;
    flex: 1;
    min-height: 0;
}

/* Entries Panel */
.entries-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow-y: auto;
    contain: strict;
}

/* Mini Calendar */
.mini-calendar {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    display: none;  /* Hidden until backup is loaded */
}

.mini-calendar.visible {
    display: block;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.calendar-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.calendar-nav {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 4px;
    transition: all 0.2s;
}

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

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: all 0.15s;
}

.calendar-day:hover {
    background: var(--bg-tertiary);
}

.calendar-day:focus-visible {
    background: var(--bg-tertiary);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.calendar-day.other-month {
    opacity: 0.3;
}

.calendar-day.future {
    opacity: 0.3;
    cursor: default;
}

.calendar-day.future:hover {
    background: transparent;
}

.calendar-day.today {
    border: 1px solid var(--accent);
}

.calendar-day.selected {
    background: var(--accent);
    color: white;
}

.calendar-day.has-entry::after {
    content: '';
    position: absolute;
    bottom: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--mood-color, var(--text-secondary));
}

.calendar-day.has-entry.selected::after {
    bottom: 1px;
}

.search-box {
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

.search-box input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Date Filter */
.date-filter {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
}

.date-filter select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
}

.date-filter select:focus {
    outline: none;
    border-color: var(--accent);
}

.custom-date-range {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.custom-date-range span {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.custom-date-range input[type="date"] {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.custom-date-range input[type="date"]:focus {
    outline: none;
    border-color: var(--accent);
}

.entries-list {
    flex: 1;
    padding: 10px;
}

/* Entry Item */
.entry-item {
    padding: 12px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
    margin-bottom: 5px;
    height: 68px;
    box-sizing: border-box;
    overflow: hidden;
}

/* Virtual scroll spacers */
.virtual-spacer {
    pointer-events: none;
}

.entry-item:hover {
    background: var(--bg-tertiary);
}

.entry-item:focus-visible {
    background: var(--bg-tertiary);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.entry-item.active {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent);
}

.entry-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.entry-date {
    font-weight: 500;
}

.entry-indicators {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.entry-header .mood-badge {
    margin-left: auto;
    font-size: 0.9rem;
}

.entry-preview {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-preview mark {
    background: var(--accent);
    color: white;
    padding: 0 2px;
    border-radius: 2px;
}

.entry-no-note {
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.6;
}

.photo-icon {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-left: 8px;
    margin-right: auto;
}

/* Mood Badge */
.mood-badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.mood-1 { background: var(--mood-great); color: #1a1a2e; }
.mood-2 { background: var(--mood-good); color: #1a1a2e; }
.mood-3 { background: var(--mood-meh); color: #1a1a2e; }
.mood-4 { background: var(--mood-bad); color: #1a1a2e; }
.mood-5 { background: var(--mood-awful); color: white; }

/* Editor Panel */
.editor-panel {
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.editor-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
}

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

.editor-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Activities Section */
.activities-section {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.activities-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.activity-chip {
    display: inline-block;
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* Activity indicator in entry list */
.activity-indicator {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.editor-field {
    margin-bottom: 15px;
}

.editor-field label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.editor-field input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.editor-field input:focus {
    outline: none;
    border-color: var(--accent);
}

.editor-field-note {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Quill Editor Styling */
#noteEditor {
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

#noteEditor.ql-container {
    height: 250px;
    min-height: 100px;
    max-height: 70vh;
    resize: vertical;
    overflow: auto;
    border: 1px solid var(--border) !important;
    border-top: none !important;
    border-radius: 0 0 6px 6px !important;
    background: var(--bg-primary);
    font-size: 0.95rem;
    font-family: inherit;
}

.ql-editor {
    color: var(--text-primary);
    line-height: 1.7;
    padding: 15px;
}

.ql-editor.ql-blank::before {
    color: var(--text-secondary);
    font-style: normal;
}

.ql-toolbar {
    border: 1px solid var(--border) !important;
    border-radius: 6px 6px 0 0 !important;
    background: var(--bg-tertiary);
}

.ql-toolbar .ql-stroke {
    stroke: var(--text-secondary);
}

.ql-toolbar .ql-fill {
    fill: var(--text-secondary);
}

.ql-toolbar .ql-picker {
    color: var(--text-secondary);
}

.ql-toolbar button:hover .ql-stroke,
.ql-toolbar button.ql-active .ql-stroke {
    stroke: var(--accent);
}

.ql-toolbar button:hover .ql-fill,
.ql-toolbar button.ql-active .ql-fill {
    fill: var(--accent);
}

.ql-toolbar button:hover,
.ql-toolbar button.ql-active {
    color: var(--accent);
}

.ql-editor ul,
.ql-editor ol {
    padding-left: 1.5em;
}

.ql-editor li {
    margin-bottom: 0.5em;
}

.editor-footer {
    margin-top: 10px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.revert-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.revert-btn:hover {
    background: rgba(233, 69, 96, 0.1);
    text-decoration: underline;
}

.revert-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.revert-btn.hidden {
    display: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

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

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

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

/* Emoji Picker */
.emoji-picker-popup {
    position: fixed;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    overflow: hidden;
}

.emoji-picker-popup.hidden {
    display: none;
}

/* Dark theme for emoji-picker-element */
emoji-picker {
    --background: var(--bg-secondary);
    --border-color: var(--border);
    --indicator-color: var(--accent);
    --input-border-color: var(--border);
    --input-font-color: var(--text-primary);
    --input-placeholder-color: var(--text-secondary);
    --outline-color: var(--accent);
    --category-font-color: var(--text-secondary);
    --button-active-background: var(--bg-tertiary);
    --button-hover-background: var(--bg-tertiary);
    --secondary-text-color: var(--text-secondary);
    --emoji-padding: 0.4rem;
    --num-columns: 8;
    height: 350px;
}

/* Emoji button in toolbar */
.ql-emoji {
    width: 28px !important;
    height: 24px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
}

/* Undo/Redo buttons in toolbar */
.ql-undo,
.ql-redo {
    width: 28px !important;
    height: 24px !important;
    position: relative;
}

.ql-undo::before,
.ql-redo::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background-color: var(--text-secondary);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.ql-undo::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7v6h6'/%3E%3Cpath d='M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7v6h6'/%3E%3Cpath d='M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13'/%3E%3C/svg%3E");
}

.ql-redo::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 7v6h-6'/%3E%3Cpath d='M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 7v6h-6'/%3E%3Cpath d='M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7'/%3E%3C/svg%3E");
}

.ql-undo:hover::before,
.ql-redo:hover::before {
    background-color: var(--accent);
}

.ql-emoji::before {
    content: '😊';
}

/* Photo Section */
.photo-section {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
}

.photo-section label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.photo-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.photo-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.photo-thumbnail:hover {
    border-color: var(--accent);
    transform: scale(1.05);
}

.photo-thumbnail:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.photo-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Photo Lightbox */
.photo-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 5px 10px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.lightbox-close:hover {
    opacity: 1;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 15px 20px;
    border-radius: 4px;
    opacity: 0.7;
    transition: all 0.2s;
}

.lightbox-nav:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: -80px;
}

.lightbox-next {
    right: -80px;
}

.lightbox-counter {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Insights Modal */
.insights-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.insights-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
}

.insights-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: 12px;
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.insights-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 1;
}

.insights-header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
}

.insights-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.insights-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

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

.insights-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.insights-body {
    padding: 25px;
}

.insights-section {
    margin-bottom: 30px;
}

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

.insights-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Quick Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Year in Pixels */
.year-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.year-nav-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.year-nav-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.year-nav-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.year-label {
    font-size: 1.2rem;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

.year-pixels-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.month-labels {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 2px;
}

.month-label {
    height: 12px;
    font-size: 0.65rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.year-pixels-grid {
    display: grid;
    grid-template-columns: repeat(31, 12px);
    grid-template-rows: repeat(12, 12px);
    gap: 2px;
}

.pixel {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: transform 0.1s, opacity 0.1s;
}

.pixel:hover {
    transform: scale(1.3);
    z-index: 1;
}

.pixel.mood-1 { background: var(--mood-great); }
.pixel.mood-2 { background: var(--mood-good); }
.pixel.mood-3 { background: var(--mood-meh); }
.pixel.mood-4 { background: var(--mood-bad); }
.pixel.mood-5 { background: var(--mood-awful); }
.pixel.empty { background: var(--bg-tertiary); opacity: 0.3; }

.pixel[title] {
    position: relative;
}

/* Mood Legend */
.mood-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-color.mood-1 { background: var(--mood-great); }
.legend-color.mood-2 { background: var(--mood-good); }
.legend-color.mood-3 { background: var(--mood-meh); }
.legend-color.mood-4 { background: var(--mood-bad); }
.legend-color.mood-5 { background: var(--mood-awful); }
.legend-color.mood-empty { background: var(--bg-tertiary); opacity: 0.3; }

/* Mood Breakdown */
.mood-breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mood-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mood-bar-label {
    width: 60px;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.mood-bar-container {
    flex: 1;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.mood-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.mood-bar.mood-1 { background: var(--mood-great); }
.mood-bar.mood-2 { background: var(--mood-good); }
.mood-bar.mood-3 { background: var(--mood-meh); }
.mood-bar.mood-4 { background: var(--mood-bad); }
.mood-bar.mood-5 { background: var(--mood-awful); }

.mood-bar-percent {
    width: 50px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: right;
}

/* Insights Filters */
.insights-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 24px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    min-width: 160px;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.filter-summary {
    margin-left: auto;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Mood Trends Chart */
.mood-trends-container {
    width: 100%;
    overflow-x: auto;
}

.mood-trends-chart {
    width: 100%;
    min-width: 400px;
    height: 200px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.mood-trends-chart .axis-line {
    stroke: var(--border-color);
    stroke-width: 1;
}

.mood-trends-chart .grid-line {
    stroke: var(--border-color);
    stroke-width: 0.5;
    opacity: 0.3;
}

.mood-trends-chart .trend-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
}

.mood-trends-chart .trend-area {
    fill: var(--accent);
    opacity: 0.1;
}

.mood-trends-chart .data-point {
    fill: var(--accent);
    cursor: pointer;
}

.mood-trends-chart .data-point:hover {
    r: 6;
}

.mood-trends-chart .axis-label {
    font-size: 10px;
    fill: var(--text-secondary);
}

.mood-trends-chart .mood-label {
    font-size: 9px;
    fill: var(--text-secondary);
}

/* Top Activities */
.top-activities {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.co-occurring-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-style: italic;
}

.activity-stat {
    display: flex;
    align-items: center;
    gap: 12px;
}

.activity-stat-name {
    width: 140px;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-stat-bar-container {
    flex: 1;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.activity-stat-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.activity-stat-count {
    width: 60px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: right;
}

.activity-stat-mood {
    width: 50px;
    font-size: 0.85rem;
    text-align: center;
}

/* Entries per Month */
.entries-per-month {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 150px;
    padding: 10px 0;
}

.month-bar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.month-bar {
    width: 100%;
    max-width: 40px;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
    transition: height 0.3s ease;
    cursor: pointer;
    margin-top: auto; /* Push bar to bottom so it grows upward */
}

.month-bar:hover {
    opacity: 0.8;
}

.month-bar-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
    text-align: center;
}

.month-bar-count {
    font-size: 0.7rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.no-data-message {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .entries-panel {
        max-height: 300px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-nav {
        padding: 10px 15px;
        font-size: 1.2rem;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 380px;
    pointer-events: auto;
    animation: toast-in 0.3s ease;
}

.toast.toast-out {
    animation: toast-out 0.3s ease forwards;
}

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

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

.toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    word-wrap: break-word;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.toast-close:hover {
    opacity: 1;
}

/* Toast types */
.toast-error {
    border-color: var(--accent);
}

.toast-error .toast-icon {
    color: var(--accent);
}

.toast-error .toast-title {
    color: var(--accent);
}

.toast-success {
    border-color: var(--success);
}

.toast-success .toast-icon {
    color: var(--success);
}

.toast-success .toast-title {
    color: var(--success);
}

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

.toast-warning .toast-icon {
    color: #ff8c42;
}

.toast-warning .toast-title {
    color: #ff8c42;
}

.toast-info {
    border-color: var(--text-secondary);
}

.toast-info .toast-icon {
    color: var(--text-secondary);
}
