@font-face {
  font-family: "Space Grotesk";
  src: url("assets/space-grotesk.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-display: swap;
}

:root {
  --paper: #f3efe4;
  --paper-raised: #fffdf6;
  --ink: #17211b;
  --muted: #59635d;
  --faint: #d8d3c7;
  --line: #bbb6aa;
  --lime: #c9f43b;
  --blue: #2947d9;
  --orange: #ef6b3a;
  --rose: #d93d69;
  --focus: #3657ff;
  --shadow: 8px 8px 0 var(--ink);
  --duration-fast: 140ms;
  --duration-panel: 260ms;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, transparent calc(100% - 1px), rgba(23, 33, 27, .055) 1px),
    linear-gradient(transparent calc(100% - 1px), rgba(23, 33, 27, .055) 1px),
    var(--paper);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
button { touch-action: manipulation; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  transform: translateY(-160%);
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper-raised);
  font-weight: 700;
}

.skip-link:focus { transform: translateY(0); }

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding: 16px clamp(20px, 4vw, 64px);
  border-bottom: 2px solid var(--ink);
  background: rgba(243, 239, 228, .94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand strong, .brand small, .shift-card small { display: block; }
.brand strong { font-size: 1.12rem; letter-spacing: .07em; line-height: 1.05; }
.brand small, .shift-card small { color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: .7rem; }

.shift-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 16px;
  border: 2px solid var(--ink);
  background: var(--paper-raised);
  font-family: "IBM Plex Mono", monospace;
  font-size: .78rem;
}

.signal-light {
  width: 16px;
  height: 16px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(201, 244, 59, .28);
}

main { max-width: 1440px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 64px) 64px; }

.hero {
  display: grid;
  grid-template-columns: minmax(330px, .88fr) minmax(500px, 1.12fr);
  gap: clamp(40px, 7vw, 110px);
  align-items: end;
  min-height: 352px;
  padding: 64px 0 50px;
}

.eyebrow {
  margin: 0 0 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1 {
  margin: 0;
  font-size: clamp(3.4rem, 6.3vw, 6.6rem);
  line-height: .82;
  letter-spacing: -.075em;
}

h1 span { color: var(--blue); font-family: "IBM Plex Mono", monospace; font-weight: 400; letter-spacing: -.11em; }
.intro { max-width: 460px; margin: 26px 0 0; color: var(--muted); font-size: 1.05rem; }

.network-map {
  position: relative;
  min-height: 225px;
  padding: 22px 24px;
  overflow: hidden;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper-raised);
  box-shadow: var(--shadow);
}

.map-heading, .status-overview {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-family: "IBM Plex Mono", monospace;
  font-size: .72rem;
  letter-spacing: .08em;
}

.status-overview { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 112px; }
.status-stat { display: flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.status-stat strong { color: var(--lime); font-size: 1.2rem; }
.status-stat span { color: #c4ccc7; }
.route-sketch { position: absolute; inset: 55px 18px auto; width: calc(100% - 36px); height: 126px; }
.route-sketch path { fill: none; stroke: var(--paper); stroke-width: 3; stroke-dasharray: 4 5; vector-effect: non-scaling-stroke; }
.route-sketch circle { fill: var(--lime); stroke: var(--ink); stroke-width: 2; vector-effect: non-scaling-stroke; }

.board { border-top: 2px solid var(--ink); }
.board-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 34px 0 24px; }
h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1; letter-spacing: -.045em; }
.results-count { margin: 0; font-family: "IBM Plex Mono", monospace; font-size: .8rem; }

.control-deck {
  display: grid;
  grid-template-columns: 1.6fr minmax(240px, .65fr);
  gap: 2px;
  border: 2px solid var(--ink);
  background: var(--ink);
  box-shadow: 6px 6px 0 rgba(23, 33, 27, .25);
}

