/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-card: #1c2128;
    --border: #30363d;
    --accent: #58a6ff;
    --accent-green: #2ea043;
    --accent-red: #f85149;
    --accent-yellow: #d29922;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --btn-hover: #2d333b;
    --btn-success-hover: #238636;
    --btn-danger-hover: #da3633;
    --bubble-user-bg: #0d419d;
    --bubble-error-bg: #3d1f1f;
    --code-bg: #161b22;
    --strong-color: #ffffff;
    --radius: 8px;
    --radius-lg: 12px;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #eaeef2;
    --bg-card: #ffffff;
    --border: #d0d7de;
    --accent: #0969da;
    --accent-green: #1a7f37;
    --accent-red: #cf222e;
    --accent-yellow: #9a6700;
    --text-primary: #1f2328;
    --text-secondary: #656d76;
    --text-muted: #8c959f;
    --btn-hover: #eef1f4;
    --btn-success-hover: #116329;
    --btn-danger-hover: #a40e26;
    --bubble-user-bg: #ddf4ff;
    --bubble-error-bg: #ffebe9;
    --code-bg: #f6f8fa;
    --strong-color: #1f2328;
}

/* ── Sakura: girly pink light ───────────────────────────────────────────── */
[data-theme="sakura"] {
    --bg-primary: #fff0f5;
    --bg-secondary: #ffe4ef;
    --bg-tertiary: #ffd6e7;
    --bg-card: #fff5f8;
    --border: #f9b8d0;
    --accent: #e8518a;
    --accent-green: #2e9e6b;
    --accent-red: #e03e3e;
    --accent-yellow: #c48a00;
    --text-primary: #3d1a2a;
    --text-secondary: #a05070;
    --text-muted: #c9a0b0;
    --btn-hover: #ffd6e7;
    --btn-success-hover: #1e7a50;
    --btn-danger-hover: #b82e2e;
    --bubble-user-bg: #fadadd;
    --bubble-error-bg: #ffe4e1;
    --code-bg: #ffe4ef;
    --strong-color: #2a0f1e;
}

/* ── Abyss: OLED pure black ─────────────────────────────────────────────── */
[data-theme="abyss"] {
    --bg-primary: #000000;
    --bg-secondary: #0d0d0d;
    --bg-tertiary: #1a1a1a;
    --bg-card: #111111;
    --border: #272727;
    --accent: #58a6ff;
    --accent-green: #3fb950;
    --accent-red: #f85149;
    --accent-yellow: #d29922;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --btn-hover: #1a1a1a;
    --btn-success-hover: #238636;
    --btn-danger-hover: #da3633;
    --bubble-user-bg: #0d419d;
    --bubble-error-bg: #3d1f1f;
    --code-bg: #0d0d0d;
    --strong-color: #ffffff;
}

/* ── Forest: deep dark green ────────────────────────────────────────────── */
[data-theme="forest"] {
    --bg-primary: #1a2f28;
    --bg-secondary: #234238;
    --bg-tertiary: #2e5449;
    --bg-card: #1f3a33;
    --border: #2d5244;
    --accent: #4ade80;
    --accent-green: #22c55e;
    --accent-red: #f87171;
    --accent-yellow: #fbbf24;
    --text-primary: #d0e8e0;
    --text-secondary: #6b9d80;
    --text-muted: #4a7560;
    --btn-hover: #2e5449;
    --btn-success-hover: #16a34a;
    --btn-danger-hover: #dc2626;
    --bubble-user-bg: #0f5d2a;
    --bubble-error-bg: #551515;
    --code-bg: #234238;
    --strong-color: #e8f5ee;
}

/* ── Amethyst: deep purple ──────────────────────────────────────────────── */
[data-theme="amethyst"] {
    --bg-primary: #1a1533;
    --bg-secondary: #251d47;
    --bg-tertiary: #312659;
    --bg-card: #2a1f4a;
    --border: #3d3570;
    --accent: #a78bfa;
    --accent-green: #34d399;
    --accent-red: #f87171;
    --accent-yellow: #fbbf24;
    --text-primary: #d9d4f0;
    --text-secondary: #8d7cb8;
    --text-muted: #5a4d90;
    --btn-hover: #312659;
    --btn-success-hover: #059669;
    --btn-danger-hover: #dc2626;
    --bubble-user-bg: #4a2a9e;
    --bubble-error-bg: #552535;
    --code-bg: #251d47;
    --strong-color: #f0ecff;
}

/* ── Mocha: warm earthy brown ───────────────────────────────────────────── */
[data-theme="mocha"] {
    --bg-primary: #2a1f12;
    --bg-secondary: #3a2e20;
    --bg-tertiary: #4a3a2a;
    --bg-card: #3f331f;
    --border: #5a4830;
    --accent: #fb923c;
    --accent-green: #86efac;
    --accent-red: #f87171;
    --accent-yellow: #fde047;
    --text-primary: #e6dab0;
    --text-secondary: #b0956a;
    --text-muted: #7a6a52;
    --btn-hover: #4a3a2a;
    --btn-success-hover: #16a34a;
    --btn-danger-hover: #dc2626;
    --bubble-user-bg: #a85a1a;
    --bubble-error-bg: #5a3525;
    --code-bg: #3a2e20;
    --strong-color: #fffbeb;
}

/* ── Ink Wash: rice-paper light with sumi-e ink + cinnabar seal accent ───── */
[data-theme="ink"] {
    --bg-primary: #f3efe4;
    --bg-secondary: #e9e3d4;
    --bg-tertiary: #ded6c2;
    --bg-card: #f7f3ea;
    --border: #c8bca2;
    --accent: #8a2b22;
    --accent-green: #4f6b54;
    --accent-red: #a8322a;
    --accent-yellow: #a87f33;
    --text-primary: #211d17;
    --text-secondary: #5a5346;
    --text-muted: #948c79;
    --btn-hover: #ded6c2;
    --btn-success-hover: #3f5743;
    --btn-danger-hover: #7f261f;
    --bubble-user-bg: #e3d9c2;
    --bubble-error-bg: #f0ddd6;
    --code-bg: #e9e3d4;
    --strong-color: #1a1610;
}
[data-theme="ink"] body {
    background-image: radial-gradient(ellipse at center, rgba(0,0,0,0) 62%, rgba(90,70,40,0.06) 100%);
    background-attachment: fixed;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Nav ──────────────────────────────────────────────────────────────── */
#nav {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    height: 48px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    margin-right: 8px;
}

.nav-tabs { display: flex; gap: 2px; }

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px 14px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    border-bottom: 2px solid transparent;
    transition: all .15s;
    filter: grayscale(0.6);
    opacity: 0.7;
}
.tab-btn:hover { color: var(--text-primary); filter: grayscale(0); opacity: 1; }
.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    filter: grayscale(0);
    opacity: 1;
}
.nav-settings-btn {
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
}
.nav-settings-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }

/* ── Current Task Bar ────────────────────────────────────────────────── */
.current-task-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    min-height: 32px;
}
.current-task-bar.has-task { background: rgba(46,160,67,0.1); border-bottom-color: rgba(46,160,67,0.3); }

