/* ============================================================
   DOCKET — team task inbox
   World: print-shop job docket. Job tickets, rubber-stamp
   statuses, ruled ledger, registration marks.
   ============================================================ */

/* ---------- Faces (local, from the supplied pool) ---------- */
@font-face {
  font-family: "Oswald";
  src: url("assets/oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --paper: #f3f2ec;
  --paper-raised: #fbfaf5;
  --paper-sunken: #e8e7df;
  --paper-hover: #f7f6f1;
  --paper-deep: #dedcd1;

  --ink: #191b1f;
  --ink-2: #3c4048;
  --ink-3: #6a6e77;
  --rule: #d5d3c9;
  --rule-strong: #b7b5a9;

  --accent: #1f47c7;
  --accent-deep: #16307f;
  --accent-soft: #e2e7fa;

  --rail: #1a1c21;
  --rail-2: #24272e;
  --rail-line: #34373f;
  --rail-text: #ecebe4;
  --rail-muted: #979ba5;
  --rail-accent: #aebfff;

  --st-todo: #2b56d6;
  --st-in-progress: #ad4d05;
  --st-blocked: #ba2a20;
  --st-done: #1b7548;
  --white: #ffffff;
  --rail-edge: #0e0f12;
  --dot-todo: #5f7cf0;
  --dot-in-progress: #e08a3c;
  --dot-blocked: #e0655c;
  --dot-done: #4aa878;
  --rail-st-todo: #a9baff;
  --rail-st-in-progress: #f0a45e;
  --rail-st-blocked: #f08b82;
  --rail-st-done: #74cf9f;

  --font-condensed: "Oswald", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --rail-w: 264px;
  --radius: 4px;
  --shadow-sheet: -18px 0 44px -22px rgba(16, 18, 24, 0.45), -2px 0 0 rgba(16, 18, 24, 0.06);
  --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent);
  --focus-rail: 0 0 0 2px var(--rail), 0 0 0 4px var(--rail-accent);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, dl, dd, dt, ul, ol, figure {
  margin: 0;
  padding: 0;
}

ul, ol {
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
}

svg {
  display: block;
}

::selection {
  background: var(--accent);
  color: var(--white);
}

/* ---------- Typed browser surfaces ---------- */
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-decoration: none;
  border-radius: var(--radius);
  transform: translateY(-160%);
  transition: transform 0.16s ease;
}
.skip-link:focus {
  transform: translateY(0);
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ============================================================
   RAIL
   ============================================================ */
.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 26px 20px 22px;
  background: var(--rail);
  color: var(--rail-text);
  border-right: 1px solid var(--rail-edge);
  overflow-y: auto;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rail-line);
}

.brand-mark {
  color: var(--rail-accent);
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-condensed);
  font-weight: 600;
  font-size: 27px;
  line-height: 0.95;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-sub {
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--rail-muted);
  text-transform: uppercase;
}

.rail-label {
  font-family: var(--font-condensed);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--rail-muted);
  margin-bottom: 10px;
}

.rail-counts {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail-count {
  width: 100%;
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  color: var(--rail-text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}
.rail-count:hover {
  background: var(--rail-2);
}
.rail-count[aria-pressed="true"] {
  background: var(--rail-2);
}
.rail-count[aria-pressed="true"] .rail-count-name {
  color: var(--white);
  font-weight: 600;
}
.rail-count[aria-pressed="true"] .rail-count-num {
  background: var(--rail-accent);
  color: var(--rail);
  border-color: transparent;
}
.rail-count:focus-visible {
  box-shadow: var(--focus-rail);
}

.rail-count-name {
  font-size: 14px;
  color: var(--rail-text);
}

.rail-count-num {
  font-family: var(--font-mono);
  font-size: 11.5px;
  min-width: 24px;
  text-align: center;
  padding: 1px 6px;
  border: 1px solid var(--rail-line);
  border-radius: 3px;
  color: var(--rail-muted);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--rail-muted);
  flex: none;
}
.dot-todo { background: var(--dot-todo); }
.dot-in-progress { background: var(--dot-in-progress); }
.dot-blocked { background: var(--dot-blocked); }
.dot-done { background: var(--dot-done); }
.dot-all { background: linear-gradient(135deg, var(--dot-todo) 0 25%, var(--dot-in-progress) 25% 50%, var(--dot-blocked) 50% 75%, var(--dot-done) 75% 100%); }

.rail-foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--rail-line);
}

