:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #eef2f1;
  color: #1e252b;
}

.ui-skin-glass .topbar,
.ui-skin-glass .context-panel,
.ui-skin-glass .composer,
.ui-skin-glass .sidebar-section-body,
.ui-skin-glass .message-body,
.ui-skin-glass .trace-list div,
.ui-skin-glass .tool,
.ui-skin-glass .fetch-iframe-container {
  background: rgba(251, 252, 253, 0.78);
  -webkit-backdrop-filter: blur(16px) saturate(1.18);
  backdrop-filter: blur(16px) saturate(1.18);
}

.ui-skin-glass .chat-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(238, 242, 241, 0.72)),
    #eef2f1;
}

.ui-skin-glass .sidebar-section-header,
.ui-skin-glass .drawer-brand,
.ui-skin-glass .fetch-iframe-header {
  background: rgba(238, 242, 241, 0.76);
  -webkit-backdrop-filter: blur(14px) saturate(1.16);
  backdrop-filter: blur(14px) saturate(1.16);
}

.ui-skin-contrast .topbar,
.ui-skin-contrast .context-panel,
.ui-skin-contrast .composer,
.ui-skin-contrast .message-body,
.ui-skin-contrast .trace-list div,
.ui-skin-contrast .tool {
  border-color: #25313a;
}

.ui-skin-contrast .topbar,
.ui-skin-contrast .drawer-brand,
.ui-skin-contrast .sidebar-section-header {
  background: #ffffff;
}

.ui-skin-contrast .chat-panel,
.ui-skin-contrast .sidebar-section-body {
  background: #f4f7f7;
}

.ui-skin-contrast .mode-toggle,
.ui-skin-contrast .diagnostics-toggle,
.ui-skin-contrast .agent-toggle,
.ui-skin-contrast .mobile-menu-toggle,
.ui-skin-contrast .drawer-close,
.ui-skin-contrast .drawer-action,
.ui-skin-contrast .report-button,
.ui-skin-contrast .memory-button,
.ui-skin-contrast .composer-action-button,
.ui-skin-contrast .composer-menu-item,
.ui-skin-contrast .prompt-list button,
.ui-skin-contrast .conversation-new,
.ui-skin-contrast .conversation-entry-button,
.ui-skin-contrast .conversation-delete,
.ui-skin-contrast textarea,
.ui-skin-contrast .setting-row input[type="text"],
.ui-skin-contrast .setting-row select {
  border-color: #25313a;
}

