:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #22d3ee;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark: #0f172a;
    --gray: #334155;
    --light-gray: #e2e8f0;
    --white: #ffffff;
    --shadow: 0 4px 6px rgb(0 0 0 / 0.12);
    --shadow-lg: 0 10px 15px rgb(0 0 0 / 0.15);
    --radius: 8px;
    --transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Minimal scrollbar — all scrollable elements */
* {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

*::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

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

*::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 99px;
}

*::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

*::-webkit-scrollbar-button {
    display: none;
}

body.dark * {
    scrollbar-color: #374151 transparent;
}

body.dark *::-webkit-scrollbar-thumb {
    background: #374151;
}

body.dark *::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

body.dark {
    --dark: #f3f4f6;
    --gray: #9ca3af;
    --light-gray: #1f2937;
    --white: #111827;
    --shadow: 0 2px 4px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 4px 12px rgb(0 0 0 / 0.5);
    background: #0f172a;
    color: #f3f4f6;
}

body.dark .header {
    background: transparent;
    border-bottom: none;
}

body.dark .main {
    background: transparent;
}

body.dark .card,
body.dark .weeks-grid,
body.dark .stats-container,
body.dark .stat-card,
body.dark .eras-panel,
body.dark .journal-customize-dropdown,
body.dark .journal-entry-box,
body.dark .life-stat,
body.dark .modal-content,
body.dark .chart-container,
body.dark .insights {
    background: #1e293b;
    border-color: #334155;
    color: #f3f4f6;
}

body.dark .view-toggle-track {
    background: #374151;
    border-color: #4b5563;
}

body.dark .setting-item label,
body.dark h2,
body.dark h3 {
    color: #f3f4f6;
}

body.dark .weeks-grid {
    background: #0f172a;
}

body.dark textarea,
body.dark input[type="text"]:not(.milestone-title-input),
body.dark input[type="date"],
body.dark input[type="number"],
body.dark select {
    background: #0f172a;
    color: #f3f4f6;
    border-color: #334155;
}

body.dark textarea:focus,
body.dark input:focus,
body.dark select:focus {
    border-color: var(--primary-color);
}

body.dark .nav-btn {
    color: #cbd5e1;
}

body.dark .nav-btn:hover {
    background: #334155;
    color: #f3f4f6;
}

body.dark .nav-btn.active {
    background: var(--primary-color);
    color: #ffffff;
}

body.dark .btn-secondary {
    background: #334155;
    color: #f3f4f6;
    border-color: #475569;
}

body.dark .btn-secondary:hover {
    background: #475569;
}

body.dark .btn-icon {
    border-color: #334155;
    color: #9ca3af;
}

body.dark .btn-icon:hover {
    background: #334155;
    color: #f3f4f6;
}

body.dark .journal-item:hover {
    background: #334155;
}

body.dark .journal-item.active {
    background: rgba(99, 102, 241, 0.2);
}

body.dark .journal-filter-bar input {
    background: #0f172a;
    border-color: #334155;
    color: #f3f4f6;
}

/* Dark mode calendar icon inversion */
body.dark input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.8;
}

body.dark input[type="date"]:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

body.dark .era-timeline-date:focus {
    background: #0f172a;
    color: #f3f4f6;
    border-color: #334155;
}

body.dark .week-box.past {
    background: #374151;
}

body.dark .week-box.future {
    background: #1f2937;
    border-color: #374151;
}

body.dark .week-box.current {
    background: var(--primary-color);
}

body.dark .progress-bar {
    background: #374151;
}

body.dark .setting-group {
    border-color: #334155;
}

/* View-only mode refinements */
body.view-only .nav,
body.view-only #settings-toggle,
body.view-only #journal-view {
    display: none !important;
}

body.view-only #life-view {
    display: block !important;
}

body.view-only .header .container {
    justify-content: center;
}

body.view-only .header-actions {
    position: absolute;
    right: 20px;
}


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

html {
    /* Always show scrollbar to prevent layout shift between pages */
    overflow-y: scroll;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--light-gray);
    min-height: 100vh;
    color: var(--dark);
    zoom: 80%;
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: transparent;
    border-bottom: none;
    padding: 1rem 0;
    position: static;
    z-index: 50000;
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    cursor: pointer;
    user-select: none;
}

.nav {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background-color 0.15s ease, color 0.15s ease;
    color: var(--gray);
    font-weight: 500;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

/* Invisible bold clone reserves width so active state doesn't shift layout */
.nav-btn::after {
    content: attr(data-text);
    font-weight: 600;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    user-select: none;
}

.nav-btn:hover {
    background: var(--light-gray);
    color: var(--dark);
}

.nav-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    font-weight: 600;
}

/* Main Content */
.main {
    padding: 2rem 0;
}

.view {
    display: none;
    background: transparent;
    padding: 2rem;
    margin-bottom: 2rem;
}

.view.active {
    display: block;
}

/* Life Grid View */
.life-info {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    background: transparent;
}


.btn-gear {
    background: none;
    border: 1px solid var(--light-gray);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    color: var(--gray);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.btn-gear:hover {
    background: var(--light-gray);
    color: var(--dark);
}

.btn-gear.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}


.view-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.view-toggle-input {
    display: none;
}

.view-toggle-label {
    font-size: 0.8rem;
    color: var(--gray);
    font-weight: 500;
    transition: color 0.15s ease;
}

.view-toggle-track {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--light-gray);
    border-radius: 999px;
    transition: background 0.15s ease;
    flex-shrink: 0;
    border: 1px solid #d1d5db;
}

.view-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease;
}

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

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

.view-toggle-input:checked~.view-toggle-label:last-child {
    color: var(--primary-color);
    font-weight: 600;
}

.life-stats {
    grid-column: 2;
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
}

.life-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: var(--white);
    border: 1px solid var(--light-gray);
    border-radius: 12px;
    padding: 0.6rem 1.25rem;
    min-width: 140px;
    white-space: nowrap;
    box-shadow: var(--shadow);
}

.life-stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--dark);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.life-stat-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.2rem;
}

.life-stat-sub {
    font-size: 0.68rem;
    color: var(--gray);
    margin-top: 0.1rem;
    opacity: 0.8;
}

body.dark .life-stat-value {
    color: #f1f5f9;
}

