/* ==========================================================================
   Frontline AI assistant — 1:1 port of the launcher surface
   (frontline-launcher/src/renderer/components/ai/ai-assistant.css).
   Tokens mirror the launcher shell: zinc surfaces on #0b0c10 with an orange
   accent, so the CRM widget and the launcher widget are the same product.
   Only the host section at the bottom is CRM-specific.
   ========================================================================== */

.ai,
.ai-fab,
.ai-page {
  --ai-bg: #0b0c10;
  --ai-surface: #101217;
  --ai-raised: #16181f;
  --ai-line: rgba(63, 63, 70, 0.55);
  --ai-line-soft: rgba(63, 63, 70, 0.32);
  --ai-text: #fafafa;
  --ai-muted: #a1a1aa;
  --ai-faint: #71717a;
  --ai-accent: #f97316;
  --ai-accent-soft: #fdba74;
  --ai-accent-wash: rgba(249, 115, 22, 0.1);
  --ai-accent-line: rgba(249, 115, 22, 0.24);
  --ai-ok: #34d399;
  --ai-warn: #fbbf24;
  --ai-bad: #fb7185;

  --ai-r-shell: 24px;
  --ai-r-panel: 20px;
  --ai-r-btn: 16px;
  --ai-r-sm: 12px;

  color: var(--ai-text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.ai *,
.ai-fab *,
.ai-page * {
  box-sizing: border-box;
}

/* React drops hidden branches from the tree; this port toggles [hidden]
   instead, and most of these blocks set their own display. */
.ai [hidden],
.ai-fab [hidden],
.ai-page [hidden] {
  display: none !important;
}

/* Zero-specificity reset so any single component class still wins. */
:where(.ai, .ai-fab, .ai-page) button {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  touch-action: manipulation;
}

:where(.ai, .ai-fab) button:not(:disabled) {
  cursor: pointer;
}

.ai :focus-visible,
.ai-fab :focus-visible,
.ai-page :focus-visible {
  outline: 2px solid var(--ai-accent);
  outline-offset: 2px;
}

.ai__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  margin: -1px;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ai__spin {
  animation: ai-spin 0.9s linear infinite;
}

@keyframes ai-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Robot mascot
   ========================================================================== */

.ai-robot {
  display: block;
  overflow: visible;
  --ai-robot-eye: var(--ai-accent-soft, #fdba74);
  --ai-robot-glow: var(--ai-accent, #f97316);
}

.ai-robot__face rect {
  fill: var(--ai-robot-eye);
}

.ai-robot__mouth {
  stroke: var(--ai-robot-eye);
  opacity: 0.5;
}

.ai-robot__bulb {
  fill: var(--ai-robot-glow);
}

.ai-robot__bulb-halo {
  fill: var(--ai-robot-glow);
  opacity: 0.16;
  /* Without fill-box the ping keyframe would scale about the SVG origin. */
  transform-box: fill-box;
  transform-origin: center;
}

.ai-robot__core {
  fill: var(--ai-robot-glow);
  opacity: 0.75;
}

.ai-robot__eyes,
.ai-robot__lids {
  transform-box: fill-box;
  transform-origin: center;
}

.ai-robot[data-state="offline"] {
  --ai-robot-eye: #52525b;
  --ai-robot-glow: #3f3f46;
}

.ai-robot[data-state="offline"] .ai-robot__lids {
  transform: scaleY(0.16);
}

.ai-robot[data-state="offline"] .ai-robot__mouth {
  opacity: 0.25;
}

.ai-robot[data-state="listening"] {
  --ai-robot-eye: #fed7aa;
}

.ai-robot[data-state="listening"] .ai-robot__bulb-halo {
  opacity: 0.32;
}

@media (prefers-reduced-motion: no-preference) {
  .ai-robot__rig {
    animation: ai-robot-float 5.4s ease-in-out infinite;
  }

  .ai-robot__lids {
    animation: ai-robot-blink 6.5s ease-in-out infinite;
  }

  .ai-robot[data-state="thinking"] .ai-robot__eyes {
    animation: ai-robot-scan 1.9s ease-in-out infinite;
  }

  .ai-robot[data-state="thinking"] .ai-robot__bulb,
  .ai-robot[data-state="listening"] .ai-robot__bulb {
    animation: ai-robot-pulse 1.2s ease-in-out infinite;
  }

  .ai-robot[data-state="listening"] .ai-robot__bulb-halo {
    animation: ai-robot-ping 1.2s ease-out infinite;
  }

  .ai-robot[data-state="offline"] .ai-robot__rig,
  .ai-robot[data-state="offline"] .ai-robot__lids {
    animation: none;
  }
}

@keyframes ai-robot-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2.5px); }
}

@keyframes ai-robot-blink {
  0%, 91%, 100% { transform: scaleY(1); }
  94%, 95.5% { transform: scaleY(0.12); }
}

@keyframes ai-robot-scan {
  0%, 100% { transform: translateX(-2.5px); }
  50% { transform: translateX(2.5px); }
}

@keyframes ai-robot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@keyframes ai-robot-ping {
  0% { transform: scale(0.6); opacity: 0.4; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ==========================================================================
   Panel shell
   ========================================================================== */

.ai {
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ai-line);
  background: var(--ai-bg);
  isolation: isolate;
}

.ai--popover {
  width: min(392px, calc(100vw - 32px));
  height: min(620px, calc(100dvh - 128px));
  border-radius: var(--ai-r-shell);
  box-shadow:
    0 32px 80px -32px rgba(0, 0, 0, 0.95),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

/* Sits in the CRM window shell, so it keeps the app's card treatment. */
.ai--page {
  width: 100%;
  min-height: 0;
  height: 100%;
  flex: 1 1 auto;
  border-radius: var(--ai-r-shell);
  box-shadow: 0 24px 60px -44px rgba(0, 0, 0, 0.85);
}

.ai__body {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.ai__conversation {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
}

.ai__sidebar {
  display: flex;
  width: 236px;
  min-width: 236px;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  padding: 14px 12px 12px;
  border-right: 1px solid var(--ai-line-soft);
  background: #0d0f14;
}

.ai__new-chat {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--ai-accent-line);
  border-radius: var(--ai-r-sm);
  background: var(--ai-accent-wash);
  color: var(--ai-accent-soft);
  font-size: 12.5px;
  font-weight: 600;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.ai__new-chat:hover:not(:disabled) {
  border-color: rgba(249, 115, 22, 0.48);
  background: rgba(249, 115, 22, 0.16);
}

.ai__new-chat:disabled,
.ai__history-select:disabled,
.ai__history-delete:disabled,
.ai__clear-history:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ai__quota-card {
  padding: 11px 12px 10px;
  border: 1px solid var(--ai-line-soft);
  border-radius: var(--ai-r-sm);
  background: var(--ai-surface);
}

.ai__quota-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai__quota-plan {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ai-accent-soft);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.ai__quota-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ai-faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ai__quota-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 7px 0 0;
}

.ai__quota-value strong {
  color: var(--ai-text);
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.ai__quota-value span {
  color: var(--ai-faint);
  font-size: 11px;
}

.ai__quota-card[data-empty] .ai__quota-value strong,
.ai__quota-card[data-empty] .ai__quota-value span {
  color: var(--ai-bad);
}

.ai__quota-track {
  height: 5px;
  margin: 9px 0 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--ai-raised);
}

.ai__quota-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ai-accent), #fb923c);
  transition: width 0.24s ease;
}

.ai__quota-card[data-empty] .ai__quota-track > span {
  background: var(--ai-bad);
}

.ai__quota-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  margin: 0;
  color: var(--ai-muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.ai__quota-reset {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ai-faint);
}

.ai__history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  color: var(--ai-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ai__history-head > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ai__history-head small {
  display: grid;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--ai-raised);
  color: var(--ai-faint);
  font-size: 10px;
  place-items: center;
}

.ai__history-list {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--ai-line) transparent;
  scrollbar-width: thin;
}

