:root {
    /* Colors - Light Theme Default */
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --text-main: #2d3748;
    --text-muted: #718096;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --primary: #5c6bc0;
    --primary-rgb: 92, 107, 192;
    --primary-hover: #3f51b5;
    --white: #ffffff;
    --radius-lg: 16px;
    --radius-md: 8px;

    /* Calendar */
    --cal-hover: rgba(92, 107, 192, 0.1);
    --cal-active: #5c6bc0;
    --cal-active-text: #ffffff;
    --cal-dot: #ff7043;
}

[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #1a1c22 0%, #2d3748 100%);
    --text-main: #e2e8f0;
    --text-muted: #a0aec0;
    --glass-bg: rgba(30, 32, 40, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --primary: #7986cb;
    --primary-rgb: 121, 134, 203;
    --primary-hover: #9fa8da;
    --white: #1a1c22;
    /* Card bg in dark mode essentially */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-gradient);
    z-index: -1;
}

.app-container {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    gap: 2rem;
    min-height: 100vh;
    align-items: flex-start;
    /* Allow items to have independent heights for JS control */
}

/* Glassmorphism Utility */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

/* Sidebar */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex-shrink: 0;
}

.sidebar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-controls {
    display: flex;
    gap: 0.5rem;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
}

/* Calendar */
.calendar-wrapper {
    padding: 1rem;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-weight: 600;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
}

.cal-day-header {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding-bottom: 0.5rem;
}

.cal-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    position: relative;
}

.cal-day:hover {
    background: var(--cal-hover);
}

.cal-day.active {
    background: var(--cal-active);
    color: var(--cal-active-text);
}

.cal-day.has-memo {
    font-weight: 700;
    color: var(--primary);
    background: rgba(92, 107, 192, 0.05);
}

.cal-day.has-memo::after {
    content: '';
    width: 5px;
    height: 5px;
    background-color: var(--primary);
    border-radius: 50%;
    position: absolute;
    bottom: 3px;
}

.cal-day.active.has-memo::after {
    background-color: var(--white);
}

.cal-day.empty {
    cursor: default;
}

.cal-day.today {
    border: 2px solid var(--primary);
    font-weight: 700;
}

.cal-day.empty:hover {
    background: transparent;
}


/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    /* overflow-y: auto; - Removed for window scrolling */
    padding-right: 0.5rem;
    /* Space for scrollbar */
}

/* Editor */
.editor-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#memoInput {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    outline: none;
    color: var(--text-main);
    min-height: 80px;
}

.editor-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--glass-border);
    padding-top: 0.8rem;
}

.tool-tip {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.icon-btn:hover {
    background: var(--cal-hover);
}

/* Feed */
.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.memo-feed {
    flex: 1;
}

.memo-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    /* Softer shadow for cards */
}

.memo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.memo-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.memo-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
}

.memo-content {
    font-size: 1rem;
    line-height: 1.5;
}

.memo-content p {
    margin-bottom: 0.5rem;
}

.memo-content img {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
}

/* Markdown Styling overrides */
.memo-content ul,
.memo-content ol {
    padding-left: 1.5rem;
}

.memo-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

.theme-btn {
    align-self: auto;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        padding: 1rem;
        height: auto;
    }

    .sidebar {
        width: 100%;
    }

    .main-content {
        overflow-y: visible;
    }

    .memo-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .memo-header-right {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 0.5rem;
    }
}

.memo-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    align-items: center;
}

.meta-left {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.memo-id {
    background: rgba(0, 0, 0, 0.05);
    /* Very subtle badge */
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: default;
}

[data-theme="dark"] .memo-id {
    background: rgba(255, 255, 255, 0.1);
}

.memo-actions {
    display: flex;
    gap: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.memo-card:hover .memo-actions {
    opacity: 1;
}

textarea {
    resize: none;
    overflow-y: hidden;
    min-height: 80px;
}

.edit-area {
    min-height: 100px;
}

/* Tags */
.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-item {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.05);
    cursor: pointer;
    color: var(--primary);
    transition: all 0.2s;
    border: 1px solid transparent;
}

.tag-item:hover {
    background: var(--cal-hover);
}

.tag-item.active {
    background: var(--primary);
    color: white;
}

[data-theme="dark"] .tag-item {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-hover);
}

[data-theme="dark"] .tag-item.active {
    color: white;
}

.text-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

.clear-filter-btn {
    background: rgba(229, 62, 62, 0.1);
    color: #e53e3e;
    border: 1px solid rgba(229, 62, 62, 0.2);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.clear-filter-btn:hover {
    background: rgba(229, 62, 62, 0.2);
}

.clear-filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.location-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    text-decoration: none;
    margin-right: 0.5rem;
    font-weight: 500;
    transition: all 0.2s;
}

