/* ── Legacy variable aliases (keep JS inline styles working) ── */
:root {
  --color-bg:             var(--bg);
  --color-surface:        var(--bg-card);
  --color-surface-raised: var(--bg-secondary);
  --color-surface-glass:  rgba(255,255,255,0.7);
  --color-elevated:       var(--bg-elevated);
  --color-terminal-bg:    var(--bg-terminal);
  --color-text:           var(--text-primary);
  --color-text-secondary: var(--text-secondary);
  --color-text-dim:       var(--text-dim);
  --color-accent:         var(--accent);
  --color-accent-soft:    var(--accent-soft);
  --color-accent-dim:     var(--accent-dim);
  --color-border:         var(--border);
  --color-border-accent:  var(--accent-border);
  --color-border-muted:   var(--border);
  --color-success:        var(--green);
  --color-warn:           var(--amber);
  --color-warn-dim:       var(--amber-bg);
  --color-danger:         var(--red);
  --color-claude:         var(--claude-fg);
  --color-codex:          var(--codex-fg);
  --keybar-h: 46px;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%; overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.hidden { display: none !important; }

/* ── Auth screen ───────────────────────────────────── */
#auth-screen {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column;
}
.auth-hero {
  flex: 1; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-4); padding: var(--sp-6);
}
.auth-mascot {
  width: 96px; height: 96px; border-radius: var(--r-2xl);
  box-shadow: var(--shadow-md);
  object-fit: cover; display: block;
}
.auth-title {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.4px;
}
.auth-title span {
  color: var(--accent);
}
.auth-subtitle {
  font-size: 15px; color: var(--text-dim); text-align: center;
}
.auth-card {
  background: var(--bg-card);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-6) var(--sp-6) calc(var(--sp-6) + var(--safe-bottom));
  width: 100%;
  box-shadow: var(--shadow-sheet);
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.auth-input-wrap {
  position: relative;
}
.auth-input-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); pointer-events: none;
}
#token-input {
  width: 100%; padding: 14px 44px;
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); color: var(--text-primary); font-size: 15px;
  font-family: var(--font-mono); outline: none;
  transition: border-color var(--dur-fast);
}
#token-input:focus { border-color: var(--accent); }
.auth-eye-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-dim);
  padding: 6px; display: flex; align-items: center;
}
#token-submit {
  width: 100%; padding: 15px;
  background: var(--accent); color: var(--text-on-accent);
  border: none; border-radius: var(--r-pill);
  font-family: var(--font-ui); font-size: 16px; font-weight: 600;
  cursor: pointer; transition: opacity var(--dur-fast);
}
#token-submit:active { opacity: 0.85; }
#auth-error { color: var(--red); font-size: 13px; text-align: center; }
.auth-hint { font-size: 13px; color: var(--text-dim); text-align: center; }

/* ── QR cross-device sign-in ───────────────────────── */
.auth-divider {
  display: flex; align-items: center; gap: var(--sp-3);
  color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.auth-secondary-btn {
  width: 100%; padding: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1.5px solid var(--border); border-radius: var(--r-pill);
  font-family: var(--font-ui); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: border-color var(--dur-fast), opacity var(--dur-fast);
}
.auth-secondary-btn:hover { border-color: var(--accent); }
.auth-secondary-btn:active { opacity: 0.85; }
.auth-card-title {
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  color: var(--text-primary); text-align: center;
}
#qr-login-body, #qr-approve-body {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  text-align: center;
}
#qr-login-body .qr-card { max-width: 240px; }
.qr-login-status, .qr-approve-msg { font-size: 14px; color: var(--text-dim); }
.qr-login-code {
  font-family: var(--font-mono); font-size: 13px; color: var(--text-dim);
}
.qr-login-code b { color: var(--text-primary); letter-spacing: 3px; font-size: 18px; }
.qr-approve-bigcode {
  font-family: var(--font-mono); font-size: 40px; font-weight: 800;
  letter-spacing: 8px; color: var(--accent); margin: var(--sp-2) 0;
}
.qr-approve-ok { color: var(--green, #22c55e); font-weight: 700; font-size: 16px; }
.qr-approve-fail { color: var(--red); font-size: 14px; }

/* ── App shell ─────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100%; }
#tab-content { flex: 1; overflow: hidden; position: relative; }
.tab-panel { position: absolute; inset: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ── Tab bar ───────────────────────────────────────── */
#tab-bar {
  display: flex;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px;
  background: none; border: none; color: var(--text-dim);
  font-family: var(--font-ui); font-size: 10px; font-weight: 500;
  cursor: pointer; transition: color var(--dur-fast);
  padding: 6px 0; letter-spacing: 0.03em;
}
.tab-btn svg { width: 22px; height: 22px; transition: color var(--dur-fast); }
.tab-btn.active { color: var(--accent); }

/* ── Top bar (shared) ──────────────────────────────── */
.top-bar {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--safe-top) var(--sp-4) 0;
  height: calc(var(--topbar-h) + var(--safe-top));
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.top-bar-title {
  font-size: 17px; font-weight: 700; color: var(--text-primary); flex: 1;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.top-bar-action {
  padding: 6px 12px; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-secondary); font-family: var(--font-ui);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.top-bar-action:active { background: var(--accent-dim); color: var(--accent); }
.top-bar-action:disabled {
  opacity: 0.55;
  cursor: default;
}
.top-bar-action.primary {
  background: var(--accent-dim); color: var(--accent);
  border-color: var(--accent-border);
}
.top-bar-action.danger {
  color: var(--red);
  background: var(--red-bg);
  border-color: var(--red-bg);
}

/* ── Status dot ────────────────────────────────────── */
.status-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.connected    { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.reconnecting { background: var(--amber); animation: pulse-warn 1s ease-in-out infinite; }
.status-dot.offline      { background: var(--text-dim); }

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

/* ── Scroll containers ─────────────────────────────── */
.scroll-list {
  flex: 1; overflow-y: auto;
  padding: var(--sp-4) var(--sp-4) calc(var(--tabbar-h) + var(--safe-bottom) + var(--sp-4));
  display: flex; flex-direction: column; gap: var(--sp-3);
  background: var(--bg);
}
.scroll-list::-webkit-scrollbar { display: none; }
.section-label {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 800; letter-spacing: -0.2px;
  color: var(--text-primary);
  padding: 0 16px; margin-bottom: 12px;
  text-transform: none;
}

/* ── Cards (shared) ────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

/* ── Editorial feed (Today/Home) ─────────────────── */
.news-large-title {
  font-family: var(--font-display);
  font-size: 34px; font-weight: 800; letter-spacing: -0.4px;
  color: var(--text-primary);
  line-height: 1;
}
.news-feed {
  flex: 1; overflow-y: auto; background: var(--bg);
  scrollbar-width: none;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--sp-4));
}
.news-feed::-webkit-scrollbar { display: none; }
.news-section { margin-bottom: 32px; }
.news-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; margin-bottom: 12px;
}
.news-section-header > span {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 800; letter-spacing: -0.2px;
  color: var(--text-primary);
}
.news-see-all {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 14px; font-weight: 600;
  font-family: var(--font-ui); padding: 4px 0;
}
.news-hero-card {
  background: var(--bg-card); border-radius: 14px; overflow: hidden;
  margin: 0 16px; border: 1px solid var(--border); box-shadow: var(--shadow-xs);
}
.hero-card-body { padding: 20px; }
.hero-card-eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 6px;
}
.hero-card-headline {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--text-primary); margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
  line-height: 1.25;
}
.hero-card-dek {
  font-size: 15px; color: var(--text-secondary); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 16px;
}
.hero-card-cta {
  display: block; width: 100%; padding: 13px;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--r-pill); font-family: var(--font-ui);
  font-size: 16px; font-weight: 600; cursor: pointer; text-align: center;
  transition: opacity var(--dur-fast);
}
.hero-card-cta:active { opacity: 0.85; }
.hero-card-meta {
  font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
  text-transform: uppercase; color: var(--text-dim); margin-top: 12px;
}

/* Story list (compact agent/project rows) */
.story-list-card {
  background: var(--bg-card); border-radius: 14px; overflow: hidden;
  margin: 0 16px; border: 1px solid var(--border); box-shadow: var(--shadow-xs);
}
.story-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background var(--dur-fast);
}
.story-row:last-child { border-bottom: none; }
.story-row:active { background: var(--bg-secondary); }
.story-row-icon {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
}
.story-row-info { flex: 1; min-width: 0; }
.story-row-name {
  font-size: 17px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.story-row-meta {
  font-size: 13px; color: var(--text-dim); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.story-row-action {
  flex-shrink: 0; padding: 7px 16px;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--r-pill); font-family: var(--font-ui);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity var(--dur-fast);
}
.story-row-action:active { opacity: 0.85; }
.story-row-action.secondary {
  background: var(--bg-secondary); color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* sys bar for home footer */
#home-sys-bar {
  font-size: 12px; font-family: var(--font-mono); color: var(--text-dim);
}

/* ── Terminal tab ──────────────────────────────────── */
#terminal-container {
  flex: 1; background: var(--bg-terminal); overflow: hidden; position: relative;
  margin: 0 var(--sp-3);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
#terminal-container .xterm { height: 100%; }
#terminal-container .xterm-viewport { overflow-y: scroll !important; }

#term-topbar { gap: var(--sp-2); }
#term-topbar .top-bar-action {
  padding: 6px 9px;
  font-size: 12px;
  white-space: nowrap;
}

