/* The shared look of both Complexa hosts (docs/15 §3, docs/10 §5.5): tokens in both themes, base elements, buttons, the mark.
   The chat site prepends it to site.css, site-auth to auth.css. System fonts only, no external assets. */

:root {
  --bg: #f6f6f3;
  --panel: #ffffff;
  --nav: #efefeb;
  --soft: #ebebe6;
  --active: #e3e3dd;
  --text: #1d1d1f;
  --muted: #6c6c70;
  --line: #e2e2dc;
  --accent: #2f6bd8;
  --accent-text: #ffffff;
  --accent-soft: #e6eefc;
  --user: #e8edf6;
  --code: #f0f0eb;
  --good: #1f8a4c;
  --warn: #a8640a;
  --danger: #c23b31;
  --trusted: #6b57c9;
  --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 6px 20px rgb(0 0 0 / 5%);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
  font: 15.5px/1.55 var(--font);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618;
    --panel: #1f1f22;
    --nav: #1a1a1d;
    --soft: #26262a;
    --active: #2e2e33;
    --text: #ececef;
    --muted: #9b9ba3;
    --line: #2e2e33;
    --accent: #6c9dff;
    --accent-text: #0d1424;
    --accent-soft: #233150;
    --user: #2a2e38;
    --code: #26262b;
    --good: #4cc27f;
    --warn: #e0a24a;
    --danger: #ff7b6e;
    --trusted: #a493ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 25%);
  }
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
a {
  color: var(--accent);
}
button {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
.cx-muted {
  color: var(--muted);
  font-size: 13.5px;
  margin: 2px 0;
}
.cx-boot,
.cx-empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 16px;
  margin: auto;
}
.cx-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Buttons */
.cx-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 14px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}
.cx-button:hover {
  background: var(--soft);
}
.cx-primary,
.cx-button.cx-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.cx-button.cx-primary:hover {
  filter: brightness(1.06);
  background: var(--accent);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
.cx-round {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.cx-round:hover:not(.cx-primary) {
  background: var(--soft);
}
.cx-logo {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 8px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--trusted));
  color: #fff;
  font-weight: 700;
  font-size: 24px;
}
/* The chat site's own style. Tokens, base elements, buttons and the mark come first from @complexa/ui theme.css. */

/* Frame: the panel slides out on a phone, stays on the left from 900 px */
.cx-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
}
.cx-nav {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: min(86vw, 320px);
  display: flex;
  flex-direction: column;
  background: var(--nav);
  border-right: 1px solid var(--line);
  transform: translateX(-102%);
  transition: transform 0.22s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
.cx-app[data-drawer="open"] .cx-nav {
  transform: none;
  box-shadow: var(--shadow);
}
.cx-scrim {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgb(0 0 0 / 35%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.cx-app[data-drawer="open"] .cx-scrim {
  opacity: 1;
  pointer-events: auto;
}
@media (min-width: 900px) {
  .cx-app {
    grid-template-columns: 284px minmax(0, 1fr);
  }
  .cx-nav {
    position: static;
    width: auto;
    transform: none;
    transition: none;
  }
  .cx-app[data-drawer="open"] .cx-nav {
    box-shadow: none;
  }
  .cx-menu,
  .cx-close,
  .cx-scrim {
    display: none;
  }
}
.cx-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 8px 16px;
}
.cx-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 16px;
}
.cx-logo-small {
  width: 28px;
  height: 28px;
  margin: 0;
  border-radius: 9px;
  font-size: 14px;
}
.cx-new {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 12px 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-weight: 550;
  cursor: pointer;
}
.cx-new:hover {
  background: var(--soft);
}
.cx-convs-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px;
}
.cx-convs {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cx-convs-empty {
  padding: 8px 10px;
}
.cx-conv {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1px 8px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
.cx-conv:hover {
  background: var(--soft);
}
.cx-conv[aria-current="page"] {
  background: var(--active);
}
.cx-conv-title,
.cx-conv-preview {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
}
.cx-conv-preview {
  color: var(--muted);
  font-size: 12.5px;
}
.cx-unread .cx-conv-title {
  font-weight: 650;
}
.cx-conv-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.cx-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11.5px;
  font-weight: 650;
  justify-self: end;
  margin-left: auto;
}
.cx-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: cx-pulse 1.4s ease-in-out infinite;
}
.cx-nav-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border-top: 1px solid var(--line);
}
.cx-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 14.5px;
}
.cx-nav-link:hover {
  background: var(--soft);
}
.cx-nav-link[aria-current="page"] {
  background: var(--active);
}