body.dark .life-stat-label {
    color: #94a3b8;
}

body.dark .life-stat-sub {
    color: #94a3b8;
}

.eras-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1000;
    width: 650px;
    max-width: 90vw;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body.dark .eras-panel {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
}

.life-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.life-filter label {
    font-weight: 500;
}

.life-filter select {
    min-width: 180px;
    padding: 0.5rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--radius);
    transition: var(--transition);
}

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

.age-input,
.life-expectancy {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.age-input label,
.life-expectancy label {
    font-weight: 500;
}

.age-input input,
.life-expectancy input {
    width: 80px;
    padding: 0.5rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
}

.age-input input[readonly] {
    background: var(--light-gray);
    color: var(--dark);
    cursor: not-allowed;
}

.age-input input:focus,
.life-expectancy input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.grid-container {
    margin-bottom: 2rem;
    overflow-x: auto;
}

#life-grid-container {
    position: relative;
}

.milestone-callouts {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.milestone-callout {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(31, 41, 55, 0.12);
    border-radius: 999px;
    box-shadow: var(--shadow);
    white-space: nowrap;
    transform-origin: left center;
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
}

.milestone-callout.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: transform 240ms ease, opacity 240ms ease;
}

.milestone-callout-emoji {
    font-size: 14px;
}

.milestone-callout-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dark);
}

.milestone-callout-line {
    position: absolute;
    width: 1px;
    background: rgba(31, 41, 55, 0.18);
    transform-origin: top;
    opacity: 0;
}

.milestone-callout-line.show {
    opacity: 1;
    transition: opacity 240ms ease;
}

.week-spacer {
    background: transparent;
    pointer-events: none;
}

.row-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 0.55rem;
    font-weight: 700;
    color: #ffffff;
    opacity: 1;
    line-height: 1;
    padding-right: 2px;
    user-select: none;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    gap: 2px;
}

.row-label-word {
    /* fixed-width so 'Age' aligns vertically */
    display: inline-block;
    width: 3ch;
    text-align: left;
}

.row-label-num {
    display: inline-block;
    width: 2ch;
    text-align: right;
}

.weeks-grid {
    display: grid;
    grid-template-columns: repeat(52, 1fr);
    gap: 2px;
    padding: 1rem;
    background: var(--light-gray);
    border-radius: var(--radius);
    width: 100%;
}

.weeks-grid.milestones-expanded {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 1.5rem;
    justify-content: center;
    grid-template-columns: none;
    /* override grid */
}

.weeks-grid.milestones-expanded .row-label {
    display: none;
}

.weeks-grid.milestones-expanded .week-box {
    display: flex;
    grid-column: unset;
    grid-row: unset;
    aspect-ratio: unset;
    height: 30px;
    /* Reduced from 38px */
    width: 12px;
    /* Increased from 8px for empty weeks */
    border-radius: 8px;
    flex-shrink: 0;
    justify-content: center;
    align-items: center;
}

.week-box {
    aspect-ratio: 1;
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    width: 100%;
    contain: layout;
}

.week-box.filtered-out {
    opacity: 0.1 !important;
    pointer-events: none;
    filter: grayscale(1);
}

.week-box:hover {
    transform: scale(1.15);
    z-index: 10;
    transition: transform 100ms ease-out;
    filter: brightness(0.6);
}

.week-tooltip {
    position: fixed;
    z-index: 20000;
    min-width: 180px;
    max-width: 280px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    padding: 0.6rem 0.75rem;
    pointer-events: none;
}

.week-tooltip-title {
    font-weight: 700;
    color: #f1f5f9;
    margin-bottom: 0.25rem;
}

