/* Chloe components (0.8 ORBIT; 0.6 base). Built only from tokens.css; shown together on /styleguide.
   Plain elements get the default look (a <button> is a secondary button, inputs are inputs),
   so older screens pick up the design without extra classes.
   Classes: .btn .primary .secondary .quiet .link .danger .big .icon-btn | .field .toggle .segmented
   .chip .badge (.success .warning .danger .accent) | .card .list-group .list-row | .sheet .scrim
   .toast .empty-state .skeleton .steps | .stack .cluster .muted .visually-hidden */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
}
[hidden] {
  display: none !important;
}
h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: var(--lh-tight);
  font-weight: var(--fw-bold);
  letter-spacing: -0.015em;
}
h1 {
  font-size: var(--fs-2xl);
}
h2 {
  font-size: var(--fs-xl);
}
h3 {
  font-size: var(--fs-lg);
}
h4 {
  font-size: var(--fs-md);
}
p {
  margin: 0;
}
a {
  color: var(--accent-text);
  text-underline-offset: 2px;
}
small,
.small {
  font-size: var(--fs-xs);
}
.muted {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.error {
  color: var(--danger);
  font-size: var(--fs-sm);
}
.num,
time,
.timer,
.call-row .row-sub,
.page-meta,
.ask-count,
.task-next,
.ps-number,
.ps-choices,
.ps-time-left,
.ps-step-line,
.call-page-head .muted {
  /* Tabular numbers for timers, minutes, times and dates (blueprint 03); not body text,
     where Inter's tabular hyphen looks too wide. */
  font-variant-numeric: tabular-nums;
}
code {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.stack {
  display: grid;
  gap: var(--s-3);
}
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  align-items: center;
}

/* Keyboard focus: always visible. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}

/* ---------- icons ---------- */
svg.icon {
  width: 20px;
  height: 20px;
  flex: none;
  vertical-align: middle;
}
svg.icon.sm {
  width: 16px;
  height: 16px;
}
svg.icon.lg {
  width: 24px;
  height: 24px;
}

/* ---------- buttons ---------- */
button,
.btn {
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
  min-height: var(--tap);
  min-width: var(--tap);
  padding: var(--s-2) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  text-align: center;
  text-decoration: none;
  line-height: var(--lh-tight);
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
button:hover,
.btn:hover {
  background: var(--surface-2);
}
button:active,
.btn:active {
  transform: scale(0.98);
}
button:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: default;
  transform: none;
}
.primary {
  background: var(--grad-primary);
  border-color: transparent;
  color: var(--on-accent);
  font-weight: var(--fw-bold);
}
.primary:hover {
  background: var(--grad-primary-hover);
  border-color: transparent;
}
.secondary {
  background: var(--surface);
  border-color: var(--border-strong);
}
.quiet,
.link {
  background: transparent;
  border-color: transparent;
  color: var(--accent-text);
}
.quiet:hover,
.link:hover {
  background: var(--accent-soft);
}
.danger {
  background: var(--danger-fill);
  border-color: var(--danger-fill);
  color: var(--on-danger);
  font-weight: var(--fw-bold);
}
.danger:hover {
  filter: brightness(1.08);
  background: var(--danger-fill);
}
.danger.quiet {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}
.danger.quiet:hover {
  background: var(--danger-soft);
  filter: none;
}
/* Outlined destructive (danger zones): <button class="danger outline"> */
.danger.outline {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
  color: var(--danger);
}
.danger.outline:hover {
  background: var(--danger-soft);
  filter: none;
}
.big {
  min-height: 56px;
  border-radius: var(--r-pill);
  padding: var(--s-3) var(--s-6);
  font-size: var(--fs-md);
  width: 100%;
}
.icon-btn {
  padding: 0;
  width: var(--tap);
  border-radius: var(--r-pill);
}
.btn-row,
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* ---------- inputs ---------- */
input:not([type]),
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="time"],
input[type="date"],
input[type="search"],
input[type="url"],
textarea,
select {
  font: inherit;
  font-size: var(--fs-md);
  color: var(--text);
  width: 100%;
  min-height: var(--tap);
  padding: 10px var(--s-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
textarea {
  resize: vertical;
  min-height: 88px;
  line-height: var(--lh);
}
select {
  appearance: none;
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
input:hover,
textarea:hover,
select:hover {
  border-color: var(--border-strong);
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  background-color: var(--surface);
}
::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  width: 20px;
  height: 20px;
  margin: 0;
  flex: none;
}
.field {
  display: grid;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.field > span:first-child,
.field-label {
  font-weight: var(--fw-medium);
  color: var(--text);
}
.field .hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.field.invalid input,
.field.invalid textarea {
  border-color: var(--danger);
}

/* Toggle: <label class="toggle"><input type="checkbox" role="switch"><span>Label</span></label> */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: var(--tap);
  cursor: pointer;
  color: var(--text);
}
.toggle input {
  appearance: none;
  -webkit-appearance: none;
  order: 2;
  width: 48px;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  position: relative;
  cursor: pointer;
  transition: background-color var(--t) var(--ease);
}
.toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform var(--t) var(--ease);
}
.toggle input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle input:checked::after {
  transform: translateX(20px);
}
.toggle input:disabled {
  opacity: 0.5;
}

/* Segmented control: <div class="segmented" role="group"><button aria-pressed="true">A</button>...</div> */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-input);
  max-width: 100%;
  justify-self: start;
}
.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 8px;
  min-height: var(--tap);
  color: var(--text-muted);
  white-space: nowrap;
}
.segmented button[aria-pressed="true"],
.segmented button.active {
  background: var(--surface);
  color: var(--text);
  font-weight: var(--fw-bold);
  box-shadow: var(--shadow);
}
:root[data-theme="dark"] .segmented button[aria-pressed="true"],
:root[data-theme="dark"] .segmented button.active {
  background: var(--surface-3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .segmented button[aria-pressed="true"],
  :root:not([data-theme="light"]) .segmented button.active {
    background: var(--surface-3);
  }
}

/* ---------- chips and badges ---------- */
.badge,
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.3;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
  vertical-align: middle;
}
.success {
  --tone: var(--success);
  --tone-soft: var(--success-soft);
}
.warning {
  --tone: var(--warning);
  --tone-soft: var(--warning-soft);
}
.badge.danger,
.chip.danger {
  --tone: var(--danger);
  --tone-soft: var(--danger-soft);
}
.accent {
  --tone: var(--accent-text);
  --tone-soft: var(--accent-soft);
}
.badge.success,
.badge.warning,
.badge.danger,
.badge.accent,
.chip.success,
.chip.warning,
.chip.danger,
.chip.accent {
  background: var(--tone-soft);
  color: var(--tone);
  border: 0;
  font-weight: var(--fw-medium);
}

