/* ─── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea { font: inherit; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ─── Tokens ─────────────────────────────────────────────────────────── */
:root {
    --sidebar-bg: rgb(252, 250, 248);
    --sidebar-text: #6b6b6b;
    --sidebar-hover: #efebe7;
    --sidebar-active: #e6e0da;
    --sidebar-active-text: #202020;
    --sidebar-width: 240px;

    --content-bg: #ffffff;
    --text-primary: #202020;
    --text-secondary: #777;
    --text-muted: #aaa;

    --accent: #db4035;
    --accent-hover: #c03329;
    --accent-light: #fef2f1;

    --goal: #7c3aed;
    --goal-light: #f3effe;

    --border: #f0f0f0;
    --border-input: #e0e0e0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,.12);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.18);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;
}

body {
    font-family: var(--font);
    background: var(--content-bg);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* ─── Layout ─────────────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-right: 1px solid #e5e0da;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    padding-bottom: 24px;
}

.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid #e5e0da;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Inter', var(--font);
    font-size: 16px;
    font-weight: 600;
    color: #202020;
    letter-spacing: -.2px;
}

.sidebar-logo-mark {
    flex-shrink: 0;
}

.streak-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
    flex-shrink: 0;
}

.streak-badge--empty {
    background: transparent;
    color: var(--text-muted);
}

.streak-badge--empty .streak-flame {
    filter: grayscale(1);
    opacity: .6;
}

.streak-badge--at-risk {
    background: #fff7ed;
    color: #d97706;
}

.streak-flame {
    font-size: 14px;
    line-height: 1;
}

.streak-badge--pop {
    animation: streak-pop .4s ease;
}

@keyframes streak-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 4px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--sidebar-text);
    transition: background .12s, color .12s;
    position: relative;
}

.nav-item:hover { background: var(--sidebar-hover); color: #333; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-active-text); }

.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: .7;
}

.nav-count {
    margin-left: auto;
    font-size: 12px;
    opacity: .6;
}

.project-dot, .tag-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

#project-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 4px 8px;
}

/* ─── Hierarchical project tree ──────────────────────────────────────── */
.project-node { position: relative; }

.project-row {
    display: flex;
    align-items: center;
    gap: 2px;
    -webkit-touch-callout: none;
}

.project-row .nav-item { flex: 1; min-width: 0; }

.drag-handle {
    cursor: grab;
    font-size: 13px;
    padding: 4px 2px;
    color: #555;
    opacity: 0;
    transition: opacity .12s;
    flex-shrink: 0;
    user-select: none;
    touch-action: none;
}

.project-row:hover .drag-handle { opacity: 1; }
.drag-handle:active { cursor: grabbing; }

.project-archive-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity .12s, background .12s, color .12s;
    flex-shrink: 0;
}

.project-row:hover .project-archive-btn { opacity: 1; }
.project-archive-btn:hover { background: var(--accent-light); color: var(--accent); }

.nav-item--child {
    padding-left: 22px;
    font-size: 13px;
}

.project-children {
    margin-left: 8px;
}

/* Dragging state */
.project-node--dragging { opacity: 0.35; }

/* Drop indicators */
.project-node--drop-before::before,
.project-node--drop-after::after {
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
    z-index: 10;
}

.project-node--drop-before::before { top: -1px; }
.project-node--drop-after::after  { bottom: -1px; }

.project-node--drop-into > .project-row > .nav-item {
    background: rgba(219, 64, 53, .12);
    outline: 1px dashed var(--accent);
    border-radius: var(--radius-sm);
}

.sidebar-section {
    margin-top: 16px;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #555;
}

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.sidebar-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    font-size: 16px;
    line-height: 1;
    color: #555;
    transition: background .12s, color .12s;
}
.sidebar-add-btn:hover { background: #e6e0da; color: #333; }

/* ─── Main content ───────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px 48px;
}

.main-content > * {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.main-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.main-title {
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tag-title-name {
    cursor: text;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: -4px;
    outline: none;
    transition: background .12s;
}

.tag-title-name:hover {
    background: rgba(0,0,0,.05);
}

.tag-title-name--editing {
    background: rgba(0,0,0,.06);
    box-shadow: 0 0 0 2px var(--border-input);
}

.project-dot-lg {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
}

/* ─── Quick Add ──────────────────────────────────────────────────────── */
.todo-section {}

.quick-add-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    transition: color .12s;
    width: 100%;
}
.quick-add-trigger:hover { color: var(--accent); }
.quick-add-trigger:hover .quick-add-plus { border-color: var(--accent); color: var(--accent); }

.quick-add-plus {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    transition: border-color .12s, color .12s;
    color: var(--text-muted);
}

