/* Viti public assistant UI (floating widget + /viti/ standalone page).
   Uses styles-ad3.css design tokens for light and Nordic Night dark themes. */

.viti-launcher-wrap {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 950;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  pointer-events: none;
}

.viti-launcher-wrap > * {
  pointer-events: auto;
}

.viti-launcher__lantern {
  position: absolute;
  left: 43.36%;
  top: 26.17%;
  width: 13.28%;
  height: 11.72%;
  border-radius: 18%;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity 400ms ease;
}

.viti-launcher-wrap--beam-on .viti-launcher__lantern {
  opacity: 1;
}

.viti-launcher-wrap--beam-off .viti-launcher__lantern {
  opacity: 0;
}

.viti-launcher-wrap--beam-off .viti-launcher__lantern::before,
.viti-launcher-wrap--beam-off .viti-launcher__lantern::after {
  animation-play-state: paused;
}

.viti-launcher__lantern::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 240%;
  height: 240%;
  margin-left: -120%;
  margin-top: -120%;
  transform-origin: center center;
  background: conic-gradient(
    from -15deg at 50% 50%,
    transparent 0deg 235deg,
    rgba(246, 185, 135, 0.22) 252deg,
    rgba(255, 231, 198, 0.72) 268deg,
    rgba(255, 248, 236, 1) 284deg,
    rgba(255, 231, 198, 0.72) 300deg,
    rgba(246, 185, 135, 0.22) 316deg,
    transparent 332deg 360deg
  );
  animation: viti-launcher-lantern-sweep 3.75s ease-in-out infinite;
}

.viti-launcher__lantern::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 6px 1px rgba(255, 252, 247, 0.35);
  animation: viti-launcher-lantern-glow 3.75s ease-in-out infinite;
  pointer-events: none;
}

@keyframes viti-launcher-lantern-sweep {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes viti-launcher-lantern-glow {
  0%,
  100% {
    opacity: 0.3;
    box-shadow: inset 0 0 4px 1px rgba(255, 252, 247, 0.25);
  }
  10%,
  22% {
    opacity: 1;
    box-shadow: inset 0 0 11px 3px rgba(255, 252, 247, 0.92);
  }
  48%,
  52% {
    opacity: 0.18;
    box-shadow: inset 0 0 2px 0 rgba(255, 252, 247, 0.12);
  }
  60%,
  72% {
    opacity: 0.95;
    box-shadow: inset 0 0 10px 2px rgba(255, 252, 247, 0.82);
  }
}

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

  .viti-launcher__lantern::before {
    transform: none;
    opacity: 1;
    background: radial-gradient(
      ellipse 85% 75% at 50% 42%,
      rgba(255, 238, 205, 0.95) 0%,
      rgba(246, 195, 159, 0.5) 58%,
      transparent 100%
    );
  }

  .viti-launcher__lantern::after {
    opacity: 0.8;
    box-shadow: inset 0 0 9px 2px rgba(255, 252, 247, 0.62);
  }

  .viti-launcher-wrap--beam-on .viti-launcher__lantern {
    opacity: 1 !important;
  }
}

.viti-launcher-hint {
  position: relative;
  z-index: 1;
  max-width: 236px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 12px 32px var(--shadow-md);
}

.viti-launcher-hint[hidden] {
  display: none !important;
}

