/* CSS Variables for Premium Theme */
:root {
    --bg-paper: #f8f5f2;
    --bg-paper-dark: #e8e6e1;
    --bg-card: #ffffff;
    --border-color: #eeeeee;
    --text-ink: #2c2c2c;
    --text-muted: #666;
    --accent-gold: #d4Af37;
    --accent-blue: #4a90e2;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.05);
    --shadow-book: 0 4px 8px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.1);
    --font-serif: 'Georgia', 'Times New Roman', serif;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
    --bg-paper: #1a1a1a;
    --bg-paper-dark: #121212;
    --bg-card: #242424;
    --border-color: #333333;
    --text-ink: #e0e0e0;
    --text-muted: #a0a0a0;
    --accent-gold: #ffd700;
    --accent-blue: #64b5f6;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-book: 0 4px 8px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.5);
}

/* Dark Mode Form Elements */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background-color: #333;
    color: var(--text-ink);
    border-color: #555;
    caret-color: white;
}

[data-theme="dark"] .nav-btn,
[data-theme="dark"] .btn,
[data-theme="dark"] button {
    color: var(--text-ink);
}

[data-theme="dark"] .nav-btn:hover {
    background-color: #444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-paper-dark);
    font-family: var(--font-sans);
    color: var(--text-ink);
    min-height: 100vh;
    overflow-y: auto;
    /* Enable native scroll */
}

#app {
    min-height: 100vh;
    width: 100%;
    position: relative;
    overflow: visible;
}

section {
    position: relative;
    /* Fixed: Changed from absolute to allow native scrolling */
    min-height: 100vh;
    background-color: var(--bg-paper-dark);
    display: none;
    /* Hide from flow */
}

section.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

/* Onboarding View */
.hero-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    text-align: center;
}

h1 {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-ink);
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 3rem;
}

.drop-zone {
    width: 100%;
    max-width: 500px;
    height: 300px;
    border: 2px dashed #ccc;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.02);
}

.drop-zone .icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.privacy-note {
    margin-top: 2rem;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.4);
    padding: 10px 20px;
    border-radius: 20px;
}

/* Book View */
.book-header {
    padding: 1rem 2rem;
    background: var(--bg-paper);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 20;
}

.book-header h2 {
    font-family: var(--font-serif);
}

.nav-btn {
    background: none;
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.nav-btn:hover {
    background: #eee;
}

.book-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    /* Removed flex to prevent height calculation issues causing background clipping */
    display: block;
}

.book-pages {
    width: 100%;
    max-width: 1000px;
    background: var(--bg-paper);
    padding: 4rem;
    min-height: 100%;
    box-shadow: var(--shadow-book);
    border-radius: 4px;
    margin: 0 auto;
    /* Center the book */
    text-align: left;
    /* Ensure text is left aligned despite parent potentially doing otherwise */
}

/* ... existing styles ... */

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    .book-pages {
        padding: 1.5rem;
        max-width: 100%;
    }

    .book-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
        padding: 1rem;
    }

    .book-header .actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .nav-btn.secondary {
        /* Hide text on small screens if needed, or just wrap */
        white-space: nowrap;
    }

    /* Stack Search Bar */
    .search-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .search-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .search-bar input,
    .search-bar select {
        width: 100%;
    }

    /* Responsive Table */
    .location-manager-container {
        overflow-x: auto;
    }

    #locations-table th,
    #locations-table td {
        white-space: nowrap;
        /* Prevent ugly wrapping inside cells */
        padding: 10px;
        font-size: 0.9em;
    }
}

/* Diary Entries Styling */
.diary-entry {
    margin-bottom: 3rem;
    position: relative;
    padding-left: 2rem;
    /* Space for timeline line */
}

.diary-entry::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    bottom: -3rem;
    width: 2px;
    background: #e0e0e0;
}

.diary-entry:last-child::before {
    display: none;
}

.diary-date {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
    display: block;
    width: 100%;
}

.diary-item {
    margin-bottom: 1.5rem;
    position: relative;
}

.diary-item::after {
    content: '';
    position: absolute;
    left: -2.35rem;
    /* center on line */
    top: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 3px solid var(--accent-blue);
    z-index: 2;
}

.diary-item.stationary::after {
    border-color: var(--accent-gold);
}

