/* ============================================================
   Relay Robotics design system, copied from relay-applications-v2
   apps/admin-portal/src/styles/relay-theme.css with its `.relay-app`
   scoping prefix stripped (this app is Relay-styled throughout, so
   the tokens live on body instead). Dark mode binds to the `.dark`
   class on <html>, same as the portals. App-specific additions
   belong in app.css, not here — keep this file re-syncable.
   ============================================================ */

body {
  /* ---------- Brand: Relay Blue scale ---------- */
  --relay-50:  #ecf8fd;
  --relay-100: #cfeefa;
  --relay-200: #9eddf4;
  --relay-300: #5cc6eb;
  --relay-400: #2bb2e0;
  --relay-500: #00a0db;
  --relay-600: #0086c0;
  --relay-700: #006bb6;
  --relay-800: #005691;
  --relay-900: #084772;
  --relay-950: #052a47;

  /* ---------- Accent green ---------- */
  --mint-50:  #ecf8ed;
  --mint-100: #d3efd6;
  --mint-200: #a8dfae;
  --mint-300: #6fcb78;
  --mint-400: #4ec05a;
  --mint-500: #39b54a;
  --mint-600: #2c9a3b;
  --mint-700: #237c30;

  /* ---------- Warm ink neutrals ---------- */
  --ink-50:  #f8fafc;
  --ink-100: #f1f5f9;
  --ink-200: #e2e8f0;
  --ink-300: #cbd5e1;
  --ink-400: #94a3b8;
  --ink-500: #64748b;
  --ink-600: #475569;
  --ink-700: #334155;
  --ink-800: #1e293b;
  --ink-900: #0f172a;
  --ink-950: #050a17;

  /* ---------- Type families (font CSS vars supplied by next/font) ---------- */
  --relay-font-sans: var(--font-relay-sans, "Inter", ui-sans-serif, system-ui, sans-serif);
  --relay-font-serif: var(--font-relay-serif, "Instrument Serif", ui-serif, Georgia, serif);
  --relay-font-mono: var(--font-relay-mono, "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace);

  /* ---------- Motion ---------- */
  --ease-out-soft: cubic-bezier(.2, .7, .2, 1);

  font-family: var(--relay-font-sans);
  color: var(--ink-900);
  background: #fff;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}

body, body * { box-sizing: border-box; }

/* ---------- Eyebrow micro-label ---------- */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px; border-radius: 9999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--relay-50); color: var(--relay-700);
  box-shadow: inset 0 0 0 1px var(--relay-100);
}
.eyebrow::before {
  content:""; width:4px; height:4px; border-radius:9999px;
  background:currentColor; opacity:.75;
}
.eyebrow.ink { background: var(--ink-100); color: var(--ink-700); box-shadow: inset 0 0 0 1px var(--ink-200); }
.eyebrow.warn { background: #fff5e6; color: #b45309; box-shadow: inset 0 0 0 1px #fde4b8; }
.eyebrow.danger { background: #fef2f2; color: #b91c1c; box-shadow: inset 0 0 0 1px #fecaca; }

.eyebrow.live {
  background: var(--mint-50);
  color: var(--mint-700);
  box-shadow: inset 0 0 0 1px var(--mint-100);
}
.eyebrow.live::before {
  background: var(--mint-500);
  opacity: 1;
  animation: relay-live-pulse 1.6s ease-in-out infinite;
}
@keyframes relay-live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(57, 181, 74, 0.6); }
  100% { box-shadow: 0 0 0 6px rgba(57, 181, 74, 0); }
}