#keybar {
  display: flex; align-items: center; overflow-x: auto; gap: 4px;
  padding: 0 var(--sp-2);
  height: var(--keybar-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  scrollbar-width: none; flex-shrink: 0;
}
#keybar::-webkit-scrollbar { display: none; }

.key-btn {
  flex-shrink: 0; height: 32px; min-width: 38px; padding: 0 10px;
  background: var(--bg-secondary); border: 1px solid var(--border-mid);
  border-radius: var(--r-sm); color: var(--text-secondary);
  font-family: var(--font-mono); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--dur-fast), color var(--dur-fast);
  box-shadow: var(--shadow-xs);
}
.key-btn:active { background: var(--accent-dim); color: var(--accent); }
.key-btn.sticky-active {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}

/* ── Screen tab: on-screen VNC keyboard ───────────────── */
.screen-kbd-toggle {
  position: absolute; right: 12px; bottom: 12px; z-index: 5;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(14,12,21,0.82); backdrop-filter: blur(10px);
  border: 1px solid var(--accent-border); color: var(--accent-soft);
  font-size: 22px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md, 0 6px 20px rgba(0,0,0,0.4));
  transition: background var(--dur-fast), color var(--dur-fast);
}
.screen-kbd-toggle.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.screen-kbd {
  flex-shrink: 0; background: var(--bg-card); border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 5px;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.screen-kbd.hidden { display: none; }
.screen-kbd-row { display: flex; gap: 5px; }
.screen-key {
  flex: 1 1 30px; min-width: 0; height: 42px;
  background: var(--bg-secondary); border: 1px solid var(--border-mid);
  border-radius: var(--r-sm); color: var(--text-secondary);
  font-family: var(--font-mono); font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-xs); transition: background var(--dur-fast), color var(--dur-fast);
}
.screen-key.screen-key-special, .screen-key.screen-key-mod {
  font-family: var(--font-ui); font-size: 12px; color: var(--text-dim);
  background: var(--bg-card);
}
.screen-key.pressed, .screen-key:active { background: var(--accent-dim); color: var(--accent); }
.screen-key.screen-key-mod.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.screen-key.screen-key-mod.locked { box-shadow: inset 0 0 0 2px var(--accent-soft); }
@media (max-width: 480px) { .screen-key { height: 38px; font-size: 14px; } }

#reconnect-pill {
  position: absolute; top: var(--sp-2); left: 50%; transform: translateX(-50%);
  background: rgba(14,12,21,0.85); backdrop-filter: blur(10px);
  border: 1px solid var(--accent-border);
  color: var(--accent-soft); padding: 5px 14px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 500;
  pointer-events: none; z-index: 10; white-space: nowrap;
}

#term-toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--keybar-h) + var(--sp-3));
  transform: translate(-50%, 8px);
  background: rgba(14,12,21,0.90);
  color: var(--text-on-dark);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast), transform var(--dur-fast);
  z-index: 20;
  white-space: nowrap;
}
#term-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.terminal-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0,0,0,0.40);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.terminal-sheet-panel {
  width: 100%;
  max-width: 600px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-4) + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.terminal-sheet-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.terminal-sheet-head span {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
#term-paste-input {
  width: 100%;
  min-height: 132px;
  max-height: 42vh;
  resize: vertical;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.45;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
#term-paste-input:focus { border-color: var(--accent); }
.terminal-sheet-send {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-pill);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.terminal-sheet-send:active { opacity: 0.85; }

.session-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.session-row.active .session-title { color: var(--accent); }
.session-info {
  flex: 1;
  min-width: 0;
}
.session-title {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-meta {
  margin-top: 2px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
}
.session-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.session-empty {
  color: var(--text-dim);
  font-size: 14px;
}

@media (max-width: 380px) {
  #term-topbar {
    padding: 0 var(--sp-2);
    gap: 5px;
  }
  #term-topbar .top-bar-action {
    padding: 6px 7px;
    font-size: 11px;
  }
  .session-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .session-actions {
    width: 100%;
  }
  .session-actions .top-bar-action {
    flex: 1;
  }
}

/* ── Agent cards ───────────────────────────────────── */
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.agent-card-header {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4);
  cursor: pointer;
}
.agent-icon {
  width: 44px; height: 44px; border-radius: var(--r-md); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; font-family: var(--font-mono);
  color: #fff;
}
.agent-info { flex: 1; min-width: 0; }
.agent-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.agent-meta { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.agent-status-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600;
}
.agent-status-chip.running { background: var(--green-bg); color: var(--green); }
.agent-status-chip.ready   { background: var(--blue-bg);  color: var(--blue); }
.agent-status-chip.offline { background: var(--bg-secondary); color: var(--text-dim); }
.agent-status {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500;
}
.agent-status.running { color: var(--green); }
.agent-status.ready   { color: var(--text-secondary); }
.agent-status.offline { color: var(--text-dim); }

.agent-actions {
  display: flex; gap: var(--sp-2); padding: 0 var(--sp-4) var(--sp-4);
}
.agent-btn {
  flex: 1; padding: 9px; border-radius: var(--r-sm);
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border);
  background: var(--bg-secondary); color: var(--text-secondary);
  transition: all var(--dur-fast); text-align: center;
}
.agent-btn:active { opacity: 0.8; }
.agent-btn.primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  border-radius: var(--r-pill); height: 44px; font-size: 15px; font-weight: 600;
}
.agent-btn.danger {
  color: var(--red); border-color: rgba(255,59,48,0.25);
}

.agent-output {
  margin: 0 var(--sp-4) var(--sp-4);
  background: var(--bg-terminal);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--r-md);
  padding: var(--sp-3); max-height: 120px; overflow-y: auto;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-on-dark);
  line-height: 1.5; white-space: pre-wrap; word-break: break-all;
}
.agent-output::-webkit-scrollbar { display: none; }

/* ── Target-first launcher ─────────────────────────── */
.launcher-search {
  width: 100%; box-sizing: border-box;
  padding: 11px 14px; margin-bottom: var(--sp-3);
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  font-family: var(--font-ui); font-size: 15px;
  -webkit-appearance: none;
}
.launcher-search:focus { outline: none; border-color: var(--accent); }
.launcher-search::placeholder { color: var(--text-dim); }

#launcher-targets { display: flex; flex-direction: column; gap: var(--sp-2); }

.target-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--dur-fast);
}
.target-row.expanded { border-color: var(--accent); box-shadow: var(--shadow-xs); }

.target-head {
  width: 100%; display: flex; align-items: center; gap: var(--sp-2);
  padding: 13px var(--sp-4); background: none; border: none; cursor: pointer;
  font-family: var(--font-ui); text-align: left; color: var(--text-primary);
}
.target-star { width: 14px; flex-shrink: 0; color: var(--accent); font-size: 13px; }
.target-name { font-size: 15px; font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-branch { font-size: 12px; color: var(--text-dim); font-family: var(--font-mono); flex-shrink: 0; }
.target-sub { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }

.launch-panel {
  padding: 0 var(--sp-4) var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.agent-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.agent-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px 7px 7px; border-radius: var(--r-pill);
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-secondary); font-family: var(--font-ui);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all var(--dur-fast);
}
.agent-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.agent-chip.disabled { opacity: 0.4; cursor: not-allowed; }
.chip-dot {
  width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; font-family: var(--font-mono); color: #fff;
}
.launch-prompt {
  width: 100%; box-sizing: border-box; resize: none;
  padding: 10px 12px; background: var(--bg-terminal);
  border: 1px solid rgba(255,255,255,0.08); border-radius: var(--r-md);
  color: var(--text-on-dark); font-family: var(--font-mono); font-size: 13px;
  line-height: 1.45;
}
.launch-prompt:focus { outline: none; border-color: var(--accent); }
.launch-prompt::placeholder { color: var(--text-dim); }
.launch-go { width: 100%; }
.launch-btn-row { display: flex; gap: var(--sp-2); }
.launch-btn-row .launch-go { flex: 1; width: auto; }
.launch-auto {
  flex: 0 0 auto; min-width: 96px;
  background: var(--claude-fg); border-color: var(--claude-fg); color: #fff;
  border-radius: var(--r-pill); height: 44px; font-size: 15px; font-weight: 600;
}
.launch-auto:active { opacity: 0.85; }

