/* ideal — themed after the Limbus Company menu: a dark wood-and-brass
   machine holding sheets of aged paper. Chrome (sidebar, title plates, the
   red button tray) is dark with brass outlines and an amber glow for what is
   selected; everything you read or edit sits on paper in dark ink.
   The mascot's sheet is multiplied onto the same paper. */

@font-face {
  font-family: "Saira Stencil One";
  src: url("saira-stencil-one.woff2") format("woff2");
  font-display: swap;
}

:root {
  /* machine */
  --machine: #140d0b;
  --wood: #2a1b14;
  --plate: #1d1410;       /* black label plates, table heads */
  --brass: #b9874c;
  --brass-hi: #e6b36a;
  --brass-dim: #6f5030;
  --tray: #561512;        /* the red button tray */
  --amber: #ffab3d;
  --cream: #eadfc6;

  /* paper */
  --bg: #ddd0b2;          /* the sheet; also used inside some icons */
  --paper-hi: #ece2c9;    /* fields */
  --paper-lo: #cdbf9e;    /* hover, group heads, side panel */
  --rule: #ab9c7c;
  --text: #2a1d15;
  --muted: #5e4e3e;
  --faint: #8b7b65;

  --link: #2a5d8c;
  --green: #2e7d32;
  --yellow: #a17208;
  --orange: #b85c12;
  --red: #a3221c;
  --purple: #6f3fa0;
  --gauge: #3aa648;

  --display: "Saira Stencil One", Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --glow: 0 0 10px rgb(255 171 61 / .55), inset 0 0 8px rgb(255 171 61 / .3);

  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans", sans-serif;
  font-size: 13px;
  line-height: 1.35;
  color-scheme: light;
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--brass-dim) transparent; }
body {
  margin: 0; color: var(--text);
  background: var(--machine) radial-gradient(ellipse 90% 70% at 50% 0, #2b1711, transparent 75%) fixed;
}
h1, h2, h3 { font-family: var(--display); font-weight: normal; letter-spacing: .02em; margin: 0; }
h1 { font-size: 18px; }
h2 { font-size: 16px; margin-bottom: 8px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
::selection { background: var(--amber); color: var(--plate); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.error { color: var(--red); margin: 0; font-weight: 600; }
.notice { color: var(--green); margin: 0; font-weight: 600; }
.icon { width: 16px; height: 16px; flex: none; display: block; }
code, pre { font-family: var(--mono); font-size: 12px; }

/* ---- controls ---- */
input, textarea {
  width: 100%; padding: 4px 8px; margin-top: 4px;
  background: var(--paper-hi); color: var(--text); font: inherit;
  border: 1px solid var(--faint); border-radius: 2px;
}
input { height: 28px; }
textarea { padding: 6px 8px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 2px rgb(255 171 61 / .55); }
input[type="date"] { width: auto; }
label { display: block; color: var(--muted); font-weight: 600; }

button.primary, button.ghost, a.ghost, button.link, .pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 28px; padding: 0 12px; border-radius: 3px; white-space: nowrap;
  background: none; color: var(--text); border: 1px solid var(--text);
}
:is(button.ghost, a.ghost, .pill):hover { background: var(--paper-lo); }
/* The "Confirm" button: a pale plate with a heavy ink outline. */
button.primary {
  min-width: 92px; min-height: 30px; padding: 0 18px;
  background: var(--paper-hi); border-width: 2px;
  font-family: var(--display); font-size: 14px; letter-spacing: .03em;
  box-shadow: 0 1px 0 var(--text);
}
button.primary:hover { background: var(--amber); }
:is(button.primary, button.ghost, a.ghost):active { translate: 0 1px; box-shadow: none; }
button.link { min-height: 24px; padding: 0 6px; border-color: transparent; color: var(--muted); text-decoration: underline; }

.card {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--bg); padding: 16px; border: 1px solid var(--rule);
}

/* ---- portrait ---- */
/* The art has a white background; multiplying it onto the paper colour turns
   it into a sepia print that belongs in the machine's window. */
.mascot { position: relative; margin: 0; background: #d9caa6; overflow: hidden; }
.mascot img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; object-position: 50% 50%; mix-blend-mode: multiply; }

/* ---- login ---- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-panel {
  display: grid; grid-template-columns: 250px 330px; overflow: hidden;
  border: 4px solid var(--wood); outline: 2px solid var(--brass-dim); border-radius: 12px;
  box-shadow: 0 30px 80px rgb(0 0 0 / .6);
}
.auth .mascot { min-height: 390px; border-right: 4px solid var(--wood); }
.auth .card { border: 0; padding: 28px 24px; justify-content: center; box-shadow: inset 0 0 60px rgb(80 45 20 / .25); }
.auth h1 { font-size: 34px; line-height: 1; }
.auth .muted { margin: 0 0 6px; }
.auth button.primary { align-self: flex-end; margin-top: 4px; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 10px; padding: 10px; height: 100vh; }
.sidebar {
  min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 8px;
  color: var(--cream); background: linear-gradient(#2f1e16, #1f140f);
  border: 2px solid var(--brass-dim); border-radius: 12px;
  box-shadow: inset 0 0 0 2px var(--machine), inset 0 0 30px rgb(0 0 0 / .5);
}
/* the level plate */
.team {
  display: flex; align-items: baseline; gap: 8px; padding: 8px 10px;
  background: var(--plate); border: 1px solid var(--brass-dim); border-radius: 6px;
  font-family: var(--display); font-size: 19px; letter-spacing: .03em; line-height: 1;
}
.team-key { font-size: 12px; color: var(--amber); }
.team-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the red tray of brass-rimmed buttons */
.sidebar nav {
  display: flex; flex-direction: column; gap: 5px; padding: 6px;
  background: linear-gradient(#63181400, #3a0d0b66), var(--tray);
  border: 2px solid var(--machine); border-radius: 8px; box-shadow: 0 0 0 1px var(--brass-dim);
}
.nav-item, .page-header .tab, .page-header :is(button.ghost, a.ghost) {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px;
  background: #22150f; color: #c99c64; border: 1px solid var(--brass-dim); border-radius: 5px;
  font-family: var(--display); font-size: 14px; letter-spacing: .03em; line-height: 1.1;
}
:is(.nav-item, .page-header .tab, .page-header :is(button.ghost, a.ghost)):hover { border-color: var(--brass-hi); color: var(--brass-hi); background: #22150f; }
.nav-item.active, .page-header .tab.active { color: var(--amber); border-color: var(--amber); background: #3b1e0c; box-shadow: var(--glow); }
.sidebar .mascot {
  margin-top: auto; height: 176px; flex: none;
  border: 3px solid var(--machine); border-radius: 8px; box-shadow: 0 0 0 2px var(--brass-dim);
}
.me {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 6px 5px 10px;
  background: var(--plate); border: 1px solid var(--brass-dim); border-radius: 6px;
}
.me button.link { color: var(--brass); }
.me button.link:hover { color: var(--amber); }

/* the window: a brass-rimmed frame around a sheet of paper */
.main {
  position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg); border: 4px solid var(--wood); outline: 2px solid var(--brass-dim); border-radius: 12px;
}
.main::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 5; border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--brass-dim), inset 0 0 70px rgb(80 45 20 / .22);
}
.page-header {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 46px; padding: 6px 14px; color: var(--cream);
  background: var(--plate); border-bottom: 2px solid var(--brass-dim);
}
.page-header .tab, .page-header :is(button.ghost, a.ghost) { min-height: 0; padding: 5px 10px; font-size: 13px; }
.toolbar { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 14px; background: var(--paper-lo); border-bottom: 1px solid var(--rule); }
.pill { min-height: 24px; padding: 0 10px; border-color: var(--faint); color: var(--muted); }
.pill.active, .pill.active:hover { background: var(--plate); border-color: var(--plate); color: var(--cream); }
.empty { padding: 24px 16px; color: var(--muted); margin: 0; }

/* ---- projects list ---- */
.ptable { flex: 1; min-height: 0; overflow: auto; }
/* The projects table is one grid; its rows are subgrids, so a column is as
   wide as its widest cell across the whole list;
   Milestone takes whatever room is left. */
.ptable.projects {
  display: grid; align-content: start;
  grid-template-columns: max-content minmax(0, 1fr) 112px 124px 68px 150px 52px;
}
.ptable.projects > .phead, .ptable.projects > #project-list, #project-list > .prow {
  grid-column: 1 / -1; display: grid; grid-template-columns: subgrid;
}
.ptable.projects > .empty { grid-column: 1 / -1; }
.prow {
  display: grid;
  align-items: center; height: 34px; padding: 0 8px; border-bottom: 1px solid var(--rule);
}
.prow > span { display: flex; align-items: center; gap: 6px; min-width: 0; height: 100%; padding: 0 6px; }
.phead {
  position: sticky; top: 0; z-index: 1; height: 28px; border-bottom: 0;
  background: #3a291e; color: var(--cream); font-family: var(--display); letter-spacing: .03em;
}
.prow:not(.phead):hover, .irow:hover, .milestones li:hover, .member-list li:hover, .file-list a:hover { background: var(--paper-lo); }
#project-list:not(:empty) + .empty, #pull-list:not(:empty) + .empty { display: none; }
#project-list > .prow { cursor: pointer; }