.chat-style-compact .messages {
  gap: 8px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.chat-style-compact .message {
  gap: 8px;
}

.chat-style-compact .message-body {
  padding: 8px 10px;
}

.chat-style-compact .message-meta,
.chat-style-compact .message-actions {
  font-size: 12px;
}

.chat-style-bubbles .message {
  grid-template-columns: 30px minmax(0, min(720px, 100%));
}

.chat-style-bubbles .message.user {
  grid-template-columns: minmax(0, min(720px, 100%)) 30px;
}

.chat-style-bubbles .message-body {
  border-radius: 18px;
}

.chat-style-bubbles .message.user .message-body {
  border-color: #b7d0f8;
  background: #e9f2ff;
}

.chat-style-bubbles .message.assistant .message-body {
  border-color: #c8dad3;
  background: #f7fbf9;
}

:root[data-theme="dark"] .ui-skin-glass .topbar,
:root[data-theme="dark"] .ui-skin-glass .context-panel,
:root[data-theme="dark"] .ui-skin-glass .composer,
:root[data-theme="dark"] .ui-skin-glass .sidebar-section-body,
:root[data-theme="dark"] .ui-skin-glass .message-body,
:root[data-theme="dark"] .ui-skin-glass .trace-list div,
:root[data-theme="dark"] .ui-skin-glass .tool,
:root[data-theme="dark"] .ui-skin-glass .fetch-iframe-container {
  background: rgba(29, 32, 31, 0.78);
}

:root[data-theme="dark"] .ui-skin-glass .chat-panel {
  background:
    linear-gradient(180deg, rgba(32, 35, 34, 0.62), rgba(24, 26, 27, 0.78)),
    #181a1b;
}

:root[data-theme="dark"] .ui-skin-glass .sidebar-section-header,
:root[data-theme="dark"] .ui-skin-glass .drawer-brand,
:root[data-theme="dark"] .ui-skin-glass .fetch-iframe-header {
  background: rgba(34, 38, 36, 0.76);
}

:root[data-theme="dark"] .ui-skin-contrast .topbar,
:root[data-theme="dark"] .ui-skin-contrast .context-panel,
:root[data-theme="dark"] .ui-skin-contrast .composer,
:root[data-theme="dark"] .ui-skin-contrast .message-body,
:root[data-theme="dark"] .ui-skin-contrast .trace-list div,
:root[data-theme="dark"] .ui-skin-contrast .tool,
:root[data-theme="dark"] .ui-skin-contrast .mode-toggle,
:root[data-theme="dark"] .ui-skin-contrast .diagnostics-toggle,
:root[data-theme="dark"] .ui-skin-contrast .agent-toggle,
:root[data-theme="dark"] .ui-skin-contrast .mobile-menu-toggle,
:root[data-theme="dark"] .ui-skin-contrast .drawer-close,
:root[data-theme="dark"] .ui-skin-contrast .drawer-action,
:root[data-theme="dark"] .ui-skin-contrast .report-button,
:root[data-theme="dark"] .ui-skin-contrast .memory-button,
:root[data-theme="dark"] .ui-skin-contrast .composer-action-button,
:root[data-theme="dark"] .ui-skin-contrast .composer-menu-item,
:root[data-theme="dark"] .ui-skin-contrast .prompt-list button,
:root[data-theme="dark"] .ui-skin-contrast .conversation-new,
:root[data-theme="dark"] .ui-skin-contrast .conversation-entry-button,
:root[data-theme="dark"] .ui-skin-contrast .conversation-delete,
:root[data-theme="dark"] .ui-skin-contrast textarea,
:root[data-theme="dark"] .ui-skin-contrast .setting-row input[type="text"],
:root[data-theme="dark"] .ui-skin-contrast .setting-row select {
  border-color: #c9c1b6;
}

:root[data-theme="dark"] .chat-style-bubbles .message.user .message-body {
  border-color: #365878;
  background: #1e3142;
}

:root[data-theme="dark"] .chat-style-bubbles .message.assistant .message-body {
  border-color: #3f514b;
  background: #202826;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ui-skin-glass .topbar,
  :root:not([data-theme="light"]) .ui-skin-glass .context-panel,
  :root:not([data-theme="light"]) .ui-skin-glass .composer,
  :root:not([data-theme="light"]) .ui-skin-glass .sidebar-section-body,
  :root:not([data-theme="light"]) .ui-skin-glass .message-body,
  :root:not([data-theme="light"]) .ui-skin-glass .trace-list div,
  :root:not([data-theme="light"]) .ui-skin-glass .tool,
  :root:not([data-theme="light"]) .ui-skin-glass .fetch-iframe-container {
    background: rgba(29, 32, 31, 0.78);
  }

  :root:not([data-theme="light"]) .ui-skin-glass .chat-panel {
    background:
      linear-gradient(180deg, rgba(32, 35, 34, 0.62), rgba(24, 26, 27, 0.78)),
      #181a1b;
  }

  :root:not([data-theme="light"]) .ui-skin-glass .sidebar-section-header,
  :root:not([data-theme="light"]) .ui-skin-glass .drawer-brand,
  :root:not([data-theme="light"]) .ui-skin-glass .fetch-iframe-header {
    background: rgba(34, 38, 36, 0.76);
  }

  :root:not([data-theme="light"]) .ui-skin-contrast .topbar,
  :root:not([data-theme="light"]) .ui-skin-contrast .context-panel,
  :root:not([data-theme="light"]) .ui-skin-contrast .composer,
  :root:not([data-theme="light"]) .ui-skin-contrast .message-body,
  :root:not([data-theme="light"]) .ui-skin-contrast .trace-list div,
  :root:not([data-theme="light"]) .ui-skin-contrast .tool,
  :root:not([data-theme="light"]) .ui-skin-contrast .mode-toggle,
  :root:not([data-theme="light"]) .ui-skin-contrast .diagnostics-toggle,
  :root:not([data-theme="light"]) .ui-skin-contrast .agent-toggle,
  :root:not([data-theme="light"]) .ui-skin-contrast .mobile-menu-toggle,
  :root:not([data-theme="light"]) .ui-skin-contrast .drawer-close,
  :root:not([data-theme="light"]) .ui-skin-contrast .drawer-action,
  :root:not([data-theme="light"]) .ui-skin-contrast .report-button,
  :root:not([data-theme="light"]) .ui-skin-contrast .memory-button,
  :root:not([data-theme="light"]) .ui-skin-contrast .composer-action-button,
  :root:not([data-theme="light"]) .ui-skin-contrast .composer-menu-item,
  :root:not([data-theme="light"]) .ui-skin-contrast .prompt-list button,
  :root:not([data-theme="light"]) .ui-skin-contrast .conversation-new,
  :root:not([data-theme="light"]) .ui-skin-contrast .conversation-entry-button,
  :root:not([data-theme="light"]) .ui-skin-contrast .conversation-delete,
  :root:not([data-theme="light"]) .ui-skin-contrast textarea,
  :root:not([data-theme="light"]) .ui-skin-contrast .setting-row input[type="text"],
  :root:not([data-theme="light"]) .ui-skin-contrast .setting-row select {
    border-color: #c9c1b6;
  }

  :root:not([data-theme="light"]) .chat-style-bubbles .message.user .message-body {
    border-color: #365878;
    background: #1e3142;
  }

  :root:not([data-theme="light"]) .chat-style-bubbles .message.assistant .message-body {
    border-color: #3f514b;
    background: #202826;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--formal-ai-viewport-height, 100dvh);
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--formal-ai-viewport-height, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
}

button,
textarea,
.report-button {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  position: fixed;
  top: var(--formal-ai-viewport-offset-top, 0px);
  left: var(--formal-ai-viewport-offset-left, 0px);
  width: 100vw;
  width: var(--formal-ai-viewport-width, 100vw);
  height: 100vh;
  height: 100dvh;
  height: var(--formal-ai-viewport-height, 100dvh);
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.topbar {
  width: 100%;
  min-width: 0;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid #d6dde1;
  background: #fbfcfd;
}

.brand,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand {
  flex: 0 0 auto;
}

.topbar-actions {
  flex: 1 1 auto;
  justify-content: flex-end;
}

.brand strong {
  font-size: 18px;
  white-space: nowrap;
}

.brand-version {
  color: #657584;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.mark,
.avatar {
  display: grid;
  place-items: center;
  color: #ffffff;
  font-weight: 800;
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #175f4f;
  font-size: 14px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 12px;
}

.status {
  color: #5f6d78;
  font-size: 14px;
}

.demo-status {
  color: #40515f;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  flex: 0 0 auto;
}

.mode-toggle,
.diagnostics-toggle,
.agent-toggle,
.mobile-menu-toggle,
.sidebar-toggle,
.drawer-close,
.drawer-action,
.report-button,
.source-code-button,
.memory-button,
.send-button,
.prompt-list button {
  border: 1px solid #b9c6ca;
  border-radius: 8px;
  background: #ffffff;
  color: #1e252b;
  font-weight: 700;
}

.mode-toggle,
.diagnostics-toggle,
.agent-toggle,
.mobile-menu-toggle,
.sidebar-toggle,
.report-button,
.source-code-button,
.memory-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  white-space: nowrap;
}

/* Issue #27: topbar buttons carry an emoji icon + label so the label can be
 * hidden on narrow viewports for an icon-only mobile topbar. */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.btn-label {
  display: inline;
  margin-left: 6px;
}

/* Issue #27: the hamburger toggle is hidden on wide viewports — the full
 * sidebar is always visible there — and only surfaces under the mobile
 * breakpoint where the sidebar collapses behind a drawer. */
.mobile-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
}

.mobile-menu-toggle .btn-icon {
  font-size: 20px;
}

/* Issue #153: desktop-only sidebar collapse toggle. Hidden on the mobile
 * breakpoint where the slide-in drawer already provides the equivalent
 * affordance. */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  min-height: 38px;
  flex: 0 0 auto;
}

.sidebar-toggle-icon {
  font-size: 14px;
  line-height: 1;
}

.menu-icon {
  position: relative;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.menu-icon-hamburger::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  box-shadow:
    0 6px 0 currentColor,
    0 12px 0 currentColor;
}

.menu-icon-close::before,
.menu-icon-close::after {
  content: "";
  position: absolute;
  left: 1px;
  top: 8px;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.menu-icon-close::before {
  transform: rotate(45deg);
}

.menu-icon-close::after {
  transform: rotate(-45deg);
}

/* Issue #27: full-viewport scrim sits behind the slide-in drawer and dismisses
 * the menu on tap, the same way iOS / Material navigation drawers behave. */
.mobile-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 40, 0.45);
  z-index: 90;
}

.drawer-brand {
  display: none;
}

.drawer-menu-section {
  flex: 0 0 auto;
  display: grid;
  gap: 8px;
  padding: 10px 18px 12px;
  border-bottom: 1px solid #d6dde1;
  background: #f7f8fa;
}

