/* Local web GUI, following the approved design (docs/ui/design/*.dc.html): neutral greys, one teal
   accent reserved for verified/identity states, a sidebar with the Agent identity card, a centred
   768px conversation column and a pinned composer. Everything is driven by the custom properties below.

   Theme: `<html data-theme="light"|"dark">` is set by theme.js and always reflects the effective
   theme, including the OS preference when no override was chosen, so automation can read it
   directly (WG-AC-11). The `prefers-color-scheme` block only covers the moment before that script
   runs, so a dark OS does not flash white.

   CSP: style-src 'self', font-src falls back to default-src 'none'. This file therefore uses the
   system font stack (the design's Geist cannot be loaded without loosening the CSP), no `style=`
   attributes and no data: URIs. Icons are inline SVG or CSS shapes. See docs/architecture/web-gui.md
   "Visual design". */

:root {
  /* Surfaces */
  --bg: #ffffff;
  --sidebar-bg: #f7f7f8;
  --surface: #ffffff;
  --raised: #f0f0f2;
  --hover: rgba(0, 0, 0, 0.06);
  --border: #e4e4e7;
  --border-strong: #8e8e96; /* control boundaries: >= 3:1 against the page and fills (WCAG 1.4.11) */
  --scrim: rgba(17, 17, 19, 0.45);
  /* Text */
  --fg: #111113;
  --muted: #5e5e66;
  /* Chat */
  --user-bubble: #f0f0f2;
  /* The single accent: verified / identity states and links only. */
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #e3f2ef;
  --focus-ring: #0f766e;
  --focus-soft: rgba(15, 118, 110, 0.18);
  /* Status */
  --danger: #b3261e;
  --banner-bg: #b3261e;
  --error-fg: #9c1c1c;
  --error-bg: #fdecea;
  --notice-bg: #fff7e6;
  --notice-border: #f0dcae;
  --warn: #8a5a00;
  /* Shape and type */
  --col: 768px;
  --indent: 44px;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}

/* Dark values, written once for the "no script yet" case and once for the explicit attribute. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #212121;
    --sidebar-bg: #171717;
    --surface: #262626;
    --raised: #303030;
    --hover: rgba(255, 255, 255, 0.08);
    --border: #363636;
    --border-strong: #767676;
    --scrim: rgba(0, 0, 0, 0.6);
    --fg: #ececec;
    --muted: #a6a6a6;
    --user-bubble: #303030;
    --accent: #3cc9b4;
    --accent-hover: #6fe0cf;
    --accent-soft: #173a35;
    --focus-ring: #3cc9b4;
    --focus-soft: rgba(60, 201, 180, 0.25);
    --danger: #ff6b6b;
    --error-fg: #ff9a92;
    --error-bg: #3b1d1c;
    --notice-bg: #33290f;
    --notice-border: #54431a;
    --warn: #f5c26b;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  --bg: #212121;
  --sidebar-bg: #171717;
  --surface: #262626;
  --raised: #303030;
  --hover: rgba(255, 255, 255, 0.08);
  --border: #363636;
  --border-strong: #767676;
  --scrim: rgba(0, 0, 0, 0.6);
  --fg: #ececec;
  --muted: #a6a6a6;
  --user-bubble: #303030;
  --accent: #3cc9b4;
  --accent-hover: #6fe0cf;
  --accent-soft: #173a35;
  --focus-ring: #3cc9b4;
  --focus-soft: rgba(60, 201, 180, 0.25);
  --danger: #ff6b6b;
  --error-fg: #ff9a92;
  --error-bg: #3b1d1c;
  --notice-bg: #33290f;
  --notice-border: #54431a;
  --warn: #f5c26b;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

button,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

/* Small status pill: neutral by default, teal only for a verified state. */
.pill {
  display: inline-block;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--muted);
  background: var(--raised);
  border-radius: 999px;
}

.pill[data-state="verified"],
.pill-verified {
  color: var(--accent);
  background: var(--accent-soft);
}

/* Answered by the AS but not verified: neutral amber, deliberately not red. */
.pill[data-state="unverified"] {
  color: var(--warn);
  background: var(--notice-bg);
}

/* ---------- Shell ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-width: 320px;
}

.banner {
  flex: none;
  background: var(--banner-bg);
  color: #ffffff;
  text-align: center;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
}

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

.main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Sidebar ---------- */

.sidebar {
  flex: none;
  width: 272px; /* the design's 260px plus room for "verified by AIGW" on one line */
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 14px 12px;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
}