.rail-stamp {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rail-accent);
}
.rail-note {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--rail-muted);
}

/* ============================================================
   WORKSPACE
   ============================================================ */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 30px 34px 20px;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.masthead::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 5px;
  background-image: radial-gradient(var(--rule-strong) 1px, transparent 1.2px);
  background-size: 6px 6px;
  opacity: 0.55;
  pointer-events: none;
}

.masthead h1 {
  font-family: var(--font-condensed);
  font-weight: 600;
  font-size: 40px;
  line-height: 0.98;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.masthead-sub {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--ink-3);
}

.masthead-date {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: none;
}
.masthead-day {
  font-family: var(--font-condensed);
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.masthead-cal {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.main {
  flex: 1;
  padding: 22px 34px 40px;
  min-width: 0;
}

/* ============================================================
   CONTROLS
   ============================================================ */
.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.7fr) minmax(150px, 1fr) minmax(140px, 1fr);
  gap: 14px;
  align-items: end;
  padding: 16px;
  margin-bottom: 22px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 var(--rule), 0 8px 20px -18px rgba(16, 18, 24, 0.5);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-family: var(--font-condensed);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.field-input {
  position: relative;
  display: block;
}

.field-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}

input[type="search"],
select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

input[type="search"] {
  padding-left: 36px;
}
input[type="search"]::placeholder {
  color: var(--ink-3);
  opacity: 1;
}

input[type="search"]:hover,
select:hover {
  border-color: var(--ink-3);
}

input[type="search"]:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--paper-raised);
  box-shadow: var(--focus);
}

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%233c4048' stroke-width='1.7'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  height: 15px;
  width: 15px;
  background: no-repeat center / 13px 13px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='%236a6e77' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M2 2l10 10M12 2 2 12'/%3E%3C/svg%3E");
  cursor: pointer;
}

/* ============================================================
   LEDGER
   ============================================================ */
.ledger {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  box-shadow: 0 1px 0 var(--rule), 0 22px 44px -40px rgba(16, 18, 24, 0.6);
  overflow: hidden;
}

