:root {
  /* RetailGear / main-app palette: primary #3ba68c, active #109070. */
  --bg: #f1faff;
  --panel: #ffffff;
  --panel-soft: #f8fcfd;
  --border: #d6e6e2;
  --border-strong: #b9d6cf;
  --text: #244555;
  --muted: #6b8190;
  --accent: #3ba68c;
  --accent-hover: #109070;
  --accent-soft: #e8fff7;
  --accent-text: #ffffff;
  --user-bubble: #3ba68c;
  --agent-bubble: #ffffff;
  --tool-bubble: #fff8e6;
  --tool-border: #e7c56a;
  --error-bubble: #fff5f8;
  --error-border: #c85a72;
  --confirm-bg: #fff8dd;
  --confirm-border: #d9a936;
  --shadow-sm: 0 2px 8px rgba(36, 69, 85, 0.06);
  --shadow-md: 0 8px 24px rgba(36, 69, 85, 0.1);
  --font-ui: "Inter", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a2b;
    --panel: #1b293d;
    --panel-soft: #202f45;
    --border: #31465b;
    --border-strong: #49677b;
    --text: #eefafc;
    --muted: #a9c0c9;
    --accent: #3ba68c;
    --accent-hover: #52c2a7;
    --accent-soft: #183a32;
    --accent-text: #ffffff;
    --user-bubble: #3ba68c;
    --agent-bubble: #202f45;
    --tool-bubble: #302b1b;
    --tool-border: #8a6a1e;
    --error-bubble: #421722;
    --error-border: #c85a72;
    --confirm-bg: #302b1b;
    --confirm-border: #a47f29;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.16);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.22);
    --font-ui: "Inter", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  }
}

* { box-sizing: border-box; }

/* Keep the HTML hidden attribute authoritative even when a component has an
   explicit display rule such as .preview-pane { display: flex; }. This also
   keeps hidden sign-in fields hidden when their form styles use flex. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: -0.005em;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  min-height: 68px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 10px rgba(59, 166, 140, 0.25);
}

.header-center {
  position: absolute;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  max-width: min(48vw, 460px);
  transform: translateX(-50%);
}

.business-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 11px 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--panel-soft);
  box-shadow: var(--shadow-sm);
}

.business-switcher.single-business {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.business-label {
  flex-shrink: 0;
  color: var(--accent-hover);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.business-switcher select {
  min-width: 120px;
  max-width: min(30vw, 280px);
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  cursor: pointer;
  color-scheme: light dark;
}

.business-name {
  max-width: min(30vw, 280px);
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.business-switcher select option {
  background: var(--panel);
  color: var(--text);
}

.session-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: min(34vw, 310px);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-soft);
  box-shadow: var(--shadow-sm);
}

.session-label {
  flex-shrink: 0;
  color: var(--accent-hover);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.session-indicator .session-id {
  max-width: min(24vw, 240px);
  color: var(--muted);
}

.topbar-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.topbar-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 7px;
  font-size: 15px;
  line-height: 1;
}

.sidebar-toggle:hover:not(:disabled),
.sidebar-toggle:focus-visible {
  transform: none;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.topbar-controls input {
  font: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 130px;
}

.session-id {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: -0.03em;
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.005em;
  box-shadow: 0 2px 5px rgba(36, 69, 85, 0.12);
  transition: background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 10px rgba(36, 69, 85, 0.16);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

button.secondary:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.session-sidebar {
  display: flex;
  flex: 0 0 248px;
  flex-direction: column;
  min-height: 0;
  padding: 18px 12px;
  border-right: 1px solid var(--border);
  background: var(--panel);
}

.session-sidebar.collapsed {
  display: none;
}

.session-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px 10px;
}

.session-sidebar-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.session-sidebar-count {
  color: var(--muted);
  font-size: 11px;
}

.session-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.session-list::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.session-list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  box-shadow: none;
}

.session-list-item:hover:not(:disabled),
.session-list-item:focus-visible,
.session-list-item.active {
  background: var(--accent-soft);
  border-color: var(--border-strong);
  color: var(--accent-hover);
  box-shadow: none;
  transform: none;
}

.session-list-item-title {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-list-item-date {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.session-list-state {
  margin: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.chat-pane {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg) 0%, var(--panel-soft) 100%);
}

/* ChatGPT-style first-use layout: keep the welcome note and composer as a
   centered starting point until the user sends the first message. */