.drawer-menu-section h2 {
  margin: 0;
  color: #40515f;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.drawer-action-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.drawer-action {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 10px;
  text-align: left;
  text-decoration: none;
  white-space: normal;
}

.drawer-action span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.memory-status {
  font-size: 13px;
  color: #40515f;
  align-self: center;
}

.report-button,
.source-code-button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.mode-toggle[aria-pressed="true"],
.diagnostics-toggle[aria-pressed="true"],
.agent-toggle[aria-pressed="true"],
.mobile-menu-toggle[aria-pressed="true"],
.send-button {
  border-color: #175f4f;
  background: #175f4f;
  color: #ffffff;
}

/* Issue #153: when the desktop sidebar is collapsed the toggle keeps its
 * "expand" affordance subtle — no green press state, since the action label
 * already flips. */
.sidebar-toggle.is-collapsed {
  background: #eef2f1;
}

.workspace {
  --context-panel-width: 300px;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(220px, var(--context-panel-width)) 10px minmax(0, 1fr);
  overflow: hidden;
}

/* Issue #153: when the desktop sidebar is collapsed the workspace gives the
 * chat the full viewport width. The aside and resizer are display:none, so the
 * remaining chat panel must be laid out in a single full-width grid column. */
.workspace.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.context-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  padding: 0;
  border-right: 1px solid #d6dde1;
  background: #f7f8fa;
}

.context-panel.is-desktop-collapsed {
  display: none;
}

.workspace.sidebar-collapsed .context-resizer {
  display: none;
}

.context-resizer {
  min-height: 0;
  display: grid;
  place-items: center;
  border-right: 1px solid #d6dde1;
  background: #eef2f1;
  cursor: col-resize;
  touch-action: none;
}

.context-resizer::before {
  content: "";
  width: 2px;
  height: 34px;
  border-radius: 999px;
  background: #9aa9b1;
}

.context-resizer:hover,
.context-resizer:focus-visible,
body.is-resizing-context .context-resizer {
  background: #dfe8e5;
}

.context-resizer:focus-visible {
  outline: 2px solid #2d6cdf;
  outline-offset: -2px;
}

body.is-resizing-context {
  cursor: col-resize;
  user-select: none;
}

.context-panel h2 {
  margin: 0;
  color: #40515f;
  font-size: 13px;
  text-transform: uppercase;
}

/* Issue #27: each sidebar section is a flex column that shares space
 * equally with its siblings and scrolls on its own. Collapsed sections drop
 * out of the flex grow pool so the remaining sections expand to fill the
 * panel — replicating VS Code's accordion behaviour. */
.sidebar-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: 1px solid #d6dde1;
}

.sidebar-section.is-expanded {
  flex: 1 1 0;
}

.sidebar-section.is-collapsed {
  flex: 0 0 auto;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 18px;
  border: 0;
  background: #eef2f1;
  color: #40515f;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.sidebar-section-header:hover {
  background: #e3eae9;
}

.sidebar-section-header h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.sidebar-section-caret {
  display: inline-block;
  width: 10px;
  font-size: 10px;
  color: #5f6d78;
}

.sidebar-section-body {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 18px 14px;
}

.conversation-list {
  display: grid;
  gap: 6px;
}

.conversation-new {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px dashed #b9c6ca;
  border-radius: 8px;
  background: #ffffff;
  color: #175f4f;
  font-weight: 700;
  text-align: left;
}

.conversation-new:hover {
  border-color: #175f4f;
  background: #f1f6f4;
}

.conversation-deleted-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #40515f;
  font-size: 12px;
  font-weight: 700;
}

.conversation-deleted-toggle input {
  width: 16px;
  height: 16px;
  accent-color: #175f4f;
}

.conversation-empty {
  margin: 0;
  color: #5f6d78;
  font-size: 12px;
}

.conversation-entries {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.conversation-entry-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: stretch;
}

.conversation-entry-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid #d6dee2;
  border-radius: 6px;
  background: #ffffff;
  color: #1c2429;
  text-align: left;
  cursor: pointer;
}

.conversation-delete {
  width: 34px;
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #d6dee2;
  border-radius: 6px;
  background: #ffffff;
  color: #8b2f2f;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.conversation-entry-button:hover {
  border-color: #175f4f;
  background: #f1f6f4;
}

.conversation-delete:hover {
  border-color: #8b2f2f;
  background: #fff0f0;
}

.conversation-entry.is-active .conversation-entry-button {
  border-color: #175f4f;
  background: #e3efe9;
  font-weight: 600;
}

.conversation-entry.is-deleted .conversation-entry-button {
  border-color: #c7cdd1;
  background: #f0f3f4;
  color: #5f6d78;
}

.conversation-entry-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  font-size: 13px;
}

.conversation-entry-meta {
  color: #5f6d78;
  font-size: 11px;
  white-space: nowrap;
}

.prompt-list {
  display: grid;
  gap: 8px;
}

.prompt-list button {
  min-height: 42px;
  padding: 9px 10px;
  text-align: left;
  overflow-wrap: anywhere;
}

.prompt-list button:hover {
  border-color: #2d6cdf;
}

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

.setting-row {
  display: grid;
  gap: 6px;
  color: #40515f;
  font-size: 12px;
  font-weight: 700;
}

.setting-row label,
.setting-row > span,
.setting-row-slider > label {
  color: #40515f;
  font-size: 12px;
  text-transform: uppercase;
}

.setting-row input[type="text"],
.setting-row select {
  width: 100%;
  min-height: 34px;
  border: 1px solid #b9c6ca;
  border-radius: 6px;
  padding: 6px 8px;
  background: #ffffff;
  color: #1e252b;
}

.setting-row input[type="range"] {
  width: 100%;
  accent-color: #175f4f;
}

.setting-poles {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #657584;
  font-size: 11px;
  font-weight: 600;
}

.setting-row output {
  color: #1e252b;
  font-size: 12px;
  font-weight: 800;
  justify-self: end;
}

.setting-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #40515f;
  font-size: 12px;
  font-weight: 700;
}

.setting-check input {
  width: 16px;
  height: 16px;
  accent-color: #175f4f;
}

.trace-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.trace-list div {
  display: grid;
  gap: 2px;
  border: 1px solid #d6dde1;
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
}

.trace-list dt {
  color: #657584;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.trace-list dd {
  margin: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.chat-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #ffffff;
}

.messages {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding: 24px clamp(14px, 4vw, 48px);
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  width: min(820px, 100%);
}

.message.user {
  justify-self: end;
  grid-template-columns: minmax(0, 1fr) 38px;
}