.quick-add-form {
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    box-shadow: 0 0 0 2px #db403520;
    margin-bottom: 16px;
}

.quick-add-input {
    width: 100%;
    font-size: 15px;
    color: var(--text-primary);
    background: transparent;
    border: none;
    outline: none;
    padding: 4px 0;
}
.quick-add-input::placeholder { color: var(--text-muted); }

.quick-add-description {
    width: 100%;
    font-size: 13px;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-top: 1px solid var(--border);
    outline: none;
    resize: vertical;
    padding: 8px 0 0;
    margin-top: 4px;
    font-family: var(--font);
    line-height: 1.5;
}
.quick-add-description::placeholder { color: var(--text-muted); }

.quick-add-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.quick-add-picker-bar { display: flex; flex-wrap: wrap; gap: 4px; }

.picker-slot {
    display: inline-flex;
    align-items: center;
    border-radius: 99px;
    border: 1px solid var(--border-input);
    overflow: hidden;
}
.picker-slot.is-set { border-color: var(--accent-light); background: var(--accent-light); }

.picker-remove {
    font-size: 10px;
    color: var(--text-muted);
    opacity: .7;
    padding: 5px 8px 5px 2px;
    line-height: 1;
    transition: opacity .1s, color .1s;
}
.picker-remove:hover { opacity: 1; color: var(--text-primary); }
.picker-remove:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.picker-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-input);
    transition: background .12s, color .12s, border-color .12s;
}
.picker-btn:hover { background: var(--border); color: var(--text-primary); }
.picker-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.picker-btn.is-set { color: var(--accent); }

/* Inside a slot, the value button and remove ✕ blend into one pill
   (the slot itself carries the border/background) instead of looking
   like two separate controls next to each other. */
.picker-slot .picker-btn {
    border: none;
    background: transparent;
    border-radius: 0;
    padding: 5px 4px 5px 10px;
}
/* No remove ✕ follows (e.g. a fixed default project/date) — give the button its full padding back */
.picker-slot .picker-btn:last-child { padding-right: 10px; }
.picker-slot .picker-btn:hover { background: rgba(0, 0, 0, .06); }
.picker-slot .picker-remove { padding: 5px 10px 5px 2px; }

.picker-icon { width: 13px; height: 13px; flex-shrink: 0; }
.picker-icon--text {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1;
    width: auto;
    height: auto;
}

.quick-add-buttons { display: flex; gap: 8px; }

/* ─── Dropdown ───────────────────────────────────────────────────────── */
.quick-add-wrapper { position: relative; }

.quick-add-dropdown, .detail-dropdown {
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 2px;
    background: #fff;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 100;
    min-width: 200px;
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
}

/* The calendar is fixed-size and needs to show in full, not scroll */
.quick-add-dropdown.dropdown--calendar,
.detail-dropdown.dropdown--calendar {
    max-height: none;
    overflow: visible;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background .1s;
}
.dropdown-item:hover, .dropdown-item--active { background: var(--border); }
.dropdown-item--child { padding-left: 26px; }
.dropdown-item:focus-visible, .calendar-day:focus-visible, .calendar-nav-btn:focus-visible, .calendar-clear:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.dropdown-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dropdown-new { color: var(--accent); font-style: italic; }

.dropdown-search-row { padding: 4px 4px 6px; }

.dropdown-search {
    width: 100%;
    font-size: 13px;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 1.5px solid var(--border-input);
    outline: none;
    padding: 4px 2px;
}
.dropdown-search:focus { border-bottom-color: var(--accent); }
.dropdown-search::placeholder { color: var(--text-muted); }