.eyebrow.paused {
  background: var(--ink-100);
  color: var(--ink-600);
  box-shadow: inset 0 0 0 1px var(--ink-200);
}
.eyebrow.paused::before { opacity: 0.5; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 9999px;
  border: 0;
  font-family: inherit;
  font-size: 13px; font-weight: 600;
  transition: all 200ms var(--ease-out-soft);
  white-space: nowrap;
  cursor: pointer;
}
.btn:disabled { cursor: not-allowed; }
.btn-primary { background: var(--relay-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--relay-700); }
.btn-primary:disabled { background: var(--ink-300); color: var(--ink-500); }
.btn-secondary { background: #fff; color: var(--ink-900); box-shadow: inset 0 0 0 1px var(--ink-200); }
.btn-secondary:hover:not(:disabled) { box-shadow: inset 0 0 0 1px var(--relay-300); color: var(--relay-700); }
.btn-secondary:disabled { opacity: 0.5; }
.btn-ghost { background: transparent; color: var(--ink-700); padding: 8px 12px; }
.btn-ghost:hover:not(:disabled) { background: var(--ink-100); color: var(--ink-900); }
.btn-danger { background: #fff; color: #b91c1c; box-shadow: inset 0 0 0 1px #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; width: 32px; height: 32px; border-radius: 8px; }

/* ---------- Inputs ---------- */
.input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--ink-200);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink-900);
  transition: border-color 200ms var(--ease-out-soft), box-shadow 200ms var(--ease-out-soft);
}
.input:hover { border-color: var(--ink-300); }
.input:focus { outline: none; border-color: var(--relay-400); box-shadow: 0 0 0 3px rgba(0,160,219,0.15); }
.input.mono { font-family: var(--relay-font-mono); font-size: 13px; }
.input-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-500);
  margin-bottom: 6px;
}

.pin-input {
  width: 100%;
  font-family: var(--relay-font-mono);
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--ink-200);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-900);
}
.pin-input:focus { outline: none; border-color: var(--relay-400); box-shadow: 0 0 0 2px rgba(0,160,219,0.15); }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
}
.card-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ink-200);
}
.card-title {
  font-size: 14px; font-weight: 600; color: var(--ink-900);
  display: flex; align-items: center; gap: 10px;
}
.card-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.card-body { padding: 20px; }

/* ---------- Status pill ---------- */
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 9999px;
  font-size: 12px; font-weight: 600;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--ink-200);
  color: var(--ink-700);
}
.status-pill .led {
  width: 8px; height: 8px; border-radius: 9999px;
  background: var(--ink-400);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}