.c-name { overflow: hidden; }
.pname { white-space: nowrap; font-weight: 600; min-width: 0; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.pname:hover, .ititle:hover, .pr-title:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.prow:not(.phead) .c-milestone { color: var(--muted); white-space: nowrap; }
.c-milestone svg, .c-milestone .faint { flex: none; }
.c-milestone .mname { overflow: hidden; text-overflow: ellipsis; }
.milestone { color: var(--yellow); }
.health-on_track { color: var(--green); }
.health-at_risk { color: var(--orange); }
.health-off_track { color: var(--red); }
.health-none { color: var(--faint); }
.c-issues { justify-content: flex-end; font-variant-numeric: tabular-nums; }
.pct { font-variant-numeric: tabular-nums; min-width: 30px; }
.spark { width: 34px; height: 14px; color: var(--red); flex: none; }

.cell-btn {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; height: 24px;
  padding: 0 5px; border: 0; border-radius: 3px; background: none; white-space: nowrap;
}
.cell-btn span { overflow: hidden; text-overflow: ellipsis; }
.cell-btn:hover { background: var(--paper-hi); box-shadow: 0 0 0 1px var(--faint); }
.on-hover { visibility: hidden; color: var(--faint); }
:is(.prow, .irow):hover .on-hover { visibility: visible; }

.target-soon .icon { color: var(--orange); }
.target-overdue .icon, .target-overdue span { color: var(--red); }

/* icon colours */
.prio-none { color: var(--faint); }
.prio-urgent { color: var(--red); }
.prio-bars { color: var(--muted); }
.st-backlog { color: var(--orange); }
.st-planned { color: var(--muted); }
.st-progress { color: var(--yellow); }
.st-completed { color: var(--link); }
.st-canceled { color: var(--faint); }
.ist-backlog, .ist-todo { color: var(--muted); }
.ist-progress { color: var(--yellow); }
.ist-review { color: var(--green); }
.ist-done { color: var(--link); }
.ist-canceled { color: var(--faint); }
.avatar-none { color: var(--faint); }

.avatar {
  width: 18px; height: 18px; flex: none; display: inline-grid; place-items: center;
  font-size: 9px; font-weight: 700; color: #fff; border-radius: 3px; box-shadow: 0 0 0 1px var(--text);
}

/* ---- project emblems: a sinner's glyph on a plate of the project's color,
   and the popover that picks both (views/project_icon.templ) ---- */
/* the plate's rim: ink on paper, brass on the dark chrome */
.picon-rim { fill: var(--picon-rim, var(--machine)); }
.page-header, .sidebar, .big-icon { --picon-rim: var(--brass); }
.picon-btn { display: inline-grid; place-items: center; flex: none; padding: 3px; margin: -3px; border: 0; border-radius: 3px; background: none; }
.picon-btn:hover { background: var(--paper-hi); box-shadow: 0 0 0 1px var(--faint); }
:is(.page-header, .big-icon) .picon-btn:hover { background: #3b1e0c; box-shadow: 0 0 0 1px var(--amber); }
.crumb-icon { display: inline-flex; flex: none; }
.crumb-icon .icon { width: 18px; height: 18px; }
.big-icon .picon-btn { padding: 5px; margin: 0; }
[popover].picker {
  min-width: 0; padding: 8px 10px 10px; --picon-rim: var(--machine);
  font: 13px/1.35 ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans", sans-serif; letter-spacing: 0;
}
.picker-title { margin-bottom: 6px; padding-bottom: 2px; border-bottom: 2px solid var(--text); font-family: var(--display); font-size: 14px; letter-spacing: .03em; }
.picker-grid + .picker-title { margin-top: 10px; }
.picker-grid { display: grid; grid-template-columns: repeat(6, 40px); gap: 4px; }
.picker .picker-cell { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; background: var(--paper-lo); box-shadow: none; }
.picker .picker-cell .icon { width: 28px; height: 28px; }
.picker .picker-cell.active { background: var(--bg); box-shadow: inset 0 0 0 2px var(--text); }
/* the chosen one sits in a lit socket, like the selected nav button */
.picker .picker-cell[data-checked] { background: var(--plate); box-shadow: inset 0 0 0 2px var(--amber), var(--glow); --picon-rim: var(--brass); }
.picker .picker-cell[data-color] .icon { width: 24px; height: 24px; }

/* ---- popup menus: a small sheet in a brass rim ---- */
[popover].menu, [popover].dialog {
  background: var(--paper-hi); color: var(--text);
  border: 3px solid var(--wood); border-radius: 8px;
  box-shadow: 0 0 0 2px var(--brass-dim), 0 16px 40px rgb(0 0 0 / .6);
}
[popover].menu { position: fixed; inset: auto; margin: 0; min-width: 220px; padding: 4px; }
.menu:focus { outline: none; }
.menu-search { display: flex; align-items: center; gap: 6px; padding: 2px 2px 6px; }
.menu-search input { margin: 0; background: var(--bg); }
.kbd-hint { display: flex; align-items: center; gap: 3px; color: var(--faint); font-size: 11px; white-space: nowrap; }
kbd {
  display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 3px;
  font: inherit; font-size: 10px; color: var(--muted); border: 1px solid var(--faint); border-radius: 2px;
}
.menu-items { max-height: 320px; overflow-y: auto; border-top: 1px solid var(--rule); padding-top: 4px; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 28px;
  padding: 0 8px; border: 0; border-radius: 3px; background: none; text-align: left;
}
.menu-item.active { background: var(--paper-lo); box-shadow: inset 3px 0 var(--red); }
.menu-label { flex: 1; }
.menu-item .shortcut { width: 12px; text-align: right; color: var(--faint); }

/* ---- date picker ---- */
.datepicker { width: 300px; }
.dp-top { padding: 6px 6px 8px; }
.dp-title { font-family: var(--display); font-size: 15px; margin-bottom: 4px; }
.dp-input { position: relative; }
.dp-input input { margin: 0; padding-right: 28px; background: var(--bg); }
.dp-input input.invalid { color: var(--red); }
.dp-clear {
  position: absolute; right: 4px; top: 4px; width: 20px; height: 20px; padding: 0;
  border: 0; background: none; color: var(--faint); font-size: 13px; line-height: 1;
}
.dp-clear:hover { color: var(--red); }
.dp-tabs { display: flex; gap: 3px; margin-top: 8px; }
.dp-tabs button {
  flex: 1 1 auto; height: 24px; padding: 0 4px; white-space: nowrap;
  background: none; border: 1px solid var(--faint); border-radius: 3px; color: var(--muted);
}
.dp-tabs button.on { background: var(--plate); border-color: var(--plate); color: var(--cream); }
.dp-body { margin: 0 6px 6px; padding: 4px; background: var(--bg); border: 1px solid var(--rule); }
.dp-nav { display: flex; align-items: center; gap: 2px; padding: 2px 2px 6px; }
.dp-nav span { flex: 1; font-weight: 700; }
.dp-nav button { width: 22px; height: 20px; padding: 0; border: 0; border-radius: 3px; background: none; line-height: 1; }
.dp-nav button:hover { background: var(--paper-lo); }
.dp-grid { display: grid; gap: 2px; }
.dp-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.dp-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.dp-grid.cols-7 { grid-template-columns: repeat(7, 1fr); gap: 0; }
.dp-grid button { height: 28px; border: 0; border-radius: 3px; background: var(--paper-lo); }
.dp-grid button:hover { background: var(--paper-hi); box-shadow: 0 0 0 1px var(--text); }
.dp-grid button.sel, .dp-grid.cols-7 button.sel { background: var(--plate); color: var(--amber); font-weight: 700; }
.dp-dow { display: grid; place-items: center; height: 20px; color: var(--faint); font-size: 11px; font-weight: 700; }
.dp-grid.cols-7 button { height: 26px; background: none; }
.dp-grid.cols-7 .wknd { color: var(--red); }
.dp-grid.cols-7 .out { color: var(--faint); }
.dp-grid.cols-7 button.today { box-shadow: inset 0 0 0 2px var(--red); }

/* ---- dialog ---- */
[popover].dialog { width: min(440px, calc(100vw - 32px)); padding: 18px 20px 16px; margin: 15vh auto auto; }
[popover].dialog::before { content: "New project"; display: block; margin-bottom: 12px; font-family: var(--display); font-size: 20px; letter-spacing: .02em; }
[popover].dialog::backdrop { background: rgb(10 5 3 / .6); }
.title-input { margin: 0 0 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---- project page ---- */
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-family: var(--display); font-size: 17px; letter-spacing: .02em; }
.crumbs a { color: var(--brass); }
.crumbs a:hover { color: var(--amber); }
.crumbs .faint { color: var(--brass-dim); }
.crumbs > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 5px; }
.tab .count { color: inherit; opacity: .7; font-family: inherit; }

.project-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 264px; }
.project-main { overflow-y: auto; min-height: 0; }
.overview { max-width: 780px; padding: 20px 24px 48px; }
.big-icon { width: 46px; height: 46px; display: grid; place-items: center; background: var(--plate); border: 1px solid var(--brass-dim); border-radius: 6px; box-shadow: 0 0 0 2px var(--plate); }
.big-icon .icon { width: 30px; height: 30px; }
.project-title {
  margin: 12px 0 0; padding: 2px 0; height: 40px; background: none; border-color: transparent; border-radius: 0;
  font-family: var(--display); font-size: 28px; letter-spacing: .02em;
}
.project-title:hover { border-bottom-color: var(--rule); }
.project-title:focus { box-shadow: none; border-color: transparent; border-bottom-color: var(--text); }

