:root {
  color-scheme: light;
  --paper: #F5F4ED;
  --paper-deep: #ECEAE1;
  --surface: #FFFFFF;
  --surface-hover: #F1F0E9;
  --surface-muted: #E8E6DE;
  --ink: #141413;
  --ink-secondary: #5E5D58;
  --ink-tertiary: #85837B;
  --ink-disabled: #AAA79E;
  --clay: #D97757;
  --clay-hover: #C66547;
  --clay-active: #AD5036;
  --clay-soft: #F7EDE8;
  --clay-border: #EBD3C8;
  --green: #3D7C53;
  --green-soft: #EDF4EF;
  --green-border: #C7DACD;
  --amber: #8A6220;
  --amber-soft: #F7F0E3;
  --amber-border: #E4D3B3;
  --red: #B43E3E;
  --red-soft: #F7EBEB;
  --red-border: #E6C7C7;
  --blue: #3898EC;
  --border: #D8D5CC;
  --border-subtle: #E6E3DA;
  --border-strong: #B9B6AD;
  --radius: 13px;
  --sidebar-width: 248px;
  --topbar-height: 64px;
  --touch: 44px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --shadow-panel: 0 4px 24px rgba(20, 20, 19, 0.05);
  --fast: 160ms ease-out;
  --slow: 220ms ease-out;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 22px;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
}

button,
input,
textarea,
select {
  border: 0;
}

button {
  background: none;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

::selection {
  background: var(--clay-border);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  height: 32px;
}

.brand-mark {
  display: block;
  width: 24px;
  height: 24px;
  flex: none;
}

.brand-name {
  overflow: hidden;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  width: var(--touch);
  height: var(--touch);
  padding: 0;
  flex: none;
  place-items: center;
  border-radius: var(--radius);
  color: var(--ink-secondary);
  transition: color var(--fast), background-color var(--fast), border-color var(--fast);
}

.icon-button:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.icon-button:active {
  background: var(--surface-muted);
}

.icon-button:disabled {
  background: transparent;
  color: var(--ink-disabled);
}

.icon-button svg,
.button svg,
.workspace-button svg,
.cwd-button svg,
.search-field svg,
.settings-chip svg,
.reconnect-banner svg,
.settings-warning svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

.button {
  display: inline-flex;
  min-height: var(--touch);
  padding: 9px 16px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 500;
  line-height: 20px;
  transition: color var(--fast), background-color var(--fast), border-color var(--fast);
}

.button-primary {
  background: var(--clay);
  color: #FFFFFF;
}

.button-primary:hover {
  background: var(--clay-hover);
}

.button-primary:active {
  background: var(--clay-active);
}

.button-primary:disabled {
  background: var(--surface-muted);
  color: var(--ink-disabled);
}

.button-secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--ink);
}

.button-secondary:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.button-quiet {
  color: var(--ink-secondary);
}

.button-quiet:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.compact-button {
  min-height: 40px;
  padding: 8px 13px;
}

.login-view {
  display: grid;
  width: 100%;
  height: 100dvh;
  min-height: 520px;
  padding: 24px;
  place-items: center;
  background: var(--paper);
}

.login-panel {
  width: min(100%, 404px);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
}

.brand-login {
  margin-bottom: 48px;
}

.login-copy h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 600;
  line-height: 36px;
}

.login-copy p {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 15px;
  line-height: 24px;
}

.login-form {
  display: flex;
  margin-top: 28px;
  flex-direction: column;
  gap: 8px;
}

.login-form label,
.field > span {
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
}

.password-field {
  position: relative;
}

.password-field input,
.field select,
.path-row input,
.search-field {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.password-field input {
  height: 48px;
  padding: 11px 52px 11px 14px;
}

.password-field input:focus,
.field select:focus,
.path-row input:focus,
.search-field:focus-within,
.composer:focus-within {
  border-color: var(--clay);
  box-shadow: 0 0 0 1px var(--clay);
  outline: 0;
}

.input-action {
  position: absolute;
  top: 2px;
  right: 2px;
}

.form-error,
.dialog-error {
  margin: 2px 0 0;
  color: var(--red);
  font-size: 13px;
  line-height: 20px;
}

.login-button {
  width: 100%;
  margin-top: 14px;
}

.app-shell {
  display: grid;
  width: 100%;
  height: 100dvh;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background: var(--paper);
}

.sidebar {
  display: flex;
  width: var(--sidebar-width);
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--paper);
}