.field { position: relative; background: var(--paper-raised); }
.field label {
  display: block;
  padding: 12px 16px 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.input-shell, .select-shell { position: relative; display: flex; align-items: center; }
.input-shell > svg { position: absolute; left: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.input-shell input, .select-shell select {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 650;
}

.input-shell input { padding: 8px 16px 12px 50px; }
.select-shell select { appearance: none; padding: 8px 46px 12px 16px; }
.input-shell input::placeholder { color: #6b746e; font-weight: 400; }
.input-shell input:focus, .select-shell select:focus { outline: 0; }
.input-shell:focus-within, .select-shell:focus-within { box-shadow: inset 0 0 0 3px var(--focus); }
.select-shell > svg { pointer-events: none; position: absolute; right: 16px; fill: none; stroke: currentColor; stroke-width: 2.5; }

.manifest-key, .task-item {
  display: grid;
  grid-template-columns: minmax(370px, 1.65fr) minmax(140px, .65fr) 120px minmax(140px, .7fr) 108px;
  gap: 16px;
  align-items: center;
}

.manifest-key {
  padding: 24px 18px 10px 50px;
  font-family: "IBM Plex Mono", monospace;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.manifest-key span:first-child { transform: translateX(-32px); }
.task-list { border-top: 2px solid var(--ink); }
.task-list:focus { outline: 0; }

.task-item {
  position: relative;
  min-height: 104px;
  padding: 16px 12px 16px 50px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 239, 228, .76);
  transition: background-color var(--duration-fast) ease;
}

.task-item:hover { background: var(--paper-raised); }
.rail-cell { position: absolute; top: 0; bottom: 0; left: 18px; width: 20px; }
.rail-line { position: absolute; top: 0; bottom: 0; left: 8px; width: 3px; background: var(--status-color); }
.rail-dot { position: absolute; z-index: 1; top: calc(50% - 8px); left: 1px; width: 18px; height: 18px; border: 3px solid var(--ink); border-radius: 50%; background: var(--status-color); }
.task-item:first-child .rail-line { top: 50%; }
.task-item:last-child .rail-line { bottom: 50%; }

.task-code, .task-project, .task-due, .task-assignee, .task-mobile-meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: .73rem;
}

.task-code { margin-bottom: 4px; color: var(--muted); text-transform: uppercase; }
.task-main h3 { max-width: 580px; margin: 0; font-size: 1.15rem; line-height: 1.23; letter-spacing: -.02em; }
.task-project { font-weight: 700; }
.task-due, .task-assignee { color: var(--muted); }
.task-mobile-meta { display: none; }

.open-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease;
}

.open-item svg, .close-button svg { fill: none; stroke: currentColor; stroke-width: 2; }
.open-item:hover, .open-item:active { background: var(--ink); color: var(--paper-raised); }

.task-item[data-status="todo"] { --status-color: var(--blue); }
.task-item[data-status="in-progress"] { --status-color: var(--lime); }
.task-item[data-status="blocked"] { --status-color: var(--rose); }
.task-item[data-status="done"] { --status-color: #727b76; }

.empty-state { margin-top: 30px; padding: 52px 24px; border: 2px dashed var(--ink); background: var(--paper-raised); text-align: center; }
.empty-state[hidden] { display: none; }
.empty-state h3 { margin: 4px 0; font-size: 1.8rem; }
.empty-state > p:not(.eyebrow) { margin: 0 auto 20px; color: var(--muted); }
.empty-symbol { display: flex; justify-content: center; align-items: center; height: 58px; margin-bottom: 20px; }
.empty-symbol span { width: 22px; height: 22px; margin: 0 -2px; border: 3px solid var(--ink); border-radius: 50%; background: var(--paper); }
.empty-symbol span:nth-child(2) { background: var(--orange); }

.button { min-height: 48px; padding: 10px 18px; border: 2px solid var(--ink); font-family: "IBM Plex Mono", monospace; font-weight: 700; }
.button-dark { background: var(--ink); color: var(--paper-raised); }
.button-dark:hover { background: var(--blue); }

footer:not(.route-control) {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 26px clamp(20px, 4vw, 64px);
  border-top: 2px solid var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: .66rem;
  letter-spacing: .08em;
}

.detail-dialog {
  width: min(760px, calc(100vw - 40px));
  max-height: calc(100dvh - 40px);
  margin: auto 20px auto auto;
  padding: 0;
  overflow: visible;
  border: 2px solid var(--ink);
  background: var(--paper-raised);
  color: var(--ink);
  box-shadow: -12px 12px 0 rgba(201, 244, 59, .8);
}

.detail-dialog::backdrop { background: rgba(12, 19, 15, .67); backdrop-filter: blur(3px); }
.detail-dialog[open] { animation: panel-in var(--duration-panel) cubic-bezier(.2, .75, .2, 1); }
@keyframes panel-in { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: translateX(0); } }
.detail-panel { max-height: calc(100dvh - 44px); overflow: auto; }

.detail-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  min-height: 88px;
  padding: 16px 22px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper-raised);
}

