/* ── TangleClaw v3 — Session Wrapper Styles ── */
/* Mobile-first. Preserves v2 color palette and visual identity. */

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

/* ── CSS Variables (v2 palette — do not change) ── */
:root {
  --primary: #8BC34A;
  --primary-bright: #9CCC65;
  --primary-dark: #558B2F;
  --chrome: #C0C0C0;
  --bg: #000000;
  --card-bg: #0D0D0D;
  --elevated-bg: #1A1A1A;
  --danger: #EF5350;
  --danger-dark: #C62828;
  --text: #E8E8E8;
  --text-muted: #777;
  --root-accent: #4a9eff;
  --amber: #FFA726;
  --engine-claude: #8BC34A;
  --engine-codex: #42A5F5;
  --engine-aider: #AB47BC;
  --engine-genesis: #FF7043;
  --radius-btn: 6px;
  --radius-card: 10px;
  --radius-modal: 12px;
  --radius-pill: 14px;
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg: #F5F5F5;
  --card-bg: #FFFFFF;
  --elevated-bg: #E0E0E0;
  --text: #1A1A1A;
  --text-muted: #666;
}

/* ── High Contrast Theme ── */
[data-theme="high-contrast"] {
  --bg: #000000;
  --card-bg: #000000;
  --elevated-bg: #333333;
  --text: #FFFFFF;
  --text-muted: #BBBBBB;
  --primary: #A4D65E;
  --primary-bright: #B8E070;
  --danger: #FF6B6B;
}

/* ── Base ── */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── Connection Toast ── */
.toast {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}
.toast.visible { transform: translateY(0); }
.toast-warn { background: var(--amber); color: #000; }
.toast-ok { background: var(--primary); color: #000; }

/* ── Banner ── */
.banner {
  flex-shrink: 0;
  background: var(--card-bg);
  border-bottom: 1px solid var(--elevated-bg);
  padding: calc(env(safe-area-inset-top, 0px) + 4px) 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.banner-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.banner-back {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  color: var(--text);
  text-decoration: none;
  font-size: 18px;
  border-radius: var(--radius-btn);
}
.banner-back:active { background: var(--elevated-bg); }
.banner-back:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.banner-logo {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  object-fit: contain;
  aspect-ratio: 1;
}
.banner-sep {
  color: var(--elevated-bg);
  font-size: 16px;
}
.banner-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.banner-version {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
}
.update-badge {
  display: inline-block;
  font-size: 10px;
  font-family: monospace;
  color: var(--danger);
  background: rgba(239, 83, 80, 0.15);
  border: 1px solid var(--danger);
  border-radius: 14px;
  padding: 1px 6px;
  white-space: nowrap;
  vertical-align: middle;
}
.update-badge.hidden { display: none; }

/* ── Status Dot ── */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  animation: breathe 2s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.status-dot.disconnected {
  background: var(--danger);
  animation: none;
}
.status-dot.wrapping {
  background: var(--amber);
  animation: breathe-slow 3s ease-in-out infinite;
}
@keyframes breathe-slow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.status-dot.ended {
  background: var(--text-muted);
  animation: none;
}

/* ── Engine Badge ── */
.banner-engine {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(139, 195, 74, 0.15);
  color: var(--primary);
  white-space: nowrap;
}
.banner-engine[data-engine="codex"] {
  background: rgba(66, 165, 245, 0.15);
  color: var(--engine-codex);
}
.banner-engine[data-engine="aider"] {
  background: rgba(171, 71, 188, 0.15);
  color: var(--engine-aider);
}
.banner-engine[data-engine="genesis"] {
  background: rgba(255, 112, 67, 0.15);
  color: var(--engine-genesis);
}

/* ── Engine Status Dot ── */
.engine-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  background: var(--text-muted);
}
.engine-status-dot.engine-status-operational {
  background: var(--primary);
}
.engine-status-dot.engine-status-degraded {
  background: var(--amber);
}
.engine-status-dot.engine-status-partial_outage {
  background: #FF7043;
}
.engine-status-dot.engine-status-major_outage {
  background: var(--danger);
}
.engine-status-dot.engine-status-unknown {
  background: var(--text-muted);
}

/* ── Engine Status Pill States ── */
.banner-engine.engine-pill-degraded {
  background: rgba(255, 167, 38, 0.2);
  color: var(--amber);
}
.banner-engine.engine-pill-partial_outage {
  background: rgba(255, 112, 67, 0.2);
  color: #FF7043;
}
.banner-engine.engine-pill-major_outage {
  background: rgba(239, 83, 80, 0.25);
  color: var(--danger);
  animation: engine-pulse 1.5s ease-in-out infinite;
}
@keyframes engine-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(239, 83, 80, 0.3); }
  50% { box-shadow: 0 0 12px rgba(239, 83, 80, 0.8); }
}