/* ── Toasts ────────────────────────────────────────── */
#toast-host {
  position: fixed; left: 0; right: 0; z-index: 200;
  bottom: calc(var(--tab-bar-h, 64px) + env(safe-area-inset-bottom) + 12px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 16px;
}
.toast {
  max-width: 440px; width: fit-content;
  padding: 11px 16px; border-radius: var(--r-pill);
  background: #2c2c2e; color: #fff;  /* fixed dark — readable in both themes */
  font-family: var(--font-ui); font-size: 14px; font-weight: 500;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  opacity: 0; transform: translateY(12px); transition: opacity .22s, transform .22s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.hide { opacity: 0; transform: translateY(12px); }
.toast-error   { background: var(--red); }
.toast-success { background: var(--green); }

/* ── Dialogs (confirm / prompt) ────────────────────── */
.app-dialog-overlay {
  position: fixed; inset: 0; z-index: 210;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; transition: opacity .18s; pointer-events: none;
}
.app-dialog-overlay.show { opacity: 1; pointer-events: auto; }
.app-dialog-overlay.hide { opacity: 0; pointer-events: none; }
.app-dialog {
  width: 100%; max-width: 340px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: var(--sp-5);
  box-shadow: 0 16px 48px rgba(0,0,0,0.4);
  transform: scale(0.96); transition: transform .18s;
}
.app-dialog-overlay.show .app-dialog { transform: scale(1); }
.app-dialog-title { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.app-dialog-msg { font-size: 14px; color: var(--text-secondary); margin-top: 8px; line-height: 1.45;
  word-break: break-word; }
.app-dialog-input {
  width: 100%; box-sizing: border-box; margin-top: var(--sp-4);
  padding: 11px 13px; background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--r-md);
  font-family: var(--font-mono); font-size: 15px; -webkit-appearance: none;
}
.app-dialog-input:focus { outline: none; border-color: var(--accent); }
.app-dialog-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); }
.app-dialog-btn {
  flex: 1; min-height: 44px; padding: 11px; border-radius: var(--r-pill);
  font-family: var(--font-ui); font-size: 15px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-secondary); color: var(--text-primary);
}
.app-dialog-btn.ok { background: var(--accent); border-color: var(--accent); color: #fff; }
.app-dialog-btn.ok.danger { background: var(--red); border-color: var(--red); }
.app-dialog-btn:active { opacity: 0.85; }

/* ── Bottom sheet ──────────────────────────────────── */
.app-sheet-overlay {
  position: fixed; inset: 0; z-index: 210;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.app-sheet-overlay.show { opacity: 1; pointer-events: auto; }
.app-sheet-overlay.hide { opacity: 0; pointer-events: none; }
.app-sheet {
  width: 100%; max-width: 600px; max-height: 82vh; display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  transform: translateY(16px); transition: transform .2s;
  padding-bottom: env(safe-area-inset-bottom);
}
.app-sheet-overlay.show .app-sheet { transform: translateY(0); }
.app-sheet-head {
  display: flex; align-items: center; gap: 8px;
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.app-sheet-title { flex: 1; font-size: 16px; font-weight: 700; color: var(--text-primary); }
.app-sheet-close {
  background: none; border: none; color: var(--accent); font-family: var(--font-ui);
  font-size: 15px; font-weight: 600; cursor: pointer; padding: 4px 6px;
}
.app-sheet-body { overflow-y: auto; padding: var(--sp-4) var(--sp-5); }
.sheet-empty { padding: 40px 0; text-align: center; color: var(--text-dim); font-size: 14px; }

/* QR */
.qr-card {
  background: #fff; border-radius: var(--r-md); padding: 16px;
  width: 232px; max-width: 80%; margin: 8px auto 0; display: block;
}
.qr-card svg { width: 100%; height: auto; display: block; }
.qr-url {
  margin: var(--sp-4) auto 0; text-align: center; word-break: break-all;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary);
}
.qr-toggle {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: var(--sp-4); font-size: 14px; color: var(--text-primary); cursor: pointer;
}
.qr-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.qr-note { margin-top: 8px; text-align: center; font-size: 12px; color: var(--text-dim); }

/* In-app QR scanner (camera) */
.qr-scan-wrap {
  position: relative; width: 260px; max-width: 86%; aspect-ratio: 1;
  margin: 8px auto 0; border-radius: var(--r-md); overflow: hidden;
  background: #000;
}
.qr-scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.qr-scan-frame {
  position: absolute; inset: 14%; border-radius: 12px;
  border: 2px solid var(--accent); box-shadow: 0 0 0 9999px rgba(0,0,0,.35);
  pointer-events: none;
}
.qr-scan-status {
  margin-top: var(--sp-4); text-align: center; font-size: 14px; color: var(--text-dim);
}
.qr-scan-status b { color: var(--text-primary); }

/* Shared clipboard items */
.clip-item { padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.clip-item:last-child { border-bottom: none; }
.clip-item-text {
  font-size: 14px; color: var(--text-primary); line-height: 1.45;
  white-space: pre-wrap; word-break: break-word; max-height: 80px; overflow: hidden;
}
.clip-item-text.mono { font-family: var(--font-mono); font-size: 12.5px; }
.clip-item-actions { display: flex; gap: var(--sp-2); margin-top: 8px; }
.clip-item-actions button {
  padding: 7px 14px; border-radius: var(--r-pill); font-family: var(--font-ui);
  font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid var(--border);
}
.clip-copy { background: var(--bg-secondary); color: var(--text-primary); }
.clip-term { background: var(--accent); border-color: var(--accent); color: #fff; }
.clip-item-actions button:active { opacity: 0.85; }
.clip-add { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.clip-add-input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: var(--r-md);
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-primary); font-family: var(--font-ui); font-size: 14px; -webkit-appearance: none;
}
.clip-add-input:focus { outline: none; border-color: var(--accent); }
.clip-add-btn {
  flex: 0 0 auto; padding: 0 16px; border-radius: var(--r-pill);
  background: var(--accent); border: 1px solid var(--accent); color: #fff;
  font-family: var(--font-ui); font-size: 14px; font-weight: 600; cursor: pointer;
}
.clip-add-btn:active { opacity: 0.85; }

/* ── Split view (wide screens only) ────────────────── */
@media (min-width: 920px) {
  body.split #tab-content { display: flex; flex-direction: row; }
  body.split .tab-panel { position: relative; inset: auto; flex: 1 1 0; min-width: 0; height: 100%; }
  body.split .tab-panel.hidden { display: none; }
  body.split #tab-term { order: 2; flex: 1 1 0; border-left: 1px solid var(--border); }
}

/* ── Stan chat (inside Agents) ─────────────────────── */
#stan-chat {
  display: flex; flex-direction: column; height: 100%;
  background: var(--bg);
}
#stan-chat-messages {
  flex: 1; overflow-y: auto; padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
#stan-chat-messages::-webkit-scrollbar { display: none; }
.chat-bubble {
  max-width: 88%; padding: 10px 14px;
  border-radius: var(--r-lg); font-size: 14px; line-height: 1.55;
  word-break: break-word;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent); color: #fff;
  border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg);
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) 4px;
  box-shadow: var(--shadow-xs);
}
.chat-bubble pre {
  background: var(--bg-terminal); border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--r-sm); padding: 10px 12px; overflow-x: auto;
  margin: 8px 0; font-family: var(--font-mono); font-size: 12px;
  line-height: 1.5; position: relative; color: var(--text-on-dark);
}
.chat-bubble pre .code-actions {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 4px;
}
.code-btn {
  padding: 2px 8px; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 4px;
  color: var(--text-on-dark); font-size: 11px; cursor: pointer;
}
.code-btn:active { color: var(--accent-soft); }
#stan-chat-input-row {
  display: flex; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4);
  background: var(--bg-card); border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#stan-chat-input {
  flex: 1; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text-primary); padding: 9px 12px;
  font-family: var(--font-ui); font-size: 14px; outline: none; resize: none;
  max-height: 100px; transition: border-color var(--dur-fast);
}
#stan-chat-input:focus { border-color: var(--accent); }
#stan-chat-send {
  padding: 9px 16px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-md); font-size: 14px; font-weight: 600;
  cursor: pointer;
}
#stan-chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

.stan-thinking {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-dim); font-size: 13px; padding: 4px 0;
}
.stan-thinking .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); opacity: 0.3;
  animation: thinking-pulse 1.2s ease-in-out infinite;
}
.stan-thinking .dot:nth-child(2) { animation-delay: 0.2s; }
.stan-thinking .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinking-pulse {
  0%,80%,100% { opacity: 0.2; transform: scale(0.85); }
  40%          { opacity: 1;   transform: scale(1); }
}

