:root {
  --page: #f3f4f6;
  --surface: #ffffff;
  --lane: #e9ecf0;
  --border: #d7dce2;
  --ink: #15181c;
  --muted: #59626d;
  --late: #b42318;
  --ready-ink: #17603a;
  --ready-bg: #e2f2e8;
  --prep-ink: #454d57;
  --prep-bg: #eceef1;
  --warn-ink: #7a4300;
  --warn-bg: #fcefd3;
  --focus: #15181c;
  --font: "Geist", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

.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-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.bar-title { display: flex; align-items: baseline; gap: 10px; }
.bar h1 { margin: 0; font-size: 16px; font-weight: 600; }
.clock { margin: 0; color: var(--muted); font-size: 13px; }

.stats { margin: 0; display: flex; gap: 14px; color: var(--muted); font-size: 13px; }
.stats b { color: var(--ink); font-weight: 600; }
.stats .is-late, .stats .is-late b { color: var(--late); }

.bar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.btn:hover { background: #f1f3f5; border-color: #c5ccd4; }
.btn:disabled { color: #9aa1aa; cursor: default; background: var(--surface); border-color: var(--border); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #2a2f36; border-color: #2a2f36; }
.btn-primary:disabled { background: #6b727b; border-color: #6b727b; color: #fff; }
.btn-link { border-color: transparent; background: transparent; color: var(--muted); }
.btn-link:hover { background: transparent; border-color: transparent; color: var(--ink); text-decoration: underline; }

/* ---------- Board ---------- */

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 1fr);
  gap: 12px;
  align-items: start;
  padding: 16px;
  overflow-x: auto;
}

.lane {
  background: var(--lane);
  border-radius: 10px;
  padding: 10px;
  min-height: 220px;
}

.lane-head { display: flex; align-items: center; gap: 10px; padding: 2px 2px 10px; }
.lane-title { min-width: 0; flex: 1; }
.lane-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.lane-head p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }

.avatar {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.count { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.lane-list { list-style: none; margin: 0; padding: 0; min-height: 60px; }

.lane-foot { margin: 8px 2px 0; font-size: 12px; color: var(--muted); }

.empty {
  padding: 18px 8px;
  border: 1px dashed #c3cad3;
  border-radius: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.drop-marker {
  height: 0;
  margin: 2px 0 6px;
  border-top: 2px solid var(--ink);
  border-radius: 1px;
}

/* ---------- Cards ---------- */

.card {
  margin: 0 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: grab;
  transition: opacity 120ms ease, background-color 1.2s ease;
}
.card:active { cursor: grabbing; }
.card.is-dragging { opacity: 0.35; }
.card.is-lifted { border-color: var(--ink); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }
.card.is-new { background: #fff7d6; }

.grab { padding: 9px 11px 0; border-radius: 8px 8px 0 0; }
.grab:focus-visible { outline-offset: 0; }
@supports selector(:has(a)) {
  .grab:focus-visible { outline: none; }
  .card:has(.grab:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
}

.c-top { display: flex; align-items: baseline; gap: 8px; }
.c-ref { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.c-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.c-line { font-size: 12px; color: var(--muted); }

.c-foot { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 11px; }
.c-eta { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.c-eta.is-unknown { color: #697079; font-weight: 500; }
.c-eta.is-late { color: var(--late); }

.chip {
  margin-left: auto;
  white-space: nowrap;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
}
.chip-ready { color: var(--ready-ink); background: var(--ready-bg); }
.chip-preparing { color: var(--prep-ink); background: var(--prep-bg); }
.chip-attention { color: var(--warn-ink); background: var(--warn-bg); }

.c-note { margin: -2px 11px 9px; font-size: 12px; font-weight: 500; color: var(--warn-ink); }
.c-note.is-late { color: var(--late); }

.c-menu {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.c-menu svg { fill: currentColor; }
.c-menu:hover, .c-menu[aria-expanded="true"] { background: #eef0f3; color: var(--ink); }

/* ---------- Menu ---------- */

.menu {
  position: fixed;
  z-index: 20;
  min-width: 190px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.menu [role="menuitem"] {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.menu [role="menuitem"]:hover, .menu [role="menuitem"]:focus { background: #f0f2f4; outline: none; }
.menu [role="menuitem"]:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.menu [role="separator"] { height: 1px; margin: 4px 2px; background: var(--border); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 32px);
  padding: 10px 12px 10px 14px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transform: translateX(-50%);
}
.toast[hidden] { display: none; }
.toast-undo {
  border: 0;
  background: transparent;
  color: #fff;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 2px 4px;
}
.toast-undo:focus-visible { outline-color: #fff; }

.load-error { margin: 24px 16px; color: var(--late); }

/* ---------- Small screens: one lane per swipe ---------- */

@media (max-width: 720px) {
  .bar { gap: 8px 12px; }
  .bar-actions { margin-left: 0; width: 100%; }
  .board {
    grid-auto-columns: 86%;
    scroll-snap-type: x mandatory;
    scroll-padding: 16px;
  }
  .lane { scroll-snap-align: start; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
}
