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

:root {
    --bg: #f4f6f9;
    --bg-card: #ffffff;
    --bg-hover: #f0f2f5;
    --bg-selected: #eef2ff;
    --text: #1a1d23;
    --text-secondary: #5f6b7a;
    --text-muted: #8b95a5;
    --border: #e1e5eb;
    --border-light: #edf0f4;
    --accent: #6366f1;
    --accent-light: #eef2ff;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --header-h: 56px;
    --toolbar-h: 52px;
    --priority-high: #dc2626;
    --priority-high-bg: #fee2e2;
    --priority-medium: #d97706;
    --priority-medium-bg: #fef3c7;
    --priority-low: #059669;
    --priority-low-bg: #d1fae5;
    --task-color: #7c3aed;
    --task-bg: #f3e8ff;
    --task-border: #ddd6fe;
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ============ LOGIN ============ */
.login-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-screen.hidden { display: none; }

.login-box {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px 28px 32px;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 24px 80px rgba(0,0,0,0.25);
    text-align: center;
}

.login-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 18px;
}
.login-icon svg { width: 28px; height: 28px; fill: #fff; }

.login-box h2 { font-size: 1.3rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.login-box .login-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 24px; }

.login-field {
    width: 100%; padding: 11px 14px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.95rem; font-family: var(--font);
    background: var(--bg); color: var(--text);
    outline: none; margin-bottom: 10px;
    transition: border-color 0.2s;
}
.login-field:focus { border-color: var(--accent); }

.login-error {
    font-size: 0.8rem; color: #dc2626;
    margin-bottom: 10px; display: none;
}

.btn-login {
    width: 100%; padding: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; border: none; border-radius: var(--radius-sm);
    font-size: 0.95rem; font-weight: 600; font-family: var(--font);
    cursor: pointer; transition: opacity 0.2s;
}
.btn-login:hover { opacity: 0.92; }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ CONFIRM DIALOG ============ */
.confirm-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.confirm-overlay.hidden { display: none; }

.confirm-box {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 24px; max-width: 340px; width: 100%;
    box-shadow: var(--shadow-md); text-align: center;
}
.confirm-box p { font-size: 0.95rem; color: var(--text); margin-bottom: 20px; line-height: 1.5; }
.confirm-buttons { display: flex; gap: 10px; justify-content: center; }

.btn-confirm-cancel {
    padding: 9px 22px; background: var(--bg); color: var(--text-secondary);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.875rem; font-weight: 600; font-family: var(--font); cursor: pointer;
}
.btn-confirm-delete {
    padding: 9px 22px; background: #dc2626; color: #fff;
    border: none; border-radius: var(--radius-sm);
    font-size: 0.875rem; font-weight: 600; font-family: var(--font); cursor: pointer;
}
.btn-confirm-delete:hover { background: #b91c1c; }

/* ============ APP SHELL ============ */
.app { display: none; height: 100dvh; flex-direction: column; overflow: hidden; }
.app.visible { display: flex; }

/* --- Header Bar --- */
.header-bar {
    height: var(--header-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 20px; gap: 12px;
    flex-shrink: 0; z-index: 10;
}

.header-bar .logo {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: 1.05rem; color: var(--text);
    white-space: nowrap;
}
.header-bar .logo-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.header-bar .logo-icon svg { width: 18px; height: 18px; fill: #fff; }

/* --- Tab Navigation --- */
.header-tabs {
    display: flex; align-items: center; gap: 4px;
    margin-left: 12px; flex: 1;
    justify-content: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.header-tab {
    padding: 6px 16px;
    font-size: 0.82rem; font-weight: 600;
    color: var(--text-muted);
    background: none; border: none;
    border-radius: 8px;
    cursor: pointer; white-space: nowrap;
    font-family: var(--font);
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.header-tab:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}
.header-tab.active {
    background: var(--accent-light);
    color: var(--accent);
}

.tab-badge {
    font-size: 0.68rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: var(--bg);
    color: var(--text-muted);
    padding: 0 5px;
}
.header-tab.active .tab-badge {
    background: var(--accent);
    color: #fff;
}

.header-right {
    margin-left: auto;
    display: flex; align-items: center; gap: 4px;
}

.hdr-btn {
    width: 34px; height: 34px;
    background: transparent; border: none; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}
.hdr-btn:hover { background: var(--bg-hover); color: var(--text); }
.hdr-btn svg { width: 18px; height: 18px; fill: currentColor; }
.hdr-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Toolbar (search + filters) --- */
.toolbar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.search-box {
    position: relative; flex-shrink: 0;
    width: 220px;
}

.search-box svg {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; fill: var(--text-muted); pointer-events: none;
}

.search-box input {
    width: 100%; padding: 8px 10px 8px 32px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.85rem; font-family: var(--font);
    background: var(--bg); color: var(--text); outline: none;
    transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-muted); }

.toolbar-sep {
    width: 1px; height: 24px;
    background: var(--border); flex-shrink: 0;
}

.filter-pill {
    display: inline-flex; align-items: center;
    padding: 5px 12px; border-radius: 16px;
    font-size: 0.78rem; font-weight: 600;
    cursor: pointer; user-select: none;
    white-space: nowrap; flex-shrink: 0;
    opacity: 0.55; transition: opacity 0.15s, transform 0.12s;
    border: 1.5px solid transparent;
}
.filter-pill.active { opacity: 1; border-color: currentColor; }
.filter-pill:active { transform: scale(0.95); }

.project-dropdown {
    padding: 6px 28px 6px 10px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.8rem; font-family: var(--font);
    background: var(--bg); color: var(--text);
    cursor: pointer; outline: none;
    appearance: none; flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%238b95a5' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.active-badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 4px 10px; border-radius: 14px;
    font-size: 0.72rem; font-weight: 500;
    background: var(--accent-light); color: var(--accent);
    cursor: pointer; flex-shrink: 0; white-space: nowrap;
}
.active-badge:hover { background: #dde3ff; }
.active-badge .x { font-weight: 700; font-size: 0.8rem; }

/* --- Main Content Area --- */
.content {
    flex: 1; display: flex;
    overflow: hidden;
    min-height: 0;
}

/* Tab content visibility */
.tab-content { display: none; flex: 1; overflow: hidden; min-height: 0; }
.tab-content.active { display: flex; }

/* Left panel: note list */
.panel-list {
    width: 100%;
    overflow-y: auto;
    border-right: 1px solid var(--border-light);
    background: var(--bg-card);
}

/* Right panel: note detail */
.panel-detail {
    display: none;
    flex: 1;
    overflow-y: auto;
    background: var(--bg);
}

/* --- Note List Items --- */
.note-item {
    display: flex;
    flex-direction: column;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.12s;
    position: relative;
}
.note-item:hover { background: var(--bg-hover); }
.note-item.selected {
    background: var(--bg-selected);
    border-left: 3px solid var(--accent);
    padding-left: 17px;
}

.note-item-top {
    display: flex; align-items: center;
    justify-content: space-between;
    gap: 8px; margin-bottom: 5px;
}

.note-item-meta {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.72rem; color: var(--text-muted);
}

.note-item-badges {
    display: flex; align-items: center; gap: 5px;
}

.badge-sm {
    display: inline-block;
    padding: 1px 7px; border-radius: 10px;
    font-size: 0.66rem; font-weight: 700;
    white-space: nowrap; letter-spacing: 0.01em;
}
.badge-project-sm {
    display: inline-block;
    padding: 1px 7px; border-radius: 10px;
    font-size: 0.66rem; font-weight: 600;
    background: #f0f2f5; color: #5f6b7a;
    white-space: nowrap;
}

.note-item-summary {
    font-size: 0.85rem; color: var(--text);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-item-tags {
    display: flex; flex-wrap: wrap; gap: 4px;
    margin-top: 6px;
}
.note-item-tag {
    font-size: 0.65rem; color: var(--text-muted);
    background: var(--bg); padding: 1px 6px; border-radius: 4px;
}

.note-item-duration {
    display: inline-flex; align-items: center; gap: 2px;
}
.note-item-duration svg { width: 11px; height: 11px; fill: var(--text-muted); }

/* Done state */
.note-item.done { opacity: 0.5; }
.note-item.done .note-item-summary { text-decoration: line-through; }

.source-icon { display: inline-flex; align-items: center; }
.source-icon svg { width: 11px; height: 11px; fill: var(--text-muted); }

/* Results / Load more */
.list-footer {
    padding: 12px 20px;
    text-align: center;
}

.results-info {
    font-size: 0.72rem; color: var(--text-muted);
    padding: 8px 20px 0;
}

.btn-load-more {
    background: var(--bg); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 28px; font-size: 0.82rem; font-weight: 600;
    font-family: var(--font); color: var(--text-secondary);
    cursor: pointer; transition: background 0.15s;
}
.btn-load-more:hover { background: var(--bg-hover); }

/* --- Detail Panel --- */
.detail-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 100%; color: var(--text-muted);
    padding: 40px;
}
.detail-empty svg { width: 48px; height: 48px; fill: var(--text-muted); opacity: 0.3; margin-bottom: 12px; }
.detail-empty h3 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 4px; }
.detail-empty p { font-size: 0.82rem; }

.detail-content { padding: 28px 32px 40px; max-width: 720px; }

.detail-header { margin-bottom: 24px; }

.detail-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

.badge-lg {
    display: inline-block; padding: 3px 12px; border-radius: 14px;
    font-size: 0.78rem; font-weight: 700;
}
.badge-project-lg {
    display: inline-block; padding: 3px 12px; border-radius: 14px;
    font-size: 0.78rem; font-weight: 600;
    background: #f0f2f5; color: #5f6b7a;
}

.detail-meta {
    display: flex; align-items: center; gap: 12px;
    font-size: 0.8rem; color: var(--text-muted);
}
.detail-meta .dur {
    display: inline-flex; align-items: center; gap: 4px;
}
.detail-meta .dur svg { width: 14px; height: 14px; fill: var(--text-muted); }

.detail-section { margin-bottom: 24px; }

.detail-section-title {
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); margin-bottom: 8px;
}

.detail-summary {
    font-size: 1rem; line-height: 1.65;
    color: var(--text); font-weight: 500;
}

.detail-text {
    font-size: 0.9rem; line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap; word-break: break-word;
}

.detail-tags {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.detail-tag {
    font-size: 0.75rem; color: var(--text-muted);
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 3px 10px; border-radius: 6px;
}

/* Detail actions bar */
.detail-actions {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 0; margin-top: 8px;
    border-top: 1px solid var(--border-light);
    flex-wrap: wrap;
}
.detail-actions label {
    font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
}
.detail-actions select {
    padding: 7px 28px 7px 10px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.82rem; font-family: var(--font);
    background: var(--bg-card); color: var(--text);
    cursor: pointer; outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%238b95a5' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.btn-delete {
    margin-left: auto;
    padding: 7px 18px;
    background: transparent; color: #dc2626;
    border: 1.5px solid #fecaca; border-radius: var(--radius-sm);
    font-size: 0.82rem; font-weight: 600; font-family: var(--font);
    cursor: pointer; transition: background 0.15s;
}
.btn-delete:hover { background: #fee2e2; }

/* Done toggle in detail */
.done-toggle {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; user-select: none;
}
.done-toggle input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: var(--accent);
    cursor: pointer;
}
.done-toggle span {
    font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
}

/* Source badge in detail */
.badge-source {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 14px;
    font-size: 0.72rem; font-weight: 600;
    background: #f0f2f5; color: #5f6b7a;
}
.badge-source svg { width: 12px; height: 12px; fill: currentColor; }

/* Toolbar toggle for done */
.toolbar-toggle {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 12px; border-radius: 16px;
    font-size: 0.78rem; font-weight: 600;
    cursor: pointer; user-select: none;
    white-space: nowrap; flex-shrink: 0;
    background: var(--bg); color: var(--text-muted);
    border: 1.5px solid var(--border);
    transition: all 0.15s;
}
.toolbar-toggle.active {
    background: #d1fae5; color: #059669;
    border-color: #a7f3d0;
}
.toolbar-toggle:active { transform: scale(0.95); }

/* --- Multiselect --- */
.note-item .multi-check {
    display: none;
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
    transition: all 0.15s;
    align-items: center;
    justify-content: center;
}
.note-item.multiselect .multi-check { display: flex; }
.note-item.multi-selected .multi-check {
    background: var(--accent);
    border-color: var(--accent);
}
.note-item.multi-selected .multi-check::after {
    content: '\2713';
    color: white;
    font-size: 12px;
    font-weight: bold;
}
.note-item.multi-selected {
    background: var(--accent-light);
}
.multiselect-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 10px 20px;
    border-radius: 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    z-index: 100;
    font-size: 14px;
    font-weight: 500;
}
.multiselect-bar button {
    background: white;
    color: var(--accent);
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}
.multiselect-bar button:hover { opacity: 0.9; }
.multiselect-bar button:disabled { opacity: 0.5; cursor: not-allowed; }
.multiselect-bar .ms-cancel {
    background: transparent;
    color: white;
    padding: 4px 8px;
    font-size: 18px;
}

/* --- Mobile Back Button (detail view) --- */
.mobile-back {
    display: none;
    align-items: center; gap: 6px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem; font-weight: 600; color: var(--accent);
    cursor: pointer; user-select: none;
}
.mobile-back svg { width: 18px; height: 18px; fill: var(--accent); }

/* --- Empty / Loading --- */
.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state svg { width: 44px; height: 44px; fill: var(--text-muted); opacity: 0.3; margin-bottom: 10px; }
.empty-state h3 { font-size: 1rem; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state p { font-size: 0.82rem; }

.loading-bar {
    height: 2px;
    background: linear-gradient(90deg, var(--accent), #a78bfa, var(--accent));
    background-size: 200% 100%;
    animation: loading-slide 1s linear infinite;
    display: none; flex-shrink: 0;
}
.loading-bar.visible { display: block; }
@keyframes loading-slide {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
}
.sk-line {
    height: 10px; border-radius: 5px;
    background: linear-gradient(90deg, #e8ebef 25%, #f4f6f8 50%, #e8ebef 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    margin-bottom: 7px;
}
.sk-line:last-child { margin-bottom: 0; }
.sk-w40 { width: 40%; }
.sk-w80 { width: 80%; }
.sk-w60 { width: 60%; }
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============ PRIORITY BADGES ============ */
.badge-priority {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 0.66rem; font-weight: 700; white-space: nowrap;
}
.badge-priority-high { background: var(--priority-high-bg); color: var(--priority-high); }
.badge-priority-medium { background: var(--priority-medium-bg); color: var(--priority-medium); }
.badge-priority-low { background: var(--priority-low-bg); color: var(--priority-low); }

/* ============ RELATED NOTES ============ */
.related-notes-section { margin-top: 8px; }
.related-notes-list { display: flex; flex-direction: column; gap: 6px; }
.related-note-link {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer; transition: background 0.12s, border-color 0.12s;
}
.related-note-link:hover { background: var(--bg-hover); border-color: var(--accent); }
.related-note-link .related-note-summary {
    font-size: 0.82rem; color: var(--text); line-height: 1.4;
    flex: 1;
}
.related-note-link .badge-sm { flex-shrink: 0; }

/* ============ TASK DETAIL FIELDS ============ */
.task-fields {
    display: flex; align-items: center; gap: 14px;
    flex-wrap: wrap; padding: 8px 0;
}
.task-field-group {
    display: flex; align-items: center; gap: 6px;
}
.task-field-group label {
    font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
}
.task-field-group svg { width: 14px; height: 14px; fill: var(--text-muted); }
.task-field-group input,
.task-field-group select {
    padding: 5px 10px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.8rem; font-family: var(--font);
    background: var(--bg-card); color: var(--text);
    outline: none;
}
.task-field-group input:focus,
.task-field-group select:focus { border-color: var(--accent); }

/* ============ CALENDAR VIEW ============ */
.calendar-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.calendar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
}
.calendar-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.calendar-nav-btn {
    width: 32px; height: 32px;
    background: var(--bg); border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted);
    transition: background 0.15s;
}
.calendar-nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.calendar-nav-btn svg { width: 16px; height: 16px; fill: currentColor; }

.calendar-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 0;
}
.calendar-day-label {
    padding: 8px 4px;
    text-align: center;
    font-size: 0.7rem; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-light);
}
.calendar-cell {
    padding: 6px 4px;
    text-align: center;
    min-height: 44px;
    cursor: pointer;
    transition: background 0.12s;
    border-bottom: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    position: relative;
}
.calendar-cell:nth-child(7n) { border-right: none; }
.calendar-cell:hover { background: var(--bg-hover); }
.calendar-cell.other-month { color: var(--text-muted); opacity: 0.4; }
.calendar-cell.today {
    background: var(--accent-light);
    font-weight: 700;
}
.calendar-cell.selected {
    background: var(--accent);
    color: #fff;
    border-radius: 0;
}
.calendar-cell .day-num { font-size: 0.8rem; line-height: 1; }
.calendar-cell .day-dots {
    display: flex; justify-content: center; gap: 3px;
    margin-top: 4px;
}
.calendar-dot {
    width: 6px; height: 6px; border-radius: 50%;
}
.calendar-dot.high { background: var(--priority-high); }
.calendar-dot.medium { background: var(--priority-medium); }
.calendar-dot.low { background: var(--priority-low); }

/* Task list below calendar */
.tasks-list-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.tasks-list-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
}
.tasks-list-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.tasks-list-header .task-count {
    font-size: 0.75rem; font-weight: 600;
    padding: 2px 10px; border-radius: 10px;
    background: var(--bg); color: var(--text-muted);
}

.task-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer; transition: background 0.12s;
}
.task-item:hover { background: var(--bg-hover); }
.task-item:last-child { border-bottom: none; }
.task-item.task-done { opacity: 0.5; }
.task-item.task-done .task-item-summary { text-decoration: line-through; }