.chat-pane.empty-state {
  justify-content: center;
}

.welcome-state {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 0 18px 4px;
  text-align: center;
}

.welcome-eyebrow {
  margin-bottom: 12px;
  color: var(--accent-hover);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.welcome-state h1 {
  max-width: 680px;
  margin: 0 auto;
  color: var(--text);
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.08;
}

.welcome-state p {
  max-width: 570px;
  margin: 16px auto 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.6;
}

.preview-pane {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  box-shadow: inset 8px 0 22px rgba(36, 69, 85, 0.035);
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex-shrink: 0;
}

.preview-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.preview-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  flex: 1;
}

.preview-url {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: min(42%, 420px);
  overflow: hidden;
  padding: 5px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-family: var(--font-mono);
  font-size: 11px;
  text-overflow: ellipsis;
  text-decoration: none;
  white-space: nowrap;
}

.preview-url:hover,
.preview-url:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  outline: none;
}

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

.preview-actions button,
.preview-actions a {
  padding: 4px 10px;
  font-size: 12px;
}

.preview-open-link {
  background: var(--accent-soft) !important;
  border-color: var(--border-strong) !important;
  color: var(--accent-hover) !important;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.preview-open-link:hover:not([hidden]),
.preview-open-link:focus-visible {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: var(--accent-text) !important;
  outline: none;
}

.preview-frame-wrap {
  flex: 1;
  position: relative;
  background: var(--bg);
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 13px;
}

.preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

/* Below this width, the preview pane isn't useful side-by-side — stack it
   under the chat instead of squeezing both into unusable slivers. */
@media (max-width: 900px) {
  .workspace {
    flex-direction: column;
  }

  .session-sidebar {
    flex: 0 0 auto;
    width: 100%;
    max-height: 190px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .session-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .session-list-item {
    flex: 0 0 220px;
  }

  .chat-pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex: 1 1 55%;
  }

  .preview-pane {
    flex: 1 1 45%;
  }
}

.log {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 56px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.log::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* A "turn" is one labeled request/response entry: a small sender/time
   caption above its bubble, so which side said what is never ambiguous. */
.turn {
  display: flex;
  flex-direction: column;
  max-width: min(78%, 760px);
  gap: 5px;
}

.turn.tool { max-width: 85%; }

.turn.user { align-self: flex-end; align-items: flex-end; }
.turn.agent, .turn.tool, .turn.error { align-self: flex-start; align-items: flex-start; }

/* Give every newly rendered chat bubble a short, directional entrance. The
   bubble itself is animated instead of the whole turn so sender metadata and
   the user copy control stay stable while the message arrives. */
.turn.user .msg {
  transform-origin: right bottom;
  animation: chat-bubble-in-right 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.turn.agent .msg,
.turn.tool .msg,
.turn.error .msg {
  transform-origin: left bottom;
  animation: chat-bubble-in-left 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes chat-bubble-in-right {
  from {
    opacity: 0;
    transform: translate3d(14px, 8px, 0) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes chat-bubble-in-left {
  from {
    opacity: 0;
    transform: translate3d(-14px, 8px, 0) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

.meta {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  padding: 0 8px;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.msg {
  width: fit-content;
  max-width: min(100%, 760px);
  min-width: 0;
  padding: 11px 15px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.62;
  letter-spacing: -0.005em;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}

.msg.user {
  background: var(--user-bubble);
  color: var(--accent-text);
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 12px rgba(59, 166, 140, 0.2);
}

.message-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
}

.message-row .msg {
  flex: 0 1 auto;
  min-width: 0;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  width: max-content;
  margin: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 140ms ease, visibility 140ms ease;
}

.turn:hover .message-actions,
.turn:focus-within .message-actions {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.copy-message-button,
.quote-message-button,
.edit-message-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  box-shadow: none;
  transform: none;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.copy-message-button {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.quote-message-button {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.copy-message-button:hover:not(:disabled),
.quote-message-button:hover:not(:disabled),
.edit-message-button:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
  box-shadow: none;
  transform: none;
}

.copy-message-button:focus-visible,
.quote-message-button:focus-visible,
.edit-message-button:focus-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.copy-message-button svg,
.quote-message-button svg,
.edit-message-button svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.message-quote {
  margin: 0 0 9px;
  padding: 7px 9px;
  border-left: 2px solid currentColor;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.13);
  color: inherit;
  opacity: 0.9;
}

.message-quote-label {
  margin-bottom: 2px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.8;
}

.message-quote-text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.4;
}

.turn.user .message-quote {
  background: rgba(0, 0, 0, 0.12);
}

.turn.user:hover .copy-message-button,
.turn.user:focus-within .copy-message-button,
.turn.agent:hover .quote-message-button,
.turn.agent:focus-within .quote-message-button,
.turn.user:hover .quote-message-button,
.turn.user:focus-within .quote-message-button {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.msg.agent {
  background: var(--agent-bubble);
  border-color: var(--border);
  border-bottom-left-radius: 5px;
}

.msg.agent strong {
  font-weight: 750;
}

.msg.tool {
  background: var(--tool-bubble);
  border: 1px solid var(--tool-border);
  font-family: var(--font-mono);
  font-size: 12px;
  box-shadow: none;
}

.msg.error {
  background: var(--error-bubble);
  border: 1px solid var(--error-border);
  box-shadow: none;
}

.msg.agent.thinking {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.msg.agent.thinking span.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: thinking-bounce 1.2s infinite ease-in-out both;
}

.msg.agent.thinking span.dot:nth-child(1) { animation-delay: -0.32s; }
.msg.agent.thinking span.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes thinking-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.msg.system {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  background: none;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: none;
}

.pending-confirmations {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 0 clamp(18px, 4vw, 56px) 12px;
}

.confirmation-card {
  width: min(100%, 680px);
  align-self: center;
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--confirm-border) 62%, var(--border));
  border-radius: 14px;
  padding: 12px 14px 11px;
  box-shadow: 0 8px 24px rgba(36, 69, 85, 0.12);
}

.confirmation-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--confirm-border);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.confirmation-heading::before {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid color-mix(in srgb, var(--confirm-border) 70%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--confirm-bg) 72%, var(--panel));
  content: '!';
  font-size: 12px;
  letter-spacing: 0;
}

.confirmation-description {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 8px;
  white-space: pre-line;
  word-break: break-word;
}

.confirmation-card .actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
}

.confirmation-card .actions button {
  min-width: 82px;
}

.confirmation-card .status {
  font-size: 12px;
  margin-top: 6px;
  color: var(--muted);
}

.confirmation-card .actions button.deny {
  background: transparent;
  color: var(--error-border);
  border: 1px solid var(--error-border);
}

.confirmation-card .actions button.deny:hover:not(:disabled) {
  background: color-mix(in srgb, var(--error-border) 10%, transparent);
  box-shadow: none;
  transform: none;
}

.confirmation-card.resolved {
  opacity: 0.6;
}

.import-card {
  width: min(100%, 760px);
  align-self: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
}

.import-card .import-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.import-card progress {
  width: 100%;
  height: 8px;
  accent-color: var(--confirm-border);
}

.import-card .import-counts,
.import-card .import-note {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.import-card[data-status='paused'] .import-note,
.import-card[data-status='needs_attention'] .import-note,
.import-card[data-status='failed'] .import-title {
  color: var(--error-border);
}

.import-card .actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.import-card .actions:empty {
  display: none;
}

.composer {
  display: flex;
  gap: 10px;
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 16px clamp(18px, 4vw, 56px) 20px;
  background: transparent;
  flex-shrink: 0;
}

.composer textarea {
  display: block;
  width: 100%;
  resize: none;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  min-height: 58px;
  padding: 15px 58px 15px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.composer textarea::placeholder {
  color: var(--muted);
  opacity: 1;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.composer button {
  flex-shrink: 0;
}

.composer-input {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(36, 69, 85, 0.08);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.quote-composer {
  margin: 10px 12px 0;
  padding: 8px 10px 9px;
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--text);
}

.edit-composer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 12px 0;
  padding: 7px 10px;
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 650;
}

.edit-composer button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-size: 12px;
  font-weight: 600;
}

.edit-composer button:hover:not(:disabled),
.edit-composer button:focus-visible {
  background: transparent;
  color: var(--accent-hover);
  box-shadow: none;
  transform: none;
}

.quote-composer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.quote-composer-label {
  color: var(--accent-hover);
  font-size: 11px;
  font-weight: 650;
}

.quote-composer-label strong {
  font-weight: 800;
}

.quote-composer-text {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 3px;
  padding-right: 4px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.quote-clear-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}

.quote-clear-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--text);
  box-shadow: none;
  transform: none;
}

.composer-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent), 0 8px 24px rgba(36, 69, 85, 0.08);
}

.icon-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px !important;
  height: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 50%;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.icon-button.is-busy {
  background: var(--error-border);
  cursor: pointer;
}

.icon-button.is-busy:hover:not(:disabled) {
  background: color-mix(in srgb, var(--error-border) 82%, var(--text));
}

.send-icon,
.stop-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  line-height: 0;
}