.sidebar-header {
  display: flex;
  height: var(--topbar-height);
  padding: 0 14px 0 18px;
  flex: none;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-close {
  display: none;
}

.sidebar-actions {
  display: flex;
  padding: 14px 12px 8px;
  flex-direction: column;
  gap: 8px;
}

.sidebar-actions > .button {
  width: 100%;
}

.project-section {
  display: flex;
  min-height: 54px;
  max-height: 220px;
  padding: 0 8px 8px;
  flex: none;
  flex-direction: column;
}

.section-action {
  width: 28px;
  height: 28px;
}

.project-list {
  min-height: 0;
  padding: 0 4px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.project-item {
  display: grid;
  width: 100%;
  min-height: 42px;
  padding: 7px 10px;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border-radius: var(--radius);
  color: var(--ink-secondary);
  text-align: left;
  transition: color var(--fast), background-color var(--fast);
}

.project-item:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.project-item[aria-current="true"] {
  background: var(--surface);
  color: var(--ink);
}

.project-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-empty {
  margin: 0;
  padding: 8px 10px;
  color: var(--ink-tertiary);
  font-size: 12px;
  line-height: 18px;
}

.thread-section {
  display: flex;
  min-height: 0;
  padding: 8px;
  flex: 1;
  flex-direction: column;
}

.section-row {
  display: flex;
  min-height: 32px;
  padding: 0 8px;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-tertiary);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}

.thread-count {
  font-family: var(--font-mono);
}

.search-field {
  display: grid;
  height: 40px;
  margin: 4px 4px 8px;
  padding: 0 10px;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--ink-tertiary);
}

.search-field input {
  min-width: 0;
  height: 36px;
  padding: 0;
  outline: 0;
  background: transparent;
}

.search-field input::placeholder {
  color: var(--ink-tertiary);
}

.thread-list {
  min-height: 0;
  padding: 0 4px 8px;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.thread-item {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 58px;
  padding: 9px 10px 9px 14px;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  border-radius: var(--radius);
  color: var(--ink-secondary);
  text-align: left;
  transition: color var(--fast), background-color var(--fast);
}

.thread-item:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.thread-item[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
}

.thread-item[aria-current="page"]::before {
  position: absolute;
  top: 13px;
  bottom: 13px;
  left: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--clay);
  content: "";
}