.status-pill.connected { color: var(--mint-700); background: var(--mint-50); box-shadow: inset 0 0 0 1px var(--mint-100); }
.status-pill.connected .led { background: var(--mint-500); box-shadow: 0 0 0 3px rgba(57,181,74,0.18), 0 0 8px rgba(57,181,74,0.6); animation: relay-led-pulse 2s ease-in-out infinite; }
.status-pill.connecting { color: #b45309; background: #fff7ec; box-shadow: inset 0 0 0 1px #fde4b8; }
.status-pill.connecting .led { background: #f59e0b; animation: relay-led-pulse 1s ease-in-out infinite; }
.status-pill.error { color: #b91c1c; background: #fef2f2; box-shadow: inset 0 0 0 1px #fecaca; }
.status-pill.error .led { background: #dc2626; }

@keyframes relay-led-pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ---------- Segmented (Board / Raw / Split) ---------- */
.segmented {
  display: inline-flex;
  background: var(--ink-100);
  border-radius: 9999px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: 9999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-600);
  transition: all 200ms var(--ease-out-soft);
  cursor: pointer;
}
.segmented button.active {
  background: #fff;
  color: var(--ink-900);
  box-shadow: 0 1px 2px rgba(15,23,42,0.06), 0 0 0 1px var(--ink-200);
}
.segmented button:hover:not(.active) { color: var(--ink-900); }

/* ---------- Toggle switch ---------- */
.toggle {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 500; color: var(--ink-700);
  cursor: pointer;
}
.toggle input { display: none; }
.toggle-track {
  width: 36px; height: 20px;
  background: var(--ink-300);
  border-radius: 9999px;
  position: relative;
  transition: background 200ms var(--ease-out-soft);
  display: inline-block;
}
.toggle-track::after {
  content:""; position: absolute; top:2px; left:2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 9999px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 200ms var(--ease-out-soft);
}
.toggle input:checked + .toggle-track { background: var(--relay-500); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* ---------- Mono / code ---------- */
.mono { font-family: var(--relay-font-mono); }
.code-block {
  font-family: var(--relay-font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  border-radius: 12px;
  padding: 16px;
  color: var(--ink-800);
  white-space: pre;
  overflow: auto;
}

/* ---------- Code editor with syntax highlighting ---------- */
.code-editor {
  transition: border-color 200ms var(--ease-out-soft), box-shadow 200ms var(--ease-out-soft);
}
.code-editor:focus-within {
  border-color: var(--relay-400);
  box-shadow: 0 0 0 3px rgba(0,160,219,0.15);
}
.code-editor[data-disabled] { opacity: 0.6; }
.code-editor .tok-string    { color: var(--mint-700); }
.code-editor .tok-number    { color: var(--relay-700); }
.code-editor .tok-keyword   { color: var(--relay-800); font-weight: 600; }
.code-editor .tok-property  { color: var(--relay-800); }
.code-editor .tok-punctuation { color: var(--ink-500); }
.code-editor .tok-comment   { color: var(--ink-500); font-style: italic; }
.code-editor .tok-builtin   { color: var(--relay-600); }
.code-editor .tok-variable  { color: var(--mint-700); }

.dark .code-editor {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.10);
}
.dark .code-editor:focus-within {
  border-color: var(--relay-400);
  box-shadow: 0 0 0 3px rgba(0,160,219,0.25);
}
.dark .code-editor .code-editor-pre { color: #cfeefa; }
.dark .code-editor .code-editor-textarea { caret-color: #fff; }
.dark .code-editor .tok-string    { color: var(--mint-300); }
.dark .code-editor .tok-number    { color: var(--relay-300); }
.dark .code-editor .tok-keyword   { color: #5cc6eb; }
.dark .code-editor .tok-property  { color: #9eddf4; }
.dark .code-editor .tok-punctuation { color: rgba(207,238,250,0.55); }
.dark .code-editor .tok-comment   { color: rgba(207,238,250,0.45); font-style: italic; }
.dark .code-editor .tok-builtin   { color: var(--relay-300); }
.dark .code-editor .tok-variable  { color: var(--mint-300); }

/* ---------- Section labels ---------- */
.section-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-500);
  margin-bottom: 10px;
}
.section-label::after {
  content:""; flex:1; height: 1px; background: var(--ink-200);
}

/* ---------- Scrollbars ---------- */
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 9999px; border: 2px solid #fff; }
.scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }
.scroll::-webkit-scrollbar-track { background: transparent; }

/* ---------- Workspace layout ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  padding: 20px 28px 80px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}
@media (max-width: 1200px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
}
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- Connection bar ---------- */
.conn-bar {
  background: linear-gradient(180deg, #fff 0%, var(--ink-50) 100%);
  border: 1px solid var(--ink-200);
  border-radius: 16px;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr auto auto auto;
  gap: 12px;
  align-items: end;
}
@media (max-width: 720px) {
  .conn-bar { grid-template-columns: 1fr; }
}

/* ---------- Board info strip ---------- */
.board-info {
  display: flex;
  flex-wrap: wrap;
  background: linear-gradient(180deg, #fff 0%, var(--ink-50) 100%);
  border: 1px solid var(--ink-200);
  border-radius: 12px;
  padding: 10px 4px;
  /* Match the height of the populated strip so the empty/loading state
     reserves space and the cells don't pop in once the banner lands. */
  min-height: 64px;
  box-sizing: border-box;
}
.board-info-cell {
  flex: 1 1 auto;
  min-width: 140px;
  padding: 4px 18px;
  border-right: 1px solid var(--ink-200);
  min-width: 0;
}
.board-info-cell:last-child {
  border-right: none;
}
.board-info-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-500);
  margin-bottom: 3px;
}
.board-info-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-info-value.mono {
  font-family: var(--relay-font-mono);
  font-size: 12px;
}
.board-info--empty {
  align-items: center;
  justify-content: center;
  color: var(--ink-500);
  font-size: 13px;
  padding: 18px 20px;
}

/* ---------- Chip tag ---------- */
.chip-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--relay-font-mono);
  font-size: 11px;
  font-weight: 500;
  background: var(--relay-50);
  color: var(--relay-700);
  box-shadow: inset 0 0 0 1px var(--relay-100);
}
.chip-tag.muted { background: var(--ink-100); color: var(--ink-600); box-shadow: inset 0 0 0 1px var(--ink-200); }

/* ---------- Virtual board ---------- */
.vboard {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(8,71,114,0.04), rgba(8,71,114,0.02));
  border: 1px solid var(--ink-200);
}
.vboard-inner {
  padding: 24px;
  background-image:
    linear-gradient(rgba(0,160,219,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,160,219,0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}
.vboard-row {
  display: flex; flex-direction: column; gap: 4px;
  border-radius: 10px;
  border: 1px solid var(--ink-200);
  padding: 10px 12px;
  background: #fff;
}

/* ---------- LED ---------- */
.led {
  width: 12px; height: 12px;
  border-radius: 9999px;
  background: var(--ink-300);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.2), 0 0 0 2px rgba(0,0,0,0.04);
  transition: all 200ms var(--ease-out-soft);
  flex-shrink: 0;
  display: inline-block;
}
.led.on {
  background: var(--mint-500);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.1), 0 0 0 2px rgba(57,181,74,0.18), 0 0 12px rgba(57,181,74,0.7);
}
.led.on.amber {
  background: #f59e0b;
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.1), 0 0 0 2px rgba(245,158,11,0.18), 0 0 12px rgba(245,158,11,0.7);
}
.led.on.blue {
  background: var(--relay-500);
  box-shadow: inset 0 1px 1px rgba(0,0,0,0.1), 0 0 0 2px rgba(0,160,219,0.18), 0 0 12px rgba(0,160,219,0.7);
}

/* ---------- Push button (board) ---------- */
.push-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 80px; height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff 0%, var(--ink-50) 100%);
  border: 1px solid var(--ink-200);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ink-700);
  text-transform: uppercase;
}
.push-btn.pressed {
  transform: translateY(1px);
  background: var(--relay-500);
  border-color: var(--relay-600);
  color: #fff;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* ---------- Door status ---------- */
.door-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--ink-100);
  color: var(--ink-700);
  font-family: var(--relay-font-mono);
}

