:root {
    --bg-main: #0f1014;
    --bg-card: #1b1d24;
    --accent: #0064ff;
    --accent-glow: rgb(81, 117, 255);
    --text-primary: #c9d4e3;
    --text-secondary: #8f9bb3;
    --success: #00e676;
    --warning: #ffab00;
    --danger: #ff1744;
    --radius: 12px;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 20px;
}

.container { max-width: 1200px; margin: 0 auto; }

/* Header & Search */
/* =========================================
   HEADER & FILTER STYLES (Responsive & Wrapping)
   ========================================= */

header {
    display: flex;
    flex-direction: column; /* Default: Stack vertically for mobile */
    gap: 20px;
    margin-bottom: 30px;
}

/* Desktop: Side-by-side layout */
@media (min-width: 768px) {
    header {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start; /* Aligns to top */
    }

    /* Title & Tags Container */
    header > div:first-child {
        flex: 1; /* Takes up available space */
        margin-right: 30px; 
    }

    /* Button Container */
    header > div:last-child {
        flex-shrink: 0; /* Prevents buttons from squishing */
        margin-top: 5px; /* Aligns nicely with the H1 */
    }
}

h1 {
    font-weight: 700;
    background: linear-gradient(to right, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0 0 15px 0; /* Add space below title for the chips */
    font-size: 2rem;
    line-height: 1.2;
}

/* Filter Bar - Wrapping List */
.filter-bar {
    display: flex;
    flex-wrap: wrap; /* KEY CHANGE: Wraps tags to next line */
    gap: 8px;        /* Consistent spacing */
    width: 100%;
}

.chip {
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid #333;
    border-radius: 50px; /* Fully rounded pill shape */
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    user-select: none;
}

.chip:hover {
    border-color: var(--accent);
    color: #fff;
    transform: translateY(-1px);
}

.chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* Card Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px; /* More padding */
    border: 1px solid #2c303a;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 320px;
}