.sidebar-head {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 6px 8px;
  font-size: 15px;
  font-weight: 600;
}

.brand-mark,
.empty-mark {
  display: grid;
  place-items: center;
  flex: none;
  background: var(--fg);
  color: var(--bg);
  font-weight: 600;
  line-height: 1;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 14px;
}

.new-chat,
.re-register,
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--border-strong);
  transition: background-color 0.15s ease;
}

.new-chat {
  border-radius: 12px;
  background: var(--surface);
}

.re-register {
  justify-content: center;
  border-radius: 10px;
  font-size: 13px;
}

.theme-toggle {
  min-height: 36px;
  border-radius: 10px;
  border-color: transparent;
  font-size: 13px;
  color: var(--muted);
}

.new-chat:hover:not(:disabled),
.re-register:hover:not(:disabled),
.theme-toggle:hover {
  background: var(--hover);
}

.new-chat:disabled,
.re-register:disabled {
  opacity: 0.5;
}

.icon {
  flex: none;
}

.side-heading {
  margin: 0 0 8px;
  padding: 0 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.provider-model {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* The current provider/model text stays in the DOM (hook and screen-reader text), the selects are the UI. */
.pm-current {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.pm-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pm-label {
  padding: 0 4px;
  font-size: 12px;
  color: var(--muted);
}

/* CSS-only chevron: no image, so nothing for the CSP to block. */
.pm-field::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 15px;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.provider-model select {
  appearance: none;
  width: 100%;
  min-height: 40px;
  padding: 6px 32px 6px 12px;
  font-size: 14px;
  text-overflow: ellipsis;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  transition: border-color 0.15s ease;
}

.provider-model select:hover:not(:disabled) {
  border-color: var(--muted);
}

.provider-model select:disabled {
  opacity: 0.6;
}

/* Agent identity card (bottom of the sidebar). */
.identity-card {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

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

.identity-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.identity-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* "Verified by Trulioo": teal on its soft fill (4.7:1 light, 6.0:1 dark). */
.trulioo-tag {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 3px 11px 3px 9px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}

.identity-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.identity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.identity-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.identity-icon.ok {
  color: var(--accent);
}

.identity-name {
  flex: 1 1 auto;
  white-space: nowrap;
}

.identity-client-label {
  color: var(--muted);
}

.identity-value {
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
  color: var(--muted);
  overflow-wrap: anywhere;
  text-align: right;
}

.identity-mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
}

.scrim {
  display: none;
}

/* ---------- Header ---------- */

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 20px;
}

button.sidebar-toggle,
button.new-chat-icon {
  display: none;
}

.topbar-title {
  min-width: 0;
}

.app-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.app-model {
  margin-left: 6px;
  font-weight: 400;
  color: var(--muted);
}

.header-verified {
  display: none;
  margin: 0;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11px;
  color: var(--accent);
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}

.status-line {
  color: var(--muted);
}

.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.state-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}

.state-pill[data-state="online"]::before {
  background: var(--accent);
}

.state-pill[data-state="offline"]::before,
.state-pill[data-state="ended"]::before {
  background: var(--danger);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 10px;
}

.icon-button:hover:not(:disabled) {
  background: var(--hover);
}

.icon-button:disabled {
  opacity: 0.5;
}

/* ---------- Conversation ---------- */

.chat {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.transcript {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  /* Centres a 768px column; the scrollbar stays at the window edge. */
  padding: 16px max(16px, calc((100% - var(--col)) / 2)) 12px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scrollbar-width: thin;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px 16px 64px;
  text-align: center;
  pointer-events: none;
}

.chat[data-empty="false"] .empty-state {
  display: none;
}

.empty-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 22px;
}

.empty-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.25;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: var(--col);
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: auto;
}

