:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI Variable", "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--canvas);
  letter-spacing: 0;
  --canvas: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f1f3f6;
  --surface-blue: #edf5ff;
  --text: #18202a;
  --text-secondary: #5c6877;
  --text-tertiary: #8793a1;
  --line: #dfe4ea;
  --line-strong: #cbd3dc;
  --accent: #1769d2;
  --accent-hover: #115bb8;
  --accent-soft: #dcecff;
  --ok: #17845b;
  --ok-soft: #e6f5ef;
  --warn: #a96708;
  --warn-soft: #fff4dc;
  --danger: #c73d3d;
  --danger-soft: #fff0f0;
  --shadow: 0 8px 24px rgba(26, 39, 58, 0.08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--canvas); }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid rgba(23, 105, 210, 0.35);
  outline-offset: 2px;
}
svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] { display: none !important; }
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: calc(58px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 250, 0.96);
  backdrop-filter: blur(12px);
}
.brand-lockup { min-width: 0; display: flex; align-items: center; gap: 10px; }
.brand-lockup > div:last-child { min-width: 0; display: grid; gap: 1px; }
.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #263140;
  border-radius: 6px;
  color: #fff;
  background: #202a36;
  font-size: 15px;
  font-weight: 750;
}
.brand-lockup strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.brand-lockup span { color: var(--text-tertiary); font-size: 11px; }
.connection-state {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-secondary);
  background: var(--surface);
  font-size: 12px;
  font-weight: 650;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-tertiary); }
.connection-state.online { color: var(--ok); border-color: #b9dfd0; background: var(--ok-soft); }
.connection-state.online .status-dot { background: var(--ok); }
.connection-state.connecting { color: var(--warn); border-color: #ead09f; background: var(--warn-soft); }
.connection-state.connecting .status-dot { background: var(--warn); animation: pulse 1.2s infinite; }
.connection-state.offline .status-dot { background: var(--text-tertiary); }

main { width: min(920px, 100%); margin: 0 auto; flex: 1; }
.setup-view {
  min-height: calc(100dvh - 58px - env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px 80px;
  text-align: center;
}
.setup-symbol {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.setup-symbol svg { width: 26px; height: 26px; }
.setup-view h1 { margin: 0; font-size: 23px; line-height: 1.25; }
.setup-view p { max-width: 390px; margin: 10px 0 22px; color: var(--text-secondary); font-size: 14px; line-height: 1.65; }
.setup-view.discovery-mode { justify-content: flex-start; padding-top: clamp(34px, 8vh, 86px); }
.discovery-controls {
  width: min(580px, 100%);
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  text-align: left;
}
.mobile-name-control { display: grid; gap: 6px; }
.mobile-name-control > span { color: var(--text-tertiary); font-size: 11px; font-weight: 650; }
.mobile-name-control input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
}
.discovery-heading {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}
.discovery-heading > div { min-width: 0; display: grid; gap: 2px; }
.discovery-heading strong { font-size: 13px; }
.discovery-heading span { color: var(--text-tertiary); font-size: 10px; }
.desktop-discovery-list { display: grid; gap: 8px; }
.desktop-discovery-empty {
  min-height: 110px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  color: var(--text-tertiary);
  background: var(--surface);
  font-size: 12px;
  text-align: center;
}
.desktop-discovery-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(26, 39, 58, 0.04);
}
.desktop-discovery-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent);
  background: var(--surface-blue);
}
.desktop-discovery-icon svg { width: 20px; height: 20px; }
.desktop-discovery-copy { min-width: 0; display: grid; gap: 4px; }
.desktop-discovery-copy strong,
.desktop-discovery-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desktop-discovery-copy strong { font-size: 13px; }
.desktop-discovery-copy span { color: var(--text-tertiary); font-size: 10px; }
.desktop-discovery-health { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 10px; }
.desktop-discovery-health i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
}
.desktop-discovery-health i.online { background: var(--ok); }
.desktop-discovery-health i.warn { background: var(--warn); }
.desktop-discovery-row > button {
  min-width: 72px;
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}
.desktop-discovery-row > button:hover { border-color: var(--accent-hover); background: var(--accent-hover); }