/* ---------- cards and lists ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: var(--s-4);
  display: grid;
  /* One column that never grows past the card: long words wrap instead of widening the page. */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-2);
}
.card-title {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
}
.list-group {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
}
.list-group-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: var(--s-6) var(--s-1) var(--s-2);
}
.list-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 56px;
  padding: var(--s-3) var(--s-4);
  background: transparent;
  border: 0;
  border-radius: 0;
  border-top: 1px solid var(--border);
  text-align: left;
  color: var(--text);
  font-size: var(--fs-md);
  font-weight: var(--fw-regular);
  justify-content: flex-start;
}
.list-row:first-child {
  border-top: 0;
}
.list-row:hover {
  background: var(--surface-2);
}
.list-row:active {
  transform: none;
}
.list-row .row-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  flex: none;
}
.list-row .row-text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.list-row .row-title {
  font-weight: var(--fw-medium);
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row .row-sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-row .chev {
  color: var(--text-muted);
  flex: none;
}

/* ---------- bottom sheet (dialog on wide screens) ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 40;
  animation: fade-in var(--t) var(--ease);
}
.sheet {
  position: fixed;
  z-index: 41;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(88dvh, 720px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
  padding: var(--s-2) var(--s-4) calc(var(--s-6) + var(--safe-bottom));
  display: grid;
  gap: var(--s-3);
  animation: sheet-up var(--t-slow) var(--ease);
}
.sheet::before {
  content: "";
  justify-self: center;
  width: 40px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--border-strong);
  margin-bottom: var(--s-2);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}
@media (min-width: 900px) {
  .sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: min(560px, calc(100vw - 48px));
    transform: translate(-50%, -50%);
    border-radius: var(--r-sheet);
    padding-bottom: var(--s-6);
    animation: fade-in var(--t) var(--ease);
  }
  .sheet::before {
    display: none;
  }
}

/* ---------- toast ---------- */
.toast-host {
  position: fixed;
  z-index: 60;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--bar-h) + var(--s-4) + var(--safe-bottom));
  display: grid;
  gap: var(--s-2);
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  border-radius: var(--r-input);
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  display: flex;
  gap: var(--s-2);
  align-items: center;
  animation: sheet-up var(--t) var(--ease);
  pointer-events: auto;
}
.toast.danger {
  background: var(--danger-fill);
  color: var(--on-danger);
}
@media (min-width: 900px) {
  .toast-host {
    bottom: var(--s-6);
  }
}

/* ---------- empty state ---------- */
.empty-state {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: var(--s-2);
  padding: var(--s-8) var(--s-4);
  color: var(--text-muted);
}
.empty-state .empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  margin-bottom: var(--s-1);
}
.empty-state strong {
  color: var(--text);
  font-size: var(--fs-md);
}
.empty-state p {
  max-width: 36ch;
  font-size: var(--fs-sm);
}

/* ---------- skeleton loader ---------- */
.skeleton {
  display: block;
  border-radius: var(--r-input);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  min-height: 16px;
}
.skeleton.block {
  height: 64px;
  border-radius: var(--r-card);
}
.skeleton-list {
  display: grid;
  gap: var(--s-2);
}