.detail-header .eyebrow { margin-bottom: 3px; }
.detail-status { margin: 0; font-size: .84rem; font-weight: 700; }
.close-button { display: grid; place-items: center; flex: 0 0 48px; width: 48px; height: 48px; border: 2px solid var(--ink); border-radius: 50%; background: var(--orange); color: var(--ink); }
.close-button:hover { background: var(--ink); color: var(--paper-raised); }

.ticket-body { padding: clamp(24px, 5vw, 48px); }
.project-label { margin: 0 0 10px; color: var(--blue); font-family: "IBM Plex Mono", monospace; font-size: .75rem; font-weight: 700; text-transform: uppercase; }
.ticket-title-block h2 { max-width: 640px; font-size: clamp(2.2rem, 5vw, 4.2rem); line-height: .96; }

.task-meta { display: grid; grid-template-columns: repeat(4, 1fr); margin: 42px 0; border: solid var(--ink); border-width: 2px 0; }
.task-meta div { min-width: 0; padding: 16px 12px; border-right: 1px solid var(--line); }
.task-meta div:first-child { padding-left: 0; }
.task-meta div:last-child { border-right: 0; }
.task-meta dt { font-family: "IBM Plex Mono", monospace; font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.task-meta dd { margin: 5px 0 0; font-size: .82rem; font-weight: 650; }

.briefing { max-width: 640px; }
.briefing .eyebrow { margin-bottom: 16px; }
.briefing p:not(.eyebrow) { margin: 0 0 16px; font-size: 1.05rem; line-height: 1.65; }
.briefing p:last-child { padding: 16px; border-left: 5px solid var(--lime); background: var(--paper); font-weight: 650; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 30px; }
.detail-tags span { padding: 7px 10px; border: 1px solid var(--ink); font-family: "IBM Plex Mono", monospace; font-size: .67rem; text-transform: uppercase; }

.route-control {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr minmax(230px, .65fr);
  gap: 24px;
  align-items: center;
  padding: 20px 24px;
  border-top: 2px solid var(--ink);
  background: var(--blue);
  color: #fff;
}

.route-copy p { margin: 0; }
.route-copy p:last-child { font-size: .82rem; }
.status-field { background: transparent; }
.status-field label { padding: 0 0 6px; color: #fff; }
.select-shell-light { background: #fff; color: var(--ink); }
.select-shell-light select { min-height: 50px; padding-block: 8px; }

.toast {
  position: fixed;
  z-index: 20;
  right: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 14px 18px;
  border: 2px solid var(--ink);
  background: var(--lime);
  color: var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: .78rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: opacity var(--duration-fast) ease, transform var(--duration-fast) ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; gap: 38px; padding-top: 48px; }
  .network-map { max-width: 760px; }
  .manifest-key { display: none; }
  .task-list { margin-top: 24px; }
  .task-item { grid-template-columns: minmax(280px, 1.4fr) minmax(130px, .6fr) 110px 96px; }
  .task-assignee { display: none; }
  .detail-dialog { width: min(720px, calc(100vw - 40px)); }
}

@media (max-width: 680px) {
  .masthead { min-height: 74px; padding: 12px 16px; }
  .brand svg { width: 40px; height: 40px; }
  .brand strong { font-size: .94rem; }
  .brand small { display: none; }
  .shift-card { min-height: 44px; padding: 6px 10px; }
  .shift-card small { display: none; }
  .signal-light { width: 13px; height: 13px; }
  main { padding: 0 16px 40px; }
  .hero { min-height: auto; padding: 44px 0 40px; }
  h1 { font-size: clamp(3.3rem, 17vw, 4.8rem); }
  .intro { margin-top: 22px; font-size: 1rem; }
  .network-map { min-height: 206px; padding: 18px 16px; box-shadow: 6px 6px 0 var(--ink); }
  .status-overview { grid-template-columns: repeat(2, 1fr); gap: 3px 16px; margin-top: 102px; }
  .status-stat { gap: 5px; }
  .status-stat strong { font-size: 1rem; }
  .route-sketch { inset-inline: 10px; width: calc(100% - 20px); }
  .board-head { display: block; padding: 30px 0 20px; }
  .results-count { margin-top: 12px; }
  .control-deck { grid-template-columns: 1fr; }
  .field label { padding-top: 10px; }
  .input-shell input, .select-shell select { min-height: 52px; }
  .task-list { margin-top: 22px; }
  .task-item {
    grid-template-columns: minmax(0, 1fr) 52px;
    gap: 12px;
    min-height: 120px;
    padding: 18px 8px 18px 42px;
    background: rgba(255, 253, 246, .7);
  }
  .rail-cell { left: 10px; }
  .task-project, .task-due, .task-assignee { display: none; }
  .task-main h3 { font-size: 1.08rem; }
  .task-mobile-meta { display: block; margin-top: 10px; color: var(--muted); }
  .open-item { width: 48px; padding: 0; }
  .open-item span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  footer:not(.route-control) { display: block; padding: 22px 16px; }
  footer:not(.route-control) span { display: block; }
  footer:not(.route-control) span + span { margin-top: 7px; }
  .detail-dialog {
    width: 100vw;
    max-width: none;
    max-height: 100dvh;
    height: 100dvh;
    margin: 0;
    border: 0;
    box-shadow: none;
  }
  .detail-panel { max-height: 100dvh; height: 100%; }
  .detail-header { min-height: 76px; padding: max(12px, env(safe-area-inset-top)) 16px 12px; }
  .ticket-body { padding: 30px 20px 46px; }
  .ticket-title-block h2 { font-size: clamp(2.15rem, 11vw, 3.3rem); }
  .task-meta { grid-template-columns: 1fr 1fr; margin: 32px 0; }
  .task-meta div { padding: 13px 10px; }
  .task-meta div:nth-child(2) { border-right: 0; }
  .task-meta div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .task-meta div:nth-child(3) { padding-left: 0; }
  .briefing p:not(.eyebrow) { font-size: 1rem; }
  .route-control { grid-template-columns: 1fr; gap: 12px; padding: 16px 20px max(16px, env(safe-area-inset-bottom)); }
  .route-copy p:last-child { display: none; }
  .toast { right: 16px; bottom: 16px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161c18;
    --paper-raised: #212923;
    --ink: #f4f0e5;
    --muted: #c0c8c1;
    --faint: #38433b;
    --line: #58645b;
    --focus: #a9bcff;
    --shadow: 8px 8px 0 #090c0a;
  }
  body { background-color: var(--paper); }
  .masthead { background: rgba(22, 28, 24, .95); }
  .brand svg path:not([fill="none"]) { fill: var(--ink); }
  .brand svg path[fill="none"] { stroke: var(--paper); }
  .network-map { background: #090c0a; }
  .control-deck { background: #090c0a; border-color: var(--ink); }
  .task-item { background: rgba(22, 28, 24, .8); }
  .task-item:hover { background: var(--paper-raised); }
  .input-shell input::placeholder { color: #aeb7b0; }
  .select-shell-light { background: #fff; color: #17211b; }
  .empty-symbol span { background: var(--paper-raised); }
  .detail-dialog::backdrop { background: rgba(0, 0, 0, .78); }
  .button-dark, .open-item:hover { background: var(--ink); color: var(--paper); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
