/**
 * Claude Terminal — Design System
 * Clean light design with reDim brand colors
 *
 * reDim Primary: #165678 (blue)
 * reDim Accent:  #ff7a00 (orange)
 *
 * @copyright reDim GmbH | @link https://www.redim.de | @contact team@redim.de
 */

:root {
  /* reDim Brand */
  --primary:        #165678;
  --primary-dark:   #024667;
  --primary-light:  #edf5f7;
  --primary-dim:    #16567815;
  --accent:         #c96200;
  --accent-hover:   #b55800;
  --accent-dim:     #c9620015;

  /* Surfaces */
  --bg:             #f2f5f6;
  --bg-white:       #ffffff;
  --surface:        #ffffff;
  --surface-hover:  #f8fafb;
  --border:         #d8e2e8;
  --border-hover:   #a3c0d0;

  /* Text — WCAG AA compliant */
  --text:           #333333;
  --text-muted:     #5f6d73;
  --text-subtle:    #8a9196;

  /* Status — WCAG AA compliant */
  --admin:          #d81f1f;
  --viewer:         #5f6d73;
  --warning:        #b27300;
  --error:          #d81f1f;
  --success:        #5c8a00;

  /* Session Types */
  --claude:         #6d28d9;
  --ssh:            #c96200;

  /* Spacing */
  --space-1:        0.25rem;
  --space-2:        0.5rem;
  --space-3:        0.75rem;
  --space-4:        1rem;
  --space-5:        1.5rem;
  --space-6:        2rem;
  --space-8:        3rem;

  /* Shadows */
  --shadow-sm:      0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg:      0 8px 24px rgba(0,0,0,0.15);

  /* Layout */
  --radius:         6px;
  --radius-lg:      12px;
  --font:           'Inter', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-mono:      'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --transition:     150ms ease;
}

/* ── Dark Mode ── */
[data-theme="dark"] {
  color-scheme: dark;
  --primary:        #5ba8d4;
  --primary-dark:   #8fc5e6;
  --primary-light:  #1a2a35;
  --primary-dim:    #5ba8d420;

  --bg:             #0e1117;
  --bg-white:       #161b22;
  --surface:        #161b22;
  --surface-hover:  #1c2333;
  --border:         #2a3140;
  --border-hover:   #3d4a5c;

  --text:           #e2e8f0;
  --text-muted:     #94a3b8;
  --text-subtle:    #64748b;

  --admin:          #f87171;
  --viewer:         #94a3b8;
  --warning:        #fbbf24;
  --error:          #f87171;
  --success:        #86efac;

  --claude:         #a78bfa;
  --ssh:            #fb923c;

  --accent:         #fb923c;
  --accent-hover:   #f97316;
  --accent-dim:     #fb923c20;
}

[data-theme="dark"] .login-wrap {
  background: linear-gradient(135deg, var(--bg) 0%, var(--primary-light) 100%);
}