.free-hours-display {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    cursor: help;
    flex-shrink: 0;
}
.current-task-label { color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; flex-shrink: 0; }
.current-task-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.current-task-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.current-task-time { color: var(--text-secondary); font-size: 12px; flex-shrink: 0; }
.toggle-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ── Tag Manager ─────────────────────────────────────────────────────── */
.tag-rules-list {
    max-height: 55vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.tag-rule-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tag-rule-header {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.tag-rule-name, .tag-rule-select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    width: 100%;
}
.day-checks {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.day-label {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    transition: background .15s;
}
.day-label:has(input:checked) {
    background: rgba(88,166,255,0.15);
    border-color: var(--accent);
    color: var(--accent);
}
.day-label input { display: none; }
.time-ranges { display: flex; flex-direction: column; gap: 4px; }
.time-range-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.time-range-row input[type="time"] {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
    width: 110px;
}
.time-range-row span { color: var(--text-muted); font-size: 12px; }

/* ── Main ─────────────────────────────────────────────────────────────── */
main {
    height: calc(100vh - 48px - 32px);
    overflow: hidden;
}

.tab-content {
    display: none;
    height: 100%;
    overflow: hidden;
}
.tab-content.active { display: flex; flex-direction: column; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background .15s;
    white-space: nowrap;
}
.btn:hover { background: var(--btn-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }
.btn-success { background: var(--accent-green); color: #fff; border-color: var(--accent-green); }
.btn-success:hover { background: var(--btn-success-hover); }
.btn-danger { background: var(--accent-red); color: #fff; border-color: var(--accent-red); }
.btn-danger:hover { background: var(--btn-danger-hover); }
.btn-secondary { background: var(--bg-tertiary); }
.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--accent);
    font-size: 12px;
    padding: 4px 12px;
}
.btn-outline:hover { background: var(--bg-tertiary); }

/* ── Forms ─────────────────────────────────────────────────────────────── */
input[type="text"], input[type="number"], input[type="date"], input[type="time"],
input[type="password"], textarea, select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
    outline: none;
    transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: inherit; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
/* Inside modals, trim vertical rhythm so more fields fit without scrolling */
.modal-content .form-group { margin-bottom: 10px; }
.modal-content .form-group label { margin-bottom: 2px; }

.radio-group { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-label { font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.modal-content .radio-group { gap: 12px; }

.form-container {
    max-width: 560px;
    margin: 40px auto;
    padding: 30px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.form-container h2 { margin-bottom: 20px; color: var(--accent); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: 12px; }
.preset-btns { display: flex; gap: 4px; margin-top: 4px; }

.select-sm {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    color: var(--text-primary);
    font-size: 12px;
}

/* ── Dashboard ────────────────────────────────────────────────────────── */
.dashboard-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.task-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.panel-actions { display: flex; gap: 4px; }
.icon-btn {
    font-size: 15px;
    line-height: 1;
    padding: 4px 8px;
    min-width: 32px;
    text-align: center;
}

.multi-select-btn {
    font-size: 16px;
    line-height: 1;
    padding: 4px 8px;
    flex-shrink: 0;
}
.multi-select-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.tree-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--accent);
    margin: 0;
}

.bulk-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}
.bulk-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin-right: 4px;
}

.panel-search {
    flex: 1;
    min-width: 80px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color .15s;
}
.panel-search:focus { border-color: var(--accent); }
.panel-search::placeholder { color: var(--text-muted); }

.task-tree {
    flex: 1;
    overflow: auto;
    padding: 0 0 8px;
}

/* Tree items */
.tree-item {
    padding: 0;
}
.tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 6px 8px;
    margin-left: calc(var(--depth, 0) * 20px);
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all .1s;
    font-size: 13px;
}
.tree-row:hover { background: var(--bg-tertiary); }
.tree-row.completed .tree-name { text-decoration: line-through; color: var(--text-muted); }
.tree-row.completed { opacity: 0.65; }
.tree-row.snoozed .tree-name { color: var(--text-muted); font-style: italic; }
.tree-row.snoozed { opacity: 0.75; }

.tree-snooze-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(110, 110, 200, 0.2);
    color: #a8a8d0;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 6px;
    flex-shrink: 0;
    white-space: nowrap;
}

.tree-row.dragging { opacity: 0.4; }
.tree-row.drag-over-top { box-shadow: inset 0 2px 0 0 var(--accent); }
.tree-row.drag-over-bottom { box-shadow: inset 0 -2px 0 0 var(--accent); }
/* Middle-zone drop = make this row the new parent of the dragged task.
   Subtle accent-tinted background + dashed border to distinguish from
   sibling-insertion (which is the slim top/bottom line above). */
.tree-row.drag-over-into {
    background: color-mix(in srgb, var(--accent) 18%, var(--bg-secondary));
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
}

.snooze-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 8px 0 16px;
}

