/* IronClaw Web Gateway */

:root {
  --bg: #09090b;
  --bg-secondary: #0f0f11;
  --bg-tertiary: #1a1a1e;
  --border: rgba(255, 255, 255, 0.08);
  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --accent: #34d399;
  --accent-hover: #2fc48d;
  --accent-soft: rgba(52, 211, 153, 0.15);
  --success: #34d399;
  --warning: #F5A623;
  --danger: #E64C4C;
  --code-bg: #111113;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --font-mono: 'IBM Plex Mono', 'SF Mono', 'Fira Code', Consolas, monospace;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  --bg-modal: #1a1a1a;
  --border-modal: #333;
  --border-soft: #2a2a2a;
  --text-tertiary: #e0e0e0;
  --text-muted: #888;
  --text-dimmed: #666;
  --text-on-accent: #09090b;
  --accent-brand: #00D894;
  --accent-brand-hover: #00be82;
  --warning-bg: #1e1400;
  --warning-border: #3a2a00;
  --warning-text: #facc15;
  --tab-bg: rgba(9, 9, 11, 0.75);
  --popover-bg: rgba(15, 15, 17, 0.9);
  --badge-sandbox-bg: rgba(136, 132, 216, 0.15);
  --badge-sandbox-text: #b4b0e8;
  --hover-surface: rgba(255, 255, 255, 0.03);
  --focus-ring: rgba(52, 211, 153, 0.1);
  --accent-subtle: rgba(52, 211, 153, 0.15);
  --accent-border-subtle: rgba(52, 211, 153, 0.3);
  --danger-subtle: rgba(230, 76, 76, 0.15);
  --danger-border-subtle: rgba(230, 76, 76, 0.3);
  --warning-subtle: rgba(245, 166, 35, 0.15);
  --border-hover: rgba(255, 255, 255, 0.15);
  --user-msg-bg: rgba(52, 211, 153, 0.08);
  --user-msg-border: rgba(52, 211, 153, 0.2);
  --danger-error-bg: rgba(230, 76, 76, 0.1);
  --accent-tee-bg: rgba(52, 211, 153, 0.1);
  --accent-tee-border: rgba(52, 211, 153, 0.25);
  --accent-tee-hover: rgba(52, 211, 153, 0.18);
  --text-on-danger: #fff;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-toast: 0 4px 12px rgba(0, 0, 0, 0.4);
  --danger-error-border: rgba(230, 76, 76, 0.2);
  --note-bg: rgba(255, 255, 255, 0.04);
  --overlay-heavy: rgba(0, 0, 0, 0.6);
  --highlight-bg: rgba(52, 211, 153, 0.3);
  --hover-subtle: rgba(255, 255, 255, 0.06);
  --transition-fast: 150ms ease;
  --transition-base: 0.2s ease;

  /* Shadows (3-tier) */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.15);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.2);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5), 0 4px 12px rgba(0,0,0,0.3);

  /* Accent glow */
  --glow-accent: 0 0 20px rgba(52,211,153,0.1);

  /* Glass morphism */
  --glass-bg: rgba(9,9,11,0.72);
  --glass-blur: blur(16px) saturate(180%);

  /* Spring easing */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring-gentle: cubic-bezier(0.22, 1.2, 0.36, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  /* Surface highlight */
  --surface-highlight: inset 0 1px 0 rgba(255,255,255,0.05);

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  /* Typography scale */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 36px;

  /* Timing */
  --transition-slow: 300ms ease;
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-instant: 100ms;
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 400ms;

  /* Legacy aliases (mapped to new theme tokens) */
  --accent-soft: var(--accent-subtle);
  --accent-dim: var(--accent-subtle);
  --bg-hover: var(--hover-surface);
  --danger-soft: var(--danger-subtle);
  --warning-soft: var(--warning-subtle);
}

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

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  animation: focusExpand 200ms ease;
}

@keyframes focusExpand {
  from { outline-offset: 0px; outline-color: transparent; }
  to { outline-offset: 2px; outline-color: var(--accent); }
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Auth Screen */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
}

.auth-card-login {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  box-shadow: var(--shadow-card);
}

.auth-brand {
  text-align: center;
}

.auth-brand h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.auth-tagline {
  font-size: var(--text-base);
  color: var(--text-secondary);
}

#auth-screen .auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

#auth-screen .auth-form label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

#auth-screen input {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-base);
  width: 100%;
}

#auth-screen input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-border-subtle);
}

#auth-screen button {
  padding: 10px 16px;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 600;
  margin-top: 4px;
  transition: background 0.2s, transform 150ms var(--ease-spring);
}

#auth-screen button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

#auth-screen button:active {
  transform: scale(0.97);
}

#auth-error {
  color: var(--danger);
  font-size: var(--text-sm);
  min-height: 20px;
  text-align: center;
}

.auth-hint {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}

/* Main App */
#app {
  display: none;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  opacity: 0;
  transition: opacity 0.3s ease 0.15s;
}

#app.visible {
  opacity: 1;
}

/* Tab Bar */
.tab-bar {
  display: flex;
  background: var(--tab-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  will-change: backdrop-filter;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  gap: 0;
  flex-shrink: 0;
  position: relative;
  z-index: 200;
  box-shadow: var(--surface-highlight);
}

.tab-bar button:not(.status-logs-btn):not(.restart-btn) {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 500;
  transition: color 0.2s, border-color 0.2s;
}

.tab-bar button:not(.status-logs-btn):not(.restart-btn):hover {
  color: var(--text);
}

.tab-bar button:not(.status-logs-btn):not(.restart-btn).active {
  color: var(--accent);
  border-bottom-color: transparent;
  background: var(--accent-subtle);
  border-radius: var(--radius) var(--radius) 0 0;
}

.tab-bar .spacer {
  flex: 1;
}

.tab-bar .status-logs-btn {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-xs);
  align-self: center;
  margin-right: 8px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.tab-bar .status-logs-btn:hover {
  color: var(--text);
  border-color: var(--text-secondary);
}

.tab-bar .status-logs-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-tee-bg);
}

.tab-bar .status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  color: var(--text-secondary);
  position: relative;
  cursor: pointer;
}

.tab-bar .status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  position: relative;
}

.tab-bar .status .dot.disconnected {
  background: var(--danger);
}

/* Tab sliding indicator */
.tab-indicator {
  position: absolute;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  transition: left 300ms var(--ease-spring), width 300ms var(--ease-spring);
  z-index: 1;
  pointer-events: none;
}

/* TEE Shield */
.tee-shield {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--success);
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--accent-tee-bg);
  border: 1px solid var(--accent-tee-border);
  cursor: pointer;
  position: relative;
  margin-right: 8px;
  transition: background 0.2s;
}

.tee-shield:hover {
  background: var(--accent-tee-hover);
}

.tee-shield svg {
  flex-shrink: 0;
}

#tee-shield-label {
  font-weight: 500;
  white-space: nowrap;
}

/* Restart Button */
.tab-bar .restart-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin: 0.375rem;
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  border: 1px solid var(--accent-brand);
  color: var(--accent-brand);
  background-color: transparent;
  cursor: pointer;
  transition: color 150ms, background-color 150ms, border-color 150ms;
}

.tab-bar .restart-btn:hover:not(:disabled) {
  background-color: var(--accent-tee-bg);
}

.tab-bar .restart-btn:disabled {
  border-color: var(--border-modal);
  color: var(--text-dimmed);
  cursor: not-allowed;
}

.tab-bar .restart-btn:disabled:hover {
  background-color: transparent;
}

.tab-bar .restart-btn svg {
  flex-shrink: 0;
  width: 13px;
  height: 13px;
}

.tab-bar .restart-btn svg.spinning {
  animation: spin-icon 1s linear infinite;
}

@keyframes spin-icon {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Restart Loader Overlay */
.restart-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.restart-loader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: -1;
}

.restart-loader-content {
  position: relative;
  z-index: 10000;
  background-color: var(--bg-modal);
  border: 1px solid var(--border-modal);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 28rem;
  margin: 0 1rem;
  overflow: hidden;
  padding: 1.25rem;
}

.restart-spinner {
  display: none;
}

.restart-loader-text {
  padding: 0;
}

.restart-title {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  margin-top: 0;
}

.restart-subtitle {
  display: none;
}

/* Restart Modal (Confirmation) */
.restart-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.restart-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
}

