/* =========================================================
   LIME — Clean Light UI
   ========================================================= */

:root {
  /* Backgrounds */
  --bg-app: #f0f4ff;
  --bg-surface: #ffffff;
  --bg-elevated: #f8f9fc;
  --bg-input: #f4f5f9;
  --bg-hover: #eef0f8;
  --bg-active: #e8ecf8;

  /* Borders */
  --border: #e2e5f0;
  --border-light: #edf0f7;
  --border-focus: #6366f1;

  /* Text */
  --text: #1e1b4b;
  --text-secondary: #4b5068;
  --text-muted: #8b8fa8;
  --text-inverse: #ffffff;

  /* Accent */
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-subtle: rgba(99, 102, 241, 0.08);
  --accent-glow: rgba(99, 102, 241, 0.18);

  /* Brand */
  --lime: #22c55e;
  --lime-dark: #16a34a;
  --lime-yellow: #a3e635;

  /* Semantic */
  --green: #10b981;
  --green-subtle: rgba(16, 185, 129, 0.08);
  --red: #f43f5e;
  --red-subtle: rgba(244, 63, 94, 0.08);
  --amber: #f59e0b;
  --amber-subtle: rgba(245, 158, 11, 0.08);
  --cyan: #06b6d4;

  /* Misc */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.1);
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', Menlo, Consolas, monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text);
  height: 100vh;
  display: flex;
  overflow: hidden;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c8cdd8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a6b8; }

/* =========================================================
   App Shell — 3-Column Layout
   ========================================================= */
.app-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* ---- Icon Sidebar ---- */
.icon-sidebar {
  width: 56px;
  min-width: 56px;
  background: #1e1b4b;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  flex-shrink: 0;
  z-index: 10;
}
.sidebar-logo {
  margin-bottom: 20px;
}
.sidebar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--lime), var(--lime-dark));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  color: white;
  box-shadow: 0 2px 12px rgba(34, 197, 94, 0.35);
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.sidebar-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 10px;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.sidebar-btn:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.8);
}
.sidebar-btn.active {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-bottom {
  margin-top: auto;
  padding-top: 12px;
}

/* ---- Device Panel ---- */
.device-panel {
  width: 340px;
  min-width: 280px;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.device-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.device-panel-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.device-quick-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}
.quick-actions-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 8px;
}
.quick-actions-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.quick-actions-row .btn {
  flex: 1;
  justify-content: center;
}
.keyboard-btn {
  width: 100%;
  justify-content: center;
}

/* ---- Workspace (right) ---- */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  min-width: 0;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 48px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-brand {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text);
}
.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Status Badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c8cdd8;
  flex-shrink: 0;
}
.status-badge.connected {
  background: rgba(16, 185, 129, 0.08);
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.25);
}
.status-badge.connected .status-dot {
  background: var(--green);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}
.platform-info {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  background: var(--bg-input);
  padding: 3px 10px;
  border-radius: 100px;
  border: 1px solid var(--border);
}
.platform-info:empty { display: none; }

.user-menu {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.user-name {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.btn.small {
  padding: 4px 10px;
  font-size: 11px;
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  transition: all var(--transition);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}
.btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: #c8cdd8;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.btn.primary {
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px var(--accent-glow);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #818cf8 0%, #a5b4fc 100%);
  box-shadow: 0 4px 18px var(--accent-glow);
  transform: translateY(-1px);
}
.btn.danger {
  color: var(--red);
  border-color: transparent;
  background: var(--red-subtle);
}
.btn.danger:hover {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.2);
}
.btn.recording {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  animation: recording-pulse 2s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(244, 63, 94, 0.3);
}
@keyframes recording-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 12px rgba(244, 63, 94, 0.3); }
  50% { opacity: 0.85; box-shadow: 0 0 24px rgba(244, 63, 94, 0.4); }
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover { background: var(--bg-hover); }

/* =========================================================
   Command Bar
   ========================================================= */
