:root {
    --border: #ddd;
    --muted: #666;
    --accent: #2d5be3;
    --danger: #b00020;
}
body { font-family: system-ui, sans-serif; margin: 0; color: #222; background: #f6f6f4; }
/* non-production systems (p3-214) */
.dev-banner { background: #c8102e; color: #fff; text-align: center; font-weight: 700; font-size: .85rem; letter-spacing: .05em; padding: .3rem 1rem; }

/* header */
body > header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; padding: .75rem 1rem; background: #fff; border-bottom: 1px solid var(--border); }
.main-nav { display: flex; gap: 1.25rem; align-items: center; }
.main-nav a { color: inherit; text-decoration: none; }
.main-nav a.brand { font-weight: 700; }
.main-nav a[aria-current=page] { color: var(--accent); font-weight: 600; }
/* on narrow screens the user menu wraps onto its own line, right-aligned */
.user-menu { display: flex; align-items: center; gap: .75rem; min-width: 0; margin-left: auto; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; }
.user-menu form { display: inline; }
.user-menu a.user-name { color: inherit; text-decoration: none; }
.user-menu a.user-name:hover, .user-menu a.user-name[aria-current=page] { text-decoration: underline; }
.account-section { margin-top: 1.5rem; }
.account-section h2 { font-size: 1.1rem; }

main { max-width: 60rem; margin: 2rem auto; padding: 0 1rem; }
/* pages using the whole width (dashboard, p3-302) */
main.is-wide { max-width: none; padding: 0 1.5rem; }
@media (max-width: 40rem) { main.is-wide { padding: 0 1rem; } }
h1 { margin-top: 0; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 1.5rem; }
.hint { color: var(--muted); }

/* forms and buttons */
label { display: block; margin-bottom: .25rem; }
input[type=email], input[type=password], input[type=text], input[type=search], input[type=date] { display: block; width: 100%; box-sizing: border-box; padding: .5rem; margin: .25rem 0 1rem; border: 1px solid #bbb; border-radius: 4px; font: inherit; }
button, .button { display: inline-block; white-space: nowrap; padding: .4rem .9rem; font: inherit; font-size: .95rem; line-height: 1.4; border: 1px solid #bbb; border-radius: 4px; background: #fff; color: inherit; text-decoration: none; cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); border-color: #e4b3bb; }
.error, form ul li { color: var(--danger); }
form ul { padding-left: 1rem; margin: 0 0 .5rem; }

/* flash messages: floating toasts at the bottom (clear of breadcrumb and headers), out of the page flow */
.flashes { position: fixed; bottom: calc(3rem + env(safe-area-inset-bottom)); top: auto; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; width: min(32rem, calc(100vw - 2rem)); pointer-events: none; }
.flash { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem .6rem 1rem; border-radius: 6px; background: #e7f3ea; border: 1px solid #b9dcc2; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); pointer-events: auto; }
.flash-text { flex: 1; }
.flash-close { border: none; background: transparent; font-size: 1.2rem; line-height: 1; padding: 0 .25rem; color: inherit; opacity: .6; cursor: pointer; }
.flash-close:hover { opacity: 1; }
.flash-error { background: #fbeaec; border-color: #e4b3bb; color: var(--danger); }
.flash:not(.flash-error) { animation: flash-out .4s ease-in 4s forwards; }
@keyframes flash-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .flash:not(.flash-error) { animation-duration: 0s; animation-delay: 6s; } }

.muted, .meta { color: var(--muted); }
.meta { font-size: .9rem; margin: 1rem 0 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
select { display: block; padding: .45rem; margin: .25rem 0 1rem; border: 1px solid #bbb; border-radius: 4px; font: inherit; background: #fff; min-width: 12rem; max-width: 100%; }

/* item history entries: compact muted lines between the notes of the item timeline (p3-260) */
.history-entry { display: flex; gap: .75rem; margin: 0 0 .75rem; padding: 0 0 0 .9rem; border-left: 2px solid var(--border); color: var(--muted); font-size: .9rem; }
.history-entry .history-user { color: #222; }
.history-time { color: var(--muted); font-size: .9rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.history-user { font-weight: 600; }
.history-entry q { quotes: "“" "”"; }


/* settings area */
.settings { display: grid; grid-template-columns: 12rem 1fr; gap: 2rem; align-items: start; }
.settings-nav h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: .4rem 0 .5rem; }
.settings-nav ul { list-style: none; padding: 0; margin: 0; }
.settings-nav a { display: block; padding: .4rem .6rem; border-radius: 4px; color: inherit; text-decoration: none; }
.settings-nav a:hover { background: #ececea; }
.settings-nav a[aria-current=page] { background: #fff; border: 1px solid var(--border); font-weight: 600; }
/* the actions wrap below the heading when there's no room for both (long titles, phones) */
.page-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; }
.page-header h1 { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 40rem) { .settings { grid-template-columns: 1fr; } }

/* badges */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: #eef2fd; border: 1px solid #cdd8f8; font-size: .85rem; white-space: nowrap; }
.badge-default { background: #fff4d6; border-color: #f0d68a; }
/* Agent accounts (p3-359): a small tag after the name in chips, pickers and notes. */
.agent-badge { display: inline-block; padding: 0 .3rem; border-radius: 4px; background: #ece8fb; color: #5a4a9c; font-size: .7rem; font-weight: 600; line-height: 1.4; text-transform: uppercase; letter-spacing: .03em; vertical-align: .1em; }
.status-badge { background: var(--status-color); color: var(--status-text); border-color: color-mix(in srgb, var(--status-color), #000 15%); }
/* Text colour from the badge colour itself: white below OKLCH lightness 0.7, else black (keep in sync with Status::WHITE_TEXT_BELOW_LIGHTNESS). Browsers without relative colour syntax keep the server-computed --status-text above. */
@supports (color: oklch(from red l c h)) {
    .status-badge { color: oklch(from var(--status-color) clamp(0, (0.7 - l) * 1000, 1) 0 0); }
}

/* form bits */
input[type=color] { display: block; width: 4rem; height: 2.25rem; padding: .15rem; margin: .25rem 0 .25rem; border: 1px solid #bbb; border-radius: 4px; background: #fff; }
.help-text, form .help-text { color: var(--muted); font-size: .85rem; margin: 0 0 1rem; }

/* form action row: Save / Cancel … Delete */
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; }
.form-actions .push-right { margin-left: auto; }

/*
 * Lists (items tree, statuses): no box, slim rows on the page background,
 * a row lights up on hover. Nesting is shown by indentation plus a thin guide.
 */
.sortable-list, .tree { list-style: none; margin: 0; padding: 0; }
.sortable-list, .item-tree { margin: 1rem 0; border-top: 1px solid var(--border); }
.tree .tree { margin-left: .55rem; padding-left: 1.1rem; border-left: 1px solid var(--border); }
/* Empty child lists (leaves) open up as drop zones while an item is dragged (sortable_controller.js),
   without moving anything (p3-149): the zone overlays the empty bottom strip of its row instead of adding height. */
.is-dragging-items .tree .tree:not(:has(> *)) { min-height: .6rem; margin-top: -.6rem; position: relative; z-index: 1; border-left-style: dashed; }
.row { position: relative; display: flex; align-items: center; gap: .6rem; min-height: 2.25rem; padding: 0 .5rem; border-bottom: 1px solid #e9e9e5; }
.row:hover, .row:focus-within { background: #fff; }
/* item rows (and status rows in Settings): light tint of the status colour (--row-status set per row) */
.item-row { background: color-mix(in oklab, var(--row-status, transparent) 12%, transparent); }
.item-row:hover, .item-row:focus-within { background: color-mix(in oklab, var(--row-status, #fff) 22%, #fff); }
/* own row background (p3-217): text light on dark backgrounds, like badges (white below OKLCH L 0.7; --row-text is the server-computed fallback) */
.item-row.has-row-bg { background: var(--row-bg); color: var(--row-text); }
.item-row.has-row-bg:hover, .item-row.has-row-bg:focus-within { background: color-mix(in oklab, var(--row-bg), #fff 12%); }
@supports (color: oklch(from red l c h)) {
    .item-row.has-row-bg { color: oklch(from var(--row-bg) clamp(0.13, (0.7 - l) * 1000, 1) 0 0); }
}
.item-row.has-row-bg :is(.item-ref, .item-assignee, .item-notes, .item-subs, .item-repositories, .item-changed) { color: inherit; opacity: .75; }
.item-row.has-row-bg :is(.row-button, .drag-handle) { color: inherit; }
/* The title link fills the row's full height and free width, so the whole row line is clickable. */
.row .item-title { flex: 1; align-self: stretch; display: flex; align-items: center; min-height: 2.25rem; color: inherit; text-decoration: none; }
/* When the title gets narrower than ~14rem (phones, deep nesting), the row's
   controls (notes, assignee, status, +) wrap onto a second line, right-aligned. */
.item-row { flex-wrap: wrap; column-gap: .6rem; row-gap: 0; }
.row-controls { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.row-ref { display: none; }
.item-row .item-title { flex: 1 1 14rem; min-width: 0; }
.item-row .item-title-text { overflow-wrap: anywhere; }
/* titles wrapping onto several lines keep some space above and below (p3-302); one-line rows keep their height */
.row .item-title { box-sizing: border-box; padding-block: .3rem; }
.row .item-title:hover { text-decoration: underline; }
.row .item-name { text-decoration: none; }
.row form { margin: 0; }
.row-button { display: inline-flex; align-items: center; justify-content: center; min-width: 1.75rem; height: 1.6rem; padding: 0 .45rem; font-size: .85rem; line-height: 1; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 4px; text-decoration: none; cursor: pointer; }
.row-button:hover, .row-button:focus-visible { color: inherit; border-color: #bbb; background: #fff; }
/* secondary row actions only appear on hover / keyboard focus */
.row .row-button, .row .row-reveal { opacity: 0; }
.row:hover .row-button, .row:hover .row-reveal, .row:focus-within .row-button, .row:focus-within .row-reveal { opacity: 1; }
.drag-handle { display: none; cursor: grab; color: #aaa; user-select: none; }
.is-sortable .drag-handle { display: inline; }
.sortable-ghost > .row, .sortable-ghost.row { background: #eef2fd; }
[aria-busy=true] { opacity: .7; }
@media (hover: none) { .row .row-button, .row .row-reveal { opacity: 1; } }

/* inline pickers in lists (status, assignee) */
.inline-trigger { position: relative; text-decoration: none; color: inherit; cursor: pointer; border-radius: 999px; }
.inline-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.assignee-picker, .owner-picker { padding: .1rem .35rem; border-radius: 4px; }
.assignee-picker:hover, .owner-picker:hover { background: #f2f2ef; }
/* the "Assign" placeholder only shows on hover / focus, like other row actions */
.row .assignee-picker.is-empty { opacity: 0; }
.row:hover .assignee-picker.is-empty, .row:focus-within .assignee-picker.is-empty { opacity: 1; }
.picker-menu { position: absolute; z-index: 50; top: calc(100% - .2rem); left: 0; display: flex; flex-direction: column; gap: .15rem; max-height: 18rem; overflow-y: auto; padding: .35rem; background: #fff; color: #222; font-weight: 400; text-align: left; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .14); }
.picker-option { display: block; text-align: left; border: 1px solid transparent; background: transparent; color: inherit; font: inherit; padding: .2rem .45rem; border-radius: 4px; cursor: pointer; white-space: nowrap; font-size: .9rem; }
.picker-option:hover, .picker-option:focus-visible { background: #f2f2ef; border-color: var(--border); outline: none; }
.picker-option[aria-checked=true] { background: #f2f2ef; font-weight: 600; }
.picker-option[hidden] { display: none; }
/* the current value when no option stands for it (due dates, p3-191) */
.picker-current { margin: 0 0 .15rem; padding: .2rem .45rem; font-size: .85rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); outline: none; }
.picker-divider { border: 0; border-top: 1px solid var(--border); margin: .2rem .1rem; }
.item-assignee { color: var(--muted); font-size: .85rem; white-space: nowrap; }
/* due dates (p3-191): a muted chip; due now orange, overdue red (done items never) */
.due-picker { padding: .1rem .3rem; border-radius: 4px; }
.due-picker:hover { background: #f2f2ef; }
.due-chip { display: inline-flex; align-items: center; gap: .25rem; font-size: .8rem; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.due-chip.is-due { color: #b45309; font-weight: 600; }
.due-chip.is-overdue { color: #fff; background: #c2410c; padding: 0 .4rem; border-radius: 999px; font-weight: 600; }
.row .due-picker.is-empty { opacity: 0; }
.row:hover .due-picker.is-empty, .row:focus-within .due-picker.is-empty { opacity: 1; }
@media (hover: none) { .row .due-picker.is-empty { display: none; } }
.item-row.has-row-bg .due-chip:not(.is-overdue) { color: inherit; opacity: .85; }
.due-row { margin-bottom: 1rem; }
.due-inputs { display: flex; gap: .5rem; align-items: center; }
.due-inputs input[type=text] { flex: 1; min-width: 0; margin: .25rem 0 0; }
.due-inputs .due-date-input { flex: none; width: auto; padding: .45rem; margin: .25rem 0 0; }
.due-preview { margin: .2rem 0 0; font-size: .85rem; min-height: 1.2em; }
.due-preview.is-error { color: var(--danger); }
@media (hover: none) { .row .assignee-picker.is-empty { opacity: 1; } }
.item-ref { color: var(--muted); font-size: .8em; font-weight: 400; font-variant-numeric: tabular-nums; margin-right: .5rem; user-select: all; white-space: nowrap; flex-shrink: 0; }
h1 .item-ref { margin-left: .35rem; }

/* notes (item edit page) */
.notes { margin-top: 2rem; }
.note { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: .6rem .9rem .8rem; margin-bottom: .75rem; }
.note-header { display: flex; align-items: center; gap: .6rem; font-size: .9rem; margin-bottom: .35rem; }
.note-header .note-edit { margin-left: auto; opacity: 1; }
.note-author { font-weight: 600; }
.note-body { overflow-wrap: anywhere; }
.note-description { border-left: 3px solid var(--accent); }
.note-documentation { border-left: 3px solid #22a06b; }
.note-type { font-size: .75rem; }
.note-new h3 { margin: 0 0 .75rem; font-size: 1rem; }
/* Hidden until "Add comment" / "c" opens it (p3-412, note_compose_controller.js). */
.note-new.is-collapsed { display: none; }
textarea { display: block; width: 100%; box-sizing: border-box; padding: .5rem; margin: .25rem 0 1rem; border: 1px solid #bbb; border-radius: 4px; font: inherit; resize: vertical; }

/* several short fields side by side; wraps on narrow screens */
.field-row { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.field-row > div { flex: 1 1 12rem; min-width: 0; }
.field-row select { width: 100%; min-width: 0; }

/* item page */
.breadcrumb { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .9rem; color: var(--muted); }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.page-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.item-self { margin-bottom: 0; }
.icon { display: block; }

/* updates page (global history) */
.updates-day h2 { font-size: 1rem; color: var(--muted); margin: 1.5rem 0 .5rem; }
.updates-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.update-entry { display: flex; gap: 1rem; padding: .5rem .5rem; border-bottom: 1px solid #e9e9e5; }
.update-time { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; min-width: 3rem; padding-top: .1rem; }
.update-body { flex: 1; min-width: 0; }
.update-item { color: inherit; font-weight: 600; text-decoration: none; }
.update-item:hover { text-decoration: underline; }
.update-path { font-size: .85rem; margin-left: .35rem; }
/* settings entries (p3-155): "Status"/"User" before the name */
.update-kind { font-size: .85rem; margin-right: .35rem; }
.update-text { font-size: .95rem; }
.update-text q { quotes: "“" "”"; }
/* the note's text under "added a comment"; long notes are cut after a few lines */
.update-note { margin: .35rem 0 .15rem; padding: .4rem .7rem; background: #fff; border-left: 3px solid var(--border); border-radius: 0 4px 4px 0; overflow-wrap: anywhere; font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
/* sub-item count (p3-282) looks like the note count */
.item-subs, .item-notes { display: inline-flex; align-items: center; gap: .2rem; color: var(--muted); font-size: .8rem; text-decoration: none; white-space: nowrap; }
/* Repositories on the item page (p3-360); inherited ones lighter. */
.item-repositories { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .2rem; color: var(--muted); font-size: .8rem; }
.item-repository { color: inherit; text-decoration: none; white-space: nowrap; }
a.item-repository:hover { text-decoration: underline; }
.item-repository.is-inherited { opacity: .7; }
/* Agent sessions on the item page and in rows (p3-363, p3-134): a dot for the state. */
.item-agent-session { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .8rem; }
.item-agent-session code { font-size: .75rem; }
.agent-session-state { width: .5rem; height: .5rem; border-radius: 50%; background: #9ca3af; }
.item-agent-session.is-running .agent-session-state { background: #22a06b; }
.item-agent-session.is-failed .agent-session-state { background: #ef4444; }
.item-notes:hover { color: inherit; }
/* last change (p3-154): muted, compact */
.item-changed { color: var(--muted); font-size: .8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge-done { background: #e7f3ea; border-color: #b9dcc2; }
.badge-grouping { background: #f1f1ee; border-color: #d9d9d4; }
.checkbox-row, form div:has(> input[type=checkbox]) { margin-bottom: 1rem; }
input[type=checkbox] { margin-right: .4rem; }
/* own changes on the Updates page: muted and compact */
.update-entry.is-mine { opacity: .55; padding-top: .25rem; padding-bottom: .25rem; font-size: .9rem; }
.update-entry.is-mine .update-item { font-weight: 400; }
.update-entry.is-mine .update-note { -webkit-line-clamp: 1; padding-top: .15rem; padding-bottom: .15rem; }
.update-entry.is-mine:hover { opacity: 1; }

/* done items greyed out; context rows (filtered lists: shown only for a match below) dimmed */
.tree-item.is-done > .row { opacity: .5; }
.tree-item.is-done > .row:hover { opacity: .8; }
.tree-item.is-context > .row { opacity: .55; }
.tree-item.is-context > .row:hover { opacity: .85; }

/* item filter (p3-202): a closed box, its summary line shows the current filter; saved filters menu (p3-203) before it */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .25rem .75rem; margin: 0 0 .75rem; }
.filter-bar > .item-filter { flex: 1 1 18rem; min-width: 0; }
.saved-filter-picker { display: flex; gap: .4rem; margin: 0; }
.saved-filter-picker button[hidden] { display: none; }
.saved-filter-picker select { margin: 0; min-width: 0; max-width: 14rem; padding: .2rem .4rem; font-size: .9rem; }
.item-filter { font-size: .9rem; }
.item-filter > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .5rem; cursor: pointer; color: var(--muted); padding: .2rem 0; }
.item-filter-label { font-weight: 600; }
.item-filter-summary { min-width: 0; overflow-wrap: anywhere; }
.item-filter-form { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem 1rem; padding: .75rem; margin: .25rem 0 0; border: 1px solid var(--border); border-radius: 6px; }
.filter-field label { font-size: .85rem; color: var(--muted); margin: 0 0 .2rem; }
.item-filter-form select, .item-filter-form input[type=search] { margin: 0; min-width: 0; max-width: 100%; padding: .35rem .45rem; font: inherit; font-size: .95rem; border: 1px solid #bbb; border-radius: 4px; box-sizing: border-box; }
.item-filter-form input[type=search] { width: 12rem; }
.item-filter-form input.filter-days { width: 6rem; margin: 0; padding: .35rem .45rem; font: inherit; font-size: .95rem; border: 1px solid #bbb; border-radius: 4px; box-sizing: border-box; }
.item-filter-form select#filter-root { max-width: 16rem; }
/* p3-191: due range */
.filter-dates { display: flex; align-items: center; gap: .35rem; }
.item-filter-form input[type=date] { width: auto; margin: 0; padding: .3rem .4rem; font-size: .95rem; }
.filter-check { display: inline-flex; align-items: center; margin: 0; padding-bottom: .35rem; cursor: pointer; }
.filter-actions { display: flex; gap: .5rem; }
.filter-empty { color: var(--muted); }
/* Filters page: title and summary, then the default controls (p3-204); wraps on narrow screens */
/* the title link fills the row's free space, so the whole row opens the edit page (p3-222) */
.saved-filter-list .row { flex-wrap: wrap; }
.saved-filter-text { flex: 1 1 14rem; align-self: stretch; min-width: 0; display: flex; flex-wrap: wrap; align-content: center; align-items: baseline; gap: 0 .6rem; padding: .3rem 0; color: inherit; text-decoration: none; }
.saved-filter-text:hover .item-title { text-decoration: underline; }
.saved-filter-text .item-title { flex: none; min-height: 0; align-self: auto; }
.saved-filter-list .saved-filter-summary { font-size: .85rem; overflow-wrap: anywhere; min-width: 0; }
.saved-filter-defaults { display: flex; flex-wrap: wrap; gap: .3rem; }
.badge-remove { border: none; background: transparent; padding: 0 0 0 .35rem; font-size: 1rem; line-height: 1; color: inherit; opacity: .6; cursor: pointer; }
.badge-remove:hover, .badge-remove:focus-visible { opacity: 1; }
@media (max-width: 40rem) {
    .filter-field, .item-filter-form input[type=search], .item-filter-form select, .item-filter-form select#filter-root { width: 100%; max-width: 100%; }
}
.note-link { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 2px; }
.note-link:hover { text-decoration-color: currentColor; }
.note:target { outline: 2px solid var(--accent); outline-offset: 2px; }

/* rendered Markdown (notes) */
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p, .markdown ul, .markdown ol, .markdown pre, .markdown blockquote, .markdown table { margin: 0 0 .6rem; }
.markdown ul, .markdown ol { padding-left: 1.4rem; }
.markdown li > p { margin: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { font-size: 1rem; margin: .8rem 0 .4rem; }
.markdown code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; background: #f2f2ef; padding: .05rem .3rem; border-radius: 3px; }
.markdown pre { background: #f6f6f3; border: 1px solid var(--border); border-radius: 4px; padding: .6rem .75rem; overflow-x: auto; }
.markdown pre code { background: none; padding: 0; }
.markdown blockquote { border-left: 3px solid var(--border); padding-left: .75rem; color: var(--muted); }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: .25rem .5rem; text-align: left; }
.markdown a { color: var(--accent); }
/* p3-123 references in Markdown (App\Markdown): status badge, plus the title when alone on a line */
.markdown a.item-ref-link { text-decoration: none; }
.item-ref-badge { padding: 0 .4rem; font-size: .8em; font-variant-numeric: tabular-nums; vertical-align: .05em; }
.item-ref-link:hover .item-ref-badge { filter: brightness(1.08); }
.item-ref-link:hover .item-ref-title { text-decoration: underline; }
.markdown li:has(> input[type=checkbox]) { list-style: none; margin-left: -1.2rem; }

/* Settings → Users */
.user-list .user-email, .user-list .user-login { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-list .user-login { flex-shrink: 0; }
.user-list .is-disabled .user-name-link { color: var(--muted); text-decoration: line-through; }
.badge-disabled { background: #fbeaec; border-color: #e4b3bb; color: var(--danger); }

/* Settings → Users → API tokens */
.tokens { margin-top: 2rem; }
.tokens h2 { font-size: 1.1rem; }
.token-list { margin-bottom: 1rem; }
.token-list .token-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.token-list .token-meta { font-size: .85rem; }
.danger-text { color: var(--danger); }
.token-secret { font-family: ui-monospace, monospace; }

/* filters (Updates) */
.updates-filter { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem 1rem; margin: 0 0 1rem; }
.updates-filter label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); margin: 0; }
.updates-filter input, .updates-filter select { margin: 0; min-width: 0; padding: .35rem .45rem; font-size: .95rem; color: #222; }
.updates-filter input[type=text] { display: inline-block; width: 8rem; }

/* paging (Updates) */
.pager { display: flex; gap: .5rem; margin: 1.5rem 0; }
.pager .push-right { margin-left: auto; }

/* phones */
@media (max-width: 40rem) {
    main { margin: 1rem auto; }
    h1 { font-size: 1.6rem; }
    /* one more link since p3-278 (Lists): tighter, and wraps rather than overflowing */
    .main-nav { gap: .3rem .8rem; flex-wrap: wrap; }
    .tree .tree { margin-left: .3rem; padding-left: .55rem; }
    /* Two lines per row: the title alone on the first; reference (left) and controls (right) on the second. */
    .item-row .item-title { flex-basis: 100%; max-width: 100%; min-height: 2rem; }
    .item-row .drag-handle + .item-title { max-width: calc(100% - 1.5rem); }
    .item-row .item-title .item-ref { display: none; }
    .item-row .row-controls { flex-basis: 100%; box-sizing: border-box; min-height: 1.9rem; flex-wrap: wrap; justify-content: flex-end; column-gap: .5rem; }
    .item-row .drag-handle ~ .row-controls { padding-left: 1.1rem; }
    .item-row .row-ref { display: inline; margin-right: auto; }
    .note-header { flex-wrap: wrap; row-gap: .2rem; }
    .user-list .row { flex-wrap: wrap; }
    .user-list .user-email { flex-basis: 100%; order: 3; }
    .token-list .row { flex-wrap: wrap; }
    .token-list .token-meta { flex-basis: 100%; order: 3; }
    .history-entry { flex-direction: column; gap: 0; }
    /* menus open leftwards from the trigger, so they stay on screen */
    .picker-menu { left: auto; right: 0; }
}

/* live updates (live_update_controller.js): changed or new parts light up briefly */
@keyframes live-flash { from { background-color: #fff3b0; } }
.live-flash { animation: live-flash 1.6s ease-out; }
@media (prefers-reduced-motion: reduce) { .live-flash { animation: none; } }

/* multiselect (multiselect_controller.js, e.g. a status's "Next statuses") */
select[multiple] { min-width: 14rem; }
select[hidden] { display: none; }
.multiselect { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; min-height: 2.4rem; box-sizing: border-box; padding: .35rem .45rem; margin: .25rem 0 1rem; border: 1px solid #bbb; border-radius: 4px; background: #fff; }
.multiselect:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.multiselect + .help-text { margin-top: -.75rem; }
.multiselect-chip { display: inline-flex; align-items: center; gap: .2rem; padding-right: .2rem; }
.multiselect-remove { padding: 0 .3rem; border: none; border-radius: 999px; background: transparent; color: inherit; font-size: 1rem; line-height: 1.1; opacity: .7; }
.multiselect-remove:hover, .multiselect-remove:focus-visible { opacity: 1; background: rgba(0, 0, 0, .12); outline: none; }
.multiselect-add { padding: .1rem .5rem; font-size: .85rem; color: var(--muted); border: 1px dashed #bbb; border-radius: 999px; background: transparent; }
.multiselect-add:hover, .multiselect-add:focus-visible, .multiselect-add[aria-expanded=true] { color: inherit; border-style: solid; background: #f2f2ef; outline: none; }
.multiselect-menu { top: 100%; margin-top: .2rem; }
.multiselect-menu .picker-option { padding: .25rem .4rem; }

/* Settings → Statuses rows: the link fills the row (whole row opens the edit page), "done" at its right end, then the default slot */
.row .status-title { flex: 1; align-self: stretch; display: flex; align-items: center; gap: .6rem; min-width: 0; min-height: 2.25rem; color: inherit; text-decoration: none; }
.status-title .badge-done { margin-left: auto; }
/* Next statuses in the list (p3-337): smaller badges after an arrow, wrapping on narrow screens. */
.status-next { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .25rem; min-width: 0; }
.status-next .status-badge { font-size: .72rem; padding: 0 .4rem; }
.status-next-arrow { color: var(--muted); font-size: .85rem; }
.status-default-slot { display: flex; justify-content: flex-end; min-width: 7rem; }
/* status form preview (p3-234): an example item row, framed like a list on the page background */
.status-preview { margin: 0 0 1rem; }
.status-preview-label { display: block; font-size: .85rem; color: var(--muted); margin: 0 0 .2rem; }
.status-preview .tree-item { background: #f6f6f4; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.status-preview .row { border-bottom: none; }
.identifier-row input { max-width: 20rem; }

/* new-item form in a dialog (item_dialog_controller.js, p3-188) */
.item-dialog { width: min(40rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); box-sizing: border-box; padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.item-dialog::backdrop { background: rgba(0, 0, 0, .25); }
.item-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.item-dialog-title { margin: 0; font-size: 1.2rem; }
.item-dialog-close { border: none; background: transparent; font-size: 1.4rem; line-height: 1; padding: 0 .25rem; color: var(--muted); cursor: pointer; }
.item-dialog-close:hover { color: inherit; }
.item-dialog form[aria-busy=true] { opacity: .6; pointer-events: none; }

/* dashboard on / (p3-199): widgets as cards, one column for now */
.dashboard { display: grid; gap: 1rem; align-items: start; }
.dashboard.layout-1 { grid-template-columns: minmax(0, 60rem); }
.dashboard.layout-1-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard.layout-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.dashboard.layout-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.dashboard.layout-1-1-1 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-column { display: flex; flex-direction: column; gap: 1rem; min-width: 0; min-height: 2rem; }
/* edit mode: empty columns stay visible as drop zones */
.dashboard.is-editing .dashboard-column { min-height: 6rem; border: 1px dashed var(--border); border-radius: 8px; padding: .25rem; }
.dashboard-columns { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: 0; font-size: .9rem; }
.dashboard-columns .button.is-current { border-color: var(--accent, #2d5be3); font-weight: 600; }
/* layout buttons (p3-281): a sketch of the columns */
.dashboard-columns .layout-button { display: inline-flex; gap: 3px; width: 3.6rem; height: 2rem; padding: .25rem; }
.layout-sketch-col { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; border-radius: 2px; background: #e4e5e8; color: var(--muted); font-size: .75rem; line-height: 1; }
.layout-button.is-current .layout-sketch-col { background: var(--accent, #2d5be3); color: #fff; }
/* phones (p3-244): the columns stack, first column first */
@media (max-width: 700px) { .dashboard:not(.layout-1) { grid-template-columns: minmax(0, 1fr); } }
.widget { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; min-width: 0; }
.widget-title { margin: 0 0 .5rem; font-size: 1.05rem; }
.widget-body > :first-child { margin-top: 0; }
.widget-body > :last-child { margin-bottom: 0; }
.widget .item-tree { margin: 0 -.5rem; }
.widget-more { margin: .5rem 0 0; font-size: .9rem; }
/* Count widget (p3-241): one big number, optionally in a status colour */
.widget-count { display: inline-flex; flex-direction: column; align-items: flex-start; gap: .1rem; padding: .4rem .9rem; border-radius: 8px; color: inherit; text-decoration: none; }
.widget-count.has-color { background: var(--status-color); color: var(--status-text); }
.widget-count:hover { filter: brightness(1.05); }
.widget-count-number { font-size: 2.2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.widget-count-label { font-size: .9rem; }
/* dashboard edit mode (p3-239) */
.dashboard-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 0 0 .75rem; }
.dashboard-toolbar > a.button { margin-left: auto; }
.dashboard-edit-link { margin: 1rem 0 0; text-align: center; }
.widget-edit-bar { display: flex; align-items: center; gap: .6rem; margin: -.25rem 0 .5rem; padding-bottom: .4rem; border-bottom: 1px dashed var(--border); font-size: .85rem; }
.widget-edit-bar .button { margin-left: auto; }
.dashboard.is-editing .drag-handle { display: inline; font-size: 1.1rem; }
.add-widget { position: relative; }
.add-widget > summary { list-style: none; }
.add-widget > summary::-webkit-details-marker { display: none; }
.add-widget-menu { position: absolute; left: 0; z-index: 20; min-width: 14rem; margin: .3rem 0 0; padding: .3rem 0; list-style: none; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.add-widget-menu a { display: block; padding: .35rem .8rem; color: inherit; text-decoration: none; }
.add-widget-menu a:hover, .add-widget-menu a:focus-visible { background: #f1f3f8; }
/* Recent updates, Item card, Status overview widgets (p3-248) */
.widget-updates { list-style: none; margin: 0; padding: 0; }
.widget-updates li { display: flex; gap: .75rem; padding: .3rem 0; border-bottom: 1px solid #f0f0ec; font-size: .9rem; }
.widget-updates .update-time { min-width: 2.5rem; }
.widget-update-body { min-width: 0; overflow-wrap: anywhere; }
.widget-update-body .update-item { margin-right: .35rem; }
.item-card-title { font-weight: 600; color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.item-card-title:hover { text-decoration: underline; }
.item-card-facts { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .75rem; margin: .4rem 0; font-size: .9rem; }
.item-card-progress { height: .5rem; background: #eceae4; border-radius: 999px; overflow: hidden; }
.item-card-progress-bar { height: 100%; background: #22a06b; }
.item-card-count { margin: .3rem 0 0; font-size: .85rem; }
.status-overview-bar { display: flex; height: .75rem; border-radius: 999px; overflow: hidden; margin: 0 0 .6rem; }
.status-overview-list { display: flex; flex-wrap: wrap; gap: .4rem .75rem; margin: 0; padding: 0; list-style: none; }
.status-overview-list a { display: inline-flex; align-items: center; gap: .3rem; color: inherit; text-decoration: none; }
.status-overview-count { font-variant-numeric: tabular-nums; font-weight: 600; }
/* Quick add widget (p3-249) */
.quick-add { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0; }
.quick-add input[type=text] { flex: 1 1 12rem; min-width: 0; margin: 0; }
.quick-add[aria-busy=true] { opacity: .6; pointer-events: none; }
.quick-add-more { font-size: .9rem; }
.quick-add-message { margin: .4rem 0 0; font-size: .85rem; min-height: 1.2em; }

/* item page header (p3-257): the item itself, tinted like its rows */
.item-header { display: block; margin: .25rem 0 1rem; padding: .6rem .9rem .7rem; border-radius: 8px; }
.item-header-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 1.6rem; }
.item-header .item-ref { font-size: .85rem; margin: 0; }
.item-header-title { margin: .1rem 0 .45rem; font-size: 1.6rem; line-height: 1.25; overflow-wrap: anywhere; }
/* positioned: the inline picker menus open right below their trigger (p3-257) */
.item-facts { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; font-size: .9rem; }
.item-header-dates { color: var(--muted); }
.item-header.has-row-bg .item-header-dates, .item-header.has-row-bg .item-ref { color: inherit; opacity: .75; }
.more-menu { position: relative; }
.more-menu > summary { list-style: none; opacity: 1; font-size: 1.1rem; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu-items { position: absolute; right: 0; z-index: 20; display: flex; flex-direction: column; min-width: 12rem; margin-top: .25rem; padding: .3rem 0; background: #fff; color: #222; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.more-menu-items > a, .more-menu-items > button { display: block; width: 100%; padding: .35rem .8rem; border: none; background: none; font: inherit; font-size: .9rem; text-align: left; color: inherit; text-decoration: none; cursor: pointer; }
.more-menu-items > :hover, .more-menu-items > :focus-visible { background: #f1f3f8; }
.more-menu-items > .danger { color: var(--danger); }
.sub-items-bar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .25rem .75rem; margin: 0 0 .5rem; }
.sub-items-bar > .filter-bar { flex: 1 1 18rem; margin: 0; }
.add-buttons { display: flex; flex-wrap: wrap; gap: .25rem .5rem; margin-left: auto; }
.add-buttons .button { white-space: nowrap; }
.page-end-bar { display: flex; margin: 1rem 0; }
/* inline title/identifier editing (p3-258) */
.item-header-title[data-controller~=inline-edit] { cursor: text; border-radius: 4px; }
.item-header-title[data-controller~=inline-edit]:hover, .item-header-title[data-controller~=inline-edit]:focus-visible { outline: 1px dashed currentColor; outline-offset: 2px; }
.item-ref-edit { display: inline-flex; align-items: center; gap: .15rem; }
.item-ref-pencil { opacity: 0; font-size: .85rem; min-width: 1.4rem; height: 1.4rem; }
.item-header:hover .item-ref-pencil, .item-ref-pencil:focus-visible { opacity: 1; }
@media (hover: none) { .item-ref-pencil { opacity: 1; } }
.inline-edit-input { width: 100%; box-sizing: border-box; margin: 0; padding: .15rem .35rem; font: inherit; color: #222; background: #fff; border: 1px solid #888; border-radius: 4px; }
.item-ref-edit .inline-edit-input { width: 16rem; max-width: 60vw; font-size: .9rem; }
.inline-edit-error { display: block; font-size: .85rem; font-weight: 400; color: var(--danger); }
.inline-edit-error:empty { display: none; }
/* parent picker (p3-259): a searchable item menu */
.parent-picker { color: inherit; text-decoration: none; opacity: .85; max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parent-picker:hover { opacity: 1; text-decoration: underline; }
.parent-menu { width: min(26rem, calc(100vw - 2rem)); max-height: 22rem; overflow: hidden; }
.parent-menu-search { margin: 0 0 .3rem; padding: .3rem .45rem; font: inherit; font-size: .9rem; border: 1px solid #bbb; border-radius: 4px; }
.parent-menu-options { display: flex; flex-direction: column; overflow-y: auto; }
.parent-menu .picker-option { white-space: normal; overflow-wrap: anywhere; }
.parent-menu .picker-option.is-done { opacity: .55; }
.parent-menu .picker-option[aria-checked=true] { font-weight: 600; }
/* in a tinted header the menu keeps its own colours (p3-302) */
.parent-menu .item-ref, .item-row.has-row-bg .parent-menu .item-ref { color: var(--muted); opacity: 1; margin-right: .5rem; }
.parent-menu-empty { padding: .3rem .45rem; color: var(--muted); font-size: .9rem; }
/* keyboard: the current row (p3-262), ringed only while the keyboard is in use */
.keyboard-active :is(.item-row, [data-keyboard-row]).is-current { outline: 2px solid #2d5be3; outline-offset: -2px; border-radius: 3px; }
/* keyboard help (p3-263) */
.keyboard-help { width: min(28rem, calc(100vw - 2rem)); padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.keyboard-help::backdrop { background: rgba(0, 0, 0, .25); }
.keyboard-help-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.keyboard-help-header form { margin: 0; }
.keyboard-help-title { margin: 0; font-size: 1.2rem; }
.keyboard-help-close { border: none; background: transparent; font-size: 1.4rem; line-height: 1; padding: 0 .25rem; color: var(--muted); cursor: pointer; }
.keyboard-help-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.keyboard-help-table th { text-align: left; padding: .6rem 0 .2rem; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.keyboard-help-table td { padding: .2rem 0; vertical-align: top; }
.keyboard-help-table td:first-child { width: 8rem; white-space: nowrap; }
.keyboard-help-table a { color: inherit; }
kbd { display: inline-block; min-width: 1.2em; padding: 0 .35em; font: inherit; font-size: .85em; text-align: center; background: #f4f4f1; border: 1px solid #ccc; border-bottom-width: 2px; border-radius: 4px; }
.keyboard-help-note { margin: .75rem 0 0; font-size: .85rem; }
/* jump to item (p3-264) */
.jump-search { width: 100%; box-sizing: border-box; margin: 0 0 .5rem; padding: .4rem .55rem; font: inherit; border: 1px solid #bbb; border-radius: 4px; }
.jump-results { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.jump-results [role=option] { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .5rem; padding: .35rem .5rem; border-radius: 4px; cursor: pointer; overflow-wrap: anywhere; }
.jump-results [role=option][aria-selected=true], .jump-results [role=option]:hover { background: #eef2fd; }
.jump-results .is-done { opacity: .6; }
.jump-path { flex-basis: 100%; font-size: .8rem; }
.jump-path:empty { display: none; }
/* multi-select (p3-266): a toggle at the row's start, shown on hover, while selecting, and on touch screens */
.row-select { flex: none; width: 1rem; height: 1rem; margin: 0; padding: 0; border: 1.5px solid #999; border-radius: 3px; background: #fff; cursor: pointer; opacity: 0; }
.item-row:hover .row-select, .has-selection .row-select, .row-select:focus-visible { opacity: 1; }
@media (hover: none) { .row-select { opacity: 1; } }
.row-select[aria-pressed=true] { background: #2d5be3; border-color: #2d5be3; box-shadow: inset 0 0 0 2px #fff; }
.item-row.is-selected { background: color-mix(in oklab, #2d5be3 14%, #fff); }
.selection-bar { position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; max-width: calc(100vw - 2rem); padding: .5rem .75rem; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, .18); font-size: .9rem; }
.selection-bar .button kbd { margin-left: .3rem; font-size: .75em; }
.selection-bar[data-error=true] { border-color: var(--danger); }
.selection-menu { top: auto; bottom: calc(100% + .3rem); left: 0; }

/* item lists (p3-278) */
.item-list-link { flex: 1 1 14rem; align-self: stretch; min-width: 0; display: flex; flex-wrap: wrap; align-content: center; align-items: baseline; gap: 0 .6rem; padding: .3rem 0; color: inherit; text-decoration: none; }
.item-list-link:hover .item-title { text-decoration: underline; }
.item-list-link .item-title { flex: none; min-height: 0; align-self: auto; }
.list-entries { list-style: none; margin: 0; padding: 0; }
.list-entry { display: flex; align-items: center; gap: .4rem; margin-bottom: .35rem; }
.list-entry-body { flex: 1 1 auto; min-width: 0; }
.list-entry-body .tree { margin: 0; padding: 0; }
/* p3-295: the item's path, first line inside the row (on its background) */
.item-row .row-path { flex-basis: 100%; order: -1; padding: .3rem 0 0 1.6rem; margin-bottom: -.45rem; font-size: .75rem; line-height: 1.2; overflow-wrap: anywhere; }
.item-row .row-path a { color: inherit; }
.item-row.has-row-bg .row-path { color: inherit; opacity: .75; }
.list-entry:not(:hover):not(:focus-within) .list-entry-remove { opacity: 0; }
@media (hover: none) { .list-entry .list-entry-remove { opacity: 1; } }
.list-hidden-done { font-size: .85rem; }
.list-dialog-options [role=option]::before { content: ""; display: inline-block; width: 1.1rem; }
.list-dialog-options [role=option][aria-selected=true]::before { content: "✓"; color: var(--accent); font-weight: 600; }
.list-dialog-options [role=option][aria-selected=true], .list-dialog-options [role=option]:not(.is-active):not(:hover) { background: none; }
.list-dialog-options [role=option].is-active { background: #eef2fd; }
.list-dialog-options [role=option][hidden] { display: none; }