/* ── Group Pills ── */
.banner-groups {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}
.group-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(74, 158, 255, 0.15);
  color: var(--root-accent);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}
.group-pill:hover {
  background: rgba(74, 158, 255, 0.3);
}
.group-popover {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  background: var(--elevated-bg);
  border: 1px solid var(--text-muted);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 160px;
  z-index: 100;
  font-weight: 400;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.group-popover.open { display: block; }
.group-popover-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--root-accent);
}
.group-popover-member {
  padding: 2px 0;
  color: var(--text-muted);
}
.group-popover-member.current {
  color: var(--primary);
  font-weight: 600;
}

.banner-methodology {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(171, 71, 188, 0.15);
  color: #ce93d8;
  white-space: nowrap;
}

.banner-phase {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 152, 0, 0.15);
  color: #ffb74d;
  white-space: nowrap;
}

.banner-phase-unknown {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Banner Action Buttons ── */
.banner-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* #139 Chunk 11b — methodology-declared action buttons (e.g. prawduct's
   "Run Critic"). Slight accent so users can tell methodology actions
   apart from the always-visible Wrap / Kill / Cmd / Peek controls. */
.methodology-actions {
  display: inline-flex;
  gap: 4px;
}
.methodology-action-btn {
  border-color: var(--accent, #6c63ff) !important;
  color: var(--accent, #6c63ff);
}
.methodology-action-btn:disabled {
  opacity: 0.5;
  cursor: progress;
}

.methodology-action-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  padding: 10px 16px;
  border-radius: var(--radius-btn);
  background: var(--elevated-bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.methodology-action-toast--visible {
  opacity: 1;
  transform: translateY(0);
}
.methodology-action-toast--error {
  border: 1px solid #e25555;
  color: #e25555;
}

/* #267 — findings panel for actions that return structured findings
   (e.g. Run Critic). Anchored at bottom-right, stays open until
   explicitly dismissed (intentional contrast with auto-closing toast). */
.action-findings-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 480px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-panel, #1c1f24);
  color: var(--text-primary, #e8e8e8);
  border: 1px solid var(--border-panel, #3a4048);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  font-size: 13px;
}
.action-findings-panel--fallback {
  border-color: #d3a83f;
}
.action-findings-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-panel, #3a4048);
  background: rgba(255, 255, 255, 0.03);
}
.action-findings-panel__close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.action-findings-panel__close:hover {
  color: #fff;
}
.action-findings-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.action-findings-panel__item {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.action-findings-panel__item:last-child {
  border-bottom: none;
}
.action-findings-panel__severity {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
  align-self: flex-start;
}
.action-findings-panel__severity--blocking {
  background: #6e1c1c;
  color: #ffd0d0;
}
.action-findings-panel__severity--warning {
  background: #6d5b1f;
  color: #ffe7ad;
}
.action-findings-panel__severity--note {
  background: #2c3d5a;
  color: #b3d4ff;
}
.action-findings-panel__message {
  line-height: 1.4;
}
.action-findings-panel__recommendation,
.action-findings-panel__location {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 2px;
}
.action-findings-panel__fallback-body {
  padding: 12px;
  line-height: 1.5;
  color: #d3a83f;
}
.banner-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  min-width: 30px;
  padding: 2px 8px;
  background: none;
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.banner-btn:active { background: var(--elevated-bg); }
.banner-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.banner-btn.active {
  border-color: var(--primary);
  color: var(--primary);
}
.banner-btn.btn-wrap {
  color: var(--primary);
  border-color: var(--primary-dark);
}
.banner-btn.btn-wrap:active {
  background: var(--primary-dark);
  color: #fff;
}
.banner-btn.btn-kill {
  color: var(--danger);
  border-color: var(--danger-dark);
}
.banner-btn.btn-kill:active {
  background: var(--danger-dark);
  color: #fff;
}
.banner-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Mobile banner: smaller buttons */
@media (max-width: 600px) {
  .banner-btn {
    font-size: 10px;
    padding: 2px 6px;
  }
  .banner-name { max-width: 100px; }
}

/* Desktop banner: single row */
@media (min-width: 900px) {
  .banner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
  }
  .banner-row {
    flex-shrink: 1;
    min-width: 0;
  }
  .banner-actions {
    flex-shrink: 0;
    flex-wrap: nowrap;
  }
  .banner-btn {
    font-size: 11px;
    padding: 2px 8px;
    min-height: 26px;
    min-width: 26px;
  }
  .banner-name { max-width: 200px; }
}

/* ── Session Wrapping Bar ── */
.session-wrapping {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 167, 38, 0.12);
  border-bottom: 1px solid rgba(255, 167, 38, 0.3);
  font-size: 14px;
  color: var(--amber);
  font-weight: 600;
}
.wrapping-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  animation: breathe-slow 3s ease-in-out infinite;
}

/* Wrap-idle UI uses the existing .modal-backdrop / .modal-content pattern (#98). */

/* ── Session Ended Bar ── */
.session-ended {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--elevated-bg);
  border-bottom: 1px solid #333;
  font-size: 14px;
  color: var(--text-muted);
}
.session-ended .countdown {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

/* ── Command Bar ── */
.command-bar {
  flex-shrink: 0;
  background: var(--card-bg);
  border-bottom: 1px solid var(--elevated-bg);
  padding: 8px 10px;
}
.command-input-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.command-input {
  flex: 1;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-family: monospace;
  font-size: 14px;
  autocomplete: off;
}
.command-input:focus {
  outline: none;
  border-color: var(--primary);
}
.command-input::placeholder { color: var(--text-muted); }
.command-send {
  min-height: 44px;
  min-width: 60px;
  padding: 8px 14px;
  background: var(--primary-dark);
  border: none;
  border-radius: var(--radius-btn);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.command-send:active { background: var(--primary); }
.command-send:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Command Pills ── */
.command-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.command-pills::-webkit-scrollbar { display: none; }
.command-pill {
  flex-shrink: 0;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--elevated-bg);
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 12px;
  font-family: monospace;
  font-weight: 500;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.command-pill:active {
  background: var(--primary-dark);
  border-color: var(--primary);
  color: #fff;
}
.command-pill.history {
  border-style: dashed;
}

/* ── Terminal Viewport ── */
.terminal-viewport {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
}
.terminal-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg);
  touch-action: auto;
}