.ai__history-empty {
  padding: 14px 10px;
  margin: 0;
  color: var(--ai-faint);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

.ai__history-item {
  position: relative;
  display: flex;
  min-height: 48px;
  align-items: stretch;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.ai__history-item:hover {
  background: var(--ai-raised);
}

.ai__history-item[data-active] {
  border-color: var(--ai-accent-line);
  background: var(--ai-accent-wash);
}

.ai__history-select {
  display: flex;
  min-width: 0;
  min-height: 46px;
  flex: 1 1 auto;
  align-items: center;
  gap: 9px;
  padding: 7px 34px 7px 9px;
  text-align: left;
}

.ai__history-select > svg {
  flex: 0 0 auto;
  color: var(--ai-faint);
}

.ai__history-item[data-active] .ai__history-select > svg {
  color: var(--ai-accent-soft);
}

.ai__history-select > span {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
}

.ai__history-select strong {
  overflow: hidden;
  color: var(--ai-text);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai__history-select small {
  color: var(--ai-faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.ai__history-delete {
  position: absolute;
  top: 6px;
  right: 4px;
  display: grid;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--ai-faint);
  opacity: 0.55;
  place-items: center;
  transition: background-color 0.16s ease, color 0.16s ease, opacity 0.16s ease;
}

.ai__history-delete:hover:not(:disabled),
.ai__history-delete:focus-visible {
  background: rgba(244, 63, 94, 0.1);
  color: var(--ai-bad);
  opacity: 1;
}

.ai__clear-history {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 10px;
  color: var(--ai-faint);
  font-size: 11px;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.ai__clear-history:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.08);
  color: var(--ai-bad);
}

.ai__sidebar-scrim {
  display: none;
}

.ai--popover .ai__sidebar,
.ai--page .ai__sidebar {
  z-index: 22;
}

.ai--popover .ai__sidebar {
  position: absolute;
  inset: 0 auto 0 0;
  width: min(82%, 286px);
  min-width: min(82%, 286px);
  box-shadow: 24px 0 48px -30px rgba(0, 0, 0, 0.95);
  transform: translateX(-104%);
  visibility: hidden;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.22s;
}

.ai--popover .ai__sidebar[data-open] {
  transform: none;
  visibility: visible;
}

.ai--popover .ai__sidebar-scrim[data-open] {
  position: absolute;
  z-index: 21;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.58);
}

@media (min-width: 700px) {
  .ai--page .ai__sidebar-toggle {
    display: none;
  }
}

@media (max-width: 699px) {
  .ai--page .ai__sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(82%, 286px);
    min-width: min(82%, 286px);
    box-shadow: 24px 0 48px -30px rgba(0, 0, 0, 0.95);
    transform: translateX(-104%);
    visibility: hidden;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.22s;
  }

  .ai--page .ai__sidebar[data-open] {
    transform: none;
    visibility: visible;
  }

  .ai--page .ai__sidebar-scrim[data-open] {
    position: absolute;
    z-index: 21;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.58);
  }
}

