/* Docket — team inbox. Bento-ledger system: drawn ink rules, squared corners,
   one dark inspector tile bleeding off the right edge. */

@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.ttf") format("truetype");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  /* paper side */
  --bg: #f2f1ec;
  --surface: #fbfaf7;
  --surface-2: #ebeae4;
  --ink: #17181c;
  --muted: #585c66;
  --rule: #17181c;
  --hair: #d8d6ce;
  --accent: #4a4ac4;
  --accent-ink: #fbfaff;
  --accent-soft: #e7e6f8;

  /* inspector tile */
  --night: #15161b;
  --night-2: #1e2027;
  --night-3: #2a2d36;
  --night-ink: #ecebe6;
  --night-muted: #a3a6b0;
  --night-rule: #3a3d47;
  --night-accent: #ababff;

  /* status system — shape + color, light and dark variants */
  --todo: #4c5566;        --todo-bg: #e7e8ec;        --todo-dk: #b8becb;
  --doing: #8a5300;       --doing-bg: #f8ecd4;       --doing-dk: #f2b655;
  --blocked: #b3261e;     --blocked-bg: #f9e5e2;     --blocked-dk: #ff8f84;
  --done: #1f7144;        --done-bg: #e1f0e6;        --done-dk: #6dd69b;

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 2px;
  --inspector: 440px;
  --pad: 32px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
body.is-locked { overflow: hidden; }

h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
  padding: 3px 6px;
  border: 1px solid var(--hair);
  border-bottom-width: 2px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Focus: keep a real outline everywhere, restyle per context below. */
:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip-link {
  position: absolute;
  left: 16px; top: -64px;
  z-index: 100;
  padding: 12px 20px;
  background: var(--ink);
  color: var(--surface);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius);
}
.skip-link:focus { top: 12px; }

/* ---------- App frame ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--inspector);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "head insp"
    "desk insp"
    "foot insp";
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Masthead ---------- */
.masthead {
  grid-area: head;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding-inline: var(--pad);
  border-bottom: 2px solid var(--rule);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding-right: 4px;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius);
}
.brand-mark { flex: none; color: var(--ink); }
.brand-mark .mark-knock { fill: var(--bg); }
.brand-mark .mark-lines { stroke: var(--bg); stroke-width: 1.6; fill: none; }
.brand-mark .mark-tab { fill: var(--accent); }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.03em;
  line-height: 1;
}
.workspace {
  display: inline-flex;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}
