/* ---------- Tokens ---------- */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --sidebar: #eef0f3;
  --text: #1d2330;
  --muted: #6b7280;
  --border: #e3e6eb;
  --primary: #3b5bdb;
  --primary-contrast: #ffffff;
  --danger: #d6336c;
  --ok: #2f9e44;
  --warn: #e67700;
  --c-inbox: #1d8cf8;
  --c-today: #f2b200;
  --c-upcoming: #e8484d;
  --c-anytime: #2aa198;
  --c-someday: #b39a5b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --gutter: 16px;
  --topbar-h: 53px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b1f27;
    --sidebar: #161a21;
    --text: #e6e8ec;
    --muted: #9aa3b2;
    --border: #2b313c;
    --primary: #6d8bff;
    --primary-contrast: #0d1020;
    --danger: #f06595;
    --ok: #51cf66;
    --warn: #ffa94d;
    --shadow: none;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.danger-text { color: var(--danger); }
.prewrap { white-space: pre-wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.inline { display: inline; }
.push-right { margin-left: auto; }

/* ---------- Top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; height: var(--topbar-h); }
.topbar-inner {
  height: 100%; padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 12px;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.topnav { display: flex; gap: 14px; align-items: center; margin-left: auto; }
.linklike { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; white-space: nowrap; }
.linklike:hover { color: var(--text); }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-toggle-btn { display: none; cursor: pointer; color: var(--text); padding: 6px; margin-left: -6px; border-radius: 8px; }
.nav-toggle-btn:hover { background: var(--bg); }
.nav-backdrop { display: none; }

/* ---------- App layout: sidebar + main ---------- */
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.main {
  container: main / inline-size;
  min-width: 0;
  width: 100%;
  max-width: 1400px;
  padding: 24px clamp(var(--gutter), 3vw, 40px) 48px;
}
.main-solo { margin: 0 auto; }

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 16px 10px 32px;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.side-group { margin-bottom: 18px; }
.side-heading {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 10px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
summary.side-heading { cursor: pointer; list-style: revert; justify-content: flex-start; gap: 4px; }
.side-adds { display: flex; gap: 2px; }
.side-add { display: inline-flex; align-items: center; gap: 1px; font-size: .95rem; line-height: 1; color: var(--muted); padding: 2px 4px; border-radius: 5px; }
.side-add .proj-icon, .side-add .area-icon { width: 14px; height: 14px; color: currentColor; }
.side-add:hover { color: var(--text); text-decoration: none; background: var(--border); }
.side-area { margin-top: 6px; font-weight: 700; }
.side-area-projects { margin-left: 14px; padding-left: 4px; border-left: 1px solid var(--border); }
.side-shared { font-size: .7rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 7px; color: var(--text); font-weight: 500;
}
.side-link:hover { text-decoration: none; background: color-mix(in srgb, var(--text) 6%, transparent); }
.side-link.active { background: color-mix(in srgb, var(--primary) 16%, transparent); }
.side-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-count { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.side-count-today {
  color: #fff; background: var(--c-upcoming); border-radius: 999px; padding: 0 7px; font-weight: 700; font-size: .75rem;
}
.side-empty { padding: 0 10px; margin: 4px 0; }
.side-due { display: inline-flex; align-items: center; gap: 3px; flex: none; font-size: .72rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.side-due svg { width: 11px; height: 11px; }
.side-due.deadline-today, .side-due.deadline-overdue { color: var(--danger); }
.side-bottom { border-top: 1px solid var(--border); padding-top: 10px; }
.scope-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.scope-switch a { padding: 5px 12px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.scope-switch a:hover { text-decoration: none; color: var(--text); }
.scope-switch a.active { background: var(--primary); color: var(--primary-contrast); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; }

@media (max-width: 899px) {
  .nav-toggle-btn { display: inline-flex; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    display: none;
    position: fixed; z-index: 15; left: 0; top: var(--topbar-h); bottom: 0;
    width: min(300px, 85vw); height: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  }
  .nav-toggle:checked ~ .app .sidebar { display: block; }
  .nav-toggle:checked ~ .app .nav-backdrop {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 14; background: rgba(0, 0, 0, .3);
  }
  .topnav { gap: 10px; }
  .topnav .linklike { font-size: .85rem; }
  h1 { font-size: 1.35rem; }
}

@media (max-width: 480px) {
  .who { display: none; }
  .topbar-inner { gap: 8px; }
}

/* ---------- List icons ---------- */
.list-icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.list-icon svg { width: 100%; height: 100%; }
.list-icon-inbox { color: var(--c-inbox); }
.list-icon-today { color: var(--c-today); }
.list-icon-upcoming { color: var(--c-upcoming); }
.list-icon-anytime { color: var(--c-anytime); }
.list-icon-someday { color: var(--c-someday); }
.list-icon-logbook { color: var(--ok); }
.list-title { display: flex; align-items: center; gap: 10px; }
.list-title .list-icon { width: 28px; height: 28px; }
.star { color: var(--c-today); font-size: .9em; }

/* Area colour palette (Area.Color). Each class sets --area-c; .has-color applies it. */
.c-gray { --area-c: var(--muted); }
.c-red { --area-c: #e5484d; }
.c-orange { --area-c: #f76b15; }
.c-yellow { --area-c: #c99400; }
.c-green { --area-c: #30a46c; }
.c-teal { --area-c: #12a594; }
.c-blue { --area-c: #0b78e3; }
.c-indigo { --area-c: #3e63dd; }
.c-purple { --area-c: #8e4ec6; }
.c-pink { --area-c: #d6409f; }
@media (prefers-color-scheme: dark) {
  .c-red { --area-c: #ff6369; }
  .c-orange { --area-c: #ff8b3e; }
  .c-yellow { --area-c: #ffd23f; }
  .c-green { --area-c: #4cc38a; }
  .c-teal { --area-c: #0bd8b6; }
  .c-blue { --area-c: #52a9ff; }
  .c-indigo { --area-c: #849dff; }
  .c-purple { --area-c: #bf7af0; }
  .c-pink { --area-c: #f986c9; }
}
.area-icon.has-color, .proj-icon.has-color { color: var(--area-c); }
.area-icon.has-color svg path { fill: color-mix(in srgb, var(--area-c) 25%, transparent); }
.proj-box.has-color { border-color: var(--area-c); }
.proj-box.has-color:hover { color: var(--area-c); background: color-mix(in srgb, var(--area-c) 12%, transparent); }
.proj-box.has-color.checked { background: var(--area-c); border-color: var(--area-c); color: #fff; }

/* Colour picker in the area form */
.swatch-field { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.swatch-field legend { font-weight: 600; font-size: .9rem; padding: 0; margin-bottom: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.swatch-dot {
  display: block; width: 30px; height: 30px; border-radius: 50%;
  background: var(--area-c); border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--surface);
}
.swatch input:checked + .swatch-dot { border-color: var(--text); }
.swatch input:focus-visible + .swatch-dot { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Project / area icons */
.proj-icon, .area-icon { display: inline-flex; width: 18px; height: 18px; flex: none; color: var(--primary); }
.proj-icon svg, .area-icon svg { width: 100%; height: 100%; }
.proj-icon.is-done { color: var(--muted); }
.area-icon { color: var(--muted); }
.list-title .area-icon { width: 28px; height: 28px; }

/* Clickable project box (complete / reopen) – rounded square with a thicker blue edge,
   so it reads differently from a todo's checkbox. */
.proj-box {
  width: 22px; height: 22px; flex: none; padding: 0; cursor: pointer;
  border: 2.5px solid var(--primary); border-radius: 7px; background: transparent;
  color: transparent; font-weight: 800; font-size: .8rem; line-height: 1;
}
.proj-box:hover { color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.proj-box.is-static { display: inline-flex; align-items: center; justify-content: center; cursor: default; }
.proj-box.is-static:not(.checked):not(.cancelled):hover { color: transparent; background: transparent; }
.proj-box.checked { background: var(--primary); color: var(--primary-contrast); }
.proj-box.cancelled { border-color: var(--muted); background: var(--border); color: var(--muted); }
.detail-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-title .proj-box { width: 26px; height: 26px; font-size: .95rem; }
.detail-title .tcheck { width: 24px; height: 24px; font-size: .85rem; border-width: 2px; }

/* ---------- Page bits ---------- */
.page-head { display: flex; gap: 8px 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { margin: 0 0 .25rem; color: var(--muted); font-size: .9rem; }
.project-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin: .25rem 0 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; line-height: 1.5; padding: 1px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: .85rem; }
.chip-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.detail-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@container main (min-width: 980px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr) 280px; }
}
.form-card { max-width: 760px; }
.auth-card { max-width: 420px; margin: 32px auto; }
.list-intro { margin: 0 0 12px; }
.list-foot { margin: 16px 0 0; }
.empty { padding: 12px 0; }
.group-head { display: flex; align-items: center; gap: 8px; margin-top: 1.4rem; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.card > .group-head:first-child { margin-top: 0; }
.group-head a { color: var(--text); }
.group-head.group-area { font-size: 1rem; color: var(--text); border-bottom-width: 2px; }
.group-nested { margin-left: 18px; }
.group-day { font-size: 1.4rem; color: var(--text); letter-spacing: 0; }
.date-hint { font-weight: 400; text-transform: none; letter-spacing: 0; }
.quick-add { display: flex; gap: 8px; margin-bottom: 12px; }
.quick-add input { flex: 1; min-width: 0; }

/* ---------- Messages ---------- */
.messages { list-style: none; margin: 0 0 16px; padding: 0; }
.msg { padding: 10px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); margin-bottom: 8px; }
.msg-success { border-left-color: var(--ok); }
.msg-error { border-left-color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; min-height: 38px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none !important; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--primary); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-small { padding: 4px 10px; min-height: 30px; font-size: .85rem; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .9rem; }
.req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
.help { color: var(--muted); }
.help ul { margin: 4px 0 0; padding-left: 18px; }
.error, .form-errors { color: var(--danger); }
.form-errors ul { margin: 0 0 12px; padding-left: 18px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

.grid-form { display: grid; grid-template-columns: 1fr; column-gap: 16px; }
@container main (min-width: 600px) {
  .grid-form { grid-template-columns: 1fr 1fr; }
  .grid-form .field-wide { grid-column: 1 / -1; }
}

.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.filters select { width: auto; min-width: 140px; padding: 6px 10px; }

/* ---------- Badges / progress ---------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--bg); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.badge-open { color: var(--primary); }
.badge-in_progress { color: var(--warn); }
.badge-done { color: var(--ok); }
.badge-overdue { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.progress { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 20px; }
.progress span { display: block; height: 100%; background: var(--ok); }

/* ---------- Project rows (projects inside Today / Upcoming) ---------- */
/* Same geometry as .todo-item so project and todo rows line up in mixed lists. */
.project-rows { list-style: none; margin: 0 0 4px; padding: 0; }
.project-row { display: flex; align-items: center; gap: 10px; padding: 6px 6px; border-radius: 8px; }
.project-row:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.project-row .proj-box { width: 20px; height: 20px; border-width: 2px; border-radius: 6px; font-size: .7rem; }
.project-row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; color: var(--text); }
.project-row-main:hover { text-decoration: none; }
.project-row-main:hover .project-name { color: var(--primary); }
.project-row.is-done .project-name { color: var(--muted); }
.completed-projects { margin-top: 12px; }
.completed-projects summary { cursor: pointer; padding: 4px 0; }
.chip .area-icon { width: 14px; height: 14px; }
.project-name { font-weight: 600; }
.project-meta { color: var(--muted); font-size: .8rem; }

/* ---------- Things-style todo rows (project / area pages) ---------- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo-item { display: flex; align-items: center; gap: 10px; padding: 6px 6px; border-radius: 8px; }
.todo-item:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.todo-item-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 1.02rem; }
.todo-item-main:hover { text-decoration: none; }
.todo-item-text { display: flex; flex-direction: column; min-width: 0; }
.todo-item-title { min-width: 0; overflow-wrap: anywhere; }
.todo-item-sub { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .8rem; }
.todo-item-sub .proj-icon, .todo-item-sub .area-icon { width: 12px; height: 12px; color: currentColor; }
.todo-item-sub .proj-icon.has-color, .todo-item-sub .area-icon.has-color { color: var(--area-c); }
.todo-item.is-done .todo-item-title { color: var(--muted); }
.todo-item.is-cancelled .todo-item-title { text-decoration: line-through; }
.when-chip {
  flex: none; padding: 1px 7px; border-radius: 5px; font-size: .8rem; font-weight: 700; white-space: nowrap;
  background: color-mix(in srgb, var(--text) 14%, transparent); color: color-mix(in srgb, var(--text) 85%, transparent);
}
.note-icon { display: inline-flex; width: 15px; height: 15px; color: var(--muted); flex: none; }
.note-icon svg { width: 100%; height: 100%; }
.todo-item-meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .88rem; white-space: nowrap; }
.deadline { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.deadline svg { width: 14px; height: 14px; }
.deadline-today, .deadline-overdue { color: var(--danger); }
.avatar.avatar-sm { width: 22px; height: 22px; font-size: .7rem; }
.tcheck {
  flex: none; width: 20px; height: 20px; padding: 0; cursor: pointer; border-radius: 5px;
  border: 1.5px solid color-mix(in srgb, var(--text) 45%, transparent); background: transparent;
  color: transparent; font-weight: 800; font-size: .75rem; line-height: 1;
}
.tcheck:hover { border-color: var(--primary); color: var(--primary); }
.tcheck.checked { background: var(--primary); border-color: var(--primary); color: #fff; }
.tcheck.cancelled { background: var(--border); border-color: var(--border); color: var(--muted); }
@container main (max-width: 560px) {
  .todo-item { flex-wrap: wrap; row-gap: 2px; align-items: flex-start; }
  .todo-item .tcheck { margin-top: 3px; }
  .todo-item-meta { flex-basis: 100%; padding-left: 30px; }
}

.is-cancelled .project-name { text-decoration: line-through; color: var(--muted); font-style: italic; }
@container main (max-width: 720px) {
  .card { padding: 16px; }
  .filters select { min-width: 0; }
}

/* ---------- Inline editing (project page) ---------- */
.project-head { min-width: 0; }
.inline-edit > summary { list-style: none; cursor: pointer; border-radius: 6px; }
.inline-edit > summary::-webkit-details-marker { display: none; }
.inline-edit > summary:hover { background: color-mix(in srgb, var(--text) 7%, transparent); outline: 4px solid color-mix(in srgb, var(--text) 7%, transparent); }
.inline-edit > summary.chip:hover { outline: 0; border-color: var(--muted); }
.inline-edit[open] > summary { display: none; }
.inline-edit-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.inline-edit-form input[type=text], .inline-edit-form input[type=date], .inline-edit-form select { width: auto; padding: 5px 9px; font-size: .9rem; }
.inline-edit-form .inline-edit-title-input { font: inherit; font-size: 1.4rem; font-weight: 700; padding: 2px 8px; min-width: min(420px, 60vw); }
.inline-edit-block > summary { display: block; padding: 2px 4px; margin: 0 -4px; }
.inline-edit-form-block { display: block; }
.inline-edit-form-block textarea { width: 100%; }
.chip-add { border-style: dashed; color: var(--muted); }
/* Notes sit right under the page title (project, area and todo pages) */
.notes-top { margin: -4px 0 20px; max-width: 80ch; }
.notes-top .inline-edit-form-block { max-width: none; }
/* Markdown notes with an in-place editor */
.inline-notes { position: relative; }
.notes-view[data-opens-editor] { cursor: text; border-radius: 8px; padding: 4px 6px; margin: -4px -6px 8px; }
.notes-view[data-opens-editor]:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.inline-notes:has(.notes-editor[open]) .notes-view { display: none; }
.notes-editor > summary.notes-edit-btn { display: inline-block; color: var(--muted); font-size: .8rem; padding: 0 4px; margin-left: -4px; }
.notes-editor > summary.notes-edit-btn:hover { color: var(--text); outline: 0; }
.notes-editor > summary.notes-add { font-size: .95rem; padding: 2px 6px; margin-left: -6px; }
.notes-editor[open] > summary { display: none; }
.detail-title .inline-edit { min-width: 0; }

/* Todo page */
.todo-page { max-width: 860px; }
.todo-page .card + .form-card-follow, .todo-page .page-head + .card { margin-top: 0; }
.detail-title.is-done .inline-edit > summary { color: var(--muted); }
.chip-status { font-weight: 600; }
.chip .avatar { width: 18px; height: 18px; font-size: .62rem; margin-left: -5px; }
.chip .proj-icon, .chip .area-icon { width: 14px; height: 14px; }
.todo-meta-line { margin: 14px 0 0; }

/* ---------- Date picker (When / Due) ---------- */
.date-btn { font: inherit; border: 0; background: none; padding: 0; cursor: pointer; flex: none; }
button.when-chip { padding: 1px 7px; }
button.date-btn:hover { filter: brightness(1.15); text-decoration: underline; text-underline-offset: 3px; }
button.date-btn.deadline { color: var(--muted); font-size: inherit; }
button.date-btn.deadline.deadline-today, button.date-btn.deadline.deadline-overdue { color: var(--danger); }
.date-picker {
  position: fixed; z-index: 50; width: 292px; padding: 10px 12px 12px;
  background: color-mix(in srgb, var(--surface) 92%, var(--text)); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.dp-title { text-align: center; font-weight: 700; color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.dp-option {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; border: 0; border-radius: 7px;
  background: none; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: left;
}
.dp-option:hover, .dp-option:focus-visible { background: color-mix(in srgb, var(--primary) 22%, transparent); outline: 0; }
.dp-clear { color: var(--muted); font-weight: 500; margin-top: 4px; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 2px; }
.dp-label { font-size: .8rem; font-weight: 700; color: var(--muted); }
.dp-nav { border: 0; background: none; color: var(--text); font-size: 1.2rem; line-height: 1; padding: 2px 8px; border-radius: 6px; cursor: pointer; }
.dp-nav:hover { background: color-mix(in srgb, var(--text) 10%, transparent); }
.dp-nav:disabled { opacity: .25; cursor: default; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); padding: 2px 0 4px; }
.dp-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; line-height: 1;
}
.dp-day small { font-size: .55rem; font-weight: 700; color: var(--primary); text-transform: uppercase; }
.dp-day:hover { background: color-mix(in srgb, var(--text) 10%, transparent); }
.dp-day:focus-visible, .dp-day:focus { outline: 0; background: var(--primary); color: var(--primary-contrast); }
.dp-day:focus small { color: inherit; }
.dp-day.dp-today { color: var(--c-today); font-size: 1.05rem; }
.dp-day.dp-today:focus { color: var(--primary-contrast); }
.dp-day.dp-selected:not(:focus) { box-shadow: inset 0 0 0 2px var(--primary); }
.dp-empty { aspect-ratio: 1; }

/* ---------- Keyboard shortcuts ---------- */
.todo-item.is-selected, .project-row.is-selected {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 45%, transparent);
}
@media (min-width: 900px) {
  body.sidebar-hidden .app { grid-template-columns: minmax(0, 1fr); }
  body.sidebar-hidden .sidebar { display: none; }
}
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 5px; border-radius: 5px; text-align: center;
  font: 600 .78rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg); border: 1px solid var(--border); border-bottom-width: 2px; color: var(--text);
}
.side-shortcuts { color: var(--muted); font-size: .85rem; }
.side-shortcuts kbd { min-width: 20px; }
.shortcuts-help {
  width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  border: 1px solid var(--border); border-radius: 14px; padding: 22px 24px;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.shortcuts-help::backdrop { background: rgba(0, 0, 0, .45); }
.shortcuts-help h2 { margin: 0 0 4px; }
.shortcuts-close { position: absolute; top: 14px; right: 14px; }
.shortcut-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 28px; margin: 8px 0; }
.shortcut-groups h3 { margin: 14px 0 6px; }
.shortcut-groups dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; align-items: baseline; }
.shortcut-groups dt { white-space: nowrap; }
.shortcut-groups dd { margin: 0; font-size: .88rem; }

/* ---------- Comments ---------- */
.detail-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.form-card-follow { margin-top: 20px; }
.comments h2 { margin-bottom: 4px; }
.comment { padding: 14px 0; border-bottom: 1px solid var(--border); }
.comment:target { background: color-mix(in srgb, var(--c-today) 10%, transparent); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.comment-actions { margin-left: auto; display: flex; gap: 6px; }
.comment-form { margin-top: 16px; }
.comment-form textarea { min-height: 96px; resize: vertical; }
.comment-count { font-size: .8rem; color: var(--muted); font-weight: 500; white-space: nowrap; }
.comment-count:hover { text-decoration: none; color: var(--text); }
.md-preview { border: 1px dashed var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; }
.md-preview-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.md-help summary { cursor: pointer; }
.md-help-body { margin-top: 6px; line-height: 1.9; }

/* Rendered Markdown */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md table { margin: 0 0 .6em; }
.md h1, .md h2, .md h3, .md h4 { font-size: 1.05rem; margin: .8em 0 .4em; color: var(--text); text-transform: none; letter-spacing: 0; }
.md h1 { font-size: 1.25rem; }
.md ul, .md ol { padding-left: 1.4em; }
.md code { font: .88em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.md pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.md pre code { border: 0; padding: 0; background: none; }
.md blockquote { border-left: 3px solid var(--border); padding-left: 12px; color: var(--muted); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 8px; }
.md img { max-width: 100%; height: auto; }
.md hr { border: 0; border-top: 1px solid var(--border); }

/* ---------- People ---------- */
.people { list-style: none; padding: 0; margin: 0 0 12px; }
.people li { display: flex; align-items: center; gap: 8px; padding: 6px 0; flex-wrap: wrap; }
.avatar {
  overflow: hidden;
  width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); font-weight: 700; font-size: .8rem; flex: none;
}
.side h2 + p { margin-top: 0; }
.share-form { margin-bottom: 24px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.has-img { background: none; }
.avatar.avatar-xl { width: 88px; height: 88px; font-size: 2rem; }
.topbar-user { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.topbar-user:hover { color: var(--text); text-decoration: none; }
.profile-head { display: flex; align-items: center; gap: 16px; margin: 16px 0 20px; }
.profile-name { font-size: 1.15rem; font-weight: 700; }
.avatar-form input[type=file] { font: inherit; color: var(--text); }

/* ---------- Tags ---------- */
.tag {
  display: inline-flex; align-items: center; padding: 0 8px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--muted) 45%, transparent);
  color: var(--muted); font-size: .74rem; font-weight: 600; line-height: 1.55;
  background: none; font-family: inherit; white-space: nowrap;
}
button.tag { cursor: pointer; }
button.tag:hover { color: var(--text); border-color: var(--text); }
.tag-inherited { border-style: dashed; opacity: .8; }
.tag-big { font-size: .9rem; padding: 2px 12px; cursor: pointer; list-style: none; color: var(--text); }
.tag-big::-webkit-details-marker { display: none; }
.tag-pills { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: 1px; margin-left: 4px; }
.tag-chips { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.tag-chips .chip-add { cursor: pointer; font-family: inherit; }
.tag-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tag-filter {
  padding: 2px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: .82rem; font-weight: 600;
}
.tag-filter:hover { text-decoration: none; color: var(--text); }
.tag-filter.active { background: var(--muted); border-color: var(--muted); color: var(--surface); }
.tag-filter.tag-sub { font-weight: 500; font-size: .78rem; }
.card > .tag-bar { margin-top: 4px; }

.tag-tree { list-style: none; margin: 12px 0 0; padding: 0; }
.tag-node {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 6px 6px 6px calc(6px + var(--depth, 0) * 24px); border-bottom: 1px solid var(--border);
}
.tag-node:last-child { border-bottom: 0; }
.tag-node:not([style*="--depth: 0"])::before { content: "└"; color: var(--muted); margin-right: -4px; }
.tag-node .inline-edit[open] { flex-basis: 100%; }
.tag-node-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.tag-node-actions select { max-width: 12rem; }
.tag-add select { max-width: 12rem; }

/* ---------- Choice picker (shares the look of .date-picker) ---------- */
.choice-picker { width: 280px; }
.cp-filter {
  width: 100%; margin: 2px 0 6px; padding: 6px 9px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: .9rem;
}
.cp-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; outline: 0; }
.cp-group { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 8px 2px; }
.cp-option {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px calc(8px + var(--depth, 0) * 16px);
  border-radius: 7px; cursor: pointer; font-size: .92rem;
}
.cp-option:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.cp-option.is-active { background: var(--primary); color: var(--primary-contrast); }
.cp-option.is-active .proj-icon, .cp-option.is-active .area-icon, .cp-option.is-active .status-icon { color: inherit; }
.cp-label { flex: 1; min-width: 0; display: inline-flex; align-items: center; gap: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-label .proj-icon, .cp-label .area-icon { width: 15px; height: 15px; flex: none; }
.cp-label .list-icon { width: 15px; height: 15px; }
.cp-check { width: 16px; height: 16px; flex: none; border: 1.5px solid currentColor; border-radius: 4px; display: inline-grid; place-items: center; font-size: .72rem; font-weight: 700; opacity: .8; }
.cp-current { font-weight: 700; }
.cp-create { color: var(--primary); font-weight: 600; }
.cp-create.is-active { color: var(--primary-contrast); }
.cp-empty { padding: 8px; font-size: .85rem; list-style: none; }
.cp-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.status-icon { display: inline-grid; place-items: center; width: 16px; font-weight: 700; color: var(--muted); }
.status-icon.status-in_progress { color: var(--warn); }
.status-icon.status-done { color: var(--ok); }
.avatar-none { background: none !important; border: 1.5px dashed var(--muted); color: var(--muted); }
.avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; display: inline-flex; border-radius: 999px; }
.avatar-btn:hover .avatar { outline: 2px solid var(--primary); outline-offset: 1px; }
summary[data-choice-picker] { cursor: pointer; }

/* ---------- Quick find ---------- */
.quick-find {
  width: min(640px, calc(100vw - 32px)); max-height: min(70vh, 600px); margin: 10vh auto auto;
  padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.quick-find[open] { display: flex; flex-direction: column; }
.quick-find::backdrop { background: rgba(0, 0, 0, .35); }
.quick-find form { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.quick-find form .list-icon { color: var(--muted); }
.quick-find input {
  flex: 1; border: 0; background: none; color: var(--text); font: inherit; font-size: 1.15rem; outline: 0; min-width: 0;
}
.qf-results { overflow-y: auto; padding: 0 10px; }
.qf-results:empty { display: none; }
.qf-results .group-head:first-child { margin-top: 10px; }
.qf-results .empty { padding: 8px 6px; }
.qf-hint { margin: 0; padding: 8px 16px; border-top: 1px solid var(--border); }
.side-search .list-icon { color: var(--muted); }
.list-icon-search, .list-icon-tags { color: var(--muted); }
.search-form input[type=search] { flex: 1; }

/* ---------- Board (Kanban) ---------- */
/* Todos card head: title on the left, then sort / layout switches and the add button on the right. */
.card-head:has(.sort-switch, .layout-switch) { flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
.card-head h2 + .sort-switch, .card-head h2 + .layout-switch { margin-left: auto; }
.page-head .sort-switch { margin-left: auto; align-self: center; }
[data-sortable] > [data-item] { cursor: grab; }
[data-sortable] > [data-item].is-dragging { opacity: .4; }
.board { display: grid; grid-template-columns: repeat(var(--board-cols, 3), minmax(0, 1fr)); gap: 12px; align-items: start; }
.board.board-assignee { grid-template-columns: repeat(var(--board-cols, 3), minmax(200px, 1fr)); overflow-x: auto; padding-bottom: 6px; }
.board-mode-switch { margin: 0 0 10px; }
.board-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-head .list-icon { width: 15px; height: 15px; }
.board-overdue-icon { color: var(--danger); font-weight: 700; }
.board-col[data-no-drop].is-drop-target { border-color: transparent; }
@container main (max-width: 720px) {
  .board { grid-template-columns: 1fr; }
}
.board-col {
  background: color-mix(in srgb, var(--text) 4%, transparent); border-radius: var(--radius);
  padding: 8px; min-height: 120px; border: 2px dashed transparent; transition: border-color .1s;
}
.board-col.is-drop-target { border-color: var(--primary); }
.board-head { display: flex; align-items: center; gap: 6px; margin: 2px 4px 8px; font-size: .82rem; }
.board-head .muted { margin-left: auto; font-weight: 600; }
.board-list { display: flex; flex-direction: column; gap: 6px; min-height: 40px; }
.board-list .todo-item.board-card {
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  flex-wrap: wrap; align-items: flex-start; padding: 8px; cursor: grab;
}
.board-list .todo-item.board-card .todo-item-main { font-size: .95rem; }
.board-list .todo-item.board-card .todo-item-meta { flex-basis: 100%; justify-content: flex-end; }
.board-card.is-dragging { opacity: .45; }
.board-add { display: block; padding: 6px 8px; font-size: .88rem; color: var(--muted); }
.board-more { margin: 6px 4px 0; }
.btn.is-on { border-color: var(--primary); color: var(--primary); }
/* The board needs the full width: the People box moves below it. */
.detail-grid.detail-grid-board { grid-template-columns: minmax(0, 1fr); }
.board-card .badge-in_progress { display: none; }
.board-list .todo-item.board-card .todo-item-main { flex: 1 1 8rem; }
.tag-node-actions label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.form-picker { cursor: pointer; font-family: inherit; justify-self: start; align-self: start; padding: 4px 12px; font-size: .92rem; }
.field .form-picker { margin-top: 2px; }

/* ---------- Placeholder people (no account) ---------- */
.avatar.avatar-placeholder { background: none; border: 1.5px dashed var(--muted); color: var(--muted); }
.badge-placeholder { border: 1px dashed var(--muted); background: none; color: var(--muted); }
.placeholder-add { margin: 4px 0 20px; }
.placeholder-add > summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.placeholder-add[open] > summary { margin-bottom: 6px; }

/* ---------- Someday ---------- */
.chip-someday { color: var(--c-someday); border-color: color-mix(in srgb, var(--c-someday) 45%, transparent); }
.chip .list-icon-someday, .chip-someday .list-icon { width: 14px; height: 14px; }
button.someday-chip { color: var(--c-someday); }
.dp-someday { color: var(--c-someday); }
.dp-anytime { color: var(--c-anytime); margin-top: 6px; }
.dp-someday-icon { width: 15px; height: 15px; vertical-align: -2px; }
.dp-option.is-current { box-shadow: inset 0 0 0 2px var(--primary); }
.area-someday { margin-top: 14px; }

/* Sidebar: areas can be dragged into your own order. */
.side-area-block.is-dragging { opacity: .4; }
.side-area-block > .side-area { cursor: grab; }

.comment-icon { width: 15px; height: 15px; flex: none; vertical-align: -3px; }
.comment-count { display: inline-flex; align-items: center; gap: 3px; }
.btn .comment-icon { width: 16px; height: 16px; margin-right: 2px; }

.tag-more { position: relative; }
.tag-more > summary { list-style: none; cursor: pointer; }
.tag-more > summary::-webkit-details-marker { display: none; }
.tag-more-list {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 200px; max-height: 320px; overflow-y: auto;
  display: flex; flex-direction: column; padding: 6px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
}
.tag-more-item { display: flex; justify-content: space-between; gap: 12px; padding: 5px 8px; border-radius: 6px; color: var(--text); font-size: .88rem; }
.tag-more-item:hover { background: color-mix(in srgb, var(--text) 8%, transparent); text-decoration: none; }

/* ---------- Read-only (someone else's project) ---------- */
.lock-icon { width: 13px; height: 13px; flex: none; vertical-align: -2px; }
.chip-readonly { border-style: dashed; color: var(--muted); cursor: default; }
.chip-readonly .lock-icon { opacity: .75; }
.readonly-note {
  /* A plain block (not flex), so the text and the bold name flow as one paragraph. */
  display: block; margin: 10px 0 0; padding: 8px 12px; max-width: 70ch;
  border-radius: 8px; background: color-mix(in srgb, var(--muted) 12%, transparent); color: var(--muted); font-size: .88rem;
}
.readonly-note .lock-icon { margin-right: 6px; }
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: min(480px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--surface); font-size: .9rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  display: flex; align-items: center; gap: 8px;
}

/* Sidebar: collapsible areas. The chevron sits at the right of the area row. */
.side-area-block { position: relative; }
.side-collapse {
  position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; opacity: .55;
}
.side-collapse:hover, .side-collapse:focus-visible { opacity: 1; background: color-mix(in srgb, var(--text) 8%, transparent); }
.side-collapse svg { width: 16px; height: 16px; transition: transform .15s; }
.side-area-block.is-collapsed .side-collapse svg { transform: rotate(-90deg); }
.side-area-block.is-collapsed .side-area-projects { display: none; }
.side-area-block .side-area { padding-right: 30px; }
.side-collapsed-count { display: none; margin-left: auto; font-size: .75rem; font-weight: 600; color: var(--muted); }
.side-area-block.is-collapsed .side-collapsed-count { display: inline; }

/* Sent in the background, waiting for the server (live.js). */
[data-item].is-pending { opacity: .7; transition: opacity .2s; }
.toast[data-level="error"] { background: var(--danger); color: #fff; }

/* ---------- People (admins) ---------- */
.people-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 12px; }
.people-search { margin-left: auto; }
.people-search input { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; min-width: 14rem; }
.table-wrap { overflow-x: auto; }
.people-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.people-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.people-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.people-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.people-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.badge-admin { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); }
.list-icon-people { color: var(--muted); }

/* ---------- People box (project / area pages) ---------- */
.people-box .people li { display: flex; align-items: center; gap: 8px; }
.people-box .people-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-remove { margin-left: 2px; }
.icon-btn {
  border: 0; background: none; color: var(--muted); cursor: pointer; width: 24px; height: 24px; border-radius: 6px;
  display: inline-grid; place-items: center; font-size: .8rem;
}
.icon-btn:hover, .icon-btn:focus-visible { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.people-add { margin-top: 12px; display: grid; gap: 4px; }
.people-add-row { display: flex; gap: 6px; }
.people-add-row input { flex: 1; min-width: 0; padding: 5px 9px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: .9rem; }
.people-box .placeholder-add { margin: 8px 0 0; }
.people-box .placeholder-add > summary { font-weight: 600; }
.people-hint { margin: 10px 0 0; }