.command-bar {
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.command-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
.command-search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
}
.command-bar textarea {
  flex: 1;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font-mono);
  resize: none;
  line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.command-bar textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  background: #fff;
}
.command-bar textarea::placeholder { color: #b0b5c4; }
.command-bar textarea:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.command-chips {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.chip {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.chip:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: rgba(99, 102, 241, 0.3);
}
.chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* =========================================================
   Workspace Tabs
   ========================================================= */
.workspace-tabs {
  display: flex;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  gap: 2px;
  flex-shrink: 0;
}
.workspace-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Device action buttons */
.btn.device-action-btn {
  padding: 5px 14px;
  font-size: 12px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
}
.btn.device-action-btn:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: rgba(99, 102, 241, 0.3);
}

/* Screenshot */
.screenshot-container {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg-elevated);
  position: relative;
}
.screenshot-wrapper {
  position: relative;
  display: inline-block;
}
.screenshot-container img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 20px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.12),
    0 0 0 1px rgba(0,0,0,0.06),
    0 0 0 6px #f0f0f0,
    0 0 0 7px rgba(0,0,0,0.04);
  display: block;
  cursor: crosshair;
}
.screenshot-placeholder {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 80px 24px;
  line-height: 1.7;
}

/* ---- (legacy panel-center removed — now workspace) ---- */

/* =========================================================
   Tabs
   ========================================================= */
.tabs {
  display: flex;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  gap: 2px;
  flex-shrink: 0;
}
.tab {
  padding: 10px 18px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-muted);
  transition: all var(--transition);
  margin-bottom: -1px;
  user-select: none;
}
.tab:hover { color: var(--text-secondary); background: rgba(99, 102, 241, 0.04); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: #fff;
}

.tab-content {
  flex: 1;
  overflow: auto;
  display: none;
}
.tab-content.active { display: block; }

/* =========================================================
   Log — Structured Table
   ========================================================= */
.log {
  padding: 8px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--bg-elevated);
  flex: 1;
  overflow-y: auto;
}