.workspace-sep { color: var(--hair); font-weight: 400; }
.kbd-hints {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.kbd-hints kbd + kbd, .kbd-hints kbd:not(:first-child) { margin-left: 12px; }

/* ---------- Desk (working surface) ---------- */
.desk {
  grid-area: desk;
  min-width: 0;
  padding: 28px var(--pad) 48px;
}
.desk-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 20px;
}
h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(32px, 3vw, 44px);
  letter-spacing: -0.035em;
  line-height: 1;
}
.desk-meta {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Tally strip: proportional status views ---------- */
.tally-list {
  display: flex;
  border: 2px solid var(--rule);
  background: var(--surface);
}
.tally-cell {
  --n: 1;
  flex: var(--n) 1 0;
  min-width: 124px;
  display: flex;
  transition: flex-grow 240ms var(--ease);
}
.tally-cell + .tally-cell { border-left: 2px solid var(--rule); }
.tally-cell--all { flex: 0 0 148px; }
.tally-btn {
  position: relative;
  flex: 1;
  display: grid;
  align-content: space-between;
  gap: 6px;
  min-height: 84px;
  padding: 12px 16px 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}
.tally-btn::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 6px;
  background: var(--tally-color, var(--ink));
}
[data-status="todo"] { --tally-color: var(--todo); }
[data-status="in-progress"] { --tally-color: var(--doing); }
[data-status="blocked"] { --tally-color: var(--blocked); }
[data-status="done"] { --tally-color: var(--done); }
.tally-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tally-n {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tally-btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.tally-btn:focus-visible { outline-offset: -4px; outline-color: var(--accent); }
.tally-btn[aria-pressed="true"]:focus-visible { outline-color: var(--night-accent); }
.tally-btn:active { background: var(--surface-2); }
.tally-btn[aria-pressed="true"]:active { background: #2a2b31; }
.tally-n.is-bumped { animation: bump 220ms var(--ease); }
@keyframes bump {
  from { transform: translateY(-6px); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 200px auto;
  align-items: end;
  gap: 16px;
  margin-block: 24px 16px;
}
.field { display: grid; gap: 6px; min-width: 0; }
.field label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.field--sort { display: none; }
.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.search-kbd {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted);
}
.search-wrap:focus-within .search-kbd,
.search-wrap:has(input:not(:placeholder-shown)) .search-kbd { opacity: 0; }
input[type="search"], .toolbar select {
  width: 100%;
  min-height: 46px;
  border: 2px solid var(--rule);
  border-radius: var(--radius);
  background-color: var(--surface);
  font-size: 16px;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
input[type="search"] { padding: 0 44px 0 42px; }
input[type="search"]::placeholder { color: var(--muted); }
.toolbar select, .status-field select {
  appearance: none;
  -webkit-appearance: none;
  padding: 0 40px 0 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m5 8 5 5 5-5' fill='none' stroke='%2317181c' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  cursor: pointer;
}
input[type="search"]:focus-visible, .toolbar select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}
.result-count {
  align-self: center;
  justify-self: end;
  padding-top: 22px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- Task table ---------- */
.tasks {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 2px solid var(--rule);
  background: var(--surface);
  font-size: 15px;
}
.tasks thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0;
  background: var(--surface-2);
  border-bottom: 2px solid var(--rule);
  text-align: left;
  font-weight: 600;
}
.tasks thead th + th { border-left: 1px solid var(--hair); }
.sort-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--ink);
  transition: background-color 160ms var(--ease);
}
.sort-btn:focus-visible { outline-offset: -3px; }
.sort-btn:active { background: var(--hair); }
.sort-ind { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.sort-ind::before { content: "↕"; opacity: 0.45; }
th[aria-sort="ascending"] .sort-ind::before { content: "↑"; opacity: 1; color: var(--accent); }
th[aria-sort="descending"] .sort-ind::before { content: "↓"; opacity: 1; color: var(--accent); }

.tasks td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--hair);
  vertical-align: middle;
  transition: background-color 160ms var(--ease);
}
.tasks tbody tr:last-child td { border-bottom: 0; }
.c-no { width: 64px; }
.c-status { width: 168px; }
.c-pri { width: 112px; }
.c-who { width: 176px; }
.c-due { width: 92px; }
.row { cursor: pointer; }
.no {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.c-task { position: relative; }
.open-btn {
  display: block;
  padding: 2px 0;
  border: 0;
  background: none;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color 160ms var(--ease);
}
/* Whole cell is the hit area for the title button. */
.open-btn::after { content: ""; position: absolute; inset: 0; }
.open-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }
.c-project {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}
.row:focus-within td { background: var(--accent-soft); }
.row:focus-within td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
.row.is-open td { background: var(--accent-soft); }
.row.is-open td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
.row.is-open .no { color: var(--accent); }
.row:active td { background: var(--surface-2); }
.row.is-flash td { animation: row-flash 260ms var(--ease); }
@keyframes row-flash {
  from { background-color: #d6d5f3; }
}

/* Status pill: glyph shape + label, never color alone */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--pill);
  background: var(--pill-bg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pill) 30%, transparent);
}
.pill--todo { --pill: var(--todo); --pill-bg: var(--todo-bg); }
.pill--in-progress { --pill: var(--doing); --pill-bg: var(--doing-bg); }
.pill--blocked { --pill: var(--blocked); --pill-bg: var(--blocked-bg); }
.pill--done { --pill: var(--done); --pill-bg: var(--done-bg); }
.glyph { flex: none; }
.glyph .g-knock { stroke: var(--glyph-knock, var(--surface)); }
.updated {
  display: inline-block;
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  vertical-align: middle;
}