[data-theme="dark"] .login-box {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .topbar {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .session-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .modal {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .notification {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .session-type-badge.tmux { background: #5ba8d420; }
[data-theme="dark"] .session-type-badge.claude { background: #a78bfa20; }
[data-theme="dark"] .session-type-badge.ssh { background: #fb923c20; }

[data-theme="dark"] .mode-badge.admin { background: #f8717120; border-color: #f8717130; }
[data-theme="dark"] .mode-badge.viewer { background: #94a3b820; border-color: #94a3b830; }

[data-theme="dark"] .btn-primary:hover { box-shadow: 0 2px 8px rgba(251, 146, 60, 0.3); }
[data-theme="dark"] .btn-danger:hover { background: #ef4444; }

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

/* ── Touch Optimizations ── */
.terminal-toolbar, .terminal-statusbar, .input-bar, .quick-keys {
  -webkit-user-select: none; user-select: none;
}
.terminal-toolbar button, .quick-keys button, .btn-send {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Utility classes (CSP-compliant — no inline styles needed) */
.hidden { display: none !important; }
.mt-05 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 1rem; }
.hint-text { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.text-muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.mono-sm { font-family: var(--font-mono); font-size: 0.8125rem; }
.text-sm { font-size: 0.8125rem; }
.text-truncate { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.text-truncate-lg { max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-padded { padding: 2rem; }
.empty-padded-sm { padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: 0.875rem; }
.access-empty { color: var(--text-muted); font-size: 0.875rem; padding: 0.5rem; }
.flex-center { display: flex; align-items: center; }
.flex-center-gap { display: flex; align-items: center; gap: 0.5rem; }
.flex-center-gap-sm { display: flex; align-items: center; gap: 0.375rem; }
.star-fav { color: var(--warning); }
.mt-15-mb-1 { margin: 1.5rem 0 1rem; }
.btn-auto-width { width: auto; }
.btn-2fa-resend { margin-top: 0.5rem; font-size: 0.85rem; }
.topbar-brand-group { display: flex; align-items: center; gap: 1rem; }
.topbar-home-link { color: inherit; text-decoration: none; }
.btn-group { display: flex; gap: 0.5rem; }
.ai-main { padding: 1.5rem; }
.ai-card-actions { display: flex; flex-direction: column; justify-content: space-between; }
.checkbox-sm { font-size: 0.8125rem; }
.mt-1 { margin-top: 1rem; }
.status-success { color: var(--success); }
.status-error { color: var(--error); }

.kbd-badge {
  font-size: 0.75rem; color: var(--text-subtle); font-family: var(--font-mono);
  padding: 0.125rem 0.375rem; background: var(--bg); border-radius: 3px; border: 1px solid var(--border);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--accent); }

/* ── Login ── */
.login-wrap {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg) 100%);
}

.login-box {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  background: var(--surface);
  box-shadow: 0 4px 24px rgba(22, 86, 120, 0.08);
}

.login-logo {
  display: block;
  height: 36px;
  width: auto;
  margin: 0 auto 1rem;
}

.login-box h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--primary);
}

.login-box p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.login-box .btn-primary { width: 100%; }

.field { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.25rem; }
.field label { font-size: 0.875rem; font-weight: 500; color: var(--text-muted); }

input[type="password"],
input[type="text"],
input[type="email"],
input[type="number"],
select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
input::placeholder { color: var(--text-subtle); }
.input-icon { width: 4rem; text-align: center; font-size: 1.25rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 8px rgba(255, 122, 0, 0.3); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--primary); background: var(--primary-light); }

.btn-sm {
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  font-size: 0.875rem;
}

.btn-danger { background: var(--error); color: var(--bg-white); }
.btn-danger:hover { background: color-mix(in srgb, var(--error) 85%, black); }

.error-msg { font-size: 0.875rem; color: var(--error); margin-top: 0.75rem; min-height: 1.25rem; }

/* ── Dashboard ── */
.dashboard-layout,
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 60px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  background: var(--bg-white);
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topbar-logo {
  height: 22px;
  width: auto;
  vertical-align: middle;
}

.topbar-brand {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.01em;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-sep {
  color: var(--text-subtle);
  font-weight: 300;
}

.topbar-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.topbar-health-link { position: relative; }

.health-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--error);
  color: var(--bg-white);
  font-size: 0.625rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
  pointer-events: none;
}

.dashboard-main {
  padding: 2rem 2.5rem;
  width: 100%;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.dashboard-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dashboard-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-select {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-family: var(--font);
}

.filter-btn {
  padding: 0.375rem 0.75rem;
  min-height: 44px;
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--border-hover); color: var(--primary); }
.filter-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.session-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.session-card.active { border-left-color: var(--primary); }
.session-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 6px 20px rgba(22, 86, 120, 0.10);
  transform: translateY(-2px);
}

.session-card.type-claude {
  border-left-color: var(--claude);
  background: linear-gradient(135deg, var(--surface) 95%, color-mix(in srgb, var(--claude) 3%, transparent) 100%);
}
.session-card.type-ssh {
  border-left-color: var(--ssh);
  background: linear-gradient(135deg, var(--surface) 95%, color-mix(in srgb, var(--ssh) 3%, transparent) 100%);
}

.session-card.last-visited {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.session-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.875rem;
}

.session-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.session-type-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.session-type-badge.tmux { background: var(--primary-dim); color: var(--primary); }
.session-type-badge.claude { background: #6d28d915; color: var(--claude); }
.session-type-badge.ssh { background: var(--accent-dim); color: var(--ssh); }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-subtle);
}
.status-dot.active {
  background: var(--success);
  box-shadow: 0 0 8px rgba(128, 172, 9, 0.5);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.session-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.session-actions {
  display: flex;
  gap: 0.5rem;
}

.session-actions .btn-primary { width: auto; }

.empty-state,
.templates-empty,
.empty-padded-sm {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.empty-state {
  padding: 5rem 2rem;
  font-size: 1rem;
}

.empty-state code {
  display: block;
  margin-top: 0.75rem;
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
}

/* ── Terminal ── */
/* ── Terminal Layout — Clean Premium ── */
.terminal-layout {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  padding: 0;
  gap: 0;
}

.terminal-toolbar {
  height: 52px;
  min-height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  background: var(--bg-white);
  transition: background var(--transition), border-color var(--transition);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.toolbar-left { display: flex; align-items: center; gap: 1rem; flex: 1; }
.toolbar-right { display: flex; align-items: center; gap: 0.5rem; }

.toolbar-session {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

.mode-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.2rem 0.625rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: background var(--transition), color var(--transition);
}
.mode-badge.admin {
  background: var(--admin);
  color: #fff;
  border: none;
  animation: badgePulse 3s ease-in-out infinite;
}
.mode-badge.viewer {
  background: var(--viewer);
  color: #fff;
  border: none;
}
@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

.terminal-container {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0.25rem var(--space-3);
  background: #0d1117;
  position: relative;
  transition: padding var(--transition);
}
/* xterm.js must fill the container */
.terminal-container .xterm {
  width: 100%;
  height: 100%;
}

/* Terminal bg must match xterm theme background */
.terminal-container { background: #1a1d23; }
[data-theme="dark"] .terminal-container { background: #0d1117; }

/* xterm.js v6 scrollbar — uses VS Code scrollbar, themed via Terminal options */
/* Hide the native viewport scrollbar (v6 renders its own) */
.xterm-viewport { scrollbar-width: none; }
.xterm-viewport::-webkit-scrollbar { display: none; }
/* Slim down the VS Code scrollbar to 8px and round the thumb */
.xterm .xterm-scrollable-element > .scrollbar > .slider { border-radius: 4px; }
/* Remove the inset shadow — doesn't fit our dark theme */
.xterm .xterm-scrollable-element > .shadow { display: none !important; }

/* Scroll-to-Bottom FAB */
.scroll-to-bottom-fab {
  position: absolute;
  bottom: 12px;
  right: 16px;
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: opacity 0.2s, transform 0.2s;
  opacity: 0.85;
}
.scroll-to-bottom-fab:hover { opacity: 1; transform: scale(1.1); }
.scroll-to-bottom-fab:active { transform: scale(0.95); }
.scroll-to-bottom-fab.hidden { display: none; }
.scroll-to-bottom-fab .fab-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.scroll-to-bottom-fab .fab-count.hidden { display: none; }

/* Scroll Position Indicator */
.scroll-position-indicator {
  position: absolute;
  top: 0;
  right: 2px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 10;
}
.scroll-position-indicator.visible { opacity: 0.5; }

@media (max-width: 640px) {
  .scroll-to-bottom-fab { width: 44px; height: 44px; bottom: 8px; right: 8px; }
}

.terminal-statusbar {
  height: 36px;
  min-height: 36px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1.5rem;
  background: var(--bg-white);
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition);
}

.statusbar-item {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: color 300ms ease;
}

.statusbar-item.connected {
  color: var(--success);
  animation: statusFadeIn 400ms ease;
}
.statusbar-item.disconnected {
  color: var(--error);
  animation: statusFadeIn 400ms ease;
}
@keyframes statusFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.statusbar-mono { font-family: var(--font-mono); font-size: 0.75rem; }
.scroll-lock { color: var(--warning); }
.ai-dismiss { margin-left: auto; }

/* ── Notification Banner ── */
.notification {
  position: fixed;
  top: max(68px, env(safe-area-inset-top, 68px));
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: var(--surface);
  border: 1px solid var(--warning);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  z-index: 100;
  min-width: 0;
  max-width: calc(100vw - 2rem);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
.notification.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.notification-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--warning);
  margin-bottom: 0.5rem;
}
.notification-body {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.notification-countdown {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.notification-actions { display: flex; gap: 0.5rem; }

/* ── SSH Dialog ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 70, 103, 0.25);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 440px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(22, 86, 120, 0.12);
  animation: modalIn 200ms ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.25rem;
}
.modal .field { margin-bottom: 1rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* ── Theme Toggle ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover {
  color: var(--primary);
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

/* Login page toggle positioned top-right */
.login-theme-toggle {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
}

/* ── Focus Styles (WCAG 2.4.7) ── */
.btn:focus-visible,
.filter-btn:focus-visible,
select:focus-visible,
.sound-btn:focus-visible,
.font-btn:focus-visible,
.qk-btn:focus-visible,
.btn-send:focus-visible,
.theme-toggle:focus-visible,
.login-tab:focus-visible,
.scroll-bottom-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Smart Tooltips (JS-driven, viewport-aware) ── */
.tooltip-popup {
  position: fixed;
  top: -9999px;
  left: -9999px;
  padding: 0.25rem 0.5rem;
  background: var(--text);
  color: var(--bg-white);
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.3;
  border-radius: 4px;
  white-space: nowrap;
  max-width: 250px;
  overflow-wrap: break-word;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease;
  z-index: 9999;
}
.tooltip-popup.tooltip-visible {
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .tooltip-popup { transition: none; }
}
@media (hover: none) {
  .tooltip-popup { display: none !important; }
}

/* ── Skip Link ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  padding: 0.625rem 1.25rem;
  background: var(--primary);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius);
  z-index: 100;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 0.75rem;
  color: #fff;
}

/* ── Command Palette ── */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.35);
  display: flex;
  justify-content: center;
  padding-top: 15vh;
  backdrop-filter: blur(2px);
}
.cmd-palette-overlay.hidden { display: none; }

.cmd-palette {
  width: min(560px, 92vw);
  max-height: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cmdPaletteIn 0.15s ease-out;
  align-self: flex-start;
}
@keyframes cmdPaletteIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cmd-palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.cmd-palette-icon {
  color: var(--accent);
  font-size: 0.8rem;
  flex-shrink: 0;
}
.cmd-palette-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  min-width: 0;
}
.cmd-palette-input:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 2px; }
.cmd-palette-input::placeholder { color: var(--text-muted); }

.cmd-palette-list {
  list-style: none;
  margin: 0;
  padding: 0.375rem 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.cmd-palette-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
  transition: background var(--transition);
}
.cmd-palette-item:hover,
.cmd-palette-item.selected {
  background: var(--primary-dim);
}
.cmd-palette-item.selected {
  background: var(--primary-light);
}
.cmd-palette-item b { color: var(--accent); font-weight: 600; }

.cmd-palette-item-icon {
  width: 1.5rem;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.cmd-palette-item-label { flex: 1; min-width: 0; }
.cmd-palette-shortcut {
  flex-shrink: 0;
  margin-left: auto;
}
.cmd-palette-shortcut kbd {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  font-size: 0.75rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}
.cmd-palette-category {
  padding: 0.375rem 1rem 0.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.cmd-palette-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.cmd-palette-more {
  padding: 0.375rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.cmd-palette-footer {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
}
.cmd-palette-footer kbd {
  display: inline-block;
  padding: 0.0625rem 0.25rem;
  font-size: 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  margin-right: 0.25rem;
}

/* ── Dashboard Presence Avatars ── */
.presence-stack {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.presence-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  border: 2px solid var(--surface);
  margin-left: -0.35rem;
  cursor: default;
  transition: transform 0.15s ease;
}

.presence-avatar:first-child {
  margin-left: 0;
}

.presence-avatar:hover {
  transform: scale(1.15);
  z-index: 2;
}

.presence-admin {
  background: var(--primary);
}

.presence-viewer {
  background: #6b7280;
}

.presence-more {
  background: var(--border);
  color: var(--text-secondary);
  font-size: 0.6rem;
}

.presence-empty {
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

/* Terminal statusbar presence (small) */
.presence-avatars-sm {
  display: inline-flex;
  align-items: center;
  margin-left: 0.25rem;
  gap: 0;
}

.presence-avatar-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  font-size: 0.55rem;
  font-weight: 600;
  color: #fff;
  border: 1px solid var(--bg);
  margin-left: -0.2rem;
  cursor: default;
}

.presence-avatar-sm:first-child {
  margin-left: 0;
}

.presence-avatar-sm.presence-admin {
  background: var(--primary);
}

.presence-avatar-sm.presence-viewer {
  background: #6b7280;
}

.presence-avatar-sm.presence-overflow {
  background: var(--surface); color: var(--text-muted);
  font-size: 0.5rem; border-color: var(--border);
  cursor: help;
}

/* ── Kick Popover ── */
.kick-popover {
  position: fixed;
  z-index: 10000;
  background: var(--bg-secondary, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
  min-width: 140px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.kick-popover-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text, #e2e8f0);
  margin-bottom: 0.15rem;
}

.kick-popover-role {
  font-size: 0.75rem;
  color: var(--text-secondary, #94a3b8);
  margin-bottom: 0.5rem;
}

.kick-popover-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #dc2626;
  color: #fff;
  border: none;
  border-radius: 0.35rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s;
}

.kick-popover-btn:hover {
  background: #b91c1c;
}

.presence-avatar[data-user-id],
.presence-avatar-sm[data-user-id] {
  cursor: pointer;
}

/* ── Word Action Popup (Double-Click) ── */
.word-action-popup {
  position: fixed;
  z-index: 10000;
  background: var(--bg-secondary, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 0.5rem;
  padding: 0.3rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  display: flex;
  gap: 0.15rem;
}

.word-action-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  color: var(--text, #e2e8f0);
  border: none;
  border-radius: 0.35rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.word-action-btn:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.08));
}

.word-action-btn i {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ── AI Consent Dialog ── */
.ai-consent-text {
  margin: 0.5rem 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.ai-consent-warning {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin: 0.75rem 0;
}

.ai-consent-warning strong {
  color: #fbbf24;
  display: block;
  margin-bottom: 0.25rem;
}

.ai-consent-warning ul {
  margin: 0.25rem 0 0.25rem 1.25rem;
  padding: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.ai-consent-warning ul li {
  margin: 0.15rem 0;
}

.ai-consent-warning small {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.ai-consent-info {
  margin: 0.5rem 0;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.ai-consent-remember {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.ai-consent-remember input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .sessions-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-main {
    padding: 1.25rem;
  }
  .topbar {
    padding: 0 1rem;
  }
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .dashboard-controls {
    flex-wrap: wrap;
  }
  .login-box {
    width: 100%;
    margin: 0 1rem;
  }

  /* ── Terminal Mobile ── */
  .terminal-layout {
    height: 100dvh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .terminal-toolbar {
    flex-wrap: nowrap;
    height: 44px;
    min-height: 44px;
    padding: 0 0.5rem;
    gap: 0.25rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  }
  .toolbar-left {
    gap: 0.375rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }
  .toolbar-left .breadcrumb { font-size: 0.75rem; }
  .toolbar-left .breadcrumb a { display: none; }
  .toolbar-left .breadcrumb-sep { display: none; }
  .toolbar-left .mode-badge { font-size: 0.5625rem; padding: 0.125rem 0.375rem; }
  .toolbar-right {
    flex-wrap: nowrap;
    gap: 0.125rem;
    width: auto;
    padding-top: 0;
    border-top: none;
  }
  /* Hide text buttons, show only icon buttons on mobile */
  .toolbar-right .btn-sm { font-size: 0; padding: 0; min-width: 44px; min-height: 44px; }
  .toolbar-right .btn-sm::before { font-size: 1rem; }
  #shareBtn { display: none; }
  #requestControlBtn { font-size: 0.6875rem; min-width: auto; padding: 0.25rem 0.5rem; }
  .toolbar-right .font-controls { display: none; }
  .toolbar-right > .font-btn { min-width: 40px; min-height: 40px; }
  .toolbar-right > .sound-btn { min-width: 40px; min-height: 40px; font-size: 1.125rem; }
  /* AI cost badge compact */
  .ai-cost-badge { font-size: 0.625rem; padding: 0.125rem 0.375rem; }

  .terminal-container {
    padding: 0.25rem 0.5rem;
  }

  /* Statusbar compact on mobile */
  .terminal-statusbar {
    height: 28px;
    min-height: 28px;
    padding: 0 0.5rem;
    gap: 0.75rem;
    font-size: 0.6875rem;
  }
  .statusbar-item { font-size: 0.6875rem; }
  .statusbar-mono { font-size: 0.625rem; }
  #uptimeDisplay { display: none; }
  .scroll-lock span { font-size: 0.625rem; }

  .notification { min-width: auto; width: calc(100vw - 2rem); }
  .session-actions {
    flex-wrap: wrap;
  }

  /* Toast mobile */
  .toast { bottom: 1rem; font-size: 0.8125rem; max-width: calc(100vw - 2rem); }

  /* Modal mobile */
  .modal {
    width: calc(100vw - 2rem);
    max-width: 440px;
    padding: 1.25rem;
  }
  .modal h3 { font-size: 1rem; margin-bottom: 1rem; }
  .modal-actions { margin-top: 1rem; }

  /* Login box mobile */
  .login-box { padding: 1.5rem; margin: 0 1rem; }
  .login-wrap { padding: 1rem; }
}

/* ── Extra Small Screens (≤480px) ── */
@media (max-width: 480px) {
  .dashboard-main { padding: 0.75rem; }
  .dashboard-header { margin-bottom: 1rem; }
  .dashboard-header h2 { font-size: 1rem; }

  /* Input bar safe area */
  .input-bar { padding-bottom: env(safe-area-inset-bottom); }

  /* Modal full-width */
  .modal { padding: 1rem; border-radius: var(--radius); }

  /* Toolbar font buttons hidden */
  .toolbar-right > .font-btn,
  .toolbar-right > .sound-btn { min-width: 44px; min-height: 44px; }
}

/* ── Reconnect Ring ── */
.reconnect-ring-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  vertical-align: middle;
}
.reconnect-ring-text {
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--warning);
}
.reconnect-attempt {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

/* ── Latency Sparkline ── */
.latency-sparkline {
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.25rem;
  opacity: 0.8;
}
.latency.good .latency-sparkline { opacity: 0.6; }
.latency.poor .latency-sparkline { opacity: 1; }

/* ── Snippet Sort Select ── */
.snippet-sort-select {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  margin-left: 0.5rem;
  cursor: pointer;
  transition: border-color var(--transition);
}
.snippet-sort-select:hover,
.snippet-sort-select:focus {
  border-color: var(--primary);
  outline: none;
}
.snippet-sort-select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.snippet-use-count {
  font-size: 0.6875rem;
  color: var(--text-subtle);
  font-weight: 400;
}

/* ── Session Tags ── */
.session-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  border: 1px solid transparent;
}
.session-tag .tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 0.625rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition);
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}
.session-tag .tag-remove:hover { opacity: 1; }
.session-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}
.tag-add-input {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.6875rem;
  padding: 0.125rem 0.5rem;
  width: 80px;
  outline: none;
  transition: border-color var(--transition);
}
.tag-add-input:focus {
  border-color: var(--primary);
  color: var(--text);
}
.tag-add-input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tag-add-input::placeholder { color: var(--text-subtle); }

/* ── Command History Panel ── */
.history-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  max-width: 90vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 200ms ease;
  display: flex;
  flex-direction: column;
}
.history-overlay.active { transform: translateX(0); }
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.history-header h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}
.history-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.history-tab {
  flex: 1;
  padding: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.history-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.history-search {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}
.history-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  color: var(--text);
  outline: none;
}
.history-search input:focus { border-color: var(--primary); }
.history-search input:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
}
.history-item:hover { background: var(--surface-hover); }
.history-item-cmd {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item-meta {
  font-size: 0.6875rem;
  color: var(--text-subtle);
  white-space: nowrap;
}
.history-item-count {
  font-size: 0.625rem;
  color: var(--text-subtle);
  background: var(--primary-dim);
  padding: 0.0625rem 0.375rem;
  border-radius: 999px;
}
.history-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.history-footer {
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ── Output Heatmap (Minimap) ── */
.output-heatmap {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  z-index: 5;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity var(--transition);
  border-left: 1px solid var(--border);
}
.output-heatmap:hover { opacity: 1; }

/* ── Danger Zone ── */
.danger-zone {
  animation: danger-pulse 0.6s ease;
  border-color: var(--error) !important;
  box-shadow: 0 0 0 2px rgba(216, 31, 31, 0.25);
}
.danger-zone textarea,
.danger-zone input {
  color: var(--error);
}
@keyframes danger-pulse {
  0% { box-shadow: 0 0 0 0 rgba(216, 31, 31, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(216, 31, 31, 0.2); }
  100% { box-shadow: 0 0 0 2px rgba(216, 31, 31, 0.25); }
}

/* ── Idle Session Dimming ── */
.session-idle {
  opacity: 0.5;
}
.session-idle:hover {
  opacity: 0.85;
  transition: opacity 200ms ease;
}

/* ── Scroll Sync Toggle ── */
.scroll-sync-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
}
.scroll-sync-btn.active { color: var(--primary); }
.scroll-sync-btn i { font-size: 0.75rem; }

/* ── Upload Modal ── */
.upload-modal {
  display: none; position: fixed; inset: 0; z-index: 250;
  justify-content: center; align-items: center;
}
.upload-modal.active { display: flex; }
.upload-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}
.upload-modal-dialog {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  width: 420px; max-width: 90vw;
  box-shadow: var(--shadow-lg);
  animation: modalIn 200ms ease;
}
.upload-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.upload-modal-header h3 {
  font-size: 1rem; font-weight: 700; color: var(--success);
  display: flex; align-items: center; gap: 0.5rem; margin: 0;
}
.upload-modal-info {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.625rem 0.875rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 1rem;
}
.upload-modal-filename {
  font-family: var(--font-mono); font-size: 0.8125rem;
  font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 260px;
}
.upload-modal-size {
  font-size: 0.75rem; color: var(--text-muted);
  white-space: nowrap; margin-left: 0.75rem;
}
.upload-modal-preview {
  margin-bottom: 1rem; text-align: center;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem;
  overflow: hidden;
}
.upload-modal-img {
  max-width: 100%; max-height: 200px;
  object-fit: contain; border-radius: 4px;
}
.upload-modal-transfer-status {
  padding: 0.5rem 0.75rem; margin-bottom: 0.75rem;
  border-radius: 0.375rem; font-size: 0.8125rem;
}
.upload-modal-transfer-status.transfer-ok {
  background: rgba(0, 212, 170, 0.1); color: var(--accent);
}
.upload-modal-transfer-status.transfer-fail {
  background: rgba(255, 85, 85, 0.1); color: #f55;
}
.upload-modal-actions {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.upload-modal-actions .btn {
  justify-content: flex-start; font-size: 0.8125rem;
  padding: 0.5rem 0.75rem; min-height: 40px;
}
.upload-modal-actions .btn:disabled {
  opacity: 0.35; cursor: not-allowed;
}

@media (max-width: 640px) {
  .upload-modal-dialog { padding: 1rem; width: calc(100vw - 2rem); }
  .upload-modal-actions { grid-template-columns: 1fr; }
  .upload-modal-img { max-height: 150px; }
}

/* ══════════════════════════════════════
   Idle Actions Dialog
   ══════════════════════════════════════ */

.ia-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: none; opacity: 0;
  transition: opacity 0.2s ease;
}
.ia-overlay.visible { opacity: 1; }

.ia-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
}

.ia-dialog {
  position: relative;
  margin: 3vh auto 0;
  width: min(800px, calc(100vw - 2rem));
  max-height: calc(94vh);
  background: var(--card-bg, #1e1e2e);
  border: 1px solid var(--border, #333);
  border-radius: 12px;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  overflow: hidden;
}

.ia-dialog-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border, #333);
}

.ia-title {
  margin: 0; font-size: 1.1rem; font-weight: 600;
  color: var(--text, #e0e0e0);
}

.ia-close {
  background: none; border: none; color: var(--text-muted, #888);
  font-size: 1.5rem; cursor: pointer; padding: 0 0.25rem;
  line-height: 1;
}
.ia-close:hover { color: var(--text, #e0e0e0); }

.ia-dialog-controls {
  padding: 0.75rem 1.25rem;
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
  border-bottom: 1px solid var(--border, #333);
}

.ia-preset-row {
  display: flex; align-items: center; gap: 0.5rem;
}
.ia-preset-row label {
  color: var(--text-muted, #888); font-size: 0.85rem;
}

.ia-preset-select, .ia-cmd-suggestions, .ia-wh-format {
  background: var(--bg, #121212); color: var(--text, #e0e0e0);
  border: 1px solid var(--border, #333); border-radius: 6px;
  padding: 0.3rem 0.5rem; font-size: 0.85rem;
  font-family: inherit;
}

.ia-preset-apply {
  background: var(--accent, #00d4aa); color: #000;
  border: none; border-radius: 6px; padding: 0.3rem 0.75rem;
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.ia-preset-apply:hover { filter: brightness(1.1); }
.ia-preset-apply:disabled { opacity: 0.4; cursor: not-allowed; }

.ia-global-toggle, .ia-webhook-toggle {
  display: flex; align-items: center;
}

.ia-toggle {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--text, #e0e0e0); font-size: 0.85rem; cursor: pointer;
}
.ia-toggle input[type="checkbox"] {
  accent-color: var(--accent, #00d4aa);
  width: 16px; height: 16px;
}

.ia-columns {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  padding: 1rem 1.25rem;
  overflow-y: auto; flex: 1;
}

.ia-col {
  display: flex; flex-direction: column; gap: 0.5rem;
}

.ia-col-title {
  margin: 0; font-size: 0.95rem; font-weight: 600;
  color: var(--accent, #00d4aa);
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--accent, #00d4aa);
}
.ia-col-waiting .ia-col-title { color: #f0a040; border-color: #f0a040; }
.ia-col-idle .ia-col-title { color: #888; border-color: #555; }

.ia-col-body {
  display: flex; flex-direction: column; gap: 0.5rem;
}

.ia-card {
  background: var(--bg, #121212);
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  transition: opacity 0.2s;
}
.ia-card.ia-disabled {
  opacity: 0.4; pointer-events: none;
}

.ia-card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
}

.ia-delay {
  display: flex; align-items: center; gap: 0.3rem;
  font-size: 0.8rem; color: var(--text-muted, #888);
}

.ia-delay-input {
  width: 50px; text-align: center;
  background: var(--card-bg, #1e1e2e); color: var(--text, #e0e0e0);
  border: 1px solid var(--border, #333); border-radius: 4px;
  padding: 0.15rem 0.25rem; font-size: 0.8rem;
  font-family: inherit;
}

.ia-card-preview {
  margin-top: 0.35rem;
  padding-left: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted, #888);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ia-card-preview .ia-preview-value {
  color: var(--accent, #00d4aa);
}

.ia-card-extra {
  margin-top: 0.5rem;
  display: flex; flex-direction: column; gap: 0.3rem;
}

.ia-mini-label {
  font-size: 0.75rem; color: var(--text-muted, #888);
}

.ia-cmd-input, .ia-wh-url {
  background: var(--card-bg, #1e1e2e); color: var(--text, #e0e0e0);
  border: 1px solid var(--border, #333); border-radius: 4px;
  padding: 0.3rem 0.5rem; font-size: 0.8rem;
  font-family: 'JetBrains Mono', monospace;
  width: 100%; box-sizing: border-box;
}

.ia-sound-volume {
  width: 100%; accent-color: var(--accent, #00d4aa);
}

.ia-dialog-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border, #333);
}

.ia-footer-right {
  display: flex; gap: 0.5rem;
}

.ia-reset {
  background: none; border: 1px solid #c0392b; color: #c0392b;
  border-radius: 6px; padding: 0.4rem 0.75rem;
  font-size: 0.8rem; cursor: pointer;
}
.ia-reset:hover { background: rgba(192,57,43,0.15); }

.ia-cancel {
  background: none; border: 1px solid var(--border, #333); color: var(--text-muted, #888);
  border-radius: 6px; padding: 0.4rem 0.75rem;
  font-size: 0.85rem; cursor: pointer;
}
.ia-cancel:hover { color: var(--text, #e0e0e0); border-color: var(--text-muted, #888); }

.ia-save {
  background: var(--accent, #00d4aa); color: #000;
  border: none; border-radius: 6px; padding: 0.4rem 1rem;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.ia-save:hover { filter: brightness(1.1); }

.ia-toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
  background: var(--accent, #00d4aa); color: #000;
  padding: 0.5rem 1.25rem; border-radius: 8px;
  font-size: 0.85rem; font-weight: 600;
  opacity: 0; transition: opacity 0.3s; z-index: 10001;
  pointer-events: none;
}
.ia-toast.visible { opacity: 1; }

@media (max-width: 640px) {
  .ia-dialog { width: calc(100vw - 1rem); margin-top: 1vh; }
  .ia-columns { grid-template-columns: 1fr; }
  .ia-dialog-controls { flex-direction: column; align-items: flex-start; }
  .ia-dialog-footer { flex-direction: column; gap: 0.5rem; }
  .ia-footer-right { width: 100%; justify-content: flex-end; }
}

/* ══════════════════════════════════════
   Babysitter (Autopilot)
   ══════════════════════════════════════ */

.input-babysitter-btn {
  background: none; border: none; color: var(--text-subtle); cursor: pointer;
  padding: 6px 8px; font-size: 1rem; transition: color 0.15s;
}
.input-babysitter-btn:hover, .input-babysitter-btn.active { color: var(--accent); }

.babysitter-panel {
  position: fixed; right: 12px; bottom: 60px; width: 340px; max-height: 500px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4); z-index: 1000;
  display: flex; flex-direction: column; overflow: hidden;
}

.babysitter-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.85rem;
}
.babysitter-header .btn { margin-left: auto; }
.automation-mode-select {
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px; font-size: 0.75rem; cursor: pointer;
  outline: none; font-family: inherit;
}
.automation-mode-select:focus { border-color: var(--accent); }
.automation-mode-select option { background: var(--bg-card); color: var(--text); }

.babysitter-status-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #666;
  cursor: pointer; transition: background 0.2s; flex-shrink: 0;
}
.babysitter-status-dot:hover { transform: scale(1.2); }

.babysitter-status-label {
  font-size: 0.75rem; color: var(--text-subtle); margin-left: auto; margin-right: 4px;
}

.babysitter-sound-btn {
  background: transparent; border: none; color: var(--text-subtle); cursor: pointer;
  font-size: 0.75rem; padding: 2px 4px; border-radius: 3px; transition: color 0.15s;
}
.babysitter-sound-btn:hover { color: var(--accent); }
.babysitter-sound-btn.muted { opacity: 0.4; }

.babysitter-controls {
  padding: 8px 12px; display: flex; flex-direction: column; gap: 4px;
  border-bottom: 1px solid var(--border);
}

.babysitter-toggle {
  display: flex; align-items: center; gap: 8px; font-size: 0.78rem;
  color: var(--text); cursor: pointer;
}
.babysitter-toggle input { accent-color: var(--accent); }

.babysitter-queue {
  padding: 8px 12px; flex: 1; overflow-y: auto; min-height: 0;
}

.babysitter-queue-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.78rem; font-weight: 600; margin-bottom: 6px;
}

.babysitter-queue-count {
  background: var(--accent); color: var(--bg); border-radius: 10px;
  padding: 0 6px; font-size: 0.7rem; min-width: 18px; text-align: center;
}

.babysitter-queue-list { display: flex; flex-direction: column; gap: 3px; }

.babysitter-queue-empty {
  color: var(--text-subtle); font-size: 0.75rem; text-align: center; padding: 8px 0;
}

.babysitter-queue-item {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px;
  font-size: 0.75rem; border-radius: 4px; background: var(--bg);
}
.babysitter-queue-item.status-done { opacity: 0.5; }
.babysitter-queue-item.status-done i { color: var(--accent); }
.babysitter-queue-item.status-running i { color: var(--accent); }
.babysitter-queue-item.status-failed i { color: var(--error); }
.babysitter-queue-item.status-blocked i { color: var(--warning); }
.babysitter-queue-item.status-skipped i { color: var(--text-subtle); opacity: 0.6; }

.babysitter-task-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.babysitter-task-error { color: var(--error); font-size: 0.75rem; cursor: help; }

.babysitter-remove-btn { font-size: 0.85rem; padding: 0 4px; opacity: 0.5; }
.babysitter-remove-btn:hover { opacity: 1; color: var(--error); }

.babysitter-task-input {
  width: 100%; margin: 6px 0; padding: 6px 8px; font-size: 0.75rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); resize: vertical; font-family: inherit;
}

.babysitter-queue-actions { display: flex; gap: 6px; }

.babysitter-log {
  max-height: 120px; overflow-y: auto; padding: 6px 12px;
  border-top: 1px solid var(--border); font-size: 0.7rem; font-family: var(--mono);
}

.babysitter-log-entry { padding: 1px 0; color: var(--text-subtle); }
.babysitter-log-entry.log-warn { color: var(--warning); }
.babysitter-log-entry.log-error { color: var(--error); }
.babysitter-log-time { color: var(--text-subtle); opacity: 0.6; }

.babysitter-status-dot.pulse {
  animation: babysitter-pulse 1.5s ease-in-out infinite;
}
@keyframes babysitter-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 173, 78, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(240, 173, 78, 0); }
}

.babysitter-blocker {
  padding: 0.5rem; margin: 0.5rem 0;
  background: rgba(240, 173, 78, 0.08); border: 1px solid rgba(240, 173, 78, 0.25);
  border-radius: var(--radius); font-size: 0.8rem;
}
.babysitter-blocker-reason {
  color: var(--warning); margin-bottom: 0.375rem;
  font-family: var(--font-mono); font-size: 0.75rem;
  max-height: 3rem; overflow-y: auto; word-break: break-word;
}
.babysitter-blocker-actions { display: flex; gap: 0.375rem; }
.babysitter-blocker-actions input { flex: 1; font-size: 0.8rem; }

@media (max-width: 640px) {
  .babysitter-panel {
    right: max(4px, env(safe-area-inset-right));
    left: max(4px, env(safe-area-inset-left));
    width: auto; bottom: 50px; max-height: 60vh;
  }
}

/* Badge base */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.125rem 0.5rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}

/* Badge variants (autopilot + general) */
.badge-muted   { background: var(--bg); color: var(--text-muted); }
.badge-accent  { background: var(--accent-dim, rgba(201,98,0,0.1)); color: var(--accent); }
.badge-warning { background: var(--warning-dim, rgba(178,115,0,0.1)); color: var(--warning); }
.badge-success { background: var(--success-dim, rgba(92,138,0,0.1)); color: var(--success); }
.badge-danger  { background: var(--error-dim, rgba(216,31,31,0.1)); color: var(--error); }
.badge-info    { background: var(--primary-dim, rgba(22,86,120,0.1)); color: var(--primary); }

/* Legacy status badges */
.badge.status-idle { background: var(--bg); color: var(--text-muted); }
.badge.status-running { background: #00d4aa20; color: #00a888; }
.badge.status-warning { background: var(--warning-dim); color: var(--warning); }
.badge.status-success { background: var(--success-dim); color: var(--success); }
.badge.status-error { background: var(--error-dim); color: var(--error); }

[data-theme="dark"] .badge.status-running { background: #00d4aa30; color: #00d4aa; }

/* AI Suggest History */
.ai-sug-history-group {
  border-bottom: 1px solid var(--border); padding: var(--space-2) 0;
}
.ai-sug-history-group:last-child { border-bottom: none; }
.ai-sug-time {
  display: block; font-size: 0.75rem; color: var(--text-subtle);
  margin-bottom: var(--space-1);
}

/* #17: AI Confidence Indicator */
.ai-conf-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: var(--space-1);
  vertical-align: middle;
}
.ai-conf-high { background: var(--success); }
.ai-conf-mid { background: var(--warning); }
.ai-conf-low { background: var(--error); }

/* #8: Why tooltip */
.ai-sug-why {
  display: inline-block; width: 16px; height: 16px;
  border-radius: 50%; background: var(--primary-dim);
  color: var(--primary); font-size: 0.7rem; font-weight: 700;
  text-align: center; line-height: 16px; cursor: help;
  margin-left: var(--space-1); vertical-align: middle;
}
.ai-sug-why:hover { background: var(--primary); color: var(--bg-white); }

/* #12: AI Cost Badge */
.ai-cost-badge {
  font-size: 0.7rem; padding: 2px 6px;
  border-radius: var(--radius); background: var(--primary-dim);
  color: var(--primary); font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

/* #18: Idle hint animation */
.input-idle-hint {
  animation: idlePulse 2s ease-in-out infinite;
}
@keyframes idlePulse {
  0%, 100% { border-color: var(--border); }
  50% { border-color: var(--accent); }
}

/* #3: Command Chain */
.ai-sug-chain {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) 0; border-top: 1px solid var(--border);
  margin-top: var(--space-2);
}
.ai-chain-btn { white-space: nowrap; }
.ai-chain-btn i { margin-right: 2px; }

/* #1: AI Chat Panel */
.ai-chat-panel {
  position: fixed; right: var(--space-4); bottom: 80px; z-index: 900;
  width: 360px; max-height: 480px;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px); box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  overflow: hidden; animation: slideUp 0.2s ease;
}
.ai-chat-panel.hidden { display: none; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.ai-chat-header {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.85rem;
}
.ai-chat-header .btn-ghost { margin-left: auto; }
.ai-chat-messages {
  flex: 1; overflow-y: auto; padding: var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-2);
  min-height: 200px; max-height: 340px;
}
.ai-chat-msg {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius); font-size: 0.85rem;
  line-height: 1.5; max-width: 90%; word-break: break-word;
}
.ai-chat-msg code {
  background: var(--primary-dim); padding: 1px 4px;
  border-radius: 3px; font-size: 0.8rem;
}
.ai-chat-user {
  background: var(--primary); color: var(--bg-white);
  align-self: flex-end; border-bottom-right-radius: 4px;
}
.ai-chat-assistant {
  background: var(--bg); color: var(--text);
  align-self: flex-start; border-bottom-left-radius: 4px;
}
.ai-chat-error {
  background: #fde8e8; color: var(--error);
  align-self: flex-start; font-size: 0.8rem;
}
.ai-chat-input-row {
  display: flex; gap: var(--space-1); padding: var(--space-2);
  border-top: 1px solid var(--border);
}
.ai-chat-input-row input {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-2); font-size: 0.85rem;
  background: var(--surface); color: var(--text);
}
.ai-chat-input-row input:focus { border-color: var(--primary); outline: none; }
.ai-chat-input-row input:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
@media (max-width: 480px) {
  .ai-chat-panel {
    right: env(safe-area-inset-right, 0);
    left: env(safe-area-inset-left, 0);
    bottom: 60px; width: auto; max-height: 60vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .ai-chat-input-row input { min-height: 44px; font-size: 1rem; }
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════
   Broadcast Bar
   ══════════════════════════════════════ */

.broadcast-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--surface, #1e293b);
  border-bottom: 1px solid var(--border, #334155);
  animation: slideDown 0.2s ease;
}
.broadcast-bar.hidden { display: none; }

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.broadcast-bar-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  white-space: nowrap;
}

.broadcast-count {
  background: var(--accent, #00d4aa);
  color: var(--bg, #0f172a);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 1.25rem;
  text-align: center;
}

.broadcast-bar-input {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.broadcast-bar-input input {
  flex: 1;
  background: var(--bg, #0f172a);
  border: 1px solid var(--border, #334155);
  border-radius: var(--radius, 0.375rem);
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  color: var(--text, #e2e8f0);
  outline: none;
  transition: border-color 0.15s;
}
.broadcast-bar-input input:focus { border-color: var(--accent, #00d4aa); }
.broadcast-bar-input input:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.broadcast-bar-input input::placeholder { color: var(--text-subtle, #475569); }

.broadcast-bar .btn-sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
}
.broadcast-bar .btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }

.broadcast-close-btn {
  background: none;
  border: none;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  transition: color 0.15s;
}
.broadcast-close-btn:hover { color: var(--text, #e2e8f0); }

.broadcast-cb {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #00d4aa);
  cursor: pointer;
  margin-right: 0.375rem;
  flex-shrink: 0;
}

#broadcastBtn.active {
  color: var(--accent, #00d4aa);
  background: rgba(0, 212, 170, 0.1);
}

@media (max-width: 640px) {
  .broadcast-bar { flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem; }
  .broadcast-bar-input { min-width: 0; }
}

/* ══════════════════════════════════════
   Color Picker Popup
   ══════════════════════════════════════ */

.color-picker-popup {
  position: fixed;
  z-index: 10001;
  background: var(--surface, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 0.5rem;
  padding: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
  margin-bottom: 0.375rem;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.3); }

.color-clear-btn {
  display: block;
  width: 100%;
  background: none;
  border: 1px solid var(--border, #334155);
  border-radius: 0.25rem;
  color: var(--text-muted, #94a3b8);
  font-size: 0.7rem;
  padding: 0.25rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.color-clear-btn:hover {
  color: var(--text, #e2e8f0);
  border-color: var(--text-muted, #94a3b8);
}

.badge-sm { font-size: 0.65rem; padding: 0.05rem 0.35rem; }
.btn-xs { font-size: 0.7rem; padding: 0.15rem 0.35rem; }

/* ══════════════════════════════════════
   Autopilot System
   ══════════════════════════════════════ */
.autopilot-projects { display: flex; flex-direction: column; gap: 0.75rem; }
.autopilot-project-card {
  background: var(--card-bg, rgba(255,255,255,0.03));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 8px;
  padding: 1rem;
}
.project-header { margin-bottom: 0.75rem; }
.project-info { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.project-info strong { font-size: 1rem; }
.project-meta { display: flex; gap: 1rem; font-size: 0.75rem; }
.project-meta code { background: var(--bg-dark, rgba(0,0,0,0.2)); padding: 0.1rem 0.4rem; border-radius: 4px; }
.project-controls { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.project-details { margin-top: 1rem; border-top: 1px solid var(--border, rgba(255,255,255,0.08)); padding-top: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.project-details h4 { margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.autopilot-form.card { background: var(--card-bg, rgba(255,255,255,0.03)); border: 1px solid var(--primary, #6366f1); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.autopilot-form h4 { margin: 0 0 0.75rem; }
.autopilot-form .field { margin-bottom: 0.5rem; }
.autopilot-form .field label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.2rem; }
.autopilot-form .field input { width: 100%; }
.autopilot-form .form-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

.tasks-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.tasks-header h4 { margin: 0; }

.checkpoint-list { display: flex; flex-direction: column; gap: 0.35rem; }
.checkpoint-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.35rem 0; font-size: 0.8rem; }

.autopilot-log { max-height: 200px; overflow-y: auto; font-size: 0.75rem; font-family: var(--font-mono, monospace); }
.log-entry { display: flex; gap: 0.5rem; padding: 0.15rem 0; border-bottom: 1px solid var(--border, rgba(255,255,255,0.04)); }
.log-time { color: var(--text-muted); min-width: 5.5rem; }
.log-msg { color: var(--text); }
.log-entry.log-done .log-msg { color: var(--success, #22c55e); }
.log-entry.log-blocked .log-msg, .log-entry.log-timeout .log-msg { color: var(--warning, #eab308); }
.log-entry.log-loop .log-msg { color: var(--error, #ef4444); }

.autopilot-section { margin-top: 2rem; }
.section-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.25rem; }
.section-header h3 { margin: 0; }
.section-hint { font-size: 0.75rem; color: var(--text-muted); margin: 0 0 0.75rem; }

.autopilot-dna-list { display: flex; flex-direction: column; gap: 0.25rem; }
.dna-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem; border-radius: 4px; }
.dna-item:hover { background: var(--card-bg, rgba(255,255,255,0.03)); }
.dna-disabled { opacity: 0.5; }
.dna-toggle { display: flex; align-items: center; gap: 0.5rem; flex: 1; cursor: pointer; font-size: 0.8rem; }
.dna-text { flex: 1; }

.btn-danger-outline { background: transparent; color: var(--error, #ef4444); border: 1px solid var(--error, #ef4444); }
.btn-danger-outline:hover { background: var(--error, #ef4444); color: #fff; }
.btn-warning { background: var(--warning, #eab308); color: #000; }
.btn-warning:hover { opacity: 0.85; }
.badge-success { background: rgba(34,197,94,0.15); color: var(--success, #22c55e); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--error, #ef4444); }

/* Changes list */
.changes-list { display: flex; flex-direction: column; gap: 0.2rem; max-height: 200px; overflow-y: auto; }
.change-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; padding: 0.2rem 0; }
.change-item code { flex: 1; font-size: 0.75rem; color: var(--accent); }

/* Ideas list */
.ideas-list { display: flex; flex-direction: column; gap: 0.5rem; }
.idea-item { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.5rem; border-radius: 4px; background: var(--card-bg, rgba(255,255,255,0.03)); }
.idea-text { flex: 1; font-size: 0.85rem; }
.idea-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }

/* Respond inline form */
.respond-row td { padding: 0 !important; }
.respond-form { padding: 0.5rem; background: var(--card-bg, rgba(255,255,255,0.03)); border-radius: 4px; margin: 0.25rem 0; }
.respond-input { width: 100%; resize: vertical; font-family: inherit; font-size: 0.85rem; margin-bottom: 0.35rem; }

/* Task & DNA inline forms */
.task-form, .dna-form { padding: 0.75rem; margin: 0.5rem 0; border: 1px solid var(--border, rgba(255,255,255,0.1)); border-radius: 6px; }
.task-form h5, .dna-form h5 { margin: 0 0 0.5rem; font-size: 0.9rem; }
.task-form-tabs { display: flex; gap: 0.25rem; margin-bottom: 0.5rem; }
.task-tab-btn.active { font-weight: 600; }
.task-form textarea, .dna-form textarea { width: 100%; resize: vertical; font-family: inherit; font-size: 0.85rem; }
.task-form select, .dna-form select { width: 100%; padding: 0.35rem 0.5rem; font-size: 0.85rem; background: var(--bg, #0d1117); color: var(--text, #e6edf3); border: 1px solid var(--border, rgba(255,255,255,0.1)); border-radius: 4px; }

/* Task actions */
.task-actions { display: flex; gap: 0.15rem; flex-wrap: wrap; align-items: center; }
.btn-icon { padding: 0.1rem 0.35rem; font-size: 0.75rem; line-height: 1; min-width: 24px; text-align: center; }

/* Progress bar */
.progress-bar-wrap { width: 100%; height: 4px; background: var(--border, rgba(255,255,255,0.1)); border-radius: 2px; margin-top: 0.4rem; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent, #00d4aa); border-radius: 2px; transition: width 0.4s ease; }
.project-current-task { margin-top: 0.2rem; }

/* Context section */
.context-section { margin-top: 0.75rem; }
.context-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.25rem; }
.context-header h4 { margin: 0; }
.context-preview { font-size: 0.8rem; padding: 0.5rem; background: var(--card-bg, rgba(255,255,255,0.03)); border-radius: 4px; white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto; margin: 0.25rem 0 0; border: 1px solid var(--border, rgba(255,255,255,0.1)); }
.context-form { padding: 0.75rem; margin: 0.5rem 0; border: 1px solid var(--border, rgba(255,255,255,0.1)); border-radius: 6px; }
.context-form h5 { margin: 0 0 0.5rem; font-size: 0.9rem; }
.context-form textarea { width: 100%; resize: vertical; font-family: var(--font-mono, 'JetBrains Mono', monospace); font-size: 0.8rem; }

/* Mobile: autopilot cards */
@media (max-width: 640px) {
  .autopilot-project-card { padding: 0.75rem; }
  .project-header { flex-direction: column; gap: 0.25rem; }
  .project-controls { flex-wrap: wrap; gap: 0.25rem; }
  .project-controls .btn { font-size: 0.7rem; padding: 0.25rem 0.5rem; }
  .project-meta { flex-direction: column; gap: 0.15rem; }
  .checkpoint-item { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
  .idea-item { flex-direction: column; }
  .idea-actions { align-self: flex-end; }
}