.ledger-head {
  display: grid;
  grid-template-columns: 58px 142px minmax(0, 1fr) 104px 92px 96px;
  gap: 14px;
  align-items: center;
  padding: 11px 18px;
  background: var(--paper-sunken);
  border-bottom: 1px solid var(--rule-strong);
  font-family: var(--font-condensed);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.list {
  display: flex;
  flex-direction: column;
}

/* ---------- Item ---------- */
.item {
  position: relative;
  display: grid;
  grid-template-columns: 58px 142px minmax(0, 1fr) 104px 92px 96px;
  gap: 14px;
  align-items: center;
  padding: 15px 18px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background 0.14s ease;
}
.item:last-child {
  border-bottom: 0;
}
.item:hover {
  background: var(--paper-hover);
}
.item.is-open {
  background: var(--accent-soft);
}
.item:focus-within {
  background: var(--paper-hover);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.item-num {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.item-main {
  min-width: 0;
}

.item-title {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.005em;
  overflow-wrap: anywhere;
}

.item-meta {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.item-meta .sep {
  color: var(--rule-strong);
}
.item-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 0 5px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink-3);
  background: var(--paper);
}

.item-due {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.item-due .overdue {
  font-family: var(--font-condensed);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--st-blocked);
}

.item-priority {
  font-family: var(--font-condensed);
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.prio-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}
.prio-bars i {
  width: 3px;
  background: var(--rule-strong);
  border-radius: 1px;
  display: block;
}
.prio-bars i:nth-child(1) { height: 5px; }
.prio-bars i:nth-child(2) { height: 8px; }
.prio-bars i:nth-child(3) { height: 12px; }
.prio-high .prio-bars i { background: var(--st-blocked); }
.prio-medium .prio-bars i:nth-child(-n+2) { background: var(--st-in-progress); }
.prio-low .prio-bars i:nth-child(1) { background: var(--ink-2); }

.item-action {
  display: flex;
  justify-content: flex-end;
}

.btn-open {
  font-family: var(--font-condensed);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 7px 12px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.btn-open::after {
  content: "";
  position: absolute;
  inset: 0; /* stretch the hit target across the whole ticket row */
}
.btn-open:focus-visible {
  box-shadow: none;
}
.btn-open:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* ============================================================
   STATUS STAMP
   ============================================================ */
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: start;
  justify-self: start;
  padding: 3px 7px 2px;
  font-family: var(--font-condensed);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  line-height: 1.2;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  background: var(--paper-raised);
  white-space: nowrap;
}
.stamp::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: currentColor;
  flex: none;
}
.status-todo { color: var(--st-todo); }
.status-in-progress { color: var(--st-in-progress); }
.status-blocked { color: var(--st-blocked); }
.status-done { color: var(--st-done); }

.stamp.is-stamping {
  animation: stamp-down 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes stamp-down {
  0% { transform: scale(1.35) rotate(-5deg); opacity: 0; filter: blur(2px); }
  55% { transform: scale(0.97) rotate(0.6deg); opacity: 1; filter: blur(0); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; filter: blur(0); }
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  padding: 62px 30px 66px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.empty-mark {
  color: var(--rule-strong);
  margin-bottom: 18px;
}
.empty-title {
  font-family: var(--font-condensed);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink);
}
.empty-copy {
  margin-top: 8px;
  max-width: 44ch;
  color: var(--ink-3);
  font-size: 14px;
}
.empty-actions {
  margin-top: 22px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: var(--font-condensed);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-strong);
}
.btn-ghost:hover {
  border-color: var(--ink);
  background: var(--paper-sunken);
}

/* ============================================================
   COLOPHON
   ============================================================ */
.colophon {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 16px 34px 22px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}
.colophon-spacer {
  flex: 1;
}

/* ============================================================
   DETAIL SHEET
   ============================================================ */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(18, 20, 26, 0.4);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.scrim.is-visible {
  opacity: 1;
}

.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: min(540px, 100vw);
  background: var(--paper-raised);
  border-left: 1px solid var(--rule-strong);
  box-shadow: var(--shadow-sheet);
  transform: translateX(102%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.32s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sheet.is-open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
}

.sheet-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.detail-view {
  min-height: 100%;
}

/* ---------- Sheet header ---------- */
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 20px;
  background: var(--rail);
  color: var(--rail-text);
  border-bottom: 3px solid var(--accent);
}
.sheet-num {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--rail-accent);
  letter-spacing: 0.04em;
}
.sheet-head .stamp {
  background: var(--rail);
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.55);
}
.sheet-head .stamp.status-todo { color: var(--rail-st-todo); }
.sheet-head .stamp.status-in-progress { color: var(--rail-st-in-progress); }
.sheet-head .stamp.status-blocked { color: var(--rail-st-blocked); }
.sheet-head .stamp.status-done { color: var(--rail-st-done); }

.sheet-head-spacer {
  flex: 1;
}

