/* Orca Remote — mobile-first, dark-first. */

:root {
  color-scheme: dark;
  --bg: #0b0e14;
  --surface: #131823;
  --surface-2: #1a2130;
  --surface-3: #232c3e;
  --border: #242e42;
  --border-strong: #33405a;
  --text: #e7ebf2;
  --muted: #8f99ac;
  --faint: #5f6a7e;
  --accent: #5ea6ff;
  --accent-ink: #04101f;
  --accent-soft: rgba(94, 166, 255, 0.14);
  --ok: #3fd07f;
  --ok-soft: rgba(63, 208, 127, 0.14);
  --warn: #e8b647;
  --warn-soft: rgba(232, 182, 71, 0.15);
  --danger: #ff6b63;
  --danger-soft: rgba(255, 107, 99, 0.14);
  --term-bg: #06080c;
  --term-fg: #d7deea;
  --scrim: rgba(3, 6, 12, 0.62);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);

  /* terminal kinds (icon colour; always paired with a text label) */
  --k-shell: #aab4c5;
  --k-claude: #f0936c;
  --k-codex: #45c7c0;
  --k-bot: #a993fb;
  --k-unknown: #e09fcf;
  /* agent states */
  --st-working: var(--ok);
  --st-waiting: #f2b33d;
  --st-waiting-ink: #241700;
  --st-done: #8fa3c4;

  --radius: 14px;
  --radius-sm: 10px;
  --tap: 44px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --gutter-l: max(12px, var(--sal));
  --gutter-r: max(12px, var(--sar));
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #eef1f6;
    --surface-3: #e3e8f0;
    --border: #dde2ea;
    --border-strong: #c7cfdb;
    --text: #141a24;
    --muted: #5b6578;
    --faint: #8b94a5;
    --accent: #1f6fe0;
    --accent-ink: #ffffff;
    --accent-soft: rgba(31, 111, 224, 0.1);
    --ok: #138a48;
    --ok-soft: rgba(19, 138, 72, 0.1);
    --warn: #a86b00;
    --warn-soft: rgba(168, 107, 0, 0.1);
    --danger: #d23a31;
    --danger-soft: rgba(210, 58, 49, 0.09);
    --term-bg: #fbfcfe;
    --term-fg: #1b2230;
    --scrim: rgba(15, 20, 30, 0.38);
    --shadow: 0 12px 32px rgba(20, 30, 50, 0.16);

    --k-shell: #556074;
    --k-claude: #bf4f28;
    --k-codex: #0b7f7a;
    --k-bot: #6a48d6;
    --k-unknown: #a13d8c;
    --st-waiting: #9a5f00;
    --st-waiting-ink: #ffffff;
    --st-done: #4f6487;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--font);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
