/* Claudex Command Center — visual system
 *
 * Pure black, no blue. Primary accent is near-white. The single warm color is
 * an amber/orange (#ffb347) used very sparingly for "spark" highlights and
 * shooting-star streaks. Danger is red; success is a muted green.
 */

:root {
  --bg: #000000;
  --bg-elev: #08080a;
  --panel: rgba(10, 10, 12, 0.86);
  --panel-solid: #0c0c0e;
  --line: #1a1a1d;
  --line-bright: #2b2b30;
  --line-2: #404046;

  --text: #ececee;
  --text-soft: #b9bbc1;
  --muted: #80828a;
  --dim: #4a4d54;

  --accent: #f3f3f5;
  --accent-soft: rgba(255, 255, 255, 0.06);
  --accent-warm: #ffb347;          /* "shooting star" amber */
  --accent-warm-soft: rgba(255, 179, 71, 0.1);

  --green: #4cd964;
  --red: #ff4060;
  --red-soft: rgba(255, 64, 96, 0.14);
  --yellow: #ffb347;
  --glow: rgba(255, 255, 255, 0.06);

  --radius: 10px;
  --radius-lg: 14px;
  --topbar: 60px;
  color-scheme: dark;
}

/* ───── Base ───── */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button, input, textarea, select { font: inherit; color: inherit; }
button {
  background: #111114; border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 9px 14px; min-height: 36px; cursor: pointer;
  font-weight: 500; letter-spacing: 0.01em;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .04s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
button:hover { border-color: var(--line-2); background: #16161a; }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary {
  background: var(--accent); border-color: var(--accent); color: #08080a;
  font-weight: 700;
  box-shadow: 0 0 32px rgba(255, 255, 255, 0.08);
}
button.primary:hover { background: #ffffff; color: #000; }
button.danger { color: var(--red); border-color: rgba(255, 64, 96, 0.4); background: rgba(255, 64, 96, 0.05); }
button.danger:hover { background: var(--red-soft); color: var(--red); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.icon-btn { padding: 2px 9px; font-size: 16px; min-height: 28px; line-height: 1; border-radius: 6px; }
.link-btn {
  background: transparent; border: 0; padding: 0; min-height: 0;
  color: var(--accent-warm); text-decoration: underline; text-underline-offset: 2px;
  font-weight: 500;
}
.link-btn:hover { color: #ffd28a; background: transparent; }

input, textarea, select {
  background: #050507; border: 1px solid var(--line); color: var(--text);
  border-radius: 9px; padding: 11px 12px; outline: none; width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--line-2); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
  background: #0a0a0c;
}
textarea { min-height: 88px; resize: vertical; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; }
select {
  -webkit-appearance: none; appearance: none;
  background: #050507 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2380828a' d='M2 4l4 4 4-4'/></svg>") no-repeat right 11px center;
  padding-right: 30px;
}

label {
  display: block; color: var(--muted); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.11em; margin: 14px 0 0; font-weight: 500;
}
label input, label textarea, label select { margin-top: 6px; text-transform: none; letter-spacing: 0; font-size: 13px; }
label.inline {
  display: inline-flex; align-items: center; gap: 6px; margin: 0;
  text-transform: none; letter-spacing: 0; color: var(--text); font-size: 12px;
}
label.inline input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.checkbox-row { display: inline-flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; }

code, pre, .term-window { font-family: 'JetBrains Mono', ui-monospace, monospace; }
code {
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 6px; font-size: 11.5px; color: var(--accent-warm);
}
kbd {
  font-family: 'JetBrains Mono', monospace;
  background: #050507; border: 1px solid var(--line-2);
  border-radius: 5px; padding: 2px 7px; font-size: 10.5px; color: var(--text);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,0.05);
}

/* ───── Starry sky + shooting stars ───── */
.sky { position: fixed; inset: 0; z-index: -2; pointer-events: none; background: #000; }
.starfield, .starfield-near {
  position: absolute; inset: 0;
}
/* Far layer — many small dim dots, faint twinkle. */
.starfield {
  background:
    radial-gradient(1px 1px at 4% 8%,   rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,0.7),  transparent 60%),
    radial-gradient(1px 1px at 22% 41%, rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(1px 1px at 28% 64%, rgba(255,255,255,0.5),  transparent 60%),
    radial-gradient(1px 1px at 35% 12%, rgba(255,255,255,0.6),  transparent 60%),
    radial-gradient(1px 1px at 41% 31%, rgba(255,255,255,0.62), transparent 60%),
    radial-gradient(1px 1px at 48% 55%, rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(1px 1px at 56% 76%, rgba(255,255,255,0.5),  transparent 60%),
    radial-gradient(1px 1px at 62% 16%, rgba(255,255,255,0.45), transparent 60%),
    radial-gradient(1px 1px at 71% 22%, rgba(255,255,255,0.7),  transparent 60%),
    radial-gradient(1px 1px at 79% 50%, rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(1px 1px at 85% 58%, rgba(255,255,255,0.5),  transparent 60%),
    radial-gradient(1px 1px at 90% 30%, rgba(255,255,255,0.6),  transparent 60%),
    radial-gradient(1px 1px at 96% 72%, rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(1px 1px at 18% 88%, rgba(255,255,255,0.6),  transparent 60%),
    radial-gradient(1px 1px at 38% 92%, rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(1px 1px at 63% 95%, rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(1px 1px at 8% 47%,  rgba(255,255,255,0.5),  transparent 60%),
    radial-gradient(1px 1px at 50% 5%,  rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(1px 1px at 92% 84%, rgba(255,255,255,0.7),  transparent 60%),
    #000;
  animation: twinkle-far 11s ease-in-out infinite;
  opacity: 0.95;
}
/* Near layer — fewer but bigger/brighter stars, some warm. Faster twinkle. */
.starfield-near {
  background:
    radial-gradient(1.6px 1.6px at 15% 70%, rgba(255,255,255,0.95), transparent 55%),
    radial-gradient(1.6px 1.6px at 33% 19%, rgba(255,255,255,0.9),  transparent 55%),
    radial-gradient(1.6px 1.6px at 58% 38%, rgba(255,255,255,0.95), transparent 55%),
    radial-gradient(1.6px 1.6px at 80% 12%, rgba(255,255,255,0.9),  transparent 55%),
    radial-gradient(1.6px 1.6px at 88% 80%, rgba(255,255,255,0.95), transparent 55%),
    radial-gradient(1.6px 1.6px at 5% 32%,  rgba(255,255,255,0.85), transparent 55%),
    radial-gradient(2.2px 2.2px at 26% 49%, rgba(255,210,150,0.85), transparent 55%),
    radial-gradient(2.2px 2.2px at 67% 67%, rgba(255,179,71,0.9),   transparent 55%),
    radial-gradient(2.2px 2.2px at 44% 84%, rgba(220,235,255,0.95), transparent 55%),
    transparent;
  animation: twinkle-near 6s ease-in-out infinite;
  mix-blend-mode: screen;
}
@keyframes twinkle-far  { 0%,100% { opacity: 0.9; } 50% { opacity: 1.0; } }
@keyframes twinkle-near { 0%,100% { opacity: 0.85; } 50% { opacity: 1.0; } }

.shooting-stars { position: absolute; inset: 0; overflow: hidden; }
.shooting-star {
  position: absolute; top: var(--y, 20%); left: var(--x, -15%);
  width: 220px; height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.2) 25%,
    rgba(255,255,255,1) 70%,
    rgba(255,210,150,0.95) 88%,
    rgba(255,179,71,0.4) 96%,
    transparent 100%);
  border-radius: 999px;
  transform: rotate(var(--angle, 18deg));
  opacity: 0;
  animation: shoot var(--dur, 1.4s) cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.6)) drop-shadow(0 0 18px rgba(255,179,71,0.35));
}
.shooting-star.bright {
  width: 280px; height: 3px;
  filter: drop-shadow(0 0 14px rgba(255,255,255,0.9)) drop-shadow(0 0 28px rgba(255,179,71,0.55));
}
@keyframes shoot {
  0%   { opacity: 0; transform: rotate(var(--angle, 18deg)) translateX(0); }
  8%   { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--angle, 18deg)) translateX(125vw); }
}

/* ───── Auth (login) view ───── */
.auth-shell {
  position: fixed; inset: 0; display: none; z-index: 100;
  place-items: center; padding: 24px;
}
body[data-auth="anonymous"] .auth-shell { display: grid; }
.auth-card {
  width: min(100%, 420px);
  background: rgba(8, 8, 10, 0.78); backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.75), 0 0 60px rgba(255, 255, 255, 0.03);
  animation: card-in .35s ease;
}
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-mark {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 16px; border: 1px solid var(--line-2);
  display: grid; place-items: center;
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 18px; color: var(--text);
  background: linear-gradient(180deg, #0e0e10, #050507);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 0 28px rgba(255,179,71,0.06);
}
.auth-title { font-size: 18px; font-weight: 700; }
.auth-subtitle { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.auth-error {
  background: rgba(255, 64, 96, 0.08); border: 1px solid rgba(255, 64, 96, 0.35);
  color: var(--red); padding: 9px 12px; border-radius: 8px; font-size: 12.5px; margin-top: 14px;
}
.auth-submit { width: 100%; margin-top: 16px; min-height: 42px; font-size: 14px; }
.auth-footer { margin-top: 18px; color: var(--muted); font-size: 12px; text-align: center; }

/* ───── App shell ───── */
.app-shell { display: none; flex-direction: column; height: 100dvh; }
body[data-auth="authenticated"] .app-shell { display: flex; }
.topbar {
  height: var(--topbar); display: flex; align-items: center; gap: 14px;
  padding: 0 18px; padding-top: env(safe-area-inset-top);
  background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line); z-index: 50;
}
.hamburger {
  display: none; min-height: 32px; min-width: 32px; padding: 0;
  font-size: 22px; background: transparent; border: 0;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line-2);
  display: grid; place-items: center; font-family: 'JetBrains Mono', monospace;
  font-weight: 700; font-size: 12.5px; color: var(--text);
  background: linear-gradient(180deg, #0e0e10, #050507);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 0 16px rgba(255,179,71,0.04);
  flex-shrink: 0;
}
.brand-text { min-width: 0; }
.brand-title { font-size: 14.5px; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; }
.brand-subtitle { font-size: 10px; color: var(--muted); white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 7px 14px; font-size: 12.5px; font-weight: 500;
  background: transparent; border: 1px solid transparent;
  color: var(--text-soft); white-space: nowrap;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.03); border-color: var(--line); }
.tab.active { color: var(--text); background: rgba(255,255,255,0.06); border-color: var(--line-bright); }
.topbar-right { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.status-pill {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 11px; color: var(--muted); font-size: 11px;
}
.status-pill.bad { border-color: rgba(255, 64, 96, 0.4); color: var(--red); }
.dot, .state-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  display: inline-block; flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.dot.bad, .state-dot.bad { background: var(--red); }
.pulse { animation: pulse 1.6s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: 0.35; } }

.user-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 5px; min-height: 36px;
  background: rgba(255,255,255,0.03); border-color: var(--line);
  font-size: 12.5px; font-weight: 500;
}
.user-pill:hover { background: rgba(255,255,255,0.06); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, #ffb347, #ff7a40);
  color: #1a0e00; font-weight: 800; font-size: 11.5px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.user-name { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chev { color: var(--muted); font-size: 10px; }

.user-menu {
  position: absolute; right: 18px; top: calc(var(--topbar) + 6px); z-index: 80;
  width: 240px;
  background: rgba(8,8,10,0.94); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line-bright); border-radius: 12px;
  padding: 8px; box-shadow: 0 30px 80px rgba(0,0,0,0.7);
  animation: card-in .14s ease;
}
.user-menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-menu-name { font-size: 13px; font-weight: 600; }
.user-menu-role { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.user-menu-build { font-size: 10px; color: var(--dim); margin-top: 4px; font-family: 'JetBrains Mono', monospace; }

/* Non-dismissable stale-client banner. Fires when the JS's baked-in
   __APP_VERSION__ is older than the server's current build. The "Refresh
   now" button does a full location.reload() to pick up the new HTML + JS. */
.stale-banner {
  position: fixed; left: 50%; top: 12px; transform: translateX(-50%);
  z-index: 700; max-width: calc(100vw - 24px);
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-radius: 999px;
  background: rgba(255, 179, 71, 0.12);
  border: 1px solid rgba(255, 179, 71, 0.5);
  color: var(--accent-warm);
  font-size: 12.5px; font-weight: 500;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0,0,0,0.6);
  animation: card-in .25s ease;
}
.stale-banner .stale-banner-btn {
  padding: 6px 12px; min-height: 0; font-size: 11.5px;
  background: var(--accent-warm); color: #1a0e00; border-color: var(--accent-warm);
}
.stale-banner .stale-banner-btn:hover { background: #ffd28a; }
.menu-item {
  width: 100%; text-align: left; padding: 8px 10px;
  background: transparent; border: 0; min-height: 0; font-size: 13px; border-radius: 7px;
}
.menu-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.menu-item.danger { color: var(--red); }
.menu-divider { height: 1px; background: var(--line); margin: 6px 4px; }

.main { flex: 1; min-height: 0; position: relative; }
.view { display: none; height: 100%; min-height: 0; }
.view.active { display: flex; }

/* ───── Canvas tab ───── */
.launch-panel {
  width: 340px; background: var(--panel); border-right: 1px solid var(--line);
  z-index: 30; display: flex; flex-direction: column;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  transition: width .18s ease;
}
/* Collapsed-to-rail: the full form is hidden, an icon-sized strip remains.
   Clicking it expands back. Persisted in localStorage so it survives reload. */
.launch-panel.rail { width: 48px; }
.launch-panel.rail .panel-head,
.launch-panel.rail .panel-body { display: none; }
.launch-panel.rail .rail-expand { display: flex; }
.rail-expand {
  display: none; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 6px; padding: 16px 0; width: 100%; height: 100%;
  background: transparent; border: 0; min-height: 0; cursor: pointer;
  color: var(--text-soft);
}
.rail-expand:hover { color: var(--text); background: rgba(255,255,255,0.02); }
.rail-expand .rail-icon {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--line-2); display: grid; place-items: center;
  color: var(--accent-warm); font-size: 18px; font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.rail-expand .rail-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  font-weight: 600;
  transform: rotate(180deg);   /* read bottom-to-top */
  color: var(--muted);
}
.panel-head-actions { display: flex; gap: 4px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-soft); text-transform: uppercase; font-size: 11px; letter-spacing: 0.14em;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line); flex-shrink: 0;
  font-weight: 600;
}
.panel-body { flex: 1; overflow: auto; padding: 4px 16px 16px; -webkit-overflow-scrolling: touch; }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-three { display: grid; grid-template-columns: 2fr 1fr 2fr; gap: 8px; }
.launch-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 16px; }
.launch-actions button { min-height: 42px; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.danger-zone button { width: 100%; }

.canvas-wrap { position: relative; flex: 1; overflow: hidden; min-width: 0; background: transparent; cursor: grab; }
.canvas-wrap.panning { cursor: grabbing; }
/* Desktop canvas is a transformable layer (translate+scale via JS) so users
   can wheel-zoom and drag-pan to arrange many terminals side-by-side. The
   terminal windows inside stay absolutely positioned in "world" coords. */
.canvas { position: absolute; top: 0; left: 0; width: 0; height: 0; transform-origin: 0 0; will-change: transform; }
.zoom-pop {
  position: absolute; right: 14px; bottom: 14px; z-index: 38;
  padding: 4px 10px; border-radius: 999px; font-size: 11px;
  font-family: 'JetBrains Mono', monospace; letter-spacing: 0.04em;
  background: rgba(8, 8, 10, 0.85); border: 1px solid var(--line);
  color: var(--text-soft); pointer-events: none; opacity: 0;
  transition: opacity .18s ease; backdrop-filter: blur(8px);
}
.zoom-pop.vis { opacity: 1; }
.zoom-pop .recenter { pointer-events: auto; cursor: pointer; margin-left: 6px; color: var(--accent-warm); }
.floating-launch {
  display: none; position: absolute; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 40; padding: 12px 18px; border-radius: 999px; font-weight: 600;
  background: var(--accent); color: #08080a; border: 0;
  box-shadow: 0 10px 40px rgba(0,0,0,0.7), 0 0 28px rgba(255,255,255,0.08);
  align-items: center; gap: 8px;
}
.floating-launch:hover { background: #fff; }
.floating-launch .plus { font-weight: 800; font-size: 16px; }

.empty-state { position: absolute; inset: 0; display: none; place-items: center; pointer-events: none; padding: 24px; }
.empty-state.show { display: grid; pointer-events: auto; }
.empty-card {
  background: rgba(8, 8, 10, 0.86); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 32px 36px; text-align: center; max-width: 480px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.empty-icon { font-size: 38px; color: var(--accent-warm); margin-bottom: 10px; filter: drop-shadow(0 0 12px rgba(255,179,71,0.45)); }
.empty-card h2 { margin: 0 0 8px; font-size: 19px; }
.empty-card p { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.empty-card strong { color: var(--text); font-weight: 600; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.mobile-toolbar {
  display: none; position: absolute; left: 12px; right: 12px; top: 12px; z-index: 36;
  align-items: center; gap: 10px; justify-content: space-between;
}
.mobile-mode {
  display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: rgba(8, 8, 10, 0.85); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.mode-chip {
  padding: 6px 14px; min-height: 0; border-radius: 999px; font-size: 11.5px;
  background: transparent; border: 0; color: var(--text-soft);
}
.mode-chip.active { background: rgba(255,255,255,0.1); color: var(--text); }
.dismiss-closed {
  padding: 7px 12px; min-height: 0; border-radius: 999px; font-size: 11.5px;
  background: rgba(8, 8, 10, 0.85); border: 1px solid var(--line); color: var(--text-soft);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.dismiss-closed:hover { color: var(--text); border-color: var(--line-2); }
.mobile-switcher {
  display: none; position: absolute; left: 12px; right: 12px; top: 56px; z-index: 35;
  gap: 6px; overflow-x: auto; scrollbar-width: none;
}
.mobile-switcher::-webkit-scrollbar { display: none; }
.mobile-switcher .chip {
  flex-shrink: 0; padding: 8px 14px; border-radius: 999px; font-size: 12px;
  background: rgba(8, 8, 10, 0.82); border: 1px solid var(--line); color: var(--text-soft);
  white-space: nowrap; max-width: 60vw; overflow: hidden; text-overflow: ellipsis;
  backdrop-filter: blur(10px); min-height: 0;
}
.mobile-switcher .chip.active { border-color: var(--line-bright); color: var(--text); background: rgba(255,255,255,0.08); }

/* ───── Terminal windows ───── */
.term-window {
  position: absolute; background: #000; border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; display: flex; flex-direction: column;
  min-width: 320px; min-height: 240px;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.85);
  transition: box-shadow .18s ease, border-color .14s ease, opacity .15s ease;
  contain: layout paint; will-change: transform;
  cursor: default;
}
.term-window.focused { border-color: var(--line-bright); box-shadow: 0 20px 90px rgba(0, 0, 0, 0.95), 0 0 36px rgba(255,255,255,0.05); }
.term-window.minimized { opacity: 0.45; }
.term-window.dangerous .term-bar { box-shadow: inset 0 -1px 0 var(--red); }
.term-window.dangerous .term-bar::after {
  content: "⚠ DANGEROUS"; font-family: 'JetBrains Mono', monospace; font-size: 9.5px;
  letter-spacing: 0.08em; color: var(--red); padding: 0 6px; font-weight: 700;
}
.term-window.stale .term-bar::before {
  content: "⏱ STALE"; font-family: 'JetBrains Mono', monospace; font-size: 9.5px;
  letter-spacing: 0.08em; color: var(--yellow); padding: 0 6px; font-weight: 700;
}
.term-bar {
  height: 34px; background: linear-gradient(180deg, #0d0d10, #07070a);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px;
  padding: 0 10px; cursor: grab; user-select: none; flex-shrink: 0; touch-action: none;
}
.term-bar:active { cursor: grabbing; }
.traffic { display: flex; gap: 6px; }
.traffic-btn {
  /* Visible "dot" stays Mac-traffic-light sized for the desktop look,
     but a transparent ::before expands the hit area to a finger-friendly
     square so a slightly-off tap still registers. The drag handler on the
     term-bar bails when ev.target.closest("button") matches, so this also
     prevents accidental window-drag when the user meant to close. */
  position: relative;
  width: 12px; height: 12px;
  border: 0; padding: 0; min-height: 0;
  border-radius: 50%;
  transition: filter .12s ease, transform .08s ease;
}
.traffic-btn::before {
  /* Invisible tap target — actual click hit zone */
  content: ""; position: absolute;
  inset: -6px;             /* desktop: 24x24 hit area on a 12x12 dot */
  border-radius: 8px;
  background: transparent;
}
.traffic-btn:hover { filter: brightness(1.3); transform: scale(1.12); }
.traffic-btn.close { background: var(--red); }
.traffic-btn.min { background: var(--yellow); }
.traffic-btn.max { background: var(--green); }
.term-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; font-size: 11.5px; color: var(--muted); }
.term-title .label { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.term-title .meta { font-size: 10px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; padding: 2px 7px;
  border-radius: 4px; border: 1px solid var(--line-bright); color: var(--text);
  text-transform: uppercase; flex-shrink: 0; background: rgba(255,255,255,0.03);
}
.agent-tag[data-agent="codex"] { color: var(--accent-warm); border-color: rgba(255,179,71,0.3); background: rgba(255,179,71,0.06); }
.os-badge {
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.05em; padding: 2px 7px;
  border-radius: 4px; border: 1px solid var(--line); color: var(--muted);
  text-transform: uppercase; flex-shrink: 0; background: rgba(255,255,255,0.02);
  margin-left: 4px;
}
.os-badge[data-os="windows"] { color: #6cbcff; border-color: rgba(108,188,255,0.28); background: rgba(108,188,255,0.05); }
.os-badge[data-os="mac"]     { color: #d5d5d5; border-color: rgba(220,220,220,0.28); background: rgba(220,220,220,0.04); }
.os-badge[data-os="linux"]   { color: #ffb347; border-color: rgba(255,179,71,0.25); background: rgba(255,179,71,0.05); }
.hint-text {
  display: block; margin-top: 4px; font-size: 11.5px; color: var(--dim);
  line-height: 1.45;
}
.hint-text code { background: rgba(255,255,255,0.05); padding: 1px 5px; border-radius: 3px; font-size: 10.5px; }
.term-kill { padding: 4px 9px; font-size: 10.5px; min-height: 0; color: var(--red); border-color: rgba(255, 64, 96, 0.35); }
.term-kill:hover { background: var(--red-soft); }
.term-body { flex: 1; min-height: 0; background: #000; position: relative; }
.term-body .xterm { padding: 6px; height: 100%; }
.term-body .xterm-viewport { background: transparent !important; }
.resize-handle {
  position: absolute; right: 0; bottom: 0; width: 18px; height: 18px;
  cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.1) 50%);
}

/* ───── Preset chips ───── */
.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.preset-chips .chip {
  padding: 7px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); color: var(--text-soft);
  min-height: 0; line-height: 1; transition: border-color .14s, color .14s, background .14s;
}
.preset-chips .chip:hover { color: var(--text); border-color: var(--line-2); }
.preset-chips .chip.active { color: var(--text); border-color: var(--line-bright); background: rgba(255,255,255,0.08); }
.preset-chips .chip[data-preset$="-yolo"].active,
.preset-chips .chip[data-preset="claude-skip-perms"].active {
  color: var(--red); border-color: rgba(255, 64, 96, 0.5); background: rgba(255, 64, 96, 0.08);
}
.preset-hint { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.5; min-height: 34px; }
.preset-hint.danger { color: var(--red); }

.advanced { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 6px; }
.advanced summary { cursor: pointer; padding: 8px 0; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.advanced summary:hover { color: var(--text); }

.trust-hint {
  margin: 14px 0 0; font-size: 11.5px; color: var(--text-soft); line-height: 1.55;
  background: rgba(255, 179, 71, 0.04); border: 1px solid rgba(255, 179, 71, 0.18);
  border-radius: 9px; padding: 10px 12px;
}
.trust-hint strong { color: var(--text); font-weight: 600; }

/* ───── Terminal context menu ───── */
.term-context-menu {
  position: fixed; z-index: 600; min-width: 220px;
  background: rgba(10, 10, 12, 0.97); border: 1px solid var(--line-bright);
  border-radius: 10px; padding: 4px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7), 0 0 30px rgba(255,255,255,0.04);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  animation: card-in .12s ease;
}
.term-context-menu .ctx-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 9px 12px; min-height: 0; font-size: 12.5px;
  background: transparent; border: 0; border-radius: 6px;
  color: var(--text);
}
.term-context-menu .ctx-item:hover:not(:disabled) { background: rgba(255,255,255,0.06); }
.term-context-menu .ctx-item:disabled { opacity: 0.4; cursor: not-allowed; }
.term-context-menu .ctx-item .ctx-icon {
  width: 20px; text-align: center; color: var(--accent-warm); font-size: 13px;
}
.term-context-menu .ctx-shortcut {
  margin-left: auto; font-size: 10.5px; color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}
.term-context-menu .ctx-divider {
  height: 1px; background: var(--line); margin: 4px 4px;
}
.term-context-menu .ctx-note {
  padding: 6px 12px; font-size: 10.5px; color: var(--muted); line-height: 1.4;
}

/* ───── Modal ───── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fade-in .14s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel-solid); border: 1px solid var(--line-bright); border-radius: 14px;
  padding: 24px 26px; max-width: 460px; width: calc(100% - 32px);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255,255,255,0.04);
  animation: modal-in .2s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal h3 { margin: 0 0 10px; font-size: 15.5px; }
.modal p { margin: 0 0 16px; color: var(--text-soft); font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal .modal-actions button { min-width: 96px; }
.modal-form label { margin-top: 10px; }

/* ───── Cards / shared ───── */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.card.wide { grid-column: 1 / -1; }
.card h2 { margin: 0 0 10px; font-size: 14px; font-weight: 700; letter-spacing: 0.02em; }
.card h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.card p { color: var(--text-soft); font-size: 13px; line-height: 1.6; margin: 0 0 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.config-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.output, pre {
  white-space: pre-wrap; word-break: break-word; background: #000;
  border: 1px solid var(--line); border-radius: 9px; padding: 10px;
  max-height: 360px; overflow: auto; color: #c8cad0; font-size: 11.5px;
  line-height: 1.55; margin: 12px 0 0;
}
#m-create-output:empty, #u-output:empty { display: none; }

/* ───── Machines tab ───── */
.machines-view { padding: 18px; overflow: auto; -webkit-overflow-scrolling: touch; }
.machines-layout {
  display: grid; grid-template-columns: minmax(360px, 1fr) minmax(0, 1.4fr); gap: 14px;
  width: 100%; align-content: start;
}
.machine-list { display: grid; gap: 10px; margin-top: 10px; }
.machine-card { background: rgba(8, 8, 10, 0.7); border: 1px solid var(--line); border-radius: 11px; padding: 14px; }
.machine-card.builtin { border-color: var(--line-bright); background: rgba(255,179,71,0.04); }
.machine-card h3 { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.machine-card .meta { color: var(--muted); font-size: 11.5px; line-height: 1.6; word-break: break-all; }
.machine-card .agent-pills { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.machine-card .agent-pills span {
  padding: 2px 8px; font-size: 10px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.05em;
}
.machine-card .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.machine-card .ping-result { font-size: 11px; margin-top: 6px; }
.machine-card .ping-result.ok { color: var(--green); }
.machine-card .ping-result.fail { color: var(--red); }

/* ───── Setup Guide ───── */
.setup-view { padding: 18px; overflow: auto; -webkit-overflow-scrolling: touch; }
.setup-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 14px; align-content: start; }
.setup-intro { grid-column: 1 / -1; }
.setup-guide  { grid-column: 1 / 2; }
.setup-tips   { grid-column: 2 / 3; }
.setup-overview { color: var(--text-soft); font-size: 13px; line-height: 1.7; padding-left: 22px; margin: 0 0 14px; }
.setup-overview li { margin-bottom: 4px; }
.setup-tips ul { margin: 0; padding-left: 20px; color: var(--text-soft); font-size: 12.5px; line-height: 1.65; }
.os-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.os-tab {
  padding: 8px 14px; border-radius: 9px; font-size: 12.5px; font-weight: 500;
  background: rgba(255,255,255,0.03); border: 1px solid var(--line); color: var(--text-soft); min-height: 36px;
}
.os-tab:hover { color: var(--text); }
.os-tab.active { color: var(--text); background: rgba(255,255,255,0.08); border-color: var(--line-bright); }

.setup-block { margin-top: 18px; }
.setup-block:first-of-type { margin-top: 8px; }
.setup-block-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 6px;
}
.setup-code {
  background: #000; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-family: 'JetBrains Mono', monospace;
  font-size: 12px; line-height: 1.6; color: #d4d6dc; overflow: auto;
  white-space: pre; -webkit-overflow-scrolling: touch;
}
.copy-block-btn { background: transparent; border: 1px solid var(--line); padding: 4px 10px; font-size: 11px; min-height: 0; border-radius: 7px; }
.copy-block-btn:hover { border-color: var(--line-2); }
.copy-block-btn.copied { color: var(--green); border-color: rgba(76, 217, 100, 0.4); }
.setup-card .os-tabs { margin: 8px 0 4px; }
.setup-intro-text { color: var(--text-soft); font-size: 13px; line-height: 1.55; margin: 4px 0 0; }
.setup-manual-toggle { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 12px; }
.setup-manual-toggle > summary {
  cursor: pointer; font-size: 12.5px; color: var(--muted); padding: 6px 4px;
  border-radius: 6px; list-style: none;
}
.setup-manual-toggle > summary::-webkit-details-marker { display: none; }
.setup-manual-toggle > summary:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.setup-manual-toggle[open] > summary { color: var(--text); margin-bottom: 8px; }

/* ───── Users tab ───── */
/* ───── Notification bell + drawer ───── */
.bell-btn {
  position: relative;
  width: 38px; height: 36px; padding: 0; min-height: 0;
  background: rgba(255,255,255,0.03);
  border-color: var(--line);
  display: grid; place-items: center;
}
.bell-btn:hover { background: rgba(255,255,255,0.06); }
.bell-icon { font-size: 16px; filter: grayscale(1) brightness(1.3); }
.bell-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 700; line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.bell-btn[data-critical="true"] .bell-badge { background: var(--red); }
.bell-btn[data-critical="false"] .bell-badge { background: var(--accent-warm); color: #1a0e00; }

.notif-drawer {
  position: absolute; right: 18px; top: calc(var(--topbar) + 6px); z-index: 80;
  width: 360px; max-width: calc(100vw - 24px);
  max-height: calc(100dvh - var(--topbar) - 30px);
  background: rgba(8,8,10,0.96); backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line-bright); border-radius: 12px;
  display: flex; flex-direction: column;
  animation: card-in .14s ease;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7);
}
/* Defence in depth: regardless of cascade order, [hidden] beats any
   inadvertent display value above. Same for the user menu and ctx menu. */
.notif-drawer[hidden], .user-menu[hidden], .term-context-menu[hidden] {
  display: none !important;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  flex-shrink: 0; gap: 10px;
}
.notif-title { font-size: 13px; font-weight: 600; flex-shrink: 0; }
.notif-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
/* Force a real, tappable size for the close × even at cramped widths. */
.notif-actions .icon-btn {
  min-width: 32px; min-height: 32px; padding: 0 10px;
  font-size: 18px; line-height: 1; border-radius: 7px;
  display: grid; place-items: center;
}
.notif-list { overflow: auto; padding: 6px; -webkit-overflow-scrolling: touch; }
.notif-row {
  padding: 10px 12px; border-radius: 9px; cursor: pointer;
  display: flex; align-items: flex-start; gap: 10px;
  transition: background .14s ease;
}
.notif-row:hover { background: rgba(255,255,255,0.04); }
.notif-row.unread { background: rgba(255,255,255,0.03); }
.notif-row.unread::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-warm);
  margin-top: 7px; flex-shrink: 0; box-shadow: 0 0 8px rgba(255,179,71,0.7);
}
.notif-row.read::before {
  content: ""; width: 6px; height: 6px; flex-shrink: 0; margin-top: 7px;
}
.notif-body { flex: 1; min-width: 0; }
.notif-rowtitle { font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.notif-rowtitle .sev-critical { color: var(--red); }
.notif-rowtitle .sev-warning  { color: var(--accent-warm); }
.notif-rowtitle .sev-info     { color: var(--green); }
.notif-message { font-size: 11.5px; color: var(--text-soft); line-height: 1.5; word-break: break-word; }
.notif-meta { font-size: 10px; color: var(--muted); margin-top: 4px; }
.notif-empty {
  padding: 32px 12px; text-align: center; color: var(--muted);
  font-size: 12.5px;
}

/* ───── Ops strip ───── */
.ops-strip {
  display: flex; gap: 10px; padding: 14px 18px; margin: 18px 18px 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); flex-wrap: wrap;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.ops-item {
  flex: 1; min-width: 130px;
  padding: 8px 10px; border-radius: 9px;
  background: rgba(255,255,255,0.02); border: 1px solid var(--line);
}
.ops-item.ops-critical[data-active="true"] {
  border-color: rgba(255, 64, 96, 0.4); background: rgba(255, 64, 96, 0.06);
}
.ops-label {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--muted); text-transform: uppercase; margin-bottom: 4px;
}
.ops-value { font-size: 14px; font-weight: 600; color: var(--text); }
.ops-value.bad { color: var(--red); }
.ops-value.warn { color: var(--accent-warm); }
.ops-value.ok { color: var(--green); }

/* Goal-needs-attention */
.goal-row.needs-attention {
  border-color: rgba(255, 64, 96, 0.45);
  box-shadow: 0 0 22px rgba(255, 64, 96, 0.08);
}
.badge.attention { color: var(--red); border-color: rgba(255, 64, 96, 0.4); background: rgba(255, 64, 96, 0.08); }

/* ───── Goals tab ───── */
/* IMPORTANT: do NOT set `display:` here. `.view` and `.view.active` own the
   show/hide rules — adding `display: flex` here would beat `.view { display:
   none }` on specificity tie (later rule wins), pinning goals-view visible
   even when another tab is selected. We only need flex-direction, and that's
   harmless when the parent isn't flex (no-op). */
.goals-view { padding: 18px; overflow: auto; -webkit-overflow-scrolling: touch; flex-direction: column; }
.goals-view .ops-strip { margin: 0 0 14px; }
.goals-layout { display: grid; grid-template-columns: minmax(360px, 1fr) minmax(0, 1.4fr); gap: 14px; align-content: start; }
.goal-list { display: grid; gap: 10px; margin-top: 10px; }
.goal-row {
  background: rgba(8,8,10,0.7); border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 14px;
}
.goal-row h3 { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.goal-row .meta { font-size: 11.5px; color: var(--muted); line-height: 1.55; word-break: break-word; }
.goal-row .prompt-preview {
  margin-top: 6px; padding: 8px 10px; background: #000; border: 1px solid var(--line);
  border-radius: 8px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px;
  color: var(--text-soft); max-height: 110px; overflow: auto; white-space: pre-wrap;
}
.goal-row .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.goal-row .badge.run { color: var(--green); border-color: rgba(76, 217, 100, 0.4); background: rgba(76, 217, 100, 0.06); }
.goal-row.disabled { opacity: 0.6; }
.goal-row.dangerous { border-color: rgba(255, 64, 96, 0.35); }
.goal-row.unattended-dangerous { border-color: rgba(255, 64, 96, 0.55); box-shadow: 0 0 24px rgba(255, 64, 96, 0.08); }
.goal-row .goal-summary {
  margin-top: 8px; padding: 8px 10px; background: rgba(76, 217, 100, 0.06);
  border: 1px solid rgba(76, 217, 100, 0.18); border-radius: 8px;
  font-size: 11.5px; color: var(--text-soft); line-height: 1.5;
}
.goal-row .goal-summary .summary-label {
  display: inline-block; margin-right: 8px; font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.08em; color: var(--green); text-transform: uppercase;
}
.goal-row .goal-error {
  margin-top: 8px; padding: 8px 10px; background: rgba(255, 64, 96, 0.06);
  border: 1px solid rgba(255, 64, 96, 0.25); border-radius: 8px;
  font-size: 11px; color: var(--red);
}
.goal-row .goal-runs {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.goal-row .runs-label {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--muted); text-transform: uppercase; margin-bottom: 6px;
}
.goal-row .run-line {
  display: flex; gap: 8px; align-items: center;
  padding: 4px 0; font-size: 11px; color: var(--text-soft);
}
.goal-row .run-when { color: var(--muted); min-width: 90px; }
.goal-row .run-mode {
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  color: var(--dim); padding: 1px 6px; border: 1px solid var(--line); border-radius: 4px;
}
.goal-row .run-summary {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-soft);
}
.badge.success { color: var(--green); border-color: rgba(76, 217, 100, 0.35); background: rgba(76, 217, 100, 0.06); }

.users-view { padding: 18px; overflow: auto; -webkit-overflow-scrolling: touch; }
.users-layout { display: grid; grid-template-columns: minmax(340px, 1fr) minmax(0, 1.4fr); gap: 14px; align-content: start; }
.user-list { display: grid; gap: 10px; margin-top: 10px; }
.user-row {
  background: rgba(8,8,10,0.7); border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 14px;
}
.user-row h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.user-row .meta { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.user-row .role-tag { font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-bright); text-transform: uppercase; }
.user-row .role-tag.admin { color: var(--accent-warm); border-color: rgba(255,179,71,0.4); background: rgba(255,179,71,0.06); }
.user-row .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ───── Sessions tab ───── */
.sessions-view { flex-direction: column; padding: 18px; overflow: auto; -webkit-overflow-scrolling: touch; }
.session-list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.session-list-head h2 { margin: 0; font-size: 14px; font-weight: 700; }
.session-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.session-card {
  background: rgba(8, 8, 10, 0.7); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; transition: border-color .14s ease;
}
.session-card:hover { border-color: var(--line-bright); }
.session-card h3 { margin: 0 0 8px; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.session-card .meta { color: var(--muted); font-size: 11px; line-height: 1.65; word-break: break-all; }
.session-card .actions { display: flex; gap: 8px; margin-top: 12px; }
.session-card .actions button { flex: 1; }
.badge {
  display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 999px;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em;
  border: 1px solid var(--line); color: var(--muted); text-transform: uppercase;
}
.badge.danger { color: var(--red); border-color: rgba(255, 64, 96, 0.4); background: rgba(255, 64, 96, 0.08); }
.badge.stale { color: var(--yellow); border-color: rgba(255, 179, 71, 0.4); background: rgba(255, 179, 71, 0.06); }

/* ───── Toasts ───── */
.toast-stack {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: rgba(10, 10, 12, 0.96); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 9px; padding: 11px 14px;
  font-size: 12.5px; color: var(--text); max-width: 380px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); pointer-events: auto;
  animation: toast-in .18s ease;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
.toast.warn { border-left-color: var(--accent-warm); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ───── Scrollbars ───── */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--line-bright); }

/* ───── Responsive ───── */
@media (max-width: 900px) {
  :root { --topbar: 62px; }
  .topbar { gap: 8px; padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); height: auto; min-height: var(--topbar); flex-wrap: wrap; }
  .hamburger { display: inline-flex; place-items: center; justify-content: center; }
  .brand { flex: 1; min-width: 0; }
  .brand-subtitle { display: none; }
  /* Tab strip scrolls horizontally with a soft fade on each edge so users
     know more is offscreen. Sticky to top so it doesn't get lost on scroll. */
  .tabs {
    order: 99; width: 100%; gap: 2px; padding: 4px 16px;
    overflow-x: auto; flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { font-size: 11.5px; padding: 7px 12px; flex-shrink: 0; min-height: 36px; }
  .topbar-right .status-pill { display: none; }
  .user-name { display: none; }
  .user-pill { padding: 4px; }

  .view.active { display: flex; }
  .launch-panel {
    position: absolute; left: 12px; right: 12px; top: 12px; width: auto;
    max-height: calc(100dvh - var(--topbar) - 76px); border-radius: 14px;
    transform: translateY(-130%); opacity: 0;
    transition: transform .22s ease, opacity .18s ease; z-index: 80; pointer-events: none;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.95);
  }
  .launch-panel.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .floating-launch { display: inline-flex; }
  .grid-two, .grid-three { grid-template-columns: 1fr; }
  /* Focused mode (default on mobile): focused terminal goes fullscreen, the
     others are hidden behind it. The "All" mode toggle below lets you see
     every terminal scaled down so you can navigate the canvas with a pinch. */
  body[data-view="mobile"][data-mode="focused"] .term-window {
    left: 8px !important; right: 8px !important; top: 100px !important;
    width: calc(100vw - 16px) !important; height: calc(100dvh - var(--topbar) - 116px) !important;
    min-width: 0; border-radius: 12px;
  }
  body[data-view="mobile"][data-mode="focused"] .term-window:not(.focused) { display: none; }
  body[data-view="mobile"][data-mode="focused"] .resize-handle { display: none; }

  /* All-terminals canvas mode on mobile: each terminal renders at a compact,
     readable thumbnail size. Drag/resize stay disabled (avoids touch
     conflicts with pinch-zoom and scrolling), but the user can pinch the
     page itself to zoom in/out. */
  body[data-view="mobile"][data-mode="all"] .term-window {
    position: relative !important;
    left: auto !important; top: auto !important;
    width: 100% !important; height: 280px !important;
    margin: 0 0 12px 0;
    transform: none !important;
  }
  body[data-view="mobile"][data-mode="all"] .term-window:not(.focused) { display: flex; }
  body[data-view="mobile"][data-mode="all"] .resize-handle { display: none; }
  body[data-view="mobile"][data-mode="all"] #canvas {
    position: absolute; inset: 100px 8px 8px 8px;
    width: auto; height: auto;
    transform: none !important;
    overflow: auto; -webkit-overflow-scrolling: touch;
    display: flex; flex-direction: column;
    padding-bottom: 16px;
  }
  body[data-view="mobile"][data-mode="all"] #canvas-wrap { touch-action: pan-x pan-y pinch-zoom; cursor: default; }
  body[data-view="mobile"] #canvas-wrap { cursor: default; }
  body[data-view="mobile"][data-mode="focused"] #canvas { transform: none !important; }

  body[data-view="mobile"] .mobile-toolbar { display: flex; }
  body[data-view="mobile"] .mobile-switcher { display: flex; }
  body[data-view="mobile"][data-mode="all"] .mobile-switcher { display: none; }
  .term-bar { height: 42px; }
  /* Visible dot stays small for the chrome look; expand the invisible hit
     area to 44x44 (Apple HIG / Material minimum touch target) so phone
     taps don't slide off the dot onto the drag-handle. */
  .traffic-btn { width: 16px; height: 16px; }
  .traffic-btn::before { inset: -14px; border-radius: 12px; }
  .term-kill { padding: 9px 14px; font-size: 12px; min-height: 36px; }

  .machines-layout, .users-layout, .setup-layout { grid-template-columns: 1fr; }
  .setup-guide, .setup-tips { grid-column: auto; }
  .session-list { grid-template-columns: 1fr; }
  .user-menu { right: 8px; left: 8px; width: auto; }
  /* Notifications drawer becomes near-full-width on phones and respects the
     iPhone home-indicator + landscape notch areas. */
  .notif-drawer {
    left: 8px; right: 8px; width: auto;
    max-height: calc(100dvh - var(--topbar) - 80px);
    padding-bottom: env(safe-area-inset-bottom);
  }
  /* iPhone home-indicator padding so the floating launch button + toasts
     don't get clipped on iOS Safari standalone. */
  .floating-launch { bottom: calc(18px + env(safe-area-inset-bottom)); }
  .toast-stack { bottom: calc(12px + env(safe-area-inset-bottom)); }
}

@media (min-width: 901px) and (max-width: 1150px) {
  .launch-panel { width: 296px; }
  .term-window { min-width: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .shooting-stars { display: none; }
}