.restart-modal-content {
  position: relative;
  z-index: 10000;
  background-color: var(--bg-modal);
  border: 1px solid var(--border-modal);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 28rem;
  margin: 0 1rem;
  overflow: hidden;
}

.restart-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
}

.restart-modal-header h2 {
  color: var(--text-tertiary);
  font-size: 0.95rem;
  margin: 0;
}

.restart-modal-close {
  color: var(--text-muted);
  padding: 0.25rem;
  border-radius: 0.25rem;
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: color 150ms, background-color 150ms;
  display: flex;
  align-items: center;
  justify-content: center;
}

.restart-modal-close:hover {
  color: var(--text);
  background-color: var(--border-soft);
}

.restart-modal-body {
  padding: 1.25rem;
}

.restart-modal-description {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0;
}

.restart-modal-warning {
  margin-top: 1rem;
  background-color: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

.restart-modal-warning p {
  color: var(--warning-text);
  font-size: 0.8rem;
  margin: 0;
}

.restart-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-soft);
}

.restart-modal-btn {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  transition: background-color 150ms;
}

.restart-modal-btn.cancel {
  color: var(--text);
  background-color: transparent;
}

.restart-modal-btn.cancel:hover {
  background-color: var(--border-soft);
}

.restart-modal-btn.confirm {
  background-color: var(--accent-brand);
  color: var(--text-on-accent);
}

.restart-modal-btn.confirm:hover {
  background-color: var(--accent-brand-hover);
}

/* Progress Bar for Restart */
.restart-progress-bar {
  width: 100%;
  height: 0.375rem;
  background-color: var(--border-soft);
  border-radius: 9999px;
  overflow: hidden;
}

.restart-progress-fill {
  height: 100%;
  border-radius: 9999px;
  background-color: var(--accent-brand);
  width: 40%;
  animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
  0% {
    margin-left: 0;
    width: 40%;
  }
  50% {
    margin-left: 60%;
    width: 40%;
  }
  100% {
    margin-left: 0;
    width: 40%;
  }
}

.restart-modal-info {
  color: var(--text-dimmed);
  font-size: 0.8rem;
  margin-top: 1.25rem;
  margin-bottom: 0;
}

.restart-modal-info a {
  color: var(--accent-brand);
  text-decoration: none;
}

.restart-modal-info a:hover {
  text-decoration: underline;
}

.tee-popover {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--popover-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  min-width: 340px;
  max-width: 420px;
  z-index: 500;
  box-shadow: var(--shadow);
}

.tee-popover.visible {
  display: block;
}

.tee-popover-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tee-popover-title svg {
  color: var(--success);
}

.tee-field {
  margin-bottom: 10px;
}

.tee-field:last-child {
  margin-bottom: 0;
}

.tee-field-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.tee-field-value {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text);
  word-break: break-all;
  background: var(--bg);
  padding: 4px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.tee-popover-actions {
  margin-top: 12px;
  display: flex;
  gap: var(--space-2);
}

.tee-btn-copy {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-xs);
  transition: color 0.2s, border-color 0.2s;
}

.tee-btn-copy:hover {
  color: var(--text);
  border-color: var(--text-secondary);
}

.tee-popover-loading {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px 0;
}

/* Tab Panels */
.tab-panel {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}

.tab-panel.active {
  display: flex;
}

#app.visible .tab-panel.active {
  animation: tabFadeIn 200ms ease forwards;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Chat Tab */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.message {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: var(--text-base);
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
  animation: slideUp 350ms var(--ease-spring);
}

@keyframes slideUp {
  0% { opacity: 0; transform: translateY(12px) scale(0.98); }
  70% { opacity: 1; transform: translateY(-2px) scale(1.005); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.message[data-streaming="true"]::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 16px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: cursorPulse 1.2s ease-in-out infinite;
}

@keyframes cursorPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.message.user {
  align-self: flex-end;
  background: var(--accent-soft);
  color: var(--accent);
  border-bottom-right-radius: 2px;
  white-space: pre-wrap;
}

.message.user::after {
  content: '';
  position: absolute;
  right: -6px;
  bottom: 10px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-left-color: var(--accent-soft);
  border-right: 0;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-bottom-left-radius: 2px;
  padding: 14px 18px;
  font-size: 15px;
  line-height: 1.6;
}

.message.has-copy {
  padding-right: 52px;
}

.message-content {
  min-width: 0;
}

.message-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-radius: 8px;
  font-size: var(--text-xs);
  padding: 2px 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.message.user:hover .message-copy-btn,
.message.assistant:hover .message-copy-btn,
.message.user:focus-within .message-copy-btn,
.message.assistant:focus-within .message-copy-btn {
  opacity: 1;
  pointer-events: auto;
}

.message-copy-btn:focus-visible {
  opacity: 1;
  pointer-events: auto;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.message-copy-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

@media (hover: none) {
  .message.user .message-copy-btn,
  .message.assistant .message-copy-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

.message-timestamp {
  position: absolute;
  top: 8px;
  right: 52px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 150ms ease;
  pointer-events: none;
}

.message:hover .message-timestamp {
  opacity: 0.7;
}

.message.user .message-timestamp {
  right: auto;
  left: -80px;
}

.time-separator {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 16px 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.time-separator::before,
.time-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.message.system {
  align-self: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 6px 12px;
}

.message code {
  background: var(--code-bg);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: var(--text-sm);
}

.message pre {
  background: var(--code-bg);
  padding: 8px 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 6px 0;
}

.message pre code {
  background: none;
  padding: 0;
}

.message p { margin: 0 0 10px 0; }
.message p:last-child { margin-bottom: 0; }
.message ul, .message ol { margin: 4px 0; padding-left: 20px; }
.message li { margin: 4px 0; }
.message blockquote {
  margin: 6px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
}
.message h1, .message h2, .message h3,
.message h4, .message h5, .message h6 {
  margin: 8px 0 4px 0;
  line-height: 1.3;
}
.message h1 { font-size: 1.3em; }
.message h2 { font-size: 1.2em; }
.message h3 { font-size: 1.1em; }
.message a { color: var(--accent); }
.message hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.message table { border-collapse: collapse; margin: 6px 0; }
.message th, .message td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  font-size: var(--text-sm);
}
.message th { background: var(--bg-tertiary); }

/* Status bar */

.scroll-load-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.scroll-load-spinner .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* === Tool Activity Cards === */

.activity-group {
  align-self: flex-start;
  max-width: 80%;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--border);
  margin: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.activity-group.collapsed {
  border-left-color: transparent;
  padding-left: 0;
}

/* Thinking indicator */

.activity-thinking {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 8px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.activity-thinking-dots {
  display: flex;
  gap: 3px;
}

.activity-thinking-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: thinkingPulse 1.4s ease-in-out infinite;
}

.activity-thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.activity-thinking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

.activity-thinking-text {
  font-style: italic;
}

/* Tool card */

.activity-tool-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.activity-tool-card[data-status="running"] {
  border-color: var(--accent-border-subtle);
}

.activity-tool-card[data-status="fail"] {
  border-color: var(--danger-border-subtle);
}

.activity-tool-card[data-status="fail"] .activity-tool-name {
  color: var(--danger);
}

.activity-tool-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.activity-tool-header:hover {
  background: var(--bg-tertiary);
}

.activity-tool-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.activity-tool-icon .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.activity-icon-success {
  color: var(--success);
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1;
}

.activity-icon-fail {
  color: var(--danger);
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1;
}

.activity-tool-name {
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.activity-tool-duration {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
}

.activity-tool-chevron {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.15s ease;
  width: 12px;
  text-align: center;
}

.activity-tool-chevron.expanded {
  transform: rotate(90deg);
}

.activity-tool-body {
  border-top: 1px solid var(--border);
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms var(--ease-out-expo);
}

.activity-tool-body.expanded {
  max-height: 300px;
}

.activity-tool-output {
  margin: 0;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
  background: var(--code-bg);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Collapsed summary */

.activity-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: background 0.15s;
}

.activity-summary:hover {
  background: var(--bg-tertiary);
}

.activity-summary-chevron {
  font-size: 10px;
  transition: transform 0.15s ease;
  width: 12px;
  text-align: center;
}

.activity-summary-chevron.expanded {
  transform: rotate(90deg);
}

.activity-summary-text {
  font-weight: 500;
}

.activity-summary-duration {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  opacity: 0.7;
}

.activity-cards-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
  margin-top: 2px;
}

@media (max-width: 768px) {
  .activity-group {
    max-width: 95%;
  }
}

/* Approval card (inline in chat) */
.approval-card {
  align-self: flex-start;
  max-width: 80%;
  background: var(--bg-secondary);
  border: 1px solid var(--warning);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: border-color 0.2s;
}

.approval-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--warning);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.approval-tool-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
}

.approval-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.4;
}

