:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #fbfcfe;
  --panel-elevated: #ffffff;
  --border: #d7e0ec;
  --border-strong: #c5d2e1;
  --border-subtle: #e2e8f0;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #5f7189;
  --accent: #1d4ed8;
  --accent-soft: #1e40af;
  --reasoning: #2563eb;
  --tool-success: #059669;
  --tool-error: #dc2626;
  --control-bg: #ffffff;
  --control-border: #cbd5e1;
  --control-muted-bg: #f8fafc;
  --overlay: rgba(15, 23, 42, 0.22);
  --overlay-soft: rgba(15, 23, 42, 0.16);
  --message-user-bg: #ecf3ff;
  --message-user-border: #9abdfd;
  --branch-target-border: #2563eb;
  --branch-target-ring: rgba(37, 99, 235, 0.18);
  --message-assistant-bg: #ffffff;
  --message-system-bg: #f8faff;
  --streaming-bg: #e6f0ff;
  --streaming-text: #1e40af;
  --tool-surface: #f8fbff;
  --tool-error-surface: #fef2f2;
  --reasoning-surface: #eff6ff;
  --canvas-bg: #f9fbff;
  --canvas-border: #cfdae8;
  --tree-edge: #9fb0c7;
  --tree-edge-active: #2563eb;
  --tree-node-bg: #ffffff;
  --tree-node-active-path-bg: #e7f0ff;
  --tree-node-active-tip-bg: #d9e9ff;
  --tree-node-stroke: #a8b7ca;
  --tree-node-active-stroke: #2563eb;
  --tree-node-active-tip-stroke: #1d4ed8;
  --tree-node-text: #0f172a;
  --tree-node-branch-count: #1d4ed8;
  --mobile-agent-text-font-size: 14px;
}

:root[data-theme='light'] {
  color-scheme: light;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #111315;
  --panel: #181b20;
  --panel-2: #1d2127;
  --panel-elevated: #181b20;
  --border: #2d333b;
  --border-strong: #39424d;
  --border-subtle: #3f4854;
  --text: #e5e7eb;
  --text-soft: #cbd5e1;
  --muted: #9aa4b2;
  --accent: #8ab4ff;
  --accent-soft: #b7ceff;
  --reasoning: #93b8ff;
  --tool-success: #34d399;
  --tool-error: #f87171;
  --control-bg: #15181d;
  --control-border: #434c58;
  --control-muted-bg: #20252c;
  --overlay: rgba(8, 10, 12, 0.72);
  --overlay-soft: rgba(8, 10, 12, 0.56);
  --message-user-bg: #222831;
  --message-user-border: #3d4754;
  --branch-target-border: #f59e0b;
  --branch-target-ring: rgba(245, 158, 11, 0.25);
  --message-assistant-bg: transparent;
  --message-system-bg: #24272e;
  --streaming-bg: #2a2f37;
  --streaming-text: #d1d5db;
  --tool-surface: #20242b;
  --tool-error-surface: #3a2628;
  --reasoning-surface: #232730;
  --canvas-bg: #14171c;
  --canvas-border: #2f3742;
  --tree-edge: #5b6674;
  --tree-edge-active: #9abdf9;
  --tree-node-bg: #1a1f26;
  --tree-node-active-path-bg: #2a3039;
  --tree-node-active-tip-bg: #323946;
  --tree-node-stroke: #46505d;
  --tree-node-active-stroke: #9abdf9;
  --tree-node-active-tip-stroke: #c4d7fb;
  --tree-node-text: #e5e7eb;
  --tree-node-branch-count: #d1ddf5;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #111315;
    --panel: #181b20;
    --panel-2: #1d2127;
    --panel-elevated: #181b20;
    --border: #2d333b;
    --border-strong: #39424d;
    --border-subtle: #3f4854;
    --text: #e5e7eb;
    --text-soft: #cbd5e1;
    --muted: #9aa4b2;
    --accent: #8ab4ff;
    --accent-soft: #b7ceff;
    --reasoning: #93b8ff;
    --tool-success: #34d399;
    --tool-error: #f87171;
    --control-bg: #15181d;
    --control-border: #434c58;
    --control-muted-bg: #20252c;
    --overlay: rgba(8, 10, 12, 0.72);
    --overlay-soft: rgba(8, 10, 12, 0.56);
    --message-user-bg: #222831;
    --message-user-border: #3d4754;
    --branch-target-border: #f59e0b;
    --branch-target-ring: rgba(245, 158, 11, 0.25);
    --message-assistant-bg: transparent;
    --message-system-bg: #24272e;
    --streaming-bg: #2a2f37;
    --streaming-text: #d1d5db;
    --tool-surface: #20242b;
    --tool-error-surface: #3a2628;
    --reasoning-surface: #232730;
    --canvas-bg: #14171c;
    --canvas-border: #2f3742;
    --tree-edge: #5b6674;
    --tree-edge-active: #9abdf9;
    --tree-node-bg: #1a1f26;
    --tree-node-active-path-bg: #2a3039;
    --tree-node-active-tip-bg: #323946;
    --tree-node-stroke: #46505d;
    --tree-node-active-stroke: #9abdf9;
    --tree-node-active-tip-stroke: #c4d7fb;
    --tree-node-text: #e5e7eb;
    --tree-node-branch-count: #d1ddf5;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#root {
  height: 100%;
  overflow: hidden;
}