.message.user .avatar {
  grid-column: 2;
  grid-row: 1;
  background: #2d6cdf;
}

.message.user .message-body {
  grid-column: 1;
  grid-row: 1;
  background: #edf4ff;
  border-color: #c6d9fb;
}

.message.assistant .avatar {
  background: #175f4f;
}

.message-body {
  min-width: 0;
  border: 1px solid #dce4e7;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfcfd;
}

.message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  color: #667684;
  font-size: 13px;
}

.message-meta strong {
  color: #1e252b;
}

.intent {
  border: 1px solid #dac78b;
  border-radius: 999px;
  padding: 2px 7px;
  background: #fff8df;
  color: #6c5512;
  font-size: 12px;
  font-weight: 800;
}

.markdown-body {
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.markdown-body p {
  margin: 8px 0;
}

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

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

.markdown-body pre {
  overflow: auto;
  border-radius: 8px;
  padding: 12px;
  background: #111827;
  color: #f7fafc;
  line-height: 1.45;
}

.markdown-body code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.markdown-body :not(pre) > code {
  border-radius: 5px;
  padding: 2px 5px;
  background: #e9eef1;
}

.evidence-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.evidence-list span {
  border: 1px solid #cbd6db;
  border-radius: 999px;
  padding: 3px 7px;
  color: #4b5e6b;
  font-size: 12px;
  font-weight: 700;
}

.thinking-steps {
  margin-top: 10px;
  border-top: 1px solid #dce4e7;
  padding-top: 10px;
  color: #4b5e6b;
  font-size: 12px;
}

.thinking-steps strong {
  display: block;
  margin-bottom: 6px;
  color: #40515f;
  text-transform: uppercase;
}

.thinking-steps ol {
  margin: 0;
  padding-left: 18px;
}

.thinking-steps li + li {
  margin-top: 4px;
}

.diagnostics-steps,
.diagnostics-tools {
  margin-top: 12px;
  border-top: 1px solid #dce4e7;
  padding-top: 10px;
  color: #334650;
  font-size: 13px;
}

.diagnostics-steps > strong,
.diagnostics-tools > strong {
  display: block;
  margin-bottom: 8px;
  color: #40515f;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.diagnostics-step-list,
.diagnostics-tool-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.diagnostics-step,
.diagnostics-tool {
  padding-left: 2px;
}

.diagnostics-detail {
  overflow: hidden;
  border: 1px solid #cfdadf;
  border-radius: 8px;
  background: #f8fafb;
}

.diagnostics-detail > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  color: #1f2d36;
  cursor: pointer;
  list-style: none;
}

.diagnostics-detail > summary::-webkit-details-marker {
  display: none;
}

.diagnostics-detail > summary::before {
  content: "▶";
  flex: 0 0 auto;
  color: #5f6d78;
  font-size: 11px;
}

.diagnostics-detail[open] > summary::before {
  content: "▼";
}

.diagnostics-step-name,
.diagnostics-tool-name {
  min-width: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.diagnostics-step-summary,
.diagnostics-tool-summary {
  min-width: 0;
  color: #5f6d78;
  overflow-wrap: anywhere;
}

.diagnostics-detail-body {
  display: grid;
  gap: 10px;
  border-top: 1px solid #dce4e7;
  padding: 10px;
  background: #ffffff;
}

.diagnostics-tool-section {
  display: grid;
  gap: 6px;
}

.diagnostics-section-label {
  color: #657584;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.diagnostics-payload,
.diagnostics-tool-reasoning {
  margin: 0;
  max-width: 100%;
  overflow: auto;
  border: 1px solid #dce4e7;
  border-radius: 6px;
  padding: 8px 10px;
  background: #f5f8f9;
  color: #1f2d36;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Issue #153: formalization view — Subject-Verb-Object tuple rendering for
   the `formalize` and `formalize_resolved` diagnostics steps. The raw prompt
   is shown on the left with an arrow → to the canonical tuple, then the SVO
   slots are listed below with one-letter labels (S/V/O). */
.formalization-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #2c3a44;
  background: #f5f8f9;
  border: 1px solid #cfdadf;
  border-radius: 6px;
  padding: 10px 12px;
}

.formalization-raw {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.formalization-raw code,
.formalization-tuple {
  background: transparent;
  color: #1f2d36;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-word;
}

.formalization-arrow {
  color: #6b7d89;
  font-weight: 700;
}

.formalization-svo {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.formalization-svo-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7d89;
}

.formalization-svo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.formalization-svo-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.formalization-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 4px;
  background: #e3ebee;
  color: #40515f;
  font-weight: 700;
  font-size: 12px;
}

.formalization-svo-list code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: #1f2d36;
}

.message-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
}

.message-actions a {
  color: #175f4f;
  text-decoration: none;
}

.message-actions a:hover {
  text-decoration: underline;
}

.fetch-iframe-container {
  margin-top: 12px;
  border: 1px solid #d6dde1;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.fetch-iframe-container.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  margin: 0;
  border-radius: 0;
}

.fetch-iframe-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #f0f4f8;
  border-bottom: 1px solid #d6dde1;
  font-size: 12px;
  flex-wrap: nowrap;
}

.fetch-iframe-url {
  color: #444;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.fetch-iframe-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.fetch-iframe-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid #b0bac4;
  border-radius: 4px;
  color: #175f4f;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  text-decoration: none;
}

.fetch-iframe-control:hover {
  background: #dde3e9;
  text-decoration: none;
}

.fetch-iframe {
  display: block;
  width: 100%;
  height: 400px;
  border: none;
  background: #fff;
}

.fetch-iframe-container.is-fullscreen .fetch-iframe {
  flex: 1;
  height: auto;
  min-height: 0;
}

.pending .message-body {
  width: 116px;
}

.typing::after {
  content: "...";
}

.composer {
  max-height: min(280px, calc(var(--formal-ai-viewport-height, 100dvh) * 0.5));
  overflow: auto;
  border-top: 1px solid #d6dde1;
  padding: 12px clamp(14px, 4vw, 48px) max(12px, env(safe-area-inset-bottom));
  background: #f7f8fa;
}

.composer-style-glass-soft .composer,
.composer-style-glass-clear .composer {
  background: rgba(247, 248, 250, 0.86);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  backdrop-filter: blur(18px) saturate(1.25);
}

.composer-style-glass-clear .composer {
  background: rgba(247, 248, 250, 0.68);
}

.composer-style-bubble .composer {
  background: #ffffff;
}

.composer-demo-hint {
  margin: 0 0 10px;
  width: min(860px, 100%);
  margin-left: auto;
  margin-right: auto;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fff8df;
  border: 1px solid #dac78b;
  color: #6c5512;
  font-size: 13px;
  text-align: center;
}