.primary-command,
.secondary-command {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: 6px;
  font-weight: 700;
}
.primary-command { border: 1px solid var(--accent); color: #fff; background: var(--accent); }
.primary-command:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.secondary-command { border: 1px solid var(--line-strong); color: var(--text-secondary); background: var(--surface); }
.secondary-command:hover { color: var(--text); border-color: #aab4c0; background: var(--surface-soft); }
.wide { width: 100%; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

.device-view { min-height: calc(100dvh - 58px - env(safe-area-inset-top)); padding: 14px 14px calc(82px + env(safe-area-inset-bottom)); }
.computer-summary {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(26, 39, 58, 0.04);
}
.computer-identity { min-width: 0; display: flex; align-items: center; gap: 11px; padding: 13px 14px; }
.computer-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent);
  background: var(--surface-blue);
}
.computer-identity > div:last-child { min-width: 0; display: grid; gap: 2px; }
.computer-identity span { color: var(--text-tertiary); font-size: 11px; }
.computer-identity strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.health-rail { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); background: #fbfcfd; }
.health-rail > div {
  min-width: 0;
  display: grid;
  grid-template-columns: 8px minmax(0, auto);
  grid-template-rows: auto auto;
  column-gap: 6px;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}
.health-rail > div:last-child { border-right: 0; }
.health-indicator { width: 7px; height: 7px; margin-top: 3px; border-radius: 50%; background: var(--text-tertiary); }
.health-indicator.online { background: var(--ok); }
.health-indicator.warn { background: var(--warn); }
.health-indicator.danger { background: var(--danger); }
.health-rail span:not(.health-indicator) { min-width: 0; overflow: hidden; color: var(--text-tertiary); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.health-rail strong { grid-column: 2; min-width: 0; margin-top: 2px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: calc(62px + env(safe-area-inset-bottom));
  padding: 4px 10px env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(14px);
}
.tabs button {
  min-width: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 0;
  border-radius: 6px;
  color: var(--text-tertiary);
  background: transparent;
  font-size: 10px;
  font-weight: 650;
}
.tabs button svg { width: 20px; height: 20px; }
.tabs button.active { color: var(--accent); background: var(--surface-blue); }
.content-region { padding-top: 18px; }
.view-panel { min-width: 0; }
.panel-head { min-height: 45px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.panel-head > div { min-width: 0; }
.panel-head h1 { margin: 0; font-size: 20px; line-height: 1.25; }
.panel-head p { margin: 5px 0 0; color: var(--text-tertiary); font-size: 12px; }
.icon-command {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-secondary);
  background: var(--surface);
}
.icon-command:hover { color: var(--accent); border-color: #b9d3f5; background: var(--surface-blue); }
.icon-command.loading svg { animation: spin 0.8s linear infinite; }

.search-control { position: relative; display: block; margin: 0 0 12px; }
.search-control svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; }
.search-control input { height: 42px; padding: 0 12px 0 38px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
  color: var(--text);
  background: var(--surface);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input::placeholder, textarea::placeholder { color: #9aa5b1; }
input:focus, select:focus, textarea:focus { border-color: #83b6f4; box-shadow: 0 0 0 3px rgba(23, 105, 210, 0.09); }
.session-status-filter {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  margin-bottom: 14px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}
.session-status-filter button {
  min-width: 0;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  color: var(--text-secondary);
  background: transparent;
  font-size: 11px;
  font-weight: 650;
}
.session-status-filter button strong {
  min-width: 20px;
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--text-tertiary);
  background: rgba(127, 140, 152, 0.1);
  font-size: 10px;
  line-height: 1.2;
}
.session-status-filter button.active {
  color: var(--accent);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(26, 39, 58, 0.08);
}
.session-status-filter button.active strong { color: var(--accent); background: var(--surface-blue); }
.session-list { display: grid; gap: 10px; }
.project-group {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.project-heading {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  text-align: left;
  border: 0;
  color: var(--text);
  background: #fbfcfd;
}
.project-heading:hover { background: var(--surface-blue); }
.project-symbol {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--accent);
}
.project-symbol svg { width: 19px; height: 19px; }
.project-identity { min-width: 0; display: grid; gap: 2px; }
.project-identity strong,
.project-identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-identity strong { font-size: 13px; line-height: 1.3; }
.project-identity small { color: var(--text-tertiary); font-size: 10px; font-weight: 500; }
.project-disclosure { color: var(--text-tertiary); transition: transform 140ms ease; }
.project-disclosure svg { width: 17px; height: 17px; transform: rotate(90deg); }
.project-group.collapsed .project-disclosure { transform: rotate(-90deg); }
.project-sessions { border-top: 1px solid var(--line); }
.project-sessions .session-row {
  min-height: 66px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
}
.project-sessions .session-row:last-of-type { border-bottom: 0; }
.project-sessions .session-row:hover { background: var(--surface-blue); }
.project-sessions .session-row.view-only { background: color-mix(in srgb, var(--surface) 92%, var(--warn-soft)); }
.project-sessions .session-row.view-only:hover { background: var(--warn-soft); }
.project-load-button,
.project-empty {
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 9px 13px;
  border-top: 1px solid var(--line);
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  color: var(--text-tertiary);
  background: #fbfcfd;
  font-size: 11px;
  text-align: center;
}
.project-load-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--accent);
  font-weight: 700;
}
.project-load-button:hover { background: var(--surface-blue); }
.project-load-button.loading::before {
  width: 12px;
  height: 12px;
  box-sizing: border-box;
  border: 2px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  content: '';
  animation: spin 0.8s linear infinite;
}
.project-empty { display: grid; place-items: center; }
.session-row {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface);
}
.session-row:hover { border-color: #bbd3ef; background: #fbfdff; }
.session-symbol {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent);
  background: var(--surface-blue);
}
.session-symbol svg { width: 16px; height: 16px; }
.session-content { min-width: 0; }
.session-row strong, .session-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-row strong { display: block; }
.session-row strong { font-size: 13px; line-height: 1.35; }
.session-meta-line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
}
.session-meta {
  min-width: 0;
  flex: 1 1 auto;
  color: var(--text-tertiary);
  font-size: 10px;
}
.session-access {
  min-width: max-content;
  display: inline-flex !important;
  align-items: center;
  flex: 0 0 auto;
  margin: 0 !important;
  padding: 2px 5px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 9px !important;
  font-weight: 700;
  line-height: 1.2;
}
.session-access.continuable { color: var(--ok); background: var(--ok-soft); }
.session-access.view-only { color: var(--warn); background: var(--warn-soft); }
.session-chevron { color: var(--text-tertiary); }
.session-chevron svg { width: 17px; height: 17px; }
.session-load-more {
  min-height: 40px;
  margin-top: 12px;
  font-size: 12px;
}
.session-load-more.loading svg { animation: spin 0.8s linear infinite; }
.session-loading {
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--accent);
}
.session-loading span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: session-loading 900ms infinite ease-in-out;
}
.session-loading span:nth-child(2) { animation-delay: 120ms; }
.session-loading span:nth-child(3) { animation-delay: 240ms; }
.empty {
  min-height: 170px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 28px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  color: var(--text-tertiary);
  text-align: center;
  font-size: 13px;
}
.empty svg { width: 24px; height: 24px; color: var(--text-tertiary); }

