/* ==========================================================================
   Orbit / 掌控 - Modern Cyber Mobile UI Design System
   Color Palette: Charcoal/Ink Surfaces + Electric Mint/Cyan Focus
   Author: Gemini 3.8 Flash (High) - UI Designer & Implementer
   ========================================================================== */

:root {
  /* Dark Theme (Default) */
  --bg-app: #080b0f;
  --bg-shell: #0d1117;
  --bg-surface: #141a23;
  --bg-surface-elevated: #1a2330;
  --bg-surface-input: #10161f;
  --bg-surface-hover: #1f2937;
  --bg-overlay: rgba(8, 11, 15, 0.78);

  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-focus: #00f2a1;

  /* Typography */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0d1117;

  /* Brand & Accents */
  --accent-mint: #00f2a1;
  --accent-mint-hover: #00d68f;
  --accent-mint-glow: rgba(0, 242, 161, 0.22);
  --accent-mint-subtle: rgba(0, 242, 161, 0.12);
  --accent-cyan: #06b6d4;
  --accent-cyan-subtle: rgba(6, 182, 212, 0.12);

  /* Status Colors */
  --status-online: #00f2a1;
  --status-idle: #94a3b8;
  --status-running: #00f2a1;
  --status-warning: #f59e0b;
  --status-error: #f43f5e;
  --status-error-bg: rgba(244, 63, 94, 0.12);
  --status-error-border: rgba(244, 63, 94, 0.35);

  /* Provider Badges */
  --provider-claude: #f97316;
  --provider-claude-bg: rgba(249, 115, 22, 0.12);
  --provider-codex: #00f2a1;
  --provider-codex-bg: rgba(0, 242, 161, 0.12);
  --provider-omp: #38bdf8;
  --provider-omp-bg: rgba(56, 189, 248, 0.12);
  --provider-pi: #a855f7;
  --provider-pi-bg: rgba(168, 85, 247, 0.12);

  /* Font Stacks */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", Menlo, Monaco, Consolas, "Courier New", monospace;

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-mint-glow);

  /* Animation Timings */
  --transition-fast: 160ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-shell: #ffffff;
  --bg-surface: #f8fafc;
  --bg-surface-elevated: #ffffff;
  --bg-surface-input: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --bg-overlay: rgba(15, 23, 42, 0.5);

  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: #059669;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --accent-mint: #059669;
  --accent-mint-hover: #047857;
  --accent-mint-glow: rgba(5, 150, 105, 0.18);
  --accent-mint-subtle: rgba(5, 150, 105, 0.1);
  --accent-cyan: #0284c7;
  --accent-cyan-subtle: rgba(2, 132, 199, 0.1);

  --status-online: #059669;
  --status-idle: #64748b;
  --status-running: #059669;
  --status-warning: #d97706;
  --status-error: #e11d48;
  --status-error-bg: rgba(225, 29, 72, 0.08);
  --status-error-border: rgba(225, 29, 72, 0.28);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 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;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Desktop Centered Phone Preview Shell
   ========================================================================== */
.desktop-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-app);
}

.phone-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-shell);
  position: relative;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* Desktop Preview Enhancement (Screens wider than 480px) */
@media (min-width: 481px) {
  .phone-shell {
    max-width: 420px;
    height: min(94vh, 880px);
    border-radius: 36px;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--border-medium);
  }
}

/* Small mobile devices (320px) support */
@media (max-width: 350px) {
  :root {
    font-size: 13px;
  }
  .providers-strip {
    gap: 4px;
  }
  .provider-chip {
    padding: 3px 6px;
    font-size: 11px;
  }
}

/* ==========================================================================
   Header Bar
   ========================================================================== */
.app-header {
  height: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background-color: var(--bg-shell);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 20;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-mint);
  filter: drop-shadow(0 0 8px var(--accent-mint-glow));
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.brand-host-status {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.brand-host-status.connected {
  color: var(--status-online);
}

.brand-host-status.connecting {
  color: var(--status-warning);
}

.brand-host-status.offline {
  color: var(--status-error);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Buttons & Interactive Elements
   ========================================================================== */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent-mint);
  outline-offset: 1px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--accent-mint);
  color: var(--text-inverse);
  box-shadow: 0 2px 10px var(--accent-mint-glow);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-mint-hover);
}

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

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-surface-hover);
}