.cx-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
}
.cx-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 52px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.cx-title {
  flex: 1;
  min-width: 0;
  margin: 0 4px;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cx-conn {
  margin: 0;
  color: var(--warn);
  font-size: 12.5px;
}
.cx-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Conversation */
.cx-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.cx-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px 8px;
}
.cx-older {
  display: flex;
  margin: 0 auto 16px;
}
.cx-feed,
.cx-pending {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 760px;
  margin: 0 auto;
}
.cx-pending:empty {
  display: none;
}
.cx-msg {
  min-width: 0;
}
.cx-user {
  align-self: flex-end;
  max-width: min(85%, 600px);
}
.cx-bubble {
  padding: 9px 14px;
  border-radius: 18px 18px 5px 18px;
  background: var(--user);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cx-sending {
  opacity: 0.6;
}
.cx-meta {
  margin: 4px 6px 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.cx-user .cx-meta {
  text-align: right;
}
.cx-assistant {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
}
.cx-avatar {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--trusted));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.cx-body {
  overflow-wrap: anywhere;
  padding-top: 2px;
}
.cx-body > * + * {
  margin-top: 10px;
}
.cx-md p,
.cx-md ul,
.cx-md ol,
.cx-md pre,
.cx-md h3 {
  margin: 0 0 0.65em;
}
.cx-md > :last-child {
  margin-bottom: 0;
}
.cx-md h3 {
  font-size: 15.5px;
}
.cx-md ul,
.cx-md ol {
  padding-left: 22px;
}
.cx-md li + li {
  margin-top: 3px;
}
.cx-md code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--code);
  font: 0.88em/1.4 var(--mono);
}
.cx-md pre {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--code);
  overflow-x: auto;
}
.cx-md pre code {
  padding: 0;
  background: none;
  white-space: pre;
}
.cx-domain {
  color: var(--muted);
  font-size: 12px;
}
.cx-notice {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13.5px;
}
.cx-notice.cx-error {
  color: var(--danger);
}
.cx-question {
  max-width: 560px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.cx-question > p:first-child {
  margin: 0 0 10px;
}
.cx-question-keys,
.cx-actions,
.cx-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cx-progress {
  margin-left: 40px;
}
.cx-progress > * + * {
  margin-top: 8px;
}
.cx-thinking {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.cx-dots {
  display: inline-flex;
  gap: 4px;
}
.cx-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: cx-bounce 1.2s ease-in-out infinite;
}
.cx-dots i:nth-child(2) {
  animation-delay: 0.15s;
}
.cx-dots i:nth-child(3) {
  animation-delay: 0.3s;
}
.cx-steps {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  font-size: 13.5px;
  color: var(--muted);
}
.cx-steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}
.cx-step-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.6px solid var(--muted);
  flex-shrink: 0;
}
.cx-done .cx-step-mark {
  border-color: var(--good);
  background: var(--good);
}
.cx-now {
  color: var(--text);
}
.cx-now .cx-step-mark {
  border-color: var(--accent);
  border-right-color: transparent;
  animation: cx-spin 0.9s linear infinite;
}
.cx-trace summary {
  width: fit-content;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.cx-welcome-chat {
  max-width: 560px;
  margin: 0 auto;
  padding: 12vh 0 24px;
  text-align: center;
}
.cx-welcome-chat h2 {
  margin: 6px 0 4px;
  font-size: 22px;
  font-weight: 650;
}
.cx-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}
.cx-chip {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 14px;
  cursor: pointer;
}
.cx-chip:hover {
  background: var(--soft);
}