.ui-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.ui-card-header,
.ui-card-content {
  padding: 10px;
}

.ui-card-title {
  margin: 0;
  font-size: 14px;
}

.ui-card-description {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.ui-input,
.ui-select,
.ui-textarea,
.ui-button {
  border: 1px solid var(--control-border);
  border-radius: 12px;
  background: var(--control-bg);
  color: var(--text);
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.35;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.ui-select,
.ui-input,
.ui-textarea {
  width: 100%;
}

.ui-input:focus,
.ui-select:focus,
.ui-textarea:focus,
.ui-button:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 52%, var(--control-border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.ui-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 620;
  letter-spacing: 0.01em;
}

.ui-button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--control-border));
}

.ui-button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.ui-button--default {
  background: linear-gradient(180deg, #2f67ea, var(--accent));
  color: #fff;
  border-color: #1e47b6;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset;
}

.ui-button--default:hover:not(:disabled) {
  background: linear-gradient(180deg, #285fdc, #1b4ccd);
}

.ui-button--secondary {
  background: var(--control-muted-bg);
}

.ui-button--outline {
  background: #ffffff;
}

.ui-button--ghost {
  background: transparent;
  border-color: transparent;
}

.ui-button--destructive {
  background: #fff7f7;
  border-color: #fecaca;
  color: #b91c1c;
}

.ui-button--sm {
  padding: 6px 10px;
  font-size: 12px;
}

.ui-button--md {
  padding: 8px 12px;
}

.ui-button--lg {
  padding: 10px 14px;
}

.ui-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--control-border);
  padding: 3px 8px;
  font-size: 11px;
  background: var(--control-muted-bg);
  color: var(--text-soft);
}

.ui-badge--success {
  color: color-mix(in srgb, var(--tool-success) 78%, var(--text));
  border-color: color-mix(in srgb, var(--tool-success) 44%, var(--control-border));
}

.ui-badge--destructive {
  color: color-mix(in srgb, var(--tool-error) 78%, var(--text));
  border-color: color-mix(in srgb, var(--tool-error) 44%, var(--control-border));
}

.mobile-app-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
  background: #ffffff;
}

.mobile-header,
.mobile-conversation-picker,
.mobile-composer,
.mobile-message-list {
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
}

.mobile-header {
  padding: 14px 16px 12px;
  display: grid;
  gap: 10px;
  background: #ffffff;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mobile-header-brand h1 {
  margin: 0;
  font-size: clamp(28px, 5.4vw, 32px);
  line-height: 1.06;
  letter-spacing: -0.035em;
  color: #111827;
  font-weight: 760;
}

.mobile-status {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mobile-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.15);
}

.mobile-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.mobile-header-icon-button {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  border: 1px solid #dbe2ec;
  background: #f8fafc;
  color: #334155;
  font-size: 19px;
  line-height: 1;
  box-shadow: none;
}

.mobile-header-icon-button:hover:not(:disabled) {
  color: #111827;
  border-color: #cfd8e4;
  background: #f1f5f9;
}

.mobile-header-icon-button:disabled {
  opacity: 0.45;
}

.mobile-header-summary {
  border: 1px solid #dde3eb;
  border-radius: 10px;
  background: #f8fafc;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-header-summary--compact {
  width: fit-content;
  max-width: 100%;
}

.mobile-header-summary-item {
  min-width: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.mobile-header-summary-item span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.mobile-header-summary-item strong {
  font-size: 13px;
  color: var(--text);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-header-summary-divider {
  display: none;
}

.mobile-settings-portal-root {
  position: fixed;
  inset: 0;
  z-index: 150;
}

.mobile-settings-portal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: color-mix(in srgb, var(--overlay) 85%, transparent);
  backdrop-filter: blur(2px);
}

.mobile-settings-portal {
  position: absolute;
  left: 12px;
  right: 12px;
  top: max(14px, env(safe-area-inset-top, 14px));
  bottom: max(14px, env(safe-area-inset-bottom, 14px));
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 28px);
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel-elevated);
  box-shadow: 0 26px 64px -24px rgba(15, 23, 42, 0.45);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mobile-settings-portal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 16px 13px;
  border-bottom: 1px solid var(--border-subtle);
  flex: 0 0 auto;
}

.mobile-settings-portal-header h2 {
  margin: 0;
  font-size: 17px;
  color: var(--text);
}

.mobile-settings-portal-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.mobile-settings-portal-body {
  padding: 12px 16px 16px;
  display: grid;
  gap: 12px;
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
}

.mobile-settings-select-grid {
  display: grid;
  gap: 12px;
}

.mobile-settings-field,
.mobile-profile-picker-label {
  display: grid;
  gap: 6px;
}

.mobile-settings-field span,
.mobile-profile-picker-label > span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.mobile-settings-field .ui-select,
.mobile-profile-picker .ui-select {
  min-height: 40px;
}

.mobile-settings-field-hint {
  font-size: 11px;
  color: var(--muted);
}

.mobile-settings-font-zoom {
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  padding: 12px 14px;
  display: grid;
  gap: 9px;
}

.mobile-settings-font-zoom-header,
.mobile-settings-font-zoom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mobile-settings-font-zoom-header span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.mobile-settings-font-zoom-header strong {
  color: var(--text);
  font-size: 13px;
}

