:root {
  color-scheme: light;
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-soft: #f9f7f1;
  --surface-pressed: #eeebe3;
  --ink: #181a16;
  --muted: #696d63;
  --quiet: #8d9187;
  --line: rgba(24, 26, 22, 0.1);
  --line-strong: rgba(24, 26, 22, 0.18);
  --accent: #256b4d;
  --accent-soft: #e5f2eb;
  --accent-ink: #ffffff;
  --warn: #9b6a17;
  --warn-soft: #f5ecd7;
  --danger: #b43d32;
  --danger-soft: #f6e4e1;
  --shadow: 0 18px 50px rgba(33, 35, 30, 0.09);
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --sans: "Aptos", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 0.85rem;
  padding: 0.72rem 1rem;
  cursor: pointer;
  color: var(--ink);
  background: var(--surface-pressed);
  transition: background 120ms ease, color 120ms ease, transform 120ms ease, opacity 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

button.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

button.ghost {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}

input,
select,
textarea {
  width: 100%;
  border: 0;
  border-radius: 0.95rem;
  padding: 0.82rem 0.9rem;
  color: var(--ink);
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--line);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 55%, var(--line));
}

textarea {
  min-height: 15rem;
  resize: vertical;
}

label,
.panel-heading,
.command-panel,
.connection-panel,
.metrics-panel,
.transcript-panel,
.side-panel,
.history-panel,
.log-panel {
  display: flex;
  flex-direction: column;
}

label {
  gap: 0.45rem;
}

label span,
.section-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.shell {
  width: min(1320px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.1rem 0 2.2rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
}

.brand-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4.4vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: -0.065em;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.25;
}

p,
small,
.command-hint,
.muted {
  color: var(--muted);
}

.intro-panel {
  margin-bottom: 1rem;
  max-width: 58rem;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.6;
}

.panel {
  border-radius: 1.15rem;
  padding: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.state-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: min(27rem, 100%);
  border-radius: 1rem;
  padding: 0.76rem 0.9rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.state-title {
  font-weight: 850;
}

.state-dot {
  width: 0.76rem;
  height: 0.76rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 0.34rem var(--danger-soft);
}

.state-dot.online,
.remote-state-online .state-dot {
  background: var(--accent);
  box-shadow: 0 0 0 0.34rem var(--accent-soft);
}

.remote-state-pairing .state-dot {
  background: var(--warn);
  box-shadow: 0 0 0 0.34rem var(--warn-soft);
}

.control-grid,
.status-grid,
.workspace-grid {
  display: grid;
  gap: 1rem;
}

.control-grid {
  grid-template-columns: minmax(18rem, 0.76fr) minmax(0, 1.24fr);
  margin-bottom: 1rem;
}

.status-grid {
  grid-template-columns: minmax(20rem, 0.95fr) minmax(0, 1.05fr);
  margin-bottom: 1rem;
}

.workspace-grid {
  grid-template-columns: minmax(0, 1.3fr) minmax(17rem, 0.82fr) minmax(18rem, 0.88fr);
}

.connection-panel,
.command-panel,
.metrics-panel,
.transcript-panel,
.side-panel,
.history-panel,
.log-panel {
  gap: 0.9rem;
}

.panel-heading {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.75rem;
  padding-bottom: 0.1rem;
}

.panel-heading p {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.step-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  border-radius: 0.7rem;
  background: var(--surface-pressed);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 0.75rem;
}

.prompt-field {
  flex: 1;
}

.prompt-field textarea {
  flex: 1;
}

.command-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.command-hint {
  max-width: 30rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.secondary-actions button,
.command-footer button {
  min-width: 7rem;
}

.run-button {
  min-width: 9rem;
}

.log {
  min-height: 11.8rem;
  max-height: 18rem;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  border-radius: 0.9rem;
  padding: 0.85rem;
  background: #1e211c;
  color: #f4f0e8;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
}

.transcript-stream,
.task-tree,
.runtime-event-stream,
.tool-stream,
.history-list,
.history-detail,
.audit-list,
.metrics-grid {
  display: grid;
  gap: 0.58rem;
}

.transcript-stream,
.runtime-event-stream,
.tool-stream,
.history-list,
.history-detail,
.audit-list {
  max-height: 30rem;
  overflow: auto;
}

.transcript-stream {
  min-height: 23rem;
}

.task-tree,
.runtime-event-stream,
.tool-stream,
.history-list,
.history-detail,
.audit-list {
  min-height: 4.5rem;
}

.section-title-spaced {
  margin-top: 0.35rem;
}

.transcript-message,
.task-item,
.runtime-event-item,
.tool-item,
.history-item,
.history-detail-card,
.audit-item,
.metric-item {
  width: 100%;
  border-radius: 0.9rem;
  padding: 0.78rem 0.85rem;
  text-align: left;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}

.transcript-message.pending {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(37, 107, 77, 0.22);
}

.transcript-message strong,
.task-item strong,
.runtime-event-item strong,
.tool-item strong,
.history-detail-card strong,
.audit-item strong,
.history-item strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.92rem;
}

.transcript-message pre,
.history-detail-card pre {
  margin: 0;
  white-space: pre-wrap;
  color: var(--ink);
  font: inherit;
  line-height: 1.48;
}

.task-item,
.runtime-event-item,
.tool-item {
  display: grid;
  gap: 0.2rem;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-item {
  min-width: 0;
  padding: 0.7rem 0.75rem;
}

.metric-item span {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--quiet);
  font-size: 0.72rem;
}

.metric-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.05rem;
}