.location-pill:hover {
    background: rgba(var(--primary-rgb), 0.2);
    text-decoration: none;
}

/* Tag inside content */
.hashtag {
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
}

.hashtag:hover {
    text-decoration: underline;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.modal-header {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

.form-group {
    margin-bottom: 1rem;
}

ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.25rem;
}

/* Helper for Task Lists (Remove bullet) */
li:has(input[type="checkbox"]) {
    list-style-type: none;
    margin-left: -1rem;
    /* Adjust alignment */
}

/* Strikethrough for checked items */
li:has(input[type="checkbox"]:checked) {
    text-decoration: line-through;
    color: var(--text-muted);
    opacity: 0.8;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--glass-border);
    /* Slightly more visible border */
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md);
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
}

[data-theme="dark"] .form-input {
    background: rgba(0, 0, 0, 0.2);
}

.form-input:focus {
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.text-center {
    text-align: center;
}

.error-msg {
    color: #e53e3e;
    /* Red-500 */
    font-size: 0.85rem;
    margin-top: 0.5rem;
    text-align: center;
    min-height: 1.2rem;
}

.close-modal-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

/* Toolbar */
.tool-btn {
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tool-btn:hover {
    opacity: 1;
    color: var(--primary);
}

/* Link Preview Card */
.link-preview-card {
    display: flex;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    /* Very subtle bg */
    text-decoration: none;
    color: inherit;
    margin: 0.8rem 0;
    overflow: hidden;
    transition: background 0.2s;
    height: 100px;
}

.link-preview-card:hover {
    background: rgba(255, 255, 255, 0.1);
}

.preview-image {
    width: 100px;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-color: #f0f0f0;
    flex-shrink: 0;
}

.preview-info {
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.preview-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.2rem;
}

.preview-url {
    font-size: 0.7rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Map Modal Tweaks */
.leaflet-container {
    font-family: inherit;
}

/* Reminder Styles */
.reminder-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(var(--primary-rgb), 0.05);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 0.8rem 0;
    transition: all 0.2s;
}

.reminder-card:hover {
    background: rgba(var(--primary-rgb), 0.1);
}

.reminder-card.done {
    opacity: 0.6;
    background: rgba(100, 100, 100, 0.05);
    border-color: rgba(100, 100, 100, 0.1);
}

.reminder-icon {
    font-size: 1.5rem;
    color: var(--cal-dot);
}

.reminder-info {
    display: flex;
    flex-direction: column;
}

.reminder-desc {
    font-weight: 600;
    font-size: 1rem;
}

.reminder-dates {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.reminder-action {
    margin-left: auto;
}

.mark-done-btn {
    background: var(--white);
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.mark-done-btn:hover {
    background: var(--primary);
    color: var(--white);
}

.reminder-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Notification Bell */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notification-bell-container {
    position: relative;
    margin-right: 0.5rem;
}

#notifDropdown {
    left: 0 !important;
    right: auto !important;
    transform: none !important;
    width: 320px;
    /* Wider for better view */
}

/* Ensure mobile responsiveness */
@media (max-width: 768px) {
    #notifDropdown {
        position: fixed;
        top: 60px;
        left: 10px;
        right: 10px;
        width: auto;
        transform: none;
    }
}

.notification-bell.has-active {
    color: #e53e3e;
    /* Red */
    animation: pulse 2s infinite;
}

.notification-bell.has-active::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background: #e53e3e;
    border-radius: 50%;
    border: 1px solid var(--white);
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    width: 300px;
    box-shadow: var(--shadow);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.notif-item {
    padding: 0.8rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    font-size: 0.9rem;
    cursor: pointer;
}

.notif-item:hover {
    background: rgba(var(--primary-rgb), 0.1);
}

.notif-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.notif-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.notif-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

[data-theme='dark'] .notif-item {
    background: rgba(255, 255, 255, 0.05);
}

/* Calendar Event Marker */
.cal-day.has-event {
    color: #e53e3e !important;
    font-weight: 700;
}

.cal-day.has-event::before {
    content: '';
    width: 4px;
    height: 4px;
    background-color: #e53e3e;
    border-radius: 50%;
    position: absolute;
    top: 4px;
    right: 4px;
}


/* Workspace Color Picker */
.color-picker {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.color-option {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--text-main);
    transform: scale(1.1);
}

.color-option.selected::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    opacity: 0.5;
}

/* Workspace Pill */
.workspace-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    margin-right: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.9;
}

/* Dropdown Options Fix */
select option {
    background-color: var(--white);
    color: var(--text-main);
}