.btn-danger-outline {
  background: transparent;
  border-color: var(--status-error-border);
  color: var(--status-error);
}

.btn-danger-outline:hover:not(:disabled) {
  background-color: var(--status-error-bg);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
}

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

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
}

.btn-block {
  width: 100%;
}

.btn-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Main Viewport & Panels
   ========================================================================== */
.main-viewport {
  flex: 1;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.view-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn var(--transition-normal);
}

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

/* ==========================================================================
   1. Connection Screen Styles
   ========================================================================== */
.connection-hero {
  padding: 12px 4px 4px;
}

.hero-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-mint);
  background-color: var(--accent-mint-subtle);
  border: 1px solid var(--accent-mint-glow);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
}

.hero-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.hero-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.connection-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.label-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  background-color: var(--bg-surface-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input-code {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-mint-subtle);
}

.connection-guide {
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 14px;
}

.guide-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.guide-steps {
  padding-left: 20px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.guide-steps li {
  margin-bottom: 4px;
}

.guide-steps code {
  font-family: var(--font-mono);
  background-color: var(--bg-surface-elevated);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--accent-mint);
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.45;
}

.alert-error {
  background-color: var(--status-error-bg);
  border: 1px solid var(--status-error-border);
  color: var(--status-error);
}

.alert-info {
  background-color: var(--accent-cyan-subtle);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--accent-cyan);
}

/* Quick Reconnect Prompt */
.quick-reconnect-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.quick-reconnect-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-reconnect-icon {
  color: var(--accent-mint);
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-reconnect-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.quick-reconnect-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   2. Connected Dashboard View
   ========================================================================== */
.host-status-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.host-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.host-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-mint);
}

.host-details {
  flex: 1;
  min-width: 0;
}

.host-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.host-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-pill {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.status-pill-online {
  background-color: var(--accent-mint-subtle);
  color: var(--status-online);
  border: 1px solid var(--accent-mint-glow);
}

.status-pill-offline {
  background-color: rgba(148, 163, 184, 0.12);
  color: var(--status-idle);
}

.status-pill-warning {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--status-warning);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.host-meta {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* Section Blocks */
.section-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.section-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.section-counter {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.project-selector-wrapper {
  position: relative;
}

.project-dropdown {
  background-color: var(--bg-surface);
  cursor: pointer;
}

/* Providers Showcase Strip */
.providers-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.provider-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}

.chip-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.provider-chip-claude .chip-indicator { background-color: var(--provider-claude); }
.provider-chip-codex .chip-indicator { background-color: var(--provider-codex); }
.provider-chip-omp .chip-indicator { background-color: var(--provider-omp); }
.provider-chip-pi .chip-indicator { background-color: var(--provider-pi); }

/* Agent Cards List */
.agent-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-card:hover {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.agent-card:active {
  transform: scale(0.99);
}

.agent-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agent-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-card-tags {
  display: flex;
  align-items: center;
  gap: 6px;
}

.provider-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  letter-spacing: 0.3px;
}

.provider-tag-claude { background: var(--provider-claude-bg); color: var(--provider-claude); }
.provider-tag-codex { background: var(--provider-codex-bg); color: var(--provider-codex); }
.provider-tag-omp { background: var(--provider-omp-bg); color: var(--provider-omp); }
.provider-tag-pi { background: var(--provider-pi-bg); color: var(--provider-pi); }

.agent-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
}

.agent-status-badge.status-running {
  color: var(--status-running);
}

.agent-status-badge.status-idle {
  color: var(--status-idle);
}

.agent-status-badge.status-error {
  color: var(--status-error);
}

.agent-status-badge.status-permission {
  color: var(--status-warning);
}

.agent-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.agent-project-path {
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 16px;
  text-align: center;
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-md);
}

.empty-icon {
  color: var(--text-muted);
  margin-bottom: 10px;
}

.empty-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-subtext {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   3. Agent Conversation View
   ========================================================================== */
.conversation-panel {
  padding: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.conversation-header {
  height: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 10;
}

.back-btn {
  margin-right: 6px;
}

.conversation-heading-info {
  flex: 1;
  min-width: 0;
}

.conversation-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.conversation-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.provider-pill {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
}

.conversation-status-line {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
}

.status-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--status-idle);
}