.time {
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
    display: block;
}

.narrative {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Scrollbar */
/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    /* For horizontal scroll */
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 4px;
    border: 2px solid transparent;
    /* Padds the scrollbar slightly */
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #aaa;
}

/* Print / PDF Export Styling */
/* Print / PDF Export Styling */
@media print {
    @page {
        margin: 2cm;
        size: A4;
    }

    /* 1. Reset Global Layout */
    html,
    body {
        height: auto !important;
        overflow: visible !important;
        background-color: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #app {
        display: block !important;
        visibility: visible !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* Hide Navigation and UI Elements */
    .book-header,
    .nav-btn,
    .drop-zone,
    #search-controls,
    #pagination-controls,
    .hero-container,
    #view-onboarding,
    #view-locations,
    #view-analytics,
    #view-binder,
    .modal-overlay,
    #export-overlay,
    .action-btn,
    .privacy-note,
    #enhance-progress,
    #btn-settings {
        display: none !important;
    }

    /* Obsolete Container - Remove or Ignore */
    /* #print-export-container { display: none !important; } */

    /* Cover Page */
    .print-cover-page {
        height: 100vh;
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        break-after: page;
        page-break-after: always;
    }

    .print-cover-title {
        font-family: var(--font-serif);
        font-size: 3rem;
        margin-bottom: 2rem;
    }

    .print-cover-subtitle {
        font-size: 1.5rem;
        color: #555;
    }

    /* Stats Page */
    .print-stats-page {
        padding: 4rem;
        /* Removed force break here, relying on Content Page's break-before to avoid double pages */
    }

    .print-stats-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
        margin-top: 2rem;
    }

    .print-stat-item {
        border: 1px solid #ccc;
        padding: 1.5rem;
        border-radius: 8px;
    }

    .print-stat-item h4 {
        margin-bottom: 0.5rem;
        font-family: var(--font-serif);
        font-size: 1.2rem;
    }

    .print-stat-val {
        font-size: 2rem;
        font-weight: bold;
    }

    /* Content Pages */
    .print-content-page {
        padding: 0 4rem;
        break-before: page;
        page-break-before: always;
    }

    /* 2. Hide Non-Printable Elements */
    .book-header,
    .nav-btn,
    .drop-zone,
    .privacy-note,
    .hero-container,
    #view-onboarding,
    #view-archives,
    #view-locations,
    #enhance-progress,
    #btn-settings,
    #search-controls,
    #pagination-controls,
    .pagination-bar,
    .location-manager-container,
    .modal-overlay,
    .modal,
    #export-overlay {
        display: none !important;
    }

    /* 3. Force Content to Flow */
    html,
    body {
        height: auto !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        background: white !important;
    }

    #app,
    section,
    #view-book,
    .book-container,
    .book-pages {
        display: block !important;
        visibility: visible !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        width: 100% !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        position: static !important;
        background: transparent !important;
        box-shadow: none !important;
        transform: none !important;
        /* Prevent layer clipping */
    }

    /* Content Styling */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    p,
    span,
    div,
    h1,
    h2,
    h3,
    h4,
    li,
    strong,
    em {
        color: black !important;
        text-shadow: none !important;
    }

    /* 4. Entry Formatting */
    .diary-entry {
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 2rem;
        padding-left: 0 !important;
        border: none !important;
        position: relative;
        display: block;
        /* Ensure it's not flex/grid */
    }

    .diary-date {
        color: #000 !important;
        border-bottom: 2px solid #000 !important;
        break-after: avoid;
        page-break-after: avoid;
    }

    /* 5. Typography */
    body,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    p,
    span,
    div,
    li {
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* THE NOVEL LOOK */
    .diary-entry p,
    .diary-entry .location-link,
    .print-chapter-title,
    .print-cover-title {
        font-family: 'Merriweather', serif !important;
        line-height: 1.6;
    }

    /* HIDE WEB TIMELINE STYLES */
    .diary-entry::before,
    .diary-item::after {
        display: none !important;
    }

    .diary-entry {
        font-size: 12pt;
        margin-bottom: 2rem;
        position: relative;
        padding-left: 0 !important;
        /* Reset padding from web view */
    }

    /* VERTICAL TIMELINE LOOK (PRINT ONLY) */
    .diary-item {
        position: relative;
        padding-left: 25px;
        /* Space for line */
        margin-left: 10px;
        border-left: 2px solid #ccc;
        /* The Timeline */
        padding-bottom: 1.5rem;
    }

    .diary-item:last-child {
        border-left: 2px solid transparent;
        /* Stop line at last item */
    }

    /* The Dot */
    .diary-item::before {
        content: '';
        position: absolute;
        left: -6px;
        /* Center on 2px border */
        top: 6px;
        /* Align with text top */
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: var(--bg-card);
        border: 2px solid #555;
    }

    /* Specific Styles */
    .diary-item.moving::before {
        background: #555;
        /* Solid dot for moving */
        border-color: #555;
    }

    .diary-item.stationary::before {
        background: var(--bg-card);
        /* Hollow dot for stop */
        border-color: #000;
        width: 12px;
        height: 12px;
        left: -7px;
    }

    .time {
        font-family: 'Inter', sans-serif;
        font-size: 0.85rem;
        color: #666 !important;
        display: block;
        /* Time on its own line/block for clarity */
        margin-bottom: 0.2rem;
    }

    .narrative {
        display: block;
    }

    /* Chapter Breaks */
    .print-chapter-break {
        break-before: page;
        page-break-before: always;
        min-height: 50vh;
        /* Visual breathing room */
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        margin-bottom: 4rem;
        border-bottom: 2px solid #333;
    }

    .print-chapter-title {
        font-size: 3rem;
        font-weight: 700;
        margin-bottom: 1rem;
    }

    .print-chapter-subtitle {
        font-family: 'Inter', sans-serif;
        /* Contrast */
        font-size: 1rem;
        text-transform: uppercase;
        letter-spacing: 2px;
        color: #555 !important;
    }

    .time {
        color: #555 !important;
    }

    /* Link styling removed to allow TOC links to work */
}

