:root {
  --bg-canvas: #0b0e14;
  --bg-surface: #121722;
  --bg-elevated: #182030;
  --bg-hover: #1f293d;
  --border-subtle: #232d42;
  --border-strong: #33415c;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #f59e0b;
  --accent-hover: #fbbf24;
  --accent-text: #090d16;
  --status-ok: #10b981;
  --status-err: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

html,
body {
  height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  letter-spacing: 0.01em;
}

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #2b364d;
  border-radius: 3px;
}

/* App Shell */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header */
.app-header {
  height: 58px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mobile-menu-btn {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  padding: 0;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.brand-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Segmented View Switcher */
.view-switch {
  display: inline-flex;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.btn {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

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

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

.btn-seg {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-seg:hover {
  color: var(--text-primary);
}

.btn-seg.active {
  background: var(--bg-elevated);
  color: var(--accent);
}

.btn-seg-icon {
  width: 34px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 700;
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.22);
  color: #ffffff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  padding: 0;
  flex-shrink: 0;
}

.btn-icon-md {
  width: 38px;
  height: 38px;
  padding: 0;
  flex-shrink: 0;
}

.btn-icon-lg {
  width: 44px;
  height: 44px;
  padding: 0;
  flex-shrink: 0;
}

.btn-icon-pill {
  height: 38px;
  padding: 0 11px;
  gap: 6px;
  flex-shrink: 0;
}

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

.icon-spin {
  animation: iconSpin 0.9s linear infinite;
}

.bridge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  flex-shrink: 0;
}

.bridge-dot.connected {
  background: var(--status-ok);
}

.btn-primary .bridge-dot {
  border: 1.5px solid rgba(9, 13, 22, 0.75);
}

/* Dropdown */
.dropdown-wrapper {
  position: relative;
}

.agent-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 6px;
  min-width: 240px;
  z-index: 200;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  gap: 2px;
}

.agent-dropdown.open {
  display: flex;
}

.dropdown-item {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.dropdown-item:hover {
  background: var(--bg-hover);
}

.dropdown-item.active {
  background: var(--bg-elevated);
  color: var(--accent);
}

/* Workspace Layout */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: 304px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

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

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.bridge-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bridge-state-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

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

.detected-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.detected-tab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.detected-tab-info {
  min-width: 0;
  flex: 1;
}

.detected-tab-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detected-tab-url {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agents-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-card {
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.agent-card.active {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.06);
}

.agent-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.agent-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.agent-card-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.agent-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

.agent-card-actions-left {
  display: flex;
  gap: 6px;
}

.empty-roster {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 12px 0;
}

/* Main Chat Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-canvas);
}

.context-bar {
  padding: 10px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.context-bar strong {
  color: var(--text-primary);
}

.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.onboarding-card {
  max-width: 860px;
  width: 100%;
  margin: 12px auto 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.onboarding-card h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.onboarding-card p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.onboarding-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Message Cards */
.msg-card {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.msg-card.user-msg {
  background: var(--bg-elevated);
  border-color: rgba(245, 158, 11, 0.35);
}

.msg-card.system-msg {
  background: transparent;
  border-color: var(--border-subtle);
  padding: 12px 16px;
}

.msg-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.msg-sender {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.msg-sender-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.msg-sender-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.msg-time {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.msg-body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.msg-body p + p {
  margin-top: 8px;
}

.msg-body ul,
.msg-body ol {
  margin: 8px 0 8px 20px;
}

.msg-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  padding: 2px 5px;
  border-radius: 4px;
}

.msg-body pre {
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0;
}

.msg-body pre code {
  border: none;
  padding: 0;
  background: transparent;
}

.msg-attachment {
  margin-top: 12px;
  max-width: 320px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.msg-attachment.file-only {
  max-width: none;
  width: fit-content;
  border: none;
  overflow: visible;
}

.msg-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  max-width: 100%;
}

.msg-file-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.msg-attachment img {
  width: 100%;
  display: block;
}

/* Composer */
.composer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 12px 24px 16px;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.composer.drag-over {
  background: rgba(245, 158, 11, 0.08);
  border-top-color: var(--accent);
}

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

.composer-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mention-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.mention-label {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.mention-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.mention-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.attachment-bar {
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  width: fit-content;
  max-width: 100%;
}

.attachment-bar.active {
  display: flex;
}

.attachment-bar img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.attachment-file-badge {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.attachment-name {
  font-size: 12px;
  color: #cbd5e1;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-recording-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}

.voice-recording-bar.active {
  display: flex;
}

.voice-recording-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

@keyframes voicePulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.82);
  }
}

.voice-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  animation: voicePulse 1.1s ease-in-out infinite;
}

.voice-timer {
  font-size: 12px;
  font-weight: 700;
  color: #fca5a5;
  flex-shrink: 0;
}

.voice-status-text {
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-recording-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

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

.icon-btn {
  width: 44px;
  height: 44px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.icon-btn.recording {
  background: #dc2626;
  border-color: #ef4444;
  color: #ffffff;
}

.command-input {
  flex: 1;
  height: 44px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 14px;
  color: var(--text-primary);
  min-width: 0;
}

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

.send-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  flex-shrink: 0;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.78);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.modal-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  color: var(--accent);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

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

.form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-field input,
.form-field select,
.form-field textarea {
  background: var(--bg-canvas);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-primary);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.provider-box {
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-secondary);
}

.step-list strong {
  color: var(--text-primary);
}

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

.copy-row input {
  flex: 1;
}

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.login-connect-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-connect-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.login-connect-status {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.login-connect-status.ok {
  color: #34d399;
}

.login-connect-status.warn {
  color: #fbbf24;
}

/* Toast */
.toast {
  display: none;
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 1500;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13px;
  max-width: 360px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.toast.open {
  display: block;
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.6);
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.6);
}

/* Built-In In-App Browser Workspace */
#browserWorkspaceModal {
  padding: 10px;
}

.browser-modal-panel {
  max-width: 1440px;
  width: 100%;
  height: 95vh;
  max-height: 95vh;
}

.connector-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}

.connector-badge.ready {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.45);
  color: #34d399;
}

.connector-badge.login {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fbbf24;
}

.browser-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.browser-nav-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.browser-url-form {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 220px;
}

.browser-url-form input {
  flex: 1;
  min-width: 0;
  background: var(--bg-canvas);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-primary);
}

.browser-quick-sites {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.browser-viewport-wrap {
  flex: 1;
  min-height: 0;
  background: #06080c;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
}

.browser-viewport-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 13px;
}

.browser-stream-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  aspect-ratio: 1200 / 760;
  object-fit: contain;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  cursor: pointer;
  display: none;
  user-select: none;
}

