:root {
  color-scheme: light dark;
  --canvas: #eeebf6;
  --background: #faf9fd;
  --surface: #fff;
  --quiet: #f4f1f8;
  --ink: #201a2d;
  --muted: #655e73;
  --line: #e7e1ef;
  --field-line: #c9bfd8;
  --accent: #5a39b3;
  --on-accent: #fff;
  --tint: #eee8ff;
  --amber: #80500e;
  --amber-bg: #fff5e3;
  --amber-mark: #f6e7ce;
  --amber-line: #ebd5aa;
  --green: #21634c;
  --green-bg: #e7f4ec;
  --red: #922f42;
  --red-bg: #fcebef;
  --shadow: 0 14px 52px #34265b18;
  --composer-shadow: 0 3px 16px #34265b0d;
  --overlay-shadow: 0 8px 30px #34265b26;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #100e16;
    --background: #17141e;
    --surface: #211c2a;
    --quiet: #292334;
    --ink: #f3edf9;
    --muted: #b6a9c3;
    --line: #3a3146;
    --field-line: #64566f;
    --accent: #c8b5ff;
    --on-accent: #231538;
    --tint: #37294f;
    --amber: #f5cb8b;
    --amber-bg: #32261f;
    --amber-mark: #4d3726;
    --amber-line: #65492f;
    --green: #a0dfbc;
    --green-bg: #20372d;
    --red: #ffb9c6;
    --red-bg: #412831;
    --shadow: 0 14px 52px #06040985;
    --composer-shadow: 0 3px 16px #0604094d;
    --overlay-shadow: 0 8px 30px #06040985;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p, pre { margin: 0; }
button, input, select, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled, button[aria-disabled="true"] { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
code, pre { font-family: var(--mono); }

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 620px;
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  background: var(--background);
}
.app-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  min-height: 65px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 19px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 9px;
  font-size: 17px;
  font-weight: 730;
  letter-spacing: -.035em;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, #8468da, #532eac);
  color: #fff;
  font: 700 19px/1 var(--mono);
  letter-spacing: -.17em;
  padding-right: 3px;
  padding-bottom: 2px;
  box-shadow: inset 0 1px 0 #ffffff52;
}
.device-switch {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--background);
  font-size: 12px;
  font-weight: 650;
}
.device-switch .device-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: currentColor; }
.online { color: var(--green); }
.offline { color: var(--muted); }
.chevron { font-size: 17px; line-height: 1; color: var(--muted); }