/* --- Enhancement UI --- */
.nav-btn.secondary {
    background: #e0f7fa;
    color: #006064;
    border: 1px solid #b2ebf2;
}

.nav-btn.secondary.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.nav-btn.secondary:hover:not(.disabled) {
    background: #b2ebf2;
}

.progress-bar {
    width: 200px;
    height: 16px;
    background: #eee;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    margin-left: 1rem;
    display: inline-block;
    vertical-align: middle;
}

.progress-bar .fill {
    height: 100%;
    background: #00bcd4;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-bar .text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: 0.7rem;
    line-height: 16px;
    color: #333;
    text-align: center;
    font-weight: bold;
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal,
.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    /* Ensure solid opacity */
    opacity: 1 !important;
    color: var(--text-ink);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text-ink);
    font-family: 'Georgia', serif;
}

.modal-subtitle {
    margin: 0 0 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.9em;
}

.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.input-group label {
    font-size: 0.85em;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: #7AA2E3;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.btn.primary {
    background: #7AA2E3;
    color: white;
}

.btn.primary:hover {
    background: #5d8ccf;
}

.btn.secondary {
    background: var(--bg-paper, #f0f0f0);
    color: var(--text-ink, #333);
    border: 1px solid var(--border-color, transparent);
}

.btn.secondary:hover {
    background: var(--bg-card-hover, #e0e0e0);
}

/* --- Location Manager Table --- */
.location-manager-container {
    background: var(--bg-card);
    /* Match book page background */
    padding: 2rem;
    overflow: hidden;
    /* For rounded corners */
}

#locations-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    font-size: 0.95rem;
}

#locations-table thead {
    position: sticky;
    top: 0;
    background: var(--bg-hover, #eef2f5);
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#locations-table th,
#locations-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

#locations-table th {
    font-weight: 600;
    color: #444;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

#locations-table tbody tr:hover {
    background-color: var(--bg-card-hover, #f0f7ff);
}

#locations-table tbody tr:nth-child(even) {
    background-color: var(--bg-paper, #fafafa);
}

/* Responsive Table for Mobile */
@media screen and (max-width: 768px) {

    .location-manager-container {
        padding: 1rem;
    }

    /* Force Table to render as block */
    #locations-table,
    #locations-table tbody,
    #locations-table tr,
    #locations-table td {
        display: block;
        width: 100%;
    }

    /* Hide Header */
    #locations-table thead {
        display: none;
    }

    /* Card Style for Rows */
    #locations-table tr {
        background: var(--bg-card, white);
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        margin-bottom: 1.5rem;
        border: 1px solid var(--border-color, #eee);
        padding: 15px;
        position: relative;
    }

    /* Flex-based Cells */
    #locations-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 10px 0;
        border-bottom: 1px solid #f0f0f0;
        min-height: 40px;
    }

    #locations-table td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        padding-top: 15px;
    }

    /* Labels via data-attribute */
    #locations-table td::before {
        content: attr(data-label);
        font-weight: 600;
        text-transform: uppercase;
        font-size: 0.8rem;
        color: #888;
        margin-right: 15px;
        text-align: left;
    }
}