/* --- top bar --------------------------------------------------------- */

.ai__bar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 11px;
  padding: 11px 12px 11px 13px;
  border-bottom: 1px solid var(--ai-line-soft);
  background: var(--ai-surface);
}

.ai__avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid var(--ai-accent-line);
  border-radius: var(--ai-r-btn);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(249, 115, 22, 0.14), transparent 62%),
    var(--ai-raised);
  place-items: center;
}

.ai__identity {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
}

.ai__name {
  overflow: hidden;
  color: var(--ai-text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ai-muted);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.2;
}

.ai__dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--ai-ok);
}

.ai__status[data-tone="busy"] .ai__dot,
.ai__status[data-tone="live"] .ai__dot {
  background: var(--ai-accent);
}

.ai__status[data-tone="off"] .ai__dot {
  background: var(--ai-faint);
}

.ai__status[data-tone="warn"] .ai__dot {
  background: var(--ai-warn);
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.45);
}

@media (prefers-reduced-motion: no-preference) {
  .ai__status[data-tone="live"] .ai__dot {
    animation: ai-robot-pulse 1.1s ease-in-out infinite;
  }
}

.ai__tools {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
}

.ai__plan {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  margin-right: 3px;
  color: var(--ai-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.ai__plan[data-blocked] {
  border-color: rgba(244, 63, 94, 0.28);
  background: rgba(244, 63, 94, 0.08);
  color: var(--ai-bad);
}

.ai__icon-btn {
  display: grid;
  width: 32px;
  height: 32px;
  border-radius: var(--ai-r-sm);
  color: var(--ai-muted);
  place-items: center;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.ai__icon-btn:hover:not(:disabled) {
  background: var(--ai-raised);
  color: var(--ai-text);
}

.ai__icon-btn:disabled {
  opacity: 0.5;
}

/* --- message log ----------------------------------------------------- */

.ai__log {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  padding: 16px 14px 8px;
  gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--ai-line) transparent;
  scrollbar-width: thin;
}

.ai__log::-webkit-scrollbar {
  width: 8px;
}

.ai__log::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--ai-line);
  background-clip: content-box;
}

.ai__hero {
  display: grid;
  width: min(100%, 300px);
  padding: 6px 0 2px;
  /* Auto top margin pairs with the one on .ai__suggestions: the spare height in
     an empty conversation splits instead of pooling above the chips. */
  margin: auto auto 0;
  background: radial-gradient(52% 60% at 50% 58%, rgba(249, 115, 22, 0.1), transparent 72%);
  place-items: center;
}

/* The popover trades the bust for headroom — the talk button is the hero there,
   and the bar already carries the robot. */
.ai--popover .ai__hero {
  display: none;
}

.ai__msg {
  display: flex;
  max-width: 100%;
  flex-direction: column;
  gap: 5px;
}

.ai__msg--user {
  align-items: flex-end;
}

.ai__bubble {
  display: flex;
  max-width: 100%;
  align-items: flex-start;
  gap: 8px;
}

/* Direct child only: user and error text is literal, so it keeps its own line
   breaks. Assistant copy goes through .ai__md below. */
.ai__bubble > p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ai__msg--assistant .ai__bubble {
  color: #e4e4e7;
}

.ai__msg--user .ai__bubble {
  max-width: 86%;
  padding: 9px 13px;
  border: 1px solid var(--ai-accent-line);
  border-radius: var(--ai-r-btn);
  background: var(--ai-accent-wash);
  color: #fff1e5;
}

.ai__msg--error .ai__bubble {
  padding: 9px 12px;
  border: 1px solid rgba(244, 63, 94, 0.24);
  border-radius: var(--ai-r-btn);
  background: rgba(244, 63, 94, 0.08);
  color: #fecdd3;
}

.ai__msg--error .ai__bubble svg {
  flex: 0 0 auto;
  margin-top: 2px;
}

.ai__msg[data-pending] .ai__bubble {
  opacity: 0.65;
}

/* --- assistant copy --------------------------------------------------- */

.ai__md {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 9px;
  font-size: 13.5px;
  line-height: 1.55;
}

.ai__md .ai__md-p {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ai__msg-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ai-faint);
  font-size: 10.5px;
  line-height: 1.3;
}

.ai__msg-meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ai__msg-time {
  opacity: 0;
  transition: opacity 0.16s ease;
}

.ai__msg:hover .ai__msg-time,
.ai__msg[data-pending] .ai__msg-time {
  opacity: 1;
}

/* --- action results -------------------------------------------------- */

.ai__actions {
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 2px 0 0;
  gap: 6px;
  list-style: none;
}

.ai__action {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--ai-line-soft);
  border-radius: var(--ai-r-sm);
  background: var(--ai-surface);
}

.ai__action-icon {
  display: flex;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--ai-muted);
}

.ai__action[data-status="success"] .ai__action-icon { color: var(--ai-ok); }
.ai__action[data-status="error"] .ai__action-icon { color: var(--ai-bad); }
.ai__action[data-status="warning"] .ai__action-icon { color: var(--ai-warn); }