.viti-launcher-hint__open {
  appearance: none;
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 34px 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.viti-launcher-hint__open:hover {
  background: var(--wash);
}

.viti-launcher-hint__open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.viti-launcher-hint__close {
  appearance: none;
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.viti-launcher-hint__close:hover {
  color: var(--ink);
  background: var(--wash);
}

.viti-launcher-hint__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.viti-launcher {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 72px;
  height: 72px;
  min-width: 72px;
  min-height: 72px;
  padding: 5px;
  overflow: hidden;
  border: 2px solid var(--accent-fill);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow:
    0 14px 36px var(--shadow-lg),
    0 0 0 1px color-mix(in srgb, var(--ink) 6%, transparent);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.viti-launcher[hidden] {
  display: none !important;
}

.viti-launcher:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 12px 32px var(--shadow-lg);
}

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

.viti-launcher__avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  flex: none;
  display: block;
  object-fit: cover;
}

.viti-launcher__text {
  display: none;
}

.viti-launcher__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.viti-launcher__tag {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.viti-backdrop {
  position: fixed;
  inset: 0;
  z-index: 965;
  background: rgba(15, 20, 23, 0.46);
  backdrop-filter: blur(2px);
}

.viti-backdrop[hidden] {
  display: none !important;
}

html.viti-maximized-open {
  overflow: hidden;
}

.viti-panel {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px var(--shadow-lg);
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

.viti-panel--floating {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 960;
  width: 420px;
  height: 600px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  min-width: 320px;
  min-height: 360px;
}

.viti-panel--floating[hidden] {
  display: none !important;
}

.viti-panel--maximized,
.viti-panel--page.viti-panel--maximized {
  position: fixed !important;
  top: 16px !important;
  right: 16px !important;
  bottom: 16px !important;
  left: 16px !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  border-radius: 8px;
  z-index: 970;
}

.viti-panel--maximized .viti-messages {
  padding: 18px max(20px, calc((100% - 860px) / 2));
}

.viti-panel--maximized .viti-composer {
  padding: 12px max(20px, calc((100% - 860px) / 2));
}

.viti-panel--page {
  width: 100%;
  min-height: 460px;
  height: min(64dvh, 660px);
  box-shadow: 0 8px 26px var(--shadow-sm);
}

.viti-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 4;
  background: transparent;
  border: 0;
  padding: 0;
}

.viti-resize-handle::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 5px;
  width: 7px;
  height: 7px;
  border-top: 2px solid var(--muted);
  border-left: 2px solid var(--muted);
  border-top-left-radius: 2px;
  opacity: 0.65;
}

.viti-resize-handle:hover::after,
.viti-resize-handle:focus-visible::after {
  opacity: 1;
  border-color: var(--accent);
}

.viti-resize-handle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.viti-panel--maximized .viti-resize-handle,
.viti-panel--page .viti-resize-handle {
  display: none;
}

.viti-head {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex: 0 0 auto;
}

.viti-head__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.viti-head__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: none;
}

.viti-head__titles {
  min-width: 0;
  flex: 1 1 auto;
}

.viti-head__title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.viti-head__title {
  margin: 0;
  text-transform: none;
  letter-spacing: normal;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.viti-head__sub {
  margin: 1px 0 0;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viti-head__controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.viti-langs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  background: var(--paper);
}

.viti-lang-btn {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 4px 7px;
  min-height: 30px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.viti-lang-btn:last-child {
  border-right: 0;
}

.viti-lang-btn[aria-pressed="true"] {
  background: var(--accent-fill);
  color: var(--on-accent);
}

.viti-lang-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.viti-icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}

.viti-icon-btn svg {
  width: 15px;
  height: 15px;
  display: block;
}

.viti-icon-btn--close {
  background: var(--wash);
}

.viti-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.viti-icon-btn--close:hover {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
}

.viti-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.viti-tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex: 0 0 auto;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.viti-tabs::-webkit-scrollbar {
  display: none;
}

.viti-tab {
  appearance: none;
  flex: 0 0 auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 3px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--muted);
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}

.viti-tab:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.viti-tab[aria-selected="true"] {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
  font-weight: 600;
}

.viti-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.viti-panel--maximized .viti-tabs {
  padding: 6px max(20px, calc((100% - 860px) / 2));
}

.viti-messages {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--paper);
}

.viti-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 92%;
}

.viti-msg--user {
  align-self: flex-end;
  align-items: flex-end;
}

.viti-msg--assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.viti-msg__role {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
}

.viti-bubble {
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.56;
  word-break: break-word;
}

.viti-msg--user .viti-bubble {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
}

.viti-msg--error .viti-bubble {
  background: var(--wash-warm);
  border-color: var(--wash-warm-border);
  color: var(--ink);
}

.viti-bubble p {
  margin: 0 0 8px;
}

.viti-bubble p:last-child {
  margin-bottom: 0;
}

.viti-bubble .viti-md-heading {
  margin: 10px 0 6px;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}