/* ── Model picker strip ────────────────────────────── */
.model-bar {
  display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-4);
  height: 42px; background: var(--bg-card); border-bottom: 1px solid var(--border);
  flex-shrink: 0; overflow-x: auto; scrollbar-width: none;
}
.model-bar::-webkit-scrollbar { display: none; }
.model-chip {
  flex-shrink: 0; padding: 5px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--bg-secondary); color: var(--text-secondary);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all var(--dur-fast); white-space: nowrap;
}
.model-chip.active {
  background: var(--accent-dim); color: var(--accent);
  border-color: var(--accent-border);
}

/* ── Project cards ─────────────────────────────────── */
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.project-card-body { padding: var(--sp-4); }
.project-name { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.project-branch {
  font-family: var(--font-mono); font-size: 12px; color: var(--accent-soft);
  margin-top: 2px;
}
.project-meta {
  font-size: 12px; color: var(--text-dim); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-dirty-badge {
  display: inline-block; padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--amber-bg); color: var(--amber);
  font-size: 10px; font-weight: 600; letter-spacing: 0.05em;
  margin-left: 6px; vertical-align: middle;
}
.project-actions {
  display: flex; gap: var(--sp-2); padding: 0 var(--sp-4) var(--sp-4);
}
.project-btn {
  flex: 1; padding: 8px 6px; text-align: center;
  border-radius: var(--r-sm); font-size: 12px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-secondary); color: var(--text-secondary);
  cursor: pointer; transition: all var(--dur-fast);
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.project-btn:active { opacity: 0.8; }
.project-btn.claude { color: var(--claude-fg); border-color: rgba(212,118,59,0.25); background: var(--claude-bg); }
.project-btn.codex  { color: var(--codex-fg);  border-color: rgba(16,163,127,0.25);  background: var(--codex-bg); }

.file-entry {
  display: flex; align-items: center; padding: 11px var(--sp-4); gap: var(--sp-3);
  border-bottom: 1px solid var(--border); cursor: pointer;
  background: var(--bg-card);
}
.file-entry:active { background: var(--bg-secondary); }
.file-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }
.file-name { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.file-meta { color: var(--text-dim); font-size: 11px; font-family: var(--font-mono); white-space: nowrap; }

/* ── Context menu ──────────────────────────────────── */
.ctx-menu {
  position: fixed; z-index: 200; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; min-width: 160px; box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
}
.ctx-item {
  padding: 12px var(--sp-4); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; gap: var(--sp-3); color: var(--text-primary);
}
.ctx-item:active { background: var(--bg-secondary); }
.ctx-item.danger { color: var(--red); }

/* ── File browser ──────────────────────────────────── */
.breadcrumb {
  display: flex; align-items: center; gap: 2px;
  padding: var(--sp-2) var(--sp-4);
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  overflow-x: auto; flex-shrink: 0;
  scrollbar-width: none;
}
.breadcrumb::-webkit-scrollbar { display: none; }
.crumb-btn {
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  padding: 3px 5px; border-radius: var(--r-sm);
  white-space: nowrap; font-family: var(--font-ui);
  transition: color var(--dur-fast), background var(--dur-fast);
}
.crumb-btn:active { background: var(--accent-dim); color: var(--accent); }
.crumb-btn.active { color: var(--text-primary); font-weight: 600; }
.crumb-sep { font-size: 12px; color: var(--text-dim); user-select: none; padding: 0 1px; }

.pin-row {
  display: flex; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4);
  overflow-x: auto; flex-shrink: 0; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.pin-row::-webkit-scrollbar { display: none; }

/* New file / folder / upload action bar */
.dir-actions {
  display: flex; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4);
  flex-shrink: 0;
}
.dir-action-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 38px; padding: 8px 10px; border-radius: var(--r-md);
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-secondary); font-family: var(--font-ui);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: all var(--dur-fast);
}
.dir-action-btn:active { opacity: 0.8; }
.dir-action-plus { color: var(--accent); font-weight: 700; font-size: 15px; line-height: 1; }
.pin-chip {
  flex-shrink: 0; padding: 5px 12px; border-radius: var(--r-pill);
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid var(--accent-border);
  font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--font-ui);
  transition: all var(--dur-fast); white-space: nowrap;
}
.pin-chip:active { background: var(--accent); color: #fff; }

.launch-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-dim);
  margin-bottom: var(--sp-2);
}
.launch-dir-suggested {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 1px var(--accent-border);
}

.file-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px var(--sp-4); cursor: pointer;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  min-height: 60px;
  transition: background var(--dur-fast);
}
.file-row:last-child { border-bottom: none; }
.file-row:active { background: var(--bg-secondary); }
.file-row-icon {
  width: 36px; height: 36px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dir-icon {
  background: var(--blue-bg); color: var(--blue);
}
.file-icon-wrap {
  background: var(--bg-secondary); color: var(--text-dim);
}
.file-row-info {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.file-row-name {
  font-size: 15px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-row-path {
  font-size: 11px; color: var(--text-dim); font-family: var(--font-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.git-badge {
  display: inline-block; padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--accent-dim); color: var(--accent);
  font-size: 10px; font-weight: 600; letter-spacing: 0.03em;
  margin-top: 2px; font-family: var(--font-mono); align-self: flex-start;
}
.file-row-action {
  flex-shrink: 0; padding: 6px 10px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-secondary);
  font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: var(--font-ui); text-decoration: none;
  display: flex; align-items: center; gap: 4px;
  transition: all var(--dur-fast);
}
.cd-btn { color: var(--blue); border-color: rgba(0,122,255,0.25); background: var(--blue-bg); }
.edit-btn { color: var(--accent); border-color: var(--accent-border); background: var(--accent-dim); }
.dl-btn  { color: var(--text-secondary); }
.file-row-action:active { opacity: 0.7; }

/* ── System stats bar (Agents tab) ────────────────── */
#sys-bar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-4);
  height: 34px; flex-shrink: 0;
  background: var(--bg-terminal);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
#sys-bar::-webkit-scrollbar { display: none; }
.sys-stat { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.sys-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-dim); font-family: var(--font-mono);
}
.sys-val {
  font-size: 12px; font-weight: 600; font-family: var(--font-mono);
  color: var(--accent-soft); min-width: 32px;
}
.sys-sep { color: var(--text-dim); font-size: 12px; }

/* ── Agent Watchtower enhancements ─────────────────── */
.running-card { border-color: rgba(255,59,92,0.18); }
.agent-dur {
  display: block; font-family: var(--font-mono); font-size: 10px;
  color: var(--text-dim); margin-top: 2px; font-weight: 400;
}
.agent-ticker {
  padding: var(--sp-2) var(--sp-4);
  font-family: var(--font-mono); font-size: 11px; color: var(--accent-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-top: 1px solid var(--border); opacity: 0.7;
}

/* ── Diff review sheet ─────────────────────────────── */
.diff-sheet-overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
}
.diff-sheet {
  background: var(--bg-card);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border: 1px solid var(--border);
  width: 100%; max-width: 680px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.diff-sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 10px auto 0; flex-shrink: 0;
}
.diff-sheet-header {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.diff-sheet-title {
  font-size: 16px; font-weight: 700; color: var(--text-primary);
}
.diff-sheet-sub {
  font-size: 12px; color: var(--text-dim); margin-top: 2px;
}
.diff-body {
  flex: 1; overflow-y: auto; background: var(--bg-terminal);
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.diff-body::-webkit-scrollbar { width: 4px; }
.diff-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.diff-file-list {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; gap: 4px;
}
.diff-file-entry {
  font-family: var(--font-mono); font-size: 12px;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-secondary);
}
.diff-file-entry.diff-added   { color: var(--green); }
.diff-file-entry.diff-removed { color: var(--red); }
.diff-file-entry.diff-modified { color: var(--amber); }
.diff-file-label { width: 12px; text-align: center; flex-shrink: 0; }

.diff-hunk-wrap { padding: var(--sp-3) 0; }
.diff-filename {
  padding: 8px var(--sp-4); font-family: var(--font-mono); font-size: 11px;
  color: var(--accent-soft); background: rgba(255,59,92,0.05);
  border-top: 1px solid rgba(255,59,92,0.10);
  border-bottom: 1px solid rgba(255,59,92,0.10);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.diff-line {
  display: flex; align-items: baseline; gap: 8px;
  padding: 1px var(--sp-4); font-family: var(--font-mono); font-size: 12px;
  line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}
.diff-line.add  { background: rgba(52,199,89,0.10); color: var(--green); }
.diff-line.del  { background: rgba(255,59,48,0.10);  color: var(--red); }
.diff-line.hunk { background: var(--accent-dim); color: var(--accent-soft); font-size: 11px; }
.diff-line.ctx  { color: var(--text-dim); }
.diff-sign { opacity: 0.6; width: 12px; flex-shrink: 0; }

.diff-footer {
  padding: var(--sp-3) var(--sp-4); background: var(--bg-card);
  border-top: 1px solid var(--border); flex-shrink: 0;
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.diff-commit-input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-secondary); border: 1.5px solid var(--border);
  border-radius: var(--r-md); color: var(--text-primary);
  font-family: var(--font-ui); font-size: 14px; outline: none;
  transition: border-color var(--dur-fast);
}
.diff-commit-input:focus { border-color: var(--accent); }
.diff-action-row {
  display: flex; gap: var(--sp-2);
}
.diff-btn {
  flex: 1; padding: 11px 8px; border-radius: var(--r-md);
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  border: none; cursor: pointer; transition: opacity var(--dur-fast);
}
.diff-btn:active { opacity: 0.8; }
.diff-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.diff-btn.approve { background: var(--green); color: #fff; }
.diff-btn.reject  { background: var(--red); color: #fff; }
.diff-btn.undo    { background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border); }

/* ── Dirty badge in file browser ───────────────────── */
.git-dirty-badge {
  display: inline-block; padding: 1px 7px; border-radius: var(--r-pill);
  background: var(--amber-bg); color: var(--amber);
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
  margin-top: 2px; font-family: var(--font-mono); align-self: flex-start;
}
.review-btn {
  color: var(--amber); border-color: rgba(255,149,0,0.3);
  background: var(--amber-bg);
}

/* ── Terminal macros ───────────────────────────────── */
.macro-btn {
  color: var(--amber) !important;
  border-color: rgba(255,149,0,0.3) !important;
  background: var(--amber-bg) !important;
}

/* ── Repo quick actions ────────────────────────────── */
.more-btn {
  color: var(--text-dim);
  font-size: 16px;
  min-width: 28px;
  padding: 4px 6px;
}

/* ── Pi Remote tab ─────────────────────────────────── */
.pi-stats-card {
  padding: var(--sp-4); margin-bottom: 0;
}
.pi-stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3);
}
.pi-stat {
  display: flex; flex-direction: column; gap: 2px;
}
.pi-stat-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-dim);
}
.pi-stat-val {
  font-size: 20px; font-weight: 700; color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.pi-stat-val.warn { color: var(--amber); }
.pi-stat-sub { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }

.proc-card {
  padding: 0; margin: 0; overflow: hidden;
}
.proc-card-body {
  display: flex; align-items: center; padding: var(--sp-3) var(--sp-4);
  gap: var(--sp-3);
}
.proc-info { flex: 1; min-width: 0; }
.proc-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.proc-meta { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); margin-top: 1px; }
.proc-status-badge {
  flex-shrink: 0; padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
}
.proc-status-badge.online  { background: var(--green-bg); color: var(--green); }
.proc-status-badge.offline { background: var(--bg-secondary); color: var(--text-dim); }
.proc-actions {
  display: flex; gap: var(--sp-2); padding: 0 var(--sp-4) var(--sp-3);
}