.compact-link {
    display: inline-block;
    padding: 4px 8px;
    background: #e3f2fd;
    color: #1976d2;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 500;
}

.compact-link:hover {
    background: #bbdefb;
}

.action-btn {
    padding: 4px 10px;
    font-size: 0.85em;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    border-color: #4a90e2;
    color: #4a90e2;
    background: #f5f9ff;
}

/* --- Search Bar --- */
.search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
}

.search-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-group label {
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

.search-bar input[type="date"],
.search-bar select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9em;
    outline: none;
}

.search-bar select {
    min-width: 150px;
}

.nav-btn.small {
    padding: 6px 12px;
    font-size: 0.9em;
}

#search-text {
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    width: 220px;
    outline: none;
    font-size: 0.9em;
}

#search-text:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.15);
    background: var(--bg-card);
}

.event-count {
    margin-left: auto;
    /* Push to right */
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
    align-self: center;
}

/* ... Pagination Styles from Previous Step ... */
/* (Assuming they are there, just appending new stuff) */
/* Actually, I need to be careful not to overwrite the Pagination styles if I target the end. */
/* I will append AFTER the pagination styles. */

/* --- Archives View --- */
.archives-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.archive-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.archive-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
    border-color: #4a90e2;
}

.archive-header {
    margin-bottom: 15px;
}

.archive-title {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    margin: 0 0 5px 0;
}

.archive-stats {
    font-size: 0.9em;
    color: #666;
}

.archive-actions {
    display: flex;
    gap: 10px;
}

.archive-actions button {
    flex: 1;
    padding: 8px;
    font-size: 0.9em;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.2s;
}

.btn-view-month {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
}

.btn-view-month:hover {
    background: #bbdefb;
}

.btn-download-month {
    background: #f5f5f5;
    color: #555;
    border: 1px solid var(--border-color);
}

.btn-download-month:hover {
    background: #e0e0e0;
}

/* --- Pagination --- */
.pagination-bar {
    width: 100%;
    max-width: 1000px;
    margin: 10px auto;
    display: flex;
    justify-content: flex-end;
    /* Align right */
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    background: var(--bg-card);
    /* Fixed */
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.03);
}

.pagination-bar #page-info {
    font-weight: 600;
    color: #4a90e2;
    min-width: 100px;
    text-align: center;
    background: rgba(74, 144, 226, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9em;
}

.pagination-bar .nav-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: #555;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.pagination-bar .nav-btn:hover:not(:disabled) {
    background: #4a90e2;
    color: white;
    border-color: #4a90e2;
    box-shadow: 0 4px 8px rgba(74, 144, 226, 0.3);
    transform: translateY(-1px);
}

.pagination-bar .nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
    box-shadow: none;
    transform: none;
}

.goto-group {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 15px;
    padding-left: 15px;
    border-left: 1px solid #eee;
}

.goto-group input {
    width: 45px;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-align: center;
    font-size: 0.9em;
    transition: border 0.2s;
}

.goto-group input:focus {
    border-color: #4a90e2;
    outline: none;
}

/* Mobile Pagination */
@media (max-width: 768px) {
    .pagination-bar {
        flex-wrap: wrap;
        justify-content: center;
        /* Center on mobile */
        margin: 10px 0;
    }

    .goto-group {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
    }
}

/* --- Table of Contents (Print) --- */
.toc-container {
    margin: 2rem 0;
    font-family: var(--font-serif);
}

.toc-container h1 {
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.toc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1.1rem;
}

.toc-table th {
    text-align: left;
    border-bottom: 2px solid #ccc;
    padding: 10px;
}