.week-tooltip-meta {
    font-size: 0.875rem;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.week-tooltip-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.week-tooltip-tag {
    font-size: 0.75rem;
    color: #e2e8f0;
    background: #334155;
    border-radius: 999px;
    padding: 0.15rem 0.45rem;
}

.week-tooltip-text {
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.4;
    white-space: pre-wrap;
    margin-top: 0.3rem;
    border-top: 1px solid #334155;
    padding-top: 0.3rem;
}

.week-tooltip-era {
    font-size: 0.75rem;
    color: #818cf8;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.week-tooltip-mood {
    font-size: 0.8rem;
    color: #94a3b8;
    font-style: italic;
}

.emoji-picker {
    position: fixed;
    z-index: 30000;
    width: 320px;
    max-width: calc(100vw - 24px);
    background: var(--white);
    border: 1px solid var(--light-gray);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    padding: 0.75rem;
}

.emoji-search {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 2px solid var(--light-gray);
    border-radius: 10px;
    transition: var(--transition);
    background: var(--white);
    color: var(--dark);
    font-size: 0.9rem;
    box-sizing: border-box;
}

.emoji-search:focus {
    outline: none;
    border-color: var(--primary-color);
}

.emoji-grid {
    margin-top: 0.6rem;
    max-height: 260px;
    overflow-x: hidden;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    gap: 0.25rem;
    padding: 0.25rem;
}

.emoji-btn {
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0.45rem 0;
    transition: background 0.1s, border-color 0.1s;
}

.emoji-btn:hover {
    background: var(--light-gray);
    border-color: rgba(99, 102, 241, 0.25);
}

body.dark .emoji-picker {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

body.dark .emoji-search {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark .emoji-search::placeholder {
    color: #64748b;
}

body.dark .emoji-search:focus {
    border-color: var(--primary-color);
}

body.dark .emoji-btn:hover {
    background: #334155;
    border-color: rgba(99, 102, 241, 0.3);
}

@media (max-width: 480px) {
    .emoji-grid {
        grid-template-columns: repeat(8, 1fr);
    }
}

.week-box.past {
    background: #334155;
    /* Slate-700 */
}

.week-box.current {
    background: var(--primary-color);
    animation: pulse 2s infinite;
    box-shadow: 0 0 12px var(--primary-color);
}

.week-box.future {
    background: #e2e8f0;
    /* Muted Light Gray */
    border: 1px solid rgba(0, 0, 0, 0.05);
}

body.dark .week-box.future {
    background: #334155;
    /* Match deep slate 700 of past boxes */
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.week-box.journal {
    background: #312e81;
    /* Indigo-900 */
}

.week-box.milestone {
    background: #064e3b;
    /* Emerald-900 */
}

.week-box.era {
    opacity: 1;
}

.week-box.milestone.milestone-card {
    grid-column: unset;
    grid-row: unset;
    aspect-ratio: unset;
    border-radius: 8px;
    padding: 0 0.7rem;
    /* slightly tighter padding */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #065f46;
    height: 30px;
    /* matched unified height */
    width: auto;
    min-width: fit-content;
    flex: 0 0 auto;
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: transform 0.15s ease, background 0.15s ease;
    color: #fff;
}

/* Ensure regular journal entries that aren't milestones look consistent in grid */
.week-box.journal.milestone-card {
    background: #3730a3;
    /* Deeper Indigo (800) */
    border-color: rgba(0, 0, 0, 0.1);
}

.week-box.milestone-card.card-skinny {
    padding: 0;
    justify-content: center;
    min-width: 30px;
    width: 30px;
}

.week-box.birthday-card {
    grid-column: unset;
    grid-row: unset;
    aspect-ratio: unset;
    border-radius: 8px;
    padding: 0 0.7rem;
    display: flex;
    align-items: center;
    background: #334155;
    border: 1px solid rgba(255, 255, 255, 0.1);
    height: 30px;
    /* matched unified height */
    width: auto;
    min-width: fit-content;
    flex: 0 0 auto;
    color: #fff;
}

.week-box.birthday-card.future {
    background: #4b5563;
    /* Grey for future birthdays */
}

body.dark .week-box.birthday-card {
    background: #1e293b;
}

body.dark .week-box.birthday-card.future {
    background: #4b5563;
}


.birthday-card-text {
    font-size: 15px;
    font-weight: 800;
    color: #ffffff !important;
    white-space: nowrap;
    line-height: 1.2;
}

body.dark .week-box.birthday-card {
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark .birthday-card-text {
    color: #fff;
}

.week-box.milestone.milestone-card:hover {
    transform: scale(1.02);
}

.milestone-card-emoji {
    font-size: 16px;
    line-height: 1;
    flex: 0 0 auto;
}

.milestone-card-title {
    font-weight: 700;
    color: #fff;
    font-size: 15px;
    /* Slightly larger for readability */
    line-height: 1.2;
    /* Room for descenders */
    white-space: nowrap;
    overflow: visible;
    padding-bottom: 2px;
    /* Bottom alignment tweak */
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.legend {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-item .week-box {
    width: 20px;
    height: 20px;
}

/* Milestones View */
.milestones-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.milestones-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.milestones-subtitle {
    color: var(--gray);
}

.milestones-timeline {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.weeks-grid.milestones-expanded .week-box:not(.milestone-card):not(.birthday-card) {
    background: #334155;
    /* Slate-700 */
    border: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark .weeks-grid.milestones-expanded .week-box:not(.milestone-card):not(.birthday-card) {
    background: #334155;
    /* Slate-700 */
    border-color: rgba(255, 255, 255, 0.05);
}


.timeline-current {
    position: absolute;
    inset: 0;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 999px;
    transition: width 0.3s ease;
}

.timeline-markers {
    position: absolute;
    inset: 0;
}

.timeline-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.timeline-marker:hover {
    transform: translate(-50%, -50%) scale(1.15);
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    color: var(--gray);
    font-size: 0.875rem;
}

.milestones-content {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.milestones-empty {
    color: var(--gray);
    text-align: center;
    padding: 2rem 0;
}

.milestones-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.milestone-item {
    border: 1px solid var(--light-gray);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.milestone-item:hover {
    border-color: rgba(99, 102, 241, 0.35);
    box-shadow: var(--shadow);
}

.milestone-title {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 0.25rem;
}

.milestone-meta {
    color: var(--gray);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.milestone-preview {
    color: var(--dark);
    line-height: 1.45;
}

/* Journal View */
.journal-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: stretch;
    min-width: 0;
    transition: all 0.25s ease-out;
}

.journal-container.hide-dates {
    grid-template-columns: 180px 1fr;
    gap: 1.5rem;
}

.journal-sidebar {
    background: transparent;
    border-radius: var(--radius);
    padding: 1rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: padding 0.25s ease-out;
    height: 0;
    min-height: 100%;
}

.journal-container.hide-dates .journal-sidebar {
    padding: 0.75rem 0.5rem;
}

.journal-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.journal-list-header h3 {
    margin: 0;
    color: var(--dark);
}

.journal-list-actions {
    display: flex;
    gap: 0.25rem;
}

.btn-icon {
    background: none;
    border: 1px solid var(--light-gray);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    font-size: 0.95rem;
    cursor: pointer;
    color: var(--gray);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    padding: 0;
}

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

.btn-icon.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.journal-filter-bar {
    margin-bottom: 0.5rem;
}

.journal-filter-bar input {
    width: 100%;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--light-gray);
    border-radius: 6px;
    font-size: 0.8rem;
    outline: none;
    box-sizing: border-box;
    background: var(--white);
}

.journal-filter-bar input:focus {
    border-color: var(--primary-color);
}

.journal-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    flex: 1;
    margin-top: 0.5rem;
    padding-right: 4px;
}

.journal-item {
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 30px;
    flex-shrink: 0;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.1;
}

.journal-item:hover {
    background: var(--light-gray);
}

.journal-item.active,
.journal-item-current {
    background: rgba(99, 102, 241, 0.12);
    border-left-color: var(--primary-color);
    border-radius: 0 4px 4px 0;
}

body.dark .journal-item.active,
body.dark .journal-item-current {
    background: rgba(99, 102, 241, 0.25);
    border-left-color: #818cf8;
}

.ji-date {
    font-size: 0.72rem;
    color: var(--gray);
    opacity: 0.85;
    white-space: nowrap;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    letter-spacing: -0.01em;
}

body.dark .ji-date {
    color: #64748b;
}

body.dark .journal-item-current {
    border-left-color: #818cf8;
}

.journal-item-new {
    opacity: 0.5;
    border: 1px dashed var(--gray);
    margin-bottom: 0.35rem;
    transition: opacity 0.15s, border-color 0.15s;
}

.journal-item-new:hover {
    opacity: 1;
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.04);
}

.ji-meta-new {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.ji-preview-new {
    font-size: 0.75rem;
    color: var(--gray);
}

body.dark .journal-item-new {
    border-color: #4b5563;
}

body.dark .journal-item-new:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.08);
}

.ji-meta {
    font-size: 0.75rem;
    color: var(--gray);
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.ji-emoji {
    display: inline-flex;
    justify-content: center;
    width: 20px;
    margin-right: 4px;
    flex-shrink: 0;
    font-size: 0.95rem;
    /* Slightly larger for readability, still shrunken from 1rem */
}

.ji-label {
    width: 85px;
    display: inline-block;
    flex-shrink: 0;
    transition: width 0.2s ease;
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, monospace;
    font-size: 0.72rem;
    letter-spacing: -0.01em;
}

.journal-container.hide-dates .ji-label {
    width: auto;
    flex: 1;
}

.ji-preview {
    font-size: 0.8rem;
    color: var(--dark);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.journal-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.journal-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.journal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--light-gray);
    flex-wrap: nowrap;
    overflow: hidden;
    min-width: 0;
}

.journal-header h2 {
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 1.1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.journal-header-mid {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.journal-week-title {
    font-size: 0.75rem;
    color: var(--gray);
    font-weight: 500;
    white-space: nowrap;
    opacity: 0.8;
}

.headline-emoji-btn {
    font-size: 1.4rem;
    padding: 0 4px;
    margin-right: -4px;
    transition: transform 0.1s ease;
}

.headline-emoji-btn:hover {
    transform: scale(1.15);
}

.milestone-toggle-inline {
    flex-shrink: 0;
}

.journal-header .journal-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    margin-left: auto;
}

.mood-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.mood-container {
    margin-bottom: 1.5rem;
    width: 100%;
}

.mood-text-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 150px;
    flex-shrink: 0;
    line-height: 1.25;
}

.mood-today-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.mood-result {
    font-weight: 800;
    cursor: text;
    border-bottom: 1px dashed transparent;
    border-radius: 2px;
    padding: 0;
    transition: border-color 0.15s, background 0.15s;
    outline: none;
    min-width: 4ch;
    display: inline-block;
    font-size: 1.1rem;
    color: var(--dark);
}

.mood-result:hover {
    border-bottom-color: var(--gray);
}

.mood-result:focus {
    border-bottom-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.06);
}

.mood-pad-wrap {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    background: var(--white);
    padding: 0.8rem 1.25rem;
    border-radius: 16px;
    border: 1px solid var(--light-gray);
    box-shadow: var(--shadow);
    width: 100%;
}

.emoji-btn-none {
    background: rgba(148, 163, 184, 0.08) !important;
    border: 1px dashed rgba(148, 163, 184, 0.3) !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.none-icon {
    width: 12px;
    height: 12px;
    border: 1.5px solid rgba(148, 163, 184, 0.5);
    border-radius: 50%;
    position: relative;
}

.none-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 1.5px;
    background: rgba(148, 163, 184, 0.5);
    transform: translate(-50%, -50%) rotate(-45deg);
}

body.dark .mood-pad-wrap {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.05);
}

.mood-pad-y-label {
    font-size: 0.7rem;
    color: var(--gray);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    user-select: none;
}

.mood-pad-col {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

.mood-pad-x-label {
    font-size: 0.7rem;
    color: var(--gray);
    text-align: right;
    user-select: none;
}

.mood-pad {
    position: relative;
    width: 100%;
    height: 100px;
    border-radius: var(--radius);
    cursor: crosshair;
    touch-action: none;
    /* Happiness (x): sad=left blue → happy=right yellow; Energy (y): low=bottom gray → high=top red */
    background: linear-gradient(to right, rgba(99, 102, 241, 0.25), rgba(251, 191, 36, 0.25)),
        linear-gradient(to top, rgba(107, 114, 128, 0.2), rgba(239, 68, 68, 0.25));
    border: 1px solid var(--light-gray);
}

.mood-pad-cursor {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.mood-meter {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.10), rgba(139, 92, 246, 0.10));
}

.mood-dim label {
    display: block;
    font-size: 0.875rem;
    color: var(--gray);
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.mood-dim input[type="range"] {
    width: 100%;
}

@media (max-width: 768px) {
    .mood-meter {
        grid-template-columns: 1fr;
    }
}

.mood-btn {
    border: 1px solid var(--light-gray);
    background: var(--white);
    border-radius: 999px;
    padding: 0.35rem 0.55rem;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
}

.mood-btn.selected {
    border-color: rgba(99, 102, 241, 0.35);
    background: rgba(99, 102, 241, 0.08);
}

.journal-customize-dropdown {
    position: fixed;
    z-index: 1000;
    background: var(--white);
    border: 1px solid var(--light-gray);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    padding: 1rem;
    min-width: 260px;
    max-width: 340px;
}

body.dark .journal-customize-dropdown {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.journal-customize-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.jc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--dark);
    cursor: pointer;
    padding: 0.15rem 0;
}

body.dark .jc-row {
    color: #e2e8f0;
}

.switch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--dark);
}

.journal-customize-sections-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.journal-customize-sections-title {
    font-weight: 700;
    margin-right: auto;
}

.template-sections-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.template-section-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.template-section-item input {
    flex: 1;
    padding: 0.5rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--radius);
}

.template-section-item input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.journal-actions {
    display: flex;
    gap: 0.5rem;
}

.journal-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.milestone-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.milestone-details {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    overflow: hidden;
    flex: 1;
}

.btn-emoji-bare {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0 0.1rem;
    line-height: 1;
    flex-shrink: 0;
}

.headline-seamless {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--light-gray);
    box-shadow: var(--shadow);
    border-radius: 28px;
    padding: 0 6px;
    gap: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
    min-width: 0;
    height: 54px;
}

.headline-seamless:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.headline-seamless:focus-within {
    background: rgba(148, 163, 184, 0.14);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

body.dark .headline-seamless {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark .headline-seamless:focus-within {
    background: rgba(255, 255, 255, 0.08);
}

.headline-emoji-trigger {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    padding: 0 0 3px 0;
    /* Nudge emoji up slightly for better centering */
    border-radius: 50%;
    transition: all 0.15s ease;
    opacity: 0.6;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

.headline-emoji-trigger.has-emoji {
    opacity: 0.95;
    transform: scale(1.05);
}

body.dark .headline-emoji-trigger {
    color: #fff;
    opacity: 0.5;
}

body.dark .headline-emoji-trigger.has-emoji {
    opacity: 1;
}

.headline-emoji-trigger:hover {
    opacity: 1;
    background: rgba(148, 163, 184, 0.15);
}

.milestone-title-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0 4px;
    color: var(--dark);
    outline: none;
}

.milestone-title-input::placeholder {
    color: var(--gray);
    font-weight: 400;
    opacity: 0.7;
}

.milestone-title-input:focus {
    outline: none;
}

body.dark .headline-seamless {
    background: rgba(255, 255, 255, 0.08);
}

body.dark .headline-seamless:focus-within {
    background: rgba(255, 255, 255, 0.12);
}

body.dark .milestone-title-input {
    color: #f1f5f9;
}

body.dark .btn-emoji-bare {
    color: #f3f4f6;
}

.journal-entry-box {
    border: 2px solid var(--light-gray);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--white);
    margin-bottom: 1rem;
}

.journal-entry-box #journal-text {
    border: none;
    border-radius: 0;
}

.journal-entry-box {
    position: relative;
}

.journal-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.75rem;
    font-size: 1rem;
    color: var(--gray);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    font-style: italic;
    line-height: 1.6;
    user-select: none;
}