.mobile-settings-font-zoom-row span:first-child {
  font-size: 12px;
}

.mobile-settings-font-zoom-row span:last-child {
  font-size: 20px;
  font-weight: 650;
}

.mobile-settings-font-zoom-slider.ui-input {
  min-width: 0;
  flex: 1;
  min-height: 28px;
  padding: 0;
  accent-color: var(--accent);
}

.mobile-settings-font-zoom p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.mobile-settings-auth-row {
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.mobile-conversation-cwd--in-settings,
.mobile-settings-tools-wrap,
.mobile-settings-collapsible {
  margin-top: 2px;
}

.mobile-settings-collapsible {
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  overflow: hidden;
}

.mobile-settings-collapsible-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}

.mobile-settings-collapsible-toggle span {
  display: grid;
  gap: 2px;
}

.mobile-settings-collapsible-toggle strong {
  font-size: 13px;
}

.mobile-settings-collapsible-toggle small {
  color: var(--muted);
  font-size: 11px;
}

.mobile-settings-collapsible-body {
  padding: 0 14px 14px;
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--border-subtle);
}

.mobile-settings-collapsible-body .ui-textarea {
  min-height: 88px;
  resize: vertical;
}

.mobile-conversation-cwd--in-settings {
  border-color: var(--border-subtle);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.mobile-conversation-cwd--in-settings label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.mobile-conversation-cwd--in-settings .mobile-conversation-cwd-hint {
  font-size: 10px;
}

.mobile-settings-tools-wrap .mobile-tool-panel {
  border-color: var(--border-subtle);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.mobile-auth-pill {
  border: 1px solid var(--control-border);
  border-radius: 999px;
  font-size: 11px;
  padding: 4px 8px;
  color: var(--muted);
  background: var(--control-muted-bg);
}

.mobile-auth-pill.connected {
  border-color: color-mix(in srgb, var(--tool-success) 55%, var(--control-border));
  color: color-mix(in srgb, var(--tool-success) 75%, var(--text));
}

.mobile-auth-pill.disconnected {
  border-color: color-mix(in srgb, var(--tool-error) 55%, var(--control-border));
  color: color-mix(in srgb, var(--tool-error) 75%, var(--text));
}

@media (min-width: 560px) {
  .mobile-settings-portal {
    left: 50%;
    right: auto;
    width: min(620px, calc(100vw - 28px));
    transform: translateX(-50%);
  }

  .mobile-settings-select-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.mobile-conversation-picker select,
.mobile-conversation-picker button,
.mobile-composer textarea,
.mobile-composer button {
  border: 1px solid var(--control-border);
  border-radius: 12px;
  background: var(--control-bg);
  color: var(--text);
  padding: 9px 10px;
}

.mobile-conversation-picker {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
}

.mobile-message-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  max-height: none;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  background: #ffffff;
  border: 0;
}

.mobile-branch-toolbar {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  display: grid;
  gap: 8px;
  padding: 10px 11px;
  font-size: 12px;
  color: var(--muted);
}

.mobile-branch-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mobile-branch-toolbar button {
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: var(--control-bg);
  color: var(--text);
  padding: 6px 10px;
  font-size: 12px;
}

.mobile-branch-toolbar button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.mobile-message {
  border: 1px solid #d9e1ed;
  border-radius: 14px;
  padding: 10px 11px;
  box-shadow: 0 10px 18px -22px rgba(15, 23, 42, 0.9);
}

.mobile-message.user {
  border-color: var(--message-user-border);
  background: var(--message-user-bg);
}

.mobile-message.assistant {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  padding-inline: 2px;
}

.mobile-message.branch-target {
  border-color: var(--branch-target-border);
  box-shadow: 0 0 0 2px var(--branch-target-ring);
}

.mobile-message.tool,
.mobile-message.system {
  background: var(--message-system-bg);
}

.mobile-message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 9px;
}

.mobile-message-role {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 640;
}

.mobile-streaming-badge {
  background: var(--streaming-bg);
  color: var(--streaming-text);
  border: 1px solid #c9defd;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
}

.mobile-message-body {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.mobile-message.assistant .mobile-message-text {
  font-size: var(--mobile-agent-text-font-size, 14px);
}

.mobile-message-text {
  font-size: 14px;
  line-height: 1.62;
}

.mobile-message-text pre,
.mobile-tool-result pre,
.mobile-reasoning-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.mobile-message-text p {
  margin: 0 0 9px;
}

.mobile-message-text p:last-child {
  margin-bottom: 0;
}

.mobile-empty-text {
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
}

.mobile-message-actions {
  margin-top: 11px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.mobile-message-actions button {
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: var(--control-bg);
  color: var(--text);
  padding: 5px 9px;
  font-size: 12px;
}

.mobile-message-actions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.mobile-composer {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 14px 12px;
  background: #ffffff;
  border: 0;
  border-top: 1px solid var(--border-subtle);
}

.mobile-composer-disabled-overlay {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 3;
}

.mobile-composer textarea {
  min-height: 42px;
  max-height: 156px;
  line-height: 1.45;
  resize: none;
  overflow-y: hidden;
  border-radius: 14px;
  border-color: #dbe2ec;
  background: #f8fafc;
  padding: 10px 12px;
}

.mobile-branch-banner {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--accent-soft);
  background: #eef5ff;
  border: 1px solid #cfe0ff;
  border-radius: 11px;
  padding: 9px;
}

.mobile-branch-banner button {
  border: 1px solid #bdd2fa;
  border-radius: 10px;
  background: #ffffff;
  color: var(--accent-soft);
  padding: 5px 8px;
}

.mobile-composer button {
  min-width: 78px;
  border-radius: 14px;
  border-color: #111827;
  background: #111827;
  color: #ffffff;
  font-weight: 620;
  padding-inline: 14px;
}

.mobile-composer button:hover:not(:disabled) {
  background: #0b1220;
  border-color: #0b1220;
}

.mobile-tool-card,
.mobile-reasoning-card {
  position: relative;
  border-left: 1px solid #d8e3f1;
  margin-left: 6px;
  padding-left: 18px;
}

.mobile-tool-dot,
.mobile-reasoning-dot {
  position: absolute;
  left: -5px;
  top: 8px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.mobile-tool-dot.success {
  background: var(--tool-success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
}

.mobile-tool-dot.error {
  background: var(--tool-error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.13);
}

.mobile-reasoning-dot {
  background: var(--reasoning);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.mobile-tool-header,
.mobile-reasoning-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}

.mobile-tool-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  padding: 3px 7px;
  border: 1px solid #cedcf1;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--accent-soft);
}

.mobile-tool-path,
.mobile-reasoning-summary {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.mobile-reasoning-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  color: var(--accent-soft);
  font-weight: 700;
}

.mobile-tool-block,
.mobile-tool-result {
  border-left: 2px solid #c9d8ea;
  border-radius: 0 10px 10px 0;
  padding: 9px;
  margin-top: 8px;
  background: var(--tool-surface);
}

.mobile-tool-result.success {
  border-left-color: rgba(16, 185, 129, 0.55);
}

.mobile-tool-result.error {
  border-left-color: rgba(239, 68, 68, 0.55);
  background: var(--tool-error-surface);
}

.mobile-tool-kv {
  font-size: 11px;
  line-height: 1.45;
}

.mobile-tool-k {
  color: var(--muted);
}

.mobile-tool-v {
  color: var(--text-soft);
}

.mobile-tool-status {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mobile-tool-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.mobile-tool-app-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.mobile-tool-app-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mobile-tool-app-toggle {
  border: 1px solid var(--control-border);
  border-radius: 999px;
  background: var(--control-bg);
  color: var(--text-soft);
  padding: 4px 10px;
  font-size: 11px;
  line-height: 1.1;
}

.mobile-tool-app-toggle:disabled {
  opacity: 0.55;
}

.mobile-custom-tool-iframe-shell {
  width: 100%;
}

.mobile-custom-tool-iframe-shell.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1900;
  display: flex;
  flex-direction: column;
  background: var(--overlay);
}

.mobile-custom-tool-fullscreen-bar {
  height: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--panel-elevated) 92%, black 8%);
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-custom-tool-fullscreen-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 0.01em;
}

.mobile-custom-tool-fullscreen-close {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1;
  padding: 2px 4px;
}

.mobile-custom-tool-iframe-shell.fullscreen .mobile-custom-tool-iframe-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  border-radius: 0;
  border: 0;
}

