:root {
  --bg: #0b0b0c;
  --panel: #141416;
  --raise: #1b1b1e;
  --line: #26262a;
  --text: #f2f2f3;
  --text-2: #b4b4ba;
  --text-3: #7c7c84;
  --accent: #5b8cff;
  --ok: #3fb950;
  --busy: #e8a33d;
  --bad: #f85149;
  --add: #3fb950;
  --del: #f85149;
  --r: 12px;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f6f6f7;
    --panel: #ffffff;
    --raise: #f0f0f2;
    --line: #e2e2e6;
    --text: #141416;
    --text-2: #4a4a52;
    --text-3: #85858d;
    --accent: #2f66e8;
    color-scheme: light;
  }
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
a {
  color: var(--accent);
}

/* ------------------------------------------------------------------ chrome */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  text-decoration: none;
  color: var(--text);
}
.mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
  font-weight: 800;
  font-size: 15px;
}
.top__spacer {
  flex: 1;
}
.me {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
}
.me img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}
.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--text-3);
  font-size: 13px;
  flex-wrap: wrap;
}
.crumbs a {
  color: var(--text-2);
  text-decoration: none;
}
.crumbs a:hover {
  color: var(--text);
}
h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.lede {
  margin: 0 0 18px;
  color: var(--text-2);
}
.muted {
  color: var(--text-3);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--raise);
  font-weight: 550;
  text-decoration: none;
  color: var(--text);
}
.btn:hover {
  border-color: color-mix(in srgb, var(--text) 25%, var(--line));
}
.btn--primary {
  border-color: transparent;
  background: var(--text);
  color: var(--bg);
}
.btn--sm {
  padding: 5px 10px;
  font-size: 13px;
}
.btn--ghost {
  background: transparent;
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ------------------------------------------------------------------ cards and lists */
.card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
}
.list {
  display: flex;
  flex-direction: column;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}
.row:first-child {
  border-top: 0;
}
a.row:hover,
button.row:hover {
  background: var(--raise);
}
button.row {
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
}
.row__main {
  flex: 1;
  min-width: 0;
}
.row__title {
  overflow: hidden;
  font-weight: 560;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.row__sub {
  overflow: hidden;
  color: var(--text-3);
  font-size: 12.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.row__end {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 12.5px;
  white-space: nowrap;
}
.dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-3);
}
.dot[data-s='online'],
.dot[data-s='live'],
.dot[data-s='idle'] {
  background: var(--ok);
}
.dot[data-s='offline'],
.dot[data-s='stopped'],
.dot[data-s='exited'] {
  background: var(--text-3);
  opacity: 0.6;
}
.dot[data-s='working'] {
  background: transparent;
  border: 2px solid var(--busy);
  border-right-color: transparent;
  animation: spin 0.9s linear infinite;
}
.dot[data-s='failed'] {
  background: var(--bad);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.add {
  color: var(--add);
  font-family: var(--mono);
  font-size: 12px;
}
.del {
  color: var(--del);
  font-family: var(--mono);
  font-size: 12px;
}
.tag {
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--text-2);
  font-size: 11.5px;
}
.section {
  margin: 22px 0 8px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 14px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  width: fit-content;
}
.tabs a {
  padding: 5px 12px;
  border-radius: 7px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 550;
}
.tabs a[aria-current='page'] {
  background: var(--raise);
  color: var(--text);
}
.empty {
  padding: 26px 16px;
  color: var(--text-3);
  text-align: center;
}
.banner {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--busy) 45%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--busy) 10%, var(--panel));
  color: var(--text-2);
  font-size: 13px;
}
.error {
  color: var(--bad);
}
.field {
  display: flex;
  gap: 8px;
}
.input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  outline: none;
}
.input:focus {
  border-color: var(--accent);
}
select.input {
  flex: none;
}

/* ------------------------------------------------------------------ hero (signed out, linking) */
.hero {
  max-width: 460px;
  margin: 12vh auto 0;
  padding: 0 20px;
  text-align: center;
}
.hero .mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  border-radius: 14px;
  font-size: 28px;
}
.hero h1 {
  font-size: 28px;
}
.hero .btn {
  margin-top: 8px;
  padding: 11px 18px;
}
.code {
  margin: 18px 0;
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 650;
  letter-spacing: 0.12em;
}
.gh {
  width: 18px;
  height: 18px;
}

/* ------------------------------------------------------------------ terminal */
.term-view {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 58px);
}
.term-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}
.term-screen {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 6px 8px 10px;
  background: #0a0a0a;
}
.term-keys {
  display: flex;
  gap: 6px;
  padding: 8px 10px 4px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.term-keys button {
  flex: none;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--raise);
  font-family: var(--mono);
  font-size: 12.5px;
}
.term-line {
  display: flex;
  gap: 8px;
  padding: 6px 10px max(10px, env(safe-area-inset-bottom));
  background: var(--panel);
}

/* ------------------------------------------------------------------ workers */
.thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--user {
  align-self: flex-end;
  background: var(--raise);
}
.msg__tool {
  margin: 4px 0;
  color: var(--text-3);
  font-size: 12.5px;
}
.ask {
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: var(--r);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
  margin-bottom: 10px;
}
.ask__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.composer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 10px 0 max(10px, env(safe-area-inset-bottom));
  background: var(--bg);
}
textarea.input {
  resize: none;
  min-height: 42px;
  max-height: 160px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  transform: translateX(-50%);
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
}