.journal-placeholder.visible {
    opacity: 0.45;
}

body.dark .journal-placeholder {
    color: #9ca3af;
}

.tag-section.inside {
    padding: 0.1rem 0.75rem 0.75rem;
    margin-bottom: 0;
    background: transparent;
    border: none;
}

body.dark .tag-section.inside {
    background: transparent;
    border: none;
}

.tags-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.selected-tags {
    display: contents;
}

.selected-tags:empty::before {
    content: none;
}

#toggle-tag-picker {
    font-size: 0.8rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px dashed var(--gray);
    background: transparent;
    color: var(--gray);
    cursor: pointer;
    line-height: 1.4;
    box-shadow: none;
}

#toggle-tag-picker:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.tag-options {
    margin-top: 0.6rem;
    padding: 0.6rem;
    border: none;
    border-radius: var(--radius);
    background: rgba(243, 244, 246, 0.55);
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

body.dark .tag-options {
    background: rgba(15, 23, 42, 0.4);
}

.tag-chip {
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    background: var(--light-gray);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.tag-chip.selected {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.tag-chip-del {
    margin-left: 0.25rem;
    opacity: 0.4;
    font-size: 1rem;
    line-height: 1;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    padding-bottom: 2px;
}

.tag-chip:hover .tag-chip-del {
    opacity: 1;
    color: var(--primary-color);
}

/* removed duplicate headline-emoji-trigger */

.headline-emoji-trigger:hover {
    opacity: 1;
}

body.dark .headline-emoji-trigger {
    filter: grayscale(0.5);
}

body.dark .headline-emoji-trigger:hover {
    filter: none;
}

.sections-inline {
    margin-bottom: 1rem;
}

.sections-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    grid-auto-rows: 1fr;
    gap: 0.75rem;
    align-items: stretch;
    margin-top: 0.5rem;
}

.section-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius);
    background: var(--white);
    overflow: hidden;
    min-height: 140px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.section-card:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