.pri { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; }
.pri-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.pri-bars i { display: block; width: 3px; background: var(--hair); }
.pri-bars i:nth-child(1) { height: 5px; }
.pri-bars i:nth-child(2) { height: 8px; }
.pri-bars i:nth-child(3) { height: 12px; }
.pri--low .pri-bars i:nth-child(1),
.pri--medium .pri-bars i:nth-child(-n+2),
.pri--high .pri-bars i { background: currentColor; }
.pri--high { font-weight: 600; }

.who { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; }
.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 26px; height: 26px;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--hair);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.c-due time {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Load / error / empty states ---------- */
.load-state {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
  border: 2px solid var(--rule);
  background: var(--surface);
  color: var(--muted);
}
.empty {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding: 32px;
  border: 2px solid var(--rule);
  background: var(--surface);
}
.empty-art { flex: none; }
.empty-art .art-paper { fill: var(--bg); stroke: var(--ink); stroke-width: 2; }
.empty-art .art-perf { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 2 4; }
.empty-art .art-line { stroke: var(--hair); stroke-width: 3; }
.empty-art .art-stamp { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 3 3; }
.empty h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.empty p { margin-top: 6px; max-width: 56ch; color: var(--muted); }
.empty-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.noscript { padding: 24px; border: 2px solid var(--rule); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  transition: background-color 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--ease);
}
.btn--primary { border: 2px solid var(--accent); background: var(--accent); color: var(--accent-ink); }
.btn--quiet { border: 2px solid var(--rule); background: transparent; color: var(--ink); }
.btn:active { transform: scale(0.97); }

/* ---------- Footer ---------- */
.site-foot {
  grid-area: foot;
  padding: 16px var(--pad) 24px;
  border-top: 1px solid var(--hair);
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Inspector: the dark bleeding tile ---------- */
.inspector {
  grid-area: insp;
  align-self: start;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--night);
  color: var(--night-ink);
  border-left: 2px solid var(--rule);
  color-scheme: dark;
  --glyph-knock: var(--night);
}
.inspector :focus-visible { outline-color: var(--night-accent); }

/* Overview (no task open) */
.overview { padding: 28px 28px 40px; }
.ov-intro {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 20px;
  padding-bottom: 28px;
}
.ov-art .art-paper { fill: var(--night-2); stroke: var(--night-rule); stroke-width: 2; }
.ov-art .art-hole { fill: var(--night); stroke: var(--night-rule); stroke-width: 2; }
.ov-art .art-perf { stroke: var(--night-muted); stroke-width: 2; stroke-dasharray: 2 5; }
.ov-art .art-line { stroke: var(--night-3); stroke-width: 4; }
.ov-art .art-stamp { fill: none; stroke: var(--night-accent); stroke-width: 2; stroke-dasharray: 4 3; }
.overview h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.ov-intro p { margin-top: 6px; font-size: 15px; color: var(--night-muted); }
.ov-block { padding-top: 16px; border-top: 2px solid var(--night-rule); }
.ov-block + .ov-block { margin-top: 28px; }
.ov-block h3, .slip-brief h3, .facts dt, .status-field label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--night-muted);
}
.ov-block h3 { margin-bottom: 8px; }

