/* Architects PM tool — base styles. No build step, no external fonts. */

:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --border: #e3dfd5;
  --text: #1d1d1b;
  --muted: #6b6a64;
  --accent: #1f4e46;
  --accent-ink: #ffffff;
  --accent-soft: #e4eeeb;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --ok-soft: #e6f3ec;
  --shadow: 0 1px 2px rgba(20, 20, 18, .06), 0 4px 14px rgba(20, 20, 18, .05);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark theme: only when the user picks it with the toggle (data-theme). The page defaults to light. */
:root[data-theme="dark"] {
  --bg: #161614;
  --surface: #1f1f1c;
  --surface-2: #252522;
  --border: #36352f;
  --text: #efede6;
  --muted: #a09e94;
  --accent: #6fb3a5;
  --accent-ink: #0f1f1c;
  --accent-soft: #1e302c;
  --danger: #f08a80;
  --danger-soft: #3a1f1c;
  --ok-soft: #1c2f25;
  --shadow: none;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

.theme-toggle { min-width: 2.2rem; padding-left: .55rem; padding-right: .55rem; font-size: 1.05rem; line-height: 1; }
.theme-toggle.floating { position: fixed; top: .75rem; right: .75rem; z-index: 20; background: var(--surface); border: 1px solid var(--border); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 0 .3em; border-radius: 4px; font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
#project-desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.small { font-size: .85rem; }

/* ----- layout ----- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem 1rem; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: -.01em; }
.topnav { display: flex; gap: 1rem; flex: 1; }
.topnav a { text-decoration: none; color: var(--muted); }
.topnav a:hover { color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.topbar-right form { margin: 0; }
.who { color: var(--text); text-decoration: none; font-size: .9rem; }

.page { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
body.auth .page { display: grid; place-items: center; min-height: 100vh; padding-top: 0; }
/* Project board page uses the full browser width, so more columns fit without scrolling. */
body.wide .page { max-width: none; padding-left: 1.5rem; padding-right: 1.5rem; }
/* Honeypot field on the registration form: invisible to people, tempting to bots. */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.switch-link { margin: 1rem 0 0; text-align: center; }
.cookie-note { margin: 1.1rem 0 0; padding-top: .9rem; border-top: 1px solid var(--border); text-align: center; font-size: .8rem; line-height: 1.45; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.crumbs { margin-bottom: .75rem; font-size: .9rem; }
.crumbs a { text-decoration: none; }
.section { margin-bottom: 2.25rem; }
.section > h2 { margin-bottom: .1em; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 440px; width: 100%; }

/* ----- forms and buttons ----- */
.form { display: flex; flex-direction: column; gap: .9rem; }
.form-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.form-row .grow { flex: 1; min-width: 180px; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; font-weight: 550; }
label.check { flex-direction: row; align-items: center; gap: .45rem; font-weight: 500; }
input, textarea, select {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: .55rem .65rem; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: auto; }
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
fieldset.choice { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem .8rem; margin: 0; }
fieldset.choice legend { font-size: .9rem; font-weight: 550; padding: 0 .3rem; }
label.radio { flex-direction: row; align-items: flex-start; gap: .6rem; font-weight: 400; padding: .3rem 0; }
label.radio span { display: flex; flex-direction: column; }
label.radio small { color: var(--muted); }
.field-error { color: var(--danger); font-size: .82rem; min-height: 0; font-weight: 500; }

.btn {
  font: inherit; font-weight: 550; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; text-decoration: none; display: inline-block;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.1); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-small { padding: .25rem .6rem; font-size: .85rem; }

.notice { padding: .65rem .85rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice-ok { background: var(--ok-soft); color: var(--accent); }

/* ----- tables ----- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 550; font-size: .82rem; }
.table tr.is-inactive td { color: var(--muted); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: .4rem; margin: 0; }
.inline-form input { width: 9rem; padding: .25rem .5rem; }

/* ----- project cards ----- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-top: .9rem; }
.project-card {
  display: flex; flex-direction: column; gap: .35rem; padding: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: border-color .12s, transform .12s;
}
.project-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.project-card.is-archived { opacity: .7; }
.project-card-head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.project-name { margin: 0; overflow-wrap: anywhere; }
.project-desc { margin: 0; color: var(--muted); font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-owner { margin: 0; font-size: .82rem; color: var(--accent); }
.project-meta { margin: 0; font-size: .82rem; color: var(--muted); }
.progress { height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: .4rem; }
.progress-bar { display: block; height: 100%; background: var(--accent); }
.empty { color: var(--muted); padding: .5rem 0; margin: 0; grid-column: 1 / -1; }

.badges { display: flex; gap: .4rem; flex-wrap: wrap; margin: .3rem 0 0; }
.badge { font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.badge-public { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-soft { font-weight: 500; }

/* ----- board ----- */
.board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .75rem; align-items: flex-start; }
.column { flex: 1 1 260px; min-width: 240px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; }
.column-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.column-head h3 { margin: 0; flex: 1; font-size: .95rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.count { font-size: .8rem; color: var(--muted); }
.column-body { display: flex; flex-direction: column; gap: .5rem; min-height: 3rem; }

/* ----- dialogs ----- */
.dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; width: min(480px, calc(100vw - 2rem)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.dialog::backdrop { background: rgba(20, 20, 18, .45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .5rem; }
.danger-zone h3 { color: var(--danger); }
.danger-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.member-list { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: .4rem; }
.member { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .4rem .6rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }

/* ----- toasts ----- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 50; }
.toast { background: var(--text); color: var(--bg); padding: .6rem .9rem; border-radius: 8px; box-shadow: var(--shadow); max-width: 320px; font-size: .92rem; }
.toast-error { background: var(--danger); color: #fff; }


/* ----- workspaces and templates ----- */
.section-head { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.section-head h2 { margin-bottom: .1em; }
.badge-workspace { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-template { background: var(--text); color: var(--bg); border-color: transparent; }
.status-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: .15rem 0; }
.status-chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; padding: .05rem .45rem; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.status-chip .dot { width: 8px; height: 8px; }
.template-card { cursor: default; }
.template-card:hover { transform: none; }
.template-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; padding-top: .5rem; }
.template-preview { border: 1px dashed var(--border); border-radius: 8px; padding: .65rem .8rem; background: var(--surface-2); display: flex; flex-direction: column; gap: .35rem; }
.template-preview p { margin: 0; }
.template-preview-desc { white-space: pre-wrap; }
.template-banner { background: var(--accent-soft); color: var(--text); border: 1px solid var(--border); }
.grow-span { flex: 1; gap: .3rem; }
.grow-span select { margin-top: .2rem; }
.project-card.flash { animation: card-flash 2.2s ease-out; }
@media (prefers-reduced-motion: reduce) { .project-card.flash { animation: none; outline: 2px solid var(--accent); } }
.member-link { padding: .2rem .1rem; font-size: .9rem; }
.people-list { max-width: 560px; }
.people-add { max-width: 560px; }
.share-note { flex-basis: 100%; margin-top: -.35rem; }
#ws-desc { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ----- small screens ----- */
@media (max-width: 640px) {
  .topbar { gap: .75rem; flex-wrap: wrap; }
  .topnav { order: 3; flex-basis: 100%; }
  .topbar-right { margin-left: auto; }
  .page { padding-top: 1rem; }
  .column { flex: 0 0 85vw; min-width: 0; }
  body.wide .page { padding-left: .75rem; padding-right: .75rem; }
  .dialog { padding: 1rem; }
}

/* ----- task cards ----- */
.column-head .badge { font-size: .68rem; padding: 0 .4rem; }
.column-body { min-height: 3.5rem; }
.column-body > .empty { padding: .6rem .25rem; text-align: center; border: 1px dashed var(--border); border-radius: 8px; }
.task-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem .7rem; cursor: grab; display: flex; flex-direction: column; gap: .4rem;
  box-shadow: var(--shadow);
}
.task-card:hover { border-color: var(--accent); }
.task-card.due-yellow { border-left: 4px solid #eab308; }
.task-card.due-red { border-left: 4px solid #dc2626; }
.task-card:active { cursor: grabbing; }
.task-title { font-weight: 550; overflow-wrap: anywhere; }
.drag-ghost { opacity: .4; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.chip-p1 { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip-p3 { opacity: .8; }
.chip-overdue { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.mini-subtasks { list-style: none; margin: 0; padding: .35rem 0 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; }
.mini-subtasks li { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.mini-subtasks .dot { width: 8px; height: 8px; flex: none; }
.mini-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-status { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.mini-subtasks li.is-done .mini-title { text-decoration: line-through; color: var(--muted); }
.mini-subtasks li.more { color: var(--muted); padding-left: 1rem; }

.add-task-btn { margin-top: .5rem; width: 100%; text-align: left; background: transparent; border: 0; color: var(--muted); font: inherit; padding: .4rem .3rem; border-radius: 6px; cursor: pointer; }
.add-task-btn:hover { background: var(--surface); color: var(--text); }
.add-form { margin-top: .5rem; display: flex; flex-direction: column; gap: .4rem; }
.add-actions { display: flex; gap: .4rem; }

/* ----- task dialog, subtasks ----- */
.dialog-wide { width: min(640px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow-y: auto; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; }
.dialog-actions.split { align-items: center; }
.spacer { flex: 1; }
.subtasks-head { display: flex; justify-content: space-between; align-items: baseline; }
.subtask-list { list-style: none; margin: .5rem 0 .75rem; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.subtask { display: flex; flex-direction: column; gap: .35rem; }
.subtask-main { display: grid; grid-template-columns: 1fr auto auto auto auto; gap: .4rem; align-items: center; }
.subtask .sub-title { padding: .35rem .5rem; }
.subtask .sub-title.is-done { text-decoration: line-through; color: var(--muted); }
.subtask .sub-status { width: auto; min-width: 9rem; padding: .35rem .5rem; }
.subtask-add { display: grid; grid-template-columns: 1fr auto auto; gap: .4rem; }

/* ----- status editor ----- */
.status-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.status-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.status-row input[type="text"] { flex: 1; min-width: 8rem; }
.status-row .check { white-space: nowrap; }
.status-confirm { flex-direction: column; align-items: stretch; background: var(--danger-soft); border-radius: 8px; padding: .6rem .75rem; }
.status-confirm p { margin: 0; }
.status-confirm-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.status-confirm-actions select { width: auto; flex: 1; min-width: 8rem; }
.status-add { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.status-add input[name="name"] { flex: 1; min-width: 8rem; }
.color-input { width: 2.4rem; height: 2.2rem; padding: .15rem; flex: none; cursor: pointer; }

@media (max-width: 640px) {
  .subtask-main { grid-template-columns: 1fr auto; }
  .subtask .sub-status { grid-column: 1; }
  .subtask-add { grid-template-columns: 1fr; }
}

/* Projects view full-screen */
.page:has(#project-root) {
  max-width: none;
  width: 90%;
}

/* ----- live sync ----- */
.live-status { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--muted); padding: .25rem .6rem; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); }
.live-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.live-status.offline::before { background: #f59e0b; }
/* A card someone else just created or changed glows for a moment. */
.task-card.flash { animation: card-flash 2.2s ease-out; }
@keyframes card-flash {
  0%, 30% { box-shadow: 0 0 0 3px var(--accent); background: var(--accent-soft); }
  100% { box-shadow: var(--shadow); }
}
@media (prefers-reduced-motion: reduce) { .task-card.flash { animation: none; outline: 2px solid var(--accent); } }

/* ----- labels ----- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field-label { font-size: .9rem; font-weight: 550; }
.label-chip {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: .72rem; font-weight: 650; line-height: 1.5; padding: 0 .5rem; border-radius: 4px;
}
.label-chip-sm { font-size: .7rem; padding: 0 .4rem; }
.card-labels { display: flex; flex-wrap: wrap; gap: .25rem; }
.mini-labels { display: inline-flex; gap: 2px; flex: none; }
.label-swatch { width: 12px; height: 6px; border-radius: 2px; display: inline-block; }

.label-picker-inner { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.label-toggle {
  --label: #64748b; --label-ink: #fff;
  font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .6rem; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.label-toggle { max-width: 100%; }
.label-toggle-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.label-toggle::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--label); flex: none; }
.label-toggle:hover { border-color: var(--label); }
.label-toggle[aria-pressed="true"] { background: var(--label); border-color: var(--label); color: var(--label-ink); }
.label-toggle[aria-pressed="true"]::before { content: "\2713"; width: auto; height: auto; background: none; font-size: .75rem; line-height: 1; }
.label-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.label-new { width: 9.5rem; padding: .2rem .6rem; font-size: .8rem; border-radius: 99px; border-style: dashed; }
.sub-labels { display: flex; flex-wrap: wrap; gap: .25rem; padding-left: .1rem; }
.sub-picker { padding: .5rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.sub-labels-btn { white-space: nowrap; }
.sub-labels-btn.is-open { color: var(--accent); }
.label-usage { min-width: 4.5rem; text-align: right; }
/* Dark label colors would melt into the dark theme's cards without a faint edge. */
:root[data-theme="dark"] .label-chip { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); }

/* ----- nav: current page ----- */
.topnav a[aria-current="page"] { color: var(--text); font-weight: 600; }

/* ----- timeline ----- */
.tl-root { --warn: #b45309; --tl-sticky: 4rem; } /* height of the sticky top bar */
:root[data-theme="dark"] .tl-root { --warn: #fbbf24; }
.tl-filters { align-items: flex-end; }
.tl-filter { flex-direction: row; align-items: center; gap: .45rem; font-weight: 500; }
.tl-filter select { width: auto; padding: .4rem .6rem; }

.tl-summary { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.tl-stat {
  display: flex; flex-direction: column; align-items: flex-start; min-width: 7.5rem;
  padding: .55rem .85rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); font: inherit; color: inherit; text-align: left;
}
button.tl-stat { cursor: pointer; }
.tl-stat strong { font-size: 1.4rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tl-stat span { font-size: .8rem; color: var(--muted); }
.tl-stat.is-alert { border-color: var(--danger); background: var(--danger-soft); }
.tl-stat.is-alert strong, .tl-stat.is-alert span { color: var(--danger); }
.tl-stat.is-calm strong { color: var(--accent); }
.tl-stat.is-quiet { background: transparent; box-shadow: none; }

.tl-count {
  font-size: .75rem; font-weight: 650; padding: 0 .5rem; border-radius: 99px; line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-variant-numeric: tabular-nums;
}

/* Overdue panel, always on top */
.tl-overdue {
  background: var(--danger-soft); border: 1px solid var(--danger); border-left-width: 5px;
  border-radius: var(--radius); padding: 1rem 1rem 1.1rem; margin-bottom: 1.5rem; scroll-margin-top: 4.5rem;
}
.tl-overdue-head { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tl-overdue-head h2 { margin: 0; color: var(--danger); }
.tl-overdue-head .tl-count { background: var(--danger); color: #fff; border-color: transparent; }
.tl-overdue-hint { margin-left: auto; }
.tl-alert-icon {
  width: 1.4rem; height: 1.4rem; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--danger); color: #fff; font-weight: 800; font-size: .85rem;
}
:root[data-theme="dark"] .tl-alert-icon, :root[data-theme="dark"] .tl-overdue-head .tl-count { color: #1a0f0e; }

/* Task cards */
.tl-cards { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.tl-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: .55rem; }
.tl-card {
  --proj: var(--accent);
  display: flex; flex-direction: column; gap: .35rem; min-width: 0;
  padding: .6rem .75rem .65rem .85rem; background: var(--surface);
  border: 1px solid var(--border); border-left: 4px solid var(--proj); border-radius: 8px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
  transition: border-color .12s, transform .12s;
}
.tl-card:hover { border-color: var(--accent); border-left-color: var(--proj); transform: translateY(-1px); }
.tl-card.is-overdue { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); border-left-color: var(--danger); }
.tl-card-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .15rem .5rem; font-size: .78rem; }
.tl-project { display: inline-flex; align-items: center; gap: .35rem; min-width: 0; max-width: 100%; color: var(--muted); font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tl-project .dot { background: var(--proj); flex: none; }
.tl-when { white-space: nowrap; color: var(--muted); font-weight: 600; }
.tl-when.is-soon { color: var(--warn); }
.tl-when.is-overdue { color: var(--danger); }
.tl-title { font-weight: 600; overflow-wrap: anywhere; }
.tl-parent { margin-top: -.2rem; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.chip-status { display: inline-flex; align-items: center; gap: .3rem; }
.chip-status .dot { width: 7px; height: 7px; }

/* At-a-glance day strip (scrolls sideways inside its own box) */
.tl-strip-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.75rem; min-width: 0; }
.tl-strip-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .55rem .75rem 0 .9rem; }
.tl-strip-head h2 { margin: 0; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; font-size: .75rem; }
.tl-strip-nav { display: flex; gap: .15rem; }
.tl-strip { display: flex; gap: 2px; overflow-x: auto; padding: .35rem .5rem .7rem; scroll-snap-type: x proximity; scrollbar-width: thin; overscroll-behavior-x: contain; }
.tl-day {
  flex: 0 0 3.15rem; scroll-snap-align: start; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
  padding: .2rem 0 .45rem; border: 0; border-radius: 8px; background: transparent;
  color: inherit; font: inherit; cursor: pointer;
}
.tl-day:hover:not(:disabled) { background: var(--surface-2); }
.tl-day:disabled { cursor: default; }
.tl-day.is-weekend { background: color-mix(in srgb, var(--surface-2) 70%, var(--border)); }
.tl-day.is-dim > :not(.tl-day-month) { opacity: .4; }
.tl-day.is-month-start::before { content: ""; position: absolute; left: -2px; top: .2rem; bottom: .2rem; width: 2px; background: var(--border); border-radius: 2px; }
.tl-day.is-today { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.tl-day.is-today .tl-day-num { color: var(--accent); }
.tl-day-month { height: 1.05rem; font-size: .7rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.tl-day-wd { font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tl-day-num { font-weight: 650; font-variant-numeric: tabular-nums; }
.tl-day-bars { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 2.5rem; padding-top: .25rem; }
.tl-bar { width: 1.9rem; height: 6px; border-radius: 3px; }
.tl-bar.is-high { height: 8px; box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 2.5px var(--danger); }
.tl-day-more { font-size: .65rem; font-weight: 600; color: var(--muted); line-height: 1; }

/* Vertical list: weeks, then days on a rail */
.tl-week { margin-bottom: 1.5rem; }
.tl-week-head {
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  position: sticky; top: var(--tl-sticky); z-index: 2;
  background: var(--bg); padding: .55rem 0 .45rem; margin-bottom: .25rem;
  border-bottom: 1px solid var(--border);
}
.tl-week-head h2 { margin: 0; }
.tl-days { position: relative; }
.tl-days::before { content: ""; position: absolute; left: calc(4.6rem - 1px); top: .9rem; bottom: .9rem; width: 2px; background: var(--border); border-radius: 2px; }
.tl-daygroup { display: grid; grid-template-columns: 3.6rem 2rem minmax(0, 1fr); padding: .6rem 0; scroll-margin-top: calc(var(--tl-sticky) + 3.2rem); border-radius: var(--radius); }
.tl-date { text-align: right; line-height: 1.1; padding-top: .1rem; }
.tl-date-wd, .tl-date-mo { display: block; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tl-date-num { display: block; font-size: 1.4rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tl-node { justify-self: center; width: 12px; height: 12px; margin-top: .65rem; border-radius: 50%; background: var(--bg); border: 2px solid var(--muted); position: relative; z-index: 1; }
.tl-daygroup.is-today .tl-node { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-daygroup.is-today .tl-date-num, .tl-daygroup.is-today .tl-day-label { color: var(--accent); }
.tl-day-label { font-size: .85rem; font-weight: 650; margin: .3rem 0 .45rem; }
.tl-daygroup.flash { animation: tl-flash 1.6s ease-out; }
.tl-overdue.flash { animation: tl-flash-red 1.6s ease-out; }
@keyframes tl-flash { 0%, 35% { background: var(--accent-soft); } 100% { background: transparent; } }
@keyframes tl-flash-red { 0%, 35% { box-shadow: 0 0 0 4px var(--danger); } 100% { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .tl-daygroup.flash, .tl-overdue.flash { animation: none; } }

.tl-empty, .tl-later {
  display: flex; flex-direction: column; align-items: flex-start; gap: .5rem;
  padding: 1.25rem; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.tl-later { flex-direction: row; align-items: center; flex-wrap: wrap; justify-content: space-between; padding: .8rem 1rem; }
.tl-undated { margin-top: 2rem; scroll-margin-top: 4rem; }
.tl-undated .tl-week-head { position: static; margin-bottom: .75rem; }

@media (max-width: 640px) {
  /* The top bar wraps to two rows on phones, so week headings scroll normally there. */
  .tl-week-head { position: static; }
  .tl-daygroup { scroll-margin-top: 9rem; }
  .tl-filters { width: 100%; }
  .tl-filter { flex: 1 1 10rem; }
  .tl-filter select { flex: 1; min-width: 0; }
  .tl-stat { min-width: 0; flex: 1 1 6.5rem; }
  .tl-overdue-hint { margin-left: 0; flex-basis: 100%; }
  .tl-cards-grid { grid-template-columns: minmax(0, 1fr); }
  .tl-daygroup { grid-template-columns: 2.6rem 1.5rem minmax(0, 1fr); }
  .tl-days::before { left: calc(3.35rem - 1px); }
  .tl-date-num { font-size: 1.15rem; }
}

/* ----- subtasks as full items ----- */
.task-back { align-self: flex-start; margin: -.4rem 0 .1rem -.6rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); }
.sub-meta { align-items: center; }
.chip-note { font: inherit; font-size: .72rem; font-weight: 600; cursor: pointer; }
.chip-note:hover { color: var(--text); }
.mini-subtasks li { cursor: pointer; border-radius: 4px; }
.mini-subtasks li:hover .mini-title { text-decoration: underline; }
.mini-due { font-size: .72rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mini-subtasks li.is-late .mini-due { color: var(--danger); font-weight: 650; }
@media (max-width: 640px) {
  .subtask-main { grid-template-columns: 1fr auto auto; }
  .subtask .sub-status { grid-column: 1; }
}
