:root {
  color-scheme: dark;
  --bg: #090b0c;
  --panel: #131619;
  --panel-raised: #191d20;
  --line: #2a3035;
  --text: #f4f1e8;
  --muted: #8b9298;
  --signal: #ffca0a;
  --hot: #ff593d;
  --ok: #4dde80;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 80% 5%, rgba(255, 202, 10, 0.08), transparent 25rem),
    var(--bg);
}

.board-shell {
  min-height: 100dvh;
  padding: clamp(0.85rem, 1.4vw, 1.4rem);
  display: flex;
  flex-direction: column;
}

.board-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: clamp(0.75rem, 1.2vw, 1.1rem);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--signal);
  font-size: clamp(0.62rem, 0.8vw, 0.76rem);
  font-weight: 800;
  letter-spacing: 0.23em;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 3rem);
  line-height: 0.9;
  letter-spacing: -0.055em;
}

.connection {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.connection-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--hot);
  box-shadow: 0 0 0.75rem var(--hot);
}

.connection-dot.online { background: var(--ok); box-shadow: 0 0 0.75rem var(--ok); }
.agent-count { margin-left: 0.8rem; color: var(--text); }
.agent-count strong { color: var(--signal); }

.agent-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  grid-auto-rows: minmax(13.25rem, 1fr);
  gap: clamp(0.6rem, 1vw, 0.9rem);
  align-content: start;
  padding-top: clamp(0.75rem, 1.2vw, 1.1rem);
}

.agent-grid[hidden] { display: none; }

.agent-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 13.25rem;
  padding: clamp(0.8rem, 1.2vw, 1rem);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: linear-gradient(145deg, var(--panel-raised), var(--panel));
  animation: arrive 280ms ease-out both;
  transition: border-color 160ms ease, transform 160ms ease;
}

.agent-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.3rem;
  background: var(--signal);
}