.status-pill {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 0.15rem 0.48rem;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 0.68rem;
  font-weight: 850;
  vertical-align: middle;
}

.history-item {
  cursor: pointer;
}

.history-item:hover {
  background: var(--surface-pressed);
}

.history-item small,
.audit-item small,
.task-item small,
.runtime-event-item small,
.tool-item small,
.history-detail-card small {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.runtime-event-item.attention {
  background: color-mix(in srgb, var(--accent-soft) 70%, #3a2018);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

@media (max-width: 1080px) {
  .control-grid,
  .status-grid,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .transcript-stream {
    min-height: 16rem;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 1rem, 44rem);
    padding-top: 0.4rem;
  }

  .topbar,
  .command-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .state-card {
    min-width: 0;
  }

  h1 {
    font-size: 2.65rem;
  }

  .field-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    border-radius: 1rem;
    padding: 0.86rem;
  }

  .actions button,
  .command-footer button,
  .secondary-actions button {
    flex: 1 1 9rem;
  }
}

/* Remote workbench layout. Kept at the end to override the original card dashboard. */
:root {
  color-scheme: dark;
  --bg: #10110f;
  --surface: #1a1b18;
  --surface-soft: #22231f;
  --surface-pressed: #2b2d27;
  --ink: #f2efe6;
  --muted: #aaa699;
  --quiet: #7e7a70;
  --line: rgba(242, 239, 230, 0.1);
  --line-strong: rgba(242, 239, 230, 0.18);
  --accent: #c8a45d;
  --accent-soft: rgba(200, 164, 93, 0.16);
  --accent-ink: #16130d;
  --warn: #d9a441;
  --warn-soft: rgba(217, 164, 65, 0.16);
  --danger: #df6a5f;
  --danger-soft: rgba(223, 106, 95, 0.14);
  --shadow: none;
}

body {
  overflow: hidden;
  background: var(--bg);
}

.remote-workbench {
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  background: var(--bg);
}

.remote-sidebar,
.remote-chat {
  min-height: 0;
}

.remote-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem 0.8rem 1rem 1rem;
  background: #151612;
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  display: grid;
  gap: 0.8rem;
  padding: 0.2rem 0.1rem 0;
}