/* ---------- Empty state ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed var(--ink-300);
  border-radius: 16px;
  background: var(--ink-50);
  color: var(--ink-500);
}

/* ---------- Errors drawer ---------- */
.errors-drawer {
  background: #fff;
  border-top: 1px solid var(--ink-200);
  box-shadow: 0 -10px 30px -12px rgba(15,23,42,0.12);
  border-radius: 14px;
  /* Match the workspace's content-area width: 1600px max minus 28px
     padding on each side (see .workspace). Keeps the drawer's
     left/right edges aligned with the cards on wide screens. */
  max-width: calc(1600px - 56px);
  width: calc(100% - 56px);
  margin: 0 auto 28px;
}
.errors-drawer.collapsed .errors-drawer-body { display: none; }
.errors-drawer-header {
  height: 44px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  cursor: pointer;
  user-select: none;
  color: var(--ink-900);
}
.errors-drawer-body {
  max-height: 240px;
  overflow-y: auto;
  padding: 0 20px 16px;
}
.error-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--ink-100);
  font-size: 13px;
  align-items: center;
}
.error-row .ts { font-family: var(--relay-font-mono); font-size: 11px; color: var(--ink-500); }
.error-row .level {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: 4px;
  text-transform: uppercase;
}
.error-row .level.err { background: #fef2f2; color: #b91c1c; }
.error-row .level.warn { background: #fff7ec; color: #b45309; }
.error-row .level.info { background: var(--relay-50); color: var(--relay-700); }

/* ---------- Diag stream (raw view) ---------- */
.diag-stream {
  font-family: var(--relay-font-mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--ink-950);
  color: #cfeefa;
  border-radius: 12px;
  padding: 14px 16px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* ---------- Spinner ---------- */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--ink-200);
  border-top-color: var(--relay-500);
  border-radius: 9999px;
  animation: relay-spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes relay-spin { to { transform: rotate(360deg); } }

.muted { color: var(--ink-500); }

/* ---------- Data table ---------- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-500);
  padding: 10px 14px;
  border-bottom: 1px solid var(--ink-200);
  background: var(--ink-50);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--ink-100);
  color: var(--ink-800);
  vertical-align: middle;
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}
.data-table tbody tr:hover td {
  background: var(--ink-50);
}
.data-table .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}
.data-table .row-revoked td:not(.col-actions) {
  opacity: 0.55;
}

/* Grouped rows: two <tr>s per record share a <tbody>. The main row carries
   the primary data; the scope row tucks underneath as a compact strip of
   supporting metadata. No divider between the two — they read as one unit
   — and a heavier divider at the bottom of each <tbody> separates one key
   from the next. */
.data-table-grouped tbody tr.row-main td {
  border-bottom: none;
  padding-bottom: 6px;
}
.data-table-grouped tbody tr.row-scope td {
  padding: 6px 14px 8px;
  background: transparent;
  border-top: 1px solid var(--ink-200);
  border-bottom: 2px solid var(--ink-300);
  box-shadow: inset 3px 0 0 var(--ink-300);
}
.data-table-grouped tbody:last-child tr.row-scope td {
  border-bottom: none;
}
.data-table-grouped tbody:hover tr.row-main td,
.data-table-grouped tbody:hover tr.row-scope td {
  background: var(--ink-50);
}

.dark .data-table-grouped tbody tr.row-scope td {
  background: transparent;
  border-top-color: rgba(255,255,255,0.08);
  border-bottom-color: rgba(255,255,255,0.16);
  box-shadow: inset 3px 0 0 rgba(255,255,255,0.18);
}
.dark .data-table-grouped tbody:hover tr.row-main td,
.dark .data-table-grouped tbody:hover tr.row-scope td {
  background: rgba(255,255,255,0.04);
}

.table-wrapper {
  overflow: auto;
  border: 1px solid var(--ink-200);
  border-radius: 12px;
  background: #fff;
}

.dark .data-table thead th {
  background: rgba(255,255,255,0.04);
  border-bottom-color: rgba(255,255,255,0.10);
  color: rgba(207,238,250,0.55);
}
.dark .data-table tbody td {
  border-bottom-color: rgba(255,255,255,0.06);
  color: #cfeefa;
}
.dark .data-table tbody tr:hover td {
  background: rgba(255,255,255,0.03);
}
.dark .table-wrapper {
  background: rgba(255,255,255,0.02);
  border-color: rgba(255,255,255,0.10);
}

/* ---------- Page header (workspace top strip) ---------- */
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 28px 8px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}
.page-header-titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.page-header-title {
  font-family: var(--relay-font-sans);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink-900);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
}
.page-header-subtitle {
  font-size: 13px;
  color: var(--ink-500);
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}
.dark .page-header-title { color: #fff; }
.dark .page-header-subtitle { color: rgba(207,238,250,0.55); }

/* ---------- Single-column workspace variant (full-width cards) ---------- */
.workspace.single {
  grid-template-columns: minmax(0, 1fr);
}

/* ---------- Modal / confirm dialog ---------- */
.relay-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 24px;
  animation: relay-modal-fade-in 180ms var(--ease-out-soft);
}
@keyframes relay-modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.relay-modal {
  background: #fff;
  border: 1px solid var(--ink-200);
  border-radius: 16px;
  box-shadow: 0 30px 80px -16px rgba(15, 23, 42, 0.35);
  max-width: 480px;
  width: 100%;
  padding: 24px;
  animation: relay-modal-pop-in 220ms var(--ease-out-soft);
  /* Cap to viewport so tall content scrolls inside the modal instead of
     extending past the top/bottom of the screen. */
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.relay-modal.relay-modal-wide { max-width: 720px; }

.relay-modal-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
@keyframes relay-modal-pop-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.relay-modal-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.relay-modal-body {
  font-size: 14px;
  color: var(--ink-700);
  line-height: 1.55;
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

.relay-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  flex-shrink: 0;
}

/* ---------- Save dialog ---------- */
.save-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.save-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--ink-200);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 120ms var(--ease-out-soft), background 120ms var(--ease-out-soft);
}
.save-option:hover { border-color: var(--ink-300); }
.save-option.disabled { opacity: 0.55; cursor: not-allowed; }
.save-option input[type='checkbox'] {
  margin-top: 2px;
  accent-color: var(--relay-500);
}
.save-option-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-900);
}
.save-option-hint {
  font-size: 12px;
  color: var(--ink-500);
  margin-top: 2px;
}