/* In-app reminder popup */
/* ── App update banner ───────────────────────────────────────────────── */
#app-update-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9990;
    background: var(--bg-card);
    border-top: 2px solid var(--accent-green);
    padding: 12px 16px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
    animation: slideUpBanner 0.3s ease;
}
@keyframes slideUpBanner {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.update-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}
.update-banner-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.update-banner-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}
.update-banner-notes {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.update-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.reminder-popup {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 380px;
    background: var(--bg-secondary);
    border: 1px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    animation: reminder-slide-in .3s ease-out;
}
.reminder-popup.hidden { display: none; }

@keyframes reminder-slide-in {
    from { transform: translateX(420px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.reminder-popup-content {
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
}
.reminder-popup-icon {
    font-size: 28px;
    align-self: center;
}
.reminder-popup-body {
    text-align: center;
}
.reminder-popup-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 6px;
}
.reminder-popup-text {
    font-size: 13px;
    color: var(--text-primary);
    white-space: pre-line;
}
.reminder-popup-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
    align-items: center;
}
.reminder-strict-notice {
    width: 100%;
    font-size: 12px;
    color: var(--accent-yellow);
    margin-top: 4px;
    text-align: right;
}
.tree-row.selected {
    background: rgba(88,166,255,0.1);
    border-left-color: var(--accent);
}

.tree-toggle {
    width: 18px;
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}

.tree-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tree-name-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; }
.tree-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-type { font-size: 11px; color: var(--text-muted); width: var(--col-type-w, 60px); text-align: center; flex-shrink: 0; }
.tree-progress { width: var(--col-progress-w, 50px); flex-shrink: 0; }
.tree-time { font-size: 11px; color: var(--text-secondary); width: var(--col-time-w, 80px); text-align: right; flex-shrink: 0; }
.tree-deadline { font-size: 11px; width: var(--col-deadline-w, 110px); text-align: right; flex-shrink: 0; }
.tree-tags { width: var(--col-tags-w, 110px); min-width: 0; flex-shrink: 0; display: flex; flex-wrap: wrap; align-content: center; row-gap: 1px; max-height: 40px; overflow: hidden; font-size: 9px; }
/* Tags wrap to at most 2 rows. ColumnManager.fitTags() shrinks THIS cell's
   font-size (pills are sized in em) until they fit, so they scale down to stay
   visible instead of getting clipped. Each pill's own text never wraps.
   Scoped to the tree so the detail panel's tags keep their normal size. */
.tree-tags .tag { white-space: nowrap; font-size: 1em; padding: 0.1em 0.5em 0.1em 0.9em; margin: 0.12em 0.3em 0.12em 0.55em; line-height: 1.2; }
/* The notch arrow + hole are sized in em too, so the WHOLE pill (not just its
   text) shrinks when fitTags lowers the font — otherwise fixed-px margins and
   the 6px arrow eat a narrow column and shrinking the text alone can't fit. */
.tree-tags .tag::before { width: 0.5em; left: -0.5em; }
.tree-tags .tag::after { left: 0.3em; width: 0.35em; height: 0.35em; box-shadow: 0 0 0 0.14em rgba(255,255,255,0.6), inset 0 0 1px rgba(0,0,0,0.3); }

/* Column visibility — toggled from the Column Settings panel as classes on
   #task-tree, so showing/hiding a column never forces a tree re-render.
   !important wins over the narrow-screen width overrides further down. */
.task-tree.hide-col-tags .tree-tags,
.task-tree.hide-col-tags .th-col[data-col="tags"],
.task-tree.hide-col-type .tree-type,
.task-tree.hide-col-type .th-col[data-col="type"],
.task-tree.hide-col-progress .tree-progress,
.task-tree.hide-col-progress .th-col[data-col="progress"],
.task-tree.hide-col-time .tree-time,
.task-tree.hide-col-time .th-col[data-col="time"],
.task-tree.hide-col-deadline .tree-deadline,
.task-tree.hide-col-deadline .th-col[data-col="deadline"] { display: none !important; }

/* Sticky column header — lives INSIDE .task-tree (the scroll container) so its
   columns align with .tree-row and share the same scrollbar gutter. Mirrors the
   row's flex layout + CSS-var widths; a resize handle on each fixed column lets
   you drag-size in place. renderTree() preserves this node across re-renders. */
.tree-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 6px 8px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    user-select: none;
}
.th-spacer { width: 32px; flex-shrink: 0; }
.th-name { flex: 1; min-width: 0; }
.th-col { position: relative; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-col[data-col="tags"] { width: var(--col-tags-w, 110px); text-align: left; }
.th-col[data-col="type"] { width: var(--col-type-w, 60px); text-align: center; }
.th-col[data-col="progress"] { width: var(--col-progress-w, 50px); text-align: center; }
.th-col[data-col="time"] { width: var(--col-time-w, 80px); text-align: right; }
.th-col[data-col="deadline"] { width: var(--col-deadline-w, 110px); text-align: right; }
.th-resize {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -5px; /* on the column's LEFT edge (sits in the gap to the prev cell) */
    width: 10px;
    cursor: col-resize;
    z-index: 1;
    touch-action: none;
}
.th-resize::after {
    content: '';
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 4px;
    width: 2px;
    background: var(--border);
    border-radius: 1px;
}
.th-resize:hover::after,
body.col-resizing .th-resize::after { background: var(--accent); }
body.col-resizing { cursor: col-resize; user-select: none; }

/* Column Settings panel (ColumnManager) */
.column-manager-list { display: flex; flex-direction: column; gap: 6px; }
.column-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg-tertiary); }
.column-row.col-disabled { opacity: 0.5; }
.column-row-label { display: flex; align-items: center; gap: 8px; flex: 0 0 110px; font-size: 13px; cursor: pointer; user-select: none; }
.column-row-label input { cursor: pointer; }
.column-row-width { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.column-row-width input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); cursor: pointer; }
.column-row-width .col-width-val { flex: 0 0 auto; width: 46px; text-align: right; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.deadline-overdue { color: #f85149; font-weight: 600; }
.deadline-soon { color: #d29922; font-weight: 600; }
.deadline-normal { color: var(--text-secondary); }
.snooze-tag { color: #a371f7; font-weight: 600; font-size: 11px; }
.detail-snooze { background: rgba(163,113,247,0.12); color: #a371f7; padding: 6px 10px; border-radius: 4px; margin: 8px 0; font-size: 12px; border-left: 3px solid #a371f7; }

.tree-quick-add {
    opacity: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: opacity .15s, background .15s;
    margin-left: 2px;
    position: relative;
    top: -1px;
}
.tree-row:hover .tree-quick-add,
.tree-row.selected .tree-quick-add { opacity: 1; }
.tree-quick-add:hover { background: var(--bg-tertiary); }

.tree-quick-done {
    opacity: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-green);
    cursor: pointer;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: opacity .15s, background .15s;
    margin-left: 2px;
    position: relative;
    top: -1px;
}
.tree-row:hover .tree-quick-done,
.tree-row.selected .tree-quick-done { opacity: 1; }
.tree-quick-done:hover { background: var(--bg-tertiary); }

.quick-add-row {
    display: flex;
    align-items: center;
    padding: 4px 12px 4px 8px;
}
.quick-add-input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--accent);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 13px;
    outline: none;
}
.quick-add-input::placeholder { color: var(--text-muted); }

.tree-children { padding-left: 20px; }
.tree-children.collapsed { display: none; }

/* Progress bar */
.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent-green);
    transition: width .3s;
}

/* Status badges */
.status-active { color: #f0883e; }
.status-completed { color: var(--accent-green); }
.status-overdue { color: var(--accent-red); }

/* Tag badges — pastel backgrounds, dark text for contrast */
.tag {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    padding: 2px 8px 2px 14px;
    border-radius: 0 4px 4px 0;
    color: #1a1a1a;
    margin-right: 4px;
    margin-left: 6px;
    position: relative;
    font-weight: 600;
    line-height: 1.3;
}
/* Left arrow notch — transparent via clip-path on a pseudo-element that covers left side */
.tag::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0;
    bottom: 0;
    width: 6px;
    background: inherit;
    clip-path: polygon(100% 0%, 100% 100%, 0% 50%);
}
/* Hole punch — transparent ring */
.tag::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: transparent;
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.6), inset 0 0 1px rgba(0,0,0,0.3);
}

/* ── Detail Panel ─────────────────────────────────────────────────────── */
:root {
    --detail-panel-width: 320px;
}

.detail-wrapper {
    width: var(--detail-panel-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    transition: width 0.2s ease, transform 0.25s ease;
}
.detail-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -5px;
    width: 10px;
    cursor: col-resize;
    z-index: 3;
    touch-action: none;
}
.detail-resize-handle::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 4px;
    width: 2px;
    background: transparent;
    transition: background 0.12s ease;
}
.detail-resize-handle:hover::after,
body.detail-resizing .detail-resize-handle::after {
    background: var(--accent);
}
body.detail-resizing {
    cursor: col-resize;
    user-select: none;
}
body.detail-resizing .detail-wrapper {
    transition: none;
}
.detail-panel {
    flex: 1;
    overflow: auto;
    padding: 16px;
    background: var(--bg-secondary);
}
.detail-close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 22px;
    padding: 0;
    cursor: pointer;
    z-index: 2;
}
.detail-close-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}
.detail-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
}
.dashboard-layout.detail-hidden .detail-wrapper {
    display: none;
}

.detail-placeholder {
    color: var(--text-muted);
    text-align: center;
    padding-top: 60px;
    font-size: 14px;
}

.detail-breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
}
.breadcrumb-item {
    color: var(--text-secondary);
    cursor: pointer;
    transition: color .15s;
}
.breadcrumb-item:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb-sep { color: var(--text-muted); }
.breadcrumb-current { color: var(--text-secondary); }

.detail-name { font-size: 16px; font-weight: 700; color: var(--accent); margin-bottom: 8px; word-break: break-all; }
.detail-desc { color: var(--text-secondary); font-size: 13px; margin-bottom: 12px; white-space: pre-wrap; word-break: break-word; }
.detail-desc.collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}
.detail-desc-toggle {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    margin-bottom: 12px;
}
.detail-desc-toggle[hidden] { display: none; }
.detail-tags { margin-bottom: 12px; }
.detail-info { font-size: 13px; line-height: 1.8; }
.detail-info .label { color: var(--text-muted); }

.detail-inherited {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}
.detail-inherited > .label { color: var(--text-muted); display: block; margin-bottom: 4px; }
.inherited-item {
    display: flex;
    flex-direction: column;
    padding: 4px 8px;
    margin-bottom: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    border-left: 2px solid var(--accent);
}
.inherited-name { color: var(--text-primary); font-weight: 600; }
.inherited-detail { color: var(--text-secondary); font-size: 11px; margin-top: 2px; }