/* ---------- progress steps ---------- */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--s-1);
  counter-reset: step;
}
.steps li {
  flex: 1;
  display: grid;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  counter-increment: step;
}
.steps li::before {
  content: "";
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
}
.steps li.done::before,
.steps li.current::before {
  background: var(--accent);
}
.steps li.current {
  color: var(--text);
  font-weight: var(--fw-bold);
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes sheet-up {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0ms !important;
  }
}

/* ---------- 0.8 ORBIT additions ---------- */
/* Outcome chip with a dot (status never by colour alone: the word is always there). */
.badge.dot::before,
.chip.dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge.info,
.chip.info {
  --tone: var(--info);
  --tone-soft: var(--info-soft);
  background: var(--tone-soft);
  color: var(--tone);
  font-weight: var(--fw-medium);
}
.badge {
  font-weight: var(--fw-bold);
  font-size: var(--fs-2xs);
  padding: 4px 10px;
}
/* Simulation label: a dashed outline beside every simulated action (blueprint 08). */
.sim-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 1px dashed var(--sim-border);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  background: transparent;
}
.sim-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-input);
  border: 1px dashed var(--sim-border);
  font-size: var(--fs-xs);
  color: var(--text);
}
.sim-note svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--text-muted);
}
/* Status pill (Assistant on/off, connection state): 32 px tall, dot + words. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.pill.success {
  color: var(--success);
  background: var(--success-soft);
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
}
.pill.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
}
.pill.sim {
  border-style: dashed;
  border-color: var(--sim-border);
  background: transparent;
  font-weight: var(--fw-medium);
}
.pill.sim::before {
  background: var(--text-muted);
}
button.pill {
  min-height: var(--tap);
}
/* Avatar initials (calls, account button). */
.initials {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
}
.segmented {
  border-radius: var(--r-input);
  padding: 4px;
  gap: 4px;
}
.segmented button {
  border-radius: 10px;
}

/* ---------- Orb (ds/orb.js) ---------- */
.orb {
  --orb-size: 96px;
  display: inline-block;
  width: var(--orb-size);
  height: var(--orb-size);
  line-height: 0;
  flex: none;
  transition: opacity var(--t-slow) var(--ease);
}
.orb svg {
  overflow: visible;
}
.orb .orb-halo,
.orb .orb-drift,
.orb .orb-orbit,
.orb .orb-spin {
  transform-box: view-box;
  transform-origin: 256px 256px;
}
.orb .orb-halo {
  opacity: 0.7;
  animation: orb-halo 6s ease-in-out infinite;
}
.orb .orb-drift {
  animation: orb-drift 9s ease-in-out infinite;
}
.orb .orb-orbit {
  transition: transform var(--t-slow) var(--ease);
}
.orb .orb-rim {
  opacity: 0.75;
  transition: opacity var(--t-slow) var(--ease), stroke-width var(--t-slow) var(--ease);
}
.orb .orb-travel {
  opacity: 0;
  animation: orb-travel 1.8s linear infinite;
}
.orb .orb-spark {
  opacity: 0;
}
.orb .orb-spin {
  animation: orb-turn 5s linear infinite;
}
/* listening: cyan rim brightens, orbit tightens */
.orb[data-state="listening"] .orb-halo {
  opacity: 0.85;
}
.orb[data-state="listening"] .orb-orbit {
  transform: scale(0.94);
}
.orb[data-state="listening"] .orb-rim {
  opacity: 1;
  stroke-width: 6;
}
/* thinking: the orbit turns, one spark */
.orb[data-state="thinking"] .orb-drift {
  animation: orb-turn 14s linear infinite;
}
.orb[data-state="thinking"] .orb-spark {
  opacity: 0.9;
}
/* speaking: light runs the ribbon (set only while her voice is playing) */
.orb[data-state="speaking"] .orb-halo {
  opacity: 1;
}
.orb[data-state="speaking"] .orb-travel {
  opacity: 0.95;
}
/* disconnected: dimmed and still; a text label always says so beside it */
.orb[data-state="disconnected"] {
  opacity: 0.45;
}
.orb[data-state="disconnected"] .orb-halo {
  opacity: 0.25;
}
.orb[data-state="disconnected"] .orb-flare {
  opacity: 0.3;
}
.orb[data-state="disconnected"] *,
.orb.static * {
  animation: none !important;
}
@keyframes orb-halo {
  50% {
    transform: scale(1.03);
  }
}
@keyframes orb-drift {
  0%,
  100% {
    transform: rotate(-3deg);
  }
  50% {
    transform: rotate(3deg);
  }
}
@keyframes orb-turn {
  to {
    transform: rotate(360deg);
  }
}
@keyframes orb-travel {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: -970;
  }
}
/* Reduced motion: static state variants (rim, spark, travel light still show the state). */
@media (prefers-reduced-motion: reduce) {
  .orb * {
    animation: none !important;
  }
  .orb[data-state="speaking"] .orb-travel {
    stroke-dashoffset: -300;
  }
}