:root {
  color-scheme: light;
  --bg: #f0f2f5;
  --ink: #1a1f2e;
  --muted: #5c6b82;
  --line: #dfe3ea;
  --panel: #ffffff;
  --surface: #ffffff;      /* cards, inputs, raised surfaces */
  --surface-2: #fafbfc;    /* subtle insets, table rows */
  --surface-3: #f1f5f9;    /* chips, hover fills */
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --warn: #b45309;
  --ok: #059669;
  --danger: #dc2626;
  --soft: #f0f4ff;
  --ok-bg: #ecfdf5;
  --warn-bg: #fffbeb;
  --danger-bg: #fef2f2;
  --info-bg: #eff6ff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --side-bg: #0f1117;
  --side-bg-2: #1b2030;
  --side-ink: #ecf4ff;
  --side-muted: #8b95ab;
  --transition: 150ms ease;
}

/* Dark theme — overrides the tokens only; light values above stay byte-identical
   so the default light render is unchanged. Toggle persists in localStorage. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e14;
  --ink: #e6edf6;
  --muted: #93a0b8;
  --line: #262d3b;
  --panel: #141926;
  --surface: #141926;
  --surface-2: #1a2030;
  --surface-3: #222a3a;
  --accent: #4b8bff;
  --accent-dark: #3b7bf0;
  --accent-soft: rgba(75, 139, 255, 0.16);
  --warn: #f0a13c;
  --ok: #34d399;
  --danger: #f26d6d;
  --soft: #182542;
  --ok-bg: rgba(16, 185, 129, 0.14);
  --warn-bg: rgba(240, 161, 60, 0.14);
  --danger-bg: rgba(242, 109, 109, 0.14);
  --info-bg: rgba(75, 139, 255, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 14px 44px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
  --side-bg: #0a0d13;
  --side-bg-2: #141926;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--side-bg);
  color: var(--side-ink);
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: grid;
  gap: 2px;
  padding: 4px 12px 28px;
}

.sidebar-brand strong {
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0;
}

.sidebar-brand span {
  color: var(--side-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.side-nav {
  display: grid;
  gap: 2px;
  margin-top: 4px;
}

.side-link {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--side-muted);
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
}

.side-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.side-link.is-active {
  background: rgba(37, 99, 235, 0.15);
  color: #fff;
  border-color: rgba(37, 99, 235, 0.2);
}

.app-view {
  min-width: 0;
}

.app-view[hidden] {
  display: none;
}

/* Chat / Voice playground: the embedded cockpit iframe fills the content column.
   :not([hidden]) so this never overrides the .app-view[hidden] display:none above. */
#chatVoiceView:not([hidden]) {
  display: flex;
}

.chatvoice-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

h2 {
  font-size: 14px;
  font-weight: 700;
}

h2 .badge {
  margin-left: 6px;
  vertical-align: 1px;
}

h3 {
  font-size: 14px;
  font-weight: 700;
}

h4 {
  font-size: 12px;
  font-weight: 700;
}

.status {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  border: 1px solid rgba(180, 83, 9, 0.18);
  border-radius: 999px;
  padding: 1px 7px;
  background: #fffbeb;
  color: var(--warn);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px 24px;
  max-width: none;
  margin: 0;
}

.docs-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 900px);
  gap: 18px;
  padding: 22px 28px;
  max-width: 1280px;
}

.docs-nav {
  position: sticky;
  top: 18px;
  align-self: start;
  max-height: calc(100vh - 108px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px;
  box-shadow: var(--shadow-sm);
}

.docs-nav:empty {
  display: none;
}

.docs-nav-link {
  display: block;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
}

.docs-nav-link:hover {
  background: var(--soft);
  color: var(--accent);
}

.docs-content {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 28px 32px;
  box-shadow: var(--shadow);
}

.docs-content h1 {
  font-size: 24px;
  margin-bottom: 12px;
  letter-spacing: 0;
}

.docs-content h2 {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 18px;
  letter-spacing: 0;
}

.docs-content h3 {
  margin-top: 24px;
  font-size: 15px;
}

.docs-content p,
.docs-content li {
  color: #354154;
  font-size: 14px;
  line-height: 1.65;
}

.docs-content p {
  margin-top: 12px;
}

.docs-content ul {
  margin: 12px 0 0;
  padding-left: 22px;
}

.docs-content code {
  border-radius: 4px;
  padding: 2px 5px;
  background: var(--surface-3);
  color: #1e293b;
  font-size: 0.88em;
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, monospace;
}

.doc-code {
  margin-top: 14px;
}

.doc-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  padding: 7px 10px;
  background: var(--surface-2);
}

.doc-code-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.doc-code .raw {
  border-radius: 0 0 8px 8px;
}

.docs-source-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  text-decoration: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls {
  padding: 20px;
  align-self: start;
}

.output {
  min-width: 0;
  min-height: calc(100vh - 84px);
  padding: 20px;
}

.section-head,
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head {
  justify-content: flex-start;
}

.worker-status-panel {
  padding: 16px 18px;
}

.worker-status-panel .section-head {
  margin-bottom: 12px;
}

.worker-statusboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.split-button {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}