/* Field */
.cx-composer {
  padding: 6px 12px max(12px, env(safe-area-inset-bottom));
}
.cx-field {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 760px;
  margin: 0 auto;
  padding: 6px 6px 6px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.cx-field:focus-within {
  border-color: var(--accent);
}
.cx-field textarea {
  flex: 1;
  min-width: 0;
  max-height: 200px;
  padding: 7px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.45;
  resize: none;
}
.cx-field textarea::placeholder {
  color: var(--muted);
}
.cx-stop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px 0 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--soft);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.cx-stop .cx-icon {
  fill: currentColor;
  width: 16px;
  height: 16px;
}
.cx-hint {
  max-width: 760px;
  min-height: 1.2em;
  margin: 6px auto 0;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}
.cx-hint[data-tone="error"] {
  color: var(--danger);
}

/* Widgets: the same classes as the Mini App (`webHtml`), in the site's tokens */
.cx-widget {
  max-width: 640px;
}
.cx-surface {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.cx-trust-host {
  border-color: color-mix(in srgb, var(--trusted) 45%, var(--line));
}
.cx-host {
  margin: 0 0 6px;
  color: var(--trusted);
  font-size: 12px;
}
.cx-card header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}
.cx-card h2 {
  margin: 0;
  font-size: 16.5px;
}
.cx-sub {
  width: 100%;
  margin: 2px 0 8px;
  color: var(--muted);
  font-size: 13.5px;
}
.cx-card .cx-card {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
}
.cx-surface h3 {
  margin: 12px 0 4px;
  font-size: 14.5px;
}
.cx-text,
.cx-row,
.cx-fact,
.cx-check {
  margin: 4px 0;
}
.cx-stack.cx-gap-block > * + * {
  margin-top: 10px;
}
.cx-fact-label {
  color: var(--muted);
}
.cx-fact-label::after {
  content: ":";
}
.cx-list {
  margin: 4px 0;
  padding-left: 20px;
}
.cx-list.cx-plain {
  list-style: none;
  padding-left: 0;
}
.cx-list.cx-spaced > li + li {
  margin-top: 10px;
}
.cx-more,
.cx-sep {
  color: var(--muted);
}
.cx-badge-inline,
.cx-surface .cx-badge {
  display: inline-block;
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}
.cx-money {
  font-variant-numeric: tabular-nums;
}
.cx-money s {
  color: var(--muted);
}
.cx-check.cx-done {
  color: var(--muted);
}
.cx-collapse summary {
  cursor: pointer;
  font-weight: 600;
}
.cx-table-wrap {
  overflow-x: auto;
}
.cx-table {
  border-collapse: collapse;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.cx-table th,
.cx-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.cx-chart {
  margin: 6px 0;
}
.cx-chart svg {
  width: 100%;
  max-width: 360px;
  height: 44px;
}
.cx-chart polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.cx-chart figcaption {
  color: var(--muted);
  font-size: 12px;
}
.cx-keys {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.cx-keyrow {
  display: flex;
  gap: 6px;
}
.cx-key {
  flex: 1;
  min-height: 36px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 550;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.cx-key:hover {
  border-color: var(--accent);
}

/* Pages: settings and the debug place */
.cx-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
.cx-card-section {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.cx-card-section h2 {
  margin: 0 0 10px;
  font-size: 16px;
}
.cx-card-section > p {
  margin: 4px 0;
}
.cx-card-section > * + .cx-actions,
.cx-card-section > * + .cx-invite-link {
  margin-top: 12px;
}
.cx-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cx-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}
.cx-row-item + .cx-row-item {
  border-top: 1px solid var(--line);
}
.cx-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.cx-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}
.cx-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cx-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
}
.cx-option input {
  accent-color: var(--accent);
}
.cx-input,
.cx-dialog input,
.cx-dialog textarea {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

/* Dialog and toast */
.cx-dialog {
  width: min(92vw, 440px);
  padding: 18px;
  border: 0;
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
.cx-dialog::backdrop {
  background: rgb(0 0 0 / 40%);
}
.cx-dialog h2 {
  margin: 0 0 12px;
  font-size: 17px;
}
.cx-form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.cx-field-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13.5px;
}
.cx-check-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cx-check-field input {
  flex: 0;
}
.cx-dialog-actions {
  display: flex;
  justify-content: flex-end;
}
.cx-toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: min(92vw, 480px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}
.cx-toast[data-tone="error"] {
  background: var(--danger);
  color: #fff;
}

/* Signed out */
.cx-welcome {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 16px;
}
.cx-welcome-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}
.cx-welcome-card h1 {
  margin: 4px 0 8px;
  font-size: 24px;
}
.cx-welcome-card .cx-button {
  min-width: 160px;
  margin: 18px 0 10px;
  font-size: 15px;
}

/* Chat v1 (docs/15 §3.2): conversation actions, answer actions, retries, tools */
.cx-title-slot {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.cx-bar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
.cx-bar-actions:empty {
  display: none;
}
.cx-bar-actions .cx-round[aria-expanded="true"] {
  background: var(--active);
}
.cx-rename {
  width: 100%;
  font-size: 15px;
}
.cx-conv-item {
  position: relative;
}
.cx-renaming {
  padding: 3px 2px;
}
.cx-conv-item .cx-more {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 30px;
  height: 30px;
  transform: translateY(-50%);
  background: var(--active);
  opacity: 0;
}
.cx-conv-item:hover .cx-more,
.cx-conv-item .cx-more:focus-visible,
.cx-conv-item .cx-more[aria-expanded="true"] {
  opacity: 1;
}
.cx-conv-item:hover :is(.cx-conv-meta, .cx-badge),
.cx-conv-item:focus-within :is(.cx-conv-meta, .cx-badge) {
  visibility: hidden;
}
@media (hover: none) {
  .cx-conv-item .cx-more {
    opacity: 1;
    background: transparent;
  }
  .cx-conv {
    padding-right: 40px;
  }
}
.cx-more .cx-icon {
  stroke-width: 3;
}
.cx-popover {
  position: fixed;
  z-index: 40;
  min-width: 190px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.cx-popover button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.cx-popover button:hover,
.cx-popover button:focus-visible {
  background: var(--soft);
  outline: none;
}
.cx-popover .cx-danger {
  color: var(--danger);
}
.cx-button.cx-danger-button {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.cx-button.cx-danger-button:hover {
  filter: brightness(1.06);
  background: var(--danger);
}
.cx-dialog .cx-dialog-actions {
  gap: 8px;
  margin-top: 16px;
}
.cx-dialog > p {
  margin: 0;
  overflow-wrap: anywhere;
}
.cx-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  margin-top: 4px;
}
.cx-meta-row .cx-meta {
  margin-top: 0;
}
.cx-msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.cx-assistant:hover .cx-msg-actions,
.cx-assistant.cx-actions-shown .cx-msg-actions,
.cx-msg-actions:focus-within {
  opacity: 1;
}
@media (hover: none) {
  .cx-msg-actions {
    opacity: 1;
  }
}
.cx-mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.cx-mini .cx-icon {
  width: 16px;
  height: 16px;
}
.cx-mini:hover {
  background: var(--soft);
  color: var(--text);
}
.cx-mini[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.cx-flip {
  transform: rotate(180deg);
}
.cx-retry {
  align-self: stretch;
}
.cx-retry-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}
.cx-retry-mark::before,
.cx-retry-mark::after {
  content: "";
  flex: 1;
  min-width: 16px;
  border-top: 1px solid var(--line);
}
.cx-retry-mark .cx-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.cx-retry-text {
  max-width: 50%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cx-retry-mark time {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.cx-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.cx-tool {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}
.cx-tool code {
  font: 12px/1.5 var(--mono);
}
.cx-tool-fail {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  color: var(--danger);
}

/* Artifacts (docs/15 §3.3): a panel on the right from 1200 px, sliding out below */
.cx-side {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 20;
  width: min(90vw, 340px);
  display: flex;
  flex-direction: column;
  background: var(--nav);
  border-left: 1px solid var(--line);
  transform: translateX(102%);
  visibility: hidden;
  transition:
    transform 0.22s ease,
    visibility 0s linear 0.22s;
  padding-bottom: env(safe-area-inset-bottom);
}
.cx-app[data-side="open"] .cx-side {
  transform: none;
  visibility: visible;
  box-shadow: var(--shadow);
  transition: transform 0.22s ease;
}
.cx-side-scrim {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgb(0 0 0 / 35%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.cx-app[data-side="open"] .cx-side-scrim {
  opacity: 1;
  pointer-events: auto;
}
.cx-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 8px 8px 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.cx-side-head h2 {
  margin: 0;
  font-size: 15px;
}
.cx-side-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 24px;
}
@media (min-width: 1200px) {
  .cx-app[data-side="open"] {
    grid-template-columns: 284px minmax(0, 1fr) 320px;
  }
  .cx-side {
    position: static;
    width: auto;
    transform: none;
    transition: none;
  }
  .cx-app:not([data-side="open"]) .cx-side {
    display: none;
  }
  .cx-app[data-side="open"] .cx-side {
    box-shadow: none;
  }
  .cx-side-scrim {
    display: none;
  }
}
.cx-art {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.cx-art-section h3 {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 650;
}
.cx-art-note,
.cx-art-empty {
  margin: 0 0 8px;
  font-size: 13px;
}
.cx-art-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cx-art-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  font-size: 14px;
}
.cx-art-item + .cx-art-item {
  border-top: 1px solid var(--line);
}
.cx-art-title {
  min-width: 0;
  overflow-wrap: anywhere;
}
.cx-art-status {
  flex-shrink: 0;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
}
.cx-art-active {
  background: color-mix(in srgb, var(--good) 14%, transparent);
  color: var(--good);
}
.cx-art-proposed {
  background: var(--accent-soft);
  color: var(--accent);
}

@keyframes cx-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
@keyframes cx-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes cx-pulse {
  50% {
    opacity: 0.35;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Debug (docs/15 §8.5): works, the inspector tree, someone's-data banner, viewers and support grants */
.cx-page-wide {
  max-width: 920px;
}
.cx-back {
  align-self: flex-start;
  font-size: 14px;
  text-decoration: none;
}
.cx-back:hover {
  text-decoration: underline;
}
.cx-foreign {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 12%, var(--panel));
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}
.cx-foreign .cx-icon {
  color: var(--warn);
}
.cx-banner-slot:empty {
  display: none;
}
.cx-banner-slot {
  position: sticky;
  top: 0;
  z-index: 2;
}
.cx-select {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.cx-filters,
.cx-search {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}
.cx-search .cx-input {
  flex: 1 1 200px;
}
.cx-runs {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}
.cx-runs li + li {
  border-top: 1px solid var(--line);
}
.cx-run {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 8px;
  margin: 0 -8px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
.cx-run:hover {
  background: var(--soft);
}
.cx-run-title {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.cx-run-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  color: var(--muted);
  font-size: 13px;
}
.cx-run-meta code,
.cx-locator {
  font: 12.5px var(--mono);
  overflow-wrap: anywhere;
}
.cx-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cx-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.cx-status-live::before {
  background: var(--accent);
}
.cx-status-good::before {
  background: var(--good);
}
.cx-status-bad {
  color: var(--danger);
}
.cx-status-bad::before {
  background: var(--danger);
}

/* The tree */
.cx-tree {
  list-style: none;
  margin: 0;
  padding: 0 0 0 14px;
  border-left: 1px solid var(--line);
}
.cx-tree-root {
  padding: 0;
  border: 0;
  margin-top: 10px;
}
.cx-node {
  margin: 2px 0;
}
.cx-node-toggle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.cx-node-toggle:hover {
  background: var(--soft);
}
.cx-chevron {
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.cx-node-toggle[aria-expanded="true"] .cx-chevron {
  transform: rotate(90deg);
}
.cx-node-kind {
  font-weight: 600;
}
.cx-node-label {
  color: var(--muted);
  font: 12.5px var(--mono);
  overflow-wrap: anywhere;
}
.cx-node-content {
  padding: 4px 0 8px 22px;
}
.cx-node-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  margin-bottom: 6px;
}
.cx-node-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cx-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--soft);
}
.cx-tab {
  min-height: 30px;
  padding: 4px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
}
.cx-tab[aria-selected="true"] {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
.cx-card-section > .cx-tab-panel {
  margin-top: 8px;
}
.cx-button.cx-small {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
  text-decoration: none;
}
.cx-button.cx-small .cx-icon {
  width: 16px;
  height: 16px;
}
.cx-fields {
  display: grid;
  grid-template-columns: minmax(90px, max-content) 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 14px;
}
.cx-fields dt {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.cx-fields dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 560px) {
  .cx-fields {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .cx-fields dd + dt {
    margin-top: 8px;
  }
}
.cx-pre,
.cx-code {
  margin: 0;
  max-height: 480px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--code);
  font: 12.5px/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cx-code {
  white-space: pre;
  overflow-wrap: normal;
}
.cx-code-list section + section {
  margin-top: 12px;
}
.cx-code-list h4 {
  margin: 0 0 6px;
  font-size: 13.5px;
}
.cx-tok-keyword {
  color: #8a3fb8;
}
.cx-tok-string {
  color: #1f7a45;
}
.cx-tok-number {
  color: #b2520f;
}
.cx-tok-comment {
  color: var(--muted);
  font-style: italic;
}
.cx-tok-punct {
  color: var(--muted);
}
@media (prefers-color-scheme: dark) {
  .cx-tok-keyword {
    color: #d2a8ff;
  }
  .cx-tok-string {
    color: #7ee2a8;
  }
  .cx-tok-number {
    color: #ffb070;
  }
}
.cx-more-row {
  margin-top: 6px;
}
.cx-locator-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 0;
  font-size: 13px;
}
.cx-plate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 0 0 6px;
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13.5px;
}
.cx-plate p {
  margin: 0;
  flex: 1 1 220px;
}
.cx-plate .cx-icon {
  width: 16px;
  height: 16px;
}
.cx-plate-warn {
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, var(--panel));
  color: var(--text);
}
.cx-plate-bad {
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 8%, var(--panel));
  color: var(--text);
}
.cx-fields .cx-plate {
  margin: 0;
}

/* Settings: debug mode, viewers, grants */
.cx-switch {
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: var(--active);
  cursor: pointer;
  transition: background 0.15s ease;
}
.cx-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
  transition: transform 0.15s ease;
}
.cx-switch:checked {
  background: var(--accent);
}
.cx-switch:checked::after {
  transform: translateX(16px);
}
.cx-audit {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.cx-audit-item {
  padding: 10px 0;
}
.cx-audit-item + .cx-audit-item {
  border-top: 1px solid var(--line);
}
.cx-audit-item p {
  margin: 2px 0;
  overflow-wrap: anywhere;
}
.cx-card-section > .cx-plate {
  margin: 0 0 10px;
}
.cx-grant-form {
  margin: 12px 0 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.cx-grant-form .cx-select,
.cx-grant-form .cx-input {
  max-width: 420px;
}
.cx-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}
.cx-input.cx-days {
  flex: 0 0 auto;
  width: 96px;
}
.cx-subhead {
  margin: 16px 0 4px;
  font-size: 14px;
}
.cx-row-past {
  opacity: 0.7;
}