.section-card-header {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.65rem 0.4rem;
    border-bottom: 1px solid var(--light-gray);
    background: transparent;
}

.section-card-title {
    flex: 1;
    min-width: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--dark);
    padding: 0;
    outline: none;
    letter-spacing: -0.01em;
    cursor: text;
    white-space: nowrap;
    overflow: hidden;
}

.section-card-title:empty::before {
    content: attr(data-placeholder);
    color: var(--gray);
    font-weight: 400;
    opacity: 0.6;
    pointer-events: none;
}

.section-card-del {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--gray);
    opacity: 0;
    line-height: 1;
    padding: 4px 6px;
    flex-shrink: 0;
    border-radius: 4px;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.section-card:hover .section-card-del,
.section-card:focus-within .section-card-del {
    opacity: 1;
}

.section-card-del:hover {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.08);
}

.section-card-text {
    flex: 1;
    width: 100%;
    border: none;
    resize: none;
    padding: 0.6rem 0.65rem;
    font-size: 0.82rem;
    line-height: 1.55;
    font-family: inherit;
    background: transparent;
    color: var(--dark);
    min-height: 80px;
    max-height: calc(1.55em * 10 + 1.2rem);
    outline: none;
    overflow-y: auto;
}

.section-card-text::placeholder {
    color: var(--gray);
    opacity: 0.6;
}

/* Ghost "add section" card */
.section-card-ghost {
    border: 1px dashed var(--gray);
    opacity: 0.5;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    cursor: pointer;
    padding: 1rem 0.75rem;
    text-align: center;
    transition: opacity 0.15s, border-color 0.15s, background 0.15s;
    min-height: 140px;
    border-radius: var(--radius);
}

.section-card-ghost:hover {
    opacity: 1;
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.04);
}

.section-card-ghost-plus {
    font-size: 1.5rem;
    color: var(--gray);
    line-height: 1;
    font-weight: 300;
}

.section-card-ghost-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray);
}

.section-card-ghost-hint {
    font-size: 0.68rem;
    color: var(--gray);
    opacity: 0.7;
    line-height: 1.4;
}

/* Dark mode */
body.dark .section-card {
    background: #1e293b;
    border-color: #2d3f55;
}

body.dark .section-card-header {
    background: transparent;
    border-bottom-color: #2d3f55;
}

body.dark .section-card-title {
    color: #e2e8f0;
}

body.dark .section-card-text {
    color: #cbd5e1;
    -webkit-text-fill-color: #cbd5e1;
    background: transparent;
    color-scheme: dark;
}

body.dark .section-card-ghost {
    border-color: #4b5563;
}

body.dark .section-card-ghost:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.08);
}

.toggle {
    display: flex;
    align-items: center;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--light-gray);
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--light-gray);
    border-radius: 999px;
    position: relative;
    transition: var(--transition);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--white);
    border-radius: 50%;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.toggle-text-left,
.toggle-text-right {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--gray);
    transition: var(--transition);
}

#milestone-toggle:checked+.toggle-label {
    border-color: rgba(16, 185, 129, 0.35);
}