.section { margin-top: 28px; }
.section-title, .section:has(> .desc-view, > .desc-editor)::before, .project-side h3 {
  display: block; margin: 0 0 10px; padding-bottom: 3px; border-bottom: 2px solid var(--text);
  font-family: var(--display); font-size: 15px; font-weight: normal; letter-spacing: .03em;
}
.section:has(> .desc-view, > .desc-editor)::before { content: "Description"; }
.desc-view { padding: 10px 12px; min-height: 52px; background: var(--paper-hi); border: 1px solid var(--rule); cursor: text; }
.desc-view:hover { border-color: var(--faint); }
.placeholder { color: var(--faint); margin: 0; }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.actions .hint { margin-right: auto; }

.markdown { line-height: 1.55; overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown a { color: var(--link); text-decoration: underline; }
.markdown h1, .markdown h2, .markdown h3 { font-size: 15px; margin: 1em 0 .4em; }
.markdown h1 { font-size: 18px; }
.markdown :not(pre) > code { padding: 1px 4px; background: var(--paper-lo); border-radius: 2px; }
.markdown pre, #tokens pre { padding: 8px 10px; overflow-x: auto; background: var(--plate); color: var(--cream); border-radius: 3px; }
.markdown blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--red); color: var(--muted); }
.markdown ul, .markdown ol { padding-left: 22px; }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 2px solid var(--plate); padding: 3px 10px; background: var(--paper-lo); }
.markdown th { background: #3a291e; color: var(--cream); font-family: var(--display); font-weight: normal; letter-spacing: .03em; }

.milestones { list-style: none; margin: 0 0 8px; padding: 0; }
.milestones li { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 6px; border-bottom: 1px solid var(--rule); }
.ms-progress { margin-left: auto; display: flex; align-items: center; gap: 8px; }
/* the green energy gauge */
.bar, .progress-bar { height: 12px; padding: 2px; background: var(--plate); border-radius: 3px; box-shadow: 0 0 0 1px var(--brass-dim); overflow: hidden; }
.bar { width: 64px; }
.bar > span, .progress-bar > span { display: block; height: 100%; border-radius: 1px; background: linear-gradient(#5fd06a, var(--gauge) 45%, #267a31); }
.icon-btn {
  width: 20px; height: 20px; padding: 0; border: 0; line-height: 1;
  background: none; color: var(--faint); visibility: hidden;
}
li:hover .icon-btn { visibility: visible; }
.icon-btn:hover { color: var(--red); }
.inline-add { display: flex; gap: 8px; align-items: center; }
.inline-add input { margin: 0; }
.inline-add input[name="name"], .inline-add input[name="pr"] { flex: 1; }

.update-composer { margin-bottom: 12px; }
.update-composer textarea { margin-top: 8px; }
.health-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.health-opt {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px solid var(--faint); border-radius: 3px; position: relative; cursor: pointer; font-weight: 600;
}
.health-opt input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.health-opt:has(input:checked) { background: var(--paper-hi); border-color: currentColor; box-shadow: 0 0 0 1px currentColor; }
.health-opt:has(input:focus-visible) { outline: 2px solid var(--amber); outline-offset: 1px; }
/* ---- manager memo (memo.templ): a typed sheet from the manager, with the
   project health rubber-stamped on it ---- */
.memo-composer { padding: 10px 12px; background: var(--paper-lo); border: 1px dashed var(--faint); }
.memo {
  position: relative; margin-top: 14px; background: var(--paper-hi);
  border: 1px solid var(--text); box-shadow: 4px 4px 0 rgb(42 29 21 / .2);
}
.memo-head {
  display: flex; align-items: baseline; justify-content: space-between; padding: 5px 14px 4px;
  background: #3a291e; color: var(--cream);
  font-family: var(--display); font-size: 16px; letter-spacing: .22em; text-transform: uppercase;
}
.memo-no { font-family: var(--mono); font-size: 11px; letter-spacing: .04em; color: var(--brass-hi); text-transform: none; }
.memo-fields {
  display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; row-gap: 4px;
  margin: 0 14px; padding: 10px 150px 9px 0; border-bottom: 2px solid var(--text);
}
.memo-fields dt { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.memo-fields dd { display: flex; align-items: center; gap: 6px; margin: 0; min-width: 0; font-weight: 600; }
.memo-fields dd .faint { font-weight: normal; }
.memo .markdown { padding: 10px 14px 14px; }
.memo-fields:last-child { border-bottom: 0; }
/* a rubber stamp: heavy outline in the ink of its health, set slightly askew */
.stamp {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 1px;
  border: 2px solid currentColor; border-radius: 3px; outline: 1px solid currentColor; outline-offset: 2px;
  font-family: var(--display); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  rotate: -4deg;
}
.memo-stamp { position: absolute; top: 42px; right: 18px; }

/* ---- milestones (milestone_page.templ): the Milestones tab and a
   milestone's own page ---- */
a.ms-name:hover, .ms-link:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.ms-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ms-done { color: var(--green); font-size: 11px; padding: 1px 6px 0; outline: 0; rotate: -3deg; }
/* Milestones tab: each milestone is a dark plate above its issues */
.ms-head {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; margin-top: 14px;
  background: #3a291e; color: var(--cream); border-block: 1px solid var(--brass-dim);
  font-family: var(--display); font-size: 15px; letter-spacing: .03em;
}
.ms-board > .ms-head:first-child { margin-top: 0; }
.ms-head .milestone { color: var(--amber); }
.ms-head .avatar-none { color: var(--brass); }
.ms-head .ms-link { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-head .ms-link:hover { color: var(--amber); }
.ms-head .ms-when { font-family: var(--mono); font-size: 11px; letter-spacing: 0; color: var(--brass-hi); white-space: nowrap; }
.ms-head .ms-num { font: 600 12px ui-sans-serif, system-ui, sans-serif; letter-spacing: 0; color: var(--brass-hi); }
.ms-head .ms-done { color: #7fd389; }
.ms-new { padding: 14px; margin-top: 14px; border-top: 2px solid var(--text); }
/* milestone page */
.ms-page-head { padding: 14px 24px; border-bottom: 2px solid var(--text); }
.ms-crumbs { display: flex; gap: 6px; margin-bottom: 6px; font-size: 12px; }
.ms-crumbs a, .ms-inline-link { color: var(--link); text-decoration: underline; }
.ms-title-row { display: flex; align-items: center; gap: 10px; }
.ms-title-row .icon { width: 24px; height: 24px; }
.ms-title-row .project-title { margin: 0; }
.ms-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin-top: 8px; }
.ms-meta label { display: flex; align-items: center; gap: 8px; }
.ms-meta input { margin: 0; }
.ms-meta .ms-progress { margin-left: 0; }
.ms-meta .bar { width: 180px; }
.ms-meta button.danger { margin-left: auto; color: var(--red); border-color: var(--red); }
.ms-meta button.danger:hover { background: var(--red); color: var(--paper-hi); }

.health-badge { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }

.project-side { overflow-y: auto; padding: 16px; border-left: 1px solid var(--rule); background: var(--paper-lo); }
.props { display: grid; grid-template-columns: 82px minmax(0, 1fr); align-items: center; row-gap: 4px; margin: 0 0 22px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; min-width: 0; }
.props .cell-btn { max-width: 100%; }
.side-health, .side-text { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 5px; }
.side-text { cursor: default; }
.project-side button.danger { color: var(--red); border-color: var(--red); }
.project-side button.danger:hover { background: var(--red); color: var(--paper-hi); }
.progress-bar { margin-bottom: 10px; }
.progress-stats { display: grid; gap: 4px; margin: 0; }
.progress-stats > div { display: flex; justify-content: space-between; }
.progress-stats dt { color: var(--muted); }
.progress-stats dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }

/* issues tab */
.project-issues { min-height: 100%; }
.quick-add { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-bottom: 1px solid var(--rule); color: var(--muted); }
.quick-add input { margin: 0; background: none; border-color: transparent; padding-left: 0; }
.quick-add input:focus { border-color: transparent; box-shadow: none; }
.group-head {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 14px;
  background: var(--paper-lo); border-bottom: 2px solid var(--text);
  font-family: var(--display); font-size: 14px; letter-spacing: .03em;
}
.group-head .faint { color: var(--muted); }
.irow {
  display: grid; grid-template-columns: 28px 64px 28px minmax(0, 1fr) auto 28px 56px;
  align-items: center; gap: 2px; height: 34px; padding: 0 10px; border-bottom: 1px solid var(--rule);
}
.irow > span { display: flex; align-items: center; min-width: 0; }
.itc { gap: 8px; }
.ititle { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iproj { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block !important; }
.issues-body { flex: 1; min-height: 0; overflow-y: auto; }
.issue-id { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 600; }
.chip span { max-width: 160px; }
.idate { justify-content: flex-end; font-size: 12px; }

/* ---- pull requests ---- */
.pr-open { color: var(--green); }
.pr-draft { color: var(--faint); }
.pr-merged { color: var(--purple); }
.pr-closed { color: var(--red); }

/* small tags: PR badge on issue rows, issue chips, role badges */
.pbadge, .chip-link, .badge {
  display: inline-flex; align-items: center; gap: 3px; flex: none; height: 18px; padding: 0 6px;
  border: 1px solid var(--faint); border-radius: 3px; background: var(--paper-hi); color: var(--muted);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.pbadge { padding-left: 3px; }
.pbadge .icon { width: 12px; height: 12px; }
:is(.pbadge, .chip-link):hover { border-color: var(--text); color: var(--text); }

/* linked pull requests on the issue page */
.pulls li { gap: 8px; }
.pr-ref { color: var(--muted); white-space: nowrap; }
.pr-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-when { white-space: nowrap; }
.pulls .icon-btn { visibility: visible; display: inline-grid; place-items: center; flex: none; }
.pulls a.icon-btn:hover { color: var(--text); }
.pulls .icon-btn .icon { width: 11px; height: 11px; }
.pr-none { margin: 0 0 8px; }
.pr-error { margin-top: 6px; }

/* ---- issue relations (blocked by / blocks): begin ---- */
.blocked-icon { color: var(--red); }
/* marker on issue rows */
.blocked-mark {
  display: inline-flex; align-items: center; gap: 4px; flex: none; height: 18px; padding: 0 6px 0 4px;
  background: var(--red); color: var(--cream); border-radius: 2px; cursor: help;
  font-family: var(--display); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
}
.blocked-mark .icon { width: 11px; height: 11px; color: inherit; }
/* stamp at the top of a blocked issue */
.blocked-plate {
  display: flex; align-items: center; gap: 12px; margin: 14px 0 0; padding: 6px 10px 6px 6px;
  border: 2px solid var(--red); border-radius: 3px; background: rgb(163 34 28 / .08);
}
.blocked-stamp {
  display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 3px 10px 3px 7px;
  background: var(--red); color: var(--cream); border-radius: 2px;
  font-family: var(--display); font-size: 15px; letter-spacing: .08em; text-transform: uppercase;
}
.blocked-stamp .icon { color: inherit; }
.blocked-by { font-weight: 600; }
.blocked-by a { color: var(--red); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.rel-second { margin-top: 18px; }
.rels .issue-id { white-space: nowrap; }
.rel-resolved :is(.issue-id, .pr-title) { color: var(--faint); text-decoration: line-through; }
.rel-add { flex-wrap: wrap; margin-top: 14px; }
.rel-add input[name="q"] { flex: 1; min-width: 0; }
.rel-add select {
  height: 28px; padding: 0 6px; background: var(--paper-hi); color: var(--text); font: inherit; font-weight: 600;
  border: 1px solid var(--faint); border-radius: 2px;
}
.rel-add select:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 2px rgb(255 171 61 / .55); }
.rel-results { flex-basis: 100%; }
.rel-results ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--text); background: var(--paper-hi); }
.rel-results li + li { border-top: 1px solid var(--rule); }
.rel-results button {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 30px; padding: 0 8px;
  border: 0; background: none; text-align: left;
}
.rel-results button:is(:hover, :focus-visible) { background: var(--paper-lo); }
.rel-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-empty { margin: 0; }
/* ---- issue relations: end ---- */

/* pull requests list: reuses the projects table */
.ptable.pulls .prow { grid-template-columns: 200px minmax(0, 1fr) 150px 110px 170px 56px; }
.trunc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-title { overflow: hidden; }
.c-links { gap: 4px; overflow: hidden; }
.prow:not(.phead) .c-branch { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.c-upd { justify-content: flex-end; }

/* pull request page */
.pr-page { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px 48px; }
.pr-title-row { display: flex; align-items: center; gap: 10px; }
.pr-h { margin: 0; font-size: 24px; overflow-wrap: anywhere; }
.pr-state {
  display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 2px 8px 2px 5px;
  background: var(--paper-hi); border: 2px solid currentColor; border-radius: 3px; font-weight: 700;
}
.pr-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; white-space: normal; }
.pr-meta code, .pr-issues { display: inline-flex; }
.pr-meta code { padding: 1px 5px; background: var(--paper-lo); border-radius: 2px; }
.pr-issues { align-items: center; flex-wrap: wrap; gap: 4px; margin: 8px 0 0; }
.pr-actions { justify-content: flex-start; margin: 12px 0 0; }
.pr-actions .icon { width: 12px; height: 12px; }
.msgbox { margin: 14px 0; padding: 12px 14px; background: var(--paper-hi); border: 2px solid var(--red); border-radius: 3px; }
.msgbox p { margin: 0; }
.msgbox .actions { justify-content: flex-start; }
.review .hint { margin: 6px 0 0; }
.review .error, .review .notice { margin-top: 6px; }

/* diff */
.diff-summary { display: flex; align-items: center; gap: 8px; margin: 22px 0 8px; font-weight: 700; }
.diff-summary a { margin-left: auto; font-weight: normal; color: var(--link); text-decoration: underline; }
.add { color: var(--green); }
.del { color: var(--red); }
.file-list { list-style: none; margin: 0 0 4px; padding: 0; max-height: 200px; overflow: auto; border: 1px solid var(--rule); background: var(--paper-hi); }
.file-list a { display: flex; align-items: center; gap: 8px; height: 26px; padding: 0 8px; }
.fpath { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12px; }
.fcount { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 700; }
.fstat {
  display: inline-grid; place-items: center; flex: none; width: 16px; height: 16px; border-radius: 2px;
  background: var(--yellow); color: var(--paper-hi); font-size: 10px; font-weight: 700;
}
.fs-added { background: var(--green); }
.fs-deleted { background: var(--red); }
.fs-renamed { background: var(--link); }
.dfile { margin-top: 12px; border: 2px solid var(--plate); border-radius: 3px; background: var(--paper-hi); }
.dfile > summary {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; list-style: none;
  background: #3a291e; color: var(--cream); cursor: pointer;
}
.dfile > summary :is(.add, .del) { filter: brightness(1.9) saturate(.8); }
.dfile > summary::-webkit-details-marker { display: none; }
.dfile > summary::before { content: "+"; flex: none; width: 10px; color: var(--amber); font-family: var(--mono); }
.dfile[open] > summary::before { content: "−"; }
.dscroll { overflow-x: auto; }
.dtable { border-collapse: collapse; min-width: 100%; line-height: 19px; tab-size: 4; }
.dtable td { padding: 0; height: 19px; vertical-align: top; }
.dl-no, .dl-mark, .dl-code, .dl-hunk td { font-family: var(--mono); font-size: 12px; }
.dl-no { width: 1%; min-width: 46px; padding: 0 8px !important; text-align: right; color: var(--faint); user-select: none; }
.dl-act { width: 22px; text-align: center; }
.dl-mark { width: 14px; text-align: center; user-select: none; color: var(--faint); }
.dl-code { width: 100%; padding: 0 8px !important; white-space: pre; }
.dl-add td { background: rgb(46 125 50 / .17); }
.dl-add :is(.dl-no, .dl-mark) { color: var(--green); }
.dl-del td { background: rgb(163 34 28 / .15); }
.dl-del :is(.dl-no, .dl-mark) { color: var(--red); }
.dl-hunk td { padding: 3px 8px; background: var(--paper-lo); color: var(--link); white-space: pre; }
.dnote { margin: 0; padding: 8px 10px; color: var(--muted); }
.dnote a { color: var(--link); text-decoration: underline; }
.add-comment {
  width: 18px; height: 18px; padding: 0; border: 0; border-radius: 3px; line-height: 1; opacity: 0;
  background: var(--plate); color: var(--amber); font: inherit; font-weight: 700;
}
.dl:hover .add-comment, .add-comment:focus-visible { opacity: 1; }
.comment-row td { padding: 6px 8px 8px; background: var(--paper-lo); }
.comment-box { position: sticky; left: 8px; width: min(640px, 70vw); padding: 10px; background: var(--bg); border: 2px solid var(--plate); border-radius: 3px; }
.comment-box textarea { margin: 4px 0 0; }
.comment-box .actions { margin-top: 8px; }

/* ---- members, tokens ---- */
#members, #tokens { padding: 20px 24px; display: flex; flex-direction: column; gap: 18px; max-width: 580px; overflow-y: auto; }
#tokens > p { margin: 0; }
#tokens pre { margin: 0; }
#members .card, #tokens .card { background: var(--paper-hi); }
.member-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--text); }
.member-list li { display: flex; gap: 10px; align-items: center; min-height: 34px; padding: 0 6px; border-bottom: 1px solid var(--rule); }
.member-list .icon-btn { margin-left: auto; }
.member-name { font-weight: 600; }
.inline-form button.primary { align-self: flex-end; }

/* ---- small screens ---- */
@media (max-width: 1100px) {
  .ptable.projects { grid-template-columns: max-content minmax(0, 1fr) 112px 124px 68px 150px; }
  .c-issues { display: none !important; }
  .ptable.pulls .prow { grid-template-columns: 170px minmax(0, 1fr) 140px 56px; }
  .c-author, .c-branch { display: none !important; }
}
@media (max-width: 900px) {
  .project-layout { grid-template-columns: 1fr; overflow-y: auto; }
  .project-main { overflow: visible; }
  .project-side { border-left: 0; border-top: 1px solid var(--rule); }
  .irow { grid-template-columns: 28px 56px 28px minmax(0, 1fr) 28px; }
  .irow .ims, .irow .idate { display: none; }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); padding: 6px; gap: 6px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar .mascot { display: none; }
  .ptable.projects { grid-template-columns: minmax(0, 1fr) 112px 40px; }
  .c-lead, .c-status, .c-milestone { display: none !important; }
  .ptable.pulls .prow { grid-template-columns: 150px minmax(0, 1fr) 40px; }
  .c-links { display: none !important; }
  .auth-panel { grid-template-columns: minmax(0, 340px); }
  .auth .mascot { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .nav-item, .tab, .prow, .irow, button, .pill { transition: background-color .08s, color .08s, border-color .08s, box-shadow .12s; }
}