.pi-action-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3);
}
.pi-action-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-4);
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; gap: var(--sp-3);
  transition: background var(--dur-fast);
  box-shadow: var(--shadow-xs);
}
.pi-action-btn:active { background: var(--bg-secondary); }
.pi-action-icon {
  font-size: 18px; width: 32px; height: 32px;
  background: var(--accent-dim); border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); flex-shrink: 0;
}

/* ── Remote Browser tab ────────────────────────────── */
#tab-browser { background: #000; }
#browser-panel {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  background: #000;
}
.browser-toolbar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  flex-shrink: 0; gap: 6px;
}
.browser-nav-btn {
  padding: 7px 10px; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-secondary); font-size: 14px; cursor: pointer;
  flex-shrink: 0; font-family: var(--font-ui); font-weight: 500;
  transition: all var(--dur-fast);
}
.browser-nav-btn:active { background: var(--accent-dim); color: var(--accent); }
.browser-url-input {
  flex: 1; padding: 7px 12px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text-primary);
  font-family: var(--font-mono); font-size: 12px; outline: none;
  transition: border-color var(--dur-fast);
}
.browser-url-input:focus { border-color: var(--accent); }
.browser-viewport {
  flex: 1; overflow: hidden; position: relative; background: #1a1a2e;
  display: flex; align-items: center; justify-content: center;
}
.browser-frame {
  width: 100%; height: 100%; object-fit: contain;
  display: none; cursor: crosshair;
  image-rendering: -webkit-optimize-contrast;
}
.browser-offline {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.browser-offline-inner {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 24px; max-width: 320px;
}
.browser-offline-icon { font-size: 48px; margin-bottom: 12px; }
.browser-offline-title { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.browser-offline-hint { font-size: 13px; color: var(--text-dim); line-height: 1.5; margin-bottom: 12px; }
.browser-offline-cmd {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-terminal); color: var(--accent-soft);
  padding: 10px 14px; border-radius: 8px; display: block;
  text-align: left; width: 100%; word-break: break-all;
}
.browser-type-row {
  display: flex; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3);
  background: var(--bg-card); border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.browser-type-input {
  flex: 1; padding: 7px 12px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text-primary);
  font-family: var(--font-ui); font-size: 14px; outline: none;
  transition: border-color var(--dur-fast);
}
.browser-type-input:focus { border-color: var(--accent); }

/* ── Settings / More tab ──────────────────────────── */
.settings-section { margin-bottom: var(--sp-2); }
.settings-section-title {
  font-size: 11px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: var(--sp-3) 0 var(--sp-2);
}
.settings-group {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.settings-row {
  display: flex; align-items: center; padding: var(--sp-4);
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.settings-row:last-child { border-bottom: none; }
.settings-row:active { background: var(--bg-secondary); }
.settings-row-label {
  flex: 1; font-size: 15px; color: var(--text-primary);
}
.settings-row-value {
  font-size: 13px; color: var(--text-dim);
  font-family: var(--font-mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 140px;
}

/* ── Dark mode overrides ───────────────────────────── */
@media (prefers-color-scheme: dark) {
  #tab-bar { background: rgba(0,0,0,0.88); }
  .news-hero-card, .story-list-card { box-shadow: none; }
}

/* ── Large-title panel headers (Today / More) ───────── */
.tab-large-header {
  padding: calc(var(--safe-top) + 20px) 16px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── iPad: sidebar nav (≥ 768px) ───────────────────── */
@media (min-width: 768px) {
  #app { flex-direction: row; }

  /* Sidebar replaces bottom tab bar */
  #tab-bar {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    order: -1;
    width: 80px;
    height: auto;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg-card);
    border-top: none;
    border-right: 1px solid var(--border);
    padding: calc(var(--safe-top) + 24px) 8px calc(var(--safe-bottom) + 16px);
    gap: 2px;
  }

  .tab-btn {
    flex-direction: column;
    width: 100%;
    height: auto;
    padding: 10px 4px;
    border-radius: var(--r-md);
    font-size: 10px;
    letter-spacing: 0.04em;
  }
  .tab-btn svg { width: 22px; height: 22px; }
  .tab-btn:hover { background: var(--bg-secondary); }
  .tab-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: var(--r-md);
  }

  /* Top bars: sidebar handles safe-top, panels don't need it */
  .top-bar {
    padding-top: 0;
    height: var(--topbar-h);
  }

  /* Large-title headers: sidebar handles safe-top */
  .tab-large-header {
    padding-top: 20px;
  }

  /* Scroll containers: no bottom tab bar on iPad */
  .news-feed {
    padding-bottom: var(--sp-8) !important;
  }
  .scroll-list {
    padding-bottom: var(--sp-8) !important;
  }
}

/* ── Desktop: labeled sidebar (≥ 1024px) ───────────── */
@media (min-width: 1024px) {
  #tab-bar {
    width: 220px;
    padding-left: 12px;
    padding-right: 12px;
    gap: 4px;
  }

  .tab-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0;
    border-radius: var(--r-md);
  }

  .tab-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

  /* App name / logo at top of sidebar */
  #tab-bar::before {
    content: 'Stan CLI';
    display: block;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
    padding: 0 16px 20px;
    letter-spacing: -0.3px;
  }
}

@media (min-width: 768px) and (prefers-color-scheme: dark) {
  #tab-bar { background: var(--bg-card); }
}

/* ── Pi Control Center ─────────────────────────────── */

/* Segment nav */
#pi-seg-nav {
  flex-shrink: 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#pi-seg-nav::-webkit-scrollbar { display: none; }