.task-item-check {
    width: 20px; height: 20px;
    accent-color: var(--accent);
    cursor: pointer; flex-shrink: 0;
}
.task-item-body { flex: 1; min-width: 0; }
.task-item-summary {
    font-size: 0.85rem; color: var(--text); line-height: 1.4;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.task-item-sub {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.72rem; color: var(--text-muted); margin-top: 2px;
}
.task-item-sub svg { width: 11px; height: 11px; fill: currentColor; }

/* ============ DRAFTS VIEW ============ */
.drafts-view {
    display: flex; width: 100%;
    overflow: hidden;
}

.drafts-list-panel {
    width: 100%;
    overflow-y: auto;
    border-right: 1px solid var(--border-light);
    background: var(--bg-card);
}

.drafts-detail-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
    background: var(--bg);
}

.draft-item {
    display: flex; flex-direction: column;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer; transition: background 0.12s;
}
.draft-item:hover { background: var(--bg-hover); }
.draft-item.selected {
    background: var(--bg-selected);
    border-left: 3px solid var(--accent);
    padding-left: 17px;
}
.draft-item-top {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-bottom: 4px;
}
.draft-item-title {
    font-size: 0.88rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.draft-item-date {
    font-size: 0.72rem; color: var(--text-muted); white-space: nowrap;
}
.badge-draft-status {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 0.66rem; font-weight: 700; white-space: nowrap;
}
.badge-draft-status.draft { background: #fef3c7; color: #d97706; }
.badge-draft-status.published { background: #d1fae5; color: #059669; }
.badge-draft-status.reviewed { background: #dbeafe; color: #1d4ed8; }

.draft-detail-content {
    padding: 28px 32px 40px;
    max-width: 720px;
}
.draft-detail-title {
    font-size: 1.2rem; font-weight: 700;
    color: var(--text); margin-bottom: 8px;
}
.draft-detail-meta {
    display: flex; align-items: center; gap: 12px;
    font-size: 0.8rem; color: var(--text-muted);
    margin-bottom: 20px;
}
.draft-detail-body {
    font-size: 0.92rem; line-height: 1.75;
    color: var(--text-secondary);
    white-space: pre-wrap; word-break: break-word;
}
.draft-detail-body h1,
.draft-detail-body h2,
.draft-detail-body h3 {
    color: var(--text); margin: 16px 0 8px; line-height: 1.3;
}
.draft-detail-body h1 { font-size: 1.3rem; }
.draft-detail-body h2 { font-size: 1.1rem; }
.draft-detail-body h3 { font-size: 0.95rem; }
.draft-detail-body p { margin-bottom: 10px; }
.draft-detail-body ul, .draft-detail-body ol { margin: 8px 0 8px 20px; }
.draft-detail-body code {
    background: var(--bg); padding: 1px 5px; border-radius: 3px;
    font-size: 0.85em;
}
.draft-detail-body pre {
    background: var(--bg); padding: 12px 16px; border-radius: var(--radius-sm);
    overflow-x: auto; margin: 10px 0;
}
.draft-detail-body pre code { background: none; padding: 0; }
.draft-detail-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 14px; margin: 10px 0;
    color: var(--text-muted); font-style: italic;
}
.draft-detail-body strong { color: var(--text); }

.draft-actions {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 0; margin-top: 16px;
    border-top: 1px solid var(--border-light);
}
.btn-draft-action {
    padding: 8px 20px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.82rem; font-weight: 600; font-family: var(--font);
    cursor: pointer; transition: background 0.15s;
    background: var(--bg-card); color: var(--text-secondary);
}
.btn-draft-action:hover { background: var(--bg-hover); }
.btn-draft-action.published {
    background: #d1fae5; color: #059669;
    border-color: #a7f3d0;
}
.btn-draft-action.expand {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border-color: transparent;
}
.btn-draft-action.expand:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

/* ============ EVENTS / CALENDAR VIEW ============ */
.events-view {
    display: flex; flex-direction: column;
    overflow-y: auto; width: 100%;
    padding: 20px;
    gap: 20px;
}

.biz-filters {
    display: flex; align-items: center; gap: 6px;
    flex-wrap: wrap;
}
.biz-pill {
    display: inline-flex; align-items: center;
    padding: 5px 14px; border-radius: 16px;
    font-size: 0.78rem; font-weight: 600;
    cursor: pointer; user-select: none;
    white-space: nowrap; flex-shrink: 0;
    border: 1.5px solid var(--border);
    background: var(--bg); color: var(--text-muted);
    transition: all 0.15s;
}
.biz-pill:active { transform: scale(0.95); }
.biz-pill.active { opacity: 1; }
.biz-pill.active[data-biz="malinski_ai"] { background: #eef2ff; color: #6366f1; border-color: #c7d2fe; }
.biz-pill.active[data-biz="gry_miejskie"] { background: #fef3c7; color: #d97706; border-color: #fde68a; }
.biz-pill.active[data-biz="riby"] { background: #d1fae5; color: #059669; border-color: #a7f3d0; }
.biz-pill.active[data-biz="task"] { background: var(--task-bg); color: var(--task-color); border-color: var(--task-border); }
.biz-pill.active[data-biz=""] { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

.event-card {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    border-left: 4px solid var(--border);
    transition: background 0.12s;
}
.event-card:hover { background: var(--bg-hover); }
.event-card:last-child { border-bottom: none; }

.event-card-time {
    font-size: 0.72rem; font-weight: 700;
    color: var(--text-muted); margin-bottom: 3px;
}
.event-card-title {
    font-size: 0.88rem; font-weight: 600;
    color: var(--text); margin-bottom: 4px;
    line-height: 1.4;
}
.event-card-info {
    font-size: 0.78rem; color: var(--text-secondary);
    line-height: 1.5;
}
.event-card-buffer {
    font-size: 0.72rem; color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}
.event-card-status {
    display: inline-block;
    padding: 1px 8px; border-radius: 10px;
    font-size: 0.66rem; font-weight: 700;
    margin-left: 8px;
}
.event-card-status.confirmed { background: #d1fae5; color: #059669; }
.event-card-status.tentative { background: #fef3c7; color: #d97706; }
.event-card-status.cancelled { background: #fee2e2; color: #dc2626; }

.calendar-dot.malinski { background: #6366f1; }
.calendar-dot.gry { background: #d97706; }
.calendar-dot.riby { background: #059669; }
.calendar-dot.task { background: var(--task-color); }

/* ============ PROJECTS TAB ============ */
.projects-view {
    display: flex; width: 100%;
    overflow: hidden;
}

.projects-list-panel {
    width: 100%;
    overflow-y: auto;
    border-right: 1px solid var(--border-light);
    background: var(--bg-card);
}

.projects-list-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    position: sticky; top: 0;
    background: var(--bg-card);
    z-index: 2;
}

.projects-list-header h3 {
    font-size: 1rem; font-weight: 600;
}

.btn-create-project {
    padding: 6px 14px;
    background: var(--accent);
    color: #fff;
    border: none; border-radius: var(--radius-sm);
    font-size: 0.82rem; font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-create-project:hover { background: #4f46e5; }

.projects-detail-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
    background: var(--bg);
}

.project-card {
    display: flex; flex-direction: column;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer; transition: background 0.12s;
}
.project-card:hover { background: var(--bg-hover); }
.project-card.selected {
    background: var(--bg-selected);
    border-left: 3px solid var(--accent);
    padding-left: 17px;
}

.project-card-name {
    font-weight: 600; font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 4px;
}

.project-card-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

.project-card-meta {
    display: flex; gap: 12px; align-items: center;
    font-size: 0.78rem; color: var(--text-muted);
}

.project-card-count {
    display: inline-flex; align-items: center; gap: 4px;
}

.project-empty {
    padding: 40px 20px; text-align: center;
    color: var(--text-muted); font-size: 0.9rem;
}

/* Project detail */
.project-detail-header {
    padding: 24px 28px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
}

.project-detail-name {
    font-size: 1.25rem; font-weight: 700;
    margin-bottom: 4px;
}

.project-detail-desc {
    font-size: 0.9rem; color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.project-detail-stats {
    display: flex; gap: 16px;
    font-size: 0.82rem; color: var(--text-muted);
    margin-bottom: 12px;
}

.project-detail-actions {
    display: flex; gap: 8px;
}

.project-detail-actions button {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s;
}
.project-detail-actions button:hover { background: var(--bg-hover); }

.project-notes-header {
    padding: 16px 28px 8px;
    font-size: 0.85rem; font-weight: 600;
    color: var(--text-secondary);
}

.project-note-item {
    display: flex; flex-direction: column;
    padding: 12px 28px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.12s;
}
.project-note-item:hover { background: var(--bg-hover); }

.project-note-summary {
    font-size: 0.9rem; color: var(--text);
    margin-bottom: 4px;
}

.project-note-meta {
    display: flex; gap: 8px; align-items: center;
    font-size: 0.78rem; color: var(--text-muted);
}

.detail-empty-state {
    padding: 60px 20px; text-align: center;
    color: var(--text-muted); font-size: 0.9rem;
}

/* Project modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay.hidden { display: none; }

.modal-box {
    background: var(--bg-card);
    border-radius: 14px;
    width: 100%; max-width: 480px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }

.modal-close {
    background: none; border: none;
    font-size: 1.5rem; color: var(--text-muted);
    cursor: pointer; line-height: 1;
}

.modal-body { padding: 20px 24px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 14px 24px;
    border-top: 1px solid var(--border-light);
}


/* ============ EXPORT DROPDOWN ============ */
.export-dropdown { position: relative; }
.export-menu {
    position: absolute; top: 100%; right: 0; z-index: 100;
    background: var(--bg-card); border: 1px solid var(--border-light);
    border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px; padding: 4px 0;
}
.export-menu.hidden { display: none; }
.export-item {
    display: block; padding: 10px 16px;
    color: var(--text); text-decoration: none;
    font-size: 0.85rem;
}
.export-item:hover { background: var(--bg-hover); }

/* ============ ANALYTICS ============ */
.analytics-view {
    padding: 20px;
    overflow-y: auto;
    height: 100%;
}
.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
}
.analytics-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
}
.analytics-card.wide {
    grid-column: 1 / -1;
}
.analytics-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
}
.top-tags-list {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.tag-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    background: var(--bg-hover);
    border-radius: 20px;
    font-size: 0.82rem;
    color: var(--text);
}
.tag-pill .tag-count {
    font-weight: 600;
    color: var(--accent);
}
.heatmap-container {
    overflow-x: auto;
}
.heatmap-grid {
    display: grid;
    grid-template-columns: 40px repeat(24, 1fr);
    gap: 2px;
    font-size: 0.7rem;
    min-width: 600px;
}
.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    min-height: 18px;
}
.heatmap-label {
    display: flex; align-items: center; justify-content: flex-end;
    padding-right: 6px;
    font-size: 0.72rem; color: var(--text-muted);
}
.heatmap-hour-label {
    text-align: center;
    font-size: 0.65rem; color: var(--text-muted);
    padding-top: 2px;
}
.project-health-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.ph-card {
    padding: 16px;
    background: var(--bg-hover);
    border-radius: 10px;
    border-left: 4px solid var(--accent);
}
.ph-card.declining { border-left-color: #ef4444; }
.ph-card.growing { border-left-color: #22c55e; }
.ph-card.stable { border-left-color: #f59e0b; }
.ph-name {
    font-weight: 600; font-size: 0.95rem;
    margin-bottom: 8px;
}
.ph-stats {
    display: flex; flex-wrap: wrap; gap: 8px;
    font-size: 0.78rem; color: var(--text-secondary);
}
.ph-stat {
    display: inline-flex; align-items: center; gap: 4px;
}
@media (max-width: 899px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}
.kg-node { cursor: pointer; }
.kg-node circle { stroke: #fff; stroke-width: 1.5px; }
.kg-link { stroke: #ccc; stroke-opacity: 0.6; stroke-width: 1.5px; }
.kg-label { font-size: 10px; fill: var(--text-secondary); pointer-events: none; }
.kg-tooltip {
    position: absolute; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 12px; font-size: 0.8rem;
    box-shadow: var(--shadow-md); pointer-events: none; z-index: 10; display: none;
}

/* ============ RESPONSIVE ============ */

/* Desktop: >=900px -- side-by-side */
@media (min-width: 900px) {
    .panel-list { width: 400px; min-width: 340px; flex-shrink: 0; }
    .panel-detail { display: flex; flex-direction: column; }
    .mobile-back { display: none !important; }
    .search-box { width: 200px; }

    .drafts-list-panel { width: 400px; min-width: 340px; flex-shrink: 0; }
    .drafts-detail-panel { display: flex; flex-direction: column; }
    .projects-list-panel { width: 400px; min-width: 340px; flex-shrink: 0; }
    .projects-detail-panel { display: flex; flex-direction: column; }
}

@media (min-width: 1100px) {
    .panel-list { width: 440px; }
    .search-box { width: 240px; }
    .drafts-list-panel { width: 440px; }
    .projects-list-panel { width: 440px; }
}

@media (min-width: 1400px) {
    .panel-list { width: 500px; }
    .drafts-list-panel { width: 500px; }
    .projects-list-panel { width: 500px; }
}

/* Mobile: <900px */
@media (max-width: 899px) {
    .search-box { width: 160px; flex-shrink: 1; min-width: 120px; }
    .toolbar { padding: 8px 12px; gap: 6px; }
    .note-item { padding: 12px 16px; }
    .detail-content { padding: 20px 16px 32px; }
    .draft-detail-content { padding: 20px 16px 32px; }

    .header-tabs { margin-left: 4px; }
    .header-tab { padding: 6px 10px; font-size: 0.78rem; }

    .events-view { padding: 12px; gap: 12px; }

    /* Mobile: list or detail, not both */
    .panel-list { width: 100%; }
    .panel-detail {
        display: none;
        position: absolute; inset: 0; z-index: 5;
        background: var(--bg);
    }

    .drafts-list-panel { width: 100%; }
    .drafts-detail-panel {
        display: none;
        position: absolute; inset: 0; z-index: 5;
        background: var(--bg);
    }

    .content { position: relative; }

    .app.mobile-detail .panel-list { display: none; }
    .app.mobile-detail .panel-detail { display: flex; flex-direction: column; }
    .app.mobile-detail .mobile-back { display: flex; }
    .app.mobile-detail .toolbar { display: none; }

    .app.mobile-draft-detail .drafts-list-panel { display: none; }
    .app.mobile-draft-detail .drafts-detail-panel { display: flex; flex-direction: column; }
    .app.mobile-draft-detail .mobile-back-draft { display: flex; }

    .projects-list-panel { width: 100%; }
    .projects-detail-panel {
        position: absolute; top: 0; left: 0; right: 0; bottom: 0;
        background: var(--bg); z-index: 5; display: none;
    }
    .app.mobile-project-detail .projects-list-panel { display: none; }
    .app.mobile-project-detail .projects-detail-panel { display: flex; flex-direction: column; }
    .app.mobile-project-detail .mobile-back { display: flex; }
}

/* ============ EVENT CREATION FAB + MODAL ============ */
.event-fab {
    position: fixed; bottom: 24px; right: 24px;
    width: 56px; height: 56px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; border: none;
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
    display: none; align-items: center; justify-content: center;
    cursor: pointer; z-index: 50;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 28px; line-height: 1;
}
.event-fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(99,102,241,0.5); }
.event-fab:active { transform: scale(0.95); }
.event-fab.visible { display: flex; }

.event-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1500;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    opacity: 0; visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}
.event-modal-overlay.open { opacity: 1; visibility: visible; }

.event-modal {
    background: var(--bg-card); border-radius: 14px;
    width: 100%; max-width: 520px; max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,0.25);
    transform: translateY(20px); transition: transform 0.2s;
}
.event-modal-overlay.open .event-modal { transform: translateY(0); }

.event-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-light);
}
.event-modal-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin: 0; }
.event-modal-close {
    width: 32px; height: 32px;
    background: var(--bg); border: none; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted);
    font-size: 18px; line-height: 1;
    transition: background 0.15s;
}
.event-modal-close:hover { background: var(--bg-hover); color: var(--text); }

.event-modal-body { padding: 20px 24px; }
.event-modal-footer {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
}

.biz-selector { display: flex; gap: 8px; margin-bottom: 20px; }
.biz-selector-btn {
    flex: 1; padding: 10px 8px;
    border: 2px solid var(--border); border-radius: var(--radius);
    background: var(--bg-card); cursor: pointer;
    text-align: center; font-size: 0.82rem; font-weight: 600;
    font-family: var(--font); transition: all 0.15s;
    color: var(--text-secondary);
}
.biz-selector-btn:hover { border-color: var(--text-muted); }
.biz-selector-btn.active[data-biz="malinski_ai"] { border-color: #6366f1; background: #eef2ff; color: #6366f1; }
.biz-selector-btn.active[data-biz="gry_miejskie"] { border-color: #d97706; background: #fef3c7; color: #d97706; }
.biz-selector-btn.active[data-biz="riby"] { border-color: #059669; background: #d1fae5; color: #059669; }
.biz-selector-btn .biz-icon { font-size: 1.3rem; display: block; margin-bottom: 4px; }

.event-form-group { margin-bottom: 16px; }
.event-form-group label {
    display: block; font-size: 0.78rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 5px;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.event-form-group input,
.event-form-group select,
.event-form-group textarea {
    width: 100%; padding: 10px 14px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.9rem; font-family: var(--font);
    background: var(--bg); color: var(--text);
    outline: none; transition: border-color 0.2s;
    box-sizing: border-box;
}
.event-form-group input:focus,
.event-form-group select:focus,
.event-form-group textarea:focus { border-color: var(--accent); }
.event-form-group textarea { resize: vertical; min-height: 60px; }

.event-form-row { display: flex; gap: 12px; }
.event-form-row .event-form-group { flex: 1; }

.event-form-toggle {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px; cursor: pointer; user-select: none;
}
.event-form-toggle input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer;
}
.event-form-toggle span { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }

.event-form-section-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 0; cursor: pointer;
    font-size: 0.82rem; font-weight: 600;
    color: var(--accent); user-select: none;
    border: none; background: none; font-family: var(--font);
    margin-bottom: 8px;
}
.event-form-section-toggle:hover { text-decoration: underline; }
.client-fields { display: none; }
.client-fields.visible { display: block; }

.btn-event-submit {
    padding: 10px 28px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; border: none; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; font-family: var(--font);
    cursor: pointer; transition: opacity 0.2s;
}
.btn-event-submit:hover { opacity: 0.9; }
.btn-event-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-event-cancel {
    padding: 10px 22px;
    background: var(--bg); color: var(--text-secondary);
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; font-family: var(--font);
    cursor: pointer; transition: background 0.15s;
}
.btn-event-cancel:hover { background: var(--bg-hover); }
.btn-event-delete {
    padding: 10px 22px;
    background: #fee2e2; color: #dc2626;
    border: 1.5px solid #fecaca; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; font-family: var(--font);
    cursor: pointer; transition: background 0.15s;
    margin-right: auto;
}
.btn-event-delete:hover { background: #dc2626; color: #fff; }

.event-form-error {
    font-size: 0.82rem; color: #dc2626; margin-top: 8px; display: none;
}
.event-form-error.visible { display: block; }
.event-form-success {
    font-size: 0.82rem; color: #059669; margin-top: 8px; display: none;
}
.event-form-success.visible { display: block; }

@media (max-width: 899px) {
    .event-fab { bottom: 16px; right: 16px; width: 50px; height: 50px; font-size: 24px; }
    .event-modal-overlay { align-items: flex-end; padding: 0; }
    .event-modal { max-width: 100%; border-radius: 14px 14px 0 0; max-height: 92vh; }
    .event-modal-body { padding: 16px; }
    .event-form-row { flex-direction: column; gap: 0; }
}

/* ============ DARK MODE ============ */
[data-theme="dark"] {
    --bg: #0f1117;
    --bg-card: #1a1d28;
    --bg-hover: #242836;
    --bg-selected: #1e2340;
    --text: #e4e6eb;
    --text-secondary: #9ba3b5;
    --text-muted: #6b7385;
    --border: #2a2e3d;
    --border-light: #222633;
    --accent: #818cf8;
    --accent-light: #1e2340;
    --shadow: 0 1px 3px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.15);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.3);
    --priority-high-bg: #3b1118;
    --priority-medium-bg: #3b2e10;
    --priority-low-bg: #0d3324;
    --task-bg: #2a1845;
    --task-border: #3d2a6b;
}

[data-theme="dark"] .login-box {
    background: var(--bg-card);
}
[data-theme="dark"] .login-field {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .confirm-overlay {
    background: rgba(0,0,0,0.6);
}
[data-theme="dark"] .event-modal-overlay {
    background: rgba(0,0,0,0.6);
}

/* ============ THEME TOGGLE ============ */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 1.1rem;
}
.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text);
}