.ai__action[data-status="error"] {
  border-color: rgba(244, 63, 94, 0.22);
}

.ai__action[data-status="warning"] {
  border-color: rgba(251, 191, 36, 0.22);
}

.ai__action-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.ai__action-copy strong {
  color: var(--ai-text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
}

.ai__action-copy small {
  color: var(--ai-muted);
  font-size: 11.5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.ai__confirm {
  align-self: flex-start;
  padding: 9px 15px;
  border-radius: var(--ai-r-btn);
  margin-top: 4px;
  background: var(--ai-accent);
  color: #18120b;
  font-size: 12.5px;
  font-weight: 700;
  transition: background-color 0.16s ease, transform 0.16s ease;
}

.ai__confirm:hover:not(:disabled) {
  background: #fb923c;
}

.ai__confirm:active:not(:disabled) {
  transform: scale(0.985);
}

.ai__confirm:disabled {
  background: var(--ai-raised);
  color: var(--ai-faint);
}

/* --- support extras: sources, buttons, handoff, feedback --------------- */

.ai__support {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.ai__sources {
  margin: 0;
  color: var(--ai-faint);
  font-size: 11px;
  line-height: 1.4;
}

.ai__sources span {
  color: var(--ai-muted);
}

.ai__support-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai__support-btn {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--ai-line);
  border-radius: var(--ai-r-sm);
  color: var(--ai-text);
  font-size: 12px;
  font-weight: 600;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.ai__support-btn:hover:not(:disabled) {
  border-color: var(--ai-accent-line);
  background: var(--ai-accent-wash);
}

.ai__support-btn:disabled {
  color: var(--ai-faint);
}

.ai__handoff {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid var(--ai-line-soft);
  border-radius: var(--ai-r-sm);
  background: var(--ai-surface);
}

.ai__handoff-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--ai-text);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.3;
}

.ai__handoff-summary {
  margin: 0;
  color: var(--ai-muted);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ai__handoff-status {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  color: var(--ai-faint);
  font-size: 11px;
  line-height: 1.4;
}

.ai__handoff-status svg {
  flex: none;
  margin-top: 1px;
}

.ai__handoff-status[data-tone="ok"] { color: var(--ai-ok); }
.ai__handoff-status[data-tone="bad"] { color: var(--ai-bad); }

.ai__feedback {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 22px;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.ai__msg:hover .ai__feedback,
.ai__feedback:focus-within {
  opacity: 1;
}

@media (hover: none) {
  .ai__feedback {
    opacity: 1;
  }
}

.ai__feedback-btn {
  display: inline-flex;
  padding: 4px;
  border-radius: 8px;
  color: var(--ai-faint);
  transition: color 0.16s ease, background-color 0.16s ease;
}

.ai__feedback-btn:hover {
  background: var(--ai-raised);
  color: var(--ai-text);
}

.ai__feedback-note {
  color: var(--ai-faint);
  font-size: 10.5px;
}

/* --- typing indicator ------------------------------------------------ */

.ai__typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0;
}

.ai__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ai-accent);
  opacity: 0.45;
}

@media (prefers-reduced-motion: no-preference) {
  .ai__typing span {
    animation: ai-typing 1.1s ease-in-out infinite;
  }

  .ai__typing span:nth-child(2) { animation-delay: 0.15s; }
  .ai__typing span:nth-child(3) { animation-delay: 0.3s; }
}