.approval-params-toggle {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  text-align: left;
}

.approval-params-toggle:hover {
  text-decoration: underline;
}

.approval-params {
  background: var(--code-bg);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-mono);
  line-height: 1.4;
  overflow-x: auto;
  color: var(--text-secondary);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.approval-card .approval-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.approval-card .approval-actions button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-sm);
  background: var(--bg-secondary);
  color: var(--text);
}

.approval-card .approval-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.approval-card .approval-actions button.approve {
  background: var(--success);
  border-color: var(--success);
  color: var(--text-on-accent);
  font-weight: 600;
}

.approval-card .approval-actions button.always {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
  font-weight: 600;
}

.approval-card .approval-actions button.deny {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--text-on-danger);
}

.approval-resolved {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  font-style: italic;
}

/* Tool calls summary (persisted between user/assistant messages) */
.tool-calls-summary {
  background: var(--bg-secondary);
  border-left: 3px solid var(--warning);
  padding: 6px 12px;
  margin: 4px 0;
  font-size: 0.85em;
  border-radius: 4px;
}

.tool-calls-header {
  color: var(--text-secondary);
  font-weight: 500;
  user-select: none;
}

.tool-calls-header::before {
  content: '\25B6';
  display: inline-block;
  margin-right: 6px;
  font-size: 0.7em;
  transition: transform 0.15s;
}

.tool-calls-header.expanded::before {
  transform: rotate(90deg);
}

.tool-calls-list {
  margin-top: 6px;
  display: none;
}

.tool-calls-list.expanded {
  display: block;
}

.tool-call-item {
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}

.tool-call-item:last-child {
  border-bottom: none;
}

.tool-call-name {
  font-weight: 500;
  color: var(--text-primary);
}

.tool-call-preview {
  color: var(--text-secondary);
  font-size: 0.9em;
  max-height: 60px;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

.tool-call-error-text {
  color: var(--danger);
  font-size: 0.9em;
}

.tool-error .tool-call-name {
  color: var(--danger);
}

/* Auth prompt */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.auth-card {
  align-self: flex-start;
  max-width: 80%;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: border-color 0.2s;
}

.auth-overlay .auth-card {
  width: 460px;
  max-width: min(460px, 90vw);
  margin: 0;
  align-self: auto;
  background: var(--bg);
  border-color: rgba(52, 211, 153, 0.35);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.auth-card .auth-header {
  font-weight: 600;
  color: var(--accent);
  font-size: var(--text-sm);
}

.auth-card .auth-instructions {
  font-size: var(--text-sm);
  color: var(--text);
  line-height: 1.4;
}

.auth-card .auth-links {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.auth-card .auth-links a {
  color: var(--accent);
  font-size: var(--text-sm);
  text-decoration: underline;
}

.auth-card .auth-token-input {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.auth-card .auth-token-input input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
}

.auth-card .auth-token-input input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.auth-card .auth-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.auth-card .auth-actions button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-sm);
  background: var(--bg-secondary);
  color: var(--text);
}

.auth-card .auth-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-card .auth-actions button.auth-submit {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
  font-weight: 600;
}

.auth-card .auth-actions button.auth-cancel {
  background: var(--bg-secondary);
  border-color: var(--border);
}

.auth-card .auth-actions button.auth-oauth {
  background: var(--success);
  border-color: var(--success);
  color: var(--text-on-accent);
  font-weight: 600;
}

.auth-card .auth-error {
  color: var(--danger);
  font-size: 12px;
}

/* Chat input */
.chat-input {
  display: flex;
  flex-wrap: wrap;
  margin: 0 16px 12px;
  padding: 12px 16px;
  gap: var(--space-2);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  flex-shrink: 0;
  min-height: 56px;
  box-shadow: var(--shadow-md);
}

.chat-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
}

.chat-input-wrapper textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-base);
  font-family: inherit;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  transition: height 100ms ease;
}

.ghost-text {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-secondary);
  opacity: 0.5;
  pointer-events: none;
  white-space: pre-wrap;
  overflow: hidden;
  display: none;
  z-index: 1;
}

/* Hide native placeholder when ghost text is visible */
.chat-input-wrapper.has-ghost textarea::placeholder {
  color: transparent;
}

.chat-input-wrapper textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.chat-input-wrapper textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.suggestion-chips {
  display: none;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 8px 16px;
  border-top: 1px solid var(--border);
}

.suggestion-chip {
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: var(--accent);
  color: #09090b;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.chat-input button {
  padding: 8px 20px;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 600;
  align-self: flex-end;
  transition: background 0.2s, transform 150ms var(--ease-spring);
}

.chat-input button:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.chat-input button:active {
  transform: scale(0.97);
}

.chat-input button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

#send-btn.active {
  box-shadow: var(--glow-accent);
}

/* Keyboard accessibility focus rings */
.chat-input-wrapper textarea:focus-visible,
.chat-input button:focus-visible,
.tab-bar button:focus-visible,
.tree-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Memory Tab */
.memory-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.memory-sidebar {
  width: 280px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}

.memory-sidebar .search-box {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.memory-sidebar input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-sm);
}

.memory-sidebar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.memory-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* Tree view */
.tree-row {
  display: flex;
  align-items: center;
  padding: 3px 8px;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  gap: 4px;
  min-height: 26px;
}

.tree-row:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.expand-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 8px;
  color: var(--text-secondary);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  cursor: pointer;
}

.expand-arrow.expanded {
  transform: rotate(90deg);
}

.expand-arrow-spacer {
  display: inline-block;
  width: 16px;
  flex-shrink: 0;
}

.tree-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-label.dir {
  color: var(--text);
  font-weight: 500;
}

.tree-label.file {
  color: var(--text-secondary);
}

.tree-row:hover .tree-label.file {
  color: var(--accent);
}

.tree-children {
  /* Rendered inline, indentation handled by padding-left on tree-row */
}