.split-button-main,
.split-button-caret {
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.split-button-main {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.split-button-caret {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left-color: rgba(255, 255, 255, 0.4);
  min-width: 32px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.split-button-main:hover,
.split-button-caret:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.split-button .caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}

.split-button-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 30;
}

.split-button-menu[hidden] {
  display: none;
}

.split-button-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.split-button-menu a:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.request-picker {
  margin-bottom: 8px;
}

.request-hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.request-panel[hidden],
.tab-panel[hidden] {
  display: none;
}

.section-note {
  margin-bottom: 14px;
}

.section-note p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.section-note ul {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.section-note li {
  margin-top: 2px;
}

.step {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 auto;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 12px;
}

label {
  display: grid;
  gap: 5px;
  position: relative;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.passport-randomizer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px 8px 12px;
  background: var(--surface-2);
}

.passport-randomizer-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.passport-randomizer-copy strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.passport-randomizer-copy small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.switch-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  min-width: 64px;
  border-color: var(--line);
  border-radius: 999px;
  padding: 3px 9px 3px 4px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  transition: all var(--transition);
}

.switch-button.is-on {
  border-color: rgba(37, 99, 235, 0.25);
  background: var(--soft);
  color: var(--accent);
}

.switch-knob {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
  transition: transform var(--transition);
}

.inline-field {
  min-width: 128px;
}

.field-link {
  position: absolute;
  top: 0;
  right: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
}

.field-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.field-link.is-disabled {
  color: var(--muted);
  pointer-events: none;
  text-decoration: none;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

.compact-select {
  width: auto;
  min-height: 30px;
  padding: 4px 28px 4px 9px;
  font-size: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: #b0b8c4;
}

button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.primary:not(:disabled):hover {
  background: var(--accent-dark);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
  transform: translateY(-1px);
}

.primary:not(:disabled):active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.ghost {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.ghost:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}

.small {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
}

.danger-action {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.2);
}

.danger-action:hover {
  background: #fef2f2;
  border-color: rgba(220, 38, 38, 0.35);
}

/* Active state for the Stop API toggle when the API is stopped. */
.danger-action.is-active {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.danger-action.is-active:hover {
  background: #b91c1c;
}

.api-stopped-banner {
  margin: 0 0 14px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.01em;
}

.icon-btn {
  width: 30px;
  height: 30px;
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  border-color: var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: #c8cfd8;
}

.icon-btn.is-copied,
.use-asset-action.is-copied {
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(5, 150, 105, 0.06);
}

.icon-btn.has-copy-label,
.use-asset-action.has-copy-label {
  width: auto;
  min-width: 82px;
  padding: 0 10px;
  color: var(--ok);
  font-size: 12px;
}

.copy-icon {
  position: relative;
  width: 15px;
  height: 17px;
  display: inline-block;
}

.copy-icon::before,
.copy-icon::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 12px;
  border: 1.6px solid currentColor;
  border-radius: 2px;
  background: var(--surface);
}

.copy-icon::before {
  left: 1px;
  top: 1px;
  opacity: 0.55;
}

.copy-icon::after {
  left: 4px;
  top: 4px;
}

.form-grid label.checkbox-line {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  text-transform: none;
  font-size: 12px;
}
.form-grid label.checkbox-line input {
  width: auto;
  margin: 0;
}

.wide {
  grid-column: 1 / -1;
}

.ttl-note {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 400;
}

.hint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid currentColor;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  cursor: help;
}

.lora-compare {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 12px;
  background: var(--surface-2);
}
/* `display: grid` above overrides the UA [hidden] rule, so honor hidden explicitly
   — the editor must show ONLY for the LoRA Compare entry, not Scene Reference / v2. */
.lora-compare[hidden] {
  display: none;
}
.lora-compare-grid {
  display: grid;
  grid-template-columns: 26px repeat(3, 1fr);
  gap: 6px 8px;
  align-items: center;
}
.lora-compare-grid .col-head {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
}
.lora-compare-grid .row-head {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}
.lora-compare-grid input {
  width: 100%;
  text-align: center;
}

.tabs {
  display: inline-flex;
  gap: 2px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: var(--surface-3);
}

.tab {
  min-height: 30px;
  border-radius: var(--radius-sm);
  padding: 5px 14px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
}

.tab:hover {
  color: var(--ink);
}

.tab.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.activity-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  border: 1px solid rgba(180, 83, 9, 0.2);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fffbeb;
}

.activity-panel[hidden] {
  display: none;
}

.activity-panel strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.activity-panel p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.activity-panel span {
  min-width: 52px;
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  background: var(--surface);
  color: var(--warn);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 800;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.metric-thumb {
  display: inline-block;
  margin-top: 5px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  line-height: 0;
  transition: border-color var(--transition);
}

.metric-thumb:hover {
  border-color: var(--accent);
}

.metric-thumb img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.asset-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  transition: all 180ms ease;
}

.asset-card:hover {
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.asset-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent), 0 6px 20px rgba(37, 99, 235, 0.3);
}

.asset-card.is-url-copied .copy-url-action {
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ok);
}

.asset-card.is-url-copied .copy-url-action .copy-icon::before {
  display: none;
}

.asset-card.is-url-copied .copy-url-action .copy-icon::after {
  left: 3px;
  top: 1px;
  width: 8px;
  height: 13px;
  border-top: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  transform: rotate(45deg);
}

.asset-image {
  position: relative;
}

.asset-card img,
.asset-image img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  /* Generations are tall portraits with the head at the top; anchor the square
     crop to the top so the head stays visible (crops legs/bottom instead). */
  object-position: top;
  display: block;
  background: var(--surface-2);
}

.insight-card .asset-image {
  background: var(--surface-2);
}

.insight-card .asset-image img {
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
}