/* Structured log row */
.log-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.02);
  transition: background 0.1s;
}
.log-row:hover {
  background: rgba(99, 102, 241, 0.03);
}
.log-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 42px;
  font-variant-numeric: tabular-nums;
}
.log-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 52px;
  text-align: center;
}
.badge-info { background: rgba(245, 158, 11, 0.1); color: #d97706; }
.badge-success { background: rgba(16, 185, 129, 0.1); color: #059669; }
.badge-error { background: rgba(244, 63, 94, 0.1); color: #e11d48; }
.badge-cmd { background: rgba(99, 102, 241, 0.1); color: var(--accent); }
.badge-agent { background: rgba(6, 182, 212, 0.1); color: #0891b2; }
.badge-ready { background: rgba(16, 185, 129, 0.1); color: #059669; }
.badge-dim { background: var(--bg-input); color: var(--text-muted); }
.log-msg {
  flex: 1;
  color: var(--text-secondary);
  min-width: 0;
  word-break: break-word;
}
.log-row.dim .log-msg { color: var(--text-muted); }
.log-row.cmd {
  background: #fff;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 8px;
}
.log-row.cmd .log-msg { color: var(--text); font-weight: 600; }

/* Legacy support */
.log-entry {
  padding: 4px 16px;
  border-left: 3px solid transparent;
}
.log-entry.success { color: #059669; border-left-color: var(--green); background: rgba(16, 185, 129, 0.05); }
.log-entry.error { color: #e11d48; border-left-color: var(--red); background: rgba(244, 63, 94, 0.04); }
.log-entry.info { color: #d97706; border-left-color: var(--amber); background: rgba(245, 158, 11, 0.05); }
.log-entry.dim { color: var(--text-muted); }
.log-entry.cmd {
  color: var(--text);
  font-weight: 700;
  padding: 8px 16px 4px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  border-left-color: var(--accent);
  background: #fff;
}

/* =========================================================
   Elements Table
   ========================================================= */
.filter-bar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.filter-bar input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 12.5px;
  font-family: var(--font-sans);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-bar input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.filter-bar input::placeholder { color: var(--text-muted); }

.elements-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.elements-table th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.elements-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.elements-table tr:hover { background: rgba(99, 102, 241, 0.04); }
.elements-table .clickable {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}
.elements-table .clickable:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

/* =========================================================
   Source & Code viewers
   ========================================================= */
.source-viewer {
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  line-height: 1.7;
}
.code-viewer {
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: pre;
  overflow-x: auto;
  color: var(--text);
  background: var(--bg-elevated);
  line-height: 1.7;
}

/* =========================================================
   Dialogs & Overlays
   ========================================================= */
.hidden { display: none !important; }

.dialog-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.dialog-overlay.hidden { display: none; }

.dialog {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 440px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(99, 102, 241, 0.08), 0 8px 24px rgba(0, 0, 0, 0.04);
}
.dialog h2 {
  margin-bottom: 6px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}
.dialog p {
  color: var(--text-muted);
  margin-bottom: 6px;
  font-size: 13.5px;
  line-height: 1.5;
}
.dialog .btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 24px;
}
.dialog .btn-row .btn { flex: 1; padding: 10px; justify-content: center; }

/* =========================================================
   Setup Wizard — Light Theme (matches auth card)
   ========================================================= */
#connectDialog {
  z-index: 1050;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8ecf8 30%, #f5f0ff 60%, #eef2ff 100%);
  backdrop-filter: none;
}
#connectDialog::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 40%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(56, 189, 248, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(168, 85, 247, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

.setup-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  padding: 40px 40px 32px;
  background: #fff;
  border: 1px solid #e2e5f0;
  border-radius: 24px;
  box-shadow:
    0 20px 60px rgba(99, 102, 241, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.04),
    0 1px 0 rgba(255, 255, 255, 0.8) inset;
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
}

.setup-brand {
  margin-bottom: 24px;
}
.setup-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #1e1b4b;
  margin: 0;
}
.setup-tagline {
  font-size: 13px;
  color: #8b8fa8;
  margin-top: 6px;
  letter-spacing: 0.2px;
}

/* Step indicators */
.setup-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
}
.setup-step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  transition: all 0.25s ease;
}
.setup-step .step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: #f4f5f9;
  color: #9398a8;
  border: 2px solid #e2e5f0;
  transition: all 0.25s ease;
}
.setup-step .step-label {
  font-size: 12px;
  font-weight: 600;
  color: #9398a8;
  transition: color 0.25s ease;
}
.setup-step.active .step-num {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.setup-step.active .step-label {
  color: #1e1b4b;
}
.setup-step.done .step-num {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}
.setup-step.done .step-label {
  color: #6b7084;
}
.setup-step-line {
  width: 32px;
  height: 2px;
  background: #e2e5f0;
  border-radius: 1px;
  margin: 0 4px;
  transition: background 0.25s ease;
}
.setup-step-line.done {
  background: #10b981;
}

/* Panels */
.setup-panel {
  text-align: left;
  min-height: 120px;
}
.setup-panel-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e1b4b;
  margin-bottom: 18px;
  text-align: center;
}

/* Connection mode cards */
.setup-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.setup-option {
  display: block;
  cursor: pointer;
}
.setup-option input[type="radio"] {
  display: none;
}
.setup-option-content {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 2px solid #e8eaf2;
  border-radius: 14px;
  background: #fafbfe;
  transition: all 0.2s ease;
}
.setup-option-content:hover {
  border-color: #c7cadf;
  background: #f4f5fb;
}
.setup-option input:checked + .setup-option-content {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.04);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}
.setup-option-icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f1f8;
  border-radius: 12px;
  flex-shrink: 0;
}
.setup-option input:checked + .setup-option-content .setup-option-icon {
  background: rgba(99, 102, 241, 0.1);
}
.setup-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.setup-option-name {
  font-size: 14px;
  font-weight: 700;
  color: #1e1b4b;
}
.setup-option-desc {
  font-size: 12px;
  color: #8b8fa8;
  line-height: 1.4;
}

/* Setup fields (light theme) */
.setup-field {
  margin-bottom: 14px;
  text-align: left;
}
.setup-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #6b7084;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.setup-field input,
.setup-field select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #dfe2ea;
  border-radius: 10px;
  background: #f8f9fc;
  color: #1e1b4b;
  font-size: 13px;
  font-family: var(--font-sans);
  transition: all 0.25s ease;
}
.setup-field input:focus,
.setup-field select:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  background: #fff;
}
.setup-field input::placeholder {
  color: #b0b5c4;
}
.setup-field select option {
  background: #fff;
  color: #1e1b4b;
}
.setup-field-row {
  display: flex;
  gap: 12px;
}