.detail-progress {
    margin: 12px 0;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}
.detail-progress .fill {
    height: 100%;
    background: var(--accent-green);
    border-radius: 4px;
    transition: width .3s;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
}

/* ── Calendar ─────────────────────────────────────────────────────────── */
.calendar-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow: hidden;
    min-height: 0;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.cal-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.cal-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.cal-title { font-size: 16px; font-weight: 600; white-space: nowrap; }
.cal-zoom-group { display: flex; align-items: center; gap: 2px; }
.cal-zoom-label { font-size: 12px; color: var(--text-muted); min-width: 26px; text-align: center; }
.gantt-zoom-group { display: flex; align-items: center; gap: 2px; }
.gantt-zoom-label { font-size: 12px; color: var(--text-muted); min-width: 30px; text-align: center; }

#calendar-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Month grid */
.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    flex: 1;
}
.month-header-cell {
    background: var(--bg-secondary);
    padding: 6px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}
.month-cell {
    background: var(--bg-primary);
    padding: 4px 6px;
    min-height: 70px;
    font-size: 12px;
    cursor: pointer;
    transition: background .1s;
}
.month-cell:hover { background: var(--bg-tertiary); }
.month-cell.today {
    border: 2px solid var(--accent);
    background: linear-gradient(180deg, rgba(88,166,255,0.12), rgba(88,166,255,0.04));
    box-shadow: inset 0 0 0 1px rgba(88,166,255,0.25);
}
.month-cell.other-month { opacity: 0.3; }
.month-day { font-weight: 600; margin-bottom: 2px; }
/* Subtle pill — tinted fill derived from the task color, with a thin
 * accent stripe on the left that carries full chroma. Much calmer than
 * a solid vivid fill while still conveying project identity. */
.month-event {
    position: relative;
    font-size: 10px;
    padding: 2px 7px 2px 8px;
    border-radius: 4px;
    margin-bottom: 2px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text-primary);
    cursor: pointer;
    background: color-mix(in srgb, var(--event-c, var(--accent)) 22%, var(--bg-secondary));
    border-left: 3px solid var(--event-c, var(--accent));
    transition: background .15s, transform .1s;
}
.month-event:hover {
    background: color-mix(in srgb, var(--event-c, var(--accent)) 35%, var(--bg-secondary));
    transform: translateX(1px);
}

/* Day/Week/3-day timeline */
.timeline {
    flex: 1;
    display: flex;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    scroll-behavior: smooth;
    min-height: 0;
}
.timeline-hours {
    width: 50px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    /* top padding must match .timeline-col-header height exactly */
    padding-top: 32px;
}
.timeline-hour-label {
    height: 60px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    font-size: 10px;
    color: var(--text-muted);
    /* Lift text up so its visual center sits on the hour line */
    line-height: 1;
    transform: translateY(-5px);
}
.timeline-columns {
    flex: 1;
    display: flex;
}
.timeline-col {
    flex: 1;
    border-right: 1px solid var(--border);
    position: relative;
    min-width: 120px;
}
.timeline-col:last-child { border-right: none; }
.timeline-col-today { background: rgba(88,166,255,0.07); }
.timeline-col-header {
    height: 32px;
    text-align: center;
    padding: 6px;
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 3;
}
.timeline-col-header.today-col {
    color: var(--accent);
    background: linear-gradient(180deg, rgba(88,166,255,0.28), rgba(88,166,255,0.12));
    font-weight: 700;
    box-shadow: inset 0 -2px 0 var(--accent), inset 0 1px 0 rgba(88,166,255,0.2);
    letter-spacing: 0.3px;
}
.timeline-col-body.today-col {
    background: linear-gradient(180deg, rgba(88,166,255,0.10) 0%, rgba(88,166,255,0.04) 40%, rgba(88,166,255,0.06) 100%);
}
.timeline-col-body {
    position: relative;
    height: calc(24 * 60px);
}
.timeline-hour-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border);
    opacity: 0.5;
}
/* Minimalist event card: muted tinted fill + accent stripe on the left.
 * `--event-c` is set inline to the task color; we derive the fill via
 * color-mix so one variable drives the whole look. */
.timeline-event {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: 6px;
    padding: 5px 8px 5px 10px;
    padding-right: 0;
    font-size: 11px;
    color: var(--text-primary);
    overflow: hidden;
    cursor: pointer;
    z-index: 2;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    background: color-mix(in srgb, var(--event-c, var(--accent)) 20%, var(--bg-secondary));
    border: 1px solid color-mix(in srgb, var(--event-c, var(--accent)) 40%, transparent);
    border-left: 3px solid var(--event-c, var(--accent));
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.timeline-event:hover {
    background: color-mix(in srgb, var(--event-c, var(--accent)) 32%, var(--bg-secondary));
    border-color: color-mix(in srgb, var(--event-c, var(--accent)) 60%, transparent);
    border-left-color: var(--event-c, var(--accent));
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    z-index: 5;
}
.event-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; align-self: center; }
.event-time { font-size: 9px; opacity: 0.7; }

/* Tag swatches on timeline events — small vertical pills, pastel */
.event-tags {
    display: flex;
    flex-direction: row;
    flex-shrink: 0;
    margin-left: auto;
    gap: 3px;
    padding: 4px 6px;
    align-items: center;
}
.event-tag-strip {
    display: block;
    width: 6px;
    min-height: 60%;
    flex-shrink: 0;
    border-radius: 3px;
    opacity: 0.9;
}

/* Tag dots for month view events — small rounded pills */
.month-event { display: flex; align-items: center; gap: 2px; }
.month-event-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-tags-inline {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    margin-left: auto;
}
.event-tag-dot {
    display: inline-block;
    width: 5px;
    height: 9px;
    flex-shrink: 0;
    border-radius: 2px;
    opacity: 0.9;
}

/* Now line — current time indicator. Kept present but subtle so it
 * marks the current time without slashing through events. */
.now-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 1.5px;
    background: var(--accent-red);
    z-index: 4;
    pointer-events: none;
    border-radius: 1px;
    opacity: 0.85;
}
.now-line::before {
    content: '';
    position: absolute;
    left: -5px;
    top: -4px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent-red);
    box-shadow: 0 0 0 2px var(--bg-primary);
}

/* ── Chat ─────────────────────────────────────────────────────────────── */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 16px;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.chat-header h2 { font-size: 16px; }
.chat-header-actions { margin-left: auto; display: flex; gap: 6px; }

.chat-messages {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    background: var(--bg-secondary);
    margin-bottom: 10px;
}

.chat-welcome {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}
.chat-welcome p { margin-top: 8px; }

.chat-bubble {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}
.bubble-user {
    background: var(--bubble-user-bg);
    margin-left: 60px;
}
.bubble-ai {
    background: var(--bg-tertiary);
    margin-right: 60px;
}
.bubble-error {
    background: var(--bubble-error-bg);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}
.bubble-role { font-weight: 700; font-size: 12px; margin-bottom: 4px; opacity: 0.7; }