.mobile-custom-tool-iframe-shell.fullscreen .mobile-custom-tool-iframe {
  width: 100%;
  height: 100%;
  min-height: 100%;
  border-radius: 0;
}

.mobile-custom-tool-iframe-wrap {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--panel);
}

.mobile-custom-tool-iframe {
  width: 100%;
  min-height: 420px;
  background: #fff;
}

.mobile-editfile-card {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.mobile-editfile-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mobile-editfile-op {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--accent-soft);
}

.mobile-editfile-path {
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--muted);
}

.mobile-editfile-state {
  margin-left: auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 999px;
  padding: 2px 7px;
  border: 1px solid transparent;
}

.mobile-editfile-state.success {
  color: var(--tool-success);
  border-color: color-mix(in srgb, var(--tool-success) 35%, transparent);
  background: color-mix(in srgb, var(--tool-success) 12%, transparent);
}

.mobile-editfile-state.error {
  color: var(--tool-error);
  border-color: color-mix(in srgb, var(--tool-error) 35%, transparent);
  background: color-mix(in srgb, var(--tool-error) 10%, transparent);
}

.mobile-editfile-state.pending {
  color: var(--muted);
  border-color: color-mix(in srgb, var(--muted) 35%, transparent);
  background: color-mix(in srgb, var(--muted) 9%, transparent);
}

.mobile-editfile-section {
  border-left: 2px solid #c9d8ea;
  border-radius: 0 10px 10px 0;
  padding: 8px 9px;
  background: var(--tool-surface);
}

.mobile-editfile-section pre {
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-soft);
}

.mobile-editfile-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.mobile-editfile-label.added {
  color: var(--tool-success);
}

.mobile-editfile-label.removed {
  color: var(--tool-error);
}