.setup-scan-btn {
  width: 100%;
  padding: 10px 16px;
  margin-bottom: 12px;
  justify-content: center;
  background: rgba(99, 102, 241, 0.06);
  border: 1px dashed #6366f1;
  color: #6366f1;
  font-weight: 700;
  font-size: 13px;
  border-radius: 10px;
}
.setup-scan-btn:hover {
  background: #6366f1;
  border-style: solid;
  color: #fff;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.25);
}

/* Config sections */
.setup-config {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Setup agent status (light theme override) */
#setupAgentStatusBox {
  background: #f8f9fc;
  border-color: #dfe2ea;
}
#setupAgentStatusBox .status-dot {
  background: #9398a8;
}
#setupAgentStatusBox.connected {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.04);
}
#setupAgentStatusBox.connected .status-dot {
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}
#setupAgentStatusLabel {
  color: #1e1b4b;
  font-size: 13px;
}

/* Summary card */
.setup-summary {
  background: #f8f9fc;
  border: 1px solid #e8eaf2;
  border-radius: 14px;
  padding: 20px 24px;
  text-align: left;
  margin-bottom: 16px;
}
.setup-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f0f1f5;
  font-size: 13px;
}
.setup-summary-row:last-child {
  border-bottom: none;
}
.setup-summary-label {
  color: #8b8fa8;
  font-weight: 500;
}
.setup-summary-value {
  color: #1e1b4b;
  font-weight: 600;
}

/* Navigation */
.setup-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  gap: 10px;
}
.setup-nav-btn {
  min-width: 90px;
}
.setup-nav .btn.primary {
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 24px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.2);
  transition: all 0.25s ease;
}
.setup-nav .btn.primary:hover {
  background: linear-gradient(135deg, #818cf8 0%, #a5b4fc 100%);
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
}
.setup-nav .btn:not(.primary) {
  background: #f4f5f9;
  border: 1px solid #e2e5f0;
  color: #6b7084;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 18px;
}
.setup-nav .btn:not(.primary):hover {
  background: #ecedf5;
  color: #1e1b4b;
}

/* User bar at bottom of setup card */
.setup-user-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #f0f1f5;
}
.setup-user-name {
  font-size: 12px;
  color: #6b7084;
  font-weight: 500;
}
.setup-logout-link {
  font-size: 12px;
  color: #6366f1;
  font-weight: 600;
  text-decoration: none;
}
.setup-logout-link:hover {
  text-decoration: underline;
  color: #818cf8;
}

/* Connect status (light override) */
#connectDialog .connect-status {
  color: #6b7084;
  font-size: 13px;
  padding: 12px;
  border-radius: 10px;
}
#connectDialog .connect-status.error {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.06);
}

/* Discovered devices light theme override in setup */
#connectDialog .discovered-devices {
  background: #f8f9fc;
  border-color: #e2e5f0;
  border-radius: 10px;
}
#connectDialog .device-item {
  border-bottom-color: #f0f1f5;
}
#connectDialog .device-item:hover {
  background: rgba(99, 102, 241, 0.04);
}
#connectDialog .device-item-name {
  color: #1e1b4b;
}
#connectDialog .device-item-meta {
  color: #8b8fa8;
}
#connectDialog .device-group-header {
  background: #f0f1f8;
  border-bottom-color: #e8eaf2;
  color: #6366f1;
}
#connectDialog .discovery-empty {
  color: #8b8fa8;
}