.sheet-title:focus,
.sheet-title:focus-visible {
  outline: none;
  box-shadow: none;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--rail-text);
  border: 1px solid var(--rail-line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover {
  background: var(--rail-2);
  border-color: var(--rail-muted);
}
.icon-btn:focus-visible {
  box-shadow: var(--focus-rail);
}

/* ---------- Sheet body ---------- */
.sheet-body {
  padding: 24px 22px 40px;
}

.sheet-title {
  font-family: var(--font-condensed);
  font-size: 29px;
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0.005em;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.sheet-project {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.03em;
}

/* ---------- Meta grid ---------- */
.meta {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
}
.meta-cell {
  padding: 11px 13px;
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  min-width: 0;
}
.meta-cell:nth-child(2n) {
  border-right: 0;
}
.meta-cell:nth-last-child(-n+2) {
  border-bottom: 0;
}
.meta-cell dt {
  font-family: var(--font-condensed);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.meta-cell dd {
  margin-top: 3px;
  font-size: 14px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.meta-cell dd.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.meta-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  color: var(--ink-2);
  background: var(--paper-raised);
}

/* ---------- Routing ---------- */
.routing {
  margin-top: 24px;
  padding: 16px;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
}
.routing-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-label {
  font-family: var(--font-condensed);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.routing-track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin-bottom: 18px;
}
.routing-stage {
  position: relative;
  padding-top: 15px;
  font-family: var(--font-condensed);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: center;
}
.routing-stage::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 0;
  height: 2px;
  width: 100%;
  background: var(--rule);
}
.routing-stage::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--rule-strong);
}
.routing-stage.is-done::before {
  background: var(--accent);
}
.routing-stage.is-current {
  color: var(--ink);
  font-weight: 600;
}
.routing-stage.is-current::after {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.status-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.status-field select {
  height: 46px;
  font-family: var(--font-condensed);
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
  background-color: var(--paper-raised);
}
.routing-hint {
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* ---------- Prose ---------- */
.prose {
  margin-top: 26px;
  max-width: 68ch;
}
.prose-label {
  font-family: var(--font-condensed);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.prose p {
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.66;
}
.prose p + p {
  margin-top: 14px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 80;
  transform: translate(-50%, 140%);
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 14px 12px 16px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 14px 30px -12px rgba(16, 18, 24, 0.7);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.is-visible {
  transform: translate(-50%, 0);
}
.toast[hidden] {
  display: none;
}
.toast-text {
  font-size: 13.5px;
}
.toast-text strong {
  color: var(--white);
  font-weight: 600;
}
.toast-undo {
  flex: none;
  font-family: var(--font-condensed);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rail-accent);
  background: transparent;
  border: 1px solid var(--rail-line);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
}
.toast-undo:hover {
  background: var(--rail-2);
  border-color: var(--rail-muted);
}
.toast-undo:focus-visible {
  box-shadow: var(--focus-rail);
}

/* ============================================================
   NOSCRIPT
   ============================================================ */
.noscript {
  padding: 20px 34px;
  color: var(--st-blocked);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1160px) {
  .ledger-head,
  .item {
    grid-template-columns: 52px 128px minmax(0, 1fr) 92px 76px 80px;
    gap: 10px;
  }
}

@media (max-width: 1040px) {
  .ledger-head,
  .item {
    grid-template-columns: 48px 120px minmax(0, 1fr) 92px 80px;
  }
  .lh-priority,
  .item-priority {
    display: none;
  }
}

@media (max-width: 900px) {
  :root { --rail-w: 220px; }
  .masthead,
  .main { padding-left: 22px; padding-right: 22px; }
  .colophon { padding-left: 22px; padding-right: 22px; }
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--rail-edge);
    overflow-x: auto;
    overflow-y: hidden;
  }
  .rail-brand {
    padding-bottom: 0;
    border-bottom: 0;
    border-right: 1px solid var(--rail-line);
    padding-right: 14px;
    flex: none;
  }
  .brand-name { font-size: 21px; }
  .brand-sub { display: none; }

  .rail-nav {
    flex: 1;
    min-width: 0;
  }
  .rail-nav .rail-label { display: none; }
  .rail-counts {
    flex-direction: row;
    gap: 4px;
  }
  .rail-count {
    width: auto;
    grid-template-columns: 10px auto auto;
    gap: 7px;
    padding: 7px 9px;
    min-height: 44px;
    flex: none;
  }
  .rail-count-name { font-size: 12.5px; }
  .rail-count-num { min-width: 20px; padding: 0 5px; }
  .rail-foot { display: none; }

  .masthead { padding-top: 22px; }
  .masthead h1 { font-size: 32px; }
  .masthead-date { display: none; }

  .controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
  }
  .field-search { grid-column: 1 / -1; }

  .ledger-head { display: none; }

  .item {
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-areas:
      "num main"
      "num status"
      "num due"
      "action action";
    row-gap: 9px;
    padding: 14px 15px;
  }
  .item-num { grid-area: num; }
  .item-main { grid-area: main; }
  .item > .stamp { grid-area: status; }
  .item-due {
    grid-area: due;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .item-priority { display: none; }
  .item-action { grid-area: action; }  .btn-open {
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    font-size: 11.5px;
  }

  .sheet {
    width: 100vw;
    border-left: 0;
  }
}

@media (max-width: 560px) {
  .masthead { padding: 18px 16px 15px; }
  .main { padding: 16px 16px 30px; }
  .colophon { padding: 14px 16px 18px; }
  .masthead h1 { font-size: 27px; }
  .controls { padding: 13px; }
  .meta { grid-template-columns: minmax(0, 1fr); }
  .meta-cell { border-right: 0; }
  .meta-cell:nth-last-child(-n+2) { border-bottom: 1px solid var(--rule); }
  .meta-cell:last-child { border-bottom: 0; }
  .sheet-title { font-size: 25px; }
  .routing-stage { font-size: 9px; }
}


/* ============================================================
   MOTION PREFERENCES
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .sheet {
    transition: none;
  }
}