.pi-seg-strip {
  display: flex; gap: 0; padding: 0 12px;
  min-width: max-content;
}
.pi-seg-btn {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  color: var(--text-dim); padding: 10px 14px;
  position: relative; white-space: nowrap;
  transition: color var(--dur-fast);
  -webkit-tap-highlight-color: transparent;
}
.pi-seg-btn.active { color: var(--accent); }
.pi-seg-btn.active::after {
  content: ''; position: absolute; bottom: 0; left: 12px; right: 12px;
  height: 2px; background: var(--accent); border-radius: 2px 2px 0 0;
}

/* Cards */
.pi-card {
  background: var(--bg-card); border-radius: var(--r-lg);
  border: 1px solid var(--border); margin: 0 16px 12px;
  overflow: hidden; box-shadow: var(--shadow-xs);
}
.pi-card-flush { margin: 0 16px 12px; padding: 0; }

/* Section labels */
.pi-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-dim);
  padding: 16px 16px 8px;
}
.pi-sub-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-dim);
  padding: 8px 16px 6px;
}

/* Generic row layout */
.pi-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; gap: 12px;
}
.pi-row.bordered { border-bottom: 1px solid var(--border); }
.pi-row-label { font-size: 14px; color: var(--text-secondary); flex-shrink: 0; }
.pi-row-label-bold { font-weight: 600; color: var(--text-primary); }
.pi-row-val { font-size: 14px; color: var(--text-primary); text-align: right; word-break: break-all; }
.pi-row-val.mono { font-family: var(--font-mono); font-size: 12px; }

/* Badges */
.pi-badge {
  flex-shrink: 0; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
}
.pi-badge.online  { background: var(--green-bg);  color: var(--green); }
.pi-badge.offline { background: var(--bg-secondary); color: var(--text-dim); }

/* Stat tiles (overview grid) */
.pi-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; padding: 14px;
}
.pi-stat-tile {
  background: var(--bg-secondary); border-radius: var(--r-md);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
}
.pi-tile-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-dim);
}
.pi-tile-val {
  font-size: 22px; font-weight: 700; color: var(--text-primary);
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.pi-tile-sub { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }

/* Progress bars */
.pi-tile-bar {
  height: 3px; background: var(--border); border-radius: 2px;
  margin-top: 6px; overflow: hidden;
}
.pi-tile-bar-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width 0.3s ease;
}
.pi-disk-bar {
  height: 5px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.pi-disk-bar-fill {
  height: 100%; background: var(--accent); border-radius: 3px;
  transition: width 0.3s;
}
.bar-warn  { background: var(--amber); }
.bar-danger { background: var(--red); }

/* Value colors */
.val-good   { color: var(--green); }
.val-warn   { color: var(--amber); }
.val-danger { color: var(--red); }

/* Banner */
.pi-banner {
  margin: 14px 16px 4px; padding: 14px 16px;
  background: var(--accent-dim); border-radius: var(--r-lg);
  border: 1px solid var(--accent-border);
}
.pi-banner-main { font-size: 16px; font-weight: 700; color: var(--accent); }
.pi-banner-sub  { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.pi-banner-kernel { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); margin-top: 4px; }

/* Quick action grid */
.pi-action-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 10px; padding: 0 16px 16px;
}
.pi-quick-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 10px;
  font-family: var(--font-ui); font-size: 11px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  box-shadow: var(--shadow-xs); text-align: center; line-height: 1.3;
}
.pi-quick-btn svg { color: var(--accent); }
.pi-quick-btn:active { background: var(--bg-secondary); border-color: var(--accent-border); }

/* PM2 / process cards */
.pi-proc-card { margin: 0 16px 10px; }
.pi-proc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; gap: 12px;
}
.pi-proc-info { flex: 1; min-width: 0; }
.pi-proc-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.pi-proc-meta { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); margin-top: 1px; }
.pi-proc-stats {
  display: flex; gap: 16px; padding: 0 16px 8px;
  font-size: 11px; color: var(--text-dim); font-family: var(--font-mono);
  border-bottom: 1px solid var(--border);
}
.pi-proc-actions {
  display: flex; gap: 8px; padding: 10px 16px 12px;
}

/* Service rows */
.pi-service-row {
  padding: 11px 16px; display: flex;
  align-items: center; justify-content: space-between; gap: 12px;
}
.pi-service-row.bordered { border-bottom: 1px solid var(--border); }
.pi-service-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.pi-service-name { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.pi-service-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Small service/proc action buttons */
.pi-svc-btn {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 5px 12px;
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--dur-fast); white-space: nowrap;
}
.pi-svc-btn:active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-border); }
.pi-svc-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pi-svc-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.pi-btn-primary { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }

/* WiFi network list */
.pi-net-list { display: flex; flex-direction: column; }
.pi-net-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; cursor: pointer; gap: 8px;
  transition: background 0.15s;
}
.pi-net-row:hover { background: var(--surface-2, rgba(255,255,255,0.04)); }
.pi-net-row.bordered { border-bottom: 1px solid var(--border); }
.pi-net-ssid { font-size: 14px; font-weight: 500; color: var(--text-primary); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-net-meta { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }

/* WiFi connect form */
.pi-connect-form { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 4px; }
.pi-text-input {
  flex: 1; min-width: 0;
  background: var(--surface-2, rgba(255,255,255,0.06));
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  padding: 7px 10px;
  outline: none;
}
.pi-text-input:focus { border-color: var(--accent, #FF3B5C); }

/* VPN select picker */
.pi-select {
  flex: 1; min-width: 0;
  background: var(--surface-2, rgba(255,255,255,0.06));
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  padding: 6px 8px;
}

/* Top processes */
.pi-top-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; gap: 12px;
}
.pi-top-row.bordered { border-bottom: 1px solid var(--border); }
.pi-top-info { flex: 1; min-width: 0; }
.pi-top-name { font-size: 13px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-top-meta { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }
.pi-top-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.pi-top-cpu { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.pi-top-mem { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }

/* Log viewer */
.pi-log-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; gap: 10px;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pi-log-tabs { display: flex; gap: 4px; }
.pi-log-tab {
  background: none; border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 5px 14px;
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  color: var(--text-dim); cursor: pointer; transition: all var(--dur-fast);
}
.pi-log-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pi-log-select {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 5px 8px;
  font-family: var(--font-ui); font-size: 12px;
  color: var(--text-primary); outline: none;
}
.pi-log-pm2-sel {
  padding: 8px 16px;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.pi-log-output {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  font-family: var(--font-mono); font-size: 11px; line-height: 1.55;
  background: var(--bg-terminal); color: var(--text-secondary);
  padding: 10px 14px;
}
.log-line { white-space: pre-wrap; word-break: break-all; margin-bottom: 1px; }
.log-err  { color: #ff6b6b; }
.log-warn { color: var(--amber); }
.log-info { color: var(--text-dim); }

/* Power section */
.pi-power-warn {
  margin: 0 16px 12px;
  background: var(--amber-bg); border: 1px solid var(--amber);
  border-radius: var(--r-md); padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-secondary); line-height: 1.4;
}
.pi-power-row {
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.pi-power-row.bordered { border-bottom: 1px solid var(--border); }
.pi-power-info { display: flex; align-items: center; gap: 14px; flex: 1; }
.pi-power-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--bg-secondary); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); flex-shrink: 0;
}
.pi-power-icon.danger { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: var(--red); }
.pi-power-label { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.pi-power-desc  { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.pi-power-confirm-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.pi-power-btn {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 8px 18px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  color: var(--text-primary); cursor: pointer;
  transition: all var(--dur-fast); white-space: nowrap;
}
.pi-power-btn.danger { background: rgba(239,68,68,0.1); color: var(--red); border-color: rgba(239,68,68,0.4); }
.pi-power-btn.confirming { background: var(--red); color: #fff; border-color: var(--red); }
.pi-power-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pi-power-cancel {
  background: none; border: none; font-family: var(--font-ui);
  font-size: 12px; color: var(--text-dim); cursor: pointer; padding: 2px 4px;
}

/* Toast */
.pi-toast {
  position: fixed; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px); left: 50%; transform: translateX(-50%);
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 10px 20px;
  font-size: 13px; font-weight: 500; color: var(--text-primary);
  box-shadow: var(--shadow-lg); z-index: 1000; white-space: nowrap;
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.pi-toast.show { opacity: 1; }
@media (min-width: 768px) {
  .pi-toast { bottom: calc(var(--safe-bottom) + 20px); }
  .pi-action-grid { grid-template-columns: repeat(4, 1fr); }
  .pi-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Loading / empty / error states */
.pi-loading { color: var(--text-dim); text-align: center; padding: 40px 0; font-size: 14px; }
.pi-empty   { color: var(--text-dim); text-align: center; padding: 24px 16px; font-size: 14px; }
.pi-err     { color: var(--red); padding: 16px; font-size: 13px; }
.pi-note    { font-size: 12px; color: var(--text-dim); padding: 0 16px 8px; }

/* Override scroll-list side padding for pi content (elements have own margins) */
#pi-content { padding-left: 0; padding-right: 0; gap: 0; }

/* Log viewer takes full remaining height */
#pi-content.log-mode { overflow: hidden; padding: 0; }
#pi-content.log-mode .pi-log-output { flex: 1; min-height: 0; }
.pi-log-output { min-height: 200px; }

/* Amber variable fallback */
:root { --amber: #f59e0b; --amber-bg: rgba(245,158,11,0.1); --yellow: #eab308; }

/* ── More tab additions ─────────────────────────────── */

/* Pi Control shortcuts grid */
.more-shortcut-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; padding: 4px 16px 4px;
}
.more-shortcut-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 8px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-family: var(--font-ui); font-size: 11px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--dur-fast); box-shadow: var(--shadow-xs);
  line-height: 1.2;
}
.more-shortcut-btn svg { color: var(--accent); }
.more-shortcut-btn:active { background: var(--accent-dim); border-color: var(--accent-border); }
@media (min-width: 768px) { .more-shortcut-grid { grid-template-columns: repeat(5, 1fr); } }

/* Theme toggle */
.theme-toggle-group {
  display: flex; gap: 0; border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden;
}
.theme-btn {
  flex: 1; background: none; border: none; cursor: pointer;
  font-family: var(--font-ui); font-size: 12px; font-weight: 500;
  color: var(--text-dim); padding: 6px 12px;
  transition: all var(--dur-fast); white-space: nowrap;
}
.theme-btn.active { background: var(--accent); color: #fff; }
.theme-btn:not(.active):active { background: var(--bg-secondary); }

/* Mono small for URL */
.mono-sm { font-family: var(--font-mono); font-size: 11px; }

/* ── Docker rows ──────────────────────────────────────── */
.pi-docker-row {
  padding: 12px 16px; display: flex;
  align-items: flex-start; justify-content: space-between; gap: 12px;
}
.pi-docker-row.bordered { border-bottom: 1px solid var(--border); }
.pi-docker-info { flex: 1; min-width: 0; }
.pi-docker-name  { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.pi-docker-image { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); margin-top: 1px; }
.pi-docker-status { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.pi-docker-ports  { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); margin-top: 2px; word-break: break-all; }
.pi-docker-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

/* ── Cron rows ────────────────────────────────────────── */
.pi-cron-row { padding: 10px 16px; }
.pi-cron-row.bordered { border-bottom: 1px solid var(--border); }
.pi-cron-schedule {
  font-family: var(--font-mono); font-size: 11px; color: var(--accent);
  font-weight: 600; margin-bottom: 3px;
}
.pi-cron-cmd {
  font-size: 12px; color: var(--text-primary); word-break: break-all; line-height: 1.4;
}
.pi-cron-source { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

/* ── Hardware governor ────────────────────────────────── */
.pi-governor-wrap { display: flex; align-items: center; gap: 8px; }

/* ── Clips panel ──────────────────────────────────────── */
.clips-panel-row {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.clips-panel-row:last-child { border-bottom: none; }
.clips-panel-preview {
  font-size: 13px; color: var(--text-primary); line-height: 1.4;
  white-space: pre-wrap; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.clips-panel-preview.mono { font-family: var(--font-mono); font-size: 11px; }
.clips-panel-meta {
  display: flex; gap: 6px; margin-top: 4px;
  font-size: 11px; color: var(--text-dim); align-items: center;
}
.clips-panel-actions {
  display: flex; gap: 6px; margin-top: 8px;
}

/* ── Phone tab: Android screen mirror ────────────────── */
#phone-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
  min-height: 0;
}
#phone-screen {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: none;          /* we handle gestures ourselves */
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
}
#phone-keybar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#phone-keybar .phone-key {
  flex-shrink: 0;
  min-width: 44px;
  height: 40px;
  border-radius: var(--r-md, 10px);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#phone-keybar .phone-key:active { background: var(--accent); color: #fff; }
#phone-keybar .phone-text {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-md, 10px);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 15px;
}

/* ── Automation tab: cron + agent tasks ──────────────── */
.ops-refresh {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: var(--r-pill, 999px); padding: 4px 14px; font-size: 13px; cursor: pointer;
  font-family: var(--font-ui);
}
.ops-refresh:active { background: var(--accent); color: #fff; }
.ops-row { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.ops-row:last-child { border-bottom: none; }
.ops-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.ops-main { min-width: 0; flex: 1; }
.ops-title { font-size: 15px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ops-sub { font-size: 13px; color: var(--text-dim); margin-top: 3px; line-height: 1.45; }
.ops-sub code { font-family: var(--font-mono, monospace); font-size: 12px; background: var(--bg-card); padding: 1px 6px; border-radius: 5px; }
.ops-err { color: var(--red); margin-top: 4px; font-size: 12px; word-break: break-word; }
.ops-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-dim); background: var(--bg-card); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 5px; }
.ops-badge.paused { color: var(--red); border-color: var(--red); }
.ops-badge.run { color: var(--accent); border-color: var(--accent); }
.ops-empty { padding: 18px 16px; color: var(--text-dim); font-size: 14px; }

/* ── StanCLI Jobs: group headers, actions, log, new-job form ─────────── */
.ops-grouphdr { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent); padding: 12px 16px 4px; }
.ops-dot.pulse { animation: opsPulse 1.1s ease-in-out infinite; }
@keyframes opsPulse { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 var(--accent); } 50% { opacity: .5; box-shadow: 0 0 0 4px transparent; } }
.ops-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ops-btn { font-size: 13px; font-weight: 600; color: var(--text-primary); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 14px; cursor: pointer; min-height: 34px; }
.ops-btn:active { background: var(--accent); color: #fff; border-color: var(--accent); }
.ops-btn:disabled { opacity: .5; }
.ops-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.ops-btn.danger { color: var(--red); border-color: var(--red); }
.ops-log { margin-top: 10px; background: #000; color: #b8f7ff; font-family: var(--font-mono, monospace);
  font-size: 12px; line-height: 1.5; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.ops-form { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ops-input { width: 100%; font-size: 14px; color: var(--text-primary); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-family: inherit; }
.ops-formrow { display: flex; gap: 10px; align-items: center; }
.ops-formrow .ops-input { flex: 1; }

/* ── App-shell UX: dock, palette, swipe pager ─────────── */
#dock-fab {
  position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.45); transition: transform .15s ease;
}
#dock-fab:active { transform: scale(.92); }
#dock-fab.active { transform: rotate(45deg); }
.dock-badge {
  position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px;
  border-radius: 10px; background: var(--bg); color: var(--text-primary);
  border: 1.5px solid var(--accent); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.dock-badge.hidden { display: none; }
#dock-panel {
  position: fixed; right: 16px; bottom: calc(146px + env(safe-area-inset-bottom, 0px));
  width: min(310px, calc(100vw - 32px)); max-height: 60vh; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 10px 34px rgba(0,0,0,.5); z-index: 901; padding: 12px;
  opacity: 0; transform: translateY(12px) scale(.96); pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
#dock-panel.open { opacity: 1; transform: none; pointer-events: auto; }
.dock-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.dock-act {
  background: var(--bg); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 12px; padding: 11px 8px; font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: var(--font-ui);
}
.dock-act:active { background: var(--accent); color: #fff; }
.dock-running-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); padding: 4px 4px 8px; }
.dock-session { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: none;
  border-radius: 10px; padding: 9px 8px; cursor: pointer; color: var(--text-primary); text-align: left; }
.dock-session:active { background: var(--bg); }
.dock-ic { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.dock-sname { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-empty { color: var(--text-dim); font-size: 13px; padding: 14px 6px; text-align: center; }

#cmd-palette {
  position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh; backdrop-filter: blur(3px);
}
.cmd-box { width: min(560px, calc(100vw - 32px)); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: 0 16px 50px rgba(0,0,0,.55); }
#cmd-input { width: 100%; border: none; outline: none; background: transparent; color: var(--text-primary);
  font-size: 17px; padding: 18px 20px; font-family: var(--font-ui); border-bottom: 1px solid var(--border); }
#cmd-results { max-height: 50vh; overflow-y: auto; }
.cmd-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 20px; cursor: pointer; }
.cmd-row.active, .cmd-row:active { background: var(--accent); }
.cmd-row.active .cmd-hint { color: rgba(255,255,255,.8); }
.cmd-label { font-size: 15px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-row.active .cmd-label { color: #fff; }
.cmd-hint { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); flex-shrink: 0; }
.cmd-empty { padding: 20px; text-align: center; color: var(--text-dim); }

#swipe-pager { position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 950; opacity: 0; transition: opacity .2s ease; pointer-events: none; }
#swipe-pager.show { opacity: 1; }
#swipe-pager span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); opacity: .5; }
#swipe-pager span.on { background: var(--accent); opacity: 1; width: 16px; border-radius: 3px; }

/* ── StanCLI v4.1 command deck polish ───────────────────────── */
body::before {
  content: '';
  position: fixed; inset: -20% -10% auto -10%; height: 52vh;
  background:
    radial-gradient(circle at 18% 18%, rgba(255,59,92,.22), transparent 34%),
    radial-gradient(circle at 82% 8%, rgba(14,166,194,.20), transparent 32%),
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 70%);
  pointer-events: none; z-index: 0;
}
#app, #auth-screen { position: relative; z-index: 1; }
.tab-large-header {
  padding-top: calc(var(--safe-top) + 18px) !important;
  background: linear-gradient(180deg, rgba(255,255,255,.80), rgba(255,255,255,0));
  backdrop-filter: blur(14px);
}
[data-theme="dark"] .tab-large-header { background: linear-gradient(180deg, rgba(11,15,23,.82), rgba(11,15,23,0)); }
.command-deck-card {
  position: relative; overflow: hidden;
  margin: 0 16px 2px;
  padding: 20px;
  min-height: 292px;
  border-radius: 32px;
  color: #fff;
  background: linear-gradient(135deg, #151923 0%, #28101b 48%, #0b2028 100%);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28), inset 0 1px 0 rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.12);
}
.command-deck-card.ready { background: linear-gradient(135deg, #121826 0%, #1b1020 45%, #082d35 100%); }
.command-deck-card.busy { background: linear-gradient(135deg, #18151f 0%, #3a2204 52%, #112235 100%); }
.command-deck-card.hot { background: linear-gradient(135deg, #1d1013 0%, #4a1221 52%, #251106 100%); }
.command-deck-bg {
  position: absolute; inset: -1px;
  background:
    radial-gradient(circle at 15% 18%, rgba(255,59,92,.55), transparent 28%),
    radial-gradient(circle at 90% 0%, rgba(10,166,194,.46), transparent 32%),
    radial-gradient(circle at 74% 86%, rgba(255,255,255,.16), transparent 22%);
  filter: saturate(1.2); opacity: .88;
}
.command-deck-card > *:not(.command-deck-bg) { position: relative; z-index: 1; }
.command-deck-top { display: flex; gap: 18px; justify-content: space-between; align-items: flex-start; }
.deck-eyebrow { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 800; letter-spacing: .12em; opacity: .78; }
.deck-eyebrow span { width: 8px; height: 8px; border-radius: 999px; background: #37f59b; box-shadow: 0 0 14px #37f59b; }
.deck-title { margin-top: 12px; font-family: var(--font-display); font-weight: 900; line-height: .96; letter-spacing: -.045em; font-size: clamp(34px, 9vw, 54px); max-width: 520px; }
.deck-copy { margin-top: 12px; color: rgba(255,255,255,.72); font-size: 14px; line-height: 1.45; max-width: 530px; }
.deck-orb { flex: 0 0 auto; width: 94px; height: 94px; border-radius: 28px; display: grid; place-content: center; text-align: center; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); backdrop-filter: blur(18px); box-shadow: inset 0 1px 0 rgba(255,255,255,.18); }
.deck-orb b { font-size: 13px; letter-spacing: -.01em; }
.deck-orb small { margin-top: 4px; color: rgba(255,255,255,.62); font-family: var(--font-mono); font-size: 11px; }
.deck-metrics { margin-top: 24px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.deck-metrics div { padding: 12px 10px; border-radius: 18px; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(12px); }
.deck-metrics span { display: block; color: rgba(255,255,255,.52); font-size: 10px; font-weight: 800; letter-spacing: .10em; }
.deck-metrics b { display: block; margin-top: 6px; color: #fff; font-family: var(--font-mono); font-size: 18px; }
.deck-actions { margin-top: 16px; display: flex; gap: 10px; overflow-x: auto; padding-bottom: 1px; scrollbar-width: none; }
.deck-actions::-webkit-scrollbar { display: none; }
.deck-btn { flex: 0 0 auto; min-height: 46px; padding: 0 16px; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; background: rgba(255,255,255,.10); color: #fff; font-weight: 800; font-family: var(--font-ui); backdrop-filter: blur(12px); cursor: pointer; }
.deck-btn.primary { color: #111827; background: #fff; border-color: #fff; box-shadow: 0 10px 28px rgba(255,255,255,.20); }
.story-list-card, .settings-group, #more-sys-card { border-radius: 22px !important; box-shadow: 0 12px 40px rgba(15,23,42,.08); border: 1px solid var(--border); overflow: hidden; }
.story-row { min-height: 68px; transition: transform .16s ease, background .16s ease; }
.story-row:active { transform: scale(.985); }
.story-row-action, .top-bar-action, .more-shortcut-btn, .auth-secondary-btn, #token-submit { touch-action: manipulation; }
.more-shortcut-grid { gap: 12px !important; }
.more-shortcut-btn { border-radius: 20px !important; min-height: 92px; box-shadow: 0 10px 26px rgba(15,23,42,.07); }
#tab-bar { box-shadow: 0 -10px 30px rgba(15,23,42,.08); }
@media (min-width: 920px) {
  .command-deck-card { min-height: 250px; }
  .deck-actions { overflow: visible; }
  .news-feed { padding-left: max(0px, calc((100vw - 1120px) / 2)); padding-right: max(0px, calc((100vw - 1120px) / 2)); }
}
@media (max-width: 420px) {
  .command-deck-card { padding: 18px; min-height: 310px; border-radius: 28px; }
  .deck-orb { width: 78px; height: 78px; border-radius: 23px; }
  .deck-metrics { grid-template-columns: repeat(2, 1fr); }
}
/* Keep the floating dock off the Today command deck/feed, and off the Chat tab
   where it would float right over the composer's input + send button. */
body[data-tab="home"] #dock-fab,
body[data-tab="home"] #dock-panel,
body[data-tab="chat"] #dock-fab,
body[data-tab="chat"] #dock-panel { display: none !important; }


/* ── StanCLI v4.2 live ops command centre ───────────────────────── */
.ops-command-center {
  margin: 0 16px; padding: 16px; border-radius: 26px; overflow: hidden; position: relative;
  color: var(--text-primary); background: rgba(255,255,255,.72); border: 1px solid var(--border);
  box-shadow: 0 14px 44px rgba(15,23,42,.10); backdrop-filter: blur(16px);
}
[data-theme="dark"] .ops-command-center { background: rgba(15,23,42,.72); }
.ops-command-center.loading { color: var(--text-dim); font-size: 14px; }
.ops-command-center::before { content:''; position:absolute; inset:-40% -20% auto auto; width:220px; height:220px; border-radius:999px; background: rgba(255,59,92,.16); filter: blur(4px); pointer-events:none; }
.ops-command-center.busy::before { background: rgba(245,158,11,.18); }
.ops-command-center.warn::before { background: rgba(239,68,68,.20); }
.ops-command-head { position:relative; display:flex; align-items:flex-start; justify-content:space-between; gap:14px; }
.ops-command-eyebrow { font-size:10px; font-weight:900; letter-spacing:.12em; color:var(--accent); }
.ops-command-title { margin-top:4px; font-size:22px; line-height:1; font-weight:900; letter-spacing:-.04em; }
.ops-command-sub { margin-top:7px; color:var(--text-dim); font-size:13px; line-height:1.35; }
.ops-command-open { flex:0 0 auto; min-height:36px; padding:0 13px; border-radius:999px; border:1px solid var(--border); background:var(--bg-card); color:var(--text-primary); font-weight:800; }
.ops-command-grid { position:relative; margin-top:14px; display:grid; grid-template-columns: repeat(4, 1fr); gap:10px; }
.ops-command-grid button { min-width:0; text-align:left; padding:12px 11px; border-radius:18px; border:1px solid var(--border); background:var(--bg-card); color:var(--text-primary); cursor:pointer; box-shadow:0 8px 24px rgba(15,23,42,.06); }
.ops-command-grid button:active { transform:scale(.985); background:var(--accent); color:#fff; }
.ops-command-grid span { display:block; font-size:11px; font-weight:800; color:var(--text-dim); }
.ops-command-grid b { display:block; margin-top:5px; font-size:21px; line-height:1; font-family:var(--font-mono); }
.ops-command-grid small { display:block; margin-top:5px; font-size:10px; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ops-command-grid button:active span, .ops-command-grid button:active small { color:rgba(255,255,255,.78); }
@media (max-width: 520px) { .ops-command-grid { grid-template-columns: repeat(2, 1fr); } .ops-command-head { flex-direction:column; } .ops-command-open { width:100%; } }
@media (max-width: 520px) {
  .deck-actions { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
  .deck-btn { width: 100%; padding: 0 12px; text-align: center; }
  .deck-btn.primary { grid-column: 1 / -1; }
}