/* ── Peek Drawer ── */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 290;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.peek-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--card-bg);
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-modal) var(--radius-modal) 0 0;
  max-height: 70vh;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  flex-direction: column;
}
.peek-drawer.open { transform: translateY(0); }
.drawer-handle {
  width: 40px;
  height: 4px;
  background: var(--elevated-bg);
  border-radius: 2px;
  margin: 12px auto 8px;
  /* 44px touch target via padding on parent or pseudo-element */
}
.peek-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 8px;
  flex-shrink: 0;
}
.peek-title {
  font-size: 16px;
  font-weight: 600;
}
.peek-actions {
  display: flex;
  gap: 4px;
}
.peek-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg);
  border-radius: var(--radius-btn);
  margin: 0 12px 12px;
  padding: 12px;
  min-height: 100px;
  max-height: calc(70vh - 100px);
}
.peek-jump {
  font-size: 14px;
  min-width: 28px;
}
.peek-search {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 16px 8px;
  flex-shrink: 0;
}
.peek-search-input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-btn);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: monospace;
  outline: none;
  min-width: 120px;
}
.peek-search-input:focus {
  border-color: var(--accent);
}
.peek-search-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 50px;
  text-align: center;
}
.peek-search-nav {
  font-size: 12px;
  min-width: 24px;
  padding: 2px 4px;
}
.peek-search-match {
  background: rgba(255, 200, 0, 0.4);
  border-radius: 2px;
}
.peek-search-match-active {
  background: rgba(255, 140, 0, 0.7);
  border-radius: 2px;
}

