/* Cabane Companion dashboard. Utilitarian, no framework. Light by
   default, dark via prefers-color-scheme. The job is to answer "is it
   running / what's it doing / why isn't it replying" at a glance.

   Brand tokens: bone ground, ink foreground, ember accent + mark, the warm
   dark set. The status dots stay emerald/amber/red intent tints — health is
   not a brand slot. */

:root {
  --bg: #fafaf7; /* Bone — ground */
  --panel: #ffffff; /* Surface — cards */
  --ink: #141413; /* Ink — foreground */
  --muted: rgba(20, 20, 19, 0.55); /* fg-faint — labels, secondary */
  --line: rgba(20, 20, 19, 0.09); /* hairline */
  --inset: #f2f0e9; /* recessed warm well — code, detail */
  --accent: #c8552a; /* Ember — fills, mark, large accents */
  --accent-text: #c8552a; /* link / small accent text (lifts on dark) */
  --green: #059669; /* healthy */
  --amber: #d97706; /* degraded */
  --red: #b8423a; /* error / destructive */
  --danger: #b8423a;
  --radius: 9px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110; /* base — the page */
    --panel: #1c1a18; /* surface — cards, panels */
    --ink: #ece9e2; /* warm off-white */
    --muted: rgba(236, 233, 226, 0.48);
    --line: rgba(236, 233, 226, 0.11);
    --inset: #161513;
    --accent: #c8552a; /* ember holds for fills */
    --accent-text: #e2794a; /* ember-lift — clears AA on dark */
    --green: #10b981;
    --amber: #f59e0b;
    --red: #e0635a;
    --danger: #e0635a;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    14px/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
}

.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.topbar {
  margin-bottom: 24px;
}

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

/* the Cabane mark: an A-frame roofline ("cabin"), ember stroke (viewBox 0 0 24 18). */
.logo {
  height: 17px;
  width: auto;
  color: var(--accent);
  flex: 0 0 auto;
}

.brand h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--muted);
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}
.dot--green {
  background: var(--green);
  color: var(--green);
}
.dot--amber {
  background: var(--amber);
  color: var(--amber);
}
.dot--red {
  background: var(--red);
  color: var(--red);
}
.dot--unknown {
  background: var(--muted);
  color: var(--muted);
}

.conn-line {
  margin: 10px 0 2px;
  font-weight: 500;
}
.listen-line {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.count {
  color: var(--muted);
  font-weight: 400;
}
.hint {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
}

.ws-list,
.dispatch-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ws-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.ws-row:first-child {
  border-top: none;
}
.ws-row .ws-name {
  font-weight: 550;
}
.ws-row .ws-meta {
  color: var(--muted);
  font-size: 13px;
  margin-left: 2px;
}
.ws-row .spacer {
  flex: 1;
}
/* a terminally auth-failed workspace (rotated/revoked PAT). The
   meta line carries the "re-add this workspace" call to action in red so it
   reads as actionable, not as a transient reconnect. */
.ws-row .ws-meta.ws-meta--alert {
  color: var(--red);
}

/* CT29: the agents this device runs in this workspace, pulled from Cabane.
   Wraps to its own line under the workspace row (flex-basis 100%). */
.ws-row .ws-agents {
  flex-basis: 100%;
  list-style: none;
  margin: 4px 0 0;
  padding: 0 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ws-row .ws-agent {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.ws-row .ws-agent-name {
  font-weight: 550;
}
.ws-row .ws-agent-mode {
  color: var(--muted);
  font-size: 12px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.ws-row .ws-agent-warn {
  color: var(--red);
  font-size: 12px;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 6px 12px;
}
button:hover {
  border-color: var(--accent);
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.ghost {
  background: transparent;
}
button.danger,
button.danger:hover {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
}
button.small {
  padding: 3px 9px;
  font-size: 13px;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 16px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}
.empty.error {
  color: var(--red);
}

/* CT586: harnesses surface — which of the three the device exposes, how healthy
   each is, and (loudly) when it exposes none. */

/* a text-style button in a panel heading (the "Recheck" affordance). */
.link-btn {
  border: none;
  background: none;
  padding: 0;
  margin-left: auto;
  color: var(--accent-text);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.link-btn:hover {
  border: none;
  text-decoration: underline;
}

/* The loud empty state — the headline requirement. A device exposing zero
   harnesses is useless, so this is impossible to miss: an ember-tinted well with
   a large lead line, not a grey dot. */
.harness-empty {
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: rgba(200, 85, 42, 0.1);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.harness-empty-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 650;
  color: var(--accent-text);
}
.harness-empty-body {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
}

.harness-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.harness-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}
.harness-row:first-child {
  border-top: none;
}
.harness-name {
  font-weight: 600;
}
.harness-version {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.harness-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.harness-badge--exposed {
  color: var(--green);
}
.harness-badge--detected_not_exposed {
  color: var(--amber);
}
.harness-badge--needs_attention {
  color: var(--red);
}
.harness-badge--not_detected {
  color: var(--muted);
}
.harness-spacer {
  flex: 1;
}
/* the per-harness guidance line ("install and sign in…", "run opencode serve…"),
   wrapping to its own line under the row. */
.harness-detail {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 12.5px;
  margin: 0;
}
.harness-detail code {
  font-size: 11.5px;
}
/* the inline opencode-URL enable form (URL field + Add). */
.harness-enable {
  flex-basis: 100%;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.harness-enable input {
  font: inherit;
  flex: 1;
  min-width: 180px;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--inset);
  color: var(--ink);
}

.dispatch-row {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}
.dispatch-row:first-child {
  border-top: none;
}
.dispatch-head {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.dispatch-head .time {
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
  min-width: 42px;
}
.dispatch-head .ws {
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
}
.dispatch-head .preview {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dispatch-head .verdict {
  flex: 0 0 auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.verdict.ok {
  color: var(--green);
}
.verdict.err {
  color: var(--red);
}
.verdict.run {
  color: var(--amber);
}
.dispatch-detail {
  margin: 6px 0 2px;
  padding: 10px 12px;
  background: var(--inset);
  border-radius: 7px;
  font-size: 13px;
}
/* labeled message / reply sections inside the expanded row. */
.dispatch-detail .d-block + .d-block {
  margin-top: 10px;
}
.dispatch-detail .d-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 3px;
}
.dispatch-detail .d-body {
  white-space: pre-wrap;
  word-break: break-word;
}
.dispatch-detail .d-body.muted {
  color: var(--muted);
}
.dispatch-detail .err-text {
  color: var(--red);
}

.logs {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  font:
    12px/1.45 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
}

.setting {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.setting:first-of-type {
  border-top: none;
}
.setting label {
  flex: 0 0 180px;
  font-weight: 500;
}
.readonly {
  color: var(--muted);
}
/* green ✓ flashed to the right of a setting after it saves, then cleared. */
.saved-check {
  color: var(--green);
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}
select {
  font: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.version {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  max-width: 90vw;
}
.toast.error {
  background: var(--red);
  color: #fff;
}