/* Legacy tree-item (search results) */
.tree-item {
  padding: 4px 12px 4px 16px;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tree-item:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.tree-item.active {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.tree-item .icon {
  font-size: 12px;
  width: 16px;
  text-align: center;
}

.memory-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.memory-breadcrumb {
  padding: 8px 16px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.memory-breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.memory-breadcrumb a:hover {
  text-decoration: underline;
}

.memory-viewer {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  font-size: var(--text-base);
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: var(--font-mono);
}

.memory-viewer .empty {
  color: var(--text-secondary);
  font-style: italic;
}

.search-results {
  padding: 8px 0;
}

.search-result {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.search-result:hover {
  background: var(--bg-tertiary);
}

.search-result .path {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 4px;
}

.search-result .snippet {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Jobs Tab */
.jobs-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.jobs-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: 20px;
}

.summary-card {
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: border-color 0.2s, transform 0.2s;
}

.summary-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.summary-card .count {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
}

.summary-card .label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-card.active .count { color: var(--accent); }
.summary-card.completed .count { color: var(--success); }
.summary-card.failed .count { color: var(--danger); }
.summary-card.stuck .count { color: var(--warning); }

.jobs-table {
  width: 100%;
  border-collapse: collapse;
}

.jobs-table th,
.jobs-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}

.jobs-table th {
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 0.5px;
}

.jobs-table tr:hover td {
  background: var(--hover-surface);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: var(--text-xs);
  font-weight: 500;
}

.badge.pending { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge.in_progress { background: var(--accent-subtle); color: var(--accent); }
.badge.completed { background: var(--accent-subtle); color: var(--success); }
.badge.failed { background: var(--danger-subtle); color: var(--danger); }
.badge.stuck { background: var(--warning-subtle); color: var(--warning); }
.badge.cancelled { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge.interrupted { background: var(--warning-subtle); color: var(--warning); }
.badge.source-sandbox { background: var(--badge-sandbox-bg); color: var(--badge-sandbox-text); }
.badge.source-direct { background: var(--bg-tertiary); color: var(--text-secondary); }

.btn-cancel {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  cursor: pointer;
  font-size: 12px;
}

.btn-cancel:hover {
  background: var(--danger-subtle);
}

.btn-restart {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
}

.btn-restart:hover {
  background: var(--accent-subtle);
}

.btn-browse {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--success);
  border-radius: var(--radius);
  color: var(--success);
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
}

.btn-browse:hover {
  background: var(--accent-subtle);
}

/* Job started card in chat */
.job-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 16px;
  margin: 8px 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-left: 3px solid var(--accent);
  transition: border-color 0.2s, transform 0.2s;
}

.job-card:hover {
  border-color: var(--border-hover);
}

.job-card-icon {
  font-size: var(--text-xl);
}

.job-card-info {
  flex: 1;
}

.job-card-title {
  font-weight: 600;
  font-size: var(--text-base);
}

.job-card-id {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.job-card-view, .job-card-browse {
  padding: 4px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
}

.job-card-view {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.job-card-view:hover {
  background: var(--accent-subtle);
}

.job-card-browse {
  background: none;
  border: 1px solid var(--success);
  color: var(--success);
}

.job-card-browse:hover {
  background: var(--accent-subtle);
}

/* Clickable job rows */
.job-row {
  cursor: pointer;
}

/* Job Detail View */
.job-detail-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: 16px;
}

.job-detail-header h2 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-back {
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.btn-back:hover {
  background: var(--bg-tertiary);
}

.job-detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.job-detail-tabs button {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-sm);
}

.job-detail-tabs button:hover {
  color: var(--text);
}

.job-detail-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.job-detail-content {
  flex: 1;
  overflow-y: auto;
}

/* Metadata grid */
.job-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-bottom: 20px;
}

.meta-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.meta-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.meta-value {
  font-size: var(--text-base);
  color: var(--text);
  word-break: break-all;
}

/* Job description */
.job-description {
  margin-bottom: 20px;
}

.job-description h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.job-description-body {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: var(--text-base);
  line-height: 1.6;
}

/* State transitions timeline */
.job-timeline-section {
  margin-bottom: 20px;
}

.job-timeline-section h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.timeline {
  position: relative;
  padding-left: 20px;
  border-left: 2px solid var(--border);
}

.timeline-entry {
  position: relative;
  padding: 8px 0 8px 16px;
}

.timeline-dot {
  position: absolute;
  left: -27px;
  top: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.timeline-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
}

.timeline-time {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: 8px;
}

.timeline-reason {
  width: 100%;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Action cards */
.action-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  border-left: 3px solid var(--success);
}

.action-card.failure {
  border-left-color: var(--danger);
}

.action-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: var(--text-sm);
}

.action-header:hover {
  background: var(--bg-tertiary);
}

.action-tool {
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
}

.action-seq {
  color: var(--text-secondary);
  font-size: var(--text-xs);
}

.action-duration {
  color: var(--text-secondary);
  font-size: 12px;
}

.action-time {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: auto;
}

.action-toggle {
  color: var(--text-secondary);
  font-size: 10px;
  flex-shrink: 0;
}

.action-detail {
  padding: 0 12px 12px;
}

.action-section {
  margin-top: 8px;
}

.action-section strong {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 4px;
}

.action-json {
  background: var(--code-bg);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-mono);
  line-height: 1.4;
  overflow-x: auto;
  color: var(--text-secondary);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
}

.action-error {
  background: var(--danger-error-bg);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-mono);
  line-height: 1.4;
  color: var(--danger);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Conversation messages */
.conv-message {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: var(--text-base);
  line-height: 1.5;
}

.conv-role {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.conv-body {
  word-wrap: break-word;
}

.conv-system {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}

.conv-system .conv-role { color: var(--text-secondary); }
.conv-system .conv-body { color: var(--text-secondary); font-size: var(--text-sm); }

.conv-user {
  background: var(--user-msg-bg);
  border: 1px solid var(--user-msg-border);
}

.conv-user .conv-role { color: var(--accent); }

.conv-assistant {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.conv-assistant .conv-role { color: var(--success); }

.conv-tool {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.conv-tool .conv-role { color: var(--warning); }
.conv-tool .conv-body { white-space: pre-wrap; word-break: break-all; max-height: 200px; overflow-y: auto; }

.conv-tc-id {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}

.conv-tool-calls {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.conv-tc-entry {
  margin-bottom: 6px;
}

.conv-tc-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
}

.conv-tc-args {
  background: var(--code-bg);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  line-height: 1.4;
  margin: 4px 0 0;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 150px;
  overflow-y: auto;
}

/* Job files browser */
.job-files {
  display: flex;
  height: calc(100vh - 280px);
  height: calc(100dvh - 280px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.job-files-sidebar {
  width: 240px;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  overflow-y: auto;
}

.job-files-tree {
  padding: 8px 0;
}

.job-files-viewer {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
}

.job-files-path {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

.job-files-content {
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
  margin: 0;
}

/* Welcome card */
.welcome-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  text-align: center;
  max-width: 600px;
  margin: auto;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  gap: var(--space-6);
}

.welcome-heading {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.welcome-description {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
}

.welcome-chip {
  padding: 10px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 200ms ease, transform 150ms var(--ease-spring);
  box-shadow: var(--shadow-sm);
}

.welcome-chip:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Routines Tab */
.routines-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.routines-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: 20px;
}

.routines-table {
  width: 100%;
  border-collapse: collapse;
}

.routines-table th,
.routines-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}

.routines-table th {
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 0.5px;
}

.routines-table tr:hover td {
  background: var(--hover-surface);
}

.routine-row {
  cursor: pointer;
}

.routine-detail {
  padding: 16px 0;
}

.badge.enabled { background: var(--accent-subtle); color: var(--success); }
.badge.disabled { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge.failing { background: var(--danger-subtle); color: var(--danger); }

.btn-trigger {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
}

.btn-trigger:hover {
  background: var(--accent-subtle);
}

.btn-toggle {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  color: var(--warning);
  cursor: pointer;
  font-size: 12px;
}

.btn-toggle:hover {
  background: var(--warning-subtle);
}

/* Logs Tab */
.logs-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.logs-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logs-toolbar select,
.logs-toolbar input {
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
}

.logs-toolbar select {
  min-width: 100px;
}

.logs-toolbar input {
  flex: 1;
  max-width: 240px;
}

.logs-toolbar select:focus,
.logs-toolbar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.logs-checkbox {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.logs-toolbar button {
  padding: 5px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}

.logs-toolbar button:hover {
  background: var(--border);
}

.logs-output {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg);
}

.log-entry {
  display: flex;
  gap: var(--space-2);
  padding: 1px 12px;
  white-space: nowrap;
  cursor: pointer;
}

.log-entry:hover {
  background: var(--bg-tertiary);
}

.log-ts {
  color: var(--text-secondary);
  flex-shrink: 0;
  width: 80px;
}

.log-level {
  flex-shrink: 0;
  width: 44px;
  font-weight: 600;
}

.log-target {
  color: var(--text-secondary);
  flex-shrink: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-msg {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-entry.expanded {
  white-space: normal;
}

.log-entry.expanded .log-msg {
  white-space: pre-wrap;
  word-break: break-all;
  overflow: visible;
  text-overflow: unset;
}

/* Log level coloring */
.log-entry.level-ERROR .log-level { color: var(--danger); }
.log-entry.level-ERROR .log-msg { color: var(--danger); }
.log-entry.level-WARN .log-level { color: var(--warning); }
.log-entry.level-WARN .log-msg { color: var(--warning); }
.log-entry.level-INFO .log-level { color: var(--text); }
.log-entry.level-DEBUG .log-level { color: var(--text-secondary); }
.log-entry.level-DEBUG .log-msg { color: var(--text-secondary); }

/* Extensions Tab */
.extensions-container {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.extensions-section {
  margin-bottom: 24px;
}

.extensions-section h3 {
  font-size: var(--text-xs);
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.extensions-section h4 {
  font-size: var(--text-xs);
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.extensions-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-3);
}

.ext-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: border-color var(--transition-base), box-shadow var(--transition-base), transform 0.2s;
}

.ext-card.state-active {
  border-left-color: var(--success);
}

.ext-card.state-inactive {
  border-left-color: var(--text-muted);
}

.ext-card.state-error {
  border-left-color: var(--danger);
}

.ext-card.state-pairing {
  border-left-color: var(--warning);
}

.ext-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.ext-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ext-name {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--text);
}

.ext-kind {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ext-kind.kind-mcp_server {
  background: var(--accent-subtle);
  color: var(--accent);
}

.ext-kind.kind-wasm_tool {
  background: var(--accent-subtle);
  color: var(--success);
}

.ext-kind.kind-wasm_channel {
  background: var(--warning-subtle);
  color: var(--warning);
}

.ext-kind.kind-builtin {
  background: rgba(161, 161, 170, 0.15);
  color: var(--text-secondary);
}

.ext-version {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.ext-auth-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ext-auth-dot.authed {
  background: var(--success);
}

.ext-auth-dot.unauthed {
  background: var(--danger);
}

.ext-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.4;
}

.ext-url {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ext-tools {
  font-size: 12px;
  color: var(--text-secondary);
}

.ext-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.ext-active-label {
  font-size: 12px;
  color: var(--success);
  font-weight: 500;
}

/* WASM channel setup stepper */
.ext-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 8px 0 4px;
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stepper-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.stepper-label {
  font-size: var(--text-xs);
  white-space: nowrap;
}

.stepper-step.completed .stepper-circle {
  background: var(--success);
  color: #000;
}

.stepper-step.completed .stepper-label {
  color: var(--success);
}

.stepper-step.failed .stepper-circle {
  background: var(--danger);
  color: var(--text-on-danger);
}

.stepper-step.failed .stepper-label {
  color: var(--danger);
}

.stepper-step.in-progress .stepper-circle {
  background: var(--warning);
  color: #000;
  animation: pulse-glow 1.5s ease-in-out infinite;
}

.stepper-step.in-progress .stepper-label {
  color: var(--warning);
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.stepper-step.pending .stepper-circle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.stepper-step.pending .stepper-label {
  color: var(--text-secondary);
}

.ext-pairing-label {
  font-size: 12px;
  color: var(--warning);
  font-weight: 500;
}

.stepper-connector {
  width: 20px;
  height: 2px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.stepper-connector.completed {
  background: var(--success);
}

.ext-error {
  font-size: var(--text-xs);
  color: var(--danger);
  background: var(--danger-error-bg);
  border: 1px solid var(--danger-error-border);
  border-radius: var(--radius);
  padding: 6px 8px;
  margin-top: 6px;
}

.ext-note {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  background: var(--note-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  margin-top: 6px;
}

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

.btn-ext {
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text);
  transition: all var(--transition-fast), transform 150ms var(--ease-spring);
}

.btn-ext:hover {
  background: var(--border);
  transform: translateY(-1px);
}

.btn-ext:active {
  transform: scale(0.97);
}

.btn-ext.activate {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ext.activate:hover {
  background: var(--accent-subtle);
}

.btn-ext.remove {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-ext.remove:hover {
  background: var(--danger-subtle);
}

.btn-ext.install {
  border-color: var(--success);
  color: var(--success);
}

.btn-ext.install:hover {
  background: var(--accent-subtle);
}

.btn-ext.install:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ext-available {
  border-style: dashed;
}

.ext-keywords {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  opacity: 0.7;
}

.btn-ext.configure {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ext.configure:hover {
  background: var(--badge-sandbox-bg);
}

/* Pairing requests */
.ext-pairing {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.pairing-heading {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.pairing-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 4px;
}

.pairing-code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 3px;
}

.pairing-sender {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
}

/* Configure modal */
.configure-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-heavy);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.configure-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 460px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.configure-modal h3 {
  margin: 0 0 16px 0;
  font-size: var(--text-lg);
  color: var(--text);
}

.configure-hint {
  margin: 0 0 16px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.configure-verification {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 0 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.configure-verification-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.configure-verification-instructions {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-secondary);
}

.configure-verification-code {
  display: inline-block;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: var(--text-sm);
}

.configure-verification-link {
  width: fit-content;
  color: var(--accent, var(--text-link, #4ea3ff));
  font-size: var(--text-sm);
  text-decoration: none;
}

.configure-verification-link:hover {
  text-decoration: underline;
}

.configure-inline-error {
  margin: 16px 0 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #fca5a5;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.configure-inline-status {
  margin: 16px 0 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.configure-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.configure-field label {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.configure-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.configure-input-row input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: inherit;
}

.configure-input-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.field-optional {
  color: var(--text-secondary);
  font-style: italic;
}

.field-provided {
  font-size: var(--text-xs);
  padding: 2px 8px;
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
  border-radius: 4px;
  white-space: nowrap;
}

.field-autogen {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

.configure-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: 20px;
  justify-content: flex-end;
}

.tools-table {
  width: 100%;
  border-collapse: collapse;
}

.tools-table th,
.tools-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}

.tools-table th {
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 0.5px;
}

.tools-table tr:hover td {
  background: var(--hover-surface);
}


/* --- Activity tab (unified sandbox job events) --- */

.activity-terminal {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  max-height: calc(100vh - 320px);
}

.activity-event {
  padding: 4px 0;
  border-bottom: 1px solid var(--note-bg);
}

.activity-event-message .activity-role {
  color: var(--accent);
  font-weight: 600;
  margin-right: 8px;
}

.activity-event-message .activity-content {
  white-space: pre-wrap;
  word-break: break-word;
}

.activity-event-status .activity-status {
  color: var(--text-secondary);
  font-style: italic;
}

.activity-event-result.activity-final {
  padding: 8px 0;
  font-weight: 600;
}

.activity-result-status {
  color: var(--success);
}

.activity-result-status[data-success="false"] {
  color: var(--danger);
}

.activity-session-id {
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 400;
}

.activity-tool-block {
  margin: 4px 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.activity-tool-block summary {
  padding: 6px 10px;
  cursor: pointer;
  background: var(--bg-secondary);
  font-size: 12px;
  color: var(--text-secondary);
}

.activity-tool-block summary:hover {
  color: var(--text);
}

.activity-tool-icon {
  margin-right: 4px;
}

.activity-tool-result .activity-tool-icon {
  color: var(--success);
}

.activity-tool-error .activity-tool-icon {
  color: var(--danger);
}

.activity-tool-error summary {
  color: var(--danger);
}

.activity-tool-input,
.activity-tool-output {
  padding: 8px 10px;
  margin: 0;
  font-size: 12px;
  overflow-x: auto;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg);
}

.activity-input-bar {
  display: flex;
  gap: var(--space-2);
  padding: 8px 0;
}

.activity-input-bar input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-sm);
}

.activity-input-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.activity-input-bar button {
  padding: 8px 16px;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background 0.2s, transform 150ms var(--ease-spring);
}

.activity-input-bar button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.activity-input-bar button:active {
  transform: scale(0.97);
}

#activity-done-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

#activity-done-btn:hover {
  color: var(--text);
  border-color: var(--text-secondary);
  background: var(--bg-secondary);
}

/* --- Copy button on code blocks --- */

.code-block-wrapper {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.code-block-wrapper:hover .copy-btn {
  opacity: 1;
}

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

/* --- Toast notifications --- */

#toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  padding: 10px 16px 10px 12px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--text);
  pointer-events: auto;
  transform: translateX(120%);
  transition: transform 400ms var(--ease-spring), opacity 200ms ease;
  max-width: 360px;
  word-break: break-word;
  box-shadow: var(--shadow-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
}

.toast.visible {
  transform: translateX(0);
}

.toast.dismissing {
  opacity: 0;
  transform: translateY(-8px);
}

.toast-info {
  border-left: 3px solid var(--accent);
}

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-error {
  border-left: 3px solid var(--danger);
}

.toast-icon {
  font-size: var(--text-base);
  flex-shrink: 0;
}

.toast-countdown {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  animation: toastCountdown 4s linear forwards;
}

.toast-success .toast-countdown { background: var(--success); }
.toast-error .toast-countdown { background: var(--danger); }

/* --- Connection status banner --- */

.connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 6px 16px;
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 500;
  z-index: 9999;
  animation: bannerSlideDown 250ms var(--ease-out-expo);
}

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

.connection-banner-warning {
  background: var(--warning-subtle);
  color: var(--warning);
  border-bottom: 1px solid var(--warning);
}

.connection-banner-success {
  background: var(--accent-subtle);
  color: var(--success);
  border-bottom: 1px solid var(--success);
}

@keyframes toastCountdown {
  from { width: 100%; }
  to { width: 0%; }
}

/* --- Memory search highlighting --- */

mark {
  background: var(--highlight-bg);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* --- Thread sidebar --- */

#tab-chat {
  flex-direction: row;
}

.thread-sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 300ms var(--ease-out-expo);
  overflow: hidden;
  padding: 6px;
  gap: 2px;
}

.thread-sidebar.collapsed {
  width: 36px;
}

.thread-sidebar .thread-list,
.thread-sidebar .assistant-item,
.thread-sidebar .threads-section-header span {
  transition: opacity 200ms ease;
}

.thread-sidebar.collapsed .thread-list,
.thread-sidebar.collapsed .assistant-item {
  display: none;
}

.thread-sidebar.collapsed .threads-section-header {
  padding: var(--space-2) 0;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.thread-sidebar.collapsed .threads-section-header span,
.thread-sidebar.collapsed .threads-section-header .spacer {
  display: none;
}

.thread-sidebar.collapsed .thread-list,
.thread-sidebar.collapsed .assistant-item,
.thread-sidebar.collapsed .threads-section-header span {
  opacity: 0;
}

.thread-new-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  font-size: var(--text-lg);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.thread-new-btn:hover {
  background: var(--accent-subtle);
}

.assistant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  margin-bottom: 2px;
}

.assistant-item:hover {
  background: var(--hover-subtle);
}

.assistant-item.active {
  background: var(--accent-tee-bg);
  color: var(--accent);
  border-left: 2px solid var(--accent);
}

.assistant-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.assistant-meta {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--text-secondary);
}

.threads-section-header {
  display: flex;
  align-items: center;
  padding: 10px 10px 4px;
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  gap: 4px;
}

.thread-toggle-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-base);
  padding: 2px;
}

.thread-toggle-btn:hover {
  color: var(--text);
}

.thread-list {
  flex: 1;
  overflow-y: auto;
}

.thread-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-radius: var(--radius);
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.thread-item:hover {
  background: var(--bg-tertiary);
  color: var(--text);
  transform: translateX(2px);
}

.thread-item.active {
  background: var(--bg-tertiary);
  color: var(--accent);
  border-left: 2px solid var(--accent);
}

.thread-label {
  font-family: var(--font-mono);
  font-size: 12px;
}

.thread-meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.thread-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--border);
  color: var(--text-secondary);
  margin-right: 6px;
  flex-shrink: 0;
}

.thread-badge-routine { background: var(--accent-subtle); color: var(--accent); }
.thread-badge-heartbeat { background: var(--warning-subtle); color: var(--warning); }
.thread-badge-telegram { background: rgba(0, 136, 204, 0.15); color: #0088cc; }
.thread-badge-signal { background: rgba(59, 118, 240, 0.15); color: #3b76f0; }
.thread-badge-slack { background: rgba(74, 21, 75, 0.15); color: #e01e5a; }

.thread-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  font-size: 10px;
  font-weight: 700;
  background: var(--accent);
  color: var(--bg);
  border-radius: 8px;
  padding: 0 4px;
  margin-left: auto;
  flex-shrink: 0;
}

/* --- Memory editing --- */

#memory-breadcrumb-path {
  flex: 1;
}

.memory-edit-btn {
  padding: 3px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
}

.memory-edit-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.memory-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 12px;
  overflow: hidden;
}

.memory-editor textarea {
  flex: 1;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.5;
  resize: none;
}

.memory-editor textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.memory-editor-actions {
  display: flex;
  gap: var(--space-2);
}

.btn-save {
  padding: 6px 16px;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background 0.2s, transform 150ms var(--ease-spring);
}

.btn-save:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-save:active {
  transform: scale(0.97);
}

.btn-cancel-edit {
  padding: 6px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: var(--text-sm);
}

.btn-cancel-edit:hover {
  background: var(--bg-tertiary);
}

/* Memory rendered markdown */
.memory-viewer.rendered {
  white-space: normal;
  font-family: inherit;
}

.memory-rendered {
  font-size: var(--text-base);
  line-height: 1.6;
}

.memory-rendered h1, .memory-rendered h2, .memory-rendered h3 {
  margin: 12px 0 6px 0;
}

.memory-rendered p { margin: 0 0 8px 0; }
.memory-rendered p:last-child { margin-bottom: 0; }
.memory-rendered ul, .memory-rendered ol { margin: 4px 0; padding-left: 20px; }
.memory-rendered li { margin: 2px 0; }
.memory-rendered code {
  background: var(--code-bg);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: var(--text-sm);
}
.memory-rendered pre {
  background: var(--code-bg);
  padding: 8px 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 6px 0;
}
.memory-rendered pre code { background: none; padding: 0; }
.memory-rendered a { color: var(--accent); }
.memory-rendered blockquote {
  margin: 6px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
}

/* --- Gateway status popover --- */

.gateway-popover {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--popover-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  min-width: 220px;
  box-shadow: var(--shadow);
  z-index: 500;
}

.gateway-popover.visible {
  display: block;
}

.gw-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, var(--text-secondary));
  margin-bottom: 4px;
  font-weight: 600;
}

.gw-divider {
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

.gw-stat {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
  color: var(--text-secondary);
}

.gw-stat span:last-child {
  color: var(--text);
  font-weight: 500;
}

.gw-model-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0 0 0;
}

.gw-model-name {
  color: var(--text);
  font-weight: 500;
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.gw-model-cost {
  color: var(--accent, var(--text));
  font-weight: 500;
  font-size: var(--text-xs);
}

.gw-token-detail {
  display: flex;
  gap: var(--space-3);
  font-size: 10px;
  color: var(--text-secondary);
  padding: 1px 0 4px 0;
}

/* --- Extension install form --- */

.ext-install-form {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.ext-install-form input {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-sm);
}

.ext-install-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.ext-install-form button {
  padding: 6px 16px;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background 0.2s, transform 150ms var(--ease-spring);
}

.ext-install-form button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.ext-install-form button:active {
  transform: scale(0.97);
}

/* --- Skills tab --- */

.skill-search-box {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.skill-search-box input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-sm);
}

.skill-search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.skill-search-box button {
  padding: 8px 20px;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background 0.2s, transform 0.2s;
}

.skill-search-box button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.skill-trust {
  font-size: var(--text-xs);
  padding: 3px 8px;
  border-radius: 9999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.skill-trust.trust-trusted {
  background: var(--accent-subtle);
  color: var(--success);
}

.skill-trust.trust-installed {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

.skill-version {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

@keyframes skillFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.skill-search-result {
  animation: skillFadeIn 0.3s ease-out both;
}

/* --- Activity toolbar --- */

.activity-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 0;
}

.activity-toolbar select {
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
}

.activity-toolbar select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* --- Mobile responsive --- */

@media (max-width: 768px) {
  /* Tab bar: horizontal scroll */
  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 8px;
  }

  .tab-bar button:not(.status-logs-btn) {
    padding: 8px 12px;
    font-size: var(--text-sm);
    white-space: nowrap;
  }

  /* Chat messages: wider */
  .message {
    max-width: 95%;
  }

  /* Thread sidebar: hidden behind toggle */
  .thread-sidebar {
    width: 36px;
  }

  .thread-sidebar .thread-new-btn,
  .thread-sidebar .thread-list,
  .thread-sidebar .assistant-item {
    display: none;
  }

  .thread-sidebar .threads-section-header > span,
  .thread-sidebar .threads-section-header > .spacer,
  .thread-sidebar .threads-section-header > .thread-new-btn {
    display: none;
  }

  .thread-sidebar .threads-section-header {
    padding: 0;
    justify-content: center;
  }

  .thread-sidebar .thread-toggle-btn {
    min-width: 36px;
    min-height: 44px;
  }

  .thread-sidebar.expanded-mobile {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 240px;
    z-index: 50;
  }

  .thread-sidebar.expanded-mobile .thread-new-btn,
  .thread-sidebar.expanded-mobile .assistant-item {
    display: flex;
  }

  .thread-sidebar.expanded-mobile .thread-list {
    display: block;
  }

  .thread-sidebar.expanded-mobile .threads-section-header > span,
  .thread-sidebar.expanded-mobile .threads-section-header > .spacer,
  .thread-sidebar.expanded-mobile .threads-section-header > .thread-new-btn {
    display: initial;
  }

  .thread-sidebar.expanded-mobile::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: -1;
  }

  /* Memory: vertical stack */
  .memory-container {
    flex-direction: column;
  }

  .memory-sidebar {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  /* Job detail sub-tabs: wrap */
  .job-detail-tabs {
    flex-wrap: wrap;
  }

  .job-detail-header {
    flex-wrap: wrap;
  }

  .job-detail-header h2 {
    min-width: 100%;
    order: -1;
  }

  /* Job files: vertical */
  .job-files {
    flex-direction: column;
    height: auto;
  }

  .job-files-sidebar {
    width: 100%;
    max-height: 180px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  /* Settings layout: drill-down on mobile */
  .settings-layout { flex-direction: column; }
  .settings-sidebar {
    width: 100%;
    flex-direction: column;
    border-right: none;
    padding: 8px 0;
  }
  .settings-subtab {
    border-left: none;
    padding: 14px 20px;
    text-align: left;
    font-size: var(--text-base);
    border-bottom: 1px solid var(--border);
  }
  .settings-subtab::after {
    content: '\203A';
    float: right;
    color: var(--text-secondary);
    font-size: 18px;
  }
  .settings-subtab.active {
    border-left-color: transparent;
    color: var(--text);
  }
  .settings-layout > .settings-content {
    display: none;
  }
  .settings-layout.settings-detail-active > .settings-sidebar {
    display: none;
  }
  .settings-layout.settings-detail-active > .settings-content {
    display: flex;
  }
  .settings-back-btn {
    display: flex;
  }

  .settings-theme-toggle {
    display: block;
    padding: 14px 20px;
    text-align: left;
    font-size: var(--text-base);
    background: none;
    border: none;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    margin-top: auto;
  }

  /* Extension install form */
  .ext-install-form {
    flex-direction: column;
    align-items: stretch;
  }

  .ext-install-form input {
    width: 100%;
  }

  /* Chat input: ensure visibility on mobile */
  .chat-input {
    min-height: 52px;
  }

  .chat-input-wrapper textarea {
    min-height: 36px;
    max-height: 100px;
  }

  .chat-input button {
    padding: 6px 16px;
    font-size: var(--text-base);
  }
}

/* --- Settings Tab Layout --- */
.settings-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.settings-sidebar {
  width: 180px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  padding: 12px 0;
  flex-shrink: 0;
}

.settings-subtab {
  display: block;
  width: 100%;
  padding: 10px 20px;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 500;
  text-align: left;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.settings-subtab:hover {
  color: var(--text);
  background: var(--bg-tertiary);
}

.settings-subtab.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--bg-tertiary);
}

.settings-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.settings-subpanel {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
  opacity: 0;
}

.settings-subpanel.active {
  display: flex;
  animation: settingsFadeIn 0.2s ease forwards;
}

@keyframes settingsFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Settings form styles (General subtab) */
.settings-group {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: 16px;
}

.settings-group-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  z-index: 1;
  margin: -16px -16px 12px -16px;
  padding: 16px 16px 8px 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin: 0 -12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  border-radius: 6px;
  gap: var(--space-4);
  max-height: 80px;
  overflow: hidden;
  transition: max-height 0.2s ease, opacity 0.2s ease, margin 0.2s ease, padding 0.2s ease, background var(--transition-fast);
  opacity: 1;
}

.settings-row:hover {
  background: var(--hover-surface);
}

.settings-row.hidden {
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
  border-bottom: none;
}

.settings-row.search-hidden {
  display: none;
}

.settings-row:last-child { border-bottom: none; }

.settings-label {
  font-size: var(--text-sm);
  color: var(--text);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 180px;
}

.settings-input {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-sm);
  font-family: 'IBM Plex Mono', monospace;
  width: 240px;
  max-width: 100%;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform 200ms var(--ease-spring), background 200ms ease;
}

.toggle-switch.on {
  background: var(--accent-subtle);
  border-color: var(--accent);
}

.toggle-switch.on::after {
  transform: translateX(20px);
  background: var(--accent);
}

.settings-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--glow-accent);
}

.settings-saved-indicator {
  font-size: 12px;
  color: var(--success);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 300ms ease, transform 300ms var(--ease-spring);
}

.settings-saved-indicator.visible {
  opacity: 1;
  transform: scale(1);
}

.settings-description {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.restart-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--warning-subtle);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  margin: 8px 16px;
  animation: settingsFadeIn 0.25s ease forwards;
}

.restart-banner-text {
  flex: 1;
}

.restart-banner-btn {
  padding: 4px 12px;
  background: var(--warning);
  color: #09090b;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  transition: opacity var(--transition-fast);
}

.restart-banner-btn:hover {
  opacity: 0.85;
}

.settings-label-wrap {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-width: 180px;
}

.settings-select {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-sm);
  font-family: 'IBM Plex Mono', monospace;
  width: 240px;
  max-width: 100%;
  cursor: pointer;
}