@keyframes ai-typing {
  0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* --- suggestions ----------------------------------------------------- */

.ai__suggestions {
  margin-top: auto;
  padding-top: 8px;
}

.ai__suggestions-label {
  margin: 0 0 8px;
  color: var(--ai-faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ai__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ai__trust {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 12px 0 0;
  color: var(--ai-faint);
  font-size: 10.5px;
  line-height: 1.4;
}

.ai__trust svg {
  flex: 0 0 auto;
}

/* Always-visible reminder that answers come from a model. Sits under the
   composer so it stays on screen once the greeting scrolls away. */
.ai__disclaimer {
  margin: 9px 0 0;
  color: var(--ai-faint);
  font-size: 10.5px;
  line-height: 1.4;
  text-align: center;
}

.ai__chip {
  padding: 7px 13px;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  background: var(--ai-surface);
  color: var(--ai-muted);
  font-size: 12px;
  font-weight: 500;
  transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease;
}

.ai__chip:hover:not(:disabled) {
  border-color: var(--ai-accent-line);
  background: var(--ai-accent-wash);
  color: var(--ai-accent-soft);
}

.ai__chip:disabled {
  opacity: 0.45;
}

/* --- notices --------------------------------------------------------- */

.ai__notice {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--ai-line);
  border-radius: var(--ai-r-panel);
  margin: 0 14px 10px;
  background: var(--ai-surface);
}

.ai__notice[hidden] {
  display: none;
}

.ai__notice[data-tone="block"] {
  border-color: rgba(244, 63, 94, 0.24);
  background: rgba(244, 63, 94, 0.07);
  color: #fecdd3;
}

.ai__notice[data-tone="warn"] {
  border-color: rgba(251, 191, 36, 0.24);
  background: rgba(251, 191, 36, 0.07);
  color: #fde68a;
}

.ai__notice > svg {
  flex: 0 0 auto;
  margin-top: 1px;
}

.ai__notice-copy {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  line-height: 1.45;
}

.ai__notice-copy strong {
  font-size: 12.5px;
  font-weight: 700;
}

.ai__notice-copy strong[hidden],
.ai__notice-action[hidden] {
  display: none;
}

.ai__notice-copy span {
  opacity: 0.82;
}

.ai__notice-action {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border: 1px solid currentcolor;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  opacity: 0.9;
}

.ai__notice[data-region="true"] {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
}
.ai__notice[data-region="true"][hidden] { display: none; }
.ai__notice[data-region="true"] .ai__notice-action {
  grid-column: 2;
  justify-self: start;
  min-height: 40px;
  margin-left: 0;
}

@media (max-width: 480px) {
  .ai__notice { flex-wrap: wrap; }
  .ai__notice-copy { flex-basis: calc(100% - 32px); }
  .ai__notice-action { margin-left: 26px; min-height: 40px; }
}

.ai__notice-close {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 8px;
  opacity: 0.7;
  place-items: center;
}

.ai__notice-close:hover {
  opacity: 1;
}

/* --- composer -------------------------------------------------------- */

.ai__composer {
  flex: 0 0 auto;
  padding: 10px 14px 13px;
  border-top: 1px solid var(--ai-line-soft);
  background: var(--ai-surface);
}

.ai__composer[hidden] {
  display: none;
}

/* --- voice mode (primary) -------------------------------------------- */

.ai__composer--voice {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 14px 13px;
  gap: 2px;
}

.ai__ptt {
  position: relative;
  display: grid;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--ai-raised);
  box-shadow: 0 14px 32px -18px rgba(0, 0, 0, 0.95);
  color: var(--ai-accent-soft);
  place-items: center;
  transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), color 0.16s ease,
    background-color 0.16s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.ai__ptt:hover:not(:disabled) {
  background: #1c1f28;
  color: var(--ai-accent);
}

.ai__ptt[data-recording] {
  background: var(--ai-accent);
  color: #18120b;
}

.ai__ptt:active:not(:disabled) {
  transform: scale(0.96);
}

/* The panel parks focus here on open, so the ring has to read as "armed for
   Space" — :focus-visible alone would stay invisible after a programmatic focus. */
.ai__ptt:focus:not(:disabled) {
  box-shadow:
    0 14px 32px -18px rgba(0, 0, 0, 0.95),
    0 0 0 3px rgba(249, 115, 22, 0.2);
  outline: none;
}

.ai__ptt:focus-visible:not(:disabled) {
  box-shadow:
    0 14px 32px -18px rgba(0, 0, 0, 0.95),
    0 0 0 3px rgba(249, 115, 22, 0.6);
}

.ai__ptt:disabled {
  background: var(--ai-raised);
  color: var(--ai-faint);
}

/* Halo grows with live microphone loudness, so a silent mic is obvious. It has
   to live outside the button — while recording the fill is already accent. */
.ai__ptt[data-recording]:not(:disabled) {
  box-shadow:
    0 0 0 calc(3px + var(--ai-level, 0) * 13px) rgba(249, 115, 22, 0.22),
    0 14px 32px -18px rgba(0, 0, 0, 0.95);
  transition: box-shadow 90ms linear;
}

.ai__ptt-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}

.ai__ptt-track {
  fill: none;
  stroke: var(--ai-line);
  stroke-width: 2.5;
}

.ai__ptt-progress {
  fill: none;
  stroke: var(--ai-accent-soft);
  stroke-linecap: round;
  stroke-width: 2.5;
  transition: stroke-dashoffset 120ms linear;
}

.ai__ptt[data-recording] .ai__ptt-track {
  stroke: rgba(24, 18, 11, 0.28);
}

.ai__ptt[data-recording] .ai__ptt-progress {
  stroke: #18120b;
  stroke-width: 3.4;
}

.ai__ptt-icon {
  display: grid;
  place-items: center;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .ai__ptt:not([data-recording]):not([data-busy]):not(:disabled) .ai__ptt-track {
    animation: ai-ptt-breathe 3.4s ease-in-out infinite;
  }
}

@keyframes ai-ptt-breathe {
  0%, 100% { stroke: var(--ai-line); }
  50% { stroke: var(--ai-accent-line); }
}