.card h3 { 
    margin: 10px 0 10px 0; 
    font-size: 1.4rem; /* Larger Title */
    font-family: 'Inter', serif; /* Optional: serif for stories */
    color: #e2e8f0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card:hover { transform: translateY(-3px); border-color: #444; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }

/* Card Internals */
.card-top { display: flex; justify-content: space-between; margin-bottom: 10px; }
.freq-badge { 
    font-size: 0.7rem; text-transform: uppercase; font-weight: bold; padding: 4px 8px; border-radius: 4px; letter-spacing: 0.5px;
}
.freq-Daily { background: rgba(0, 230, 118, 0.15); color: var(--success); }
.freq-Weekly { background: rgba(255, 171, 0, 0.15); color: var(--warning); }
.freq-Monthly { background: rgba(41, 121, 255, 0.15); color: #2979ff; }
.freq-One-Time { background: #333; color: #aaa; }

.card p { color: var(--text-secondary); line-height: 1.5; font-size: 0.95rem; flex-grow: 1; white-space: pre-wrap; }

/* The Hash Tag Style */
.hashtag {
    color: #c9d4e3;
    background: rgba(124, 77, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
}
.hashtag:hover { text-decoration: underline; }

.card-actions { margin-top: auto; border-top: 1px solid #2c303a; padding-top: 15px; display: flex; gap: 10px; justify-content: flex-end; }
.btn-icon { background: none; border: none; cursor: pointer; color: #666; font-size: 0.9rem; }
.btn-icon:hover { color: #fff; }

/* Wizard Modal */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal.open { opacity: 1; pointer-events: all; }
.wizard-box {
    background: #1b1d24; width: 500px; max-width: 90%; border-radius: 20px;
    padding: 30px; border: 1px solid #333; box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.preview-box {
    background: #1b1d24;
    width: 900px;
    max-width: 95%;
    max-height: 85vh;
    overflow: hidden;
    border-radius: 20px;
    padding: 28px;
    border: 1px solid #333;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.preview-meta {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

.preview-content {
    flex: 1;
    overflow: auto;
    padding-top: 16px;
    padding-right: 6px;
    border-top: 1px solid #2c303a;
}

.preview-content .toastui-editor-contents {
    color: #e2e8f0;
}

.preview-content .toastui-editor-contents a {
    color: var(--accent);
}
.form-group { margin-bottom: 20px; }
.form-group label { display: block; color: var(--text-secondary); margin-bottom: 8px; font-size: 0.9rem; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 12px; background: #0f1014; border: 1px solid #333;
    color: white; border-radius: 8px; font-family: inherit; font-size: 1rem;
    box-sizing: border-box;
}
.form-group input:focus { border-color: var(--accent); outline: none; }

.btn-primary { background: var(--accent); color: white; border: none; padding: 10px 24px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { background: var(--bg-card); }
.hidden { display: none !important; }

.view-toggle {
    display: flex;
    flex-wrap: wrap; /* Handle small screens */
}
.toggle-btn {
    background: transparent;
    border: none;
    color: #888;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 600;
}
.toggle-btn.active { background: #333; color: white; }

#view-notes {
    position: relative;
    padding-left: 26px;
    margin-left: 6px;
}

#view-notes::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: #2c303a;
}

.export-images-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #15171c;
    border: 1px solid #2c303a;
    border-radius: 8px;
    color: #9aa4b2;
    font-size: 0.85rem;
}

.export-images-toggle input {
    accent-color: var(--accent);
}

/* Calendar Container */
.calendar-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid #333;
}

/* Notes Section */
.notes-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
}

.notes-sidebar {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid #333;
    height: fit-content;
}

.notes-filter-bar {
    margin-top: 16px;
    gap: 6px;
}

.notes-filter-bar .chip {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.notes-stream {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid #333;
    min-height: 400px;
}

.notes-stream-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.notes-stream-header h2 {
    margin: 0;
}

.notes-stream-header p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.notes-list {
    display: grid;
    gap: 12px;
}

.note-card {
    background: #15171c;
    border: 1px solid #2c303a;
    border-radius: 12px;
    padding: 16px;
    display: grid;
    gap: 10px;
}

.note-card h4 {
    margin: 0;
    font-size: 1.1rem;
}

.note-card p {
    margin: 0;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.note-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: #7f8aa1;
}

.note-links {
    display: grid;
    gap: 6px;
    font-size: 0.9rem;
}

.note-links a {
    color: var(--accent);
    text-decoration: none;
}

.note-links a:hover {
    text-decoration: underline;
}

.note-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid #2c303a;
    padding-top: 10px;
}

.note-media {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.note-media a {
    display: inline-flex;
    border: 1px solid #2c303a;
    border-radius: 10px;
    overflow: hidden;
    background: #0f1014;
}

.note-media img {
    display: block;
    width: 96px;
    height: 96px;
    object-fit: cover;
}

.note-existing-images {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.note-existing-image {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid #2c303a;
    border-radius: 8px;
    background: #15171c;
    font-size: 0.85rem;
    color: #9aa4b2;
}

.note-existing-image.removed {
    opacity: 0.6;
    text-decoration: line-through;
}

.note-more summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    display: inline-block;
}

.note-more p {
    margin-top: 10px;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.more-toggle {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-weight: 600;
    padding: 0;
    display: inline-block;
    margin-left: 6px;
}

.more-content {
    margin-top: 0;
    color: var(--text-secondary);
    white-space: pre-wrap;
    display: inline;
}

.more-text {
    white-space: pre-wrap;
}

.more-less {
    margin-left: 6px;
}

.entry-text,
.note-text {
    white-space: pre-wrap;
}

/* Mini Calendar */
.mini-cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.mini-cal-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--accent);
}

.mini-cal-header button {
    background: #333;
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
}

.mini-cal-header button:hover { background: var(--accent); }

.mini-cal-grid-header,
.mini-cal-grid-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.mini-cal-grid-header div {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 4px 0;
}

.mini-cal-day {
    background: #15171c;
    border-radius: 6px;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #8d97ab;
    cursor: pointer;
    position: relative;
}

.mini-cal-day:hover { background: #1f2229; }
.mini-cal-day.today { outline: 1px solid var(--accent); }
.mini-cal-day.selected { background: rgba(0, 100, 255, 0.2); color: #fff; }

.mini-cal-dot {
    position: absolute;
    bottom: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}
.cal-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.cal-header h2 { margin: 0; color: var(--accent); }
.cal-header button {
    background: #333; border: none; color: white; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
}
.cal-header button:hover { background: var(--accent); }

/* Calendar Grid */
.cal-grid-header, .cal-grid-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #333; /* Border color */
    border: 1px solid #333;
}
.cal-grid-header div {
    background: #1b1d24;
    padding: 10px;
    text-align: center;
    color: var(--text-secondary);
    font-weight: bold;
}
.cal-day {
    background: #15171c;
    min-height: 120px;
    padding: 5px;
    position: relative;
    cursor: pointer;
}
.cal-day:hover { background: #1f2229; }
.cal-day.today { background: rgba(124, 77, 255, 0.05); }
.day-number {
    position: absolute; top: 5px; right: 8px; color: #666; font-size: 0.9rem;
}

/* Calendar Events */
.cal-event {
    font-size: 0.75rem;
    margin-top: 2px;
    padding: 3px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}
.cal-event.type-one-time { background: var(--accent); color: white; }
.cal-event.type-daily { background: rgba(0, 230, 118, 0.2); color: var(--success); border-left: 2px solid var(--success); }
.cal-event.type-weekly { background: rgba(255, 171, 0, 0.2); color: var(--warning); border-left: 2px solid var(--warning); }
.cal-event.type-monthly { background: rgba(41, 121, 255, 0.2); color: #2979ff; border-left: 2px solid #2979ff; }
.cal-event.type-yearly { 
    background: rgba(255, 64, 129, 0.2); 
    color: #ff4081; 
    border-left: 2px solid #ff4081; 
}

.cal-event::before {
    content: '•';
    margin-right: 4px;
    font-weight: bold;
    color: rgba(255,255,255,0.7);
}

/* Specific colors for categories if you want them */
.cal-event[onclick*="brain-dump"] { border-right: 3px solid #e040fb; }
.cal-event[onclick*="project"]    { border-right: 3px solid #00bcd4; }
.cal-event[onclick*="chore"]      { border-right: 3px solid #ffab00; }

#search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}


@media (max-width: 768px) {
    
    /* 1. Header controls: Make them smaller */
    .cal-header h2 { font-size: 1.1rem; }
    .cal-header button { width: 32px; height: 32px; }

    /* 2. The Grid: Reduce height and font size */
    .cal-day {
        min-height: 50px; /* Much shorter than desktop */
        font-size: 0.8rem;
        padding: 2px;
        display: flex;
        flex-direction: column;
        align-items: center; /* Center the dots */
    }

    /* 3. The Events: Transform text bars into DOTS */
    .cal-event {
        font-size: 0;       /* Hide text */
        width: 6px;         /* Dot width */
        height: 6px;        /* Dot height */
        padding: 0;         
        border-radius: 50%; /* Circle */
        border: none !important; /* Remove the left-border styling */
        margin: 1px;
        display: inline-block;
    }

    /* Keep colors but apply to background */
    .cal-event.type-one-time { background: var(--accent); }
    .cal-event.type-daily    { background: var(--success); }
    .cal-event.type-weekly   { background: var(--warning); }
    .cal-event.type-monthly  { background: #2979ff; }
    .cal-event.type-yearly   { background: #ff4081; }

    /* 4. Container for the Dots */
    /* This forces dots to wrap if there are many */
    .cal-day {
        display: flex;
        flex-flow: row wrap; 
        justify-content: center;
        align-content: flex-start;
        gap: 2px;
        padding-top: 20px; /* Make room for the number */
    }
    
    .day-number {
        position: absolute;
        top: 2px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 0.75rem;
    }

    /* 5. Selected State for Mobile */
    .cal-day.selected {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid var(--accent);
    }

    .notes-container {
        grid-template-columns: 1fr;
    }

    .notes-stream-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Styles for the Details Box below calendar (Visible on mobile) */
.mobile-day-details {
    margin-top: 20px;
    border-top: 1px solid #333;
    padding-top: 15px;
    animation: fadeIn 0.3s ease;
}

.mobile-day-details h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Reuse card styles for the mobile list items */
.mobile-event-card {
    background: #15171c;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 4px solid transparent;
    cursor: pointer;
    display: flex; 
    justify-content: space-between;
    align-items: center;
}


/* 2. New Photo Gallery Styles */
.photo-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.gallery-item {
    aspect-ratio: 1; /* Square tiles */
    background: #15171c;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid #333;
    cursor: pointer;
    transition: transform 0.2s;
}

.gallery-item:hover {
    transform: scale(1.02);
    border-color: var(--accent);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    padding: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.gallery-date {
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}


/* Add to style.css */

/* Make the modal wider/taller when writing stories */
.wizard-box.wizard-wide {
    width: 90%;
    height: 90vh; /* 90% of viewport height */
    max-width: 1200px;
    display: flex;
    flex-direction: column;
}

/* Ensure the body of the wizard takes up available space */
.wizard-box.wizard-wide #wizard-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Fix Toast UI Editor in Dark Mode to match our theme */
.toastui-editor-defaultUI {
    background-color: #15171c !important;
    border: 1px solid #2c303a !important;
}

.toastui-editor-defaultUI .ProseMirror {
    color: #c9d4e3 !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 1.1rem; /* Slightly larger font for reading */
}

.toastui-editor-mode-switch {
    background-color: #15171c !important; 
}

/* Ensure the editor fills the remaining vertical space */
#editor-container {
    flex: 1; 
    min-height: 400px; /* Minimum height */
}