button:disabled { cursor: default; opacity: 0.45; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mono { font-family: var(--mono); }
.faint { color: var(--faint); }
.ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- shell ------------------------------------------------------------- */

.shell {
  position: fixed;
  left: 0; right: 0;
  top: var(--vvt, 0px);
  height: var(--vvh, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@supports not (height: 100dvh) {
  .shell { height: var(--vvh, 100vh); }
}

.offline {
  flex: none;
  padding: calc(var(--sat) + 6px) var(--gutter-r) 6px var(--gutter-l);
  background: var(--warn);
  color: #1d1400;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.shell.is-offline .appbar { padding-top: 6px; }

.app {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---- app bar ----------------------------------------------------------- */

.appbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: calc(var(--sat) + 6px) calc(var(--gutter-r) - 6px) 6px calc(var(--gutter-l) - 6px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  z-index: 5;
}
.brand { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding-left: 6px; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; flex: none; }
.appbar-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.appbar-title {
  margin: 0; font-size: 17px; font-weight: 650; line-height: 1.2; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.appbar-sub {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  color: var(--muted); font-size: 12px; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.icon-btn {
  flex: none;
  width: var(--tap); height: var(--tap);
  display: inline-grid; place-items: center;
  padding: 0; border: 0; border-radius: 12px;
  background: transparent; color: var(--text);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.text { font-size: 14px; font-weight: 650; letter-spacing: -0.02em; }
.icon-btn.text.big { font-size: 17px; }
.icon-btn.on { color: var(--accent); }
.icon-btn.danger-ico { color: var(--danger); }
.icon-btn.spinning .ico { animation: spin 0.8s linear infinite; }

.ico { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; }
.ico svg { width: 100%; height: 100%; }

.pill {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 2px; padding: 1px 8px 1px 7px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }

/* ---- scroll area ------------------------------------------------------- */

.scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--gutter-r) calc(var(--sab) + 104px) var(--gutter-l);
}

.ptr {
  height: 0; overflow: hidden;
  display: grid; place-items: center;
  color: var(--muted);
  transition: height 0.2s ease;
}
.ptr .ico { transform: rotate(var(--rot, 0deg)); }
.ptr.ready { color: var(--accent); }
.ptr.spin .ico { animation: spin 0.8s linear infinite; }

.toolbar {
  position: sticky; top: 0; z-index: 2;
  margin: 0 calc(-1 * var(--gutter-r)) 0 calc(-1 * var(--gutter-l));
  padding: 10px var(--gutter-r) 8px var(--gutter-l);
  background: var(--bg);
}

.search {
  display: flex; align-items: center; gap: 8px;
  height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search .ico { width: 18px; height: 18px; }
.search-input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  color: var(--text);
  font-size: 16px; /* >=16px: no iOS zoom on focus */
}
.search-input::placeholder { color: var(--faint); }
.search-input::-webkit-search-cancel-button { filter: grayscale(1); }

.chips { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px; font-weight: 600;
  position: relative;
}
/* extend hit area to 44px without growing the visual chip */
.chip::after { content: ""; position: absolute; inset: -4px 0; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-count { font-size: 12px; opacity: 0.75; font-variant-numeric: tabular-nums; }
.chip-count:empty { display: none; }

/* ---- lists + cards ----------------------------------------------------- */

.list { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.group-title {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 4px 0;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
}
.group-count {
  padding: 0 6px; border-radius: 6px; background: var(--surface-2);
  font-size: 11px; letter-spacing: 0; font-variant-numeric: tabular-nums;
}

.card {
  display: flex; flex-direction: column; gap: 6px;
  min-height: 72px;
  padding: 12px 10px 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 0;
  transition: background 0.12s ease, transform 0.12s ease;
}
a.card:active { background: var(--surface-2); transform: scale(0.99); }
.card.archived { opacity: 0.6; }
.card.unread { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

.card-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-title {
  flex: 1; min-width: 0;
  font-size: 16px; font-weight: 620; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-sub {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  color: var(--muted); font-size: 12.5px;
}
.card-sub .ico { width: 14px; height: 14px; }
.card-meta {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap;
  color: var(--muted); font-size: 12.5px;
}
.meta-time { white-space: nowrap; }
.meta-count { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-variant-numeric: tabular-nums; }
.meta-count .ico { width: 15px; height: 15px; }
.chev { width: 18px; height: 18px; color: var(--faint); }
.pin-ico { width: 16px; height: 16px; color: var(--accent); }

.unread-dot {
  flex: none; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.badge {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  border-radius: 6px;
  font-size: 12px; font-weight: 650; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.ws-meta {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 12px 4px 4px;
  color: var(--faint); font-size: 12px;
}
.ws-path { direction: rtl; text-align: left; }

.term-preview {
  min-width: 0;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--term-bg);
  color: var(--term-fg);
  font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.live-dot {
  flex: none; display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: var(--faint);
  transition: transform 0.15s ease;
}
.live-dot.on { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2s ease-out infinite; }
.live-dot.idle { background: color-mix(in srgb, var(--ok) 55%, var(--faint)); }
.live-dot.poll { background: var(--warn); }
.live-dot.off { background: var(--danger); }
.live-dot.blink { transform: scale(1.35); }

.skeletons { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; }
.skeleton {
  min-height: 84px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.skeleton.short { min-height: 60px; }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px; padding: 48px 20px;
}
.empty-ico { width: 40px; height: 40px; color: var(--faint); margin-bottom: 4px; }
.empty-title { margin: 0; font-size: 16px; font-weight: 650; }
.empty-sub { margin: 0 0 10px; color: var(--muted); font-size: 14px; max-width: 30ch; overflow-wrap: anywhere; }

/* ---- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px;
  font-size: 15px; font-weight: 650;
  background: var(--surface-2); color: var(--text);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border-strong); }
.btn.block { width: 100%; }
.btn:active { filter: brightness(0.92); }

.fab {
  position: absolute;
  right: var(--gutter-r);
  bottom: calc(var(--sab) + 16px);
  z-index: 4;
  display: inline-flex; align-items: center; gap: 8px;
  height: 54px; padding: 0 20px 0 16px;
  border: 0; border-radius: 18px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 16px; font-weight: 700;
  box-shadow: var(--shadow);
}
.fab:active { transform: scale(0.97); }

/* ---- terminal ---------------------------------------------------------- */

.app.is-terminal .appbar { gap: 0; }

.screen-wrap { position: relative; flex: 1; min-height: 0; background: var(--term-bg); }
.screen {
  position: absolute; inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px calc(var(--gutter-r) - 2px) 14px calc(var(--gutter-l) - 2px);
  outline: none;
}
.term {
  margin: 0;
  min-height: 100%;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.38;
  color: var(--term-fg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  tab-size: 4;
  font-variant-ligatures: none;
}
.term.nowrap { white-space: pre; overflow-wrap: normal; width: max-content; min-width: 100%; }

.jump {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 650;
  box-shadow: var(--shadow);
}
.jump::after { content: ""; position: absolute; inset: -4px; }
.jump .ico { width: 16px; height: 16px; }

.term-notice {
  position: absolute; left: 12px; right: 12px; top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
  font-size: 13px; font-weight: 600;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.composer {
  flex: none;
  padding: 6px var(--gutter-r) max(8px, var(--sab)) var(--gutter-l);
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.composer.disabled .composer-row { opacity: 0.6; }

.keybar {
  display: flex; gap: 6px;
  margin: 0 calc(-1 * var(--gutter-r)) 6px calc(-1 * var(--gutter-l));
  padding: 0 var(--gutter-r) 0 var(--gutter-l);
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.keybar::-webkit-scrollbar { display: none; }
.qk {
  flex: none;
  min-width: var(--tap); height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px; font-weight: 600;
}
.qk.wide { padding: 0 14px; }
.qk.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.qk:active { background: var(--surface-3); }

.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-input {
  flex: 1; min-width: 0;
  min-height: var(--tap); max-height: 132px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px; /* no iOS zoom */
  line-height: 1.3;
  resize: none;
  outline: none;
}
.composer-input:focus { border-color: var(--accent); }
.composer-input::placeholder { color: var(--faint); font-family: var(--font); }
.send-btn {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--tap); padding: 0 14px;
  border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700;
}
.send-btn .ico { width: 18px; height: 18px; }
.send-btn:active { filter: brightness(0.9); }

/* ---- layers: dialog + sheet ------------------------------------------- */

.layer {
  position: fixed; inset: 0; z-index: 50;
  display: flex;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.layer.open { opacity: 1; }
.layer.center { align-items: center; justify-content: center; padding: 20px max(20px, var(--sar)) 20px max(20px, var(--sal)); }
.layer.bottom { align-items: flex-end; justify-content: center; }

.dialog {
  width: 100%; max-width: 360px;
  padding: 20px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: scale(0.96);
  transition: transform 0.18s ease;
}
.layer.open .dialog { transform: none; }
.dialog-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.dialog-msg { margin: 0 0 18px; color: var(--muted); font-size: 15px; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; }

.sheet {
  width: 100%; max-width: 560px;
  max-height: 85%;
  overflow-y: auto;
  padding: 6px max(16px, var(--sar)) calc(var(--sab) + 16px) max(16px, var(--sal));
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  box-shadow: var(--shadow);
  transform: translateY(100%);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.layer.open .sheet { transform: none; }
.sheet-grip { width: 40px; height: 5px; margin: 4px auto 6px; border-radius: 3px; background: var(--border-strong); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-title { margin: 0; font-size: 18px; font-weight: 700; }
.sheet-head .icon-btn { margin-right: -10px; }
.sheet-body { display: flex; flex-direction: column; gap: 10px; }

.preset-list { display: flex; flex-direction: column; gap: 8px; }
.preset {
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 8px 10px 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: left;
}
.preset:active { background: var(--surface-3); }
.preset.busy { opacity: 0.6; pointer-events: none; }
.preset-ico {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 11px;
  font-family: var(--mono); font-size: 17px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}
.preset-ico.p-claude { background: rgba(217, 119, 87, 0.16); color: #e08a68; }
.preset-ico.p-codex { background: var(--ok-soft); color: var(--ok); }
.preset-ico.p-shell { font-size: 14px; }
.preset-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.preset-label { font-size: 16px; font-weight: 650; }
.preset-cmd { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.field {
  width: 100%;
  height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--faint); }

/* ---- toasts ------------------------------------------------------------ */

.toasts {
  position: fixed; z-index: 60;
  left: 0; right: 0;
  top: calc(var(--vvt, 0px) + var(--sat) + 64px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 16px;
  pointer-events: none;
}
.toast {
  max-width: min(420px, 100%);
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 14px; font-weight: 550;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  overflow-wrap: anywhere;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #03140a; }

/* ---- token screen ------------------------------------------------------ */

.token-screen {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--sat) + 24px) max(20px, var(--sar)) calc(var(--sab) + 24px) max(20px, var(--sal));
}
.token-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.token-logo { align-self: center; width: 64px; height: 64px; border-radius: 16px; }
.token-title { margin: 6px 0 0; text-align: center; font-size: 22px; font-weight: 750; }
.token-sub { margin: 0 0 8px; text-align: center; color: var(--muted); }
.token-hint { margin: 0; text-align: center; color: var(--faint); font-size: 13px; }
.token-hint code { font-family: var(--mono); color: var(--muted); }

/* ---- agent kinds + states --------------------------------------------- */

.kind-ico {
  --k: var(--k-shell);
  flex: none; display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px;
  color: var(--k);
  background: color-mix(in srgb, var(--k) 15%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--k) 22%, transparent);
}
.kind-ico svg { width: 22px; height: 22px; }
.kind-ico.sm { width: 26px; height: 26px; border-radius: 8px; }
.kind-ico.sm svg { width: 16px; height: 16px; }
.kind-ico.xs { width: 20px; height: 20px; border-radius: 6px; box-shadow: none; }
.kind-ico.xs svg { width: 13px; height: 13px; }
.k-shell { --k: var(--k-shell); }
.k-claude { --k: var(--k-claude); }
.k-codex { --k: var(--k-codex); }
.k-bot { --k: var(--k-bot); }
.k-unknown { --k: var(--k-unknown); }

.kind-label {
  flex: none;
  font-size: 12px; font-weight: 650; letter-spacing: 0.01em;
  color: var(--k, var(--muted));
}

.term-card .card-row { align-items: center; gap: 10px; }
.term-head { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.term-sub {
  display: flex; align-items: baseline; gap: 6px; min-width: 0;
  color: var(--muted); font-size: 12.5px; line-height: 1.3;
}
.term-sub-text { flex: 1; }
.term-sub .kind-label + .term-sub-text::before { content: "·"; margin-right: 6px; color: var(--faint); }

.tool-chip {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px;
  border-radius: 5px; background: var(--surface-2); color: var(--muted);
  font-size: 11.5px; white-space: nowrap;
}

.ag-state {
  --st: var(--st-done);
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650; white-space: nowrap;
  color: var(--st);
  background: color-mix(in srgb, var(--st) 14%, transparent);
}
.ag-state.compact { height: 20px; padding: 0 7px 0 6px; font-size: 11.5px; gap: 5px; }
.ag-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.ag-state.working { --st: var(--st-working); }
.ag-state.working .ag-dot { animation: ag-pulse 1.6s ease-out infinite; }
.ag-state.done { --st: var(--st-done); }
.ag-state.done .ag-dot { width: 6px; height: 6px; background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
/* waiting on you: the loudest state — solid fill, dark ink */
.ag-state.waiting { --st: var(--st-waiting); background: var(--st-waiting); color: var(--st-waiting-ink); }
.ag-state.waiting .ag-dot { background: currentColor; }

.card.st-waiting {
  border-color: color-mix(in srgb, var(--st-waiting) 60%, var(--border));
  background: color-mix(in srgb, var(--st-waiting) 6%, var(--surface));
  box-shadow: inset 3px 0 0 var(--st-waiting);
}
.card.st-working { border-color: color-mix(in srgb, var(--st-working) 28%, var(--border)); }

.ws-agents { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.ws-agent { display: inline-flex; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }
.ws-agent-n { font-size: 12px; color: var(--muted); }
.ws-meta .ws-agents { flex: none; }

.agent-strip {
  flex: none;
  display: flex; align-items: center; gap: 8px; min-width: 0;
  min-height: 40px;
  padding: 6px var(--gutter-r) 6px var(--gutter-l);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
}
.agent-strip-text { flex: 1; color: var(--muted); }
.agent-strip.st-waiting {
  background: color-mix(in srgb, var(--st-waiting) 12%, var(--surface));
  border-bottom-color: color-mix(in srgb, var(--st-waiting) 50%, var(--border));
}
.agent-strip.st-waiting .agent-strip-text { color: var(--text); }

/* ---- motion ------------------------------------------------------------ */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes ag-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .ag-state.working .ag-dot { animation: none; box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 35%, transparent); }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* wider screens: keep content in a readable column */
@media (min-width: 720px) {
  .scroll > .list, .scroll > .ws-meta { max-width: 680px; margin-left: auto; margin-right: auto; }
  .toolbar > * { max-width: 680px; margin-left: auto; margin-right: auto; }
}

/* collapse groups */
.toolbar-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; min-width: 0; }
.toolbar-row > .chips {
  flex: 1; min-width: 0; margin-top: 0;
  /* fade the right edge so clipped chips read as scrollable */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent);
  padding-right: 14px;
}
.collapse-all {
  flex: none; position: relative;
  height: 36px; padding: 0 10px;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--accent); font: inherit; font-size: 13px; font-weight: 650; white-space: nowrap;
}
.collapse-all::after { content: ""; position: absolute; inset: -4px 0; } /* 44px hit area */
.collapse-all:active { background: var(--accent-soft); }
.collapse-all[hidden] { display: none; }
.group-title { margin: 6px 0 0; }
.group-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; min-height: var(--tap); padding: 0 6px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-align: left;
  cursor: pointer;
}
.group-toggle:active { background: var(--surface-2); }
.group-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.group-name { min-width: 0; }
.group-chev { flex: none; width: 16px; height: 16px; color: var(--faint); transform: rotate(90deg); transition: transform 0.18s ease; }
.group.collapsed .group-chev { transform: rotate(0deg); }
.group-sum { display: none; align-items: center; gap: 8px; margin-left: auto; letter-spacing: 0; }
.group.collapsed .group-sum { display: inline-flex; }
.group-run {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 7px; border-radius: 6px;
  background: var(--ok-soft); color: var(--ok);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.group-run-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.group-body { display: flex; flex-direction: column; gap: 8px; }
.group-body[hidden] { display: none; }
.group.collapsed { margin-bottom: 2px; }
@media (prefers-reduced-motion: reduce) { .group-chev { transition: none; } }

/* ---- hub: hosts, login, account, read-only ------------------------------ */

.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pill-row .pill { margin-top: 2px; }
.ro-badge { gap: 4px; height: 20px; padding: 0 7px; font-size: 11.5px; flex: none; }
.ro-badge .ico { width: 13px; height: 13px; }
.pill-row .ro-badge { margin-top: 2px; }
.appbar-sub .ro-badge { height: 18px; padding: 0 6px; font-size: 11px; }
.appbar-host { color: var(--muted); }

/* host filter chips */
.host-chips { margin-top: 8px; }
.host-chip-btn { gap: 6px; }
.host-chip-btn.is-off { color: var(--faint); }
.host-chip-btn.active.is-off { color: var(--accent-ink); }

/* status dot: on (Orca running) / warn (machine up, Orca off) / off */
.host-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.host-dot.on, .host-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.host-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.host-dot.off { background: var(--faint); }

/* host section = card-like container around its repo groups */
.host-group {
  gap: 4px;
  margin-bottom: 12px;
  padding: 2px 8px 6px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: color-mix(in srgb, var(--surface) 55%, var(--bg));
}
.host-group.collapsed { margin-bottom: 8px; padding-bottom: 2px; }
.host-group > .host-title { margin: 0; text-transform: none; letter-spacing: 0; color: var(--text); }
.host-toggle { min-height: 56px; padding: 6px 4px; gap: 8px; }
.host-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.host-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.host-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.host-sub { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.host-sub > * + *::before { content: "·"; margin-right: 6px; color: var(--faint); }
.host-state.ok { color: var(--ok); }
.host-state.warn { color: var(--warn); }
.host-state.off { color: var(--faint); }
.host-sub > * { white-space: nowrap; }
.host-agents { display: flex; margin-top: 3px; font-weight: 500; text-transform: none; }
.host-agents .ws-agents { flex-wrap: wrap; row-gap: 4px; }
/* the host chevron always points at its own state, not an outer one */
.host-group:not(.collapsed) > .host-title .group-chev { transform: rotate(90deg); }
.host-group.collapsed > .host-title .group-chev { transform: rotate(0deg); }
.host-group .group:not(.collapsed) .group-chev { transform: rotate(90deg); }
.host-group:not(.collapsed) .group:not(.collapsed) .group-sum { display: none; }
.host-group .group.collapsed .group-sum { display: inline-flex; }
.host-body { gap: 4px; }
.host-body > .group { margin-bottom: 4px; }
.host-body > .group > .group-title { margin-top: 2px; }
.host-empty { margin: 0 6px 8px; color: var(--muted); font-size: 14px; }

.card.host-offline {
  min-height: 0; margin: 2px 0 4px;
  background: var(--surface-2);
  border-style: dashed;
  color: var(--muted);
}
.card.host-offline .card-title { color: var(--muted); text-align: left; }
.card.host-offline .card-sub { font-family: var(--font); font-size: 13.5px; }
.host-off-ico { color: var(--faint); }
.host-group.offline .host-name { color: var(--muted); }

/* workspace header: which machine */
.host-chip {
  flex: none; display: inline-flex; align-items: center; gap: 5px; max-width: 45%;
  height: 22px; padding: 0 8px 0 6px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 650;
}
.host-chip .ico { width: 14px; height: 14px; }

/* read-only terminal: the screen takes the composer's place */
.app.is-terminal.read-only .screen-wrap { padding-bottom: var(--sab); }

/* login */
.login-card { gap: 14px; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-label { font-size: 14px; font-weight: 650; }
.login-opt { color: var(--muted); font-weight: 500; }
.login-hint { margin: 0; color: var(--muted); font-size: 13px; }
.login-error {
  margin: 0; padding: 10px 12px; border-radius: 12px;
  background: var(--danger-soft); color: var(--danger);
  font-size: 14px; font-weight: 600;
}
.field[aria-invalid="true"] { border-color: var(--danger); }
.login-lock { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.token-hint .ico { display: inline-grid; }

/* change password */
.password-form { display: flex; flex-direction: column; gap: 14px; }

/* account sheet */
.account { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.account-ico {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
}
.account-text { min-width: 0; }
.account-name { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.account-role { color: var(--muted); font-size: 13.5px; }
.account-meta { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.account-meta dt { color: var(--muted); }
.account-meta dd { margin: 0; overflow-wrap: anywhere; }
.btn .ico { width: 18px; height: 18px; }