.insight-safety {
  display: inline-block;
  width: fit-content;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.insight-safety.is-sfw {
  background: #ecfdf5;
  color: #047857;
}

.insight-safety.is-nsfw {
  background: #fef2f2;
  color: #b91c1c;
}

.preview-action,
.copy-url-action,
.use-asset-action {
  position: absolute;
  top: 6px;
  width: 28px;
  height: 28px;
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  border-color: rgba(15, 23, 42, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 0;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
}

.asset-card:hover .preview-action,
.asset-card:hover .copy-url-action,
.asset-card:hover .use-asset-action {
  opacity: 1;
}

.preview-action {
  right: 6px;
}

.copy-url-action {
  right: 40px;
}

.use-asset-action {
  right: 40px;
}

.preview-action:hover,
.copy-url-action:hover,
.use-asset-action:hover {
  background: var(--surface);
}

.use-asset-action:hover {
  color: #15803d;
}

.check-icon {
  position: relative;
  width: 15px;
  height: 15px;
  display: inline-block;
}

.check-icon::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 6px;
  width: 4px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.expand-icon {
  position: relative;
  width: 15px;
  height: 15px;
  display: inline-block;
}

.expand-icon::before,
.expand-icon::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-color: currentColor;
}

.expand-icon::before {
  top: 0;
  right: 0;
  border-top: 2px solid;
  border-right: 2px solid;
}

.expand-icon::after {
  left: 0;
  bottom: 0;
  border-left: 2px solid;
  border-bottom: 2px solid;
}

.asset-card footer {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}

.asset-card footer span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.asset-card strong,
.asset-card a {
  display: block;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-card a {
  margin-top: 2px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.asset-card a:hover {
  text-decoration: underline;
}

.asset-card a.metadata-link {
  color: #1d6fb8;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pending-job {
  border-style: dashed;
}

.pending-image {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.04), rgba(37, 99, 235, 0.08));
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.pending-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(37, 99, 235, 0.15);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 800ms linear infinite;
}

.pending-job-id,
.pending-job-status,
.pending-job-elapsed {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.pending-image .pending-job-elapsed {
  margin-top: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.pending-job.is-failed {
  border-color: rgba(190, 67, 67, 0.5);
}

.pending-job.is-failed .pending-image {
  background: rgba(190, 67, 67, 0.08);
  color: var(--danger);
}

.pending-job.is-failed .pending-spinner {
  display: none;
}

.pending-job.is-canceled {
  border-color: rgba(140, 140, 140, 0.4);
  opacity: 0.75;
}

.pending-job.is-canceled .pending-image {
  background: rgba(140, 140, 140, 0.08);
  color: var(--muted);
}

.insight-empty {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.insight-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.insight-box {
  position: absolute;
  border: 2px solid rgba(227, 108, 31, 0.95);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.insight-box.is-face {
  border-color: rgba(22, 114, 74, 0.95);
}

.insight-box span {
  position: absolute;
  left: -2px;
  bottom: calc(100% + 2px);
  max-width: 160px;
  border-radius: 4px;
  padding: 2px 5px;
  background: rgba(17, 24, 39, 0.86);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.mini {
  width: 100%;
  min-height: 28px;
  margin-top: 6px;
  padding: 4px 8px;
  border-color: var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.mini:hover {
  background: var(--soft);
  border-color: rgba(37, 99, 235, 0.2);
}

.code-panel {
  min-width: 0;
  margin-top: 16px;
}

.code-panel.is-first {
  margin-top: 0;
}

.code-head,
.io-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.code-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.code-head h3,
.io-block-head h4 {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.raw {
  margin: 0;
  width: 100%;
  min-width: 0;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  border: 1px solid rgba(30, 41, 59, 0.12);
  border-radius: 8px;
  padding: 14px;
  background: #0f172a;
  color: #cbd5e1;
  font-size: 12px;
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, monospace;
  line-height: 1.55;
}

/* Per-image Request / Response — the pair that produced the selected image. */
.io-context {
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, monospace;
  margin-left: 6px;
}

.io-empty {
  margin: 4px 0 0;
  padding: 22px 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.io-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.io-block {
  min-width: 0;
}

.io-block-head h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

@media (max-width: 900px) {
  .io-grid { grid-template-columns: minmax(0, 1fr); }
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 6, 15, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.image-modal[hidden] {
  display: none;
}

.image-modal-frame {
  width: min(96vw, 1120px);
  max-height: 92vh;
  display: grid;
  gap: 10px;
}

.modal-image-wrap {
  position: relative;
  width: fit-content;
  max-width: 100%;
  justify-self: center;
}

.modal-image-wrap img {
  max-width: 100%;
  max-height: calc(92vh - 54px);
  border-radius: 8px;
  background: #101827;
  object-fit: contain;
  display: block;
}

.modal-insight-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.modal-close {
  position: fixed;
  top: 16px;
  right: 16px;
  border-color: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-close:hover {
  background: var(--surface);
}

.modal-open-link {
  justify-self: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.modal-open-link:hover {
  text-decoration: underline;
}

.empty {
  border-style: dashed;
}

.is-ok {
  color: var(--ok);
}

.is-warn {
  color: var(--warn);
}

.is-error {
  color: var(--danger);
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
  }

  .sidebar-brand {
    padding: 0;
    border-bottom: 0;
  }

  .side-nav {
    display: flex;
    margin-top: 0;
  }

  .side-link {
    min-height: 34px;
    font-size: 12px;
  }

  .workspace,
  .docs-shell {
    grid-template-columns: 1fr;
  }

  .docs-nav {
    position: static;
    max-height: none;
  }

  .output {
    min-height: auto;
  }
}

.workers-shell {
  display: grid;
  gap: 18px;
  padding: 22px 28px;
}

.workers-shell[hidden] {
  display: none;
}

.workers-access {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 28px 0;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(180, 83, 9, 0.07);
}

.workers-access[data-locked="false"] {
  background: rgba(5, 150, 105, 0.08);
}

.workers-access-state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  font-size: 13px;
  color: var(--muted);
}

.workers-access input {
  max-width: 220px;
}

.workers-view.is-readonly .requires-write,
.workers-view.is-readonly .worker-action,
.workers-view.is-readonly #workerConfigForm input,
.workers-view.is-readonly #workerConfigForm select {
  opacity: 0.45;
  pointer-events: none;
}

.workers-summary {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.worker-control-panel {
  padding: 16px 18px;
}

.provider-actions,
.worker-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-start; /* don't vertically stretch buttons to fill the card */
}

/* Two tiers inside a card: capability Start/Stop on top, the bare-GPU
   lease/release + traffic below, divided by a hairline. */
.worker-capabilities,
.worker-gpu-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-basis: 100%;
  align-items: flex-start;
}

/* Card action buttons stay their natural height — never balloon on tall cards. */
.worker-actions .ghost.small,
.worker-capabilities .ghost.small,
.worker-gpu-actions .ghost.small {
  height: 30px;
  flex: 0 0 auto;
}

.worker-gpu-actions {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* Live status line: the transition spinner-chip (cached, so it animates smoothly) + the per-poll
   elapsed text patched into .worker-live. Divider hidden entirely when there's nothing to show. */
.worker-liveline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.worker-liveline:not(:has(.worker-progress)):has(.worker-live:empty) { display: none; }
.worker-progress { display: inline-flex; align-items: center; gap: 5px; }
.worker-progress .ic { width: 13px; height: 13px; animation: spin 800ms linear infinite; }
.worker-progress.is-stuck { color: var(--warn); }
.worker-progress.is-stuck .ic { width: 14px; height: 14px; animation: none; }

/* last_error surfaced inline — the operator must SEE why a worker died (the 502), not guess. */
.worker-error {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: var(--danger);
  font-size: 11.5px;
  line-height: 1.4;
  word-break: break-word;
}
.worker-error .ic { width: 14px; height: 14px; flex: 0 0 auto; margin-top: 1px; }

.provider-waterfall {
  display: grid;
  gap: 10px;
  max-width: 720px;
}

.worker-config-form {
  margin-top: 10px;
}

.provider-global-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.provider-settings-tabs {
  display: inline-flex;
  width: fit-content;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: var(--surface-2);
}

.provider-settings-tab {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.provider-settings-tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.provider-settings-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.provider-settings-panel[hidden] {
  display: none;
}

.gpu-token-field {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.gpu-token-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.gpu-token-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gpu-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 7px 3px 9px;
  background: var(--info-bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.gpu-chip button {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  line-height: 1;
}

.gpu-token-input {
  flex: 1;
  min-width: 160px;
  border: 0;
  padding: 5px;
  min-height: 28px;
  outline: 0;
  background: transparent;
}

.gpu-suggestions {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.gpu-suggestions button {
  width: 100%;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0 9px;
  background: transparent;
  text-align: left;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.gpu-suggestions button:hover {
  background: var(--surface-3);
}

.gpu-settings-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.gpu-settings-head h3 {
  margin: 0;
  font-size: 14px;
}

.gpu-settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.gpu-settings-head p {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.gpu-jobs-table {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.gpu-job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
}

.gpu-job-row span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}

.gpu-job-row input {
  text-align: center;
  min-height: 32px;
  padding: 4px 6px;
}

.advanced-settings {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.advanced-settings summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
}

.advanced-settings .form-grid {
  margin-top: 12px;
}

.provider-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-2);
  transition: border-color var(--transition);
}

.provider-card::after {
  content: "";
  position: absolute;
  left: 28px;
  bottom: -11px;
  width: 2px;
  height: 10px;
  background: var(--line);
}

.provider-card:last-child::after {
  display: none;
}

.provider-card.is-configured {
  border-color: rgba(5, 150, 105, 0.2);
  border-left: 3px solid var(--ok);
}

.provider-card.is-missing {
  border-color: rgba(180, 83, 9, 0.2);
  border-left: 3px solid var(--warn);
  background: #fffbeb;
}

.provider-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.provider-card-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.provider-card-toggle input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.provider-card strong {
  text-transform: capitalize;
  font-size: 13px;
}

.provider-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.provider-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.worker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  align-items: start; /* each card sizes to its own content — no row-height stretch */
}

.worker-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.worker-card:hover {
  box-shadow: var(--shadow-lg);
}

.worker-card.is-stopping {
  border-color: rgba(180, 83, 9, 0.35);
  background: var(--warn-bg);
}

/* A health failure reads as an error (red); a stuck/zombie boot as a warning (amber) — both clearly
   distinct from a healthy card and from each other, so a 45-min zombie never looks calm. */
.worker-card.is-unhealthy {
  border-color: rgba(220, 38, 38, 0.4);
  background: var(--danger-bg);
}
.worker-card.is-stuck {
  border-color: rgba(180, 83, 9, 0.45);
  background: var(--warn-bg);
}

.worker-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.worker-card h3 {
  font-size: 13px;
  font-weight: 700;
}

.worker-url {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
}

.worker-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.worker-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.worker-facts {
  margin: 0;
  display: grid;
  gap: 4px;
}

.worker-fact {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 11px;
}

.worker-fact dt {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.worker-fact dd {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  white-space: nowrap;
}

.status-pill.ready {
  background: var(--ok-bg);
  color: var(--ok);
}

.status-pill.unhealthy,
.status-pill.disabled {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-pill.draining,
.status-pill.starting,
.status-pill.stopping,
.status-pill.releasing {
  background: var(--warn-bg);
  color: var(--warn);
}

.status-pill.leasing {
  background: var(--info-bg);
  color: var(--accent);
}

.status-pill.stopped {
  background: var(--surface-3);
  color: var(--muted);
}

/* Worker activity: each worker holds at most one job, so this is a boolean. */
.status-pill.activity.is-busy {
  background: var(--info-bg);
  color: var(--accent);
}

.status-pill.activity.is-busy::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 5px;
  animation: activity-pulse 1.2s ease-in-out infinite;
}

.status-pill.activity.is-idle {
  background: var(--surface-2);
  color: #94a3b8;
}

@keyframes activity-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* Fixed-width, color-coded worker status icon — replaces the text pills so the card
   header never reflows (no jumping on idle↔working) and the long worker id has room. */
.worker-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.worker-state .ic {
  width: 16px;
  height: 16px;
  vertical-align: 0;
}

.state-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
}

.worker-state.is-working { color: var(--accent); }
.worker-state.is-idle { color: var(--ok); }
.worker-state.is-paused { color: var(--warn); }
.worker-state.is-starting { color: #eab308; }
.worker-state.is-stopping { color: var(--warn); }
.worker-state.is-inactive { color: var(--muted); opacity: 0.6; }
.worker-state.is-unhealthy { color: var(--danger); }
.worker-state.is-stopped { color: var(--muted); }
.worker-state.is-stopped .state-dot {
  background: transparent;
  box-shadow: inset 0 0 0 2px currentColor;
}

/* Active / in-progress states blink slowly so they read as "live" at a glance:
   blue = working, yellow = initializing/leasing, amber = stopping/releasing.
   (Idle is a steady green — no blink.) */
.worker-state.is-working .state-dot,
.worker-state.is-starting .state-dot,
.worker-state.is-stopping .state-dot {
  animation: state-blink 1.5s ease-in-out infinite;
}

@keyframes state-blink {
  0%, 100% { opacity: 0.28; }
  50% { opacity: 1; }
}

/* ===== Workers UI v2 — theme toggle, freshness, telemetry, waterfall ===== */
.ic {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -2px;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
}

.theme-toggle {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--side-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #e2e8f0;
}

.theme-toggle .ic {
  width: 17px;
  height: 17px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

/* Workers status/error line — its own full-width row below the toolbar, so a long
   message (e.g. a metrics redirect error) can never stretch the title block and
   crush the action buttons. Styled by id because setStatus() rewrites className. */
#workersStatus {
  margin: 14px 28px 0;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow-wrap: anywhere;
}

#workersStatus:empty {
  display: none;
}

#workersStatus.is-error {
  background: var(--danger-bg);
  border-color: var(--danger-bg);
  color: var(--danger);
}

#workersStatus.is-ok {
  background: var(--ok-bg);
  border-color: var(--ok-bg);
  color: var(--ok);
}

#workersStatus.is-warn {
  background: var(--warn-bg);
  border-color: var(--warn-bg);
  color: var(--warn);
}

.freshness {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.freshness-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-bg);
  /* Slow green blink = "polling is alive". */
  animation: freshness-blink 2.4s ease-in-out infinite;
}

@keyframes freshness-blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.freshness.is-loading .freshness-dot {
  animation-duration: 1s;
}

.freshness.is-stale {
  color: var(--warn);
  border-color: var(--warn-bg);
}

.freshness.is-stale .freshness-dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-bg);
}

/* Per-worker GPU telemetry strip */
.tele-host:empty {
  display: none;
}

.tele {
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.tele-row {
  display: grid;
  grid-template-columns: 14px 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.tele-ico {
  color: var(--muted);
  display: inline-flex;
}

.tele-ico .ic {
  width: 14px;
  height: 14px;
  vertical-align: 0;
}

.tele-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.tele-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.tele-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.tele-fill.is-low { background: #10b981; }
.tele-fill.is-mid { background: #f59e0b; }
.tele-fill.is-high { background: #ef4444; }
.tele-fill.is-empty { background: transparent; }

.tele-val {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-width: 56px;
  text-align: right;
}

/* Provider waterfall — drag/arrow-reorderable priority chain */
.provider-waterfall {
  display: grid;
  gap: 8px;
  max-width: 820px;
}

.wf-chain {
  display: grid;
  gap: 8px;
}

.wf-row {
  display: grid;
  grid-template-columns: 18px 22px minmax(120px, 1.1fr) minmax(0, 1.6fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.wf-row.is-active.is-configured { border-left-color: var(--ok); }
.wf-row.is-active.is-missing { border-left-color: var(--warn); }

.wf-row.is-inactive {
  background: var(--surface-2);
  opacity: 0.7;
}

.wf-row.is-dragging {
  opacity: 0.5;
  box-shadow: var(--shadow-lg);
}

.wf-grip {
  color: var(--muted);
  cursor: grab;
  display: inline-flex;
}

.wf-row.is-active:active .wf-grip { cursor: grabbing; }
.wf-row.is-inactive .wf-grip { cursor: default; }
.wf-grip .ic { width: 16px; height: 16px; vertical-align: 0; }

.wf-rank {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.wf-row.is-active .wf-rank { color: var(--accent); }

.wf-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}

.wf-toggle input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.wf-name {
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wf-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.wf-dot.ok { background: var(--ok); }
.wf-dot.missing { background: var(--warn); }

.wf-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  flex-wrap: wrap;
}

.wf-stats span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.wf-stats .ic { width: 13px; height: 13px; vertical-align: 0; }

.wf-move {
  display: inline-flex;
  gap: 3px;
}

.wf-arrow {
  min-height: 26px;
  width: 26px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}

.wf-arrow:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.wf-arrow .ic { width: 14px; height: 14px; vertical-align: 0; }

.wf-msg {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

.wf-empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.wf-inactive-label {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.wf-inactive {
  display: grid;
  gap: 8px;
}

.wf-inactive .wf-stats { display: none; }

/* Provider settings tabs — Local + Nebius primary, RunPod/Vast secondary */
.provider-settings-tab-sep {
  width: 1px;
  align-self: stretch;
  margin: 4px 3px;
  background: var(--line);
}

.provider-settings-tab.is-secondary {
  opacity: 0.65;
  font-weight: 600;
}

.provider-settings-tab.is-secondary:hover,
.provider-settings-tab.is-secondary.is-active {
  opacity: 1;
}

@media (max-width: 560px) {
  .topbar {
    padding: 14px;
  }

  .workspace {
    padding: 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Generation Debug archive ---- */
.debug-shell {
  padding: 22px 28px;
}

.debug-main {
  min-width: 0;
}

.debug-filters {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0 14px;
  background: linear-gradient(var(--bg) 70%, transparent);
}

.debug-search {
  flex: 1 1 240px;
  min-width: 200px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 13px;
  background: var(--surface);
}

.debug-date,
.debug-ref {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
}

.debug-ref {
  flex: 0 1 180px;
  min-width: 140px;
}

/* Native date inputs size to their content; without this they'd inherit the
   global `input { width: 100% }` and stretch across the whole filter row. */
.debug-date {
  width: auto;
  flex: 0 0 auto;
}

.debug-date-clear {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
}

.debug-date-clear:hover {
  background: var(--soft);
  border-color: var(--accent);
}

.debug-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
}

.debug-sort-btn:hover {
  background: var(--soft);
  border-color: var(--accent);
}

.debug-sort-icon {
  color: var(--muted);
}

/* Show only the icon matching the active direction. */
.debug-sort-btn .debug-sort-oldest {
  display: none;
}

.debug-sort-btn[data-dir="oldest"] .debug-sort-newest {
  display: none;
}

.debug-sort-btn[data-dir="oldest"] .debug-sort-oldest {
  display: inline-block;
}

.debug-filter-fields {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.debug-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.debug-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debug-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.debug-card.is-failed {
  border-color: rgba(220, 38, 38, 0.4);
  background: rgba(220, 38, 38, 0.03);
}

.debug-thumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.debug-thumb {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.debug-thumb img {
  height: 150px;
  width: auto;
  max-width: 220px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  cursor: zoom-in;
  background: var(--soft);
}

.debug-thumb.is-input img {
  height: 120px;
  opacity: 0.92;
}

.debug-thumb figcaption {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.debug-arrow {
  color: var(--muted);
  font-size: 20px;
}

.debug-empty {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.debug-meta {
  flex: 1 1 240px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.debug-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.debug-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
}

.debug-badge-key {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.debug-badge.is-good {
  background: rgba(5, 150, 105, 0.1);
  border-color: rgba(5, 150, 105, 0.25);
}

.debug-badge.is-bad {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.3);
  color: var(--danger);
}

.debug-error {
  margin: 0;
  font-size: 12px;
  color: var(--danger);
}

.debug-prompt-section pre {
  margin: 0;
  padding: 8px 10px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2, rgba(127, 127, 127, 0.08));
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.45;
}

.debug-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
}

.debug-jobid {
  font-size: 11px;
  color: var(--muted);
}

.debug-card .ghost.small {
  padding: 4px 10px;
  font-size: 12px;
}

.debug-details {
  flex-basis: 100%;
  margin: 4px 0 0;
  max-height: 480px;
  overflow: auto;
  font-size: 11px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

@media (max-width: 720px) {
  .debug-shell {
    padding: 16px;
  }
}

.debug-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px 0 8px;
}

.debug-pager-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* Single column in reading order: Request → Final prompt → Result → record. */
.debug-detail-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.debug-detail-section + .debug-detail-section {
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}

.debug-detail-section > summary {
  margin: 0;
  padding: 4px 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.debug-detail-section > summary::-webkit-details-marker {
  display: none;
}

/* Disclosure triangle, rotates when the section is open. */
.debug-detail-section > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}

.debug-detail-section[open] > summary::before {
  transform: rotate(90deg);
}

.debug-detail-section > summary:hover {
  color: var(--ink);
}

.debug-detail-section > summary .copy-action {
  width: 22px;
  height: 22px;
  min-height: 22px;
  margin-left: auto;
}

.debug-detail-section > :not(summary) {
  margin-top: 6px;
}

.debug-kv {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(110px, max-content) 1fr;
  gap: 2px 12px;
  font-size: 12px;
}

.debug-kv dt {
  font-weight: 600;
  color: var(--muted);
  word-break: break-word;
}

.debug-kv dd {
  margin: 0;
  color: var(--ink);
  word-break: break-word;
}

.debug-kv dd a {
  color: var(--accent);
  word-break: break-all;
}

.debug-kv-json {
  margin: 2px 0;
  padding: 6px 8px;
  background: var(--soft);
  border-radius: var(--radius-sm);
  font-size: 11px;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
}

/* ── LLM providers view ─────────────────────────────────────────────── */
.providers-shell { display: flex; flex-direction: column; gap: 18px; padding: 24px 28px; max-width: 1160px; }
.providers-view .panel { padding: 20px 22px; }
.providers-hint { color: var(--muted); font-size: 12px; font-weight: 400; }

/* Waterfall — one lane per role, ordered hops with live health */
.providers-routes { display: flex; flex-direction: column; }
.pvw-lane { padding: 16px 0; }
.pvw-lane:first-child { padding-top: 4px; }
.pvw-lane:not(:last-child) { border-bottom: 1px solid var(--line); }
.pvw-lane-head { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; }
.pvw-role { min-width: 52px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pvw-chain { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pvw-hop { display: flex; align-items: center; gap: 9px; padding: 8px 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); transition: border-color var(--transition), box-shadow var(--transition); }
.pvw-hop:hover { border-color: var(--line-strong, var(--muted)); }
.pvw-hop[draggable="true"] { cursor: grab; }
.pvw-hop[draggable="true"]:active { cursor: grabbing; }
.pvw-hop.is-dragging { opacity: .45; border-style: dashed; }
.pvw-grip { flex: none; display: inline-flex; align-items: center; color: var(--muted); margin-right: -2px; }
.pvw-grip .ic { width: 13px; height: 13px; vertical-align: 0; }
.pvw-rank { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 700; }
.pvw-hop.is-ok .pvw-rank, .pvw-hop.is-warn .pvw-rank { background: var(--accent-soft); color: var(--accent); }
.pvw-hop-body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pvw-hop-body b { font-size: 13px; color: var(--ink); }  /* neutral, high-contrast — status lives in the dot, not the name */
.pvw-hop-body span { font-family: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, monospace; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.pvw-hop-body .pvw-price { margin-top: 2px; font-size: 10.5px; color: var(--muted); overflow: visible; }
.pvw-price-sep { opacity: .55; margin: 0 1px; }
.pvw-price-unit { font-style: normal; opacity: .65; margin-left: 3px; }
.pvw-price.is-unknown { letter-spacing: .1em; }
.pvw-dot { width: 8px; height: 8px; border-radius: 999px; flex: none; }
.pvw-dot.ok { background: var(--ok); }
.pvw-dot.warn { background: var(--warn); }
/* Probe latency badge — shared by the endpoint pills (near the dot) and the provider cards (in the
   head). Color ties to the live 4s TTFT deadline: ok ≤2s, warn ≤4s, bad >4s / error / timeout. */
.pv-lat { flex: none; font-family: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, monospace; font-size: 10.5px; font-weight: 700; line-height: 1; padding: 3px 6px; border-radius: 999px; white-space: nowrap; }
.pv-lat.ok { color: var(--ok); background: var(--ok-bg); }
.pv-lat.warn { color: var(--warn); background: var(--warn-bg); }
.pv-lat.bad { color: var(--danger); background: var(--danger-bg); }
.pvw-model { flex: none; }
.pvw-model-name { font-family: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, monospace; font-size: 12px; color: var(--ink); }
.pv-model-select, .pvw-add-model { font: inherit; font-size: 12px; padding: 6px 9px; max-width: 260px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.pv-model-select:hover:not(:disabled), .pvw-add-model:hover { border-color: var(--accent); }
/* Remove-endpoint button (right edge of a lane) + the inline add-endpoint row */
.pvw-remove { flex: none; margin-left: auto; display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; transition: color var(--transition), border-color var(--transition), background var(--transition); }
.pvw-remove:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }
.pvw-addbtn { margin-left: auto; }
.pvw-add-lane { display: flex; align-items: center; gap: 10px; }
.pvw-add-name { flex: 1 1 220px; min-width: 180px; font: inherit; font-size: 13px; padding: 7px 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--accent); border-radius: var(--radius-sm); box-shadow: 0 0 0 3px var(--accent-soft); }
.pvw-add-name:focus { outline: none; }
.pvw-add-actions { display: inline-flex; gap: 8px; }
/* Chain-node states: bypassed (skipped, kept in place) + non-serving (parked, doesn't serve model) */
.pvw-hop.is-bypass { opacity: .5; border-style: dashed; }
.pvw-hop.is-bypass .pvw-hop-body b { text-decoration: line-through; }
.pvw-hop.is-unserved { opacity: .55; }
.pvw-dot.off { background: var(--muted); opacity: .5; }
/* Per-node actions: bypass toggle + remove-from-endpoint */
.pvw-node-actions { flex: none; display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; padding-left: 6px; border-left: 1px solid var(--line); }
.pvw-node-btn { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; transition: color var(--transition), border-color var(--transition), background var(--transition); }
.pvw-node-btn .ic { width: 13px; height: 13px; vertical-align: 0; }
.pvw-node-btn:hover { color: var(--ink); border-color: var(--line); background: var(--surface); }
.pvw-bypass-btn.is-on { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
.pvw-node-x:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }
/* "＋ provider" picker — a supported provider to append to an endpoint's chain */
.pvw-add-provider { flex: 0 0 auto; align-self: stretch; width: auto; min-width: 128px; max-width: 190px; min-height: 0; font: inherit; font-size: 12px; padding: 8px 12px; background: transparent; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius-sm); cursor: pointer; transition: color var(--transition), border-color var(--transition); }
.pvw-add-provider:hover { color: var(--accent); border-color: var(--accent); }
.providers-legend { display: flex; gap: 18px; margin-top: 14px; font-size: 11px; color: var(--muted); }
.providers-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Provider cards */
.providers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 340px)); gap: 14px; }
.pv-card { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: border-color var(--transition), box-shadow var(--transition); }
.pv-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.pv-card.is-unconfigured { opacity: .6; }
.pv-card.is-unconfigured:hover { border-color: var(--line); box-shadow: var(--shadow-sm); }
.pv-head { display: flex; align-items: center; gap: 8px; }
.pv-head h3 { margin: 0; font-size: 15px; flex: 1 1 auto; }
.pv-rank { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 700; }
.pv-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 999px; }
.pv-badge.ok { color: var(--ok); background: var(--ok-bg); }
.pv-badge.warn { color: var(--warn); background: var(--warn-bg); }
.pv-url { font-family: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, monospace; font-size: 11px; color: var(--muted); word-break: break-all; }
.pv-meters { display: flex; flex-direction: column; gap: 12px; }
.pv-meter-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.pv-meter-val { display: inline-flex; align-items: baseline; gap: 4px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.pv-meter-val em { color: var(--muted); font-style: normal; font-weight: 400; }
.pv-num { width: 66px; padding: 2px 6px; font: inherit; font-size: 12px; font-weight: 600; text-align: right; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; box-sizing: border-box; }
.pv-num:hover { border-color: var(--accent); }
.pv-num:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pv-num::-webkit-outer-spin-button, .pv-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pv-num { -moz-appearance: textfield; }
.pv-bar { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.pv-bar-fill { height: 100%; min-width: 2px; background: var(--accent); border-radius: 999px; transition: width var(--transition); }
.pv-bar-fill.hot { background: var(--warn); }
.pv-bar-fill.full { background: var(--danger); }
.pv-foot { display: flex; align-items: center; justify-content: flex-start; gap: 10px; font-size: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.pv-flag { font-size: 10px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 999px; }
.pv-flag.off { color: var(--muted); background: var(--surface-3); }

/* Advanced — collapsed raw JSON config */
.providers-view .providers-advanced-panel { padding: 0; overflow: hidden; }
.providers-advanced > summary { display: flex; align-items: center; gap: 10px; padding: 15px 20px; cursor: pointer; list-style: none; user-select: none; }
.providers-advanced > summary::-webkit-details-marker { display: none; }
.providers-advanced > summary:hover { background: var(--surface-2); }
.providers-caret { color: var(--muted); flex: none; transition: transform var(--transition); }
.providers-advanced[open] > summary .providers-caret { transform: rotate(90deg); }
.providers-advanced-title { font-size: 14px; font-weight: 700; }
.providers-advanced > summary > .providers-hint { margin-left: auto; text-align: right; }
.providers-config { display: flex; flex-direction: column; gap: 14px; padding: 4px 20px 20px; }
.providers-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.providers-json { width: 100%; font-family: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, monospace; font-size: 12px; line-height: 1.5; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); resize: vertical; box-sizing: border-box; }
.providers-json:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.providers-json:disabled { opacity: .6; cursor: not-allowed; }
.providers-config-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ── GPU Forge console additions ──────────────────────────────────────────── */
/* Indicator dot (upper-right of each card). Or's spec: BLINKING YELLOW = any transition;
   BLINKING BLUE = working (a capability is active/running); SOLID GREEN = powered + idle.
   Plus the operational states the happy path omits: grey = off, red = unhealthy, amber =
   paused. Lease ownership is NOT a pill anymore — it's the Release⇄Lease button + this dot. */
.ind-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  background: var(--muted);
}
.ind-dot.is-working    { background: var(--accent); }   /* blue  */
.ind-dot.is-transition { background: #eab308; }         /* yellow */
.ind-dot.is-idle       { background: var(--ok); }       /* green */
.ind-dot.is-off        { background: var(--muted); }    /* grey  */
.ind-dot.is-unhealthy  { background: var(--danger); }   /* red   */
.ind-dot.is-paused     { background: var(--warn); }     /* amber */
.ind-dot.is-blink      { animation: ind-blink 1.15s ease-in-out infinite; }
@keyframes ind-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { .ind-dot.is-blink { animation: none; } }

/* The one kept badge: a permanent reservation held by another tenant (rare; explains the
   disabled Start). Filled amber so it stands out. */
.worker-lease-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.worker-lease-chip .ic { width: 13px; height: 13px; }
.lease-label { line-height: 1; }
.worker-lease-chip.is-reserved { color: var(--warn); background: var(--warn-bg); border-color: var(--warn); }

/* Card edge tint mirrors the not-ours lease states. */
.worker-card.is-reserved { border-color: var(--warn); background: linear-gradient(0deg, var(--warn-bg), transparent 42%); }
.worker-card.is-foreign-leased { border-color: var(--accent); }

/* Disabled action chips for not-ours GPUs (no lease/start/release is valid). */
.worker-reserved-action[disabled], .worker-leased-action[disabled] {
  display: inline-flex; align-items: center; gap: 5px;
  opacity: 0.75; cursor: not-allowed;
}
.worker-reserved-action[disabled] { color: var(--warn); border-color: var(--warn); }
.worker-leased-action[disabled]   { color: var(--accent); border-color: var(--accent); }
.worker-reserved-action .ic, .worker-leased-action .ic { width: 13px; height: 13px; }

/* A per-card action error (the agent's 409 detail), distinct from the backend's
   last_error: same danger skin, tagged so it's clearly the operator's action. */
.worker-action-error { margin-top: 6px; }

/* No public URL (stopped worker) → a muted em-dash instead of a synthesized bogus URL. */
.worker-url-none { color: var(--muted); }