.chip {
  min-height: 36px;
  padding: 7px 16px;
  font-size: 14px;
  line-height: 1.4;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.chip:hover:not(:disabled) {
  background: var(--hover);
  border-color: var(--muted);
}

.chip:disabled {
  opacity: 0.5;
}

/* Every transcript entry is a `.msg`. Assistant text sits in the column with an avatar; everything
   that is not conversation (tool activity, sign-in, registration, receipts, notices, widgets)
   is a smaller, bordered card indented to the text edge so it reads as secondary. */
.msg {
  min-width: 0;
}

.msg-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-assistant {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  column-gap: 14px;
  align-items: start;
}

.msg-assistant::before {
  content: "S";
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.msg-assistant .msg-body {
  padding: 2px 0;
}

.msg-user,
.msg-widget-user {
  align-self: flex-end;
  max-width: min(80%, 540px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.msg-user .msg-body,
.msg-widget-user .msg-body {
  padding: 10px 18px;
  border-radius: 22px;
  background: var(--user-bubble);
}

.msg-widget-user .badge {
  margin-bottom: 2px;
  padding-right: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* Cards */
.msg-tool,
.auth-panel,
.msg-registration,
.msg-receipt,
.msg-notice .msg-body,
.msg-widget-consent,
.widget-placeholder {
  margin-left: var(--indent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.5;
}

.msg-notice .msg-body {
  padding: 8px 14px;
  background: var(--notice-bg);
  border-color: var(--notice-border);
}

.msg-notice-error .msg-body {
  color: var(--error-fg);
  background: var(--error-bg);
  border-color: var(--error-fg);
}

.msg-receipt {
  padding: 10px 14px;
  font-weight: 600;
  border-left: 3px solid var(--accent);
}

.msg-receipt .msg-body {
  padding: 0;
}

/* Tool activity: a compact pill, left-aligned, never stretched across the column. */
.msg-tool {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - var(--indent));
  padding: 4px 12px 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.tool-name {
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

.tool-name::before {
  content: "\2699\FE0E  ";
}

.tool-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.msg-tool[data-state="running"] .tool-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.1s ease-in-out infinite;
}

.msg-tool[data-state="done"] .tool-state {
  color: var(--accent);
}

.msg-tool[data-state="error"] .tool-state {
  color: var(--danger);
}

/* Sign-in card: a status line while it is in progress, three tiles once signed in. */
.auth-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  color: var(--fg);
}

.auth-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.auth-text {
  font-weight: 600;
  margin-right: auto;
}

.auth-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: var(--bg);
  background: var(--danger);
}

.auth-panel[data-state="running"] .auth-head::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.auth-panel[data-state="failed"] {
  color: var(--error-fg);
  border-color: var(--error-fg);
  background: var(--error-bg);
}

.auth-error {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.auth-authorize-link {
  padding: 6px 16px;
  font-weight: 600;
  text-decoration: none;
  color: var(--bg);
  background: var(--fg);
  border-radius: 999px;
}

.auth-authorize-link:hover {
  color: var(--bg);
  opacity: 0.85;
}

.auth-tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.auth-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--raised);
  border-radius: 12px;
}

.auth-tile-label {
  font-size: 12px;
  color: var(--muted);
}

.auth-tile-value {
  font-size: 13px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.auth-steps {
  font-size: 13px;
}

.auth-steps summary {
  width: fit-content;
  cursor: pointer;
  color: var(--muted);
}

.auth-step-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-step {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.auth-step-name {
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.auth-step-state {
  color: var(--muted);
  text-align: right;
}

.auth-step-failed .auth-step-state {
  color: var(--error-fg);
  font-weight: 600;
}

.auth-step-done .auth-step-state {
  color: var(--accent);
}

/* Widget cards. The iframe content is the store's own and is not styled here. */
.msg-widget {
  display: flex;
  flex-direction: column;
  margin-left: var(--indent);
}

.widget-frame {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.widget-placeholder {
  margin-left: 0;
  padding: 10px 14px;
  color: var(--muted);
  border-style: dashed;
}

.msg-widget-consent {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 14px;
  background: var(--notice-bg);
  border-color: var(--notice-border);
}

.consent-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.consent-actions {
  display: flex;
  gap: 8px;
}

.consent-actions button {
  min-height: 36px;
  padding: 0 16px;
  font-size: 14px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  transition: background-color 0.15s ease;
}

.consent-actions button:hover:not(:disabled) {
  background: var(--hover);
}

.consent-actions button[data-action="send-followup"] {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
  font-weight: 600;
}

.consent-actions button:disabled {
  opacity: 0.5;
}

/* Registration result (WBA-FR-13.8) */
.msg-registration {
  padding: 14px 16px;
  overflow-wrap: anywhere;
}

.msg-registration[data-state="failed"] {
  border-color: var(--error-fg);
}

.reg-heading {
  margin-bottom: 6px;
  font-weight: 600;
}

.msg-registration[data-state="ok"] .reg-heading {
  color: var(--accent);
}

.msg-registration[data-state="failed"] .reg-heading,
.reg-error {
  color: var(--error-fg);
}

.reg-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 6px;
}

.reg-label {
  color: var(--muted);
}

.reg-value {
  font-family: var(--mono);
  font-size: 13px;
}

.reg-notice {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--notice-bg);
  color: var(--fg);
}

.reg-notice-warning {
  border-left: 4px solid var(--danger);
  font-weight: 600;
}

.reg-notice-note {
  border-left: 4px solid var(--accent);
}

/* ---------- Composer ---------- */

.composer {
  flex: none;
  padding: 8px max(16px, calc((100% - var(--col)) / 2)) 14px;
  background: var(--bg);
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 18px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer-box:focus-within {
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px var(--focus-soft);
}

.composer-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  max-height: 200px;
  padding: 8px 0;
  resize: none;
  background: transparent;
  border: 0;
  outline: none;
  line-height: 1.5;
}

.composer-input::placeholder {
  color: var(--muted);
}

.composer-input:disabled {
  opacity: 0.6;
}

.send-button {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--bg);
  background: var(--fg);
  border: 0;
  border-radius: 50%;
  transition: opacity 0.15s ease;
}

.send-button:hover:not(:disabled) {
  opacity: 0.85;
}

.send-button:disabled {
  opacity: 0.3;
}

.composer-error {
  margin-top: 6px;
  padding: 0 14px;
  font-size: 13px;
  color: var(--error-fg);
}

.composer-error:empty {
  display: none;
}

.composer-hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.session-ended {
  flex: none;
  margin: 0 max(16px, calc((100% - var(--col)) / 2));
  padding: 8px 14px;
  text-align: center;
  font-size: 14px;
  color: var(--fg);
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: 12px;
}

/* ---------- Dialogs (purchase confirmation, re-register): a centred modal ---------- */

dialog#confirm-dialog,
dialog[data-kind="re-register"] {
  width: min(440px, 92vw);
  padding: 24px;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

/* `display: flex` only while open, or the closed dialog would be shown. */
dialog#confirm-dialog[open],
dialog[data-kind="re-register"][open] {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

dialog#confirm-dialog::backdrop,
dialog[data-kind="re-register"]::backdrop {
  background: var(--scrim);
}

.confirm-dialog h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

.confirm-question {
  margin: 0;
  color: var(--muted);
}

.confirm-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--raised);
  border-radius: 14px;
}

.confirm-summary:empty,
.confirm-total:empty {
  display: none;
}

.confirm-items {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.confirm-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name amount" "meta meta";
  gap: 0 12px;
}

.confirm-item-name {
  grid-area: name;
  overflow-wrap: anywhere;
}

.confirm-item-amount {
  grid-area: amount;
}

.confirm-item-meta {
  grid-area: meta;
  font-size: 13px;
  color: var(--muted);
}

.confirm-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding-top: 8px;
  font-weight: 600;
  border-top: 1px solid var(--border);
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.confirm-actions button {
  min-height: 44px;
  padding: 0 20px;
  font-size: 15px;
  border-radius: 999px;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.confirm-actions button:disabled {
  opacity: 0.5;
}

.confirm-cancel {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg);
  font-weight: 500;
}

.confirm-cancel:hover:not(:disabled) {
  background: var(--hover);
}

.confirm-primary {
  background: var(--fg);
  border: 1px solid var(--fg);
  color: var(--bg);
  font-weight: 600;
}

.confirm-primary:hover:not(:disabled) {
  opacity: 0.88;
}

.fatal-notice {
  padding: 40px;
  text-align: center;
  color: var(--fg);
  background: var(--bg);
}

/* ---------- Motion ---------- */

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

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Narrow screens: slide-over sidebar and the compact header ---------- */

@media (max-width: 859px) {
  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }

  .app[data-sidebar="open"] .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 0.2s ease, visibility 0s;
  }

  .sidebar-head {
    display: flex;
  }

  .scrim {
    position: fixed;
    z-index: 20;
    inset: 0;
    background: var(--scrim);
  }

  .scrim:not([hidden]) {
    display: block;
  }

  /* menu | title + "Verified agent" | new chat */
  .topbar {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    padding: 8px 6px;
    border-bottom: 1px solid var(--border);
  }

  button.sidebar-toggle,
  button.new-chat-icon {
    display: grid;
  }

  .topbar-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .app-title {
    font-size: 15px;
  }

  .app-model,
  .topbar-status {
    display: none;
  }

  .header-verified:not([hidden]) {
    display: flex;
  }
}

@media (max-width: 640px) {
  .auth-tiles {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  :root {
    --indent: 0px;
  }

  .empty-title {
    font-size: 22px;
  }

  .msg-user,
  .msg-widget-user {
    max-width: 85%;
  }
}