.status-indicator-dot.active {
  background-color: var(--status-running);
  box-shadow: 0 0 8px var(--status-running);
}

.status-indicator-dot.permission {
  background-color: var(--status-warning);
  box-shadow: 0 0 8px var(--status-warning);
  animation: pulse-warning 1.8s infinite ease-in-out;
}

@keyframes pulse-warning {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(1.15); }
}

.conversation-status-text {
  color: var(--text-muted);
}

/* Transcript Container */
.transcript-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

/* Message Bubbles */
.message-item {
  display: flex;
  flex-direction: column;
  max-width: 92%;
  animation: fadeIn var(--transition-fast);
}

.message-item.role-user {
  align-self: flex-end;
}

.message-item.role-assistant, 
.message-item.role-tool, 
.message-item.role-reasoning,
.message-item.role-status, 
.message-item.role-error {
  align-self: flex-start;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 0 4px;
}

.message-bubble {
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

/* User Message */
.role-user .message-bubble {
  background-color: var(--accent-mint);
  color: var(--text-inverse);
  font-weight: 500;
  border-bottom-right-radius: var(--radius-xs);
  box-shadow: 0 2px 8px var(--accent-mint-glow);
}

/* Assistant Message */
.role-assistant .message-bubble {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-xs);
}

/* Tool Execution Message */
.role-tool .message-bubble {
  background-color: var(--bg-surface-elevated);
  border: 1px dashed var(--border-medium);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
  border-left: 3px solid var(--accent-cyan);
}

/* Status & System Update Message */
.role-status .message-bubble {
  background-color: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 11.5px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  align-self: center;
}

/* Error Message */
.role-error .message-bubble {
  background-color: var(--status-error-bg);
  border: 1px solid var(--status-error-border);
  color: var(--status-error);
}

/* Reasoning / Thinking Message */
.role-reasoning .message-bubble {
  background-color: rgba(168, 85, 247, 0.08);
  border: 1px dashed rgba(168, 85, 247, 0.35);
  border-left: 3px solid #a855f7;
  color: var(--text-secondary);
  font-size: 12.5px;
}

/* Pending Optimistic User Message */
.role-user.pending .message-bubble {
  opacity: 0.72;
  box-shadow: none;
}

/* Permission Prompts Container & Cards */
.permission-container {
  padding: 10px 14px;
  background-color: var(--bg-shell);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 40vh;
  overflow-y: auto;
}

.permission-card {
  background-color: var(--bg-surface-elevated);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-left: 4px solid var(--status-warning);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  animation: fadeIn var(--transition-fast);
}

.permission-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.permission-title-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.permission-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--status-warning);
  text-transform: uppercase;
}

.permission-desc {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  background-color: var(--bg-surface-input);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
}

.permission-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.permission-actions .btn {
  font-size: 12px;
  padding: 6px 12px;
}

.permission-error-banner {
  font-size: 11.5px;
  color: var(--status-error);
  background-color: var(--status-error-bg);
  border: 1px solid var(--status-error-border);
  border-radius: var(--radius-xs);
  padding: 4px 8px;
}

/* Formatted Code inside Messages */
.code-block {
  margin: 8px 0;
  background-color: #05070a;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.code-header {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background-color: rgba(255, 255, 255, 0.04);
  padding: 4px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.code-block code {
  display: block;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  color: #e2e8f0;
  tab-size: 2;
  white-space: pre;
}

.inline-code {
  font-family: var(--font-mono);
  font-size: 12px;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent-mint);
  padding: 1px 5px;
  border-radius: 4px;
}

.streaming-cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  background-color: var(--accent-mint);
  margin-left: 3px;
  vertical-align: middle;
  animation: blink 0.9s infinite;
}

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

/* Composer Bar */
.composer-container {
  padding: 10px 12px;
  background-color: var(--bg-shell);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.composer-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer-input-wrapper {
  flex: 1;
  background-color: var(--bg-surface-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.composer-input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-mint-subtle);
}

.composer-textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  resize: none;
  max-height: 120px;
  min-height: 22px;
}

.composer-textarea:focus {
  outline: none;
}