.settings-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--glow-accent);
}

input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Slash command autocomplete dropdown */
.slash-autocomplete {
  position: relative;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  border-bottom: none;
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
}

.slash-ac-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 16px;
  cursor: pointer;
  transition: background 0.1s;
}

.slash-ac-item:hover,
.slash-ac-item.selected {
  background: var(--bg-tertiary);
}

.slash-ac-cmd {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--accent);
  white-space: nowrap;
  min-width: 130px;
}

.slash-ac-desc {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Image Upload */
.chat-input .attach-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2em;
  padding: 8px;
  align-self: flex-end;
  color: var(--text-secondary);
  transition: color 0.2s;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 400;
}

.chat-input .attach-btn:hover {
  background: none;
  color: var(--text);
  transform: none;
}

.image-preview-strip {
  display: flex;
  flex-direction: row;
  gap: var(--space-2);
  padding: 4px;
  overflow-x: auto;
  min-height: 0;
  width: 100%;
}

.image-preview-strip:empty {
  display: none;
}

.image-preview-container {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.image-preview {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
}

.image-preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--text-on-danger);
  border: none;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
  padding: 0;
}

.image-preview-remove:hover {
  filter: brightness(1.2);
}

/* Generated Image */
.generated-image-card {
  max-width: 512px;
  margin: 8px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.generated-image {
  max-width: 100%;
  display: block;
}

/* Language Switcher */
.language-switcher {
  position: relative;
  display: flex;
  align-items: center;
}

.language-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  font-size: var(--text-lg);
  border-radius: var(--radius);
  transition: all 0.2s;
}