.viti-bubble .viti-md-heading:first-child {
  margin-top: 0;
}

.viti-bubble .viti-md-heading:last-child {
  margin-bottom: 0;
}

.viti-bubble strong {
  font-weight: 600;
  color: var(--ink);
}

.viti-msg--user .viti-bubble strong {
  color: var(--on-accent);
}

.viti-bubble ul,
.viti-bubble ol {
  margin: 4px 0 8px;
  padding-left: 19px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.viti-bubble ul:last-child,
.viti-bubble ol:last-child {
  margin-bottom: 0;
}

.viti-bubble li {
  line-height: 1.5;
}

.viti-bubble li > ul,
.viti-bubble li > ol {
  margin: 3px 0 2px;
  padding-left: 17px;
}

.viti-bubble code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.87em;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--wash);
  color: var(--code-ink);
}

.viti-msg--user .viti-bubble code {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--on-accent);
}

.viti-bubble .viti-md-pre {
  margin: 6px 0 8px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--wash);
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.45;
}

.viti-bubble .viti-md-pre:last-child {
  margin-bottom: 0;
}

.viti-bubble .viti-md-pre code {
  padding: 0;
  border: 0;
  background: transparent;
}

.viti-table-wrap {
  margin: 6px 0 8px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.viti-table-wrap:last-child {
  margin-bottom: 0;
}

.viti-md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.4;
}

.viti-md-table th,
.viti-md-table td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.viti-md-table th {
  background: var(--wash);
  font-weight: 600;
  color: var(--ink);
}

.viti-md-table tr:last-child td {
  border-bottom: 0;
}

.viti-bubble a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.viti-bubble a:hover {
  color: var(--ink);
}

.viti-bubble a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.viti-msg--user .viti-bubble a {
  color: var(--on-accent);
}

.viti-bubble a.viti-book-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 2px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--paper);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  vertical-align: baseline;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.viti-bubble a.viti-book-btn:hover {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
  text-decoration: none;
}

.viti-bubble a.viti-book-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.viti-booking-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.viti-booking-row a.viti-book-btn {
  margin-left: 0;
}

.viti-bubble [data-viti-pending="1"] {
  display: none !important;
}

.viti-traces {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.viti-trace-card {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 5px;
  background: var(--wash);
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.4;
}

.viti-trace-card--stale,
.viti-trace-card--error {
  background: var(--wash-warm);
  border-left-color: var(--accent-2);
}

.viti-trace-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.viti-trace-server {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.viti-trace-tool {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--code-ink);
}

.viti-trace-badge {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-2-ink);
}

.viti-trace-time {
  margin-top: 3px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
}

.viti-trace-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 4px;
}

.viti-trace-links a {
  font-size: 12px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.viti-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.viti-chip {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  padding: 6px 11px;
  min-height: 34px;
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 12.5px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}

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

.viti-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.viti-chip:disabled {
  opacity: 0.6;
  cursor: default;
}

.viti-switch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.viti-switch-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 13px;
  border: 1px solid var(--accent-fill);
  border-radius: 999px;
  background: var(--wash);
  color: var(--accent);
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.viti-switch-btn:hover:not(:disabled) {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
}

.viti-switch-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.viti-switch-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.viti-thread-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.3;
}

.viti-thread-switch__line {
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
}

.viti-thread-switch__text {
  flex: 0 0 auto;
  white-space: nowrap;
}

.viti-typing {
  /* Legacy hook for tests and busy state; thinking uses viti-msg--thinking */
}

.viti-msg__row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}

.viti-msg__avatar-wrap {
  position: relative;
  flex: none;
  width: 28px;
  height: 28px;
}

.viti-msg__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
}

.viti-msg__lantern {
  position: absolute;
  left: 43.36%;
  top: 26.17%;
  width: 13.28%;
  height: 11.72%;
  border-radius: 18%;
  overflow: hidden;
  pointer-events: none;
  opacity: 0.85;
  mix-blend-mode: screen;
}

.viti-msg__lantern::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(246, 195, 159, 0.55);
  animation: viti-msg-lantern-pulse 2.4s ease-in-out infinite;
}