/* Setup wizard — mobile */
@media (max-width: 768px) {
  .setup-card {
    max-width: 100%;
    margin: 12px;
    padding: 28px 20px 24px;
    border-radius: 20px;
    max-height: 95vh;
  }
  .setup-brand { margin-bottom: 16px; }
  .setup-title { font-size: 20px; }
  .setup-tagline { font-size: 12px; }
  .setup-steps { margin-bottom: 20px; }
  .setup-step .step-label { display: none; }
  .setup-step-line { width: 24px; }
  .setup-option-content { padding: 12px 14px; }
  .setup-option-icon { width: 38px; height: 38px; font-size: 20px; }
  .setup-option-name { font-size: 13px; }
  .setup-option-desc { font-size: 11px; }
  .setup-panel-title { font-size: 14px; }
  .setup-field input,
  .setup-field select {
    font-size: 16px; /* prevents iOS zoom */
    padding: 13px 14px;
  }
  .setup-field-row { flex-direction: column; gap: 0; }
  .setup-nav { gap: 6px; }
  .setup-nav .btn { padding: 10px 14px; font-size: 13px; min-width: 70px; }
  .setup-summary-row { font-size: 12px; }
}
@media (max-width: 360px) {
  .setup-card {
    margin: 6px;
    padding: 20px 14px 18px;
  }
  .setup-option-content { gap: 10px; padding: 10px 12px; }
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.connect-status {
  padding: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}
.connect-status.error {
  color: var(--red);
  background: var(--red-subtle);
}

/* =========================================================
   Settings Dialog
   ========================================================= */
.settings-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}
.settings-overlay.hidden { display: none; }

.settings-dialog {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 36px;
  width: 540px;
  box-shadow: var(--shadow-lg);
}
.settings-dialog h2 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 24px;
  color: var(--text);
  letter-spacing: -0.3px;
}

.settings-section {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-section:first-of-type { margin-top: 0; }

.settings-field {
  margin-bottom: 14px;
  text-align: left;
}
.settings-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}
.settings-field label .hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}
.settings-field input,
.settings-field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-mono);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.settings-field input:focus,
.settings-field select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.settings-field input::placeholder { color: var(--text-muted); }
.settings-field select option { background: #fff; color: var(--text); }

.settings-row {
  display: flex;
  gap: 12px;
  margin-bottom: 0;
}
.settings-row .settings-field {
  flex: 1;
}

.settings-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 16px;
}
.checkbox-label {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 500;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Device Discovery */
.discover-btn {
  width: 100%;
  padding: 10px 16px;
  margin-bottom: 12px;
  justify-content: center;
  background: var(--accent-subtle);
  border: 1px dashed var(--accent);
  color: var(--accent-hover);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.2px;
}
.discover-btn:hover {
  background: var(--accent);
  border-style: solid;
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.discovered-devices {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
}
.discovered-devices:empty {
  display: none;
}
.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--transition);
}
.device-item:last-child {
  border-bottom: none;
}
.device-item:hover {
  background: var(--bg-hover);
}
.device-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.device-item-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-item-state {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.device-item-state.booted {
  background: var(--green-subtle);
  color: var(--green);
}
.device-item-state.shutdown {
  background: var(--bg-elevated);
  color: var(--text-muted);
}
.device-item-state.available {
  background: var(--accent-subtle);
  color: var(--accent);
}
.device-group-header {
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
}
.discovery-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* Agent Status */
.agent-status-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
  margin-bottom: 12px;
}
.agent-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}
.agent-status-indicator .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.agent-status-box.connected .status-dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.agent-status-box.connected {
  border-color: rgba(52, 211, 153, 0.3);
}
.agent-instructions {
  margin-bottom: 14px;
}
.agent-instructions p {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.agent-instructions code {
  display: block;
  padding: 8px 12px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent-hover);
  word-break: break-all;
  cursor: pointer;
  transition: background var(--transition);
}
.agent-instructions code:hover {
  background: var(--bg-hover);
}

.settings-saved {
  font-size: 13px;
  color: var(--green);
  margin-top: 8px;
  display: none;
  font-weight: 600;
}

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* =========================================================
   Type Input Dialog (refined)
   ========================================================= */
#typeDialog .dialog {
  width: 400px;
  padding: 28px 32px;
  text-align: left;
}
#typeDialog .dialog h2 {
  font-size: 16px;
  margin-bottom: 4px;
  text-align: left;
}
#typeDialog .dialog p {
  text-align: left;
}
#typeDialog input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-mono);
  transition: border-color var(--transition), box-shadow var(--transition);
}
#typeDialog input[type="text"]:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* =========================================================
   Highlight overlay
   ========================================================= */
.highlight-overlay {
  position: absolute;
  border: 3px solid var(--red);
  background: rgba(248, 113, 113, 0.15);
  border-radius: 4px;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.5);
}