/* AI markdown rendering */
.bubble-ai h1, .bubble-ai h2, .bubble-ai h3 { color: var(--accent); margin: 8px 0 4px; }
.bubble-ai h1 { font-size: 16px; }
.bubble-ai h2 { font-size: 15px; }
.bubble-ai h3 { font-size: 14px; }
.bubble-ai p { margin: 4px 0; }
.bubble-ai ul, .bubble-ai ol { padding-left: 20px; margin: 4px 0; }
.bubble-ai li { margin: 2px 0; }
.bubble-ai code {
    background: var(--code-bg);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: Consolas, monospace;
    font-size: 13px;
}
.bubble-ai pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    margin: 6px 0;
    overflow-x: auto;
    font-family: Consolas, monospace;
    font-size: 13px;
}
.bubble-ai pre code { background: none; padding: 0; }
.bubble-ai strong { color: var(--strong-color); }

/* Action blocks (AI task operations) */
.action-block {
    margin: 10px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary);
}
.action-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
}
.action-card {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}
.action-card:last-child { border-bottom: none; }
.action-card:hover { background: var(--bg-tertiary); }
.action-card.action-done {
    opacity: 0.6;
    background: rgba(6, 214, 160, 0.05);
}
.action-card.action-error {
    background: rgba(239, 71, 111, 0.08);
}
.action-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.action-type {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}
.action-type-create { background: rgba(6, 214, 160, 0.15); color: #06d6a0; }
.action-type-edit   { background: rgba(17, 138, 178, 0.15); color: #118ab2; }
.action-type-delete { background: rgba(239, 71, 111, 0.15); color: #ef476f; }
.action-field {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
    padding-left: 4px;
}
.action-field b { color: var(--text-primary); }
.action-exec-btn, .action-exec-all {
    min-width: 40px;
    font-size: 12px;
    padding: 2px 10px;
}

.streaming-indicator::after {
    content: ' ●';
    color: var(--accent);
    animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: 0.3; } }

.chat-quick-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.chat-input-area {
    display: flex;
    gap: 8px;
}
.chat-input-area textarea {
    flex: 1;
    resize: none;
}
.chat-input-area .btn { align-self: flex-end; height: 54px; }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow: auto;
    /* Provide a positioning context for the sticky actions footer */
    position: relative;
}
.modal-content h3 { color: var(--accent); margin-bottom: 10px; font-size: 17px; }
.modal-wide { max-width: 540px; }
/* Sticky actions footer: pins to the bottom of the scrollable modal, so
 * primary buttons stay reachable regardless of form length. Negative
 * horizontal/bottom margins push it flush to the modal edges to create a
 * visual toolbar, with a top border for separation from scrolling content. */
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    position: sticky;
    bottom: -20px;
    margin: 14px -24px -20px;
    padding: 12px 24px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 2;
}

/* ── Mobile calendar: compact month grid + week strip + detail pane ─────── */

/* Outer wrapper – flex column, fills #calendar-view */
.cal-mobile-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    gap: 0;
}

/* ── Compact month grid ─────────────────────────────── */
.cal-m-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    flex-shrink: 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.cal-m-hdr {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    padding: 6px 0 4px;
    letter-spacing: 0.3px;
}
.cal-m-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3px 1px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
}
.cal-m-cell:hover { background: var(--bg-tertiary); }
.cal-m-cell.cal-m-other { opacity: 0.3; }
.cal-m-num {
    font-size: 13px;
    font-weight: 500;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background .12s, color .12s;
}
.cal-m-cell.cal-m-today .cal-m-num {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}
.cal-m-cell.cal-m-sel:not(.cal-m-today) .cal-m-num {
    background: rgba(88,166,255,0.18);
    color: var(--accent);
    font-weight: 700;
}
.cal-m-cell.cal-m-sel.cal-m-today .cal-m-num {
    box-shadow: 0 0 0 3px var(--accent), 0 0 0 5px rgba(88,166,255,0.25);
}

/* ── Compact week-day strip ─────────────────────────── */
.cal-m-week-strip {
    display: flex;
    flex-shrink: 0;
    padding: 4px 0 8px;
    border-bottom: 1px solid var(--border);
}
.cal-m-wday {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 2px;
    border-radius: 10px;
    cursor: pointer;
    gap: 2px;
    transition: background .12s;
}
.cal-m-wday:hover { background: var(--bg-tertiary); }
.cal-m-wday-name {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.cal-m-wday .cal-m-num {
    font-size: 15px;
}
.cal-m-wday.cal-m-today .cal-m-num {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}
.cal-m-wday.cal-m-sel:not(.cal-m-today) .cal-m-num {
    background: rgba(88,166,255,0.18);
    color: var(--accent);
    font-weight: 700;
}

/* ── Shared: coloured dot row ───────────────────────── */
.cal-m-dots {
    display: flex;
    gap: 2px;
    justify-content: center;
    margin-top: 2px;
    flex-wrap: nowrap;
}
.cal-m-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Detail pane (scrollable lower half) ────────────── */
.cal-detail-pane {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 12px 2px 8px;
}
.cal-detail-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.cal-detail-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 28px 0;
}
.cal-detail-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cal-detail-ev {
    display: flex;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background .12s;
}
.cal-detail-ev:hover { background: var(--bg-tertiary); }
.cal-detail-bar {
    width: 4px;
    border-radius: 2px;
    flex-shrink: 0;
    align-self: stretch;
    min-height: 32px;
}
.cal-detail-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.cal-detail-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cal-detail-time {
    font-size: 12px;
    color: var(--text-muted);
}
.cal-detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.cal-detail-tag {
    font-size: 10px;
    padding: 1px 7px;
    border-radius: 8px;
    color: #1a1a1a;  /* dark text — tag swatches use pastel backgrounds */
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .task-panel { border-right: none; }
    /* Column header + column-settings button are desktop-only — the narrow
       layout wraps columns and ignores widths, so they'd do nothing here. */
    .tree-header,
    #col-settings-btn { display: none; }
    .bubble-user { margin-left: 20px; }
    .bubble-ai { margin-right: 20px; }
    .form-container { margin: 16px; padding: 20px; }

    /* Compact two-row tree layout on narrow screens */
    .tree-row {
        flex-wrap: wrap;
        row-gap: 2px;
        column-gap: 4px;
        padding: 5px 8px 5px 4px;
        margin-left: calc(var(--depth, 0) * 10px);
        font-size: 13px;
        align-items: center;
    }
    /* Line 1: toggle + dot + name fill full width */
    .tree-toggle { width: 14px; }
    .tree-dot { width: 7px; height: 7px; }
    .tree-name-wrap {
        flex: 1 1 calc(100% - 36px);
        min-width: 0;
    }
    .tree-name { font-size: 13px; }

    /* Line 2: tags + meta info, smaller text, indented under name */
    .tree-row > :not(.tree-toggle):not(.tree-dot):not(.tree-name-wrap) {
        font-size: 10px;
    }
    .tree-row .tag { font-size: 9px; padding: 1px 6px 1px 10px; }
    /* Narrow screens wrap columns, so let tags flow instead of a fixed width */
    .tree-tags { width: auto; max-height: none; flex-wrap: wrap; overflow: visible; }
    .tree-type {
        width: auto;
        flex: 0 0 auto;
        margin-left: 25px; /* align under name (approx toggle+dot width) */
    }
    .tree-progress { width: 40px; flex: 0 0 40px; }
    .tree-progress .progress-bar { height: 4px; }
    .tree-children { padding-left: 0; }
    .tree-time { width: auto; flex: 0 0 auto; }
    .tree-deadline { width: auto; flex: 1 1 auto; min-width: 0; }
    /* Hide quick-add and quick-done on narrow (use double-click or long-press instead) */
    .tree-quick-add { display: none; }
    .tree-quick-done { display: none; }

    /* Detail panel becomes a right-side slide-in drawer */
    .detail-wrapper {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 88%;
        max-width: 360px;
        z-index: 200;
        box-shadow: -6px 0 24px rgba(0, 0, 0, 0.5);
        transform: translateX(100%);
    }
    .detail-resize-handle {
        display: none;
    }
    .dashboard-layout:not(.detail-hidden) .detail-wrapper {
        display: flex;
        transform: translateX(0);
        pointer-events: auto;
        visibility: visible;
    }
    .dashboard-layout:not(.detail-hidden) .detail-backdrop {
        display: block;
    }
    .dashboard-layout.detail-hidden .detail-wrapper {
        /* On mobile, keep in DOM but slide off-screen (for transition) */
        display: flex;
        transform: translateX(100%);
        pointer-events: none;
        visibility: hidden;
    }
    /* Hide toggle button on narrow screens — use task-click to open, close button to close */
    #toggle-detail-btn { display: none; }

    /* Modal: limit width to viewport */
    .modal-content, .modal-wide {
        max-width: calc(100vw - 24px) !important;
        width: calc(100vw - 24px);
        padding: 14px 16px;
    }
    /* Keep sticky footer aligned with the smaller mobile padding */
    .modal-content .modal-actions {
        margin: 12px -16px -14px;
        padding: 10px 16px;
        bottom: -14px;
    }

    /* Calendar timeline: let columns shrink to fit the viewport */
    .timeline-col { min-width: 0; }
    .timeline { overflow-x: hidden; }
    #calendar-view { overflow-x: hidden; }
    .calendar-container {
        overflow-x: hidden;
        padding: 8px;
    }
    .calendar-header { flex-wrap: wrap; gap: 4px; justify-content: center; }
    .cal-nav { width: 100%; justify-content: center; }
    .cal-actions { flex-wrap: nowrap; }
    .cal-actions .select-sm { width: auto; }
    .cal-title { font-size: 14px; }
    .timeline-hours { width: 36px; }
    .timeline-hour-label { font-size: 9px; }
    .timeline-col-header { font-size: 11px; padding: 4px 2px; }
    .timeline-event { font-size: 10px; padding: 2px 0 2px 7px; border-left-width: 2px; }

    /* Nav: keep single row, smaller icons if needed */
    #nav { padding: 0 8px; gap: 4px; }
    .nav-tabs { gap: 0; }
    .tab-btn { padding: 10px 10px; font-size: 22px; }
    .nav-title { font-size: 14px; margin-right: 4px; }
    /* Drop the username pill on mobile — it eats horizontal space the
       nav tabs + ⭐ badge need. The user knows who they are; if they
       need to verify, the settings page has the same info. */
    .nav-user { display: none; }
    /* Tighten the coin badge slightly so it doesn't crowd the tabs */
    .coin-badge { margin-right: 4px; padding: 3px 8px; font-size: 12px; }

    /* Settings page padding */
    .settings-page { padding: 12px; }
    .settings-section { padding: 14px; }

    /* Current task bar smaller padding, hide quick-done button */
    .current-task-bar { padding: 6px 8px; gap: 6px; font-size: 12px; }
    #current-task-done { display: none !important; }

    /* Panel header buttons wrap */
    .panel-header { flex-wrap: wrap; gap: 6px; padding: 8px; }
    .panel-search { min-width: 60px; padding: 4px 8px; font-size: 12px; }
    .panel-actions { flex-wrap: wrap; gap: 4px; }
}