#milestone-toggle:checked+.toggle-label .toggle-slider {
    background: rgba(16, 185, 129, 0.25);
}

#milestone-toggle:checked+.toggle-label .toggle-slider::after {
    transform: translateX(20px);
}

#milestone-toggle:not(:checked)+.toggle-label .toggle-text-left {
    color: var(--dark);
}

#milestone-toggle:checked+.toggle-label .toggle-text-right {
    color: var(--dark);
}

.tag-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.tag-header-title {
    font-weight: 600;
    color: var(--dark);
}

.tag-add {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag-add-panel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
}

.tag-add-panel input {
    padding: 0.5rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--radius);
    transition: var(--transition);
}

.tag-add-panel input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.tag-chip.add {
    border-style: dashed;
    border-color: rgba(99, 102, 241, 0.45);
    background: rgba(99, 102, 241, 0.10);
}

.tag-add select,
.tag-add input {
    padding: 0.5rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--radius);
    transition: var(--transition);
}

.tag-add select:focus,
.tag-add input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.tag-add input {
    min-width: 160px;
}

.milestone-details-old {
    background: rgba(16, 185, 129, 0.06);
    border: 1px solid rgba(16, 185, 129, 0.18);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.milestone-fields {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field label {
    font-size: 0.875rem;
    color: var(--gray);
    font-weight: 500;
}

.field select,
.field input {
    padding: 0.5rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--radius);
    transition: var(--transition);
}

.field select:focus,
.field input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--light-gray);
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--white);
    font-size: 0.875rem;
}

.tag-chip.selected {
    border-color: rgba(99, 102, 241, 0.35);
    background: rgba(99, 102, 241, 0.08);
}

.tag-chip:hover {
    border-color: rgba(99, 102, 241, 0.35);
}

body.dark .tag-options {
    background: #1e293b;
    border-color: #334155;
}

body.dark .tag-chip {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark .tag-chip.selected {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.5);
    color: #c7d2fe;
}

body.dark .tag-chip:hover {
    border-color: rgba(99, 102, 241, 0.5);
    background: #1e293b;
}

body.dark .tag-chip.add {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.4);
    color: #a5b4fc;
}

body.dark .tag-add-panel input,
body.dark #new-tag-text {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

.week-box.filtered-out {
    opacity: 0.22;
    filter: grayscale(1);
}

.journal-meta select,
.journal-meta input {
    flex: 1;
    padding: 0.5rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--radius);
    transition: var(--transition);
}

.journal-meta select:focus,
.journal-meta input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.journal-entry-box {
    position: relative;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius);
    background: var(--white);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

#journal-text {
    flex: none;
    width: 100%;
    display: block;
    padding: 1rem;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    min-height: 120px;
    max-height: calc(1.5em * 10 + 2rem);
    overflow-y: auto;
}

#journal-text:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Timeline View */
.timeline-container {
    padding: 2rem 0;
    position: relative;
    max-width: 900px;
    margin: 2rem auto;
}

.timeline-line {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--light-gray);
    z-index: 1;
}

body.dark .timeline-line {
    background: #334155;
}

.timeline-event {
    margin-bottom: 2rem;
    position: relative;
    width: 50%;
    padding: 0 40px;
    box-sizing: border-box;
}

.timeline-event:nth-child(odd) {
    left: 0;
    text-align: right;
}

.timeline-event:nth-child(even) {
    left: 50%;
    text-align: left;
}

.timeline-dot {
    position: absolute;
    top: 1rem;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 3px solid var(--white);
    box-shadow: 0 0 0 2px var(--light-gray);
    z-index: 2;
}

.timeline-event:nth-child(odd) .timeline-dot {
    right: -7px;
}

.timeline-event:nth-child(even) .timeline-dot {
    left: -7px;
}

body.dark .timeline-dot {
    border-color: #0f172a;
    box-shadow: 0 0 0 2px #334155;
}

.timeline-content {
    background: var(--white);
    padding: 0.85rem 1.15rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    display: inline-block;
    text-align: left;
    max-width: 100%;
}

body.dark .timeline-content {
    background: #1e293b;
    border-color: #334155;
}

.timeline-content:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

.timeline-week {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--gray);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timeline-header {
    margin-bottom: 0.5rem;
}

.timeline-event:nth-child(odd) .timeline-title {
    flex-direction: row-reverse;
}

.timeline-title {
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--dark);
}

body.dark .timeline-title {
    color: #f1f5f9;
}

.timeline-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--dark);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: 0.9;
}

body.dark .timeline-text {
    color: #cbd5e1;
}

/* Statistics View */
.stats-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card h3 {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-subtitle {
    font-size: 0.875rem;
    opacity: 0.8;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--white);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.chart-container {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.chart-container h3 {
    margin-bottom: 1rem;
    color: var(--dark);
}

.insights {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.insights h3 {
    margin-bottom: 1rem;
    color: var(--dark);
}

.insights-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.insight-item {
    padding: 1rem;
    background: var(--light-gray);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary-color);
}

/* Settings dropdown */
.btn-settings-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--gray);
    padding: 0.25rem 0.4rem;
    border-radius: var(--radius);
    line-height: 1;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.btn-settings-icon:hover {
    color: var(--dark);
    background: var(--light-gray);
}

body.dark .btn-settings-icon {
    color: #9ca3af;
}

body.dark .btn-settings-icon:hover {
    color: #f3f4f6;
    background: #334155;
}

.settings-dropdown {
    position: fixed;
    z-index: 1000;
    background: var(--white);
    border: 1px solid var(--light-gray);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    padding: 1rem;
    min-width: 260px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

body.dark .settings-dropdown {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.setting-group {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--light-gray);
}

.setting-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.setting-group h3 {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray);
    margin-bottom: 0.5rem;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--dark);
}

.setting-item input[type=date],
.setting-item input[type=number] {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--light-gray);
    border-radius: var(--radius);
    font-size: 0.85rem;
    width: 130px;
    background: var(--white);
    color: var(--dark);
}

.setting-item input:focus {
    outline: none;
    border-color: var(--primary-color);
}

body.dark .setting-item input[type=date],
body.dark .setting-item input[type=number] {
    background: #0f172a;
    border-color: #334155;
    color: #f3f4f6;
}