/* ── Modal Styles (shared with landing) ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-modal);
  width: 90%;
  max-width: 380px;
  padding: 20px;
  transform: scale(0.95);
  transition: transform 0.2s;
}
.modal-backdrop.open .modal-content { transform: scale(1); }
.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
}
.modal-text {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.modal-actions .btn { min-width: 80px; }

.settings-content {
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
}

/* ── Buttons (subset from landing) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-btn);
  background: var(--card-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn:active { background: var(--elevated-bg); }
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn-primary {
  border-color: var(--primary);
  color: var(--primary);
}
.btn-primary:active {
  background: var(--primary-dark);
  color: #fff;
}
.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:active {
  background: var(--danger-dark);
  color: #fff;
}
.btn-small {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 12px;
}

/* ── Form Elements ── */
.form-group {
  margin-bottom: 14px;
}
.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}
.form-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23777' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-select:focus {
  outline: none;
  border-color: var(--primary);
}
.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
}
.password-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-size: 14px;
  font-family: monospace;
}
.password-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Toggle Switch ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}
.toggle-label {
  font-size: 14px;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--elevated-bg);
  border-radius: 26px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary-dark); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }
.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.settings-info {
  font-size: 14px;
  color: var(--text-muted);
  padding: 8px 0;
}

/* ── Select Button Active ── */
.banner-btn.select-active {
  background: var(--primary-dark);
  border-color: var(--primary);
  color: #fff;
}

/* ── Upload Modal ── */
.upload-content {
  max-width: 400px;
}
.upload-file-input {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-size: 14px;
}
.upload-preview {
  margin-bottom: 12px;
  text-align: center;
}
.upload-preview-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--elevated-bg);
}
.upload-result {
  background: var(--elevated-bg);
  border-radius: var(--radius-btn);
  padding: 12px;
  margin-bottom: 12px;
}
.upload-result-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.upload-result-path {
  font-size: 13px;
  color: var(--primary);
  word-break: break-all;
  font-family: 'SF Mono', 'Menlo', monospace;
}
.upload-history {
  margin-bottom: 12px;
}
.upload-history-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.upload-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 12px;
  color: var(--text-muted);
}
.upload-history-item code {
  font-family: 'SF Mono', 'Menlo', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}
.upload-history-size {
  flex-shrink: 0;
  font-size: 11px;
}

/* ── Spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--elevated-bg);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

/* ── Shared Documents (Settings Modal) ── */
.shared-docs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 250px;
  overflow-y: auto;
}
.shared-doc-item {
  background: var(--bg);
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-btn);
  padding: 8px 10px;
}
.shared-doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.shared-doc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shared-doc-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  background: var(--elevated-bg);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.shared-doc-badge.inject {
  background: rgba(139, 195, 74, 0.15);
  color: var(--primary);
}
.shared-doc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
}
.shared-doc-group {
  color: #64B5F6;
  font-weight: 500;
}
.shared-doc-lock {
  color: var(--text-muted);
}
.shared-doc-lock.locked {
  color: var(--amber);
}
.shared-doc-path {
  font-size: 11px;
  font-family: 'SF Mono', 'Menlo', monospace;
  color: var(--text-muted);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Sidecar Process Pills ── */
.sidecar-pills {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-wrap: wrap;
  padding: 0 10px;
}
.sidecar-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--elevated-bg);
  color: var(--text-muted);
  white-space: nowrap;
  cursor: default;
  transition: background 0.2s, box-shadow 0.2s;
}
.sidecar-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}
.sidecar-pill-label {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidecar-pill-time {
  font-family: monospace;
  font-size: 10px;
  color: var(--text-muted);
}

/* Status-specific dot colors */
.sidecar-pill--running .sidecar-pill-dot {
  background: var(--primary);
  animation: breathe 2s ease-in-out infinite;
}
.sidecar-pill--running {
  color: var(--primary);
  background: rgba(139, 195, 74, 0.12);
}
.sidecar-pill--quiet .sidecar-pill-dot {
  background: var(--amber);
}
.sidecar-pill--quiet {
  color: var(--amber);
  background: rgba(255, 167, 38, 0.12);
}
.sidecar-pill--completed .sidecar-pill-dot {
  background: var(--text-muted);
  animation: none;
}
.sidecar-pill--completed {
  opacity: 0.6;
}
.sidecar-pill--failed .sidecar-pill-dot {
  background: var(--danger);
  animation: none;
}
.sidecar-pill--failed {
  color: var(--danger);
  background: rgba(239, 83, 80, 0.12);
}

/* Attention pulse */
.sidecar-pill--attention {
  animation: sidecar-pulse 1.5s ease-in-out infinite;
}
@keyframes sidecar-pulse {
  0%, 100% { box-shadow: 0 0 2px rgba(255, 167, 38, 0.3); }
  50% { box-shadow: 0 0 8px rgba(255, 167, 38, 0.8); }
}

/* Attention badge (count of processes needing attention) */
.sidecar-attention-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--amber);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 0 4px;
}

/* Stale data indicator */
.sidecar-stale-badge {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.6;
  font-style: italic;
}

/* Clickable pills */
.sidecar-pill[data-process-id] {
  cursor: pointer;
}
.sidecar-pill[data-process-id]:active {
  opacity: 0.7;
}

/* Mobile: smaller pills */
@media (max-width: 600px) {
  .sidecar-pill {
    font-size: 10px;
    padding: 2px 6px;
  }
  .sidecar-pill-label {
    max-width: 80px;
  }
}

/* ── Sidecar Detail Panel ── */
.sidecar-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--card-bg);
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-modal) var(--radius-modal) 0 0;
  max-height: 75vh;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  flex-direction: column;
}
.sidecar-panel.open { transform: translateY(0); }

.sidecar-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 8px;
  flex-shrink: 0;
}
.sidecar-panel-title {
  font-size: 16px;
  font-weight: 600;
}
.sidecar-panel-actions {
  display: flex;
  gap: 4px;
}

/* ── Sidecar Detail Content ── */
.sidecar-detail {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
}
.sidecar-detail-empty {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 24px 0;
}

/* Process nav (when multiple processes) */
.sidecar-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.sidecar-nav::-webkit-scrollbar { display: none; }
.sidecar-nav-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--elevated-bg);
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sidecar-nav-btn:active { background: var(--elevated-bg); }
.sidecar-nav-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(139, 195, 74, 0.1);
}
.sidecar-nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

/* Detail fields */
.sidecar-field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13px;
}
.sidecar-field:last-of-type { border-bottom: none; }
.sidecar-field-label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  margin-right: 12px;
}
.sidecar-field-value {
  text-align: right;
  word-break: break-word;
}

/* Status indicator in detail */
.sidecar-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}
.sidecar-status-badge--running {
  background: rgba(139, 195, 74, 0.15);
  color: var(--primary);
}
.sidecar-status-badge--quiet {
  background: rgba(255, 167, 38, 0.15);
  color: var(--amber);
}
.sidecar-status-badge--completed {
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
}
.sidecar-status-badge--failed {
  background: rgba(239, 83, 80, 0.15);
  color: var(--danger);
}
.sidecar-status-badge--terminated {
  background: rgba(239, 83, 80, 0.15);
  color: var(--danger);
}
.sidecar-status-badge--unknown {
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
}

/* Attention flags */
.sidecar-flags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.sidecar-flag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 167, 38, 0.15);
  color: var(--amber);
}
.sidecar-flag--danger {
  background: rgba(239, 83, 80, 0.15);
  color: var(--danger);
}