.mobile-editfile-lineinfo,
.mobile-editfile-message {
  font-size: 10px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.mobile-reasoning-content {
  margin-top: 8px;
  color: var(--accent-soft);
  border-left: 2px solid #a7c4fb;
  border-radius: 0 10px 10px 0;
  padding: 9px;
  background: var(--reasoning-surface);
}

.tool-expand-container {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows 0.25s ease;
}

.tool-expand-container.open {
  grid-template-rows: 1fr;
}

.tool-expand-content {
  min-height: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tool-expand-container.open .tool-expand-content {
  opacity: 1;
}

.tool-chevron {
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.2s ease;
  font-size: 18px;
  line-height: 1;
}

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

.mobile-profile-picker {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  padding: 10px;
}

.mobile-profile-picker--compact {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.mobile-profile-picker-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-profile-picker .ui-select {
  border: 1px solid var(--control-border);
  border-radius: 12px;
  background: var(--control-bg);
  color: var(--text);
  padding: 9px 10px;
}

.mobile-project-launcher {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  padding: 10px;
}

.mobile-project-launcher button {
  width: 100%;
  border: 1px solid var(--control-border);
  border-radius: 12px;
  background: var(--control-bg);
  color: var(--text);
  padding: 9px 10px;
  font-size: 13px;
  text-align: center;
}

.mobile-project-launcher button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.mobile-conversation-cwd {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  padding: 11px;
  display: grid;
  gap: 8px;
}

.mobile-conversation-cwd label {
  font-size: 12px;
  color: var(--muted);
}

.mobile-conversation-cwd-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.mobile-conversation-cwd-row input,
.mobile-conversation-cwd-row button {
  border: 1px solid var(--control-border);
  border-radius: 11px;
  background: var(--control-bg);
  color: var(--text);
  padding: 8px 10px;
}

.mobile-conversation-cwd-row button {
  white-space: nowrap;
  font-weight: 620;
}

.mobile-conversation-cwd-hint {
  font-size: 11px;
  color: var(--muted);
}

.mobile-project-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 130;
  border: 0;
  padding: 0;
}

.mobile-project-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-project-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  max-height: 76vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--panel-elevated);
  border-bottom: 1px solid var(--border);
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  transform: translateY(-105%);
  transition: transform 0.22s ease;
  z-index: 140;
  box-shadow: 0 22px 50px -30px rgba(15, 23, 42, 0.7);
}

.mobile-project-modal.open {
  transform: translateY(0);
}

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

.mobile-project-modal-header button {
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: var(--control-muted-bg);
  color: var(--text);
  padding: 6px 10px;
  font-size: 12px;
}

.mobile-project-modal-body {
  overflow: auto;
}

.mobile-project-tree {
  background: transparent;
  overflow: hidden;
}

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

.mobile-project-tree-header button,
.mobile-project-actions button {
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: var(--control-bg);
  color: var(--text);
  padding: 6px 9px;
  font-size: 12px;
}

.mobile-project-group {
  border-top: 1px solid var(--border-subtle);
}

.mobile-project-header {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}

.mobile-project-meta {
  color: var(--muted);
  font-size: 14px;
}

.mobile-project-body {
  padding: 0 11px 11px;
  display: grid;
  gap: 8px;
}

.mobile-project-actions {
  display: flex;
  justify-content: flex-start;
}

.mobile-tree-muted {
  color: var(--muted);
  font-size: 12px;
}

.mobile-conversation-row {
  width: 100%;
  border: 1px solid var(--control-border);
  border-radius: 11px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  padding: 9px;
}

.mobile-conversation-row.active {
  border-color: var(--accent);
  background: var(--tree-node-active-path-bg);
}

.mobile-tool-panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  padding: 11px;
}

.mobile-tool-panel-details {
  width: 100%;
}

.mobile-tool-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}

.mobile-tool-panel-header::-webkit-details-marker {
  display: none;
}

.mobile-tool-panel-header h2 {
  margin: 0;
  font-size: 14px;
}

.mobile-tool-panel-chevron {
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.mobile-tool-panel-body {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.mobile-tool-panel-actions {
  display: flex;
  justify-content: flex-start;
}

.mobile-tool-panel-actions button,
.mobile-tool-toggle-row button {
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: var(--control-bg);
  color: var(--text);
  padding: 6px 10px;
  font-size: 12px;
}

.mobile-tool-toggle-list {
  display: grid;
  gap: 8px;
}

.mobile-tool-toggle-row {
  border: 1px solid var(--border-subtle);
  border-radius: 11px;
  background: var(--panel-2);
  padding: 9px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: flex-start;
}

.mobile-tool-toggle-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.mobile-tool-toggle-meta {
  display: flex;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.mobile-tree-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 110;
  backdrop-filter: blur(1px);
}

.mobile-tree-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-tree-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 72vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--panel-elevated);
  border-top: 1px solid var(--border);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  transform: translateY(102%);
  transition: transform 0.24s ease;
  z-index: 120;
  box-shadow: 0 -18px 46px -28px rgba(15, 23, 42, 0.8);
}

.mobile-tree-drawer.open {
  transform: translateY(0);
}