.setting-data-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.setting-data-btns .btn {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
}

.setting-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--dark);
}

/* Sun/Moon theme toggle */
.theme-toggle {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

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

.theme-toggle-track {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 56px;
    height: 26px;
    background: #e2e8f0;
    border-radius: 99px;
    padding: 0 4px;
    transition: background 0.2s;
    gap: 0;
    justify-content: space-between;
}

.theme-toggle-input:checked~.theme-toggle-track {
    background: #1e293b;
}

.theme-icon {
    font-size: 0.85rem;
    line-height: 1;
    z-index: 2;
    /* higher than thumb */
    user-select: none;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.theme-icon-sun {
    color: #94a3b8;
    /* Muted when inactive */
}

.theme-icon-moon {
    color: #64748b;
    /* Muted when inactive */
}

/* When unchecked (Light mode), Sun is active on the white thumb */
.theme-toggle-input:not(:checked)~.theme-toggle-track .theme-icon-sun {
    color: #f59e0b;
    /* Orange */
}

/* When checked (Dark mode), Moon is active on the white thumb */
.theme-toggle-input:checked~.theme-toggle-track .theme-icon-moon {
    color: #3b82f6;
    /* Blue, bolder to see against white */
}

.theme-toggle-thumb {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    left: 4px;
    top: 3px;
    transition: left 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1;
    /* Below the icons */
}

.theme-toggle-input:checked~.theme-toggle-track .theme-toggle-thumb {
    left: calc(100% - 24px);
}

/* Segmented control (Year / Age) */
.seg-control {
    display: inline-flex;
    background: var(--light-gray);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.seg-btn {
    border: none;
    background: none;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray);
    padding: 0.2rem 0.65rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.seg-btn.active {
    background: var(--white);
    color: var(--dark);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.seg-btn:not(.active):hover {
    color: var(--dark);
}

body.dark .seg-control {
    background: #0f172a;
}

body.dark .seg-btn.active {
    background: #334155;
    color: #f3f4f6;
}

body.dark .seg-btn:not(.active) {
    color: #9ca3af;
}

body.dark .seg-btn:not(.active):hover {
    color: #f3f4f6;
}

.era-list {
    display: flex;
    flex-direction: column;
    row-gap: 20px;
    margin-top: 0;
    padding: 0 40px 1rem 40px;
    /* Room for splines */
}

.era-panel-header {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0.5rem 0 3rem 0;
    color: var(--primary-color);
    text-align: center;
}

.era-timeline-row {
    display: flex;
    width: 100%;
}

.era-timeline-row-reverse {
    flex-direction: row-reverse !important;
}

.era-timeline-item {
    display: flex;
    flex-direction: column;
    width: 25%;
    position: relative;
    padding-bottom: 0px;
    align-items: center;
    /* Center children horizontally */
}

.era-timeline-name-wrap {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 20px;
    position: relative;
    text-align: center;
    margin-bottom: 0;
}

.era-timeline-name,
.era-timeline-date {
    background: transparent;
    font-family: inherit;
    border: none;
    padding: 2px 4px;
    margin: 0;
    /* Removed legacy offset */
    transition: all 0.2s;
}

.era-timeline-date {
    border: none !important;
    border-radius: 4px;
}

.era-timeline-name {
    font-weight: 600;
    font-size: 0.88rem;
    text-align: center;
    width: 100%;
    height: 20px;
    /* Locked height to eliminate gap */
    outline: none;
    background: none !important;
    resize: none;
    overflow: hidden;
    line-height: 1.2;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    margin: 0;
    color: inherit;
}

.era-timeline-date {
    font-size: 0.8rem;
    color: #fff !important;
    width: calc(100% - 10px);
    /* 5px gutter each side to match 6px path offset */
    box-sizing: border-box;
    text-align: center;
    cursor: pointer;
    outline: none;
    padding: 0;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px 6px 6px 0;
    /* Rule 3: Restored top radius, bottom-left square */
    margin: 0;
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
}

.era-timeline-row-reverse .era-timeline-date {
    border-radius: 6px 6px 0 6px;
    /* Rule 3: Top radius restored */
}

body.dark .era-timeline-date {
    color: #fff !important;
}

/* Calendar icon positioning */
.era-timeline-date::-webkit-calendar-picker-indicator {
    margin-left: -6px;
    /* Shifted 10px left from 4px */
    padding: 0;
    cursor: pointer;
    opacity: 0.9;
    filter: invert(1) brightness(2);
    /* Make icon white */
    transition: opacity 0.2s;
}

.era-timeline-date:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

.era-timeline-delete {
    opacity: 0;
    color: var(--danger-color);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    position: absolute;
    right: 0;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.era-timeline-item:hover .era-timeline-delete {
    opacity: 1;
}

.era-timeline-track {
    display: flex;
    align-items: center;
    width: 100%;
    position: relative;
    height: 20px;
}

.era-timeline-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    z-index: 20;
    /* Absolute Dot Supremacy */
}

.era-timeline-line {
    flex-grow: 1;
    height: 6px;
    z-index: 1;
    margin: 0 -4px;
    /* Rule: 4px overlap into 16px dot */
}

/* Stop lines at item edges so they meet splines perfectly without sticking out */
.era-timeline-row:not(.era-timeline-row-reverse) .era-timeline-item:last-child .era-timeline-line {
    margin-right: -3px;
    /* Hit the center of the 6px spline wall */
    width: calc(100% + 3px);
}

.era-timeline-row-reverse .era-timeline-item:last-child .era-timeline-line {
    margin-left: -3px;
    width: calc(100% + 3px);
}

/* Remove old internal bridging margins - items touch so lines naturally meet dots */
.era-timeline-row .era-timeline-item .era-timeline-line {
    margin-right: -4px;
    margin-left: -4px;
}

.era-timeline-date-wrap {
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    /* Locked Rule: 20px gap to track */
    width: 100%;
}

.era-timeline-connector {
    position: absolute;
    top: 46px;
    /* Starts at badge bottom (20 + 26) */
    left: 5px;
    /* (8px dot center - 3px half-width of 6px path) */
    width: 0;
    height: 34px;
    /* Rule: Reach 76px track center + 4px penetrate = 34px */
    z-index: 1;
    background: transparent !important;
    border-left: 6px solid;
    /* Thickness parity */
    border-top: none;
    border-color: inherit;
    pointer-events: none;
}

.era-timeline-connector-reverse {
    left: auto;
    right: 5px;
    border-left: none;
    border-right: 6px solid;
}

.era-timeline-connector-dashed {
    border-color: var(--gray) !important;
    border-style: dashed none none dashed;
}

.era-timeline-connector-reverse.era-timeline-connector-dashed {
    border-style: dashed dashed none none;
}

/* Timeline splines connecting edge modules to next row */
.era-timeline-spline {
    position: absolute;
    width: 24px;
    height: 112px;
    /* Row distance (106) + 6 thickness = 112px */
    border: 6px solid;
    box-sizing: border-box;
    z-index: 5;
    pointer-events: none;
}

.era-timeline-spline-right {
    right: -24px;
    top: 73px;
    /* Center 6px border on 76px track center */
    /* Center 6px border on 66px track center: (66 - 3) */
    border-left: none;
    border-radius: 0 32px 32px 0;
}

.era-timeline-spline-left {
    left: -24px;
    top: 73px;
    /* Center 6px border on 76px track center */
    /* Centered on 66px track center */
    border-right: none;
    border-radius: 32px 0 0 32px;
}

.era-timeline-ghost {
    opacity: 1;
    /* Rule: 100% opacity for ghost */
    transition: opacity 0.2s;
}

.era-timeline-ghost:hover {
    opacity: 1;
}

.era-timeline-ghost .era-timeline-dot {
    background: var(--gray);
}

.era-timeline-ghost .era-timeline-name {
    color: var(--gray);
}

.era-timeline-ghost .era-timeline-name::placeholder {
    color: var(--gray);
    opacity: 0.8;
}

.era-timeline-ghost .era-timeline-date,
.era-timeline-ghost .era-timeline-date::-webkit-datetime-edit,
.era-timeline-ghost .era-timeline-date::-webkit-datetime-edit-fields-wrapper,
.era-timeline-ghost .era-timeline-date::-webkit-datetime-edit-text,
.era-timeline-ghost .era-timeline-date::-webkit-datetime-edit-month-field,
.era-timeline-ghost .era-timeline-date::-webkit-datetime-edit-day-field,
.era-timeline-ghost .era-timeline-date::-webkit-datetime-edit-year-field {
    color: var(--gray) !important;
    background: transparent !important;
    /* Ensure background doesn't hide text */
}

.era-timeline-ghost .era-timeline-date::-webkit-calendar-picker-indicator {
    filter: invert(0.6) brightness(1.5) !important;
    /* Boost visibility */
    opacity: 1;
    cursor: pointer;
}

.era-timeline-line-dashed {
    background: transparent !important;
    border-top: 4px dashed var(--gray);
    height: 0;
}

.setting-group h3 {
    margin-bottom: 1rem;
    color: var(--dark);
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.setting-item label {
    font-weight: 500;
}

.setting-item input {
    padding: 0.5rem;
    border: 2px solid var(--light-gray);
    border-radius: var(--radius);
    transition: var(--transition);
}

.setting-item input[readonly] {
    background: var(--light-gray);
    color: var(--dark);
    cursor: not-allowed;
}

.setting-item input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-sm {
    padding: 0.35rem 0.85rem;
    font-size: 0.8rem;
}

.btn-saved {
    background: var(--success-color);
    color: var(--white);
    transition: background 0.2s ease;
}

.btn-saved:hover {
    background: #059669;
}

.btn-journal-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.3rem 0.4rem;
    border-radius: var(--radius);
    color: var(--gray);
    transition: background 0.15s, color 0.15s;
}

.btn-journal-icon:hover {
    background: var(--light-gray);
    color: var(--dark);
}

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

body.dark .btn-journal-icon {
    color: #9ca3af;
}

body.dark .btn-journal-icon:hover {
    background: #334155;
    color: #f3f4f6;
}

body.dark .btn-journal-icon--danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.btn-secondary {
    background: var(--gray);
    color: var(--white);
}

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

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

.btn-danger:hover {
    background: #dc2626;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--white);
    margin: 10% auto;
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--gray);
    transition: var(--transition);
}

.import-confirm {
    max-width: 380px;
    text-align: center;
    padding-bottom: 0.5rem;
}

.import-confirm h2 {
    margin-bottom: 0.75rem;
}

.import-warn {
    font-size: 0.9rem;
    color: var(--gray);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.import-warn strong {
    color: var(--danger-color);
}

.import-confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }

    .header .container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav {
        width: 100%;
        justify-content: center;
    }

    .life-info {
        flex-direction: column;
        gap: 1rem;
    }

    .journal-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .journal-sidebar {
        max-height: 200px;
    }

    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .weeks-grid {
        min-width: auto;
        grid-template-columns: repeat(26, 1fr);
    }

    .legend {
        gap: 1rem;
    }

    .modal-content {
        margin: 5% auto;
        width: 95%;
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .stat-cards {
        grid-template-columns: 1fr;
    }

    .weeks-grid {
        grid-template-columns: repeat(13, 1fr);
    }

    .journal-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .journal-actions {
        justify-content: center;
    }

    .journal-meta {
        flex-direction: column;
    }
}

/* View-Only Mode overrides */
body.view-only .header-actions,
body.view-only #save-journal,
body.view-only #delete-journal,
body.view-only #customize-journal,
body.view-only #toggle-tag-picker,
body.view-only .tag-add-panel,
body.view-only #add-template-section,
body.view-only .setting-data-btns,
body.view-only .section-card-actions {
    display: none !important;
}

body.view-only input,
body.view-only textarea,
body.view-only select {
    pointer-events: none;
    border-color: transparent !important;
    background: transparent !important;
    resize: none;
}

.filter-options-list {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.1s;
    user-select: none;
    color: var(--dark);
}

.filter-option-item:hover {
    background: var(--light-gray);
}

.filter-option-item.active {
    background: var(--primary-color);
    color: #fff;
}

.filter-option-emoji {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.filter-option-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.dark .filter-option-item {
    color: #e2e8f0;
}

body.dark .filter-option-item:hover {
    background: #334155;
}

body.dark .filter-option-item.active {
    background: var(--primary-color);
    color: #fff;
}