.thread-title {
  width: 100%;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-meta {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 6px;
  color: var(--ink-tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 16px;
}

.thread-meta [data-running="true"] {
  color: var(--green);
  font-weight: 600;
}

.thread-meta span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-empty {
  margin: 16px 10px;
  color: var(--ink-tertiary);
  font-size: 13px;
  line-height: 20px;
}

.sidebar-footer {
  display: flex;
  min-height: 60px;
  padding: 8px 8px 8px 16px;
  flex: none;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
}

.connection-row,
.run-state {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: var(--ink-secondary);
  font-size: 12px;
  line-height: 18px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--ink-disabled);
}

.connection-row[data-state="online"] .status-dot,
.run-state[data-state="idle"] .status-dot {
  background: var(--green);
}

.connection-row[data-state="connecting"] .status-dot,
.run-state[data-state="running"] .status-dot {
  background: var(--clay);
  animation: status-pulse 1.5s ease-out infinite;
}

.connection-row[data-state="offline"] .status-dot,
.run-state[data-state="error"] .status-dot {
  background: var(--red);
}

.footer-actions {
  display: flex;
  align-items: center;
}

.workbench {
  display: flex;
  min-width: 0;
  min-height: 0;
  height: 100dvh;
  flex-direction: column;
  background: var(--paper);
}

.mobile-topbar {
  display: none;
}

.conversation-topbar {
  display: flex;
  min-height: var(--topbar-height);
  padding: 8px 18px 8px 24px;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
}

.conversation-heading {
  min-width: 0;
}

.conversation-heading h1 {
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cwd-button {
  display: flex;
  max-width: min(60vw, 680px);
  min-height: 24px;
  padding: 0;
  align-items: center;
  gap: 6px;
  color: var(--ink-tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 18px;
}

.cwd-button:hover {
  color: var(--ink-secondary);
}

.cwd-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.run-state {
  min-height: 32px;
  padding: 0 9px;
}

.reconnect-banner {
  display: flex;
  min-height: 40px;
  padding: 8px 20px;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-bottom: 1px solid var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 13px;
  line-height: 20px;
}

.conversation {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.empty-state {
  display: flex;
  width: min(100%, 560px);
  min-height: 100%;
  margin: auto;
  padding: 64px 24px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}

.empty-symbol {
  display: grid;
  width: 56px;
  height: 56px;
  margin-bottom: 20px;
  place-items: center;
  border: 1px solid var(--clay-border);
  border-radius: var(--radius);
  background: var(--clay-soft);
  color: var(--clay-active);
}

.empty-symbol svg {
  width: 26px;
  height: 26px;
  stroke-width: 1.5;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
  line-height: 30px;
}

.empty-state p {
  max-width: 440px;
  margin: 0 0 24px;
  color: var(--ink-secondary);
  font-size: 15px;
  line-height: 24px;
}

.message-list,
.pending-approvals {
  width: min(100%, 920px);
  margin: 0 auto;
}

.message-list {
  display: flex;
  padding: 32px 24px 12px;
  flex-direction: column;
  gap: 30px;
}

.thread-loading {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink-tertiary);
  font-size: 12px;
  line-height: 18px;
}

.thread-loading svg {
  width: 16px;
  height: 16px;
  animation: thread-loading-spin 900ms linear infinite;
}

.history-load {
  display: flex;
  min-height: 36px;
  margin: -8px auto 0;
  padding: 6px 10px;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius);
  color: var(--ink-secondary);
  font-size: 12px;
  line-height: 18px;
  transition: color var(--fast), background-color var(--fast);
}

.history-load:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.history-load:disabled {
  color: var(--ink-tertiary);
  cursor: default;
}

@keyframes thread-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.message {
  min-width: 0;
  max-width: 100%;
}

.message-user {
  display: flex;
  align-self: flex-end;
  justify-content: flex-end;
}

.user-bubble {
  max-width: min(78%, 680px);
  padding: 11px 14px;
  border: 1px solid var(--clay-border);
  border-radius: var(--radius);
  background: var(--clay-soft);
  font-size: 15px;
  line-height: 24px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.user-files {
  display: flex;
  margin-top: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

.user-file {
  display: inline-flex;
  max-width: 260px;
  min-height: 28px;
  padding: 4px 8px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--clay-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 18px;
}

.user-file span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-agent {
  position: relative;
  padding-left: 22px;
}

.message-agent::before {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: 1px;
  background: var(--border);
  content: "";
}

.message-agent::after {
  position: absolute;
  top: 8px;
  left: 1px;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--clay);
  content: "";
}

.message-agent.streaming::after {
  animation: status-pulse 1.5s ease-out infinite;
}

.agent-label {
  margin-bottom: 7px;
  color: var(--ink-tertiary);
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
}

.markdown-body {
  max-width: 760px;
  color: var(--ink);
  font-size: 15px;
  line-height: 25px;
  overflow-wrap: anywhere;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table {
  margin: 0 0 14px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 24px 0 10px;
  font-weight: 600;
  line-height: 1.35;
}

.markdown-body h1 {
  font-size: 22px;
}

.markdown-body h2 {
  font-size: 19px;
}

.markdown-body h3,
.markdown-body h4 {
  font-size: 16px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 24px;
}

.markdown-body li + li {
  margin-top: 5px;
}

.markdown-body a {
  color: #2F6E9E;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.markdown-body code,
.tool-command,
.tool-output,
.approval-command,
.event-data {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 20px;
}

.markdown-body :not(pre) > code {
  padding: 2px 5px;
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  background: var(--paper-deep);
}

.markdown-body pre {
  max-width: 100%;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #20201E;
  color: #F5F4ED;
}

.markdown-body pre code {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 20px;
}

.markdown-body blockquote {
  padding: 8px 14px;
  border-left: 3px solid var(--border-strong);
  color: var(--ink-secondary);
}

.markdown-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
  padding: 7px 10px;
  border: 1px solid var(--border);
  text-align: left;
}

.markdown-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border-radius: var(--radius);
}

.stream-caret::after {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--clay);
  content: "";
  animation: caret-blink 1s steps(2, jump-none) infinite;
}

.tool-block,
.reasoning-block,
.approval-block,
.event-block {
  max-width: 760px;
  margin-left: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.tool-block + .tool-block,
.message-agent + .tool-block,
.tool-block + .message-agent,
.reasoning-block + .message-agent {
  margin-top: -14px;
}

.tool-header,
.reasoning-summary,
.event-header {
  display: flex;
  min-height: 44px;
  padding: 8px 12px;
  align-items: center;
  gap: 9px;
  color: var(--ink-secondary);
}

.tool-header svg,
.reasoning-summary svg,
.event-header svg {
  width: 17px;
  height: 17px;
  flex: none;
  stroke-width: 1.75;
}

.tool-title,
.event-title {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-status {
  flex: none;
  color: var(--ink-tertiary);
  font-size: 11px;
  line-height: 18px;
}

.tool-status[data-state="completed"] {
  color: var(--green);
}

.tool-status[data-state="failed"] {
  color: var(--red);
}

.tool-command,
.tool-output,
.event-data {
  margin: 0;
  padding: 11px 12px;
  overflow-x: auto;
  border-top: 1px solid var(--border-subtle);
  color: var(--ink-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tool-output {
  max-height: 320px;
  overflow-y: auto;
  background: var(--paper);
}

.reasoning-block {
  background: transparent;
}

.reasoning-summary {
  cursor: pointer;
  list-style: none;
}

.reasoning-summary::-webkit-details-marker {
  display: none;
}

.reasoning-body {
  padding: 0 12px 12px 38px;
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 21px;
  white-space: pre-wrap;
}

.pending-approvals {
  display: flex;
  padding: 4px 24px 24px;
  flex-direction: column;
  gap: 12px;
}

.approval-block {
  margin-left: 22px;
  border-color: var(--amber-border);
}

.approval-header {
  display: flex;
  min-height: 46px;
  padding: 11px 13px;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber);
  border-radius: var(--radius) var(--radius) 0 0;
}

.approval-header svg {
  width: 18px;
  height: 18px;
  flex: none;
  stroke-width: 1.75;
}

.approval-header strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.approval-body {
  padding: 13px;
}

.approval-description {
  margin: 0 0 10px;
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 21px;
}

.approval-context {
  margin: 0 0 10px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 20px;
}

.approval-fields {
  display: grid;
  margin-top: 12px;
  gap: 12px;
}

.approval-question {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 20px;
}

.approval-question strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.approval-question input:not([type="checkbox"]),
.approval-question select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.approval-question input:focus,
.approval-question select:focus {
  border-color: var(--clay);
  box-shadow: 0 0 0 3px var(--clay-soft);
}

.approval-check {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 9px;
}

.approval-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--clay);
}

.approval-link {
  display: inline-flex;
  min-height: 44px;
  margin-top: 2px;
  align-items: center;
  color: #2F6E9E;
  font-size: 13px;
  text-underline-offset: 3px;
}

.approval-command {
  max-height: 180px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--paper);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.approval-actions {
  display: flex;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.approval-actions .button {
  min-height: 40px;
  padding: 7px 12px;
}

.approval-resolved {
  display: flex;
  min-height: 44px;
  padding: 9px 13px;
  align-items: center;
  gap: 8px;
  color: var(--ink-secondary);
}

.error-message {
  width: min(100%, 760px);
  margin-left: 22px;
  padding: 11px 13px;
  border: 1px solid var(--red-border);
  border-radius: var(--radius);
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  line-height: 21px;
}

.composer-shell {
  position: relative;
  z-index: 10;
  width: 100%;
  padding: 8px max(24px, calc((100% - 920px) / 2 + 24px)) max(10px, env(safe-area-inset-bottom));
  flex: none;
  background: var(--paper);
}

.composer-shell::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  background: var(--border-subtle);
  content: "";
}

.upload-list {
  display: flex;
  max-height: 148px;
  margin-bottom: 8px;
  padding: 2px;
  overflow-x: auto;
  gap: 8px;
  scrollbar-width: thin;
}

.upload-list:empty {
  display: none;
}

.upload-item {
  display: grid;
  min-width: 190px;
  max-width: 260px;
  min-height: 52px;
  padding: 7px 6px 7px 9px;
  flex: 0 1 240px;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.upload-thumb {
  display: grid;
  width: 34px;
  height: 34px;
  overflow: hidden;
  place-items: center;
  border-radius: 8px;
  background: var(--paper-deep);
  color: var(--ink-secondary);
}

.upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-thumb svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.75;
}

.upload-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.upload-name {
  overflow: hidden;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-meta {
  color: var(--ink-tertiary);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 16px;
}

.upload-delete {
  width: 34px;
  height: 34px;
}

.upload-item[data-state="uploading"] {
  color: var(--ink-tertiary);
}

.upload-item[data-state="error"] {
  border-color: var(--red-border);
}

.composer {
  min-height: 96px;
  padding: 11px 11px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(20, 20, 19, 0.04);
  transition: border-color var(--fast), box-shadow var(--fast);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 40px;
  max-height: 180px;
  padding: 3px 4px 8px;
  resize: none;
  overflow-y: auto;
  outline: 0;
  background: transparent;
  font-size: 15px;
  line-height: 24px;
}

.composer textarea::placeholder {
  color: var(--ink-tertiary);
}

.composer-toolbar,
.composer-tools,
.composer-actions {
  display: flex;
  align-items: center;
}

.composer-toolbar {
  min-height: 44px;
  justify-content: space-between;
  gap: 12px;
}

.composer-tools,
.composer-actions {
  gap: 4px;
}

.settings-chip {
  display: inline-flex;
  min-width: 0;
  max-width: 190px;
  height: 36px;
  padding: 0 9px;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius);
  color: var(--ink-secondary);
  font-size: 12px;
  line-height: 18px;
}

.settings-chip:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.settings-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-chip svg {
  width: 14px;
  height: 14px;
}

.send-button {
  background: var(--clay);
  color: #FFFFFF;
}

.send-button:hover {
  background: var(--clay-hover);
  color: #FFFFFF;
}

.send-button:active {
  background: var(--clay-active);
}

.send-button:disabled {
  background: var(--surface-muted);
  color: var(--ink-disabled);
}

.stop-button {
  background: var(--red-soft);
  color: var(--red);
}

.stop-button:hover {
  background: var(--red-border);
  color: var(--red);
}

.upload-progress {
  margin-right: 4px;
  color: var(--ink-tertiary);
  font-size: 11px;
  line-height: 18px;
}

.composer-note {
  margin: 4px 4px 0;
  color: var(--ink-tertiary);
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

.panel-dialog {
  width: min(calc(100% - 32px), 620px);
  max-height: min(calc(100dvh - 32px), 760px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-panel);
}

.panel-dialog::backdrop {
  background: rgba(20, 20, 19, 0.32);
}

.dialog-frame {
  display: flex;
  max-height: min(calc(100dvh - 34px), 758px);
  flex-direction: column;
}

.dialog-header {
  display: flex;
  min-height: 74px;
  padding: 14px 14px 14px 20px;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 26px;
}

.dialog-header p {
  margin: 2px 0 0;
  color: var(--ink-secondary);
  font-size: 12px;
  line-height: 18px;
}

.path-row {
  display: grid;
  padding: 14px 16px 8px;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.path-row .icon-button {
  width: 40px;
  height: 40px;
}

.path-row input {
  height: 40px;
  min-width: 0;
  padding: 8px 11px;
  outline: 0;
  font-family: var(--font-mono);
  font-size: 12px;
}

.root-list {
  display: flex;
  padding: 4px 16px 8px;
  overflow-x: auto;
  gap: 6px;
}

.root-chip {
  display: inline-flex;
  min-width: max-content;
  height: 34px;
  padding: 0 10px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
}

.root-chip:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.directory-list {
  min-height: 220px;
  padding: 4px 12px 12px;
  overflow-y: auto;
}

.directory-item {
  display: grid;
  width: 100%;
  min-height: var(--touch);
  padding: 8px 10px;
  grid-template-columns: 20px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 9px;
  border-radius: var(--radius);
  color: var(--ink-secondary);
  text-align: left;
}

.directory-item:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.directory-item svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.75;
}

.directory-item span {
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.directory-loading,
.directory-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--ink-tertiary);
  font-size: 13px;
}

.dialog-error {
  padding: 0 18px 10px;
}

.dialog-footer {
  display: flex;
  min-height: 68px;
  padding: 12px 16px;
  flex: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.settings-fields {
  display: grid;
  padding: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  overflow-y: auto;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.field select {
  width: 100%;
  height: 44px;
  padding: 9px 34px 9px 12px;
  outline: 0;
}

.settings-warning {
  display: flex;
  margin: 0 20px 20px;
  padding: 11px 12px;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid var(--amber-border);
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  line-height: 19px;
}

.settings-warning svg {
  margin-top: 1px;
  flex: none;
}

.toast-region {
  position: fixed;
  z-index: 200;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  width: min(calc(100% - 24px), 430px);
  transform: translateX(-50%);
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  min-height: 48px;
  padding: 11px 13px;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-panel);
  color: var(--ink);
  font-size: 13px;
  line-height: 20px;
  animation: toast-in var(--slow);
  pointer-events: auto;
}

.toast svg {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex: none;
  stroke-width: 1.75;
}

.toast[data-kind="success"] svg {
  color: var(--green);
}

.toast[data-kind="error"] {
  border-color: var(--red-border);
}

.toast[data-kind="error"] svg {
  color: var(--red);
}

.toast[data-kind="warning"] {
  border-color: var(--amber-border);
}

.toast[data-kind="warning"] svg {
  color: var(--amber);
}

.toast button {
  width: 28px;
  height: 28px;
  margin: -4px -5px -4px auto;
}

.drawer-scrim {
  display: none;
}

@keyframes status-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes caret-blink {
  0%, 45% {
    opacity: 1;
  }
  46%, 100% {
    opacity: 0;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 840px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 90;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    transform: translateX(-100%);
    border-right: 0;
    transition: transform var(--slow);
  }

  .sidebar[data-open="true"] {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-grid;
  }

  .drawer-scrim {
    position: fixed;
    z-index: 80;
    inset: 0;
    display: block;
    background: rgba(20, 20, 19, 0.32);
  }

  .sidebar-actions,
  .project-section,
  .thread-section,
  .sidebar-footer {
    width: min(100%, 560px);
    margin-right: auto;
    margin-left: auto;
  }

  .workbench {
    width: 100%;
  }

  .mobile-topbar {
    display: flex;
    height: var(--topbar-height);
    padding: 0 10px;
    flex: none;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
  }

  .mobile-brand {
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    line-height: 22px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .conversation-topbar {
    min-height: 56px;
    padding: 7px 16px;
  }

  .conversation-actions .desktop-settings {
    display: none;
  }

  .cwd-button {
    max-width: calc(100vw - 140px);
  }

  .message-list {
    padding: 24px 16px 10px;
    gap: 26px;
  }

  .pending-approvals {
    padding: 4px 16px 20px;
  }

  .composer-shell {
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  }

  .composer-note {
    display: none;
  }

  .user-bubble {
    max-width: 88%;
  }

  .tool-block,
  .reasoning-block,
  .approval-block,
  .event-block,
  .error-message {
    margin-left: 16px;
  }
}

@media (max-width: 560px) {
  .login-view {
    min-height: 480px;
    padding: 0;
    place-items: stretch;
  }

  .login-panel {
    display: flex;
    width: 100%;
    min-height: 100%;
    padding: max(28px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
    justify-content: center;
    flex-direction: column;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .brand-login {
    margin-bottom: 56px;
  }

  .login-copy h1 {
    font-size: 24px;
    line-height: 32px;
  }

  .conversation-topbar {
    gap: 8px;
  }

  .run-state {
    padding: 0;
  }

  .run-state > span:last-child {
    display: none;
  }

  .cwd-button {
    max-width: calc(100vw - 76px);
  }

  .empty-state {
    padding: 40px 20px;
  }

  .empty-state h2 {
    font-size: 20px;
    line-height: 28px;
  }

  .user-bubble {
    max-width: 92%;
  }

  .message-agent {
    padding-left: 18px;
  }

  .message-agent::before {
    left: 2px;
  }

  .message-agent::after {
    left: -1px;
  }

  .markdown-body {
    font-size: 14px;
    line-height: 24px;
  }

  .tool-block,
  .reasoning-block,
  .approval-block,
  .event-block,
  .error-message {
    margin-left: 8px;
  }

  .composer {
    min-height: 88px;
  }

  .composer textarea {
    max-height: 132px;
  }

  .settings-chip {
    max-width: 132px;
  }

  .upload-list {
    max-height: 132px;
  }

  .upload-item {
    min-width: 176px;
  }

  .panel-dialog {
    width: 100%;
    max-width: none;
    max-height: 100dvh;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .dialog-frame {
    max-height: 100dvh;
    height: 100%;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .directory-list {
    flex: 1;
  }

  .settings-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-dialog .dialog-footer {
    margin-top: auto;
  }

  .approval-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .approval-actions .button-session {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --fast: 0ms;
    --slow: 0ms;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