/* ── Settings page ───────────────────────────────────────────────────── */
#tab-settings.tab-content { overflow-y: auto; }
.settings-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px;
}
.settings-page > h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}
.settings-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    margin-bottom: 18px;
}
.settings-section > h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.settings-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.settings-row:last-child { margin-bottom: 0; }
.settings-row > label {
    font-size: 13px;
    color: var(--text-secondary);
}
.settings-row .settings-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}
.settings-row-buttons {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-wrap: wrap;
}
.settings-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
}
.settings-row select,
.settings-row input[type="password"] {
    width: 100%;
    max-width: 280px;
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
}

/* Nested sub-options under a parent toggle.
   The vertical bar on the left visually anchors them as "children
   of the row above". When the parent toggle is off, .is-disabled
   adds a wash-out + blocks pointer interaction. */
.settings-sub-group {
    margin: -4px 0 14px 24px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
}
.settings-sub-group .settings-sub-row {
    margin-bottom: 10px;
}
.settings-sub-group .settings-sub-row:last-child {
    margin-bottom: 0;
}
.settings-sub-group.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* Theme switcher */
.theme-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.theme-btn {
    padding: 6px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}
.theme-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}
.theme-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Change password form */
.pw-change-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.pw-change-msg {
    font-size: 12px;
    min-height: 16px;
}
.pw-change-msg.error { color: var(--accent-red); }
.pw-change-msg.success { color: var(--accent-green); }

/* ── Calendar nav icon with real date ───────────────────────────────────── */
.cal-icon-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    width: 1em;
    height: 1em;
    border: 1.5px solid currentColor;
    border-radius: 3px;
    overflow: hidden;
    vertical-align: middle;
    line-height: 1;
}
.cal-icon-badge::before {
    content: '';
    display: block;
    width: 100%;
    height: 35%;
    background: currentColor;
    opacity: 0.85;
    flex-shrink: 0;
}
.cal-icon-day {
    font-size: 0.45em;
    font-weight: 700;
    line-height: 1;
    margin-top: 1px;
}
}

/* ── Gantt Chart ─────────────────────────────────────────────────────── */
.gantt-page {
    padding: 16px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.gantt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.gantt-header h2 {
    margin: 0;
    font-size: 18px;
    color: var(--text-primary);
}

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

#gantt-hide-completed-btn.active {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

.gantt-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
    min-height: 300px;
}

.gantt-view {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    padding: 12px;
}

.gantt-container {
    display: flex;
    flex-direction: column;
    min-width: max-content;
}

.gantt-timeline-date-header {
    display: flex;
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    overflow: visible;
}

.gantt-labels-column {
    width: 250px;
    flex-shrink: 0;
    padding: 8px;
    border-right: 1px solid var(--border);
    font-weight: bold;
    color: var(--text-primary);
}