.ai__voice-title {
  margin: 10px 0 0;
  color: var(--ai-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

.ai__voice-hint {
  margin: 3px 0 0;
  color: var(--ai-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  text-align: center;
}

.ai__voice-hint[hidden] {
  display: none;
}

.ai__mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  margin-top: 9px;
  color: var(--ai-muted);
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.ai__mode:hover:not(:disabled) {
  background: var(--ai-raised);
  color: var(--ai-text);
}

.ai__mode:disabled {
  opacity: 0.4;
}

.ai__mode[data-promoted] {
  padding: 8px 16px;
  border: 1px solid var(--ai-accent-line);
  background: var(--ai-accent-wash);
  color: var(--ai-accent-soft);
  font-weight: 600;
}

.ai__mode[data-promoted]:hover:not(:disabled) {
  border-color: rgba(249, 115, 22, 0.48);
  background: rgba(249, 115, 22, 0.16);
  color: var(--ai-accent-soft);
}

.ai__mode--inline {
  padding: 0 10px;
  border: 1px solid var(--ai-line);
  margin-top: 0;
  margin-right: 2px;
  color: var(--ai-accent-soft);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 32px;
}

.ai__mode--inline:hover:not(:disabled) {
  border-color: var(--ai-accent-line);
  background: var(--ai-accent-wash);
  color: var(--ai-accent-soft);
}

.ai__field {
  padding: 9px 9px 9px 13px;
  border: 1px solid var(--ai-line);
  border-radius: var(--ai-r-panel);
  background: var(--ai-bg);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.ai__field:focus-within {
  border-color: var(--ai-accent-line);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.09);
}

.ai__field textarea {
  display: block;
  width: 100%;
  max-height: 132px;
  min-height: 22px;
  padding: 0;
  border: 0;
  margin: 0;
  background: none;
  color: var(--ai-text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: none;
}

.ai__field textarea::placeholder {
  color: var(--ai-faint);
}

/* The field draws the focus ring. Without box-shadow: none, the CRM-wide
   :where(.crm-page textarea:focus) ring lands on the textarea too, a box with
   no side padding, and the text ends up pressed against it. */
.ai__field textarea:focus {
  outline: none;
  box-shadow: none;
}

.ai__field textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.ai__field-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 7px;
}

.ai__counter {
  margin-right: auto;
  color: var(--ai-faint);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.ai__send {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: var(--ai-r-sm);
  background: var(--ai-accent);
  color: #18120b;
  place-items: center;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.14s ease;
}

.ai__send:hover:not(:disabled) {
  background: #fb923c;
}

.ai__send:active:not(:disabled) {
  transform: scale(0.94);
}

.ai__send:disabled {
  cursor: not-allowed;
  background: var(--ai-raised);
  color: var(--ai-faint);
}

/* ==========================================================================
   Floating trigger
   ========================================================================== */

/* Above CRM page chrome and banners, below CRM modals (z-index 200+) so a
   dialog is never covered by the assistant. */
.ai-fab {
  position: fixed;
  z-index: 189;
  right: 20px;
  bottom: 20px;
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 10px;
}

.ai-fab[hidden] {
  display: none;
}

.ai-fab__panel {
  position: fixed;
  z-index: 190;
  right: 20px;
  bottom: 92px;
}

.ai-fab__panel[hidden] {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .ai-fab__panel {
    animation: ai-fab-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

@keyframes ai-fab-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.ai-fab__hint {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 8px 7px 14px;
  border: 1px solid var(--ai-line);
  border-radius: 999px;
  background: var(--ai-surface);
  box-shadow: 0 18px 40px -26px rgba(0, 0, 0, 0.95);
  color: var(--ai-muted);
  font-size: 12px;
  white-space: nowrap;
}

.ai-fab__hint[hidden] {
  display: none;
}

.ai-fab__hint-open {
  color: inherit;
  font: inherit;
}

.ai-fab__hint-open:hover {
  color: var(--ai-text);
}

.ai-fab__hint-close {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  color: var(--ai-faint);
  place-items: center;
}

.ai-fab__hint-close:hover {
  background: var(--ai-raised);
  color: var(--ai-text);
}

.ai-fab__btn {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  border: 1px solid var(--ai-accent-line);
  border-radius: 50%;
  background:
    radial-gradient(120% 110% at 50% 6%, rgba(249, 115, 22, 0.2), transparent 64%),
    var(--ai-surface);
  box-shadow:
    0 20px 44px -20px rgba(0, 0, 0, 0.95),
    0 0 22px -8px rgba(249, 115, 22, 0.4);
  place-items: center;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.18s ease;
}

.ai-fab__btn:hover {
  border-color: rgba(249, 115, 22, 0.5);
  transform: translateY(-2px);
}

.ai-fab__btn:active {
  transform: scale(0.96);
}

.ai-fab__btn .ai-robot {
  margin-top: 2px;
}

.ai-fab__btn--open {
  color: var(--ai-muted);
}

.ai-fab__badge {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--ai-bg);
  border-radius: 50%;
  background: var(--ai-ok);
}

.ai-fab__badge[hidden] {
  display: none;
}

/* ==========================================================================
   Standalone window
   ========================================================================== */

/* The assistant window fills the CRM viewport as one tall card. */
.ai-page {
  display: flex;
  height: 100%;
  min-height: 520px;
  flex-direction: column;
}

/* The sidebar already shows plan and quota in full once it is docked. */
@media (min-width: 700px) {
  .ai--page .ai__bar .ai__plan {
    display: none;
  }
}

/* Keep a comfortable reading column when the window is maximised. The max()
   collapses to the normal gutter as soon as the chat area is narrower. */
.ai--page .ai__log,
.ai--page .ai__composer {
  padding-inline: max(14px, calc((100% - 720px) / 2));
}

.ai--page .ai__notice {
  margin-inline: max(14px, calc((100% - 720px) / 2));
}

/* ==========================================================================
   Compact heights — the CRM window can be as short as 600px
   ========================================================================== */

@media (max-height: 745px) {
  .ai--popover {
    height: min(620px, calc(100dvh - 112px));
  }

  .ai-fab__panel {
    bottom: 86px;
  }

  /* Compact the talk column so the greeting and chips stay above the fold.
     Applies to the standalone window too — its minimum height is 600px. */
  .ai__composer--voice {
    padding: 10px 14px 11px;
  }

  .ai__ptt {
    width: 64px;
    height: 64px;
  }

  .ai__voice-title {
    margin-top: 8px;
  }

  .ai__mode {
    margin-top: 6px;
  }

  .ai__trust {
    display: none;
  }
}

/* ==========================================================================
   CRM host — the only part with no launcher counterpart. The launcher opens
   the full assistant as a route; the CRM has no router, so the same .ai--page
   panel is hosted in a modal window instead.
   ========================================================================== */

.crm-ai-trigger {
  position: relative;
  gap: 7px;
}

.crm-ai-trigger > svg {
  color: var(--crm-accent-2);
}

.crm-ai-trigger::after {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--crm-accent-2);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.7);
}

.ai-window {
  position: fixed;
  z-index: 191;
  top: var(--crm-system-banner-h, 0px);
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  padding: clamp(0px, 3vh, 34px) clamp(0px, 3vw, 46px);
  background: rgba(3, 6, 11, 0.72);
  backdrop-filter: blur(3px);
}

.ai-window[hidden] {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .ai-window {
    animation: ai-window-in 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

@keyframes ai-window-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ai-window .ai-page {
  width: min(1180px, 100%);
  min-height: 0;
  margin: auto;
}

@media (prefers-reduced-motion: no-preference) {
  .ai-window .ai-page {
    animation: ai-window-card-in 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

@keyframes ai-window-card-in {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

body.crm-ai-window-open {
  overflow: hidden;
}

@media (max-width: 1180px) {
  .crm-ai-trigger .crm-topbar-btn-label {
    display: none;
  }
}

@media (max-width: 640px) {
  .ai-fab {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
  }

  .ai-fab__panel {
    right: 14px;
    bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .ai-window {
    padding: 0;
  }

  .ai-window .ai-page {
    min-height: 100%;
    border-radius: 0;
  }

  .ai-window .ai--page {
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai-fab__panel,
  .ai-window,
  .ai-window .ai-page {
    animation: none !important;
  }
}

/* ==========================================================================
   Intelligence level and the input dock.
   The level recolors Flynn's eye and the composer, so the choice stays visible
   wherever the operator is looking.
   ========================================================================== */

.ai,
.ai-fab {
  --ai-tier: var(--ai-accent);
  --ai-tier-soft: var(--ai-accent-soft);
  --ai-tier-wash: rgba(249, 115, 22, 0.13);
  --ai-tier-line: rgba(249, 115, 22, 0.42);
  --ai-tier-ring: rgba(249, 115, 22, 0.1);
}

.ai[data-intelligence="simple"],
.ai-fab[data-intelligence="simple"] {
  --ai-tier: #22d3ee;
  --ai-tier-soft: #a5f3fc;
  --ai-tier-wash: rgba(34, 211, 238, 0.11);
  --ai-tier-line: rgba(34, 211, 238, 0.4);
  --ai-tier-ring: rgba(34, 211, 238, 0.1);
}

.ai[data-intelligence="smart"],
.ai-fab[data-intelligence="smart"] {
  --ai-tier: #facc15;
  --ai-tier-soft: #fef08a;
  --ai-tier-wash: rgba(250, 204, 21, 0.12);
  --ai-tier-line: rgba(250, 204, 21, 0.46);
  --ai-tier-ring: rgba(250, 204, 21, 0.11);
}

.ai .ai-robot,
.ai-fab .ai-robot {
  --ai-robot-eye: var(--ai-tier-soft);
  --ai-robot-glow: var(--ai-tier);
}

.ai__dock {
  flex: 0 0 auto;
  padding-top: 10px;
  border-top: 1px solid var(--ai-line-soft);
  background: var(--ai-surface);
}

.ai__dock .ai__composer {
  padding-top: 8px;
  border-top: 0;
}

.ai__levels {
  position: relative;
  display: grid;
  padding: 3px;
  border: 1px solid var(--ai-line-soft);
  border-radius: 15px;
  margin: 0 14px;
  background: var(--ai-bg);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ai--page .ai__levels {
  margin-inline: max(14px, calc((100% - 720px) / 2));
}

/* The thumb is one element that travels, not a state on each button. */
.ai__levels-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 3);
  border: 1px solid var(--ai-tier-line);
  border-radius: 12px;
  background: var(--ai-tier-wash);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.2s ease,
    border-color 0.2s ease;
}

.ai[data-intelligence="standard"] .ai__levels-thumb { transform: translateX(100%); }
.ai[data-intelligence="smart"] .ai__levels-thumb { transform: translateX(200%); }

.ai__level {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 42px;
  align-items: center;
  padding: 4px 9px;
  border-radius: 12px;
  color: var(--ai-muted);
  column-gap: 8px;
  grid-template-columns: auto minmax(0, 1fr);
  text-align: left;
  transition: color 0.16s ease;
}

.ai__level:hover:not(:disabled):not([aria-checked="true"]) {
  color: var(--ai-text);
}

.ai__level[aria-checked="true"] {
  color: var(--ai-text);
}

.ai__level:disabled {
  cursor: not-allowed;
}

.ai__level:disabled:not([aria-checked="true"]) {
  opacity: 0.45;
}

.ai__level-bars {
  display: flex;
  height: 16px;
  align-items: flex-end;
  gap: 2px;
  grid-row: span 2;
}

.ai__level-bars i {
  width: 3px;
  border-radius: 2px;
  background: var(--ai-line);
  transition: background-color 0.2s ease;
}

.ai__level-bars i:nth-child(1) { height: 6px; }
.ai__level-bars i:nth-child(2) { height: 11px; }
.ai__level-bars i:nth-child(3) { height: 16px; }

.ai__level[data-rank="1"] .ai__level-bars i:nth-child(-n + 1),
.ai__level[data-rank="2"] .ai__level-bars i:nth-child(-n + 2),
.ai__level[data-rank="3"] .ai__level-bars i:nth-child(-n + 3) {
  background: var(--ai-faint);
}

.ai__level[aria-checked="true"][data-rank="1"] .ai__level-bars i:nth-child(-n + 1),
.ai__level[aria-checked="true"][data-rank="2"] .ai__level-bars i:nth-child(-n + 2),
.ai__level[aria-checked="true"][data-rank="3"] .ai__level-bars i:nth-child(-n + 3) {
  background: var(--ai-tier);
}

.ai__level-name {
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai__level-cost {
  overflow: hidden;
  color: var(--ai-faint);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai__level[aria-checked="true"] .ai__level-cost {
  color: var(--ai-tier-soft);
}

/* --- text: one line, controls beside the field ------------------------- */

.ai__field {
  display: flex;
  align-items: flex-end;
  padding: 6px 6px 6px 13px;
  gap: 6px;
}

.ai__field:focus-within {
  border-color: var(--ai-tier-line);
  box-shadow: 0 0 0 3px var(--ai-tier-ring);
}

.ai__field textarea {
  width: auto;
  min-width: 0;
  flex: 1 1 auto;
  padding: 6px 0;
}

.ai__field-row {
  flex: 0 0 auto;
  margin-top: 0;
}

.ai__counter {
  margin-right: 2px;
}

.ai__mode--inline {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: transparent;
  margin: 0;
  color: var(--ai-muted);
  line-height: 0;
  place-items: center;
}

.ai__mode--inline:hover:not(:disabled) {
  border-color: var(--ai-line);
  background: var(--ai-raised);
  color: var(--ai-text);
}

.ai__send {
  background: var(--ai-tier);
}

.ai__send:hover:not(:disabled) {
  background: var(--ai-tier-soft);
}

/* --- voice: a row, so the conversation keeps the height ---------------- */

.ai__composer--voice {
  display: grid;
  align-items: center;
  column-gap: 12px;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  row-gap: 1px;
  text-align: left;
}

.ai__composer--voice .ai__ptt {
  width: 52px;
  height: 52px;
  grid-row: 1 / span 2;
}

.ai__composer--voice .ai__ptt-icon svg {
  width: 20px;
  height: 20px;
}

.ai__composer--voice .ai__voice-title {
  align-self: end;
  margin: 0;
  grid-column: 2;
  text-align: left;
}

.ai__composer--voice .ai__voice-hint {
  align-self: start;
  margin: 0;
  grid-column: 2;
  text-align: left;
}

.ai__composer--voice .ai__mode {
  margin: 0;
  grid-column: 3;
  grid-row: 1 / span 2;
}

.ai__composer--voice .ai__disclaimer {
  margin-top: 8px;
  grid-column: 1 / -1;
}

/* --- the conversation --------------------------------------------------- */

/* Ratings stay out of the way until the reply is being read. */
.ai__msg .ai__feedback {
  opacity: 0;
  transition: opacity 0.16s ease;
}

.ai__msg:hover .ai__feedback,
.ai__msg:last-child .ai__feedback,
.ai__msg .ai__feedback:focus-within {
  opacity: 1;
}

@media (hover: none) {
  .ai__msg .ai__feedback {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ai__levels-thumb {
    transition: none;
  }
}

/* --- the mini widget: same parts, tighter ------------------------------- */

.ai--popover .ai__dock {
  padding-top: 8px;
}

.ai--popover .ai__levels {
  margin-inline: 12px;
}

.ai--popover .ai__level {
  padding-inline: 7px;
  column-gap: 6px;
}

.ai--popover .ai__dock .ai__composer {
  padding-inline: 12px;
}

/* The prompt lines cost more room here than they earn. */
.ai--popover .ai__voice-hint {
  display: none;
}

.ai--popover .ai__composer--voice .ai__ptt {
  width: 46px;
  height: 46px;
  grid-row: 1;
}

.ai--popover .ai__composer--voice {
  grid-template-columns: 46px minmax(0, 1fr) auto;
}

.ai--popover .ai__composer--voice .ai__voice-title {
  overflow: hidden;
  align-self: center;
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The keyboard icon says it alone; the label stays for screen readers. */
.ai--popover .ai__composer--voice .ai__mode {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  grid-row: 1;
  place-items: center;
}

.ai--popover .ai__composer--voice .ai__mode[data-promoted] {
  width: auto;
  padding-inline: 12px;
}

.ai--popover .ai__composer--voice .ai__mode:not([data-promoted]) .ai__mode-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ai--popover .ai__disclaimer {
  font-size: 10.5px;
}

/* The line under the composer already says to check the answers. */
.ai--popover .ai__suggestions .ai__trust--commands {
  display: none;
}

/* A short window keeps the prices: they are why the switch is here. */
@media (max-height: 745px) {
  .ai__level {
    min-height: 36px;
    padding-block: 2px;
  }

  .ai__dock {
    padding-top: 7px;
  }
}