.mobile-tree-drawer-header {
  padding: 10px 13px;
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-tree-drawer-grabber {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: #d7e1ef;
  margin: 0 auto 9px;
}

.mobile-tree-drawer-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.mobile-tree-drawer-title-row button {
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: var(--control-muted-bg);
  color: var(--text);
  padding: 6px 10px;
  font-size: 12px;
}

.mobile-tree-drawer-body {
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 9px;
}

.mobile-tree-canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-tree-canvas-toolbar button {
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: var(--control-bg);
  color: var(--text);
  min-width: 34px;
  padding: 5px 8px;
  font-size: 12px;
}

.mobile-tree-drawer-canvas {
  position: relative;
  height: 52vh;
  min-height: 260px;
  max-height: 62vh;
  border: 1px solid var(--canvas-border);
  border-radius: 12px;
  background: var(--canvas-bg);
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.mobile-tree-drawer-canvas.dragging {
  cursor: grabbing;
}

.mobile-tree-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
}

.mobile-tree-edge {
  stroke: var(--tree-edge);
  stroke-width: 2;
}

.mobile-tree-edge.active {
  stroke: var(--tree-edge-active);
}

.mobile-tree-node-visual {
  cursor: pointer;
}

.mobile-tree-node-rect {
  fill: var(--panel-2);
  stroke: var(--control-border);
  stroke-width: 1.5;
}

.mobile-tree-node-rect.active-path {
  fill: var(--tree-node-active-path-bg);
  stroke: var(--tree-node-active-stroke);
}

.mobile-tree-node-rect.active-tip {
  fill: var(--tree-node-active-tip-bg);
  stroke: var(--tree-edge-active);
}

.mobile-tree-node-role-text {
  fill: var(--text-soft);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mobile-tree-node-message-text {
  fill: var(--tree-node-text);
  font-size: 11px;
}

.mobile-tree-node-branch-count-text {
  fill: var(--accent-soft);
  font-size: 11px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .ui-button,
  :root:not([data-theme='light']) button {
    border-color: transparent;
    box-shadow: none;
  }

  :root:not([data-theme='light']) .ui-input,
  :root:not([data-theme='light']) .ui-select,
  :root:not([data-theme='light']) .ui-textarea {
    border-color: transparent;
    box-shadow: none;
    background: #171a20;
  }

  :root:not([data-theme='light']) .ui-button--default {
    background: linear-gradient(180deg, #4b5563, #374151);
    color: #f3f4f6;
  }

  :root:not([data-theme='light']) .ui-button--default:hover:not(:disabled) {
    background: linear-gradient(180deg, #6b7280, #4b5563);
  }

  :root:not([data-theme='light']) .ui-button--outline {
    background: #15181d;
  }

  :root:not([data-theme='light']) .ui-button--destructive {
    background: #3a2628;
    color: #fecaca;
  }

  :root:not([data-theme='light']) .mobile-app-shell,
  :root:not([data-theme='light']) .mobile-header,
  :root:not([data-theme='light']) .mobile-message-list,
  :root:not([data-theme='light']) .mobile-composer {
    background: var(--panel);
  }

  :root:not([data-theme='light']) .mobile-header-brand h1 {
    color: var(--text);
  }

  :root:not([data-theme='light']) .mobile-status-dot {
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
  }

  :root:not([data-theme='light']) .mobile-header-icon-button {
    background: var(--control-muted-bg);
    color: var(--text-soft);
  }

  :root:not([data-theme='light']) .mobile-header-icon-button:hover:not(:disabled) {
    color: var(--text);
    background: #252b33;
  }

  :root:not([data-theme='light']) .mobile-header-summary {
    border-color: transparent;
    background: #20252d;
  }

  :root:not([data-theme='light']) .mobile-message {
    border-color: transparent;
    box-shadow: none;
  }

  :root:not([data-theme='light']) .mobile-message.branch-target {
    border-color: var(--branch-target-border);
    box-shadow: 0 0 0 2px var(--branch-target-ring);
  }

  :root:not([data-theme='light']) .mobile-streaming-badge {
    border-color: transparent;
  }

  :root:not([data-theme='light']) .mobile-composer {
    border-top: 1px solid var(--border-subtle);
  }

  :root:not([data-theme='light']) .mobile-composer textarea {
    border-color: transparent;
    background: #171a20;
    color: var(--text);
  }

  :root:not([data-theme='light']) .mobile-branch-banner {
    background: #262b33;
    border-color: transparent;
    color: #e2e8f0;
  }

  :root:not([data-theme='light']) .mobile-branch-banner button {
    background: #1f242b;
    color: #e5e7eb;
  }

  :root:not([data-theme='light']) .mobile-composer button {
    background: #374151;
    color: #f3f4f6;
  }

  :root:not([data-theme='light']) .mobile-composer button:hover:not(:disabled) {
    background: #4b5563;
  }

  :root:not([data-theme='light']) .mobile-tool-card,
  :root:not([data-theme='light']) .mobile-reasoning-card {
    border-left-color: #4b5563;
  }

  :root:not([data-theme='light']) .mobile-tool-chip {
    border-color: transparent;
    background: #1f242b;
    color: #d1d5db;
  }

  :root:not([data-theme='light']) .mobile-tool-block,
  :root:not([data-theme='light']) .mobile-tool-result,
  :root:not([data-theme='light']) .mobile-editfile-section {
    border-left-color: #6b7280;
  }

  :root:not([data-theme='light']) .mobile-editfile-state.pending {
    color: #9ca3af;
  }

  :root:not([data-theme='light']) .mobile-reasoning-content {
    border-left-color: #6b7280;
  }

  :root:not([data-theme='light']) .mobile-tree-drawer-grabber {
    background: #6b7280;
  }
}

/* Mobile overflow safety: never allow horizontal chat scrolling */
.mobile-message-list {
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

.mobile-message,
.mobile-message-body,
.mobile-message-text,
.markdown-body {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mobile-message-text pre,
.mobile-tool-result pre,
.mobile-reasoning-content,
.markdown-body pre,
.markdown-body code {
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.markdown-body img,
.markdown-body video,
.markdown-body iframe,
.markdown-body table {
  max-width: 100%;
}

.mobile-header-path-button {
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  border: 1px solid #d1dae6;
  background: #ffffff;
  color: #334155;
}

.mobile-header-path-button:hover:not(:disabled) {
  background: #f1f5f9;
  color: #111827;
}

.mobile-file-picker-portal-root {
  position: fixed;
  inset: 0;
  z-index: 160;
}

.mobile-file-picker-portal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: color-mix(in srgb, var(--overlay) 88%, transparent);
  backdrop-filter: blur(2px);
}

.mobile-file-picker-portal {
  position: absolute;
  left: 12px;
  right: 12px;
  top: max(18px, env(safe-area-inset-top, 18px));
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--panel-elevated);
  box-shadow: 0 30px 70px -30px rgba(15, 23, 42, 0.55);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(180px, 48vh);
}

.mobile-file-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-file-picker-header-buttons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mobile-file-picker-gitignore-btn {
  font-size: 11px;
  padding-inline: 8px;
  min-height: 26px;
}

.mobile-file-picker-header h2 {
  margin: 0;
  font-size: 16px;
}

.mobile-file-picker-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  max-width: 72vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-file-picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-file-picker-search {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px 8px;
}

.mobile-file-picker-search-input {
  flex: 1;
  min-width: 0;
}

.mobile-file-picker-search-hint {
  padding: 0 14px 10px;
  color: var(--muted);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.mobile-file-picker-list {
  overflow: auto;
  padding: 10px 12px 12px;
  display: grid;
  gap: 6px;
  align-content: start;
  grid-auto-rows: max-content;
}

.mobile-file-picker-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 11px;
  padding: 7px 8px;
  min-height: 46px;
  background: var(--panel-2);
}

.mobile-file-picker-item {
  border: 0;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  text-align: left;
  padding: 0;
}

.mobile-file-picker-item:disabled {
  opacity: 0.8;
}

.mobile-file-picker-item-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.mobile-file-picker-item-labels {
  display: grid;
  min-width: 0;
}

.mobile-file-picker-item-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-file-picker-item-subpath {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-file-picker-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mobile-file-picker-edit-btn,
.mobile-file-picker-insert-btn {
  width: 26px;
  min-width: 26px;
  height: 26px;
  border-radius: 999px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}

.mobile-file-picker-muted {
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
}

.mobile-file-picker-error {
  color: var(--tool-error);
  font-size: 12px;
  padding: 8px;
}

@media (min-width: 560px) {
  .mobile-file-picker-portal {
    left: 50%;
    right: auto;
    width: min(640px, calc(100vw - 28px));
    transform: translateX(-50%);
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .mobile-header-path-button {
    border-color: transparent;
    background: var(--control-muted-bg);
    color: var(--text-soft);
  }

  :root:not([data-theme='light']) .mobile-header-path-button:hover:not(:disabled) {
    background: #252b33;
    color: var(--text);
  }

  :root:not([data-theme='light']) .mobile-file-picker-row {
    border-color: transparent;
    background: #20252d;
  }
}

.mobile-monaco-modal-root {
  position: fixed;
  inset: 0;
  z-index: 999;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
  background: color-mix(in srgb, var(--overlay) 90%, transparent);
}

.mobile-monaco-modal-root.is-hidden {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.mobile-monaco-modal {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--panel);
  display: flex;
  flex-direction: column;
}

.mobile-monaco-modal-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top, 0px)) 10px 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--panel-elevated);
}

.mobile-monaco-modal-meta {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}

.mobile-monaco-modal-meta strong,
.mobile-monaco-modal-meta small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-monaco-modal-meta strong {
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.mobile-monaco-modal-meta small {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mobile-monaco-modal-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.mobile-monaco-modal-error {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--tool-error);
  border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--tool-error) 9%, var(--panel));
}

.mobile-monaco-editor-host {
  position: relative;
  min-height: 0;
  flex: 1 1 auto;
  width: 100%;
  overflow: hidden;
}

.mobile-monaco-editor-host > div {
  height: 100% !important;
  width: 100% !important;
}

.mobile-monaco-loading {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 4;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: color-mix(in srgb, var(--panel) 86%, #111827);
  color: var(--text);
  border: 1px solid var(--border-subtle);
}

/* EditFileDiffView (mobile) */
.mobile-editfile-view {
  margin-top: 8px;
}

.m-edit-root {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  overflow: hidden;
}

.m-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: color-mix(in srgb, var(--panel) 86%, #dbeafe);
  border-bottom: 1px solid var(--border);
}

.m-edit-head-left,
.m-edit-head-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.m-edit-op {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--accent-soft);
}

.m-edit-file {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--muted);
}

.m-edit-pill {
  font-size: 9px;
  border-radius: 999px;
  padding: 1px 6px;
  border: 1px solid transparent;
}

.m-edit-pill.success {
  color: var(--tool-success);
  border-color: color-mix(in srgb, var(--tool-success) 40%, transparent);
  background: color-mix(in srgb, var(--tool-success) 11%, transparent);
}

.m-edit-pill.info {
  color: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.m-edit-pill.warn {
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.14);
}

.m-edit-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: var(--panel);
}