.form-grid { display: grid; gap: 14px; }
label:not(.search-control) { display: grid; gap: 7px; }
label > span { color: var(--text-secondary); font-size: 12px; font-weight: 650; }
select { height: 44px; padding: 0 34px 0 11px; }
textarea { padding: 11px 12px; line-height: 1.55; resize: vertical; }
.task-options { display: grid; gap: 7px; }
.task-options > span { color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.option-commands { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.option-command {
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text-secondary);
  background: var(--surface);
  font-size: 12px;
  font-weight: 650;
}
.option-command:hover { color: var(--accent); border-color: #9cc4f5; background: var(--surface-blue); }
.option-command.active { color: var(--accent); border-color: #9cc4f5; background: var(--surface-blue); }
.field-hint { color: var(--text-tertiary); font-size: 10px; line-height: 1.5; }
.selection-tray {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}
.selection-chip {
  max-width: 100%;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text-secondary);
  background: var(--surface);
  font-size: 10px;
}
.selection-chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selection-chip button {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  color: var(--text-tertiary);
  background: transparent;
}
.selection-chip button:hover { color: var(--danger); }
.selection-chip button svg { width: 13px; height: 13px; }
.prompt-field { position: relative; }
.prompt-field textarea { min-height: 148px; padding-bottom: 30px; }
.prompt-field small { position: absolute; right: 10px; bottom: 9px; color: var(--text-tertiary); font-size: 10px; }
.new-task-panel .primary-command { margin-top: 16px; }
.notice { margin: 10px 0 0; padding: 10px 12px; border: 1px solid #ead09f; border-radius: 6px; color: var(--warn); background: var(--warn-soft); font-size: 12px; }
.status-list { margin: 0 0 18px; border-top: 1px solid var(--line); }
.status-list div { min-height: 49px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.status-list dt { color: var(--text-secondary); font-size: 13px; }
.status-list dd { max-width: 62%; margin: 0; overflow-wrap: anywhere; color: var(--text); text-align: right; font-size: 13px; font-weight: 650; }

.conversation-view {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: calc(58px + env(safe-area-inset-top)) 30px minmax(0, 1fr) auto;
  background: var(--canvas);
}
.conversation-head {
  min-width: 0;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: env(safe-area-inset-top) 12px 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.conversation-context { min-width: 0; display: grid; gap: 2px; }
.conversation-context strong, .conversation-context span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-context strong { font-size: 14px; }
.conversation-context span { color: var(--text-tertiary); font-size: 10px; }
.stop-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid #efbaba;
  border-radius: 6px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 12px;
  font-weight: 700;
}
.stop-button svg { width: 15px; height: 15px; }
.conversation-progress {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text-tertiary);
  background: #fbfcfd;
  font-size: 10px;
}
#conversationActivity.active { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s infinite; }
.message-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 12px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}
.message {
  position: relative;
  max-width: min(88%, 680px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.62;
  font-size: 14px;
}
.message.user { align-self: flex-end; border-color: #b6d4f7; background: var(--accent-soft); }
.message.assistant { align-self: flex-start; box-shadow: 0 1px 3px rgba(26, 39, 58, 0.04); }
.message.tool {
  align-self: stretch;
  max-width: none;
  padding: 9px 10px;
  color: var(--text-secondary);
  background: var(--surface-soft);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
}
.message.pending::after { content: "▋"; color: var(--accent); animation: blink 0.8s infinite; }
.scroll-bottom {
  position: fixed;
  right: 16px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 34;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text-secondary);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: end;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.composer-options {
  grid-column: 1 / -1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.composer-options > span {
  min-width: 0;
  overflow: hidden;
  color: var(--text-tertiary);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.composer-option {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text-secondary);
  background: var(--surface-soft);
}
.composer-option:hover, .composer-option.active { color: var(--accent); border-color: #9cc4f5; background: var(--surface-blue); }
.composer-option svg { width: 16px; height: 16px; }
.composer-selection-tray { grid-column: 1 / -1; padding: 6px; }
.composer textarea { min-height: 42px; max-height: 160px; resize: none; }
.composer button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
}
.composer button:hover { background: var(--accent-hover); }
.composer.read-only {
  grid-template-columns: minmax(0, 1fr) 42px;
  background: var(--surface-soft);
}
.composer.read-only .composer-options > span { color: var(--warn); font-weight: 650; }
.composer.read-only textarea { color: var(--text-tertiary); background: var(--surface); }
.composer.read-only button { color: var(--text-tertiary); border-color: var(--line-strong); background: var(--surface-soft); }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  padding: 10px 12px;
  border: 1px solid #c7d4e3;
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12px;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 18px 12px max(12px, env(safe-area-inset-bottom));
  background: rgba(12, 17, 23, 0.48);
}
.capability-dialog {
  width: min(640px, 100%);
  max-height: min(82dvh, 720px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(10, 18, 28, 0.24);
}
.capability-dialog > header {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 15px 10px;
}
.capability-dialog > header > div { min-width: 0; }
.capability-dialog h2 { margin: 0; font-size: 17px; }
.capability-dialog header p { margin: 4px 0 0; color: var(--text-tertiary); font-size: 10px; line-height: 1.5; }
.capability-search { margin: 0 15px 10px; }
.capability-list { min-height: 180px; overflow-y: auto; padding: 0 15px 14px; }
.capability-section { display: grid; gap: 7px; margin-top: 12px; }
.capability-section:first-child { margin-top: 0; }
.capability-section > h3 { margin: 0; color: var(--text-tertiary); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.capability-row {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
}
.capability-row:hover { border-color: #a9c9ee; background: var(--surface-blue); }
.capability-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.capability-row > span { min-width: 0; display: grid; gap: 2px; }
.capability-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.capability-row strong { font-size: 12px; }
.capability-row small {
  overflow: hidden;
  display: -webkit-box;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.capability-row em { color: var(--text-tertiary); font-size: 10px; font-style: normal; }
.capability-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
  font-size: 12px;
  text-align: center;
}
.capability-dialog > footer {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 15px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.capability-dialog > footer span { color: var(--text-tertiary); font-size: 11px; }
.relay-pairing-dialog {
  width: min(430px, 100%);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(10, 18, 28, 0.24);
}
.relay-pairing-dialog > header {
  min-height: 72px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.pairing-dialog-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--accent);
  background: var(--surface-blue);
}
.pairing-dialog-icon svg { width: 21px; height: 21px; }
.relay-pairing-dialog > header > div:nth-child(2) { min-width: 0; display: grid; gap: 2px; }
.relay-pairing-dialog header span { color: var(--text-tertiary); font-size: 10px; }
.relay-pairing-dialog h2 { margin: 0; overflow: hidden; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.relay-pairing-body { display: grid; gap: 15px; padding: 18px 16px; }
.relay-pairing-body > p { margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.6; }
.relay-pairing-body > label { display: grid; gap: 7px; }
.relay-pairing-body > label span { color: var(--text-tertiary); font-size: 11px; font-weight: 650; }
.relay-pairing-body input {
  width: 100%;
  height: 54px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-soft);
  font-size: 25px;
  font-weight: 750;
  letter-spacing: 8px;
  text-align: center;
}
.pairing-expiry { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pairing-expiry span { color: var(--text-secondary); font-size: 10px; }
.pairing-expiry strong { color: var(--warn); font-size: 10px; }
.relay-pairing-dialog > footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

@keyframes blink { 50% { opacity: 0; } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes session-loading { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

@media (min-width: 720px) {
  .topbar { padding-left: 24px; padding-right: 24px; }
  .device-view {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 20px 24px;
    padding: 24px;
  }
  .computer-summary { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(240px, 1fr) minmax(360px, 1.4fr); }
  .health-rail { border-top: 0; border-left: 1px solid var(--line); }
  .tabs {
    position: sticky;
    top: calc(82px + env(safe-area-inset-top));
    align-self: start;
    display: grid;
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    backdrop-filter: none;
  }
  .tabs button { min-height: 46px; grid-template-columns: 24px minmax(0, 1fr); place-items: center start; align-content: center; gap: 8px; padding: 0 10px; font-size: 12px; }
  .tabs button svg { width: 18px; height: 18px; }
  .content-region { min-width: 0; padding-top: 0; }
  .conversation-view {
    inset: 18px max(18px, calc((100vw - 920px) / 2));
    grid-template-rows: 58px 30px minmax(0, 1fr) auto;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(25, 37, 54, 0.14);
  }
  .conversation-head { padding: 0 12px; }
  .scroll-bottom { right: max(32px, calc((100vw - 880px) / 2)); bottom: 98px; }
  .dialog-backdrop { align-items: center; }
}

@media (max-width: 520px) {
  .setup-view.discovery-mode { padding-left: 14px; padding-right: 14px; }
  .desktop-discovery-row { grid-template-columns: 36px minmax(0, 1fr); }
  .desktop-discovery-row > button { grid-column: 1 / -1; width: 100%; }
  .pairing-expiry { align-items: flex-start; flex-direction: column; gap: 4px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --canvas: #11151a;
    --surface: #181e24;
    --surface-soft: #20272e;
    --surface-blue: #17283b;
    --text: #edf1f5;
    --text-secondary: #aeb8c3;
    --text-tertiary: #7f8c98;
    --line: #2a333c;
    --line-strong: #3a4652;
    --accent: #5ca7ff;
    --accent-hover: #78b6ff;
    --accent-soft: #193552;
    --ok: #5ad09d;
    --ok-soft: #153329;
    --warn: #efbd62;
    --warn-soft: #382b14;
    --danger: #ff8585;
    --danger-soft: #3b2023;
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
  }
  html, body { background: var(--canvas); }
  .topbar, .tabs { background: rgba(17, 21, 26, 0.96); }
  .health-rail, .conversation-progress { background: #151a20; }
  .brand-mark { border-color: #697888; color: #11151a; background: #edf1f5; }
  .connection-state.online { border-color: #245c49; }
  .connection-state.connecting { border-color: #684f22; }
  .computer-summary, .session-row, .icon-command { box-shadow: none; }
  .session-row:hover { border-color: #45698f; background: #19232e; }
  .project-heading, .project-load-button, .project-empty { background: #151a20; }
  .project-heading:hover, .project-sessions .session-row:hover { background: #17283b; }
  .session-status-filter button.active { box-shadow: none; }
}

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