/* =========================================================
   Code toolbar
   ========================================================= */
.code-toolbar {
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.code-toolbar input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}
.code-toolbar input:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* =========================================================
   Auth Card — Login / Register (Light Theme)
   ========================================================= */
#loginDialog {
  z-index: 1100;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8ecf8 30%, #f5f0ff 60%, #eef2ff 100%);
  backdrop-filter: none;
}
#loginDialog::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 40%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(56, 189, 248, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(168, 85, 247, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 44px 40px;
  background: #fff;
  border: 1px solid #e2e5f0;
  border-radius: 24px;
  box-shadow:
    0 20px 60px rgba(99, 102, 241, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.04),
    0 1px 0 rgba(255, 255, 255, 0.8) inset;
  text-align: center;
}

.auth-brand {
  margin-bottom: 32px;
}
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--lime) 0%, var(--lime-dark) 40%, var(--lime-yellow) 100%);
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.25);
  letter-spacing: -1px;
}
.auth-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #1e1b4b;
  margin: 0;
}
.auth-tagline {
  font-size: 13px;
  color: #8b8fa8;
  margin-top: 6px;
  letter-spacing: 0.2px;
}

/* Tabs */
.auth-tabs {
  display: flex;
  background: #f4f5f9;
  border: 1px solid #e8eaf0;
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 28px;
  gap: 4px;
}
.auth-tab {
  flex: 1;
  padding: 11px 0;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  border: none;
  background: transparent;
  color: #9398a8;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.25s ease;
}
.auth-tab:hover {
  color: #6366f1;
  background: rgba(99, 102, 241, 0.05);
}
.auth-tab.active {
  background: #6366f1;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

/* Form */
.auth-form {
  text-align: left;
}
.auth-field {
  margin-bottom: 18px;
}
.auth-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #6b7084;
  margin-bottom: 7px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.auth-field input {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid #dfe2ea;
  border-radius: 10px;
  background: #f8f9fc;
  color: #1e1b4b;
  font-size: 14px;
  font-family: var(--font-sans);
  transition: all 0.25s ease;
}
.auth-field input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1), 0 0 16px rgba(99, 102, 241, 0.06);
  background: #fff;
}
.auth-field input.error {
  border-color: #f43f5e;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.08);
}
.auth-field input::placeholder {
  color: #b0b5c4;
  font-size: 13px;
}
.auth-field-error {
  font-size: 11px;
  color: #f43f5e;
  margin-top: 5px;
  min-height: 0;
}

/* Captcha widget */
.auth-captcha {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  min-height: 0;
}
.auth-captcha:empty {
  display: none;
}

/* Status message */
.auth-status {
  font-size: 12px;
  min-height: 20px;
  margin-bottom: 10px;
  text-align: center;
}
.auth-status.error { color: #f43f5e; }
.auth-status.success { color: #10b981; }
.auth-status.loading { color: #6366f1; }

/* Submit button */
.auth-submit {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.25s ease;
  margin-top: 6px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.2);
  letter-spacing: 0.3px;
}
.auth-submit:hover {
  background: linear-gradient(135deg, #818cf8 0%, #a5b4fc 100%);
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.3);
  transform: translateY(-1px);
}
.auth-submit:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

/* Forgot password link */
.auth-forgot {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
}
.auth-forgot a {
  color: #6366f1;
  text-decoration: none;
  font-weight: 600;
}
.auth-forgot a:hover {
  text-decoration: underline;
  color: #818cf8;
}

/* Reset form info */
.auth-reset-info {
  font-size: 13px;
  color: #6b7084;
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* =========================================================
   Status Bar
   ========================================================= */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 28px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
}
.status-bar-left,
.status-bar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.status-bar-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}
.status-bar-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c8cdd8;
}
.status-bar.connected .status-bar-dot {
  background: var(--green);
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
}

/* =========================================================
   Responsive — Tablet (≤ 900px)
   ========================================================= */
@media (max-width: 900px) {
  .device-panel { width: 260px; min-width: 220px; }
  .topbar { padding: 0 12px; }
  .command-bar { padding: 8px 12px; }
  .topbar-right .btn { padding: 6px 10px; font-size: 11px; }
}