/* ─── Duration hint panel ────────────────────────────────────────────── */
.duration-hint {
    padding: 10px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.duration-hint-header {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
}

.duration-hint-icon { font-size: 15px; line-height: 1; }

.duration-hint-label {
    font-weight: 600;
    color: var(--text-primary);
}

.duration-hint-valid {
    color: #299438;
    font-weight: 500;
}

.duration-hint-typing {
    color: var(--text-secondary);
    font-style: italic;
}

.duration-hint-empty {
    color: var(--text-muted);
}

.duration-custom-input {
    width: 100%;
    font-size: 13px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 1.5px solid var(--border-input);
    outline: none;
    padding: 4px 2px;
}
.duration-custom-input:focus { border-bottom-color: var(--accent); }
.duration-custom-input::placeholder { color: var(--text-muted); font-family: var(--font); }

.duration-hint-examples {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.duration-example {
    font-size: 12px;
    font-family: var(--font-mono);
    padding: 3px 9px;
    border-radius: 99px;
    background: var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background .1s, color .1s;
    border: 1.5px solid transparent;
}
.duration-example:hover { background: #e8e8e8; color: var(--text-primary); }
.duration-example--active {
    background: #eef5ff;
    border-color: #4073ff;
    color: #4073ff;
}

.duration-hint-confirm {
    font-size: 11px;
    color: var(--text-muted);
    padding-top: 2px;
    border-top: 1px solid var(--border);
}

/* ─── Due date calendar picker ───────────────────────────────────────── */
.due-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: #d97706;
}

.due-label {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
}

.calendar-picker { padding: 4px; }

.calendar-date-input {
    width: 100%;
    font-size: 13px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 1.5px solid var(--border-input);
    outline: none;
    padding: 6px 6px 8px;
}
.calendar-date-input:focus { border-bottom-color: var(--accent); }
.calendar-date-input::placeholder { color: var(--text-muted); font-family: var(--font); }

.calendar-quick-options {
    padding-bottom: 4px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 4px 8px;
}
.calendar-nav-label { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.calendar-nav-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 16px;
    color: var(--text-secondary);
}
.calendar-nav-btn:hover { background: var(--border); color: var(--text-primary); }

.calendar-weekdays, .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-weekday {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    padding: 2px 0 4px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}
.calendar-day:hover { background: var(--border); }
.calendar-day--muted { color: var(--text-muted); }
.calendar-day--today { font-weight: 700; color: var(--accent); }
.calendar-day--selected { background: var(--accent); color: #fff; }
.calendar-day--selected:hover { background: var(--accent-hover); }

.calendar-clear {
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 6px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
}
.calendar-clear:hover { color: var(--accent); }

/* ─── Chips ──────────────────────────────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 99px;
    font-weight: 500;
    line-height: 1;
}

.chip--tag { border-radius: 99px; }

.chip-remove {
    font-size: 10px;
    opacity: .6;
    line-height: 1;
    padding: 0;
    transition: opacity .1s;
}
.chip-remove:hover { opacity: 1; }

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: background .12s, color .12s;
    line-height: 1;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; cursor: default; }

.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { background: var(--border); color: var(--text-primary); }

/* ─── Todo List ──────────────────────────────────────────────────────── */
.todo-list {
    border-top: 1px solid var(--border);
}

.todo-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border);
    transition: background .1s, opacity .2s;
    position: relative;
    -webkit-touch-callout: none;
}

.todo-item:hover { background: #fafafa; }
.todo-item:hover .todo-delete { opacity: 1; }
.todo-item:hover .todo-drag-handle { opacity: 1; }
.todo-item:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
    background: #fafafa;
}

.todo-drag-handle {
    cursor: grab;
    opacity: 0;
    font-size: 13px;
    padding: 2px 0;
    color: var(--text-muted);
    transition: opacity .12s;
    flex-shrink: 0;
    align-self: center;
    user-select: none;
    line-height: 1;
    touch-action: none;
}
.todo-drag-handle:active { cursor: grabbing; }

.todo-item--dragging { opacity: 0.35; }

.todo-item--drop-before::before,
.todo-item--drop-after::after {
    content: '';
    position: absolute;
    left: 0; right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
    z-index: 5;
}
.todo-item--drop-before::before { top: -1px; }
.todo-item--drop-after::after   { bottom: -1px; }

.todo-item--completed .todo-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.todo-item--removing {
    opacity: 0;
    transform: translateX(8px);
    transition: opacity .2s, transform .2s;
}

/* Checkbox */
.todo-check {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--check-color, var(--border-input));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    transition: background .15s, border-color .15s;
    color: transparent;
}

.todo-check:hover {
    border-color: var(--check-color, var(--accent));
    background: color-mix(in srgb, var(--check-color, var(--accent)) 20%, transparent);
}

.todo-check--done {
    background: var(--check-color, var(--accent));
    border-color: var(--check-color, var(--accent));
    color: #fff;
}

.todo-check--done svg {
    width: 10px;
    height: 10px;
}

@keyframes checkPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
.todo-check--animating { animation: checkPop .2s ease; }

