/* kanban-wall — responsive wall display.
   Authored mobile-first; the 800×480 panel is now one case of the layout, not a
   fixed canvas. Same contract, same colours, same information hierarchy. */

:root {
  --bg: #101319;
  --panel: #161b24;
  --panel-2: #1b2130;
  --line: #242b3a;
  --text: #e7ebf3;
  --muted: #8a93a6;
  --dim: #5d6577;

  --ready: #4f8cff;
  --running: #2fc48d;
  --review: #a77bff;
  --blocked: #ef5b5b;
  --amber: #f0a63a;
  --live: #2fc48d;

  --pad: 8px;
  --gap: 8px;
  --card-title: 13px;
  --rail-w: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: #000; }

html, body {
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: #000;
  -webkit-text-size-adjust: 100%;
  user-select: none;
}

#fit { min-height: 100dvh; display: flex; justify-content: center; }

#stage {
  width: 100%;
  max-width: 2200px;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.page[hidden] { display: none; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ── header ──────────────────────────────────────────────────────── */
#hdr {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 6px var(--pad);
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  transition: background .5s ease, border-color .5s ease;
  position: sticky;
  top: 0;
  z-index: 5;
}

#stage[data-alert="red"] #hdr { background: linear-gradient(180deg, #3a1b1f, #241318); border-bottom-color: #6a2a31; }
#stage[data-alert="amber"] #hdr { background: linear-gradient(180deg, #3a2c15, #241d12); border-bottom-color: #6a522a; }

.board-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid #33507f;
  border-radius: 5px;
  background: rgba(79, 140, 255, .10);
  color: #dbe6ff;
  font-family: inherit;
  font-weight: 600;
  font-size: 12px;
  line-height: 1;
  letter-spacing: .09em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  max-width: 62vw;
  overflow: hidden;
  transition: background .15s ease, border-color .15s ease;
}
.board-pill span { overflow: hidden; text-overflow: ellipsis; }
.board-pill:hover, .board-pill:active { background: rgba(79, 140, 255, .22); border-color: #4f8cff; }
.board-pill svg { width: 9px; height: 6px; flex: 0 0 auto; fill: none; stroke: #8fb4ff; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.hdr-right { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-family: inherit;
  font-size: 10.5px;
  line-height: 1;
  letter-spacing: .06em;
  white-space: nowrap;
}
.pill .k { color: var(--muted); font-weight: 600; }
.pill .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.pill .glyph { font-size: 8px; line-height: 1; }

.pill[data-kind="blocked"] { border-color: #5c2626; background: rgba(239, 91, 91, .12); color: #ff9d9d; }
.pill[data-kind="blocked"] .k { color: #b06363; }
.pill[data-kind="blocked"] .glyph { color: var(--blocked); }

.pill[data-kind="ready"] { border-color: #5c4a24; background: rgba(240, 166, 58, .10); color: #f3c07a; }
.pill[data-kind="ready"] .k { color: #a9814a; }
.pill[data-kind="ready"].hot { border-color: #7a5a1f; background: rgba(240, 166, 58, .18); color: #ffcf8a; }

.pill.live { border-color: #234c3c; background: rgba(47, 196, 141, .10); color: #7ee3bd; }
.pill.live .k, .pill.live span { font-weight: 700; letter-spacing: .1em; font-size: 9.5px; }
.pill.live .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 0 rgba(47,196,141,.55); animation: breathe 2.4s ease-out infinite; }
.pill.live[data-state="stale"] { border-color: #5c4a24; background: rgba(240,166,58,.10); color: #f3c07a; }
.pill.live[data-state="stale"] .dot { background: var(--amber); animation: none; }
.pill.live[data-state="down"] { border-color: #5c2626; background: rgba(239,91,91,.12); color: #ff9d9d; }
.pill.live[data-state="down"] .dot { background: var(--blocked); animation: none; }

@keyframes breathe {
  0% { box-shadow: 0 0 0 0 rgba(47,196,141,.5); }
  70% { box-shadow: 0 0 0 5px rgba(47,196,141,0); }
  100% { box-shadow: 0 0 0 0 rgba(47,196,141,0); }
}

#clock {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 500;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#pollBar {
  position: absolute;
  left: 0; bottom: -1px;
  height: 1.5px;
  width: 0;
  background: linear-gradient(90deg, transparent, #4f8cff);
  opacity: .55;
}

/* ── body: mobile first — one column stack, rail after it ─────────── */
#body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: var(--pad);
}

#cols { display: grid; gap: var(--gap); grid-template-columns: 1fr; min-width: 0; }

.col {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  min-width: 0;
}
.col-hd {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  flex: 0 0 26px;
}
.col-hd .dot { width: 4px; height: 10px; border-radius: 1px; background: var(--c); }
.col-hd .lbl {
  font-family: inherit; font-weight: 700; font-size: 10px; line-height: 1;
  letter-spacing: .13em; color: #c3cada;
}
.col-hd .cnt {
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700; font-size: 11px; line-height: 1;
  color: var(--c);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 3px 5px;
  min-width: 18px;
  text-align: center;
}
.col[data-col="ready"] { --c: var(--ready); }
.col[data-col="running"] { --c: var(--running); }
.col[data-col="review"] { --c: var(--review); }
.col[data-col="blocked"] { --c: var(--blocked); }

.col-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}

.card {
  position: relative;
  flex: 0 0 auto;
  border-radius: 4px;
  background: #1d2431;
  border: 1px solid #2b3345;
  border-left: 3px solid var(--c);
  padding: 7px 8px 6px;
  overflow: hidden;
}
.card-title {
  font-family: inherit;
  font-weight: 500;
  font-size: var(--card-title);
  line-height: 1.32;
  color: #dfe5f0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.card-title .g { color: var(--c); font-weight: 700; margin-right: 2px; }
.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-size: 10px;
  line-height: 1;
  color: var(--dim);
  white-space: nowrap;
}
.chip {
  display: inline-block;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 2px 5px;
  border-radius: 3px;
  font-family: inherit;
  font-weight: 600;
  font-size: 9.5px;
  line-height: 1;
  letter-spacing: .04em;
  background: #262e3d;
  color: #9fb0cc;
  vertical-align: middle;
}
.chip.who[data-who="coder"] { background: rgba(79,140,255,.16); color: #9dc0ff; }
.chip.who[data-who="tester"] { background: rgba(167,123,255,.16); color: #c6aaff; }
.chip.who[data-who="analyst"] { background: rgba(47,196,141,.16); color: #8ce6c2; }
.chip.who[data-who="default"] { background: rgba(240,166,58,.14); color: #f0c384; }
.card-meta .age { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; color: #7f889b; }
.card[data-col="blocked"] .card-meta .age { color: #e08b8b; }

.col-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: #6b7488;
  font-family: inherit; font-weight: 600; font-size: 10.5px; line-height: 1;
  letter-spacing: .1em;
  text-align: center;
  padding: 10px 4px;
}

.col-more {
  flex: 0 0 auto;
  height: 22px;
  margin: 0 8px 8px;
  border-top: 1px dashed #2b3345;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: inherit; font-weight: 700; font-size: 9.5px; line-height: 1;
  letter-spacing: .1em;
  color: var(--muted);
}
.col-more[hidden] { display: none; }

/* ── stats rail ──────────────────────────────────────────────────── */
#rail { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.rail-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  min-width: 0;
}
.rail-k {
  font-family: inherit; font-weight: 700; font-size: 9px; line-height: 1.2;
  letter-spacing: .12em;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rail-big {
  font-family: inherit; font-weight: 300; font-size: 30px; line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: #eef2f9;
  margin-top: 5px;
}
.rail-big small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.rail-sub { margin-top: 3px; font-size: 9.5px; line-height: 1.25; color: var(--muted); letter-spacing: .04em; }
.rail-big.amber { color: var(--amber); }
.rail-big.red { color: var(--blocked); }

.who-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.who-row:first-of-type { margin-top: 9px; }
.who-name { font-family: inherit; font-weight: 600; font-size: 10px; line-height: 1; color: #a7b2c7; width: 52px; text-transform: capitalize; overflow: hidden; text-overflow: ellipsis; }
.who-bar { flex: 1; height: 4px; border-radius: 2px; background: #232a38; overflow: hidden; }
.who-bar i { display: block; height: 100%; background: linear-gradient(90deg, #3f6fc4, #6f9bf0); border-radius: 2px; }
.who-n {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700; font-size: 10px; line-height: 1;
  color: var(--muted); width: 14px; text-align: right; font-variant-numeric: tabular-nums;
}

/* ── picker ──────────────────────────────────────────────────────── */
#pickerPage { background: var(--bg); }
#pkHdr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px var(--pad);
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 3;
}
.pk-title {
  font-family: inherit; font-weight: 700; font-size: 11px; line-height: 1;
  letter-spacing: .18em; color: #cfd7e6;
}
.pk-hint { font-size: 10px; line-height: 1; color: var(--dim); letter-spacing: .06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill.close { margin-left: auto; cursor: pointer; border-color: #3a4356; color: #c3cada; background: #1d2431; flex: 0 0 auto; }
.pill.close:hover { border-color: #6a2a31; color: #ff9d9d; background: rgba(239,91,91,.12); }

#pkGrid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  align-content: start;
  min-height: 0;
}
.tile {
  border: 1px solid #2b3345;
  border-radius: 6px;
  background: var(--panel);
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  min-height: 92px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font-family: inherit;
  transition: background .12s ease, border-color .12s ease;
}
.tile:hover, .tile:active { background: var(--panel-2); border-color: #3f4b63; }
.tile[data-idle="1"] { opacity: .45; }
.tile[data-idle="1"]:hover { opacity: .8; }
.tile[data-active="1"] { border-color: #3f6fc4; background: rgba(79,140,255,.09); box-shadow: inset 0 0 0 1px rgba(79,140,255,.35); }
.tile-name {
  font-family: inherit; font-weight: 600; font-size: 12.5px; line-height: 1.3;
  color: #dbe2ef; letter-spacing: .02em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-slug {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 500; font-size: 9.5px; line-height: 1;
  color: #6b7488; margin-top: 4px; letter-spacing: .02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile-foot { display: flex; align-items: center; gap: 6px; }
.tile-open { font-family: inherit; font-weight: 700; font-size: 17px; line-height: 1; font-variant-numeric: tabular-nums; color: #cfd7e6; }
.tile-open.zero { color: #4a5265; }
.tile-lbl { font-family: inherit; font-weight: 600; font-size: 8.5px; line-height: 1; letter-spacing: .1em; color: #5f6879; }
.tile-blocked {
  margin-left: auto;
  font-family: inherit; font-weight: 700; font-size: 9px; line-height: 1; letter-spacing: .05em;
  color: #ef8b8b; background: rgba(239,91,91,.13); border-radius: 3px; padding: 3px 6px;
}
.tile-blocked[hidden] { display: none; }
.tile.all { border-style: dashed; }
.tile.all[data-active="1"] { border-style: solid; }

#pkFoot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 10px max(12px, env(safe-area-inset-bottom));
}
.pager {
  width: 44px; height: 34px;
  border: 1px solid #2b3345; border-radius: 5px;
  background: var(--panel); color: #a7b2c7;
  font-family: inherit; font-weight: 600; font-size: 15px; line-height: 1;
  cursor: pointer;
}
.pager:hover:not(:disabled) { border-color: #3f4b63; color: #fff; }
.pager:disabled { opacity: .3; cursor: default; }
#pkDots { display: flex; gap: 6px; align-items: center; }
#pkDots i { width: 6px; height: 6px; border-radius: 50%; background: #2b3345; }
#pkDots i.on { background: #4f8cff; }

/* ── phone: tighten the header, keep the three numbers ───────────── */
@media (max-width: 679px) {
  /* the phone already shows the time in its status bar */
  #clock { display: none; }
}

@media (max-width: 520px) {
  :root { --pad: 6px; --gap: 6px; }
  #hdr { min-height: 40px; padding: 5px var(--pad); }
  .pill[data-kind="ready"] .k { display: none; }
  .pill[data-kind="ready"] .v::before { content: "⏱ "; font-size: 9px; }
  #clock { font-size: 12px; }
  #rail { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .rail-big { font-size: 22px; }
  .rail-k { font-size: 8px; letter-spacing: .06em; }
  .rail-sub { font-size: 8.5px; }
  .board-pill { font-size: 11px; height: 26px; max-width: 46vw; }
}

/* ── tablet portrait / small laptop: two columns ─────────────────── */
@media (min-width: 680px) {
  :root { --card-title: 14px; --gap: 10px; }
  #cols { grid-template-columns: repeat(2, 1fr); }
  #pkGrid { grid-template-columns: repeat(2, 1fr); }
  .rail-big { font-size: 34px; }
}

/* ── desktop: the panel layout proper — 4 columns + rail ─────────── */
@media (min-width: 1024px) {
  #stage { height: 100dvh; min-height: 0; }
  #body { flex-direction: row; overflow: hidden; }
  #cols { flex: 1; grid-template-columns: repeat(4, 1fr); min-height: 0; }
  .col { min-height: 0; }
  .col-body { overflow-y: auto; scrollbar-width: thin; }
  .col-body::-webkit-scrollbar { width: 6px; }
  .col-body::-webkit-scrollbar-thumb { background: #2b3345; border-radius: 3px; }
  #rail { flex: 0 0 var(--rail-w); display: flex; flex-direction: column; min-height: 0; }
  #rail .rail-box:last-child { flex: 1; }
  .rail-big { font-size: 40px; }
  #pkGrid { grid-template-columns: repeat(3, 1fr); grid-auto-rows: minmax(104px, 1fr); }
}

/* ── large wall / TV: scale the type up, not the canvas ──────────── */
@media (min-width: 1500px) {
  :root { --card-title: 15px; --rail-w: 260px; --gap: 10px; --pad: 12px; }
  #hdr { min-height: 52px; padding: 8px var(--pad); }
  .board-pill { font-size: 14px; height: 32px; padding: 0 12px; }
  .pill { height: 28px; font-size: 12px; padding: 0 11px; }
  .pill.live .k, .pill.live span { font-size: 11px; }
  #clock { font-size: 15px; }
  .col-hd { height: 30px; flex: 0 0 30px; }
  .col-hd .lbl { font-size: 11px; }
  .col-hd .cnt { font-size: 12px; }
  .card { padding: 9px 10px 8px; }
  .card-meta { font-size: 11px; }
  .chip { font-size: 10.5px; }
  .col-empty { font-size: 12px; }
  .col-more { font-size: 11px; height: 26px; }
  .rail-k { font-size: 10px; }
  .rail-big { font-size: 52px; }
  .rail-sub { font-size: 11px; }
  .who-name, .who-n { font-size: 11px; }
  .who-name { width: 62px; }
  .tile-name { font-size: 15px; }
  .tile-open { font-size: 20px; }
}