.language-btn:hover {
  color: var(--text);
  background: var(--bg-tertiary);
}

.language-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  min-width: 120px;
  z-index: 1000;
  box-shadow: var(--shadow);
}

.language-option {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-sm);
  transition: all 0.2s;
}

.language-option:hover {
  background: var(--bg-tertiary);
}

.language-option.active {
  background: var(--accent);
  color: var(--bg);
}

.generated-image-path {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 8px;
  background: var(--bg-secondary);
}

/* Settings toolbar (search + import/export) */
.settings-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.settings-search {
  flex: 1;
}

.settings-search input {
  width: 100%;
  padding: 6px 10px 6px 32px;
  background: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--text-sm);
  font-family: 'IBM Plex Mono', monospace;
}

.settings-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15);
}

.settings-toolbar-btn {
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast), transform 150ms var(--ease-spring);
  white-space: nowrap;
}

.settings-toolbar-btn:hover {
  background: var(--bg-secondary);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.settings-toolbar-btn:active {
  transform: scale(0.97);
}

.settings-back-btn {
  display: none;
  align-items: center;
  background: none;
  border: none;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.settings-back-btn:hover {
  background: var(--bg-tertiary);
}

/* Confirmation modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modalFadeIn 0.15s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.2s ease;
}

.modal h3 {
  margin: 0;
  padding: 16px 20px;
  font-size: var(--text-lg);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.modal p {
  margin: 0;
  padding: 16px 20px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.btn-secondary {
  padding: 8px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: var(--text-sm);
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-danger {
  padding: 8px 16px;
  background: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  font-size: var(--text-sm);
}

.btn-danger:hover {
  opacity: 0.9;
}

/* Mobile settings responsiveness */
@media (max-width: 768px) {
  .settings-row {
    flex-direction: column;
    align-items: stretch;
    max-height: 140px;
  }
  .settings-label-wrap {
    min-width: unset;
  }
  .settings-input, .settings-select {
    width: 100%;
  }
  .settings-toolbar {
    flex-wrap: wrap;
  }
  .settings-search {
    min-width: 150px;
  }
}

/* Loading skeletons */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  gap: var(--space-4);
}

.skeleton-bar {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, rgba(255,255,255,0.06) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Settings search empty state */
.settings-search-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   Light Theme
   ============================================================ */

[data-theme="light"] {
  --bg: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #ebebed;
  --border: rgba(0, 0, 0, 0.1);
  --text: #1a1a2e;
  --text-secondary: #555555;
  --accent: #059669;
  --accent-hover: #047857;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --code-bg: #f0f0f2;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --bg-overlay: rgba(0, 0, 0, 0.3);
  --bg-modal: #ffffff;
  --border-modal: #e0e0e0;
  --border-soft: #e5e5e5;
  --text-tertiary: #333333;
  --text-muted: #777777;
  --text-dimmed: #999999;
  --text-on-accent: #ffffff;
  --accent-brand: #059669;
  --accent-brand-hover: #047857;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --warning-text: #92400e;
  --tab-bg: rgba(255, 255, 255, 0.9);
  --popover-bg: rgba(255, 255, 255, 0.95);
  --badge-sandbox-bg: rgba(136, 132, 216, 0.1);
  --badge-sandbox-text: #6b67b0;
  --hover-surface: rgba(0, 0, 0, 0.03);
  --focus-ring: rgba(5, 150, 105, 0.15);
  --accent-subtle: rgba(5, 150, 105, 0.1);
  --accent-border-subtle: rgba(5, 150, 105, 0.3);
  --danger-subtle: rgba(220, 38, 38, 0.1);
  --danger-border-subtle: rgba(220, 38, 38, 0.2);
  --warning-subtle: rgba(217, 119, 6, 0.1);
  --border-hover: rgba(0, 0, 0, 0.15);
  --user-msg-bg: rgba(5, 150, 105, 0.08);
  --user-msg-border: rgba(5, 150, 105, 0.2);
  --danger-error-bg: rgba(220, 38, 38, 0.06);
  --accent-tee-bg: rgba(5, 150, 105, 0.08);
  --accent-tee-border: rgba(5, 150, 105, 0.2);
  --accent-tee-hover: rgba(5, 150, 105, 0.15);
  --text-on-danger: #fff;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-toast: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
  --danger-error-border: rgba(220, 38, 38, 0.15);
  --note-bg: rgba(0, 0, 0, 0.02);
  --overlay-heavy: rgba(0, 0, 0, 0.4);
  --highlight-bg: rgba(5, 150, 105, 0.2);
  --hover-subtle: rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --glow-accent: 0 0 20px rgba(5,150,105,0.08);
  --glass-bg: rgba(255,255,255,0.85);
  --glass-blur: blur(16px) saturate(180%);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring-gentle: cubic-bezier(0.22, 1.2, 0.36, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --surface-highlight: inset 0 1px 0 rgba(255,255,255,0.8);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 36px;
  --transition-slow: 300ms ease;
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-instant: 100ms;
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 400ms;
  --accent-soft: var(--accent-subtle);
  --accent-dim: var(--accent-subtle);
  --bg-hover: var(--hover-surface);
  --danger-soft: var(--danger-subtle);
  --warning-soft: var(--warning-subtle);
}

/* ============================================================
   Theme transition (delayed via JS to avoid FOUC)
   ============================================================ */

body.theme-transition,
body.theme-transition *:not(svg):not(path):not(line):not(circle):not(rect) {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ============================================================
   Theme toggle button
   ============================================================ */

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  align-self: center;
  margin-right: 8px;
  transition: color 0.2s, border-color 0.2s;
}

.theme-toggle-btn:hover {
  color: var(--text);
  border-color: var(--text-secondary);
}

.settings-theme-toggle {
  display: none;
}

/* CSS-only icon switching via data-theme-mode on <html> */
.theme-icon { display: none; }
[data-theme-mode="dark"]  .icon-dark   { display: block; }
[data-theme-mode="light"] .icon-light  { display: block; }
[data-theme-mode="system"] .icon-system { display: block; }

/* ============================================================
   Phase 6: Accessibility & Mobile Polish
   ============================================================ */

/* Touch target audit */
@media (pointer: coarse) {
  .approval-card button,
  .message-copy-btn,
  .toggle-switch,
  .welcome-chip,
  .code-block-copy,
  .copy-btn,
  .tree-row {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Mobile bottom sheet modals */
@media (max-width: 768px) {
  .modal-overlay {
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: 12px 12px 0 0;
    animation: bottomSheetSlideIn 300ms var(--ease-out-expo);
    max-height: 85vh;
    overflow-y: auto;
  }
}

@keyframes bottomSheetSlideIn {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Mobile bottom tab bar */
@media (max-width: 768px) {
  .tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    z-index: 100;
    border-bottom: none;
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
    overflow-x: visible;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
  }

  .tab-bar button:not(.status-logs-btn):not(.restart-btn):not(.language-btn) {
    flex: 1;
    text-align: center;
    padding: 10px 4px;
  }

  .tab-bar .spacer,
  .tab-bar .language-switcher,
  .tab-bar .tee-shield,
  .tab-bar .restart-btn {
    display: none;
  }

  .tab-bar .status {
    display: none;
  }

  .tab-bar .status-logs-btn {
    display: none;
  }

  .tab-bar .theme-toggle-btn {
    display: none;
  }

  .tab-indicator {
    top: 0;
    bottom: auto;
  }

  #app {
    padding-bottom: 52px;
  }
}

/* Job status badge pulse */
.badge.in_progress {
  background: var(--accent-soft);
  color: var(--accent);
  position: relative;
  padding-left: 18px;
}

.badge.in_progress::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: statusPulse 2s ease-out infinite;
}

@keyframes statusPulse {
  0% { transform: translateY(-50%) scale(0.8); opacity: 0.6; }
  100% { transform: translateY(-50%) scale(1.8); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --border: rgba(255, 255, 255, 0.2);
    --text-secondary: #d4d4d8;
    --text-muted: #a1a1aa;
  }
}


/* --- Config Tab --- */

.config-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.config-section-header h3 {
  margin-bottom: 0;
}

.btn-add-provider {
  padding: 5px 14px;
  background: var(--accent);
  color: #09090b;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s, transform 0.2s;
}

.btn-add-provider:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.config-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.3);
  border-radius: var(--radius);
  color: var(--warning);
  font-size: 13px;
  margin-bottom: 12px;
}

.providers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.provider-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s;
}