.sidebar-brand h1 {
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.compact-state-card {
  min-width: 0;
  padding: 0.72rem;
  border-radius: 0.95rem;
  background: var(--surface);
  box-shadow: none;
}

.connection-panel,
.workspace-card {
  gap: 0.75rem;
  border-radius: 1rem;
  padding: 0.85rem;
  background: var(--surface);
  box-shadow: none;
}

.connection-panel input,
.workspace-card input,
.chat-controls input,
.chat-controls select,
.prompt-field textarea {
  background: var(--surface-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.remote-state-online .connection-panel {
  padding: 0.65rem 0.85rem;
}

.remote-state-online .connection-panel label {
  display: none;
}

.connection-actions,
.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.provider-config-trigger {
  grid-column: 1 / -1;
}

.workspace-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}

.workspace-card small,
.history-detail {
  color: var(--muted);
  line-height: 1.45;
  word-break: break-all;
}

.history-sidebar-section {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.65rem;
}

.sidebar-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.2rem;
}

.sidebar-history-list {
  min-height: 0;
  max-height: none;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 0.25rem;
}

.workspace-tree-node {
  display: grid;
  gap: 0.12rem;
}

.workspace-tree-summary {
  width: 100%;
  border: 0;
  display: grid;
  grid-template-columns: 0.8rem 1rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.36rem;
  min-height: 2.08rem;
  border-radius: 0.68rem;
  padding: 0.38rem 0.38rem 0.38rem 0.46rem;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.workspace-tree-summary:hover {
  background: var(--surface-soft);
}

.tree-twist::before {
  content: '▸';
  display: inline-block;
  color: var(--quiet);
  font-size: 0.72rem;
  transform: translateY(-0.02rem);
  transition: transform 120ms ease;
}

.workspace-tree-node:not(.collapsed) > .workspace-tree-summary .tree-twist::before {
  transform: rotate(90deg) translateX(0.02rem);
}

.workspace-tree-node.collapsed > .workspace-tree-children {
  display: none;
}

.tree-folder,
.tree-chat-icon {
  position: relative;
  width: 0.9rem;
  height: 0.72rem;
  opacity: 0.86;
}

.tree-folder::before {
  content: '';
  position: absolute;
  inset: 0.18rem 0 0;
  border: 1px solid var(--quiet);
  border-radius: 0.12rem;
}

.tree-folder::after {
  content: '';
  position: absolute;
  left: 0.05rem;
  top: 0;
  width: 0.45rem;
  height: 0.24rem;
  border: 1px solid var(--quiet);
  border-bottom: 0;
  border-radius: 0.12rem 0.12rem 0 0;
}

.tree-workspace-text,
.tree-history-text {
  min-width: 0;
  display: grid;
  gap: 0.1rem;
}

.tree-workspace-text strong,
.tree-workspace-text small,
.tree-history-text strong,
.tree-history-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-workspace-text strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.tree-workspace-text small,
.tree-history-text small {
  color: var(--quiet);
  font-size: 0.7rem;
}

.tree-count {
  min-width: 1.15rem;
  border-radius: 999px;
  padding: 0.08rem 0.34rem;
  color: var(--quiet);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.68rem;
  text-align: center;
}

.tree-new-conversation {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.42rem;
  height: 1.42rem;
  border-radius: 0.48rem;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 70%, transparent);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

.tree-new-conversation:hover,
.tree-new-conversation:focus-visible {
  background: var(--accent);
  color: var(--accent-ink);
  outline: none;
}

.workspace-tree-children {
  display: grid;
  gap: 0.1rem;
  margin-left: 1.28rem;
  padding-left: 0.55rem;
  border-left: 1px solid var(--line);
}

.workspace-history-empty,
.workspace-history-more {
  padding: 0.4rem 0.45rem 0.54rem;
  color: var(--quiet);
  font-size: 0.76rem;
}

.workspace-history-more {
  width: 100%;
  border-radius: 0.58rem;
  background: transparent;
  box-shadow: none;
  text-align: left;
}

.workspace-history-more:hover {
  color: var(--accent);
  background: var(--surface-soft);
}

.history-item {
  border-radius: 0.66rem;
  padding: 0.48rem 0.5rem;
  background: transparent;
  box-shadow: none;
}

.history-item:hover,
.history-item.selected {
  background: var(--surface-soft);
}

.history-item strong,
.history-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item strong {
  margin-bottom: 0.1rem;
  color: var(--ink);
  font-size: 0.82rem;
}

.tree-history-item {
  display: grid;
  grid-template-columns: 0.95rem minmax(0, 1fr);
  align-items: center;
  gap: 0.32rem;
}

.tree-chat-icon::before {
  content: '';
  position: absolute;
  inset: 0.08rem 0.08rem 0.18rem;
  border: 1px solid var(--quiet);
  border-radius: 0.12rem;
}

.tree-chat-icon::after {
  content: '';
  position: absolute;
  left: 0.18rem;
  bottom: 0.04rem;
  width: 0.24rem;
  height: 0.24rem;
  border-left: 1px solid var(--quiet);
  border-bottom: 1px solid var(--quiet);
  transform: skewX(-18deg);
}

.remote-chat {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg);
}

.chat-header {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: #151612;
}

.chat-header .history-detail {
  display: block;
  min-height: 0;
  margin-top: 0.15rem;
  overflow: hidden;
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.header-action {
  display: grid;
  place-items: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.35rem;
  border-radius: 0.55rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.header-action::-webkit-details-marker {
  display: none;
}

.header-action:hover,
.chat-header-actions details[open] > .header-action {
  color: var(--accent);
  background: var(--accent-soft);
}

.display-settings-panel,
.details-grid {
  position: absolute;
  inset: calc(100% + 0.3rem) max(0.65rem, env(safe-area-inset-right)) auto auto;
  max-height: 65vh;
  max-height: 65dvh;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line-strong);
  border-radius: 0.8rem;
  background: var(--surface);
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.45);
}

.display-settings-panel {
  width: min(18rem, calc(100% - 1.3rem));
  padding: 0.8rem;
}

.display-settings-option {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
}

.display-settings-option input {
  width: 1.1rem;
  height: 1.1rem;
  flex: none;
  margin: 0.1rem 0 0;
  accent-color: var(--accent);
}

.display-settings-option span {
  color: var(--ink);
  font-size: 0.88rem;
}

.display-settings-option small {
  display: block;
  margin-top: 0.22rem;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.45;
}

.header-action:focus-visible,
button:focus-visible,
.display-settings-option input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chat-heading {
  min-width: 0;
}

.chat-heading-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.chat-heading-copy {
  min-width: 0;
  flex: 1;
}

.chat-header h2 {
  margin-top: 0.12rem;
  overflow: hidden;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-header-button,
.sidebar-backdrop {
  display: none;
}

.chat-controls {
  width: min(32rem, 36vw);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.chat-controls label,
.prompt-field {
  gap: 0.34rem;
}

.chat-controls input,
.chat-controls select {
  padding: 0.62rem 0.72rem;
  border-radius: 0.78rem;
}

.chat-stream {
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  max-height: none;
  min-height: 0;
  overflow: auto;
  padding: 1.2rem;
  align-content: start;
  background: #10110f;
}

.chat-message {
  min-width: 0;
  overflow-wrap: anywhere;
  width: min(48rem, 86%);
  padding: 0.86rem 0.95rem;
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: none;
}

.chat-message.role-user {
  justify-self: end;
  background: #d8c28f;
  color: #17140d;
}

.chat-message.role-user pre,
.chat-message.role-user .message-meta span {
  color: #17140d;
}

.chat-message.role-assistant {
  justify-self: start;
}

.chat-message.role-system_event,
.chat-message.role-system {
  justify-self: center;
  width: min(42rem, 92%);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.34rem;
}

.message-meta strong {
  margin: 0;
  font-size: 0.82rem;
  text-transform: capitalize;
}

.message-meta span {
  color: var(--quiet);
  font-size: 0.72rem;
}

.message-resume-button {
  margin-top: 0.7rem;
  padding: 0.5rem 0.9rem;
  border-radius: 0.72rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.markdown-body {
  color: inherit;
  line-height: 1.58;
  overflow-wrap: anywhere;
}

.markdown-body p {
  color: inherit;
}

.transcript-message .markdown-body strong {
  display: inline;
  margin: 0;
  font-size: inherit;
}

.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 {
  margin: 0.55rem 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 0.8rem 0 0.42rem;
  color: inherit;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.markdown-body h1 { font-size: 1.35rem; }
.markdown-body h2 { font-size: 1.18rem; }
.markdown-body h3 { font-size: 1.04rem; }
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 { font-size: 0.96rem; }

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.3rem;
}

.markdown-body li + li {
  margin-top: 0.22rem;
}

.markdown-body blockquote {
  border-left: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  padding: 0.18rem 0 0.18rem 0.8rem;
  color: var(--muted);
}

.markdown-body code {
  border-radius: 0.35rem;
  padding: 0.08rem 0.28rem;
  background: rgba(255, 255, 255, 0.08);
  font-family: var(--mono);
  font-size: 0.88em;
}

.markdown-body .markdown-code-block {
  overflow: auto;
  border-radius: 0.72rem;
  padding: 0.8rem;
  background: #0b0c0a;
  box-shadow: inset 0 0 0 1px var(--line);
}

.markdown-body .markdown-code-block code {
  display: block;
  padding: 0;
  background: transparent;
  white-space: pre;
}

.markdown-table-scroll {
  max-width: 100%;
  margin-block: 0.55rem;
  overflow-x: auto;
}

.markdown-table-scroll table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}

.markdown-table-scroll :is(th, td) {
  min-width: 5rem;
  padding: 0.36rem 0.55rem;
  border: 1px solid var(--line-strong);
  text-align: left;
  vertical-align: top;
}

.markdown-table-scroll th {
  background: var(--surface-pressed);
}

.role-user .markdown-table-scroll :is(th, td) {
  border-color: rgba(23, 20, 13, 0.22);
}

.role-user .markdown-table-scroll th {
  background: rgba(23, 20, 13, 0.08);
}

.markdown-table-scroll .markdown-table-align-center { text-align: center; }
.markdown-table-scroll .markdown-table-align-right { text-align: right; }

.markdown-body a {
  color: #e7c777;
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.chat-message.role-user .markdown-body blockquote,
.chat-message.role-user .markdown-body a,
.chat-message.role-user .markdown-body code {
  color: #17140d;
}

.chat-message.role-user .markdown-body code {
  background: rgba(23, 20, 13, 0.12);
}

.chat-message.role-user .markdown-body .markdown-code-block {
  background: rgba(23, 20, 13, 0.08);
  box-shadow: inset 0 0 0 1px rgba(23, 20, 13, 0.18);
}

.message-attachments {
  display: grid;
  gap: 0.62rem;
  margin-top: 0.72rem;
}

.message-image-card,
.message-attachment-card {
  overflow: hidden;
  margin: 0;
  border-radius: 0.86rem;
  background: color-mix(in srgb, var(--surface-soft) 82%, transparent);
  box-shadow: inset 0 0 0 1px var(--line);
}

.message-image-card img {
  display: block;
  width: 100%;
  max-height: min(58vh, 34rem);
  object-fit: contain;
  background: #0b0c0a;
}

.message-image-card figcaption,
.message-attachment-card {
  padding: 0.56rem 0.68rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.message-attachment-card strong,
.message-attachment-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-attachment-card strong {
  margin-bottom: 0.14rem;
  color: var(--ink);
  font-size: 0.82rem;
}

.chat-message.role-user .message-image-card,
.chat-message.role-user .message-attachment-card {
  background: rgba(23, 20, 13, 0.08);
  box-shadow: inset 0 0 0 1px rgba(23, 20, 13, 0.18);
}

.chat-message.role-user .message-image-card figcaption,
.chat-message.role-user .message-attachment-card,
.chat-message.role-user .message-attachment-card strong,
.chat-message.role-user .message-attachment-card small {
  color: #17140d;
}

.chat-message.tool-round-message {
  width: min(38rem, 100%);
  padding: 0;
  border-radius: 0.65rem;
  background: var(--surface);
}

.tool-round-card {
  min-width: 0;
}

.tool-round-summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.25rem 0.65rem;
  list-style: none;
  cursor: pointer;
}

.tool-round-summary::-webkit-details-marker {
  display: none;
}

.tool-round-summary::before {
  content: '';
  width: 0.36rem;
  height: 0.36rem;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  color: var(--muted);
  transform: rotate(-45deg);
}

.tool-round-card[open] > .tool-round-summary::before {
  transform: rotate(45deg);
}

.tool-round-count,
.tool-round-status,
.tool-round-names {
  color: var(--muted);
  font-size: 0.74rem;
}

.tool-round-summary > :not(.tool-round-names) {
  flex: none;
}

.tool-round-names {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-round-card.has-failure .tool-round-status {
  color: var(--danger);
}

.tool-round-summary::before {
  flex: none;
}

.tool-round-label {
  color: var(--quiet);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.tool-round-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  min-width: 0;
  padding: 0 0.65rem 0.6rem;
}

.tool-round-chip {
  max-width: min(18rem, 100%);
  overflow: hidden;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  background: var(--surface-pressed);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-changes-message {
  width: min(52rem, 94%);
}

.workspace-change-card {
  overflow: hidden;
  border-radius: 0.9rem;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}

.workspace-change-empty {
  padding: 0.85rem 1rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.workspace-change-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.82rem 1rem;
}

.workspace-change-header strong {
  margin-right: 0.1rem;
  font-size: 0.92rem;
}

.workspace-change-header small {
  margin-left: auto;
  color: var(--quiet);
  font-size: 0.76rem;
}

.workspace-change-addition {
  color: var(--accent);
  font-weight: 800;
}

.workspace-change-deletion {
  color: var(--danger);
  font-weight: 800;
}

.workspace-change-files {
  border-top: 1px solid var(--line);
}

.workspace-change-file {
  border-top: 1px solid var(--line);
}

.workspace-change-file:first-child {
  border-top: 0;
}

.workspace-change-file summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.7rem;
  align-items: center;
  min-height: 3rem;
  padding: 0.72rem 1rem;
  cursor: pointer;
  list-style: none;
}

.workspace-change-file summary::-webkit-details-marker {
  display: none;
}

.workspace-change-file summary:hover {
  background: color-mix(in srgb, var(--surface-pressed) 70%, transparent);
}

.workspace-change-path {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-change-status {
  border-radius: 999px;
  padding: 0.12rem 0.42rem;
  background: var(--surface-pressed);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.workspace-change-stats {
  display: inline-flex;
  gap: 0.42rem;
  justify-self: end;
  font-size: 0.82rem;
}

.workspace-change-diff {
  overflow: auto;
  max-height: 22rem;
  margin: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 0.9rem 1rem;
  background: #0b0c0a;
  color: #ede7d5;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre;
}

.workspace-change-diff code {
  font-family: inherit;
}

.workspace-change-no-diff {
  border-top: 1px solid var(--line);
  padding: 0.75rem 1rem 0.85rem;
  color: var(--quiet);
  font-size: 0.78rem;
}

.details-grid {
  width: min(52rem, calc(100% - 1.3rem));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  padding: 0.85rem;
}

.details-grid section {
  min-width: 0;
}

.log-section {
  grid-column: 1 / -1;
}

.task-tree,
.runtime-event-stream,
.tool-stream,
.audit-list,
.metrics-grid {
  max-height: 11rem;
  overflow: auto;
}

.metrics-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.log {
  min-height: 7rem;
  max-height: 10rem;
  background: #0c0d0b;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.72rem 0.8rem;
  align-items: end;
  padding: 0.9rem 1.2rem 1.05rem;
  border-top: 1px solid var(--line);
  background: #151612;
}

.composer-target {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.42rem 0.55rem;
}

.conversation-target-field {
  min-width: 0;
  gap: 0.3rem;
}

.conversation-target-field select {
  width: 100%;
  min-width: 0;
  padding: 0.56rem 0.68rem;
  border-radius: 0.72rem;
}

.composer-new-button {
  min-height: 2.42rem;
  padding: 0.52rem 0.78rem;
  white-space: nowrap;
}

.composer-target small {
  grid-column: 1 / -1;
  overflow: hidden;
  color: var(--quiet);
  font-size: 0.72rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer textarea {
  min-height: 4.4rem;
  max-height: 11rem;
  resize: vertical;
  border-radius: 1rem;
}

.composer-actions {
  display: flex;
  gap: 0.55rem;
}

.composer-actions button {
  min-width: 5.8rem;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

button.ghost {
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.provider-dialog {
  width: min(48rem, calc(100% - 2rem));
  max-height: min(48rem, calc(100dvh - 2rem));
  overflow: auto;
  border: 0;
  border-radius: 1.25rem;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 2rem 5rem rgba(0, 0, 0, 0.35);
}

.provider-dialog::backdrop {
  background: rgba(8, 9, 7, 0.72);
  backdrop-filter: blur(4px);
}

.provider-dialog-panel {
  display: grid;
  gap: 1rem;
  padding: 1.15rem;
}

.provider-dialog-header,
.provider-dialog-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.provider-dialog-header h2 {
  margin-bottom: 0.25rem;
  font-size: 1.4rem;
  letter-spacing: -0.035em;
}

.provider-dialog-header p:not(.eyebrow) {
  max-width: 34rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.provider-dialog-close {
  flex: 0 0 auto;
}

.provider-config-status {
  border-radius: 0.8rem;
  padding: 0.7rem 0.8rem;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 0.82rem;
  font-weight: 750;
}

.provider-config-status.muted {
  color: var(--muted);
  background: var(--surface-soft);
}

.provider-config-status.attention {
  color: var(--danger);
  background: var(--danger-soft);
}

.provider-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.provider-field-wide {
  grid-column: 1 / -1;
}

.provider-model-input {
  min-height: 6.5rem;
  max-height: 13rem;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.provider-protocols {
  margin: 0;
  border: 0;
  border-radius: 0.95rem;
  padding: 0.8rem;
  background: var(--surface-soft);
}

.provider-protocols legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.provider-protocol-options,
.provider-toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.75rem;
}

.provider-check {
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  border-radius: 0.72rem;
  padding: 0.55rem 0.65rem;
  background: var(--surface-soft);
}

.provider-check input {
  width: auto;
  flex: 0 0 auto;
  box-shadow: none;
}

.provider-check span {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.danger-check {
  color: var(--danger);
  background: var(--danger-soft);
}

.danger-check span {
  color: var(--danger);
}

.provider-dialog-actions {
  align-items: center;
  padding-top: 0.25rem;
}

.provider-dialog-actions small {
  max-width: 24rem;
  line-height: 1.4;
}

.provider-form-empty .provider-form-grid,
.provider-form-empty .provider-protocols,
.provider-form-empty .provider-toggle-grid,
.provider-form-empty .provider-dialog-actions {
  display: none;
}

@media (max-width: 960px), (max-width: 1200px) and (orientation: portrait) {
  .provider-dialog {
    width: calc(100% - 1rem);
    max-height: calc(100dvh - 1rem);
  }

  .provider-form-grid,
  .provider-protocol-options,
  .provider-toggle-grid {
    grid-template-columns: 1fr;
  }

  .provider-field-wide {
    grid-column: auto;
  }

  .provider-dialog-header,
  .provider-dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .provider-dialog-actions .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    overscroll-behavior: none;
  }

  .remote-workbench {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    display: block;
  }

  .remote-sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(88vw, 22rem);
    height: 100vh;
    height: 100dvh;
    padding: max(0.85rem, env(safe-area-inset-top)) 0.75rem max(0.85rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
    overflow: hidden;
    border-right: 1px solid var(--line-strong);
    border-bottom: 0;
    box-shadow: 1.2rem 0 3rem rgba(0, 0, 0, 0.35);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .mobile-sidebar-open .remote-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 20;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.58);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .sidebar-backdrop:hover:not(:disabled) {
    transform: none;
  }

  .mobile-sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-brand {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .sidebar-brand .compact-state-card {
    min-width: 8.5rem;
  }

  .sidebar-brand .compact-state-card small {
    display: none;
  }

  .remote-state-online .connection-panel {
    display: none;
  }

  .sidebar-history-list {
    max-height: none;
    overscroll-behavior: contain;
  }

  .remote-chat {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
  }

  .chat-header {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem;
    padding: max(0.12rem, env(safe-area-inset-top)) max(0.35rem, env(safe-area-inset-right)) 0.12rem max(0.35rem, env(safe-area-inset-left));
  }

  .chat-heading-row {
    align-items: center;
  }

  .chat-heading-copy .eyebrow {
    display: none;
  }

  .chat-header h2 {
    margin: 0;
    overflow: hidden;
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-header .history-detail {
    font-size: 0.68rem;
  }

  .chat-header .history-detail.muted {
    display: none;
  }

  .chat-heading-row {
    gap: 0.2rem;
  }

  .chat-header-actions {
    gap: 0;
  }

  .desktop-tool-toggle {
    display: none;
  }

  .mobile-header-button {
    min-width: 2.75rem;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    border-radius: 0.55rem;
    padding: 0.35rem;
    color: var(--muted);
    background: transparent;
    font-size: 0.82rem;
    font-weight: 700;
  }

  .mobile-header-button svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
  }

  .mobile-header-button[aria-expanded='true'] {
    color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
  }

  .chat-controls {
    grid-column: 1 / -1;
    width: 100%;
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0.2rem 0.3rem 0.45rem;
  }

  .mobile-controls-open .chat-controls {
    display: grid;
  }

  .chat-controls label:last-child {
    grid-column: 1 / -1;
  }

  .chat-controls input,
  .chat-controls select {
    min-height: 2.65rem;
    padding: 0.56rem 0.65rem;
    font-size: 1rem;
  }

  .chat-stream {
    min-height: 0;
    gap: 0.45rem;
    padding: 0.6rem max(0.55rem, env(safe-area-inset-right)) 0.75rem max(0.55rem, env(safe-area-inset-left));
    overscroll-behavior: contain;
    scroll-padding-block: 1rem;
  }

  .chat-message,
  .tool-round-message,
  .workspace-changes-message,
  .chat-message.role-system_event,
  .chat-message.role-system {
    width: 100%;
  }

  .chat-message {
    border-radius: 0.7rem;
    padding: 0.54rem 0.62rem;
    font-size: 0.94rem;
  }

  .chat-message.role-assistant:not(.pending, .tool-round-message) {
    background: transparent;
  }

  .chat-message.tool-round-message {
    background: transparent;
  }

  .tool-round-message > .message-meta {
    display: none;
  }

  .chat-message.role-user {
    width: fit-content;
    max-width: 90%;
    background: #d8c28f;
  }

  .message-meta {
    gap: 0.38rem;
    margin-bottom: 0.2rem;
  }

  .message-meta span {
    font-size: 0.68rem;
  }

  .markdown-body .markdown-code-block,
  .workspace-change-diff {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .workspace-change-header {
    flex-wrap: wrap;
  }

  .workspace-change-header small {
    width: 100%;
    margin-left: 0;
  }

  .workspace-change-file summary {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.45rem;
    padding-inline: 0.75rem;
  }

  .workspace-change-status {
    display: none;
  }

  .details-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .task-tree,
  .runtime-event-stream,
  .tool-stream,
  .audit-list,
  .metrics-grid {
    max-height: 14rem;
  }

  .composer {
    gap: 0.25rem 0.42rem;
    padding: 0.2rem max(0.55rem, env(safe-area-inset-right)) max(0.35rem, env(safe-area-inset-bottom)) max(0.55rem, env(safe-area-inset-left));
  }

  .composer .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .composer-target {
    gap: 0.35rem 0.42rem;
  }

  .conversation-target-field select {
    min-height: 2.75rem;
    padding: 0.45rem 0.5rem;
    background: transparent;
    box-shadow: none;
  }

  .composer-new-button {
    min-height: 2.75rem;
    padding-inline: 0.5rem;
    font-size: 0.85rem;
    box-shadow: none;
  }

  .composer textarea {
    height: 2.95rem;
    min-height: 2.95rem;
    max-height: 7rem;
    padding: 0.65rem 0.7rem;
    border-radius: 0.72rem;
    font-size: 1rem;
  }

  .composer-actions {
    display: grid;
    gap: 0.4rem;
  }

  .composer-actions button {
    min-width: 4.8rem;
    min-height: 2.65rem;
    padding: 0.55rem 0.7rem;
  }

  .composer-actions .danger:disabled {
    display: none;
  }
}

@media (max-width: 390px) {
  .sidebar-brand {
    grid-template-columns: 1fr;
  }

  .sidebar-brand .compact-state-card {
    min-width: 0;
  }

  .chat-header h2 {
    font-size: 0.92rem;
  }
}