.viti-msg--thinking .viti-bubble--thinking {
  min-width: 52px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
}

.viti-thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.viti-thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  transform: scale(0.92);
  animation: viti-thinking-dot 1.35s ease-in-out infinite;
}

.viti-thinking-dots span:nth-child(2) {
  animation-delay: 0.18s;
}

.viti-thinking-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes viti-thinking-dot {
  0%,
  100% {
    opacity: 0.32;
    transform: scale(0.9);
  }
  45% {
    opacity: 0.88;
    transform: scale(1.05);
  }
}

@keyframes viti-msg-lantern-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.95;
  }
}

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

.viti-msg--thinking {
  position: relative;
}

.viti-type-cursor {
  display: inline-block;
  width: 1px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: var(--accent);
  opacity: 0.75;
  animation: viti-type-cursor-blink 0.95s step-end infinite;
}

@keyframes viti-type-cursor-blink {
  0%,
  49% {
    opacity: 0.8;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.viti-fade-in {
  animation: viti-fade-in 320ms ease forwards;
  opacity: 0;
}

@keyframes viti-fade-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .viti-thinking-dots span,
  .viti-msg__lantern::before,
  .viti-type-cursor {
    animation: none !important;
  }

  .viti-thinking-dots span {
    opacity: 0.7;
    transform: none;
  }

  .viti-fade-in {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
}

.viti-turnstile {
  padding: 0 12px 6px;
  background: var(--paper);
}

.viti-turnstile[hidden] {
  display: none !important;
}

.viti-composer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 10px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.viti-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.viti-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  max-height: 132px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
}

.viti-input:focus {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.viti-send {
  appearance: none;
  flex: none;
  min-height: 44px;
  min-width: 72px;
  padding: 8px 14px;
  border: 1px solid var(--accent-fill);
  border-radius: 6px;
  background: var(--accent-fill);
  color: var(--on-accent);
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.viti-send:hover:not(:disabled) {
  background: var(--accent-fill-hover);
  border-color: var(--accent-fill-hover);
}

.viti-send:disabled {
  opacity: 0.55;
  cursor: default;
}

.viti-send:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.viti-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
}

.viti-count[hidden] {
  display: none !important;
}

.viti-meta-row a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.viti-voice-notice {
  padding: 7px 10px;
  border: 1px solid var(--wash-warm-border);
  border-radius: 6px;
  background: var(--wash-warm);
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.4;
}

.viti-voice-notice[hidden] {
  display: none !important;
}

.viti-mic {
  appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.viti-mic[hidden] {
  display: none !important;
}

.viti-mic svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.viti-mic:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--wash);
}

.viti-mic:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.viti-mic:disabled {
  opacity: 0.58;
  cursor: default;
}

/* Recording: red icon and border (plus a pulse unless reduced motion is on). */
.viti-mic {
  --viti-rec: #c62828;
}

:root[data-theme="dark"] .viti-mic {
  --viti-rec: #ff7b72;
}

.viti-mic--listening,
.viti-mic--listening:hover:not(:disabled) {
  border-color: var(--viti-rec);
  background: color-mix(in srgb, var(--viti-rec) 12%, var(--paper));
  color: var(--viti-rec);
  animation: viti-mic-pulse 1.5s ease-in-out infinite;
}

.viti-mic--transcribing {
  border-color: var(--accent);
  background: var(--wash);
  color: var(--accent);
}

@keyframes viti-mic-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--viti-rec) 38%, transparent);
  }
  50% {
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--viti-rec) 14%, transparent);
  }
}

.viti-voice-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
}

.viti-voice-bar[hidden] {
  display: none !important;
}

.viti-speaker-btn[hidden] {
  display: none !important;
}

.viti-speaker-btn--on,
.viti-speaker-btn[aria-pressed="true"] {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: var(--on-accent);
}

.viti-speaker-btn[aria-pressed="true"]:hover {
  background: var(--accent-fill);
  border-color: var(--accent);
  color: var(--on-accent);
}

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

.viti-msg__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.viti-listen-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.viti-listen-btn svg {
  width: 13px;
  height: 13px;
  flex: none;
}