@keyframes arrive {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

.agent-card:hover,
.agent-card:focus-within {
  border-color: #596168;
  transform: translateY(-0.1rem);
}

.agent-open {
  position: absolute;
  z-index: 1;
  inset: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.agent-open:focus-visible {
  border: 2px solid var(--signal);
  border-radius: 0.75rem;
  outline: none;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.agent-card h2 {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  font-size: clamp(1rem, 1.5vw, 1.4rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.agent-number {
  flex: none;
  padding-top: 0.15rem;
  color: var(--muted);
  font: 800 0.55rem/1 ui-monospace, monospace;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.status {
  width: 100%;
  margin-top: 0.55rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid #5b4b07;
  border-radius: 0.35rem;
  color: var(--signal);
  background: rgba(255, 202, 10, 0.07);
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.remove-agent {
  padding: 0.55rem 0.7rem;
  border: 1px solid #65352d;
  border-radius: 0.35rem;
  color: #ff9a88;
  background: rgba(255, 89, 61, 0.06);
  font: 800 0.65rem/1 ui-monospace, monospace;
  letter-spacing: 0.07em;
  cursor: pointer;
}

.remove-agent:hover,
.remove-agent:focus-visible {
  border-color: var(--hot);
  color: var(--text);
  background: rgba(255, 89, 61, 0.18);
  outline: none;
}

.remove-agent:disabled {
  cursor: wait;
  opacity: 0.55;
}

.task {
  display: -webkit-box;
  overflow: hidden;
  margin: 0.5rem 0 0;
  color: #c3c7c9;
  font-size: clamp(0.72rem, 0.85vw, 0.86rem);
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.runtime-profile {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: auto;
  margin-bottom: 0;
  padding: 0.55rem 0 0;
}

.runtime-stat {
  display: grid;
  grid-template-columns: minmax(3.8rem, auto) minmax(0, 1fr);
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
  padding: 0.3rem 0.45rem;
  border-inline: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.018);
}

.runtime-stat:first-child {
  border-top: 1px solid var(--line);
  border-radius: 0.4rem 0.4rem 0 0;
}

.runtime-stat:last-child {
  border-bottom: 1px solid var(--line);
  border-radius: 0 0 0.4rem 0.4rem;
}

.runtime-stat + .runtime-stat { border-top: 1px solid var(--line); }

.runtime-stat dt {
  margin: 0;
  color: var(--muted);
  font: 800 0.5rem/1 ui-monospace, monospace;
  letter-spacing: 0.1em;
}

.runtime-stat dd {
  margin: 0;
  color: var(--text);
  font: 700 clamp(0.64rem, 0.75vw, 0.76rem)/1.2 ui-monospace, monospace;
  overflow-wrap: anywhere;
  text-align: right;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.6rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
  color: #777f85;
  font: 700 0.52rem/1.2 ui-monospace, monospace;
}

.view-agent { color: var(--signal); white-space: nowrap; }

.agent-detail {
  width: min(60rem, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  padding: 0;
  border: 1px solid #444c52;
  border-radius: 0.85rem;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 2rem 6rem rgba(0, 0, 0, 0.65);
}

.agent-detail::backdrop { background: rgba(2, 4, 5, 0.82); backdrop-filter: blur(0.25rem); }

.detail-panel { padding: clamp(1.25rem, 3vw, 2.5rem); }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.detail-kicker,
.detail-section h3 {
  margin: 0 0 0.45rem;
  color: var(--signal);
  font: 800 0.65rem/1 ui-monospace, monospace;
  letter-spacing: 0.16em;
}

.detail-header h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 3.5rem); line-height: 1; }

.detail-close {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  color: var(--muted);
  background: transparent;
  font: 800 0.65rem/1 ui-monospace, monospace;
  cursor: pointer;
}

.detail-close:hover,
.detail-close:focus-visible { border-color: var(--text); color: var(--text); outline: none; }

.detail-status {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid #5b4b07;
  border-radius: 0.4rem;
  color: var(--signal);
  background: rgba(255, 202, 10, 0.07);
  font: 800 0.78rem/1.4 ui-monospace, monospace;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.detail-section { margin-top: 1.5rem; }
.detail-task { margin: 0; color: #d4d7d9; font-size: 1rem; line-height: 1.55; white-space: pre-wrap; }

.detail-profile,
.detail-data {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 1.5rem 0 0;
  padding: 1px;
  background: var(--line);
}

.detail-profile > div,
.detail-data > div { min-width: 0; padding: 0.85rem; background: var(--panel-raised); }
.detail-profile dt,
.detail-data dt { color: var(--muted); font: 800 0.58rem/1 ui-monospace, monospace; letter-spacing: 0.1em; }
.detail-profile dd,
.detail-data dd { margin: 0.45rem 0 0; font: 700 0.85rem/1.35 ui-monospace, monospace; overflow-wrap: anywhere; }
.detail-data { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0.75rem; }
.detail-empty { margin: 0.75rem 0 0; color: var(--muted); }

.detail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 700 0.65rem/1.2 ui-monospace, monospace;
}

.detail-remove { min-width: auto; }

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 55dvh;
  text-align: center;
}

.empty-state[hidden] { display: none; }
.empty-mark { color: var(--signal); font: 900 clamp(4rem, 10vw, 9rem)/0.8 ui-monospace, monospace; opacity: 0.9; }
.empty-state h2 { margin: 1rem 0 0.3rem; font-size: clamp(1.4rem, 3vw, 2.5rem); letter-spacing: -0.04em; }
.empty-state p { margin: 0 0 1rem; color: var(--muted); }
.empty-state code { padding: 0.55rem 0.75rem; border: 1px solid var(--line); border-radius: 0.35rem; color: var(--signal); background: var(--panel); }

@media (max-width: 600px) {
  .board-shell { padding: 0.9rem; }
  .board-header { align-items: flex-start; flex-direction: column; gap: 0.85rem; }
  .connection { width: 100%; }
  .agent-count { margin-left: auto; }
  .agent-grid { display: flex; flex-direction: column; }
  .agent-card { min-height: 13.25rem; }
  .task { -webkit-line-clamp: 3; }
  .runtime-stat { padding: 0.75rem 0.7rem; }
  .agent-detail { width: 100vw; max-height: 100dvh; height: 100dvh; border: 0; border-radius: 0; }
  .detail-profile,
  .detail-data { grid-template-columns: 1fr; }
}

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