.composer-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: var(--accent-mint);
  color: var(--text-inverse);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px var(--accent-mint-glow);
  flex-shrink: 0;
}

.composer-send-btn:hover:not(:disabled) {
  background-color: var(--accent-mint-hover);
}

.composer-send-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.composer-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.composer-error {
  font-size: 12px;
  color: var(--status-error);
  padding: 2px 4px;
}

/* ==========================================================================
   4. Desktop Remote Entry View
   ========================================================================== */
.desktop-entry-container {
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.desktop-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent-cyan);
  background-color: var(--accent-cyan-subtle);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  align-self: flex-start;
}

.desktop-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: -8px;
}

.desktop-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-top: -8px;
}

.desktop-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.desktop-screen-preview {
  height: 150px;
  background-color: #06090e;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
}

.screen-preview-text {
  font-size: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

.desktop-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 10px;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 11px;
  color: var(--text-muted);
}

.meta-value {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.desktop-notes {
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.notes-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* Desktop Target Setup & Inline Row */
.desktop-target-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background-color: var(--bg-surface-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 4px;
}

.input-inline-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-inline-row .form-input {
  flex: 1;
}

.field-feedback {
  font-size: 11.5px;
  margin-top: 2px;
}

.field-feedback.success {
  color: var(--accent-mint);
}

.field-feedback.error {
  color: var(--status-error);
}

/* Disabled mutation state styling */
button:disabled, input:disabled, textarea:disabled, select:disabled {
  opacity: 0.45;
  cursor: not-allowed !important;
}

/* ==========================================================================
   5. Settings & Diagnostics View
   ========================================================================== */
.settings-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.settings-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-subtitle {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.card-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.card-header-flex .card-subtitle {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  padding: 4px 0;
}

.settings-toggle-row {
  align-items: center;
}

.settings-label {
  font-weight: 600;
  color: var(--text-primary);
}

.settings-sublabel {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.settings-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.settings-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.diagnostics-safety-note {
  font-size: 11px;
  color: var(--accent-mint);
  line-height: 1.4;
}

.diagnostics-log-box {
  background-color: #06090e;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.diag-entry {
  display: flex;
  gap: 8px;
  line-height: 1.4;
  word-break: break-all;
}

.diag-time {
  color: var(--text-muted);
  flex-shrink: 0;
}

.diag-entry.diag-info .diag-text { color: var(--text-secondary); }
.diag-entry.diag-warn .diag-text { color: var(--status-warning); }
.diag-entry.diag-error .diag-text { color: var(--status-error); }
.diag-entry.diag-event .diag-text { color: var(--accent-mint); }

/* ==========================================================================
   Bottom Navigation Bar
   ========================================================================== */
.bottom-nav {
  height: 58px;
  min-height: 58px;
  background-color: var(--bg-shell);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 10px;
  z-index: 20;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  color: var(--text-secondary);
}

.nav-item.active {
  color: var(--accent-mint);
}

.nav-item.active .nav-icon {
  transform: translateY(-1px);
}

.nav-icon {
  transition: transform var(--transition-fast);
}

.nav-label {
  font-size: 10.5px;
  font-weight: 600;
}

/* ==========================================================================
   Create Agent Modal / Drawer
   ========================================================================== */
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 180ms ease-out;
}

.modal-card {
  width: 100%;
  background-color: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-medium);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 20px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast-notification {
  position: absolute;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 100;
  pointer-events: none;
  animation: toastIn 180ms ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ==========================================================================
   Model Selection Chips in Create Agent Modal
   ========================================================================== */
.model-suggestions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.model-suggestion-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--trans-fast);
  user-select: none;
}

.model-suggestion-chip:hover {
  background: var(--accent-mint-subtle);
  border-color: var(--accent-mint);
  color: var(--text-primary);
}

.model-suggestion-chip.active {
  background: var(--accent-mint-subtle);
  border-color: var(--accent-mint);
  color: var(--accent-mint);
  font-weight: 600;
}

.model-suggestion-chip .chip-badge {
  font-size: 9px;
  font-family: var(--font-sans);
  font-weight: 500;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.model-suggestion-chip.active .chip-badge {
  background: var(--accent-mint-subtle);
  color: var(--accent-mint);
}

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