.gantt-timeline {
    display: flex;
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.gantt-date-col {
    flex: 1;
    min-width: 80px;
    padding: 8px;
    text-align: center;
    border-right: 1px solid var(--border);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
}

.gantt-date-col:last-child {
    border-right: none;
}

.gantt-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gantt-row {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.gantt-task-label {
    width: 250px;
    flex-shrink: 0;
    padding: 8px;
    border-right: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.gantt-task-name {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gantt-dependencies {
    display: flex;
    gap: 4px;
}

.dep-icon {
    font-size: 14px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.dep-icon:hover {
    opacity: 1;
}

.gantt-task-bar-container {
    flex: 1;
    position: relative;
    height: 32px;
    background: var(--bg-primary);
    border-radius: 4px;
    margin: 0 8px;
    overflow: hidden;
}

.gantt-task-bar {
    position: absolute;
    height: 28px;
    display: flex;
    align-items: center;
    padding: 0 6px;
    border-radius: 4px;
    cursor: grab;
    user-select: none;
    transition: opacity 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-task-bar:hover {
    opacity: 0.9;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.gantt-task-bar:active {
    cursor: grabbing;
}

.gantt-task-bar.overdue {
    opacity: 0.7;
}

.gantt-task-bar.today {
    box-shadow: 0 0 0 2px var(--accent);
}

/* Parent / summary task row */
.gantt-row-parent {
    background: var(--bg-tertiary, var(--bg-secondary));
}
.gantt-row-parent .gantt-task-name {
    font-weight: 600;
}

/* Collapse toggle button */
.gantt-collapse-btn {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    padding: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.15s, color 0.15s;
}
.gantt-collapse-btn:hover {
    background: var(--bg-hover, rgba(255,255,255,0.08));
    color: var(--text-primary);
}
.gantt-collapse-spacer {
    flex-shrink: 0;
    width: 20px;
    display: inline-block;
}

/* Summary bar — classic Gantt bracket style */
.gantt-summary-bar {
    position: absolute;
    height: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bar-color, var(--text-secondary));
    border-radius: 2px;
    pointer-events: auto;
    cursor: default;
    opacity: 0.85;
}
/* Left and right downward end-caps */
.gantt-summary-bar::before,
.gantt-summary-bar::after {
    content: '';
    position: absolute;
    top: 0;
    width: 8px;
    height: 16px;
    background: var(--bar-color, var(--text-secondary));
    border-radius: 0 0 3px 3px;
}
.gantt-summary-bar::before { left: 0; }
.gantt-summary-bar::after  { right: 0; }

.gantt-bar-label {
    font-size: 11px;
    color: white;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.gantt-legend {
    display: flex;
    gap: 24px;
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 2px;
}

/* ── Charts page: Gantt / Pie / Timeline sub-tabs ──────────────────────── */
.charts-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.charts-page-header h2 {
    margin: 0;
}
.charts-subtabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.chart-tab {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-weight: 500;
}
.chart-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}
.chart-tab.active {
    background: var(--accent);
    color: #fff;
}
.chart-panel { display: none; }
.chart-panel.active { display: block; }

/* Shared toolbar for pie / timeline panels */
.stats-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.stats-toolbar h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.stats-title-wrap {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.stats-scope-hint {
    font-size: 11px;
    color: var(--text-secondary, #8b949e);
    font-weight: 400;
    opacity: 0.75;
}
.stats-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.stats-range-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}
.stats-days-select {
    padding: 3px 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}
.stats-total {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    padding: 3px 10px;
    background: rgba(88, 166, 255, 0.08);
    border-radius: 10px;
}
.chart-content {
    transition: opacity 0.15s;
}
.chart-content.loading { opacity: 0.4; }

/* Larger sparkline when the Timeline sub-tab owns the whole panel */
.stats-spark-lg { height: 160px; }
.stats-timeline-legend {
    margin-top: 18px;
    max-height: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 6px 16px;
}

/* Per-day sparkline */
.stats-spark {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 80px;
    padding: 0 4px 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.stats-spark-day {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
}
.stats-spark-bar {
    width: 80%;
    max-width: 24px;
    min-height: 1px;
    display: flex;
    flex-direction: column-reverse; /* stack largest at bottom */
    border-radius: 3px 3px 0 0;
    overflow: hidden;
    background: transparent;
    transition: opacity 0.15s;
}
.stats-spark-bar:hover { opacity: 0.85; }
.stats-spark-seg {
    display: block;
    width: 100%;
}
.stats-spark-label {
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1;
}

/* Top-projects horizontal bar list */
.stats-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stats-row {
    display: grid;
    grid-template-columns: minmax(80px, 180px) 1fr;
    gap: 12px;
    align-items: center;
    font-size: 13px;
}
.stats-label {
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stats-bar-wrap {
    position: relative;
    height: 22px;
    background: var(--bg-tertiary);
    border-radius: 11px;
    overflow: hidden;
}
.stats-bar {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    border-radius: 11px 0 0 11px;
    min-width: 2px;
    transition: width 0.25s;
}
.stats-value {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    text-shadow: 0 0 3px var(--bg-secondary);
    white-space: nowrap;
}
.stats-empty {
    text-align: center;
    padding: 24px 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ── 项目预算 ─────────────────────────────────────────────── */
.budget-table {
    display: grid;
    gap: 6px;
    overflow-x: auto;
}
.budget-row {
    display: grid;
    grid-template-columns: minmax(160px, 1.4fr) repeat(2, minmax(86px, 0.65fr)) repeat(4, minmax(118px, 0.9fr));
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 900px;
}
.budget-head {
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0;
    border-color: transparent;
    padding-top: 0;
    padding-bottom: 2px;
}
.budget-project {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
}
.budget-project span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.budget-input {
    width: 100%;
    min-width: 0;
    padding: 5px 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}
.budget-meter {
    min-width: 0;
}
.budget-meter-label {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.budget-meter.over .budget-meter-label {
    color: #f87171;
}
.budget-meter-track {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--bg-tertiary);
}
.budget-meter-track span {
    display: block;
    height: 100%;
    min-width: 2px;
    border-radius: inherit;
    background: var(--accent);
}
.budget-meter.over .budget-meter-track span {
    background: #f87171;
}

/* ── 今日时间线视图 ─────────────────────────────────────────────── */
.today-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}
.today-summary strong {
    color: var(--text-primary);
    font-weight: 600;
}
.today-summary-sep {
    color: var(--text-muted);
    opacity: 0.5;
}
.today-summary .today-coin.pos strong { color: #b45309; }
.today-summary .today-coin.neg strong { color: #b91c1c; }

.today-timeline {
    position: relative;
}
.today-row {
    display: grid;
    grid-template-columns: 56px 24px 1fr;
    align-items: stretch;
    gap: 8px;
    padding: 6px 0;
    position: relative;
}
/* Connecting vertical line through the dot column */
.today-row + .today-row::before {
    content: '';
    position: absolute;
    left: 67px;  /* 56 + half of 24 - half line width */
    top: -8px;
    bottom: calc(100% - 8px);
    width: 1px;
    background: var(--border);
}
.today-time {
    color: var(--text-secondary);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    padding-top: 4px;
    text-align: right;
}
.today-line {
    position: relative;
    display: flex;
    justify-content: center;
}
.today-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    box-shadow: 0 0 0 2px var(--bg-primary);
}
.today-body {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
    min-width: 0;
}
.today-row:hover .today-body {
    border-color: var(--accent);
}
.today-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
    word-break: break-word;
}
.today-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 11px;
}
.today-kind {
    color: var(--text-muted);
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
}
.today-dur {
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.today-tag {
    color: #1a1a1a;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 10px;
}
.today-coin {
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
}
.today-coin.pos {
    color: #b45309;
    background: color-mix(in srgb, #facc15 25%, var(--bg-primary));
    border: 1px solid color-mix(in srgb, #facc15 50%, transparent);
}
.today-coin.neg {
    color: #991b1b;
    background: color-mix(in srgb, #f87171 22%, var(--bg-primary));
    border: 1px solid color-mix(in srgb, #f87171 50%, transparent);
}
.stats-undated-note {
    font-size: 11px;
    color: var(--text-secondary, #8b949e);
    padding: 4px 0 10px 2px;
    opacity: 0.8;
    font-style: italic;
}

/* Pie chart */
.stats-pie-wrap {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 8px 0 4px;
}
.stats-pie {
    flex: 0 0 auto;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}
.stats-pie-slice {
    transition: opacity 0.15s, transform 0.15s;
    transform-origin: 50% 50%;
    cursor: default;
}
.stats-pie-slice:hover {
    opacity: 0.85;
}
.stats-pie-center-num {
    fill: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
    font-family: inherit;
}
.stats-pie-center-lbl {
    fill: var(--text-secondary, #8b949e);
    font-size: 11px;
    font-family: inherit;
}
.stats-pie-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1 1 220px;
    min-width: 0;
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stats-pie-legend-row {
    display: grid;
    grid-template-columns: 14px 1fr auto;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
}
.stats-pie-legend-row:hover {
    background: rgba(255, 255, 255, 0.04);
}
.stats-pie-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}
.stats-pie-legend-name {
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stats-pie-legend-val {
    color: var(--text-secondary, #8b949e);
    font-size: 11px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
    .charts-page-header { gap: 8px; }
    .chart-tab { padding: 5px 10px; font-size: 12px; }
    .stats-toolbar { padding: 10px; }
    .stats-toolbar h3 { font-size: 14px; }
    .stats-row { grid-template-columns: minmax(60px, 120px) 1fr; font-size: 12px; }
    .stats-spark { height: 60px; }
    .stats-spark-lg { height: 110px; }
    .stats-spark-label { font-size: 9px; }
    .stats-pie-wrap { gap: 12px; }
    .stats-pie { width: 180px; height: 180px; }
}

.gantt-filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0;
    max-height: 60vh;
    overflow-y: auto;
}

.filter-btn {
    padding: 8px 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-btn:hover {
    background: var(--btn-hover);
    border-color: var(--accent);
}

.filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Modal responsive */
.modal-content {
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}

/* Responsive - Tablets */
@media (max-width: 1024px) {
    .gantt-labels-column,
    .gantt-task-label {
        width: 180px;
    }

    .gantt-task-name {
        font-size: 13px;
    }

    .gantt-header h2 {
        font-size: 16px;
    }

    .gantt-actions {
        gap: 6px;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Responsive - Mobile (768px and below) */
@media (max-width: 768px) {
    .gantt-page {
        padding: 8px;
    }

    .gantt-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--border);
    }

    .gantt-header h2 {
        margin: 0;
        font-size: 14px;
        width: 100%;
    }

    .gantt-actions {
        width: 100%;
        gap: 4px;
        flex-wrap: wrap;
    }

    .gantt-actions .btn-sm {
        flex: 1;
        min-width: 70px;
        padding: 6px 8px;
        font-size: 11px;
    }

    .gantt-view {
        padding: 8px;
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch;
    }

    .gantt-labels-column,
    .gantt-task-label {
        width: 110px;
        padding: 6px;
        font-size: 11px;
    }

    .gantt-task-name {
        font-size: 11px;
        white-space: normal;
        word-break: break-word;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .gantt-task-bar-container {
        height: 28px;
        margin: 0 4px;
    }

    .gantt-task-bar {
        height: 24px;
    }

    .gantt-bar-label {
        font-size: 9px;
        padding: 0 2px;
    }

    .gantt-date-col {
        min-width: 55px;
        padding: 6px 2px;
        font-size: 9px;
        border-right: 1px solid var(--border);
    }

    .gantt-row {
        min-height: 34px;
        padding: 2px 0;
    }

    .gantt-legend {
        gap: 12px;
        font-size: 11px;
        margin-top: 12px;
        padding: 8px;
    }

    .legend-item {
        gap: 6px;
    }

    .legend-color {
        width: 12px;
        height: 12px;
    }

    .gantt-dependencies {
        display: flex;
        gap: 2px;
    }

    .dep-icon {
        font-size: 12px;
    }
}

/* Responsive - Small Mobile (480px and below) */
@media (max-width: 480px) {
    .gantt-page {
        padding: 4px;
    }

    .gantt-header {
        margin-bottom: 8px;
        gap: 6px;
    }

    .gantt-header h2 {
        font-size: 13px;
    }

    .gantt-actions .btn-sm {
        font-size: 10px;
        padding: 4px 6px;
        min-width: 55px;
    }

    .gantt-view {
        padding: 6px;
    }

    .gantt-labels-column,
    .gantt-task-label {
        width: 90px;
        padding: 4px;
        font-size: 10px;
    }

    .gantt-task-name {
        font-size: 10px;
        white-space: normal;
        word-break: break-word;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .gantt-date-col {
        min-width: 45px;
        padding: 4px 1px;
        font-size: 8px;
    }

    .gantt-row {
        min-height: 30px;
        padding: 1px 0;
    }

    .gantt-task-bar-container {
        height: 24px;
        margin: 0 2px;
    }

    .gantt-task-bar {
        height: 20px;
    }

    .gantt-bar-label {
        font-size: 7px;
    }

    .gantt-legend {
        gap: 8px;
        font-size: 10px;
        padding: 6px;
    }

    .legend-color {
        width: 10px;
        height: 10px;
    }

    .filter-btn {
        padding: 6px 10px;
        font-size: 10px;
    }

    .gantt-filter-options {
        gap: 6px;
    }
}

/* ── Notification diagnostic modal ─────────────────────────────────── */
.notif-guide-status { margin-bottom: 14px; }
.notif-guide-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
}
.notif-guide-card.ok { border-left-color: #2ea043; }
.notif-guide-card.warn { border-left-color: #f59e0b; }
.notif-guide-card strong { color: var(--text-primary); }
.notif-guide-card p { margin: 4px 0 0 0; font-size: 12px; }
.notif-guide-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
}
.notif-guide-step {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
}
.notif-guide-step.done { opacity: 0.65; }
.notif-guide-step-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.notif-guide-step-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 8px 0;
    line-height: 1.5;
}

/* ── Star coin (奖励) UI ─────────────────────────────────────────── */

/* Top nav badge — sits between tabs and user. Click to open ledger modal. */
.coin-badge {
    margin-left: auto;
    margin-right: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
}
.coin-badge:hover {
    background: color-mix(in srgb, var(--bg-secondary) 70%, var(--accent) 30%);
    border-color: var(--accent);
}
.coin-badge.coin-badge-positive {
    color: #b45309;
    background: color-mix(in srgb, #facc15 18%, var(--bg-secondary));
    border-color: color-mix(in srgb, #facc15 50%, transparent);
}
.coin-badge.coin-badge-negative {
    color: #b91c1c;
    background: color-mix(in srgb, #f87171 22%, var(--bg-secondary));
    border-color: color-mix(in srgb, #f87171 60%, transparent);
}

/* Per-row badge in the task tree */
.tree-coin-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.5;
    flex-shrink: 0;
}
.tree-coin-pos {
    background: color-mix(in srgb, #facc15 25%, var(--bg-primary));
    color: #b45309;
    border: 1px solid color-mix(in srgb, #facc15 50%, transparent);
}
.tree-coin-neg {
    background: color-mix(in srgb, #f87171 22%, var(--bg-primary));
    color: #991b1b;
    border: 1px solid color-mix(in srgb, #f87171 50%, transparent);
}
/* Tag-inherited (rather than task-specific) badges get a dashed border
   so users can distinguish "I set this on the task" from "this came in
   via a tag rule". Hover tooltip explains the source. */
.tree-coin-badge.tree-coin-inherited {
    border-style: dashed;
    opacity: 0.85;
}

/* Coins modal — balance display + ledger */
#coins-balance-section {
    text-align: center;
    margin: 8px 0 16px;
    padding: 16px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.coin-balance-display {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.2;
}
.coin-balance-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.coin-ledger {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 40vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    background: var(--bg-primary);
}
.coin-ledger-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}
.coin-ledger-row {
    display: grid;
    grid-template-columns: 70px 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 4px 6px;
    font-size: 12px;
    border-radius: 4px;
}
.coin-ledger-row:hover { background: var(--bg-secondary); }
.coin-le-time { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.coin-le-task { color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coin-le-delta { font-weight: 600; min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.coin-le-pos { color: #b45309; }
.coin-le-neg { color: #b91c1c; }
.coin-le-bal { color: var(--text-secondary); min-width: 32px; text-align: right; font-variant-numeric: tabular-nums; }