.save-step-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.save-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--ink-500);
}
.save-step.active { color: var(--ink-900); font-weight: 500; }
.save-step.done { color: var(--mint-700); }
.save-step-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.save-step.done .save-step-icon { color: var(--mint-600); }
.save-step.pending .save-step-icon { color: var(--ink-300); }

.save-result {
  text-align: center;
  padding: 4px 0;
}
.save-result p { margin: 8px 0 0; }
.save-result-icon {
  width: 48px;
  height: 48px;
  border-radius: 9999px;
  margin: 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
}
.save-result-icon.success {
  background: rgba(57, 181, 74, 0.15);
  color: var(--mint-700);
}
.save-result-icon.failure {
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
}
.save-result-icon.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.save-warnings {
  list-style: none;
  margin: 8px 0 0;
  padding: 10px 12px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  text-align: left;
  font-size: 12px;
}
.save-warnings .save-error-item + .save-error-item {
  border-top: 1px solid rgba(245, 158, 11, 0.18);
}
.save-warning-line {
  color: #b45309;
  font-weight: 600;
  font-family: var(--relay-font-mono);
  white-space: nowrap;
}

/* ---------- Relays grid ---------- */
.relays-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}
.relays-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  border-radius: 8px;
  min-width: 0;
}
.relays-cell-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}
.relays-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-800);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.relays-pin {
  font-family: var(--relay-font-mono);
  color: var(--ink-500);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.relays-pin.primary {
  color: var(--ink-700);
  font-size: 12px;
}
.relays-count {
  font-weight: 600;
  font-family: var(--relay-font-mono);
  color: var(--relay-700);
  font-size: 13px;
  white-space: nowrap;
}

.save-errors {
  list-style: none;
  margin: 8px 0 0;
  padding: 10px 12px;
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.20);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  text-align: left;
  font-size: 12px;
}
.save-error-item {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  align-items: baseline;
}
.save-error-item + .save-error-item {
  border-top: 1px solid rgba(220, 38, 38, 0.12);
}
.save-error-line {
  color: #b91c1c;
  font-weight: 600;
  font-family: var(--relay-font-mono);
  white-space: nowrap;
}