.toc-table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.toc-table a {
    text-decoration: underline !important;
    color: #4a90e2 !important;
    /* Force Blue */
    font-weight: bold;
    cursor: pointer;
}

.toc-table a:after {
    content: " ➔";
    /* Arrow indicator */
}

/* Map Styling (Added for Map Integration) */
.map-modal-content {
    width: 90%;
    max-width: 800px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

#map-container {
    flex: 1;
    background: #f0f0f0;
}

.map-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e8f5e9;
    color: #2e7d32;
    margin-left: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    border: 1px solid #c8e6c9;
    vertical-align: middle;
    transition: all 0.2s;
}

.map-btn:hover {
    background: #2e7d32;
    color: white;
    transform: scale(1.1);
}

/* --- Progress Bar --- */
.progress-bar {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 30px;
    background: #f0f0f0;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: none;
    /* JS toggles this to FLEX */
    align-items: center;
    padding: 2px;
    z-index: 2000;
    /* High z-index */
    overflow: hidden;
    border: 1px solid #ccc;
}

.progress-bar .fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4CAF50, #81C784);
    border-radius: 13px;
    transition: width 0.2s linear;
}

.progress-bar .text {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 0.85rem;
    font-weight: bold;
    color: #333;
    text-shadow: 0 0 2px white;
}

@keyframes fillProgress {
    0% {
        width: 0%;
    }

    10% {
        width: 10%;
    }

    80% {
        width: 90%;
    }

    100% {
        width: 100%;
    }
}

/* Notes */
.user-note {
    background-color: #fff9c4;
    border-left: 4px solid #fbc02d;
    padding: 8px 12px;
    margin: 5px 0 10px 0;
    border-radius: 4px;
    font-family: "Comic Sans MS", "Chalkboard SE", "Comic Neue", sans-serif;
    font-size: 0.95em;
    color: #333;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s;
}

.user-note:hover {
    background-color: #fff59d;
}

.note-btn {
    opacity: 0.7;
    transition: opacity 0.2s;
    display: inline-block;
}

.note-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* Year Switcher */
#year-switcher {
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9em;
    cursor: pointer;
    background-color: var(--bg-card, white);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#year-switcher:hover {
    background-color: #f8f8f8;
    border-color: #ccc;
}

/* Weather Overlay (Floating) */
.weather-overlay {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 2147483647 !important;
    display: none;
    /* Hidden by default */
    align-items: center;
    gap: 12px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--accent-blue, #90caf9);
    border-radius: 50px;
    padding: 8px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    height: 48px;
    font-family: inherit;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.weather-overlay.active {
    display: inline-flex !important;
    /* Only visible when active */
}

#weather-progress .text {
    position: relative;
    z-index: 2;
    margin-right: auto;
    font-size: 0.85em;
    font-weight: bold;
    color: var(--accent-blue, #0d47a1);
    /* Use accent color */
    white-space: nowrap;
}

#weather-progress button {
    position: relative;
    z-index: 10;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0 4px;
    opacity: 1 !important;
    display: inline-block !important;
    color: var(--accent-blue, #0d47a1);
}

#weather-progress button:hover {
    transform: scale(1.1);
    background: var(--bg-hover, rgba(255, 255, 255, 0.5));
    border-radius: 50%;
}

/* --- Map Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    /* Hidden by default via JS toggle, but flex when active */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    /* width/height controlled inline by JS, but defaults here */
}

/* --- Archives Grid --- */
.months-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.archive-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #eee;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.archive-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-blue, #2196F3);
}

.archive-header {
    padding: 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.archive-title {
    font-size: 1.2rem;
    margin: 0;
    color: #333;
    font-weight: 600;
}

.archive-stats {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
}

.archive-actions {
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
    background: var(--bg-card);
}

.archive-actions button {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-paper);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.1s;
}

.archive-actions button:hover {
    background: var(--bg-card-hover);
}