/* Todo body */
.todo-body {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.todo-title {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    display: block;
}

.todo-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.todo-project {
    font-size: 12px;
    font-weight: 500;
}

.todo-tag {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 99px;
    font-weight: 500;
}

.todo-due {
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: 500;
}
.todo-due--overdue { color: var(--accent); }
.todo-due--today   { color: #d97706; }
.todo-due--soon    { color: #6b7280; }
.todo-due--upcoming { color: var(--text-muted); }

.todo-duration {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
}

.todo-subtasks {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
}
.todo-subtasks--done { color: #16a34a; }

.todo-has-desc {
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

/* Delete button */
.todo-delete {
    opacity: 0;
    color: var(--text-muted);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: opacity .1s, color .1s, background .1s;
    flex-shrink: 0;
}

.todo-delete:hover { color: var(--accent); background: var(--accent-light); }
.todo-delete svg { width: 14px; height: 14px; }

/* Empty state */
.todo-empty {
    padding: 40px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* ─── Completed section ──────────────────────────────────────────────── */
.completed-section { margin-top: 24px; }

.completed-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 0;
    border-radius: var(--radius-sm);
    transition: color .1s;
}
.completed-toggle:hover { color: var(--text-primary); }

.chevron {
    width: 16px;
    height: 16px;
    transition: transform .2s;
}

.todo-list--completed .todo-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* ─── Modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn .15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp .15s ease;
}

/* Lets the detail-form's height:100% chain resolve against a definite height
   instead of collapsing to auto (needed for the independently-scrolling panes). */
.modal-content {
    height: 100%;
    opacity: 1;
    transition: opacity .1s ease;
}
.modal-content--switching { opacity: .35; }

@keyframes slideUp {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ─── Entity create modal (project / tag) ───────────────────────────── */
.entity-modal {
    padding: 28px 32px 24px;
    max-width: 400px;
}

.entity-modal-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.entity-modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.entity-modal-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
}

.entity-modal-input {
    width: 100%;
    font-size: 15px;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-bottom: 1.5px solid var(--border-input);
    outline: none;
    padding: 6px 0;
    transition: border-color .15s;
}
.entity-modal-input:focus { border-bottom-color: var(--accent); }
.entity-modal-input::placeholder { color: var(--text-muted); }

.entity-color-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
}

.color-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    outline: 2px solid transparent;
    transition: transform .1s, outline-color .1s;
    cursor: pointer;
    flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch--active {
    outline-color: var(--text-primary);
    outline-offset: 2px;
    transform: scale(1.1);
}

.entity-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* ─── Confirm modal ──────────────────────────────────────────────────── */
.confirm-modal {
    padding: 28px 28px 24px;
    max-width: 340px;
}

.confirm-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.confirm-modal-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

/* ─── Shortcuts modal ────────────────────────────────────────────────── */
.shortcuts-modal {
    padding: 24px 28px 28px;
    max-width: 480px;
}

.shortcuts-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.shortcuts-modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.shortcuts-modal-close {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.shortcuts-modal-close:hover { color: var(--text-primary); }

.shortcuts-group + .shortcuts-group { margin-top: 16px; }

.shortcuts-group-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.shortcuts-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    font-size: 14px;
}

.shortcuts-label { color: var(--text-secondary); }

.shortcuts-key {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-primary);
    background: var(--border);
    border: 1px solid var(--border-input);
    border-radius: 4px;
    padding: 2px 6px;
    white-space: nowrap;
}

/* ─── ────────────────────────────────────────────────────────────────── */

.modal-loading {
    padding: 48px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* ─── Detail form ────────────────────────────────────────────────────── */
.modal:has(.detail-form) {
    max-width: 760px;
    height: 80vh;
    overflow: hidden;
}

.detail-form {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Header bar */
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.detail-crumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-crumb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.detail-crumb-icon { color: var(--text-muted); }

.detail-crumb-parent {
    color: var(--text-secondary);
    font-weight: 600;
    padding: 2px 6px;
    margin-left: -6px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background .1s;
}
.detail-crumb-parent:hover { background: var(--accent-light); color: var(--accent); }

.detail-crumb-source {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 12px;
}

.detail-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.detail-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: background .1s, color .1s;
}
.detail-icon-btn:hover { background: var(--border); color: var(--text-primary); }

.detail-more-wrap { position: relative; }

.detail-more-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: #fff;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 100;
    min-width: 160px;
    padding: 4px;
}

.detail-more-item {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-align: left;
    transition: background .1s;
}
.detail-more-item:hover { background: var(--border); }
.detail-more-item--danger { color: var(--accent); }

/* Body: main column + sidebar, each pane scrolls independently */
.detail-body {
    display: flex;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

.detail-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.detail-sidebar {
    width: 220px;
    flex-shrink: 0;
    min-height: 0;
    background: #fcfaf8;
    border-left: 1px solid var(--border);
    padding: 4px 16px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 0;
}
.sidebar-row:not(:first-child) { border-top: 1px solid var(--border); }

.sidebar-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.sidebar-row-header[data-add-field] {
    cursor: pointer;
    padding: 4px 6px;
    margin: -4px -6px;
    border-radius: var(--radius-sm);
    transition: background .1s;
}
.sidebar-row-header[data-add-field]:hover { background: var(--border); }

.sidebar-row-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-row-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: background .1s, color .1s;
}
.sidebar-row-add:hover { background: var(--border); color: var(--text-primary); }

.sidebar-row-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}
.sidebar-row-body:empty { display: none; }

.sidebar-value {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    margin: -4px -6px;
    transition: background .1s;
}
.sidebar-value:hover { background: var(--border); }
.sidebar-value-icon { flex-shrink: 0; color: var(--text-muted); }
.sidebar-value-icon--accent { color: var(--accent); }
.sidebar-value-icon--text {
    width: 15px;
    flex-shrink: 0;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}
.sidebar-value-text { flex: 1; min-width: 0; }
.sidebar-value-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 50%;
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity .1s, background .1s, color .1s;
}
.sidebar-value:hover .sidebar-value-clear { opacity: 1; }
.sidebar-value-clear:hover { background: var(--accent-light); color: var(--accent); }