.due-link {
  position: relative;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 8px 8px;
  border: 0;
  border-bottom: 1px solid var(--night-rule);
  background: transparent;
  text-align: left;
  color: var(--night-ink);
  transition: background-color 160ms var(--ease);
}
.due-list li:last-child .due-link { border-bottom: 0; }
.due-link:focus-visible { outline-offset: -2px; }
.due-link:active { background: var(--night-3); }
.due-no { font-family: var(--font-mono); font-size: 13px; color: var(--night-muted); }
.due-title { font-size: 15px; font-weight: 500; line-height: 1.35; }
.due-meta { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 12px; color: var(--night-muted); white-space: nowrap; }
.due-meta .glyph { color: var(--g, var(--night-muted)); }
.due-meta--todo { --g: var(--todo-dk); }
.due-meta--in-progress { --g: var(--doing-dk); }
.due-meta--blocked { --g: var(--blocked-dk); }
.due-meta--done { --g: var(--done-dk); }
.due-none { padding: 12px 8px; font-size: 15px; color: var(--night-muted); }

.load { width: 100%; border-collapse: collapse; font-size: 14px; }
.load tbody th { padding: 8px 6px; font-weight: 500; text-align: left; }
.load .who { white-space: normal; }
.load thead th {
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--night-muted);
  border-bottom: 1px solid var(--night-rule);
}
.load abbr { text-decoration: none; }
.load td, .load tbody th { border-bottom: 1px solid var(--night-rule); }
.load td { padding: 8px 6px; }
.load tbody tr:last-child > * { border-bottom: 0; }
.load .num { text-align: right; width: 52px; }
.load td.num { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.load .is-zero { color: #80848f; }
.load .n-blocked:not(.is-zero) { color: var(--blocked-dk); }
.load .who { font-size: 14px; }
.load .avatar { background: var(--night-3); box-shadow: none; color: var(--night-ink); }

/* Detail slip */
.slip { padding-bottom: 48px; animation: slip-in 220ms var(--ease); }
@keyframes slip-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}
/* Prev/next between tasks: a quick cross-fade instead of a full slide. */
.slip.is-switching { animation-name: slip-swap; animation-duration: 160ms; }
@keyframes slip-swap {
  from { opacity: 0.35; }
  to { opacity: 1; }
}
.slip-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--night);
  border-bottom: 1px solid var(--night-rule);
}
.slip-nav { display: flex; align-items: center; gap: 4px; }
.slip-pos {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--night-muted);
  font-variant-numeric: tabular-nums;
}
.icon-btn, .close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--night-rule);
  border-radius: var(--radius);
  background: transparent;
  color: var(--night-ink);
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease), transform 120ms var(--ease);
}
.icon-btn svg, .close-btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.close-btn { padding: 0 16px 0 14px; font-size: 14px; font-weight: 600; }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn:not(:disabled):active, .close-btn:active { transform: scale(0.97); background: var(--night-3); }

.slip-head {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px 28px 0;
}
.slip-no {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-mono);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.slip-no-label { font-size: 13px; color: var(--night-muted); }
#detail-no { font-size: 48px; letter-spacing: -0.04em; }
.stamp {
  display: inline-block;
  padding: 5px 10px;
  border: 2px solid var(--stamp);
  border-radius: var(--radius);
  color: var(--stamp);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transform: rotate(-5deg);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--stamp) 18%, transparent);
}
.stamp--todo { --stamp: var(--todo-dk); }
.stamp--in-progress { --stamp: var(--doing-dk); }
.stamp--blocked { --stamp: var(--blocked-dk); }
.stamp--done { --stamp: var(--done-dk); }
.stamp.is-stamping { animation: stamp-down 240ms var(--ease); }
@keyframes stamp-down {
  0% { opacity: 0; transform: rotate(-11deg) scale(1.35); }
  100% { opacity: 1; transform: rotate(-5deg) scale(1); }
}

.slip-title { padding: 16px 28px 0; }
.slip-kicker {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--night-muted);
}
.slip-title h2 {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  text-wrap: balance;
}
.slip-title h2:focus { outline: none; }
.slip-title h2:focus-visible { outline: 2px solid var(--night-accent); outline-offset: 4px; }