.btn-view-month {
    color: var(--accent-blue, #2196F3);
    border-color: var(--accent-blue, #2196F3) !important;
}

.btn-view-month:hover {
    background: var(--accent-blue, #2196F3) !important;
    color: white !important;
}

/* Mobile Tweaks */
@media (max-width: 600px) {
    .months-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Dark Mode Specific Adjustments (User Request) --- */
/* 1. Language Switcher: Match dark mode card background */
[data-theme="dark"] #lang-switcher {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color);
    color: var(--text-ink);
}

/* 2. Filter Clear Button: Match dark mode card background */
[data-theme="dark"] #btn-clear-filter {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-ink);
}

/* 3. Paging Control Section */
[data-theme="dark"] .pagination-bar {
    background: var(--bg-card);
    /* Remove default gradient */
    border-color: var(--border-color);
}

[data-theme="dark"] .pagination-bar #page-info {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--accent-blue);
}

[data-theme="dark"] .pagination-bar .nav-btn {
    background-color: var(--bg-paper);
    border-color: var(--border-color);
    color: var(--text-ink);
}

[data-theme="dark"] .pagination-bar .nav-btn:hover:not(:disabled) {
    background-color: var(--accent-blue);
    color: white;
}

/* --- Legacy Binder & Financial Planner --- */
.binder-container {
    display: flex;
    height: calc(100vh - 140px);
    /* Adjust based on header */
    background: var(--bg-paper);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

/* Sidebar Tree */
.binder-sidebar {
    width: 300px;
    background: var(--bg-card, #f8f9fa);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.binder-header-actions {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 5px;
    background: #fff;
}

.tree-root {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* Tree Nodes */
.tree-node {
    margin-bottom: 2px;
}

/* Specific styling for Top Level Root Nodes to distinguish them */
.tree-root>.tree-node {
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
    margin-bottom: 4px;
}


.tree-title {
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    color: #333;
    user-select: none;
}

.tree-title:hover {
    background: #e9ecef;
}

.tree-node.selected>.tree-title {
    background: #e3f2fd;
    color: #1565c0;
    font-weight: 500;
}

.tree-title .icon {
    font-size: 1.1em;
    width: 20px;
    text-align: center;
    color: #fbc02d;
    /* Gold folder color */
}

/* Triangle Arrow */
.tree-title .arrow {
    font-size: 0.8em;
    color: #999;
    width: 16px;
    display: inline-block;
    transition: transform 0.2s;
    text-align: center;
}

.tree-node.expanded>.tree-title .arrow {
    transform: rotate(90deg);
}

/* Indentation for Children */
.tree-children {
    margin-left: 24px;
    /* Essential for hierarchy visual */
    border-left: 1px solid #eee;
    padding-left: 5px;
    display: none;
    /* Collapse by default */
}

.tree-node.expanded>.tree-children {
    display: block;
}

/* Dashboard Widget */
#binder-dashboard {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #ddd;
}

.alert-item {
    padding: 8px;
    border-radius: 6px;
    background: #fff3e0;
    margin-bottom: 8px;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #ffe0b2;
}

.alert-item.urgent {
    background: #ffebee;
    border-color: #ffcdd2;
}

.alert-days {
    font-weight: bold;
    color: #e65100;
    font-size: 0.9em;
}

/* Content Area */
.binder-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.content-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.content-title {
    margin: 0 0 15px 0;
    font-size: 1.5rem;
    color: #2c3e50;
    font-family: var(--font-serif);
}

.content-toolbar {
    display: flex;
    gap: 10px;
}

.fields-grid {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    align-content: start;
}

/* Field Cards */
.field-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    position: relative;
    transition: box-shadow 0.2s;
}

.field-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #bdbdbd;
}

.field-label {
    display: block;
    font-size: 0.8rem;
    color: #757575;
    text-transform: uppercase;
    margin-bottom: 5px;
    font-weight: 600;
}

.field-value {
    font-size: 1.1rem;
    color: #333;
    font-weight: 500;
    word-break: break-all;
}

.field-value.password-mask {
    font-family: monospace;
    letter-spacing: 2px;
    color: #999;
}

.field-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    opacity: 0;
    /* Show on hover */
    transition: opacity 0.2s;
}

.field-card:hover .field-actions {
    opacity: 1;
}

.field-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    opacity: 0.6;
}

.field-actions button:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Modal Specifics */
.binder-modal .input-group {
    margin-bottom: 15px;
}

.binder-modal label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.binder-modal input,
.binder-modal select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.tree-node.drag-over>.tree-title {
    background: #e3f2fd;
    border: 2px dashed #2196f3;
}