.detail-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.detail-title-input {
    width: 100%;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    border: none;
    outline: none;
    padding: 0;
    background: transparent;
}
.detail-title-input::placeholder { color: var(--text-muted); font-weight: 400; }
.detail-title-input--done { text-decoration: line-through; color: var(--text-muted); }

.todo-check--lg {
    width: 22px;
    height: 22px;
    margin-top: 0;
}
.todo-check--lg svg { width: 12px; height: 12px; }

.detail-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 4px;
}

.detail-duration-input,
.detail-project-input,
.detail-tag-input,
.detail-date-input {
    width: 100%;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--border);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    outline: none;
    transition: border-color .15s, background .15s;
}
.detail-duration-input:focus,
.detail-project-input:focus,
.detail-tag-input:focus,
.detail-date-input:focus {
    background: #fff;
    border-color: var(--border-input);
}
.detail-duration-input::placeholder,
.detail-project-input::placeholder,
.detail-tag-input::placeholder { color: var(--text-muted); }

/* These pickers live in a narrow, independently-scrolling column — render them
   inline (expanding the row) instead of floating, so they can't get clipped
   or need horizontal overflow the way the quick-add popover can afford to. */
.sidebar-row-body .detail-dropdown {
    position: static;
    width: 100%;
    min-width: 0;
    max-height: none;
    margin-top: 4px;
}

/* Description */
.detail-description {
    display: flex;
    flex-direction: column;
}

.detail-desc-toolbar {
    position: relative;
    display: flex;
    justify-content: flex-end;
}

.detail-desc-help-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border: 1px solid var(--border-input);
    transition: background .1s, color .1s, border-color .1s;
}
.detail-desc-help-btn:hover {
    background: var(--border);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.detail-md-cheatsheet {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: #fff;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 100;
    min-width: 200px;
    padding: 10px 12px;
}

.detail-md-cheatsheet-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.detail-md-cheatsheet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    font-size: 12.5px;
}

.detail-md-cheatsheet-row code {
    font-family: var(--font-mono);
    color: var(--accent);
    background: var(--accent-light);
    padding: 1px 5px;
    border-radius: 3px;
}