.send-icon svg,
.stop-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

.chat-pane.empty-state .log {
  flex: 0 0 auto;
  width: min(100%, 760px);
  max-height: none;
  overflow: visible;
  padding: 0 18px;
}

.chat-pane.empty-state .composer {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 12px 18px 20px;
  border-top: none;
  background: transparent;
  box-shadow: none;
}

.chat-pane.empty-state .composer textarea {
  min-height: 72px;
  border-radius: 20px;
}

.composer-input textarea,
.composer-input textarea:focus {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.chat-pane.empty-state .composer .icon-button {
  width: 42px;
  height: 42px;
  min-height: 42px;
}

.chat-pane.empty-state .composer .icon-button.is-busy {
  min-width: 42px;
}

/* --- Sign-in (RET-15) --- */
.auth-status {
  color: var(--muted);
  font-size: 12px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-status.signed-in {
  color: var(--text);
}

.signin-dialog {
  position: fixed;
  z-index: 1001;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-md);
}

.signin-backdrop {
  position: fixed;
  z-index: 1000;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.signin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

.signin-form h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.signin-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
}

.signin-account-summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 9px 11px;
}

.signin-account-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
}

.signin-account-back:hover:not(:disabled),
.signin-account-back:focus-visible {
  background: transparent;
  color: var(--accent-hover);
  box-shadow: none;
  transform: none;
}

