:root {
    --border: #ddd;
    --muted: #666;
    --accent: #2d5be3;
    --danger: #b00020;
}
body { font-family: system-ui, sans-serif; margin: 0; color: #222; background: #f6f6f4; }

/* header */
body > header { display: flex; justify-content: space-between; align-items: center; 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; }
.user-menu form { display: inline; margin-left: .75rem; }

main { max-width: 60rem; margin: 2rem auto; 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] { 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; 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 top, out of the page flow */
.flashes { position: fixed; top: 4rem; 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; }

/* item history */
.history { margin-top: 2rem; }
.history h2 { font-size: 1.1rem; }
.history-list { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.history-entry { display: flex; gap: 1rem; padding: .4rem 0 .4rem 1rem; }
.history-time { color: var(--muted); font-size: .9rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.history-user { font-weight: 600; }
.history 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; }
.page-header { display: flex; justify-content: space-between; align-items: center; }
@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; }
.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; 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); }
.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: 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); }
/* 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; }
.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 { padding: .1rem .35rem; border-radius: 4px; }
.assignee-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; 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; 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; }
.item-assignee { color: var(--muted); font-size: .85rem; white-space: nowrap; }
@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; }
.notes h2 { font-size: 1.1rem; }
.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 { white-space: pre-wrap; 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; }
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; }
.item-self { margin-bottom: 0; }
.sub-items h2 { font-size: 1.1rem; margin: 1.75rem 0 .5rem; }
.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; }
.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; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.item-notes { display: inline-flex; align-items: center; gap: .2rem; color: var(--muted); font-size: .8rem; text-decoration: none; white-space: nowrap; }
.item-notes:hover { color: inherit; }
.badge-done { background: #e7f3ea; border-color: #b9dcc2; }
.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; }

/* list switches (pure CSS, see _list_filters): done items greyed out and hidden unless
   "Show done items" is checked; nested lists hidden when "Show sub-items" is unchecked */
.tree-item.is-done > .row { opacity: .5; }
.tree-item.is-done > .row:hover { opacity: .8; }
.list-filters:has(.show-done:not(:checked)) .done-hideable { display: none; }
.list-filters:has(.show-subitems:not(:checked)) .item-tree .tree .tree { display: none; }
.filter-toggles { display: flex; flex-wrap: wrap; gap: 1rem; }
.done-toggle { display: inline-flex; align-items: center; gap: .1rem; font-size: .9rem; color: var(--muted); cursor: pointer; margin: .25rem 0; }
.section-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.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; }