.screen { flex: 1; min-width: 0; padding: 23px 19px 28px; }
.screen-head, .split, .actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.screen-head { margin-bottom: 17px; }
.screen-title { min-width: 0; font-size: 29px; line-height: 1.2; font-weight: 750; letter-spacing: -.045em; overflow-wrap: anywhere; }
.screen-title:focus { outline: none; }
.section-title { margin: 21px 0 8px; color: var(--muted); font-size: 13px; font-weight: 650; }
.subtext { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.section-title:first-child { margin-top: 0; }

.button {
  display: inline-flex;
  min-height: 44px;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 660;
  white-space: nowrap;
}
.button.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.button.quiet { background: transparent; border-color: transparent; color: var(--accent); }
.button.back { margin: -10px 0 6px -8px; padding-inline: 8px; color: var(--muted); }
.button.danger { color: var(--red); }
.button.wide { width: 100%; }

.connection-message, .error-note, .info-note {
  padding: 10px 12px;
  border-radius: 11px;
  overflow-wrap: anywhere;
  font-size: 13px;
}
.connection-message {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 12px 19px 0;
  padding-block: 4px;
  background: var(--amber-bg);
  color: var(--amber);
}
.connection-message .button { color: inherit; }
.error-note { margin: 0 0 14px; background: var(--red-bg); color: var(--red); }
.info-note { margin-bottom: 14px; background: var(--quiet); color: var(--muted); }
.empty-state, .loading-state { padding: 23px 14px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin: 0 0 4px; color: var(--ink); }
.empty-state .button { margin-top: 12px; }

.item-list, .approval-list, .file-list, .messages { margin: 0; padding: 0; list-style: none; }
.item-list { border: 1px solid var(--line); overflow: hidden; border-radius: 15px; background: var(--surface); }
.item-list > li + li { border-top: 1px solid var(--line); }
.item-row {
  display: flex;
  width: 100%;
  min-height: 62px;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.item-row:focus-visible { outline-offset: -3px; }
.item-content { flex: 1; min-width: 0; }
.item-label { display: block; font-weight: 680; overflow-wrap: anywhere; }
.item-detail { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.item-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  border-radius: 11px;
  background: var(--tint);
  color: var(--accent);
  font: 650 15px/1 var(--mono);
}
.status {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--quiet);
  color: var(--muted);
  font-size: 12px;
  font-weight: 670;
  white-space: nowrap;
}
.status .dot { width: 6px; height: 6px; }
.status.running { background: var(--tint); color: var(--accent); }
.status.approval { background: var(--amber-bg); color: var(--amber); }
.status.completed { background: var(--green-bg); color: var(--green); }
.status.failed { background: var(--red-bg); color: var(--red); }
.approval-list { display: grid; gap: 9px; }
.approval-preview {
  display: grid;
  width: 100%;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 13px 12px;
  border: 1px solid var(--amber-line);
  border-radius: 15px;
  background: var(--amber-bg);
  color: var(--ink);
  text-align: left;
}
.approval-preview .item-icon { width: 38px; height: 38px; background: var(--amber-mark); color: var(--amber); }
.approval-preview .item-detail { color: var(--amber); }

.app-nav {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 6px 12px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.app-nav > button {
  display: flex;
  min-height: 49px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 3px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 660;
}
.app-nav > button[aria-current="page"] { background: var(--tint); color: var(--accent); }
.nav-icon { position: relative; display: inline-block; width: 16px; height: 14px; border: 1.5px solid currentColor; border-radius: 3px; }
.icon-tasks::before { content: ""; position: absolute; inset: 3px 3px auto; height: 1px; background: currentColor; box-shadow: 0 4px currentColor; }
.icon-projects { height: 11px; margin-top: 3px; border-radius: 0 3px 3px; }
.icon-projects::before { content: ""; position: absolute; top: -5px; left: -1.5px; width: 8px; height: 4px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 3px 3px 0 0; }
.icon-device { height: 11px; margin-bottom: 3px; }
.icon-device::after { content: ""; position: absolute; bottom: -5px; left: 4px; width: 5px; height: 4px; border-bottom: 1.5px solid currentColor; }

.form { display: grid; gap: 13px; }
.form label { display: grid; min-width: 0; gap: 6px; font-size: 13px; font-weight: 660; }
.field {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 11px;
  border: 1px solid var(--field-line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  font-weight: 420;
}
textarea.field { min-height: 107px; resize: vertical; }
.field::placeholder { color: var(--muted); }
.form .info-note { margin: 0; }
.form-context { display: flex; flex-wrap: wrap; gap: 5px 12px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.form-context code { color: var(--ink); }
.pair-screen { max-width: 405px; margin: 6vh auto 0; }
.pair-mark { width: 45px; height: 45px; margin-bottom: 13px; font-size: 20px; }
.pair-screen .screen-title { margin-bottom: 7px; }
.pair-screen > .subtext { margin: 0 0 22px; }
.pair-screen .field { font-family: var(--mono); letter-spacing: .12em; }
.pair-hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.pair-local-link { display: inline-block; margin-top: 18px; color: var(--accent); text-underline-offset: 3px; }
.manual-pair { margin-top: 25px; border-top: 1px solid var(--line); }
.manual-pair summary { padding-block: 15px; color: var(--muted); cursor: pointer; }
.manual-pair .form { margin-top: 0; }
.scan-dialog { width: min(460px, calc(100% - 24px)); max-height: calc(100dvh - 32px); margin: auto; padding: 17px; overflow: auto; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); }
.scan-dialog::backdrop { background: #070510b8; }
.scan-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 13px; }
.scan-heading h2 { margin: 0; font-size: 17px; }
.scan-preview { overflow: hidden; aspect-ratio: 1; border-radius: 13px; background: #111; }
.scan-preview video { display: block; width: 100%; height: 100%; object-fit: contain; }
.scan-dialog > .subtext { margin-top: 13px; min-height: 3em; }
.pairing-screen { padding-top: 28px; padding-bottom: 30px; }
.pairing-screen > .subtext { margin-top: 8px; }
.pairing-screen > .form-context { margin-top: 9px; }
.pairing-screen > .info-note, .pairing-screen > .error-note { margin-top: 18px; }
.pairing-qr { display: grid; place-items: center; width: min(100%, 312px); margin: 24px auto 0; overflow: hidden; border: 1px solid #e7e1ef; border-radius: 14px; padding: 12px; background: #fff; color: #000; }
.pairing-qr svg { display: block; width: 100%; height: auto; }
#pairing-expiry { text-align: center; }
#pairing-origin-note { margin-top: 20px; }
.pairing-code { display: grid; gap: 3px; margin-top: 22px; text-align: center; color: var(--muted); font-size: 13px; }
.pairing-code strong { color: var(--ink); font: 600 29px/1.5 var(--mono); letter-spacing: .18em; padding-left: .18em; }
.pairing-actions { display: grid; gap: 10px; margin-top: 22px; }

.view-switch {
  display: flex;
  gap: 2px;
  margin: 0 0 15px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--quiet);
}
.view-switch > button {
  flex: 1;
  min-height: 44px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}
.view-switch > button[aria-pressed="true"] { border-color: var(--line); background: var(--surface); color: var(--ink); }
.history-filter { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.history-filter .button[aria-pressed="true"] { border-color: var(--accent); background: var(--tint); color: var(--accent); }
.history-meta { margin: -6px 0 13px; }
.history-note { margin: 12px 0 0; }
.history-more { margin-top: 12px; }
.history-earlier { margin-bottom: 12px; }
.history-icon::before {
  content: "";
  width: 13px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 4px 4px 4px 0;
}
.app-chat {
  --chat-height: min(100dvh, var(--visible-height, 100dvh));
  height: var(--chat-height);
  min-height: 0;
}
.app-chat > .app-header { display: none; }
.ui-icon { display: block; width: 16px; height: 16px; flex: none; stroke-width: 1.7; }
.conversation-screen {
  --chat-gutter: 28px;
  --chat-column: 790px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 0 max(8px, env(safe-area-inset-bottom));
  background: var(--surface);
  container: chat / inline-size;
}
.conversation-screen > .error-note { flex: none; margin-inline: var(--chat-gutter); }
.conversation-header { position: relative; z-index: 1; flex: none; }
.chat-thread-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 57px;
  padding: env(safe-area-inset-top) max(var(--chat-gutter), env(safe-area-inset-right)) 0 max(var(--chat-gutter), env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
}
.chat-thread-heading { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.chat-thread-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 650; letter-spacing: 0; }
.chat-project-crumb { position: relative; flex: 0 2 auto; min-width: 0; max-width: 56%; }
.chat-project-crumb select {
  display: block;
  max-width: 100%;
  min-height: 32px;
  border: 0;
  border-radius: 7px;
  padding: 0 24px 0 25px;
  appearance: none;
  field-sizing: content;
  text-overflow: ellipsis;
  background: var(--workspace-bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.chat-project-crumb .ui-icon { position: absolute; inset: 50% auto auto 6px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.chat-project-crumb .ui-icon:last-child { inset-inline: auto 5px; width: 13px; }
.chat-path-separator { color: var(--muted); }
.chat-path-separator .ui-icon { width: 13px; }
.chat-thread-heading .status { padding: 1px 6px; font-size: 11px; }
.chat-branch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 22%;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--workspace-bg);
  color: var(--muted);
  font-size: 11px;
}
.chat-branch code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-branch .ui-icon { width: 13px; height: 13px; }
.button.chat-thread-action { flex: none; min-height: 34px; gap: 5px; padding-inline: 7px; border-color: var(--line); border-radius: 7px; color: var(--ink); font-size: 12px; white-space: nowrap; }
.changed-count { min-width: 16px; padding-inline: 4px; border-radius: 5px; background: var(--tint); color: var(--accent); text-align: center; font: 650 11px/16px var(--mono); }
.app-short-viewport .composer-context { max-height: min(64px, max(0px, calc(var(--chat-height) - 290px))); }
.app-short-viewport .composer-popover { max-height: max(44px, calc(var(--chat-height) - 190px - env(safe-area-inset-bottom))); }
.conversation-log { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; overflow-anchor: none; }
.conversation-log:focus-visible { outline-offset: -2px; }
.conversation-feed {
  display: flex;
  flex-direction: column;
  justify-content: safe flex-end;
  min-height: 100%;
  max-width: var(--chat-column);
  margin-inline: auto;
  padding: 13px max(var(--chat-gutter), env(safe-area-inset-right)) 8px max(var(--chat-gutter), env(safe-area-inset-left));
}
.conversation-feed:has(.conversation-empty) { justify-content: safe center; }
.conversation-date { display: flex; align-items: center; gap: 11px; margin: 7px 0 17px; color: var(--muted); font-size: 11px; }
.conversation-date::before, .conversation-date::after { flex: 1; height: 1px; background: var(--line); content: ''; }
.conversation-history-tools { display: flex; justify-content: center; margin-bottom: 8px; }
.conversation-history-tools .history-earlier { min-height: 31px; margin: 0; gap: 5px; font-size: 12px; }
.conversation-approval { flex: none; width: calc(100% - var(--chat-gutter) * 2); max-width: calc(var(--chat-column) - var(--chat-gutter) * 2); max-height: 35%; margin-inline: auto; overflow: auto; }
.conversation-approval .approval-card { gap: 6px; margin: 0 0 8px; padding: 9px 10px; border-radius: 9px; }
.conversation-approval .approval-card > pre { max-height: min(25dvh, 170px); overflow: auto; }
.conversation-approval .approval-card h2 { font-size: 13px; }
.conversation-jump { position: relative; z-index: 1; flex: none; align-self: center; }
.button.chat-latest {
  position: absolute;
  bottom: 10px;
  left: 50%;
  min-height: 44px;
  padding-inline: 14px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--composer-shadow);
  white-space: nowrap;
}
.conversation-intro:empty, .conversation-date:empty, .conversation-question:empty, .conversation-progress:empty, .conversation-approval:empty { display: none; }
.conversation-empty { padding: 20px 0; text-align: center; }
.conversation-empty .brand-mark { width: 33px; height: 33px; margin: 0 auto 10px; border-radius: 8px; background: var(--tint); color: var(--accent); font-size: 17px; box-shadow: none; }
.conversation-empty h2 { font-size: 15px; font-weight: 650; }
.conversation-empty p { margin-top: 5px; color: var(--muted); font-size: 13px; }
.messages { display: grid; gap: 10px; }
.message { min-width: 0; max-width: 100%; border-radius: 17px; }
.message.user { display: grid; justify-items: end; justify-self: end; max-width: min(86%, 520px); }
.user-bubble { min-width: 0; max-width: 100%; padding: 9px 12px; border: 1px solid color-mix(in srgb, var(--accent) 17%, var(--line)); border-radius: 12px 3px 12px 12px; background: var(--tint); }
.message.assistant { padding: 3px 0; }
.message.assistant.commentary .message-body { color: var(--muted); }
.message-role .brand-mark { width: 20px; height: 20px; border-radius: 5px; padding: 0 2px 1px 0; font-size: 12px; }
.message.activity { padding: 0; border-radius: 0; }
.message.activity + .message.activity { margin-top: -6px; }
.message.plan { padding: 10px 12px; border: 1px solid var(--line); background: var(--surface); }
.message-role { display: flex; align-items: center; gap: 6px; margin: 0 0 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.message-body { overflow-wrap: anywhere; }
.plain-message { white-space: pre-wrap; }
.message-delivery { margin-top: 4px; color: var(--muted); font-size: 12px; }
.message-delivery.failed { display: flex; align-items: center; gap: 6px; color: var(--red); overflow-wrap: anywhere; }
.message-delivery .button { flex: none; min-height: 44px; padding-inline: 8px; font-size: inherit; }
.activity-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 2px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}
.activity-summary::-webkit-details-marker { display: none; }
.activity-summary::marker { content: ''; }
.activity-icon { flex: none; width: 16px; height: 16px; }
.activity-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-chevron { flex: none; width: 6px; height: 6px; margin-left: 1px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); }
.activity-disclosure[open] .activity-chevron { transform: translateY(-2px) rotate(45deg); }
.activity-warning { color: var(--amber); }
.activity-detail { margin: 2px 0 8px 24px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--quiet); }
.activity-output { max-height: min(320px, 50dvh); overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 var(--mono); }

.approval-card {
  display: grid;
  gap: 9px;
  margin-top: 13px;
  padding: 13px;
  border: 1px solid var(--amber-line);
  border-radius: 15px;
  background: var(--amber-bg);
}
.approval-card > h2 { font-size: 16px; color: var(--amber); }
.approval-card > pre { padding: 10px; border-radius: 9px; background: var(--surface); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.approval-card .actions { justify-content: flex-end; }
.approval-card .subtext { color: var(--amber); }
.chat-composer {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  flex: none;
  gap: 4px;
  min-width: 0;
  width: calc(100% - var(--chat-gutter) * 2);
  max-width: calc(var(--chat-column) - var(--chat-gutter) * 2);
  margin-inline: auto;
  padding: 7px 8px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--composer-shadow);
}
.chat-composer:focus-within { border-color: var(--accent); }
.composer-context { display: grid; gap: 4px; max-height: 105px; overflow: auto; padding: 0 5px; }
.composer-context:not(:has(> *)) { display: none; }
.composer-editing { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 0 3px; padding-inline-start: 6px; border-radius: 6px; background: var(--quiet); color: var(--muted); font-size: 12px; }
.composer-editing .button { min-height: 30px; padding-inline: 8px; font-size: inherit; }
.composer-note { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.composer-error { color: var(--red); }
.composer-option-error { display: flex; align-items: center; justify-content: space-between; gap: 5px; color: var(--muted); font-size: 12px; }
.composer-option-error .button { min-height: 32px; padding-inline: 6px; font-size: 12px; }
.composer-input-row { display: flex; min-width: 0; align-items: flex-end; }
.chat-input {
  display: block;
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  max-height: min(104px, max(42px, calc(var(--chat-height) * .25)));
  padding: 5px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  resize: none;
}
.chat-input:focus { outline: none; }
.chat-input::placeholder { color: var(--muted); }
.composer-voice-control { flex: none; }
.composer-voice {
  display: grid;
  width: 36px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}
.composer-voice[data-voice-phase="idle"]:not(:disabled):hover,
.composer-voice[data-voice-phase="transcribing"] { background: var(--quiet); }
.composer-voice:is([data-voice-phase="starting"], [data-voice-phase="recording"]) { background: var(--red-bg); color: var(--red); }
.voice-mark { position: relative; width: 16px; height: 18px; }
.voice-mark::before, .voice-mark::after {
  position: absolute;
  border: 1.5px solid currentColor;
  content: "";
}
.voice-mark::before { inset: 0 4px auto; height: 12px; border-radius: 6px; }
.voice-mark::after { inset: 6px 1px auto; height: 9px; border-top: 0; border-radius: 0 0 7px 7px; }
.voice-mark i { position: absolute; inset: 14px auto 0 7px; width: 2px; border-radius: 2px; background: currentColor; }
.composer-controls { display: flex; min-width: 0; align-items: center; gap: 4px; }
.composer-delivery { max-width: 65px; min-height: 33px; padding: 0 3px; border: 0; border-radius: 7px; color: var(--accent); background: var(--tint); font: inherit; font-size: 12px; }
.composer-queue { max-height: 150px; overflow: auto; margin-bottom: 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.composer-queue-heading, .composer-queue li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer-queue ol { margin: 3px 0 0; padding: 0; list-style: none; }
.composer-queue li > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-queue .button { min-height: 26px; flex: none; padding: 2px 6px; font-size: 12px; }
.chat-fork { display: inline-flex; flex: none; align-items: center; gap: 4px; white-space: nowrap; }
.composer-file, .composer-send, .button.composer-stop {
  display: grid;
  width: 33px;
  height: 33px;
  min-height: 0;
  flex: none;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
}
.composer-file { background: transparent; color: var(--muted); }
.composer-file:hover { background: var(--quiet); }
.composer-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 48%;
  min-height: 33px;
  gap: 6px;
  padding: 0 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.composer-picker[aria-expanded="true"] { background: var(--tint); color: var(--accent); }
.composer-picker:not(:disabled):hover { background: var(--quiet); }
.composer-picker > .ui-icon:last-child { width: 12px; height: 12px; color: var(--muted); }
.composer-model-label, .composer-permission-label { overflow: hidden; text-overflow: ellipsis; }
.composer-effort-label { flex: none; color: var(--muted); font-size: 11px; font-weight: 500; }
.composer-submit { display: flex; align-items: center; flex: none; gap: 4px; margin-inline-start: auto; }
.composer-key-hint { margin-inline-end: 4px; white-space: nowrap; color: var(--muted); font-size: 11px; }
.composer-send, .button.composer-stop { background: var(--accent); color: var(--on-accent); }
.composer-send:disabled { background: var(--tint); color: var(--accent); opacity: 1; }
.stop-icon { width: 12px; height: 12px; border-radius: 2px; background: currentColor; }
.composer-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  inset-inline-start: 41px;
  z-index: 3;
  width: min(calc(100% - 41px), 276px);
  max-height: min(300px, calc(var(--visible-height, 100dvh) * .46));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--overlay-shadow);
}
.composer-popover[data-menu="permission"] { inset-inline-start: 121px; width: min(calc(100% - 121px), 250px); }
.composer-settings { display: grid; }
.composer-model-slider { padding: 2px 4px 5px; }
.composer-model-range { display: block; width: 100%; margin: 0; min-height: 28px; accent-color: var(--accent); cursor: pointer; }
.composer-model-steps { display: flex; justify-content: space-between; gap: 5px; color: var(--muted); font-size: 11px; line-height: 1.25; }
.composer-model-steps > span { min-width: 0; overflow-wrap: anywhere; }
.composer-model-steps [data-selected] { color: var(--accent); font-weight: 650; }
.composer-permissions { display: grid; gap: 2px; min-width: 0; margin: 0; padding: 0; border: 0; }
.composer-permissions label { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 8px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.composer-permissions input { margin: 0; accent-color: var(--accent); }
.composer-permissions label:has(input:checked) { background: var(--tint); color: var(--accent); }
.composer-permissions:disabled { opacity: .65; }
.settings-title { padding: 0 4px 5px; color: var(--muted); font-size: 12px; font-weight: 650; }
.settings-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 130px);
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding-inline: 4px;
  font-size: 13px;
  font-weight: 600;
}
.settings-select { position: relative; min-width: 0; }
.settings-select::after {
  position: absolute;
  inset: calc(50% - 5px) 12px auto auto;
  width: 7px;
  height: 7px;
  border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
  pointer-events: none;
  content: "";
}
.settings-select select {
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 0 27px 0 10px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--quiet);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.settings-select select:not(:disabled):hover { border-color: var(--field-line); }
.settings-select select:disabled { background: var(--surface); color: var(--muted); opacity: 1; cursor: default; }
.settings-select:has(select:disabled)::after { display: none; }
.settings-mode { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); }
.mode-toggle {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-align: start;
}
.mode-toggle:not(:disabled):hover { background: var(--quiet); }
.mode-toggle:focus-visible { outline-offset: -2px; }
.settings-switch {
  display: flex;
  flex: none;
  align-items: center;
  width: 34px;
  height: 20px;
  padding: 3px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--muted) 72%, var(--surface));
}
.settings-switch::after { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); content: ""; }
.mode-toggle[aria-checked="true"] .settings-switch { justify-content: flex-end; background: var(--accent); }
.mode-toggle[aria-checked="true"] .settings-switch::after { background: var(--on-accent); }
.settings-note { padding: 0 4px 4px; color: var(--muted); font-size: 12px; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 5px; margin: 3px 0; padding: 0; list-style: none; }
.composer-context .attachment-list { flex-wrap: nowrap; overflow-x: auto; }
.attachment-chip { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; padding: 4px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--quiet); }
.composer-context .attachment-chip { flex: 0 0 auto; max-width: 85%; }
.attachment-icon { display: grid; width: 22px; height: 24px; flex: none; place-items: center; border-radius: 5px; background: var(--tint); color: var(--accent); }
.attachment-icon::before { width: 9px; height: 12px; border: 1px solid currentColor; border-radius: 2px; content: ""; }
.attachment-icon.image::before { width: 12px; height: 10px; border-radius: 2px; background: linear-gradient(145deg, transparent 55%, currentColor 57%, currentColor 63%, transparent 65%); }
.attachment-label { min-width: 0; font-size: 12px; }
.attachment-label b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-label small { display: block; color: var(--muted); font-size: 10px; }
.attachment-remove { width: 32px; height: 32px; flex: none; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 18px; }
.question-card, .plan-card { display: grid; gap: 8px; margin-top: 13px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.question-card h2, .plan-card h2 { font-size: 16px; }
.question-card .button, .plan-card .button { justify-self: start; }
.question-fields { display: grid; gap: 5px; min-width: 0; margin: 0; padding: 6px 0 0; border: 0; }
.question-fields legend { font-weight: 700; }
.question-choice { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.question-choice:has(input:checked) { border-color: var(--accent); background: var(--tint); }
.question-choice input { flex: none; accent-color: var(--accent); }
.question-choice small { display: block; color: var(--muted); font-size: 12px; }
.question-custom { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.plan-head { display: flex; align-items: center; gap: 10px; }
.plan-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.task-error { margin-top: 12px; }

.file-list { display: grid; gap: 8px; margin-top: 9px; }
.file-list > li { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.file-list .item-row { min-height: 49px; gap: 7px; padding: 8px 10px; }
.file-list .item-label { font: 620 13px/1.4 var(--mono); }
.file-counts { display: flex; flex: none; gap: 6px; font: 12px var(--mono); }
.plus { color: var(--green); }
.minus { color: var(--red); }
.diff { padding: 2px 0; border-top: 1px solid var(--line); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff span { display: block; padding: 3px 9px; line-height: 1.35; }
.diff .plus { background: var(--green-bg); }
.diff .minus { background: var(--red-bg); }
.diff .meta { color: var(--muted); background: var(--quiet); }
.device-card { margin-top: 10px; }
.device-card .item-row { min-height: 71px; }
.device-options { display: grid; gap: 9px; margin-top: 17px; }
.device-options p { margin-bottom: 4px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
@media (hover: hover) {
  button:not(:disabled):hover { filter: brightness(.96); }
  :is(.item-row, .app-nav > button, .button.quiet):not(:disabled):hover { background: var(--quiet); }
}
@media (min-width: 660px) {
  .app { min-height: calc(100vh - 40px); min-height: calc(100dvh - 40px); margin-block: 20px; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
  .app-chat { --chat-height: calc(min(100dvh, var(--visible-height, 100dvh)) - 40px); min-height: 0; }
  .app-header { border-radius: 21px 21px 0 0; }
  .app-nav { border-radius: 0 0 21px 21px; }
  .app-header, .screen { padding-inline: 24px; }
  .connection-message { margin-inline: 24px; }
}
@media (max-width: 360px) {
  .app-header, .screen { padding-inline: 13px; }
  .connection-message { margin-inline: 13px; }
  .brand { gap: 6px; }
  .item-row { gap: 8px; }
}

/* The same sidebar moves into a modal drawer on phones. */
.app-workspace {
  --workspace-bg: light-dark(#f8f7fb, #211d2a);
  --workspace-hover: light-dark(#efedf5, #312a3c);
  max-width: none;
  background: var(--surface);
  font-size: 14px;
}
.workspace-sidebar { display: none; min-width: 0; background: var(--workspace-bg); }
.workspace-toggle, .workspace-icon-button {
  display: grid;
  flex: none;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}
.workspace-toggle > span { position: relative; width: 16px; height: 13px; border: 1.5px solid currentColor; border-radius: 3px; }
.workspace-toggle > span::before { position: absolute; inset: 0 auto 0 4px; border-left: 1.5px solid currentColor; content: ''; }
.button.chat-sidebar-toggle { display: grid; width: 34px; min-height: 34px; height: 34px; padding: 0; margin-inline-start: -6px; border-radius: 7px; color: var(--muted); }
.workspace-icon-button:hover, .workspace-toggle:hover { background: var(--workspace-hover); }
.app-workspace .app-header .brand { flex: 1; }
.app-workspace .conversation-screen { padding-inline: 0; }
.workspace-drawer, .files-dialog { padding: 0; border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--overlay-shadow); }
.workspace-drawer::backdrop, .files-dialog::backdrop { background: light-dark(#1f133652, #070410a3); }
.workspace-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(286px, 87%);
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) env(safe-area-inset-left);
  border-width: 0 1px 0 0;
  background: var(--workspace-bg);
}
.workspace-drawer[open], .files-dialog[open] { display: flex; flex-direction: column; }
.workspace-panel { display: flex; flex: 1; flex-direction: column; min-height: 0; min-width: 0; }
.workspace-brand-row, .files-dialog-head {
  display: flex;
  flex: none;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 57px;
  padding-inline: 12px;
}
.workspace-brand-row .brand { font-size: 14px; }
.workspace-brand-row .brand-mark { width: 27px; height: 27px; border-radius: 7px; font-size: 16px; }
.workspace-primary { flex: none; padding: 0 12px 16px; }
.button.workspace-new { justify-content: flex-start; gap: 8px; min-height: 36px; padding-inline: 9px; border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line)); border-radius: 8px; background: var(--tint); color: var(--accent); font-size: 13px; }
.workspace-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 1px 11px 12px; }
.workspace-scroll h2 { padding: 0 8px 5px; color: var(--muted); font-size: 11px; font-weight: 650; }
.workspace-project-group + .workspace-project-group { margin-top: 4px; }
.workspace-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 34px;
  padding: 0 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  text-align: start;
}
.workspace-row:focus-visible { outline-offset: -2px; }
.workspace-row:hover { background: var(--workspace-hover); }
.workspace-row[aria-current="page"] { background: var(--tint); color: var(--accent); font-weight: 650; }
.workspace-project { font-weight: 650; }
.workspace-project > .ui-icon:first-child { width: 12px; height: 12px; }
.workspace-project[aria-expanded="true"] > .ui-icon:first-child { transform: rotate(90deg); }
.workspace-project .ui-icon, .workspace-chat:not([aria-current]) .ui-icon { color: var(--muted); }
.workspace-row-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-count, .workspace-state, .workspace-active-label { flex: none; margin-inline-start: auto; }
.workspace-count, .workspace-active-label { font-size: 11px; font-weight: 500; white-space: nowrap; }
.workspace-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.workspace-active-label { color: var(--amber); }
.workspace-thread-list { margin: 2px 0 9px 10px; padding: 0 0 0 8px; border-inline-start: 1px solid var(--line); list-style: none; }
.workspace-thread-list li + li { margin-top: 2px; }
.workspace-chat { font-size: 12px; }
.workspace-chat .ui-icon { width: 13px; height: 13px; }
.workspace-chat-item { position: relative; display: flex; align-items: center; min-width: 0; border-radius: 7px; }
.workspace-chat-item:hover, .workspace-chat-item:focus-within { background: var(--workspace-hover); }
.workspace-chat-item[data-current="true"] { background: var(--tint); }
.workspace-chat-item .workspace-chat { flex: 1; min-width: 0; width: auto; padding-inline-end: 3px; }
.workspace-chat-item .workspace-chat:hover { background: transparent; }
.chat-menu-trigger { display: grid; flex: none; place-items: center; width: 28px; height: 30px; margin-inline-end: 3px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); opacity: 0; }
.chat-menu-trigger .ui-icon { width: 17px; height: 17px; }
.workspace-chat-item:hover .chat-menu-trigger, .workspace-chat-item:focus-within .chat-menu-trigger,
.chat-list-row:hover .chat-menu-trigger, .chat-list-row:focus-within .chat-menu-trigger,
.chat-menu-trigger[aria-expanded="true"] { opacity: 1; }
.chat-menu-trigger:hover, .chat-menu-trigger[aria-expanded="true"] { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.chat-list-row { position: relative; display: flex; align-items: stretch; }
.chat-list-row > :is(.item-row, .approval-preview) { flex: 1; min-width: 0; width: 100%; padding-inline-end: 42px; }
.chat-list-row > .chat-menu-trigger { position: absolute; inset-inline-end: 8px; top: 50%; width: 32px; height: 34px; margin: 0; transform: translateY(-50%); }
@media (hover: none) { .chat-menu-trigger { opacity: 1; min-width: 34px; min-height: 38px; } }
.workspace-state { width: 6px; height: 6px; margin-inline-end: 2px; border-radius: 50%; background: var(--muted); }
.workspace-state.running { width: 13px; height: 13px; border: 1.5px solid var(--line); border-top-color: var(--accent); background: transparent; }
.workspace-state.completed { background: var(--green); }
.workspace-state.failed { background: var(--red); }
.workspace-empty { margin: 5px 7px; color: var(--muted); font-size: 12px; }
.workspace-links { display: grid; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.workspace-links .button, .button.workspace-more { justify-content: flex-start; min-height: 31px; padding-inline: 7px; color: var(--muted); font-size: 11px; }
.workspace-device { position: relative; flex: none; margin: 0 12px 11px; border-top: 1px solid var(--line); padding-top: 8px; }
.workspace-device summary { display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: 7px; list-style: none; cursor: pointer; }
.workspace-device summary::-webkit-details-marker { display: none; }
.workspace-device summary:hover { background: var(--workspace-hover); }
.workspace-device-icon { display: grid; flex: none; place-items: center; width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); }
.workspace-device-label { display: grid; flex: 1; min-width: 0; font-size: 12px; line-height: 1.35; }
.workspace-device-label strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.workspace-device-label small { display: flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 11px; }
.workspace-device .dot { width: 6px; height: 6px; }
.workspace-device summary > .ui-icon { width: 13px; color: var(--muted); }
.workspace-device-menu { position: absolute; z-index: 2; inset: auto 0 calc(100% + 2px); max-height: 45dvh; overflow: auto; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: var(--overlay-shadow); }
.workspace-device-menu .button { display: block; min-height: 34px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; font-size: 12px; }
.workspace-device-menu .error-note { margin: 4px; padding: 6px 8px; font-size: 12px; }
.message.assistant .message-body { color: var(--ink); line-height: 1.68; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body :is(p, ul, ol, pre, blockquote, table) { margin: .65em 0; }
.markdown-body :is(h1, h2, h3, h4, h5, h6) { margin: .9em 0 .4em; font-size: 1.04em; }
.markdown-body :is(ul, ol) { padding-inline-start: 1.48em; }
.markdown-body li + li { margin-block-start: .2em; }
.markdown-body a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .15em; }
.message-reference { color: var(--accent); }
.markdown-body code { padding: .12em .32em; border-radius: 5px; background: var(--quiet); font-size: .88em; }
.markdown-body pre { overflow: auto; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--quiet); }
.markdown-body pre code { padding: 0; background: none; }
.markdown-body blockquote { padding-inline-start: 12px; border-inline-start: 2px solid var(--field-line); color: var(--muted); }
.markdown-body table { display: block; max-width: 100%; overflow: auto; border-collapse: collapse; }
.markdown-body :is(th, td) { padding: 4px 8px; border: 1px solid var(--line); }
.markdown-body input[type="checkbox"] { margin-inline: 0 6px; }
.reply-timing { margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.reply-timing summary { display: inline-flex; align-items: center; gap: 9px; min-height: 30px; list-style: none; cursor: pointer; }
.reply-timing summary::-webkit-details-marker { display: none; }
.reply-timing[open] .activity-chevron { transform: translateY(-2px) rotate(45deg); }
.reply-timing-detail { display: flex; flex-wrap: wrap; gap: 5px 18px; padding: 3px 0 6px; }
.reply-timing-detail time { font-variant-numeric: tabular-nums; }
.reply-footer { display: flex; align-items: center; gap: 4px; margin: 4px 0 1px -4px; color: var(--muted); }
.reply-footer time { margin-inline-start: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.prompt-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; margin-top: 2px; }
.conversation-screen:not(:has(.chat-composer)) [data-action="edit-prompt"] { display: none; }
.reply-control {
  display: grid;
  width: 38px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.reply-control:hover, .reply-control[aria-expanded="true"] { border-color: var(--line); background: var(--quiet); color: var(--accent); }
.copy-mark { position: relative; width: 11px; height: 11px; margin: 3px 3px 0 0; border: 1.4px solid currentColor; border-radius: 3px; }
.copy-mark::after { position: absolute; inset: -4px -4px 3px 3px; border: 1.4px solid currentColor; border-bottom: none; border-left: none; border-radius: 0 3px 0 0; content: ''; }
.edit-mark { position: relative; width: 13px; height: 6px; margin-inline-start: 3px; border: 1.4px solid currentColor; border-radius: 0 2px 2px 0; transform: rotate(-45deg); }
.edit-mark::before { position: absolute; top: -1.4px; left: -5px; width: 0; height: 0; border-block: 3px solid transparent; border-right: 4px solid currentColor; content: ''; }
.edit-mark::after { position: absolute; top: 0; right: 2px; height: 100%; border-inline-start: 1px solid currentColor; content: ''; }
.reply-control.copied { color: var(--green); }
.reply-control.copied .copy-mark { width: 7px; height: 13px; margin: -3px 0 0; border: 0; border-right: 2px solid; border-bottom: 2px solid; border-radius: 0; transform: rotate(45deg); }
.reply-control.copied .copy-mark::after { display: none; }
.more-mark { width: 3px; height: 3px; border-radius: 50%; background: currentColor; box-shadow: -5px 0 currentColor, 5px 0 currentColor; }
.reply-menu {
  position: fixed;
  inset: auto;
  z-index: 5;
  width: max-content;
  max-width: calc(100% - 16px);
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--overlay-shadow);
}
.reply-menu-action { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding-inline: 10px; border: none; border-radius: 8px; background: var(--quiet); font-size: 13px; font-weight: 650; }
.reply-menu-action > span:first-child { color: var(--accent); }
.reply-menu p { padding: 3px 10px 5px; color: var(--muted); font-size: 11px; }
.chat-menu { position: fixed; inset: auto; z-index: 6; width: 204px; max-width: calc(100vw - 16px); margin: 0; padding: 5px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--ink); box-shadow: var(--overlay-shadow); }
.chat-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; color: inherit; font-size: 13px; text-align: start; }
.chat-menu button:hover, .chat-menu button:focus-visible { background: var(--quiet); }
.chat-menu button:disabled { opacity: .45; cursor: default; }
.chat-menu button.danger { color: var(--red); }
.chat-menu .ui-icon { flex: none; width: 16px; height: 16px; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.chat-menu-separator { height: 1px; margin: 4px 5px; background: var(--line); }
.chat-menu-note { padding: 5px 10px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.chat-action-dialog { width: min(390px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 23px; overflow: auto; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--ink); box-shadow: var(--overlay-shadow); }
.chat-action-dialog::backdrop { background: light-dark(#1f133652, #070410a3); }
.chat-action-dialog h2 { margin: 0 0 14px; font-size: 17px; }
.chat-action-description { overflow-wrap: anywhere; color: var(--muted); font-size: 13px; line-height: 1.6; }
.chat-action-description:empty { display: none; }
.chat-name-field { display: grid; gap: 7px; font-size: 13px; }
.chat-name-field input { width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--field-line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.chat-action-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.chat-action-buttons .button { min-width: 72px; }
.chat-action-buttons .button.danger { border-color: var(--red); background: var(--red); color: white; }
.clipboard-field { position: fixed; inset: 0 auto auto 0; width: 1px; height: 1px; opacity: 0; }
.connection-activity, .timeline-status { display: flex; align-items: center; gap: 8px; min-height: 30px; color: var(--muted); font-size: 13px; }
.connection-activity .activity-output { font: inherit; }
.connection-activity-mark { flex: none; width: 12px; height: 12px; margin-inline: 2px; border: 1.4px solid currentColor; border-right-color: transparent; border-radius: 50%; }
.timeline-status { margin-block: 8px 2px; }
.reply-changes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 9px;
  width: 100%;
  min-height: 38px;
  margin-top: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--workspace-bg);
  color: var(--ink);
  font-size: 12px;
  text-align: start;
}
.reply-changes > .ui-icon { color: var(--muted); }
.reply-changes-link { display: flex; align-items: center; gap: 3px; margin-inline-start: auto; color: var(--accent); }
.reply-changes-link .ui-icon { width: 12px; }
.files-dialog {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(426px, calc(100% - 18px));
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) 0;
  border-width: 0 0 0 1px;
}
.files-dialog-head { padding-inline: 14px 10px; min-height: 52px; border-bottom: 1px solid var(--line); }
.files-dialog-head h2 { font-size: 15px; font-weight: 650; }
.files-dialog-head .button { min-width: 35px; min-height: 35px; padding: 0; color: var(--muted); font-size: 20px; }
.files-dialog-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 12px 13px; }
.files-dialog-summary { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.file-list > li { border-radius: 8px; }
.file-list .item-row { min-height: 38px; }
.file-list .item-row .ui-icon { width: 14px; color: var(--muted); }
.file-list .item-label { font-size: 12px; }

@media (prefers-reduced-motion: no-preference) {
  .workspace-state.running { animation: spin 900ms linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .files-dialog[open] { animation: files-drawer-enter 180ms ease-out; }
  @keyframes files-drawer-enter { from { transform: translateX(100%); } }
  .workspace-drawer[open] { animation: workspace-drawer-enter 160ms ease-out; }
  @keyframes workspace-drawer-enter { from { transform: translateX(-100%); } }
}

@media (min-width: 681px) {
  .app-workspace {
    --chat-height: calc(min(100dvh, var(--visible-height, 100dvh)) - 40px);
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    width: calc(100% - 40px);
    max-width: 1440px;
    min-height: 0;
    height: var(--chat-height);
    border-radius: 12px;
  }
  .app-workspace.workspace-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
  .app-workspace:not(.workspace-collapsed) .workspace-toggle, .app-workspace .app-nav { display: none; }
  .app-workspace > .app-header { position: static; grid-area: 1 / 2; min-height: 57px; border-radius: 0 11px 0 0; }
  .app-workspace:not(.workspace-collapsed) .workspace-sidebar { display: flex; grid-area: 1 / 1 / 4 / 2; min-height: 0; border-inline-end: 1px solid var(--line); border-radius: 11px 0 0 11px; }
  .app-workspace .connection-message { grid-area: 2 / 2; margin-block: 6px 0; }
  .app-workspace .screen { grid-area: 3 / 2; min-height: 0; }
  .app-workspace .screen:not(.conversation-screen) { justify-self: center; width: 100%; max-width: 790px; overflow: auto; }
  .app-workspace .conversation-screen { border-radius: 0 11px 11px 0; }
}
@media (max-width: 680px) {
  .app-workspace { --chat-height: min(100dvh, var(--visible-height, 100dvh)); margin: 0; border: 0; border-radius: 0; box-shadow: none; }
  .conversation-screen { --chat-gutter: max(8px, env(safe-area-inset-left), env(safe-area-inset-right)); }
  .chat-thread-header, .workspace-brand-row { min-height: 49px; }
  .button.chat-sidebar-toggle { margin-inline-start: 0; }
  .message.user { max-width: 93%; }
  .composer-key-hint { display: none; }
  .composer-popover, .composer-popover[data-menu="permission"] { inset-inline-start: 0; width: min(100%, 276px); }
}
@container chat (max-width: 520px) {
  .chat-thread-header:has(.chat-fork) .chat-branch { display: none; }
  .button.chat-fork { min-height: 32px; padding: 4px 6px; font-size: 12px; }
  .chat-path-separator { display: none; }
  .chat-thread-title { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); }
  .chat-project-crumb { max-width: 100%; }
}
@container chat (max-width: 380px) {
  .chat-thread-header, .chat-thread-heading { gap: 5px; }
  .chat-project-crumb select { padding-inline: 6px 19px; font-size: 11px; }
  .chat-project-crumb .ui-icon:first-child, .changed-label { display: none; }
  .composer-picker { gap: 4px; padding-inline: 4px; }
  .composer-settings-toggle > .ui-icon:first-child { width: 14px; }
}
@media (pointer: coarse) {
  .chat-input, .settings-select select { font-size: 16px; }
  .composer-key-hint { display: none; }
  .reply-control, .composer-voice, .workspace-icon-button, .workspace-toggle, .button.chat-sidebar-toggle,
  .composer-file, .composer-send, .button.composer-stop { width: 44px; height: 44px; }
  .button.chat-thread-action, .button.workspace-new, .workspace-row, .workspace-device summary, .workspace-device-menu .button,
  .file-list .item-row, .composer-picker, .composer-permissions label, .composer-model-range, .settings-select select,
  .mode-toggle, .reply-changes, .reply-menu-action, .reply-timing summary, .composer-editing .button, .conversation-history-tools .history-earlier,
  .workspace-links .button, .button.workspace-more, .files-dialog-head .button { min-height: 44px; }
}