.signin-account-label {
  display: block;
  margin-bottom: 1px;
  color: var(--muted);
  font-size: 11px;
}

.signin-account-summary strong {
  display: block;
  max-width: 315px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signin-modes {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: stretch;
  font-size: 13px;
}

.signin-role-tabs {
  display: flex;
  width: 100%;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-soft);
}

.signin-role-tab {
  flex: 1 1 0;
  min-width: 0;
  width: 0;
  cursor: pointer;
}

.signin-role-tab input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.signin-role-tab span {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.signin-role-tab:hover span {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent-hover);
}

.signin-role-tab input:checked + span {
  border-color: var(--accent-hover);
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 2px 6px rgba(59, 166, 140, 0.22);
}

.signin-role-tab input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.signin-modes label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.signin-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.signin-field input,
.signin-field select {
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--panel-soft);
  color: var(--text);
  outline: none;
}

.signin-field input:focus,
.signin-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.signin-code-field input {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
}

.signin-code-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.signin-organization-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel-soft);
}

.signin-organization-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.signin-organization-summary strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signin-error {
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--error-bubble);
  border: 1px solid var(--error-border);
  font-size: 13px;
}

.signin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.business-dialog {
  position: fixed;
  z-index: 1001;
  width: min(430px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-md);
}

.business-dialog::backdrop {
  background: rgba(10, 23, 38, 0.56);
  backdrop-filter: blur(4px);
}

.business-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
}

.business-dialog-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 20px;
}

.business-form h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.business-dialog-hint {
  margin: -4px 0 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.business-error {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--error-bubble);
  border: 1px solid var(--error-border);
  font-size: 13px;
}

/* --- MCP OAuth sign-in page --- */
body.oauth-page {
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.oauth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.oauth-consent {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .topbar-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }

  .header-center {
    position: static;
    order: 3;
    width: 100%;
    max-width: none;
    justify-content: center;
    transform: none;
  }

  .business-switcher {
    max-width: calc(100vw - 32px);
  }

  .business-switcher select {
    max-width: calc(100vw - 150px);
  }

  .session-indicator .session-id {
    display: block;
    max-width: calc(100vw - 150px);
  }

  .topbar-controls .auth-status {
    max-width: 150px;
  }

  .turn,
  .turn.tool {
    max-width: 92%;
  }

  .log {
    padding: 20px 14px;
  }

  .pending-confirmations {
    padding-right: 14px;
    padding-left: 14px;
  }

  .composer {
    padding: 12px 14px 16px;
  }

  .composer textarea {
    min-width: 0;
  }

  .composer-input {
    border-radius: 17px;
  }

  .welcome-state h1 {
    font-size: 32px;
  }

  .welcome-state p {
    font-size: 14px;
  }

  .chat-pane.empty-state .composer {
    padding-right: 14px;
    padding-left: 14px;
  }
}