.provider-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.provider-card-active {
  border-color: var(--accent);
}

.provider-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.provider-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.provider-id-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.provider-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.provider-badge-active {
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent);
}

.provider-badge-builtin {
  background: rgba(161, 161, 170, 0.12);
  color: var(--text-secondary);
}

.provider-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.provider-adapter {
  font-size: 12px;
  color: var(--text-secondary);
}

.provider-url {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  opacity: 0.7;
}

.provider-current-model {
  font-size: 11px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 500;
}

.provider-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.provider-action-btn {
  padding: 4px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.provider-action-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg);
}

.provider-delete-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* Config form */

.provider-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.provider-dialog-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.provider-dialog-content {
  position: relative;
  z-index: 10000;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  width: 100%;
  max-width: 480px;
  margin: 0 1rem;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.provider-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.provider-dialog-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.provider-dialog-close {
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.provider-dialog-close:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.provider-dialog-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

.provider-dialog-footer {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.provider-dialog-footer button {
  padding: 6px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.provider-dialog-footer button:first-child {
  background: var(--accent);
  color: #09090b;
  border: none;
}

.provider-dialog-footer button:first-child:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.provider-dialog-footer .btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.provider-dialog-footer .btn-secondary:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.config-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.config-form-row label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.config-form-row input,
.config-form-row select {
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
}

.config-form-row input:focus,
.config-form-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.1);
}

.config-form-hint {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.config-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.config-form-actions button {
  padding: 6px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.config-form-actions button:first-child {
  background: var(--accent);
  color: #09090b;
  border: none;
}

.config-form-actions button:first-child:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.config-form-actions .btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.config-form-actions .btn-secondary:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-fetch-models {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 5px 11px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.btn-fetch-models:hover {
  color: var(--text);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.btn-fetch-models:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.test-connection-result {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}

.test-connection-result.test-ok {
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.test-connection-result.test-fail {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.3);
}