.m-edit-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  text-transform: lowercase;
  padding: 2px 5px;
}

.m-edit-toggle button.active {
  background: var(--panel-elevated);
  color: var(--text);
}

.m-edit-body {
  padding: 6px;
}

.m-edit-inline-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: auto;
  max-height: 300px;
  background: var(--panel);
}

.m-edit-inline-head,
.m-edit-inline-row {
  display: grid;
  grid-template-columns: 36px 36px 16px 1fr;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  line-height: 1.4;
}

.m-edit-inline-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--panel) 88%, #e2e8f0);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--muted);
  text-transform: uppercase;
}

.m-edit-ln {
  text-align: right;
  padding: 2px 4px;
  border-right: 1px solid var(--border-subtle);
  color: var(--muted);
}

.m-edit-sign {
  text-align: center;
  padding: 2px 0;
  color: var(--muted);
}

.m-edit-code {
  padding: 2px 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.m-edit-inline-row.added {
  background: color-mix(in srgb, var(--tool-success) 10%, transparent);
}

.m-edit-inline-row.removed {
  background: color-mix(in srgb, var(--tool-error) 10%, transparent);
}

.m-edit-inline-row.added .m-edit-code {
  color: color-mix(in srgb, var(--tool-success) 70%, var(--text));
}

.m-edit-inline-row.removed .m-edit-code {
  color: color-mix(in srgb, var(--tool-error) 70%, var(--text));
  text-decoration: line-through;
}

.m-edit-unified {
  display: grid;
  gap: 6px;
}

.m-edit-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

@media (min-width: 700px) {
  .m-edit-split {
    grid-template-columns: 1fr 1fr;
  }
}

.m-edit-pane {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.m-edit-pane-head {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.m-edit-pane.removed .m-edit-pane-head {
  color: color-mix(in srgb, var(--tool-error) 75%, var(--text));
  background: color-mix(in srgb, var(--tool-error) 12%, transparent);
}

.m-edit-pane.added .m-edit-pane-head {
  color: color-mix(in srgb, var(--tool-success) 75%, var(--text));
  background: color-mix(in srgb, var(--tool-success) 12%, transparent);
}

.m-edit-pane-body {
  max-height: 260px;
  overflow: auto;
  padding: 6px;
}

.m-edit-pane-body pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.m-edit-pane-body code {
  font-size: 10px;
  line-height: 1.4;
}

.m-edit-msg {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.m-edit-msg.success {
  color: color-mix(in srgb, var(--tool-success) 75%, var(--text));
  background: color-mix(in srgb, var(--tool-success) 10%, transparent);
}

.m-edit-msg.error {
  color: color-mix(in srgb, var(--tool-error) 75%, var(--text));
  background: color-mix(in srgb, var(--tool-error) 10%, transparent);
}

.mobile-blocked-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: color-mix(in srgb, var(--overlay) 92%, transparent);
  border: 0;
  padding: 0;
}

.mobile-blocked-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2001;
  width: min(92vw, 420px);
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-elevated);
  box-shadow: 0 30px 80px -35px rgba(0, 0, 0, 0.55);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.mobile-blocked-modal h3 {
  margin: 0;
  font-size: 16px;
}

.mobile-blocked-modal p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-soft);
}