.status-field {
  display: grid;
  gap: 8px;
  margin: 24px 28px 0;
  padding: 16px;
  background: var(--night-2);
  border: 1px solid var(--night-rule);
  border-left: 4px solid var(--sf, var(--night-rule));
  transition: border-color 200ms var(--ease);
}
.status-field[data-status="todo"] { --sf: var(--todo-dk); }
.status-field[data-status="in-progress"] { --sf: var(--doing-dk); }
.status-field[data-status="blocked"] { --sf: var(--blocked-dk); }
.status-field[data-status="done"] { --sf: var(--done-dk); }
.status-field select {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--night-rule);
  border-radius: var(--radius);
  background-color: var(--night-3);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m5 8 5 5 5-5' fill='none' stroke='%23ecebe6' stroke-width='2'/%3E%3C/svg%3E");
  color: var(--night-ink);
  font-size: 16px;
  font-weight: 600;
  transition: border-color 160ms var(--ease);
}
.status-field select:focus-visible { outline: 2px solid var(--night-accent); outline-offset: 2px; border-color: var(--night-accent); }
.feedback {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  min-height: 24px;
}
.feedback-text { font-size: 14px; line-height: 1.45; color: var(--night-ink); }
.feedback-text:empty { display: none; }
.feedback-text.is-saved::before {
  content: "✓";
  display: inline-block;
  margin-right: 6px;
  color: var(--done-dk);
  font-weight: 700;
}
.undo-btn {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--night-accent);
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 160ms var(--ease), transform 120ms var(--ease);
}
.undo-btn:active { transform: scale(0.97); }

/* Perforation: where the slip tears from the ledger */
.perf {
  height: 14px;
  margin: 28px 0 8px;
  background: radial-gradient(circle, var(--night-rule) 2px, transparent 2.5px) 4px 50% / 12px 12px repeat-x;
}

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding-inline: 28px;
}
.fact {
  display: grid;
  gap: 4px;
  padding-block: 12px;
  border-bottom: 1px solid var(--night-rule);
}
.fact:nth-child(odd):not(.fact--wide) { padding-right: 16px; }
.fact--wide { grid-column: 1 / -1; }
.facts dd { font-size: 15px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.facts .avatar { background: var(--night-3); box-shadow: none; color: var(--night-ink); }
.facts .pri-bars i { background: var(--night-3); }
.facts .pri--low .pri-bars i:nth-child(1),
.facts .pri--medium .pri-bars i:nth-child(-n+2),
.facts .pri--high .pri-bars i { background: currentColor; }
.facts time, .facts .mono { font-family: var(--font-mono); font-size: 14px; font-variant-numeric: tabular-nums; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--night-rule);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--night-ink);
}