/* Output snippet */
.sidecar-output {
  margin-top: 12px;
}
.sidecar-output-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.sidecar-output-content {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
  line-height: 1.4;
  color: #ccc;
  white-space: pre-wrap;
  word-break: break-all;
  background: #000;
  border-radius: var(--radius-btn);
  padding: 10px;
  max-height: 200px;
  overflow-y: auto;
}
.sidecar-output-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* ── Wrap Pipeline Drawer (#139 Chunk 10) ── */
/* Reuses .drawer-backdrop / .drawer-handle from the peek drawer. */
.wrap-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--card-bg);
  border: 1px solid var(--elevated-bg);
  border-radius: var(--radius-modal) var(--radius-modal) 0 0;
  max-height: 80vh;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.wrap-drawer.open { transform: translateY(0); }
.wrap-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--elevated-bg);
}
.wrap-drawer-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}
.wrap-drawer-status {
  padding: 12px 16px;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--elevated-bg);
}
.wrap-drawer-status--running { color: var(--text-secondary); }
.wrap-drawer-status--success { color: #22c55e; }
.wrap-drawer-status--blocked { color: #f59e0b; }
.wrap-drawer-status--warning { color: #f59e0b; }
.wrap-drawer-status--error { color: #ef4444; }
.wrap-drawer-status-detail {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-mono, monospace);
}
.wrap-step-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  overflow-y: auto;
  flex: 1;
}
.wrap-step-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--elevated-bg);
  gap: 12px;
}
.wrap-step-row:last-child { border-bottom: none; }
.wrap-step-row--blocker {
  background: rgba(245, 158, 11, 0.08);
}
.wrap-step-row--warning {
  background: rgba(245, 158, 11, 0.04);
}
.wrap-step-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.wrap-step-label {
  font-weight: 500;
  font-size: 0.95rem;
}
.wrap-step-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: var(--font-mono, monospace);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wrap-step-blockers {
  font-size: 0.8rem;
  color: #ef4444;
  margin-top: 4px;
  /* Blocker output is the full failure text (e.g. husky + jest output); wrap
     and preserve newlines so it stays readable instead of clipping (#268). */
  white-space: pre-wrap;
  word-break: break-word;
}
/* "How to fix this" remediation disclosure for a blocked step (#223). */
.wrap-step-remediation {
  margin-top: 6px;
  font-size: 0.8rem;
}
.wrap-step-remediation > summary {
  cursor: pointer;
  color: var(--primary, #3b82f6);
  font-weight: 600;
}
.wrap-step-remediation-body {
  margin: 6px 0 0;
  padding: 8px 10px;
  background: var(--elevated-bg);
  border-radius: 6px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}
/* Status badges carry a `title` tooltip (#222) — hint it's hoverable. */
.wrap-step-status[title] { cursor: help; }
.wrap-step-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.wrap-step-status--pending {
  background: var(--elevated-bg);
  color: var(--text-secondary);
}
.wrap-step-status--running {
  background: #1e3a8a33;
  color: #60a5fa;
}
.wrap-step-status--done {
  background: #16653433;
  color: #4ade80;
}
.wrap-step-status--blocked {
  background: #7c2d1233;
  color: #fb923c;
}
.wrap-step-status--skipped {
  background: var(--elevated-bg);
  color: var(--text-secondary);
}
.wrap-drawer-decision {
  padding: 12px 16px;
  border-top: 1px solid var(--elevated-bg);
  background: var(--elevated-bg);
}
.wrap-decision-label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.wrap-decision-textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 6px 8px;
  background: var(--card-bg);
  border: 1px solid var(--elevated-bg);
  border-radius: 4px;
  color: var(--text-primary);
}
.wrap-decision-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.wrap-decision-prlist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wrap-decision-prrow {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: var(--card-bg);
  border-radius: 4px;
}
.wrap-decision-prtitle {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wrap-decision-prselect {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--elevated-bg);
  border-radius: 4px;
  padding: 4px 8px;
}
.wrap-decision-note {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
}
.wrap-drawer-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--elevated-bg);
}

/* ── Utility ── */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