.save-raw-details {
  margin-top: 12px;
  text-align: left;
  font-size: 12px;
}
.save-raw-details summary {
  cursor: pointer;
  color: var(--ink-600);
  user-select: none;
  padding: 4px 0;
}
.save-raw-details summary:hover { color: var(--ink-800); }
.save-raw-output {
  margin: 6px 0 0;
  padding: 10px 12px;
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  border-radius: 8px;
  font-family: var(--relay-font-mono);
  font-size: 11px;
  color: var(--ink-700);
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Dirty banner ---------- */
.dirty-banner {
  margin-bottom: 16px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fff7ec;
  color: #b45309;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #fde4b8;
}

/* ============================================================
   DARK THEME — bound to the existing `.dark` class on <html>.
   Mirrors the design's [data-theme="dark"] block but scoped
   under .dark so the existing topbar dark toggle works.
   ============================================================ */

.dark {
  background: var(--ink-950);
  color: #cfeefa;
}

.dark .card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: none;
  color: #cfeefa;
}
.dark .card-header { border-bottom: 1px solid rgba(255,255,255,0.08); }
.dark .card-title { color: #fff; }

.dark .input,
.dark .pin-input,
.dark .code-block,
.dark textarea.code-block {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.10);
  color: #cfeefa;
}
.dark .input:focus,
.dark .pin-input:focus {
  border-color: var(--relay-400);
  box-shadow: 0 0 0 3px rgba(0,160,219,0.25);
}
.dark .input-label { color: #5cc6eb; }

.dark .btn-secondary {
  background: rgba(255,255,255,0.04);
  color: #cfeefa;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.dark .btn-secondary:hover:not(:disabled) {
  box-shadow: inset 0 0 0 1px var(--relay-400);
  color: #fff;
}
.dark .btn-primary { background: var(--relay-500); color: #fff; }
.dark .btn-primary:hover:not(:disabled) { background: var(--relay-400); }
.dark .btn-ghost { color: #cfeefa; }
.dark .btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.06); color: #fff; }
.dark .btn-danger { background: rgba(220,38,38,0.10); color: #fca5a5; box-shadow: inset 0 0 0 1px rgba(220,38,38,0.30); }
.dark .btn-danger:hover:not(:disabled) { background: rgba(220,38,38,0.18); }

.dark .segmented { background: rgba(255,255,255,0.05); }
.dark .segmented button { color: #94a3b8; }
.dark .segmented button.active {
  background: rgba(0,160,219,0.18);
  color: #fff;
  box-shadow: inset 0 0 0 1px var(--relay-500);
}
.dark .segmented button:hover:not(.active) { color: #fff; }

.dark .section-label { color: #5cc6eb; }
.dark .section-label::after { background: rgba(255,255,255,0.08); }

.dark .chip-tag {
  background: rgba(0,160,219,0.12);
  color: #5cc6eb;
  box-shadow: inset 0 0 0 1px rgba(0,160,219,0.25);
}
.dark .chip-tag.muted {
  background: rgba(255,255,255,0.05);
  color: #94a3b8;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}

.dark .conn-bar {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.10);
}

.dark .board-info {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.10);
}
.dark .board-info-cell { border-right-color: rgba(255,255,255,0.08); }
.dark .board-info-label { color: rgba(207,238,250,0.55); }
.dark .board-info-value { color: #e6f5fc; }
.dark .board-info--empty { color: rgba(207,238,250,0.55); }

.dark .save-option {
  border-color: rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.02);
}
.dark .save-option:hover { border-color: rgba(255,255,255,0.20); }
.dark .save-option-label { color: #fff; }
.dark .save-option-hint { color: rgba(207,238,250,0.55); }
.dark .save-step { color: rgba(207,238,250,0.55); }
.dark .save-step.active { color: #fff; }
.dark .save-step.done { color: #6ed47e; }
.dark .save-step.done .save-step-icon { color: #6ed47e; }
.dark .save-step.pending .save-step-icon { color: rgba(255,255,255,0.20); }
.dark .save-result-icon.success { background: rgba(57,181,74,0.18); color: #6ed47e; }
.dark .save-result-icon.failure { background: rgba(220,38,38,0.18); color: #fca5a5; }
.dark .save-result-icon.warning { background: rgba(245,158,11,0.20); color: #fbbf24; }
.dark .save-warnings {
  background: rgba(245,158,11,0.10);
  border-color: rgba(245,158,11,0.30);
  color: #fcd34d;
}
.dark .save-warning-line { color: #fbbf24; }

.dark .relays-cell {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.10);
}
.dark .relays-label { color: #cfeefa; }
.dark .relays-pin { color: rgba(207,238,250,0.55); }
.dark .relays-pin.primary { color: rgba(207,238,250,0.75); }
.dark .relays-count { color: #5cc6eb; }
.dark .save-errors {
  background: rgba(220,38,38,0.10);
  border-color: rgba(220,38,38,0.30);
  color: #fca5a5;
}
.dark .save-error-line { color: #fca5a5; }

.dark .save-raw-details summary { color: rgba(207,238,250,0.55); }
.dark .save-raw-details summary:hover { color: #fff; }
.dark .save-raw-output {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.10);
  color: #cfeefa;
}

.dark .toggle { color: #cfeefa; }
.dark .toggle-track { background: rgba(255,255,255,0.12); }
.dark .toggle input:checked + .toggle-track { background: var(--relay-500); }

.dark .vboard {
  background: linear-gradient(180deg, rgba(0,160,219,0.04), rgba(0,160,219,0.02));
  border-color: rgba(255,255,255,0.10);
}
.dark .vboard-inner {
  background-image:
    linear-gradient(rgba(0,160,219,0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,160,219,0.10) 1px, transparent 1px);
}
.dark .vboard-row {
  background: rgba(15,23,42,0.55);
  border-color: rgba(255,255,255,0.10);
}

.dark .push-btn {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-color: rgba(255,255,255,0.12);
  color: #cfeefa;
}
.dark .push-btn.pressed {
  background: var(--relay-500);
  border-color: var(--relay-400);
  color: #fff;
}

.dark .door-status {
  background: rgba(255,255,255,0.05);
  color: #cfeefa;
}

.dark .status-pill {
  background: rgba(255,255,255,0.04);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
  color: #cfeefa;
}
.dark .status-pill.connected {
  background: rgba(57,181,74,0.12);
  color: var(--mint-300);
  box-shadow: inset 0 0 0 1px rgba(57,181,74,0.25);
}
.dark .status-pill.connecting {
  background: rgba(245,158,11,0.12);
  color: #fbbf24;
  box-shadow: inset 0 0 0 1px rgba(245,158,11,0.25);
}
.dark .status-pill.error {
  background: rgba(220,38,38,0.12);
  color: #fca5a5;
  box-shadow: inset 0 0 0 1px rgba(220,38,38,0.25);
}

.dark .errors-drawer {
  background: rgba(5,10,23,0.96);
  border-top: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 -10px 30px -12px rgba(0,0,0,0.5);
  color: #cfeefa;
}
.dark .errors-drawer-header { color: #fff; }
.dark .error-row {
  border-top-color: rgba(255,255,255,0.06);
  color: #cfeefa;
}
.dark .error-row .level.info { background: rgba(0,160,219,0.18); color: #5cc6eb; }
.dark .error-row .level.warn { background: rgba(245,158,11,0.18); color: #fbbf24; }
.dark .error-row .level.err  { background: rgba(220,38,38,0.18);  color: #fca5a5; }

.dark .empty-state {
  background: rgba(255,255,255,0.02);
  border: 1px dashed rgba(255,255,255,0.12);
  color: #94a3b8;
}

.dark .eyebrow.ink {
  background: rgba(255,255,255,0.06);
  color: #cfeefa;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}

.dark .eyebrow.live {
  background: rgba(57,181,74,0.12);
  color: var(--mint-300);
  box-shadow: inset 0 0 0 1px rgba(57,181,74,0.25);
}
.dark .eyebrow.paused {
  background: rgba(255,255,255,0.05);
  color: #94a3b8;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}

.dark .scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-color: transparent;
}
.dark .scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.18);
}

.dark .relay-modal-backdrop {
  background: rgba(0, 0, 0, 0.55);
}
.dark .relay-modal {
  background: rgba(15, 23, 42, 0.98);
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow: 0 30px 80px -16px rgba(0, 0, 0, 0.6);
}
.dark .relay-modal-title { color: #fff; }
.dark .relay-modal-body { color: #cfeefa; }

.dark .dirty-banner {
  background: rgba(245,158,11,0.10);
  color: #fbbf24;
  border-color: rgba(245,158,11,0.30);
}