.mobile-blocked-modal-actions {
  display: flex;
  justify-content: flex-end;
}

.mobile-planmd-root {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.22);
  overflow: hidden;
}

.mobile-planmd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 6px;
}

.mobile-planmd-title-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.mobile-planmd-label {
  flex-shrink: 0;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  padding: 4px 6px;
  text-transform: uppercase;
}

.mobile-planmd-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1f2937;
  font-size: 13px;
  font-weight: 650;
}

.mobile-planmd-status {
  flex-shrink: 0;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 650;
  line-height: 1;
  padding: 4px 7px;
}

.mobile-planmd-status.success {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
}

.mobile-planmd-status.error {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.mobile-planmd-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 10px 7px;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
}

.mobile-planmd-body {
  max-height: min(52vh, 420px);
  overflow: auto;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  padding: 10px;
  color: #111827;
  font-size: 13px;
  line-height: 1.55;
}

.mobile-planmd-body :first-child {
  margin-top: 0;
}

.mobile-planmd-body :last-child {
  margin-bottom: 0;
}

.mobile-planmd-body pre {
  overflow: auto;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.06);
  padding: 8px;
}

:root:not([data-theme='light']) .mobile-planmd-root {
  background: rgba(23, 23, 23, 0.72);
  border-color: rgba(255, 255, 255, 0.08);
}

:root:not([data-theme='light']) .mobile-planmd-label {
  background: rgba(96, 165, 250, 0.16);
  color: #93c5fd;
}

:root:not([data-theme='light']) .mobile-planmd-title,
:root:not([data-theme='light']) .mobile-planmd-body {
  color: #e5e7eb;
}

:root:not([data-theme='light']) .mobile-planmd-path {
  color: #94a3b8;
}

:root:not([data-theme='light']) .mobile-planmd-body {
  border-top-color: rgba(255, 255, 255, 0.08);
}

:root:not([data-theme='light']) .mobile-planmd-body pre {
  background: rgba(255, 255, 255, 0.06);
}