/* --- Attachments --- */
.composer textarea {
  padding-right: 106px;
}

.attach-button {
  right: 58px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.attach-button:hover:not(:disabled),
.attach-button:focus-visible {
  background: transparent;
  color: var(--accent-hover);
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.attach-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 0;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
  font-size: 12.5px;
  color: var(--text);
}

.attachment-chip .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip .kind {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.attachment-chip.uploading {
  opacity: 0.6;
}

.attachment-chip.failed {
  border-color: #d9534f;
  color: #b52b27;
}

.attachment-chip button {
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.attachment-chip button:hover {
  color: var(--text);
  background: var(--border-strong);
}

.composer-input.dragging {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.msg .attachment-list {
  padding: 8px 0 0;
}

/* --- UX pass: replies, progress, approvals, suggestions, sign-in --- */
.msg.agent {
  white-space: normal;
}

.msg.agent > :first-child { margin-top: 0; }
.msg.agent > :last-child { margin-bottom: 0; }
.msg.agent p { margin: 0 0 8px; }
.msg.agent h3, .msg.agent h4, .msg.agent h5, .msg.agent h6 {
  margin: 12px 0 6px;
  font-size: 14.5px;
  font-weight: 750;
  line-height: 1.35;
}
.msg.agent ul, .msg.agent ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.agent li { margin: 2px 0; }
.msg.agent a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.msg.agent code {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--muted) 16%, transparent);
}
.msg.agent pre {
  margin: 6px 0 8px;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  background: color-mix(in srgb, var(--muted) 12%, transparent);
}
.msg.agent pre code { padding: 0; background: none; white-space: pre; }
.msg.agent .table-wrap { overflow-x: auto; margin: 6px 0 10px; }
.msg.agent table { border-collapse: collapse; font-size: 13px; min-width: 60%; }
.msg.agent th, .msg.agent td { border: 1px solid var(--border-strong); padding: 5px 9px; text-align: left; vertical-align: top; }
.msg.agent th { font-weight: 700; background: color-mix(in srgb, var(--accent) 10%, transparent); }

.msg.agent.thinking .thinking-label {
  margin-left: 6px;
  font-size: 13px;
  color: var(--muted);
}

.turn.agent .thinking-elapsed {
  margin: 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.confirmation-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 8px;
  word-break: break-word;
}

.confirmation-details {
  margin: 0 0 9px;
  font-size: 13px;
  color: var(--text);
}
.confirmation-details summary {
  width: fit-content;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}
.confirmation-details dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 8px 0 0;
}
.confirmation-details dt { color: var(--muted); }
.confirmation-details dd { margin: 0; word-break: break-word; }

.confirmation-typed {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text);
}
.confirmation-typed input {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
}
.confirmation-typed input:focus {
  border-color: var(--confirm-border);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--confirm-border) 18%, transparent);
  outline: none;
}
.confirmation-card .actions button:disabled { opacity: 0.5; cursor: not-allowed; }

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.agent-choice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 0 8px;
}

.agent-choice-actions .suggestion-chip {
  background: transparent;
}

.agent-choice-actions .suggestion-chip:hover,
.agent-choice-actions .suggestion-chip:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
}
.suggestion-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}
.suggestion-chip:hover, .suggestion-chip:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
}

.retry-button { margin-top: 8px; align-self: flex-start; }

.chat-action-button {
  align-self: flex-start;
  margin: 2px 0 0 8px;
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--accent-hover);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong));
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
}

.chat-action-button:hover:not(:disabled) {
  color: var(--accent-text);
  background: var(--accent);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.signin-modes { flex-wrap: wrap; align-items: center; }
.signin-modes-label { color: var(--muted); }

@media (max-width: 640px) {
  .suggestions { justify-content: flex-start; }
  .topbar-controls { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .turn.user .msg,
  .turn.agent .msg,
  .turn.tool .msg,
  .turn.error .msg {
    animation: none;
  }

  .msg.agent.thinking span.dot { animation: none; }
}