.detail-md-cheatsheet-row span {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.detail-desc-view {
    min-height: 80px;
    padding: 10px 12px;
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    cursor: text;
    transition: border-color .15s, background .15s;
}
.detail-desc-view:hover {
    border-color: var(--border-input);
    background: #fafafa;
}

.detail-desc-empty {
    color: var(--text-muted);
    font-style: italic;
    min-height: 48px;
}

.detail-desc-textarea {
    width: 100%;
    min-height: 160px;
    font-size: 14px;
    color: var(--text-primary);
    background: transparent;
    border: 1.5px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    outline: none;
    resize: none;
    overflow: hidden;
    font-family: var(--font-mono);
    line-height: 1.6;
    box-shadow: 0 0 0 2px #db403518;
}
.detail-desc-textarea::placeholder { color: var(--text-muted); font-family: var(--font); }

/* ─── Detail subtasks ────────────────────────────────────────────────── */
.detail-subtasks {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-subtasks-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-subtasks-count {
    font-size: 11px;
    color: var(--text-muted);
}

.detail-subtasks-progress {
    height: 3px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}
.detail-subtasks-progress > span {
    display: block;
    height: 100%;
    background: var(--accent);
    transition: width .2s;
}

.detail-subtasks-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.detail-subtask {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.detail-subtask:hover { background: var(--accent-light); }
.detail-subtask--dragging { opacity: .4; }

.detail-subtask-title {
    flex: 1;
    min-width: 0;
    text-align: left;
    font-size: 13.5px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.detail-subtask--done .detail-subtask-title {
    color: var(--text-muted);
    text-decoration: line-through;
}

.detail-subtask-remove {
    font-size: 10px;
    color: var(--text-muted);
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity .1s, color .1s;
}
.detail-subtask:hover .detail-subtask-remove { opacity: 1; }
.detail-subtask-remove:hover { color: var(--accent); }

.detail-subtasks-add { position: relative; }

.detail-subtasks-chips { padding: 0 4px; }

.detail-subtasks-input {
    width: 100%;
    font-size: 13px;
    padding: 6px 4px;
    border: none;
    border-bottom: 1px solid transparent;
    background: transparent;
    color: inherit;
    outline: none;
}
.detail-subtasks-input::placeholder { color: var(--accent); }
.detail-subtasks-input:focus { border-bottom-color: var(--border-input); }
.detail-subtasks-input:focus::placeholder { color: var(--text-muted); }

/* ─── Detail resources ───────────────────────────────────────────────── */
.detail-resources {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-resources-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.detail-resources-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
}

.detail-resources-add {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--accent);
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    transition: background .1s;
}
.detail-resources-add:hover { background: var(--accent-light); }

.detail-resources-dropzone {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    border: 1.5px dashed var(--border-input);
    border-radius: var(--radius-md);
    min-height: 48px;
    transition: border-color .15s, background .15s;
}
.detail-resources-dropzone--dragover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.detail-resources-empty {
    align-self: center;
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

.detail-resource-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 84px;
}

.detail-resource-thumb {
    width: 100%;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.detail-resource-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 64px;
    border-radius: var(--radius-sm);
    background: var(--border);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
}

.detail-resource-name {
    width: 100%;
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-resource-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    font-size: 9px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity .1s, background .1s, color .1s;
}
.detail-resource-item:hover .detail-resource-remove { opacity: 1; }
.detail-resource-remove:hover { background: var(--accent-light); color: var(--accent); }

.detail-resources-error {
    font-size: 12.5px;
    color: var(--accent);
}

.detail-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

kbd {
    font-family: var(--font-mono);
    font-size: 10px;
    background: rgba(255,255,255,.2);
    padding: 1px 4px;
    border-radius: 3px;
}

/* ─── Markdown preview ───────────────────────────────────────────────── */
.markdown-body h1 { font-size: 1.4em; margin: .5em 0; }
.markdown-body h2 { font-size: 1.2em; margin: .5em 0; }
.markdown-body h3 { font-size: 1.1em; margin: .5em 0; }
.markdown-body p { margin: .5em 0; }
.markdown-body ul, .markdown-body ol { margin: .5em 0 .5em 1.5em; }
.markdown-body li { margin: .2em 0; }
.markdown-body code { background: #f4f4f4; padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono); font-size: .9em; }
.markdown-body pre { background: #f4f4f4; padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote { border-left: 3px solid var(--border-input); padding-left: 12px; color: var(--text-secondary); margin: .5em 0; }
.markdown-body a { color: var(--accent); text-decoration: underline; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.markdown-body strong { font-weight: 600; }
.markdown-body em { font-style: italic; }
.markdown-body img { max-width: 100%; border-radius: var(--radius-sm); margin: .5em 0; }

/* ─── Today progress bar ─────────────────────────────────────────────── */
.today-progress {
    margin-bottom: 24px;
}

.today-progress-track {
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.today-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width .3s ease;
}

.today-progress-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    font-size: .8rem;
    color: var(--text-muted);
}

/* ─── Today duration total ───────────────────────────────────────────── */
.today-duration-total {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .8rem;
    color: var(--text-muted);
    padding: 10px 4px 4px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.today-duration-total strong {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ─── Upcoming grouped sections ─────────────────────────────────────── */
.upcoming-group {
    margin-bottom: 32px;
}

.upcoming-group-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 0 0 8px 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.upcoming-group-title--overdue { color: #dc2626; }
.upcoming-group-title--today   { color: #d97706; }
.upcoming-group-title--soon    { color: var(--text-secondary); }
.upcoming-group-title--upcoming { color: var(--text-secondary); }

.upcoming-group-count {
    margin-left: auto;
    font-size: .72rem;
    font-weight: 500;
    background: var(--border);
    border-radius: 10px;
    padding: 1px 7px;
    color: var(--text-muted);
}

/* ─── Archived projects page ─────────────────────────────────────────── */
.archived-page {
    max-width: 640px;
    margin: 40px auto;
    padding: 0 24px;
}

.archived-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.archived-back {
    color: var(--text-secondary);
    font-size: .85rem;
}
.archived-back:hover { color: var(--text-primary); }

.archived-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.archived-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.archived-name {
    font-weight: 500;
    flex: 1;
    min-width: 0;
}

.archived-date {
    font-size: .8rem;
    color: var(--text-muted);
}

/* ─── Scrollbar ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #ccc; }

/* ─── Mobile menu button (hidden on desktop) ─────────────────────────── */
.mobile-menu-btn {
    display: none;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: color .12s;
}
.mobile-menu-btn:hover { color: var(--text-primary); }

/* ─── Sidebar overlay (mobile) ───────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 299;
    opacity: 0;
    transition: opacity .25s;
}
.sidebar-overlay--visible {
    display: block;
    opacity: 1;
}

/* ─── Mobile layout ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        height: auto;
    }

    .app-layout {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    /* Sidebar slides in from left as a fixed overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100dvh;
        z-index: 300;
        width: 260px;
        transition: left .25s ease;
        overflow-y: auto;
    }
    .sidebar--open { left: 0; }

    /* Main content takes full width */
    .main-content {
        overflow-y: visible;
        height: auto;
        padding: 20px 16px 40px;
    }

    /* Hamburger visible on mobile */
    .mobile-menu-btn { display: flex; align-items: center; }

    .main-header { margin-bottom: 20px; }

    /* Drag handles always visible on touch (no hover state), and widened
       since a glyph-sized hit area is too small to reliably grab by touch. */
    .todo-drag-handle { opacity: .35; padding: 10px 8px; margin: -10px -8px -10px 0; }
    .drag-handle { opacity: .35; padding: 10px 8px; margin: -10px -8px -10px 0; }

    /* Icon-only picker buttons when unset — too cramped on mobile.
       Buttons showing a selected value keep their label since it's data, not a hint. */
    .picker-btn:not(.is-set) span:last-child { display: none; }
    .picker-btn { padding: 6px 8px; }

    /* Detail modal: stack sidebar below main content */
    .detail-body { flex-direction: column; }
    .detail-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        flex-direction: row;
        flex-wrap: wrap;
        gap: 16px 24px;
    }
    .sidebar-row {
        flex: 1 1 160px;
        padding: 0;
        border-top: none;
    }

    /* Modal as bottom sheet */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    .modal,
    .modal:has(.detail-form) {
        max-width: 100%;
        max-height: 90dvh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        animation: slideUp .2s ease;
    }

    /* Entity modals (project/tag create) keep centered */
    .modal-overlay:has(.entity-modal) {
        align-items: center;
        padding: 16px;
    }
    .modal-overlay:has(.entity-modal) .modal {
        border-radius: var(--radius-lg);
        animation: slideUp .15s ease;
    }
}

@media (max-width: 480px) {
    .main-content { padding: 16px 12px 40px; }

    .quick-add-form { padding: 10px 12px; }

    .detail-main,
    .detail-sidebar { padding: 16px; }

    .entity-modal { padding: 20px 16px 16px; }

    /* Tighten upcoming groups */
    .upcoming-group { margin-bottom: 24px; }
}

/* ─── Weekly goals ───────────────────────────────────────────────────── */
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Last item of .todo-meta, pushed to the right edge of that same line */
.todo-goal {
    font: inherit;
    border: none;
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--goal);
    background: var(--goal-light);
    padding: 1px 8px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 160px;
}
.todo-goal:hover { background: #e9e0fd; }
.detail-dropdown--right { left: auto; right: 0; }
.todo-goal-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.goal-icon { flex-shrink: 0; }

.dropdown-goal-icon { color: var(--goal); flex-shrink: 0; }
.dropdown-meta { margin-left: auto; font-size: 11px; color: var(--text-muted); }
.dropdown-clear { color: var(--text-secondary); font-style: italic; }
.dropdown-empty { padding: 8px 12px; font-size: 13px; color: var(--text-muted); }
.sidebar-value-icon--goal { color: var(--goal); }

/* Header week navigation */
.main-title > .goal-icon { color: var(--goal); }
.week-nav {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 8px;
    font-size: 14px;
    font-weight: 500;
}
.week-nav-btn {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 18px;
}
.week-nav-btn:hover { background: var(--border); color: var(--text-primary); }
.week-nav-today {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
}
.week-nav-today:hover { background: var(--border); }

/* Goal strip on Today */
.goal-strip { margin-bottom: 24px; }
.goal-strip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.goal-strip-link {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--goal);
    text-decoration: none;
}
.goal-strip-link:hover { text-decoration: underline; }
.goal-strip-chips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}
.goal-chip {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 12px 11px;
    border-radius: var(--radius-md);
    background: var(--goal-light);
    color: var(--goal);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
}
.goal-chip:hover { box-shadow: var(--shadow-sm); }
.goal-chip-title {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.goal-chip-progress { font-size: 11px; color: var(--text-secondary); }
.goal-chip-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    background: var(--goal);
    transition: width .3s ease;
}
.goal-chip--done .goal-chip-title { text-decoration: line-through; color: var(--text-secondary); }
.goal-strip-empty {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border: 1px dashed var(--border-input);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
}
.goal-strip-empty:hover { border-color: var(--goal); color: var(--goal); }

/* Carry-over banner */
.carry-over-banner {
    border: 1px solid #e4dafb;
    background: var(--goal-light);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 16px;
}
.carry-over-banner-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--goal);
    margin-bottom: 8px;
}
.carry-over-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.carry-over-item { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.carry-over-item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.carry-over-item-progress { font-size: 12px; color: var(--text-muted); }

/* This Week view */
.goal-list { display: flex; flex-direction: column; gap: 16px; }
.goal-card {
    border: 1px solid var(--border-input);
    border-left: 3px solid var(--goal);
    border-radius: var(--radius-md);
    padding: 14px 16px 10px;
}
.goal-card--completed { border-left-color: #16a34a; }
.goal-card--carried_over,
.goal-card--dropped { border-left-color: var(--text-muted); opacity: .7; }
.goal-card-header { display: flex; align-items: center; gap: 10px; }
.goal-card-header .todo-check { --check-color: var(--goal); }
.goal-card--completed .goal-card-title { text-decoration: line-through; color: var(--text-secondary); }
.goal-card-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    outline: none;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: -4px;
}
.goal-card-title[contenteditable="true"] { cursor: text; }
.goal-card-title[contenteditable="true"]:hover { background: rgba(0,0,0,.04); }
.goal-card-title:focus { background: rgba(0,0,0,.06); box-shadow: 0 0 0 2px var(--border-input); }
.goal-card-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 99px;
    background: var(--border);
    color: var(--text-secondary);
    white-space: nowrap;
}
.goal-card-badge--muted { background: var(--goal-light); color: var(--goal); }
.goal-card-delete {
    color: var(--text-muted);
    padding: 4px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity .1s, color .1s, background .1s;
}
.goal-card:hover .goal-card-delete,
.goal-card-delete:focus-visible { opacity: 1; }
.goal-card-delete:hover { color: var(--accent); background: var(--accent-light); }

.goal-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0 8px;
}
.goal-progress-track {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}
.goal-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--goal);
    transition: width .3s ease;
}
.goal-card--completed .goal-progress-fill { background: #16a34a; }
.goal-progress-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.goal-card-todos:empty { border-top: none; }
.goal-card-add .quick-add-trigger { padding: 6px 4px; }
.goal-card-add .quick-add-form { margin: 4px 0 8px; }
.goal-card-completed summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px;
}