.slip-brief { padding: 24px 28px 0; }
.slip-body {
  margin-top: 10px;
  max-width: 62ch;
  font-size: 16px;
  line-height: 1.65;
  white-space: pre-line;
  color: var(--night-ink);
}
.slip-body strong { font-weight: 700; color: #ffffff; }

/* ---------- Hover (fine pointers only) ---------- */
@media (hover: hover) and (pointer: fine) {
  .brand:hover .brand-name { color: var(--accent); }
  .tally-btn:hover { background: var(--surface-2); }
  .tally-btn[aria-pressed="true"]:hover { background: #2a2b31; }
  input[type="search"]:hover, .toolbar select:hover { border-color: var(--accent); }
  .sort-btn:hover { background: var(--hair); }
  .sort-btn:hover .sort-ind::before { opacity: 1; }
  .row:hover td { background: #f1f0ea; }
  .row.is-open:hover td { background: var(--accent-soft); }
  .row:hover .open-btn { text-decoration-color: currentColor; }
  .btn--primary:hover { background: #3b3bab; border-color: #3b3bab; }
  .btn--quiet:hover { background: var(--ink); color: var(--surface); }
  .due-link:hover { background: var(--night-2); }
  .icon-btn:not(:disabled):hover, .close-btn:hover { background: var(--night-2); border-color: var(--night-muted); }
  .status-field select:hover { border-color: var(--night-muted); }
  .undo-btn:hover { color: #d0d0ff; }
}

/* ---------- Medium widths ---------- */
@media (max-width: 1240px) {
  :root { --inspector: 380px; --pad: 24px; }
  .c-pri { width: 96px; }
  .c-who { width: 64px; }
  .c-who .who-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .kbd-hints { display: none; }
}

/* ---------- Narrow: single column, slip becomes a full-screen sheet ---------- */
@media (max-width: 900px) {
  :root { --pad: 20px; }
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "head" "desk" "insp" "foot";
  }
  .masthead { min-height: 56px; }
  .desk { padding: 20px var(--pad) 32px; }
  .desk-title { margin-bottom: 16px; }

  .tally-list { display: grid; grid-template-columns: 1fr 1fr; }
  .tally-cell, .tally-cell--all { min-width: 0; flex: none; }
  .tally-cell + .tally-cell { border-left: 0; }
  .tally-cell--all { grid-column: 1 / -1; border-bottom: 2px solid var(--rule); }
  .tally-cell:nth-child(2), .tally-cell:nth-child(3) { border-bottom: 2px solid var(--rule); }
  .tally-cell:nth-child(3), .tally-cell:nth-child(5) { border-left: 2px solid var(--rule); }
  .tally-cell--all .tally-btn { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
  .tally-btn { min-height: 72px; padding: 10px 14px 16px; }
  .tally-n { font-size: 26px; }

  .toolbar { grid-template-columns: 1fr 1fr; gap: 12px; margin-block: 20px 12px; }
  .field--search { grid-column: 1 / -1; }
  .field--sort { display: grid; }
  .search-kbd { display: none; }
  input[type="search"] { padding-right: 14px; }
  .result-count { grid-column: 1 / -1; justify-self: start; padding-top: 0; }

  .tasks, .tasks tbody { display: block; }
  .tasks thead { display: none; }
  .tasks tr {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 14px 16px 14px 56px;
    border-bottom: 1px solid var(--hair);
    transition: background-color 160ms var(--ease);
  }
  .tasks tbody tr:last-child { border-bottom: 0; }
  .tasks td { display: block; width: auto; padding: 0; border: 0; background: none; transition: none; }
  .tasks td.c-no { position: absolute; left: 16px; top: 17px; }
  .tasks td.c-task { flex: 1 1 100%; position: static; }
  .open-btn::after { inset: 0; }
  .row:focus-within, .row.is-open { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
  .row:focus-within td, .row.is-open td { background: none; box-shadow: none; }
  .row:active { background: var(--surface-2); }
  .row.is-flash { animation: row-flash 260ms var(--ease); }
  .row.is-flash td { animation: none; }
  .c-who .who-name { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .c-due time::before { content: "Due "; color: var(--muted); }

  .empty { flex-direction: column; padding: 24px 20px; }
  .empty-art { width: 48px; height: 60px; }

  .inspector {
    position: static;
    height: auto;
    overflow: visible;
    border-left: 0;
    border-top: 2px solid var(--rule);
  }
  .overview { padding: 28px var(--pad) 32px; }
  .ov-art { width: 64px; height: 80px; }

  .slip {
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--night);
    animation-name: sheet-up;
  }
  .slip-bar { padding: 8px 12px 8px 16px; }
  .slip-head, .slip-title, .slip-brief, .facts { padding-inline: var(--pad); }
  .status-field { margin-inline: var(--pad); }
  #detail-no { font-size: 40px; }
  .slip-title h2 { font-size: 24px; }
  .site-foot { padding: 16px var(--pad) 24px; }
}
@keyframes sheet-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 420px) {
  .workspace { font-size: 13px; }
  .facts { grid-template-columns: 1fr; }
  .fact:nth-child(odd):not(.fact--wide) { padding-right: 0; }
  .slip-pos { display: none; }
}

/* ---------- Reduced motion: drop transform motion, keep state changes ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .btn:active, .icon-btn:not(:disabled):active, .close-btn:active, .undo-btn:active { transform: none; }
}