.composer-demo-hint-icon {
  font-size: 14px;
}

.composer-grid {
  width: min(860px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

textarea {
  min-width: 0;
  min-height: 48px;
  height: auto;
  max-height: min(180px, calc(var(--formal-ai-viewport-height, 100dvh) * 0.5 - 96px));
  resize: none;
  overflow-y: hidden;
  border: 1px solid #b9c6ca;
  border-radius: 8px;
  padding: 13px;
  background: #ffffff;
  color: #1e252b;
  line-height: 1.35;
}

textarea:focus {
  outline: 2px solid #2d6cdf;
  outline-offset: 1px;
}

textarea:disabled {
  color: #667684;
  background: #edf1f3;
}

.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 88px;
  min-height: 44px;
  padding: 0 14px;
}

.composer-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid #b9c6ca;
  border-radius: 8px;
  background: #ffffff;
  color: #1e252b;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.composer-action-button:hover,
.composer-menu-item:hover {
  border-color: #175f4f;
  background: #f1f6f4;
}

.composer-menu {
  width: min(860px, 100%);
  margin: 0 auto 8px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.composer-menu-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid #b9c6ca;
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: #1e252b;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.composer-attachment-status {
  width: min(860px, 100%);
  margin: 8px auto 0;
  color: #40515f;
  font-size: 12px;
  font-weight: 700;
}

.composer-style-glass-soft textarea,
.composer-style-glass-soft .composer-action-button,
.composer-style-glass-soft .composer-menu-item,
.composer-style-glass-clear textarea,
.composer-style-glass-clear .composer-action-button,
.composer-style-glass-clear .composer-menu-item {
  background: rgba(255, 255, 255, 0.74);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
}

.composer-style-glass-clear textarea,
.composer-style-glass-clear .composer-action-button,
.composer-style-glass-clear .composer-menu-item {
  background: rgba(255, 255, 255, 0.52);
}

.composer-style-bubble .composer-grid {
  border: 1px solid #d6dde1;
  border-radius: 999px;
  padding: 6px;
  background: #f7f8fa;
}

.composer-style-bubble textarea {
  min-height: 42px;
  border-color: transparent;
  border-radius: 999px;
  resize: none;
}

.send-button:disabled {
  border-color: #b9c6ca;
  background: #a9b6bb;
  cursor: not-allowed;
}

.send-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: send-spinner-rotate 0.85s linear infinite;
}

@keyframes send-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

/* Issue #153: desktop overflow first keeps the canonical controls visible and
 * switches action labels to icon-only before any button can be clipped. The
 * mobile drawer carries the full action list once the topbar gets tight enough
 * that lower-priority actions have to leave the row. */
@media (max-width: 1500px) {
  .topbar-actions {
    gap: 8px;
  }

  .topbar-actions .btn-label {
    display: none;
  }

  .topbar-actions .mode-toggle,
  .topbar-actions .diagnostics-toggle,
  .topbar-actions .agent-toggle,
  .topbar-actions .report-button,
  .topbar-actions .source-code-button,
  .topbar-actions .memory-button {
    min-width: 0;
    padding: 0 10px;
  }
}

@media (max-width: 1100px) {
  .topbar {
    gap: 10px;
  }

  .demo-status,
  .memory-status {
    display: none;
  }
}

@media (max-width: 820px) {
  .topbar {
    min-height: 58px;
    flex-wrap: nowrap;
    align-items: center;
    padding: 10px 12px;
    gap: 8px;
  }

  .status {
    display: none;
  }

  .brand {
    display: none;
  }

  .brand strong {
    white-space: nowrap;
  }

  .topbar-actions {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 6px;
    overflow: hidden;
  }

  .demo-status,
  .topbar-actions [data-menu-priority="4"],
  .topbar-actions [data-menu-priority="5"],
  .topbar-actions [data-menu-priority="6"],
  .topbar-actions [data-menu-priority="7"] {
    display: none;
  }

  .memory-status {
    display: none;
  }

  /* Issue #27: icon-only topbar on mobile so the chat surface gets the bulk
   * of the vertical space. Buttons keep an aria-label / title pair so screen
   * readers and hover tooltips still expose the full action name. */
  .topbar-actions .btn-label {
    display: none;
  }

  .topbar-actions .mode-toggle,
  .topbar-actions .diagnostics-toggle,
  .topbar-actions .agent-toggle,
  .topbar-actions .report-button,
  .topbar-actions .source-code-button,
  .topbar-actions .memory-button {
    min-width: 0;
    padding: 0 10px;
  }

  /* Issue #153: on mobile the desktop sidebar toggle disappears — the
   * hamburger drawer drives all sidebar visibility there. */
  .sidebar-toggle {
    display: none;
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

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

  .context-resizer {
    display: none;
  }

  /* Issue #27: the sidebar slides in over the chat as a drawer rather than
   * eating into the message viewport. */
  .context-panel,
  .context-panel.is-desktop-collapsed {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: 100vw;
    width: var(--formal-ai-viewport-width, 100vw);
    max-height: none;
    border-right: 1px solid #d6dde1;
    border-bottom: 0;
    background: #f7f8fa;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: 4px 0 18px rgba(15, 30, 40, 0.18);
    display: flex;
  }

  .context-panel.is-mobile-open {
    transform: translateX(0);
  }

  /* Issue #153: on mobile the desktop collapse flag is irrelevant — the
   * drawer's visibility is owned by `.is-mobile-open` alone. */
  .workspace.sidebar-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }

  .drawer-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 58px;
    padding: 10px 18px;
    border-bottom: 1px solid #d6dde1;
    background: #fbfcfd;
  }

  .drawer-brand-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
  }

  .drawer-brand-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  .drawer-brand-copy strong {
    color: #1e252b;
    font-size: 17px;
  }

  .drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
  }

  .drawer-menu-section {
    display: grid;
    gap: 8px;
    padding: 10px 18px 12px;
    border-bottom: 1px solid #d6dde1;
    background: #f7f8fa;
  }

  .drawer-action-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .drawer-action {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 0 10px;
    text-decoration: none;
    white-space: nowrap;
  }

  .prompt-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .messages {
    padding: 18px 12px;
  }

  .message {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .message.user {
    grid-template-columns: minmax(0, 1fr) 32px;
  }

  .avatar {
    width: 32px;
    height: 32px;
  }

  .composer {
    max-height: calc(var(--formal-ai-viewport-height, 100dvh) * 0.5);
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  }

  .composer-grid {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    gap: 6px;
  }

  textarea {
    min-height: 42px;
    height: auto;
    max-height: min(132px, calc(var(--formal-ai-viewport-height, 100dvh) * 0.5 - 64px));
    padding: 11px;
    resize: none;
  }

  .send-button {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 8px;
  }

  .composer-action-button {
    width: 42px;
    height: 42px;
    font-size: 21px;
  }

  .send-label {
    display: none;
  }

  .send-icon {
    font-size: 20px;
    line-height: 1;
  }

  .composer-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .composer-menu-item {
    min-height: 36px;
    padding: 7px 8px;
  }
}