.goal-add {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 6px 6px 6px 12px;
    border: 1px dashed var(--border-input);
    border-radius: var(--radius-md);
    color: var(--goal);
}
.goal-add:focus-within { border-style: solid; border-color: var(--goal); }
.goal-add-input {
    flex: 1;
    border: none;
    outline: none;
    background: none;
    font: inherit;
    font-size: 14px;
    color: var(--text-primary);
}
.goal-add-error { margin-top: 6px; font-size: 13px; color: var(--accent); }
.goal-limit-hint { margin-top: 16px; font-size: 13px; color: var(--text-muted); text-align: center; }

/* Weekly review: tasks completed in the shown week */
.goal-week-done { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }
.goal-week-done-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.goal-week-done-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.goal-week-done-title .upcoming-group-count { margin-left: 4px; }
.goal-week-done-duration { padding: 0; }
.goal-week-done .upcoming-group { margin-bottom: 20px; }

@media (max-width: 480px) {
    .todo-goal { max-width: 90px; }
}

/* ─── Login ──────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-bg);
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 28px 24px;
    background: var(--content-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.login-logo {
    justify-content: center;
    margin-bottom: 6px;
}

.login-error {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    color: var(--accent-hover);
    font-size: 13px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.login-field input {
    padding: 8px 10px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.login-field input:focus {
    outline: none;
    border-color: var(--accent);
}

.login-remember {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.login-submit {
    justify-content: center;
    padding: 10px 14px;
}

/* ─── Sidebar user ───────────────────────────────────────────────────── */
.sidebar-user {
    margin-top: auto;
    padding: 12px 16px 0;
    border-top: 1px solid #e5e0da;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
}

.sidebar-user-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