.browser-stream-img.active {
  display: block;
}

.browser-stream-img:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.browser-quick-bar {
  padding: 12px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex-shrink: 0;
}

.browser-hint {
  font-size: 13px;
  color: var(--text-secondary);
}

.browser-quick-form {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: none;
}

.browser-quick-form input {
  flex: 1;
  min-width: 0;
  height: 44px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-size: 14px;
  color: var(--text-primary);
}

.browser-quick-form input:focus {
  border-color: var(--accent);
  outline: none;
}

.browser-quick-form .btn-icon-lg {
  width: 44px;
  height: 44px;
  padding: 0;
  flex-shrink: 0;
}

/* Mobile Drawer Backdrop */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 860px) {
  .app-header {
    padding: 0 10px;
    gap: 8px;
  }

  .header-left {
    flex-shrink: 0;
  }

  .mobile-menu-btn {
    display: inline-flex;
    flex-shrink: 0;
  }

  .brand-group {
    display: none;
  }

  .header-actions {
    gap: 6px;
  }

  .btn-seg:not(.btn-seg-icon) {
    padding: 5px 9px;
    font-size: 12px;
  }

  .btn:not(.btn-icon-sm):not(.btn-icon-md):not(.btn-icon-lg):not(.btn-icon-pill):not(.send-btn) {
    padding: 6px 10px;
    font-size: 12px;
  }

  .header-actions .hide-mobile {
    display: none;
  }

  .toast {
    top: 66px;
    left: 12px;
    right: 12px;
    max-width: none;
  }

  .sidebar {
    position: fixed;
    top: 58px;
    bottom: 0;
    left: 0;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: 290px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    top: 58px;
    inset: 58px 0 0 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 250;
  }

  .chat-feed {
    padding: 16px;
  }

  .composer {
    padding: 10px 12px 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .browser-modal-panel {
    height: 96vh;
    max-height: 96vh;
  }

  .browser-toolbar {
    padding: 8px 10px;
    gap: 6px;
  }

  .browser-url-form {
    min-width: 150px;
  }

  .browser-quick-bar {
    padding: 10px 12px;
  }

  .browser-quick-form {
    flex-wrap: wrap;
    width: 100%;
  }

  .browser-quick-form input {
    min-width: 180px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
