:root {
  --bg: #06060b;
  --ink: #f4f5fb;
  --muted: #9a9cb0;
  --accent: #6f8dff;
  --accent-2: #b06bff;
  --accent-3: #4de3d0;
  --line: rgba(255, 255, 255, 0.1);
  --bubble-user: rgba(111, 141, 255, 0.16);
  --bubble-bot: rgba(255, 255, 255, 0.055);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

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

.aurora {
  position: fixed;
  inset: -30%;
  background:
    radial-gradient(38% 34% at 28% 26%, rgba(111, 141, 255, 0.3), transparent 70%),
    radial-gradient(34% 30% at 74% 22%, rgba(176, 107, 255, 0.26), transparent 70%),
    radial-gradient(46% 40% at 52% 84%, rgba(77, 227, 208, 0.16), transparent 72%);
  filter: blur(30px);
  animation: drift 26s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes drift {
  from {
    transform: translate3d(-2%, -1%, 0) scale(1);
  }
  to {
    transform: translate3d(2%, 2%, 0) scale(1.08);
  }
}

.stage {
  position: relative;
  height: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(16px, 3vh, 28px) clamp(16px, 4vw, 28px) clamp(14px, 2.4vh, 22px);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vh, 20px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(244, 245, 251, 0.82);
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent-3), var(--accent));
  box-shadow: 0 0 12px rgba(111, 141, 255, 0.9);
}

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}

.ghost:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.2);
}

.ghost[aria-pressed="true"] {
  color: #dfe6ff;
  border-color: rgba(111, 141, 255, 0.5);
  background: rgba(111, 141, 255, 0.14);
}

.ghost-icon {
  font-size: 10px;
}

.orb-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: clamp(4px, 2vh, 18px);
}

.orb {
  position: relative;
  width: clamp(148px, 26vh, 196px);
  height: clamp(148px, 26vh, 196px);
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.orb:active {
  transform: scale(0.96);
}

.orb:focus-visible {
  outline: 2px solid rgba(111, 141, 255, 0.85);
  outline-offset: 10px;
}

.orb-core {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  background:
    conic-gradient(from 210deg, #4de3d0, #6f8dff 32%, #b06bff 62%, #ff7ac8 82%, #4de3d0);
  filter: blur(14px) saturate(1.15);
  opacity: 0.92;
  animation: spin 14s linear infinite;
}

.orb-glow {
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(111, 141, 255, 0.42), transparent 62%);
  filter: blur(22px);
  opacity: 0.75;
  transition: opacity 0.4s;
}

.orb-ring {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.2), transparent 58%);
  backdrop-filter: blur(2px);
}

.orb-ring-2 {
  inset: 0;
  border-color: rgba(255, 255, 255, 0.07);
}

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

.orb-bars {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  opacity: 0;
  transition: opacity 0.25s;
}

.orb-bars i {
  display: block;
  width: 3px;
  height: 24%;
  border-radius: 2px;
  background: #fff;
  animation: bar 0.9s ease-in-out infinite;
}

.orb-bars i:nth-child(1) { animation-delay: 0s; }
.orb-bars i:nth-child(2) { animation-delay: 0.12s; }
.orb-bars i:nth-child(3) { animation-delay: 0.24s; }
.orb-bars i:nth-child(4) { animation-delay: 0.36s; }
.orb-bars i:nth-child(5) { animation-delay: 0.48s; }

@keyframes bar {
  0%, 100% { height: 24%; opacity: 0.7; }
  50% { height: 100%; opacity: 1; }
}

body[data-state="listening"] .orb-core,
body[data-state="thinking"] .orb-core {
  animation-duration: 3.5s;
}

body[data-state="listening"] .orb-glow {
  opacity: 1;
  animation: pulse 1.6s ease-in-out infinite;
}

body[data-state="listening"] .orb-bars,
body[data-state="speaking"] .orb-bars {
  opacity: 1;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.09); }
}

body[data-state="thinking"] .orb-core {
  filter: blur(18px);
  opacity: 0.7;
}

body[data-state="speaking"] .orb-core {
  animation-duration: 5s;
  opacity: 1;
}

body[data-state="idle"] .orb:hover .orb-glow {
  opacity: 1;
}

.status {
  margin: 0;
  font-size: clamp(13.5px, 1.9vh, 15px);
  color: rgba(244, 245, 251, 0.66);
  text-align: center;
  min-height: 1.4em;
  letter-spacing: 0.01em;
}

.hint {
  margin: 0;
  max-width: 46ch;
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
  color: #ffcf8a;
  background: rgba(255, 190, 92, 0.09);
  border: 1px solid rgba(255, 190, 92, 0.28);
  border-radius: 12px;
  padding: 10px 13px;
}

.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 4px), transparent 100%);
}

.log:empty {
  display: none;
}

.bubble {
  max-width: min(88%, 560px);
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: rise 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  border: 1px solid transparent;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
}

.bubble.user {
  align-self: flex-end;
  background: var(--bubble-user);
  border-color: rgba(111, 141, 255, 0.28);
  border-bottom-right-radius: 6px;
}

.bubble.bot {
  align-self: flex-start;
  background: var(--bubble-bot);
  border-color: var(--line);
  border-bottom-left-radius: 6px;
}

.bubble.bot code {
  display: block;
  margin: 8px 0 2px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
  white-space: pre;
}

.bubble.error {
  background: rgba(255, 108, 108, 0.08);
  border-color: rgba(255, 108, 108, 0.3);
  color: #ffd8d8;
}

.bubble.pending {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 14px 16px;
}

.bubble.pending i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  animation: blink 1.2s ease-in-out infinite;
}

.bubble.pending i:nth-child(2) { animation-delay: 0.18s; }
.bubble.pending i:nth-child(3) { animation-delay: 0.36s; }

@keyframes blink {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.2s, background 0.2s;
}

.composer:focus-within {
  border-color: rgba(111, 141, 255, 0.55);
  background: rgba(111, 141, 255, 0.08);
}

.composer input {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
}

.composer input::placeholder {
  color: rgba(154, 156, 176, 0.85);
}

.send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  color: #0a0a12;
  background: linear-gradient(140deg, #eaf0ff, #b9c8ff);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.send:hover {
  transform: scale(1.05);
}

.send:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.footbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: rgba(154, 156, 176, 0.7);
}

.link {
  padding: 0;
  font: inherit;
  font-size: 11.5px;
  color: rgba(154, 156, 176, 0.85);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(255, 255, 255, 0.2);
}

.link:hover {
  color: var(--ink);
}

@media (max-width: 520px) {
  .stage {
    gap: 10px;
  }

  .bubble {
    font-size: 14px;
  }

  .footnote {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aurora,
  .orb-core,
  .orb-bars i,
  .orb-glow {
    animation: none !important;
  }
}