/* =========================================================
   Responsive — Mobile (≤ 768px)
   ========================================================= */
@media (max-width: 768px) {
  body {
    overflow: auto;
    height: auto;
    min-height: 100vh;
  }

  .app-shell {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .icon-sidebar {
    flex-direction: row;
    width: 100%;
    min-width: 0;
    height: 48px;
    padding: 0 8px;
    gap: 4px;
    overflow-x: auto;
  }
  .sidebar-logo { margin-bottom: 0; margin-right: 8px; }
  .sidebar-nav { flex-direction: row; gap: 2px; }
  .sidebar-bottom { margin-top: 0; margin-left: auto; padding-top: 0; }

  .device-panel {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 50vh;
  }

  .workspace { min-height: 400px; }

  /* Top bar */
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
    gap: 6px;
  }
  .topbar-left { gap: 8px; }
  .topbar-brand { font-size: 14px; }
  .status-badge { font-size: 10px; padding: 3px 8px; }
  .platform-info { display: none; }
  .topbar-right { gap: 4px; flex-wrap: wrap; }
  .topbar-right .btn { padding: 6px 10px; font-size: 11px; }
  .user-menu { margin-left: 4px; padding-left: 8px; gap: 4px; }
  .user-name { font-size: 11px; }

  /* Command bar */
  .command-bar { padding: 8px 12px; }
  .command-bar textarea {
    font-size: 14px;
    padding: 10px 12px 10px 36px;
    min-height: 42px;
  }
  .command-chips { gap: 4px; }
  .chip { font-size: 10px; padding: 4px 8px; }

  /* Screenshot */
  .screenshot-container { padding: 8px; }
  .screenshot-placeholder { padding: 40px 16px; }

  /* Tabs */
  .workspace-tabs { padding: 0 8px; overflow-x: auto; }
  .tab { padding: 10px 12px; font-size: 11.5px; white-space: nowrap; }

  /* Log */
  .log-row { padding: 4px 10px; gap: 6px; }
  .log-time { min-width: 36px; font-size: 10px; }
  .log-badge { font-size: 8px; min-width: 42px; }

  /* Status bar */
  .status-bar { padding: 0 10px; font-size: 10px; }

  /* Settings dialog */
  .settings-dialog {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0;
    padding: 20px;
  }
  .settings-overlay { align-items: flex-start; }
  .settings-field input,
  .settings-field select {
    font-size: 16px;
    padding: 12px;
  }
  .settings-row { flex-direction: column; gap: 0; }

  /* Type dialog */
  #typeDialog .dialog {
    width: calc(100% - 32px) !important;
    padding: 24px 20px !important;
  }
  #typeDialog input[type="text"] { font-size: 16px; padding: 12px; }

  /* Elements table */
  .elements-table { font-size: 11px; }
  .elements-table th { padding: 8px 10px; font-size: 9px; }
  .elements-table td { padding: 6px 10px; font-size: 10px; max-width: 120px; }
}

/* =========================================================
   Responsive — Auth Card Mobile (≤ 480px)
   ========================================================= */
@media (max-width: 480px) {
  .auth-card {
    max-width: 100%;
    margin: 16px;
    padding: 32px 24px;
    border-radius: 20px;
  }
  .auth-logo {
    width: 52px;
    height: 52px;
    font-size: 24px;
    border-radius: 14px;
  }
  .auth-title { font-size: 22px; }
  .auth-tagline { font-size: 12px; }
  .auth-field input {
    padding: 14px 16px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  .auth-field input::placeholder { font-size: 14px; }
  .auth-submit {
    padding: 15px;
    font-size: 15px;
  }
  .auth-tab {
    padding: 12px 0;
    font-size: 14px;
  }
}

@media (max-width: 360px) {
  .auth-card {
    margin: 8px;
    padding: 28px 18px;
  }
}

/* =========================================================
   Touch-friendly: ensure min touch target sizes
   ========================================================= */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .tab { min-height: 44px; }
  .device-item { min-height: 48px; padding: 10px 14px; }
  .setup-option-content { min-height: 60px; }
  .auth-field input,
  .setup-field input,
  .setup-field select,
  .settings-field input,
  .settings-field select { min-height: 48px; }
}