.tool-registry {
  margin-top: 0;
  min-width: 0;
}

.tool-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.tool {
  min-width: 0;
  border: 1px solid rgba(127, 127, 127, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
}

.tool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.tool-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tool-mode {
  flex: 0 1 auto;
  max-width: 100%;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(120, 140, 255, 0.18);
  color: #4a5acc;
}

.tool-mode-agent .tool-mode {
  background: rgba(255, 170, 90, 0.18);
  color: #b66e1a;
}

.tool-desc {
  margin: 4px 0 0;
  font-size: 12px;
  opacity: 0.75;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

@media (max-width: 520px) {
  .prompt-list {
    grid-template-columns: 1fr;
  }

  /* Issue #27: drop the brand wordmark on the narrowest viewports so the
   * topbar holds the FA logo + emoji actions + hamburger on a single row. */
  .brand {
    display: none;
  }

  /* Issue #27: collapse the icon-only buttons even tighter so a row of six
   * fits on a 360px-wide handset alongside the hamburger toggle. */
  .topbar-actions .mode-toggle,
  .topbar-actions .diagnostics-toggle,
  .topbar-actions .agent-toggle,
  .topbar-actions .report-button,
  .topbar-actions .memory-button {
    padding: 0 8px;
    min-height: 36px;
  }

  .mobile-menu-toggle {
    padding: 0 8px;
    min-height: 36px;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  background: #181a1b;
  color: #ece7df;
}

:root[data-theme="dark"] body {
  background: #181a1b;
}

:root[data-theme="dark"] .topbar {
  border-bottom-color: #343a3d;
  background: #202322;
  color: #ece7df;
}

:root[data-theme="dark"] .context-panel,
:root[data-theme="dark"] .composer {
  border-color: #343a3d;
  background: #1d201f;
}

:root[data-theme="dark"] .context-resizer {
  border-right-color: #343a3d;
  background: #222624;
}

:root[data-theme="dark"] .context-resizer::before {
  background: #6f7975;
}

:root[data-theme="dark"] .context-resizer:hover,
:root[data-theme="dark"] .context-resizer:focus-visible,
:root[data-theme="dark"] body.is-resizing-context .context-resizer {
  background: #2b302e;
}

:root[data-theme="dark"] .chat-panel,
:root[data-theme="dark"] .sidebar-section-body {
  background: #181a1b;
}

:root[data-theme="dark"] .sidebar-section {
  border-bottom-color: #343a3d;
}

:root[data-theme="dark"] .sidebar-section-header {
  background: #222624;
  color: #d8d0c4;
}

:root[data-theme="dark"] .sidebar-section-header:hover {
  background: #2b302e;
}

:root[data-theme="dark"] .context-panel h2,
:root[data-theme="dark"] .demo-status,
:root[data-theme="dark"] .memory-status,
:root[data-theme="dark"] .status,
:root[data-theme="dark"] .brand-version,
:root[data-theme="dark"] .sidebar-section-caret {
  color: #c9c1b6;
}

:root[data-theme="dark"] .mode-toggle,
:root[data-theme="dark"] .diagnostics-toggle,
:root[data-theme="dark"] .agent-toggle,
:root[data-theme="dark"] .mobile-menu-toggle,
:root[data-theme="dark"] .drawer-close,
:root[data-theme="dark"] .drawer-action,
:root[data-theme="dark"] .report-button,
:root[data-theme="dark"] .memory-button,
:root[data-theme="dark"] .send-button,
:root[data-theme="dark"] .composer-action-button,
:root[data-theme="dark"] .composer-menu-item,
:root[data-theme="dark"] .prompt-list button,
:root[data-theme="dark"] .conversation-new,
:root[data-theme="dark"] .conversation-entry-button,
:root[data-theme="dark"] .conversation-delete,
:root[data-theme="dark"] .fetch-iframe-control {
  border-color: #4a524e;
  background: #242826;
  color: #ece7df;
}

:root[data-theme="dark"] .conversation-new {
  color: #91d7bc;
}

:root[data-theme="dark"] .conversation-new:hover,
:root[data-theme="dark"] .conversation-entry-button:hover,
:root[data-theme="dark"] .conversation-delete:hover,
:root[data-theme="dark"] .prompt-list button:hover,
:root[data-theme="dark"] .composer-action-button:hover,
:root[data-theme="dark"] .composer-menu-item:hover,
:root[data-theme="dark"] .fetch-iframe-control:hover {
  border-color: #6cc5a6;
  background: #28332f;
}

:root[data-theme="dark"] .conversation-empty,
:root[data-theme="dark"] .conversation-entry-meta,
:root[data-theme="dark"] .conversation-deleted-toggle,
:root[data-theme="dark"] .message-meta,
:root[data-theme="dark"] .trace-list dt,
:root[data-theme="dark"] .setting-row,
:root[data-theme="dark"] .setting-row label,
:root[data-theme="dark"] .setting-row > span,
:root[data-theme="dark"] .setting-row-slider > label,
:root[data-theme="dark"] .setting-check,
:root[data-theme="dark"] .composer-attachment-status,
:root[data-theme="dark"] .thinking-steps {
  color: #b7b0a7;
}

:root[data-theme="dark"] .setting-poles {
  color: #b7b0a7;
}

:root[data-theme="dark"] .setting-row output {
  color: #ece7df;
}

:root[data-theme="dark"] .conversation-entry.is-active .conversation-entry-button {
  border-color: #6cc5a6;
  background: #1f3a31;
}

:root[data-theme="dark"] .message-body,
:root[data-theme="dark"] .trace-list div,
:root[data-theme="dark"] .tool {
  border-color: #343a3d;
  background: #202322;
}

:root[data-theme="dark"] .message.user .message-body {
  border-color: #365878;
  background: #1e3142;
}

:root[data-theme="dark"] .message-meta strong {
  color: #ece7df;
}

:root[data-theme="dark"] .intent,
:root[data-theme="dark"] .composer-demo-hint {
  border-color: #7f6831;
  background: #332b1b;
  color: #f1d28a;
}

:root[data-theme="dark"] .markdown-body :not(pre) > code,
:root[data-theme="dark"] textarea:disabled {
  background: #272b2a;
}

:root[data-theme="dark"] .evidence-list span {
  border-color: #4a524e;
  color: #c9c1b6;
}

:root[data-theme="dark"] .thinking-steps {
  border-top-color: #343a3d;
}

:root[data-theme="dark"] .thinking-steps strong {
  color: #d8d0c4;
}

:root[data-theme="dark"] .formalization-view {
  background: #232726;
  border-color: #343a3d;
  color: #d8d0c4;
}

:root[data-theme="dark"] .formalization-raw code,
:root[data-theme="dark"] .formalization-tuple,
:root[data-theme="dark"] .formalization-svo-list code {
  color: #ece7df;
}

:root[data-theme="dark"] .formalization-arrow,
:root[data-theme="dark"] .formalization-svo-label {
  color: #b7b0a7;
}

:root[data-theme="dark"] .formalization-slot {
  background: #2c322f;
  color: #c9d8d3;
}

:root[data-theme="dark"] .message-actions a {
  color: #91d7bc;
}

:root[data-theme="dark"] .fetch-iframe-container,
:root[data-theme="dark"] .fetch-iframe-header {
  border-color: #343a3d;
}

:root[data-theme="dark"] .fetch-iframe-header {
  background: #222624;
}

:root[data-theme="dark"] .drawer-brand,
:root[data-theme="dark"] .drawer-menu-section {
  border-bottom-color: #343a3d;
  background: #202322;
}

:root[data-theme="dark"] .drawer-brand-copy strong {
  color: #ece7df;
}

:root[data-theme="dark"] .fetch-iframe-url {
  color: #c9c1b6;
}

:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .setting-row input[type="text"],
:root[data-theme="dark"] .setting-row select {
  border-color: #4a524e;
  background: #202322;
  color: #ece7df;
}

:root[data-theme="dark"] .composer-style-glass-soft .composer,
:root[data-theme="dark"] .composer-style-glass-clear .composer {
  background: rgba(29, 32, 31, 0.82);
}

:root[data-theme="dark"] .composer-style-glass-clear .composer {
  background: rgba(29, 32, 31, 0.64);
}

:root[data-theme="dark"] .composer-style-bubble .composer {
  background: #181a1b;
}

:root[data-theme="dark"] .composer-style-glass-soft textarea,
:root[data-theme="dark"] .composer-style-glass-soft .composer-action-button,
:root[data-theme="dark"] .composer-style-glass-soft .composer-menu-item,
:root[data-theme="dark"] .composer-style-glass-clear textarea,
:root[data-theme="dark"] .composer-style-glass-clear .composer-action-button,
:root[data-theme="dark"] .composer-style-glass-clear .composer-menu-item {
  background: rgba(32, 35, 34, 0.74);
}

:root[data-theme="dark"] .composer-style-glass-clear textarea,
:root[data-theme="dark"] .composer-style-glass-clear .composer-action-button,
:root[data-theme="dark"] .composer-style-glass-clear .composer-menu-item {
  background: rgba(32, 35, 34, 0.52);
}

:root[data-theme="dark"] .composer-style-bubble .composer-grid {
  border-color: #343a3d;
  background: #1d201f;
}

:root[data-theme="dark"] textarea:focus {
  outline-color: #7aa5ff;
}

:root[data-theme="dark"] .send-button:disabled {
  border-color: #3f4643;
  background: #3f4643;
  color: #aba49c;
}

:root[data-theme="dark"] .mode-toggle[aria-pressed="true"],
:root[data-theme="dark"] .diagnostics-toggle[aria-pressed="true"],
:root[data-theme="dark"] .agent-toggle[aria-pressed="true"],
:root[data-theme="dark"] .mobile-menu-toggle[aria-pressed="true"],
:root[data-theme="dark"] .send-button {
  border-color: #2c8f71;
  background: #2c8f71;
  color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    background: #181a1b;
    color: #ece7df;
  }

  :root:not([data-theme="light"]) body {
    background: #181a1b;
  }

  :root:not([data-theme="light"]) .topbar {
    border-bottom-color: #343a3d;
    background: #202322;
    color: #ece7df;
  }

  :root:not([data-theme="light"]) .context-panel,
  :root:not([data-theme="light"]) .composer {
    border-color: #343a3d;
    background: #1d201f;
  }

  :root:not([data-theme="light"]) .context-resizer {
    border-right-color: #343a3d;
    background: #222624;
  }

  :root:not([data-theme="light"]) .context-resizer::before {
    background: #6f7975;
  }

  :root:not([data-theme="light"]) .context-resizer:hover,
  :root:not([data-theme="light"]) .context-resizer:focus-visible,
  :root:not([data-theme="light"]) body.is-resizing-context .context-resizer {
    background: #2b302e;
  }

  :root:not([data-theme="light"]) .chat-panel,
  :root:not([data-theme="light"]) .sidebar-section-body {
    background: #181a1b;
  }

  :root:not([data-theme="light"]) .sidebar-section {
    border-bottom-color: #343a3d;
  }

  :root:not([data-theme="light"]) .sidebar-section-header {
    background: #222624;
    color: #d8d0c4;
  }

  :root:not([data-theme="light"]) .sidebar-section-header:hover {
    background: #2b302e;
  }

  :root:not([data-theme="light"]) .context-panel h2,
  :root:not([data-theme="light"]) .demo-status,
  :root:not([data-theme="light"]) .memory-status,
  :root:not([data-theme="light"]) .status,
  :root:not([data-theme="light"]) .brand-version,
  :root:not([data-theme="light"]) .sidebar-section-caret {
    color: #c9c1b6;
  }

  :root:not([data-theme="light"]) .mode-toggle,
  :root:not([data-theme="light"]) .diagnostics-toggle,
  :root:not([data-theme="light"]) .agent-toggle,
  :root:not([data-theme="light"]) .mobile-menu-toggle,
  :root:not([data-theme="light"]) .drawer-close,
  :root:not([data-theme="light"]) .drawer-action,
  :root:not([data-theme="light"]) .report-button,
  :root:not([data-theme="light"]) .memory-button,
  :root:not([data-theme="light"]) .send-button,
  :root:not([data-theme="light"]) .composer-action-button,
  :root:not([data-theme="light"]) .composer-menu-item,
  :root:not([data-theme="light"]) .prompt-list button,
  :root:not([data-theme="light"]) .conversation-new,
  :root:not([data-theme="light"]) .conversation-entry-button,
  :root:not([data-theme="light"]) .conversation-delete,
  :root:not([data-theme="light"]) .fetch-iframe-control {
    border-color: #4a524e;
    background: #242826;
    color: #ece7df;
  }

  :root:not([data-theme="light"]) .conversation-new {
    color: #91d7bc;
  }

  :root:not([data-theme="light"]) .conversation-new:hover,
  :root:not([data-theme="light"]) .conversation-entry-button:hover,
  :root:not([data-theme="light"]) .conversation-delete:hover,
  :root:not([data-theme="light"]) .prompt-list button:hover,
  :root:not([data-theme="light"]) .composer-action-button:hover,
  :root:not([data-theme="light"]) .composer-menu-item:hover,
  :root:not([data-theme="light"]) .fetch-iframe-control:hover {
    border-color: #6cc5a6;
    background: #28332f;
  }

  :root:not([data-theme="light"]) .conversation-empty,
  :root:not([data-theme="light"]) .conversation-entry-meta,
  :root:not([data-theme="light"]) .conversation-deleted-toggle,
  :root:not([data-theme="light"]) .message-meta,
  :root:not([data-theme="light"]) .trace-list dt,
  :root:not([data-theme="light"]) .setting-row,
  :root:not([data-theme="light"]) .setting-row label,
  :root:not([data-theme="light"]) .setting-row > span,
  :root:not([data-theme="light"]) .setting-row-slider > label,
  :root:not([data-theme="light"]) .setting-check,
  :root:not([data-theme="light"]) .composer-attachment-status,
  :root:not([data-theme="light"]) .thinking-steps {
    color: #b7b0a7;
  }

  :root:not([data-theme="light"]) .setting-poles {
    color: #b7b0a7;
  }

  :root:not([data-theme="light"]) .setting-row output {
    color: #ece7df;
  }

  :root:not([data-theme="light"]) .conversation-entry.is-active .conversation-entry-button {
    border-color: #6cc5a6;
    background: #1f3a31;
  }

  :root:not([data-theme="light"]) .message-body,
  :root:not([data-theme="light"]) .trace-list div,
  :root:not([data-theme="light"]) .tool {
    border-color: #343a3d;
    background: #202322;
  }

  :root:not([data-theme="light"]) .message.user .message-body {
    border-color: #365878;
    background: #1e3142;
  }

  :root:not([data-theme="light"]) .message-meta strong {
    color: #ece7df;
  }

  :root:not([data-theme="light"]) .intent,
  :root:not([data-theme="light"]) .composer-demo-hint {
    border-color: #7f6831;
    background: #332b1b;
    color: #f1d28a;
  }

  :root:not([data-theme="light"]) .markdown-body :not(pre) > code,
  :root:not([data-theme="light"]) textarea:disabled {
    background: #272b2a;
  }

  :root:not([data-theme="light"]) .evidence-list span {
    border-color: #4a524e;
    color: #c9c1b6;
  }

  :root:not([data-theme="light"]) .thinking-steps {
    border-top-color: #343a3d;
  }

  :root:not([data-theme="light"]) .thinking-steps strong {
    color: #d8d0c4;
  }

  :root:not([data-theme="light"]) .formalization-view {
    background: #232726;
    border-color: #343a3d;
    color: #d8d0c4;
  }

  :root:not([data-theme="light"]) .formalization-raw code,
  :root:not([data-theme="light"]) .formalization-tuple,
  :root:not([data-theme="light"]) .formalization-svo-list code {
    color: #ece7df;
  }

  :root:not([data-theme="light"]) .formalization-arrow,
  :root:not([data-theme="light"]) .formalization-svo-label {
    color: #b7b0a7;
  }

  :root:not([data-theme="light"]) .formalization-slot {
    background: #2c322f;
    color: #c9d8d3;
  }

  :root:not([data-theme="light"]) .message-actions a {
    color: #91d7bc;
  }

  :root:not([data-theme="light"]) .fetch-iframe-container,
  :root:not([data-theme="light"]) .fetch-iframe-header {
    border-color: #343a3d;
  }

  :root:not([data-theme="light"]) .fetch-iframe-header {
    background: #222624;
  }

  :root:not([data-theme="light"]) .drawer-brand,
  :root:not([data-theme="light"]) .drawer-menu-section {
    border-bottom-color: #343a3d;
    background: #202322;
  }

  :root:not([data-theme="light"]) .drawer-brand-copy strong {
    color: #ece7df;
  }

  :root:not([data-theme="light"]) .fetch-iframe-url {
    color: #c9c1b6;
  }

  :root:not([data-theme="light"]) textarea {
    border-color: #4a524e;
    background: #202322;
    color: #ece7df;
  }

  :root:not([data-theme="light"]) .setting-row input[type="text"],
  :root:not([data-theme="light"]) .setting-row select {
    border-color: #4a524e;
    background: #202322;
    color: #ece7df;
  }

  :root:not([data-theme="light"]) .composer-style-glass-soft .composer,
  :root:not([data-theme="light"]) .composer-style-glass-clear .composer {
    background: rgba(29, 32, 31, 0.82);
  }

  :root:not([data-theme="light"]) .composer-style-glass-clear .composer {
    background: rgba(29, 32, 31, 0.64);
  }

  :root:not([data-theme="light"]) .composer-style-bubble .composer {
    background: #181a1b;
  }

  :root:not([data-theme="light"]) .composer-style-glass-soft textarea,
  :root:not([data-theme="light"]) .composer-style-glass-soft .composer-action-button,
  :root:not([data-theme="light"]) .composer-style-glass-soft .composer-menu-item,
  :root:not([data-theme="light"]) .composer-style-glass-clear textarea,
  :root:not([data-theme="light"]) .composer-style-glass-clear .composer-action-button,
  :root:not([data-theme="light"]) .composer-style-glass-clear .composer-menu-item {
    background: rgba(32, 35, 34, 0.74);
  }

  :root:not([data-theme="light"]) .composer-style-glass-clear textarea,
  :root:not([data-theme="light"]) .composer-style-glass-clear .composer-action-button,
  :root:not([data-theme="light"]) .composer-style-glass-clear .composer-menu-item {
    background: rgba(32, 35, 34, 0.52);
  }

  :root:not([data-theme="light"]) .composer-style-bubble .composer-grid {
    border-color: #343a3d;
    background: #1d201f;
  }

  :root:not([data-theme="light"]) textarea:focus {
    outline-color: #7aa5ff;
  }

  :root:not([data-theme="light"]) .send-button:disabled {
    border-color: #3f4643;
    background: #3f4643;
    color: #aba49c;
  }

  :root:not([data-theme="light"]) .mode-toggle[aria-pressed="true"],
  :root:not([data-theme="light"]) .diagnostics-toggle[aria-pressed="true"],
  :root:not([data-theme="light"]) .agent-toggle[aria-pressed="true"],
  :root:not([data-theme="light"]) .mobile-menu-toggle[aria-pressed="true"],
  :root:not([data-theme="light"]) .send-button {
    border-color: #2c8f71;
    background: #2c8f71;
    color: #ffffff;
  }
}