.viti-listen-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--wash);
}

.viti-listen-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.viti-listen-btn--playing {
  border-color: var(--accent-fill);
  background: var(--wash);
  color: var(--accent);
  font-weight: 600;
  animation: viti-listen-pulse 1.5s ease-in-out infinite;
}

@keyframes viti-listen-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 26%, transparent);
  }
  50% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .viti-mic,
  .viti-mic--listening,
  .viti-listen-btn,
  .viti-listen-btn--playing,
  .viti-speaker-btn {
    animation: none !important;
    transition: none !important;
    box-shadow: none !important;
  }
}

/* Standalone /viti/ page layout */
.viti-page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.viti-page-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  flex: none;
}

.viti-page-notes {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.viti-page-note {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  font-size: 14px;
}

.viti-page-note h2 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.viti-page-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

@media (max-width: 767px) {
  .viti-launcher-hint {
    display: none !important;
  }
}

@media (max-width: 640px) {
  html.viti-floating-open {
    overflow: hidden;
  }

  .viti-launcher-wrap {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .viti-launcher {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
  }

  .viti-panel--floating {
    position: fixed;
    top: var(--viti-vvt, 0px);
    right: 0;
    left: 0;
    bottom: auto;
    width: 100%;
    height: var(--viti-vvh, 100dvh);
    max-width: none;
    max-height: none;
    min-width: 0;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    z-index: 980;
  }

  .viti-panel--maximized,
  .viti-panel--page.viti-panel--maximized {
    top: var(--viti-vvt, 0px) !important;
    right: 0 !important;
    left: 0 !important;
    bottom: auto !important;
    height: var(--viti-vvh, 100dvh) !important;
    max-height: none !important;
    border: 0;
    border-radius: 0;
  }

  .viti-panel--maximized .viti-tabs,
  .viti-panel--maximized .viti-messages,
  .viti-panel--maximized .viti-composer {
    padding-left: 12px;
    padding-right: 12px;
  }

  .viti-resize-handle {
    display: none;
  }

  .viti-head {
    padding: 8px 10px;
    gap: 6px;
  }

  .viti-tabs {
    padding: 6px 10px;
  }

  .viti-tab {
    min-height: 30px;
    padding: 4px 12px;
  }

  .viti-head__avatar {
    width: 28px;
    height: 28px;
  }

  .viti-head__sub {
    display: none;
  }

  .viti-icon-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .viti-lang-btn {
    min-height: 34px;
    padding: 4px 7px;
  }

  .viti-composer {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .viti-input {
    font-size: 16px;
  }

  .viti-input-row {
    gap: 6px;
  }


  .viti-send {
    min-width: 64px;
    padding: 8px 11px;
  }

  .viti-listen-btn {
    min-height: 34px;
    padding: 4px 11px;
  }

  body.viti-page {
    position: fixed;
    top: var(--viti-vvt, 0px);
    left: 0;
    right: 0;
    width: 100%;
    height: var(--viti-vvh, 100dvh);
    overflow: hidden;
  }

  body.viti-page .shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  html body.viti-page .shell > aside.identity {
    position: relative;
    top: auto;
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 4px 12px;
  }

  body.viti-page .main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    max-width: none;
    overflow: hidden;
  }

  body.viti-page .viti-page-head {
    flex: 0 0 auto;
    gap: 10px;
    margin-bottom: 4px;
  }

  body.viti-page .viti-page-avatar {
    width: 34px;
    height: 34px;
  }

  body.viti-page .kicker {
    margin: 0 0 1px;
    font-size: 12px;
    line-height: 1.2;
  }

  body.viti-page h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.15;
  }

  body.viti-page .lede {
    flex: 0 0 auto;
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.35;
  }

  body.viti-page #viti-page-root {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  body.viti-page .viti-panel--page {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }

  body.viti-page .viti-page-notes,
  body.viti-page footer {
    display: none;
  }

  html.viti-kb-open body.viti-page .viti-page-head,
  html.viti-kb-open body.viti-page .lede {
    display: none;
  }
}

@media print {
  .viti-launcher-wrap,
  .viti-panel {
    display: none !important;
  }
}
