/*
 * Visual language ported from a reference "voice orb" mock: dark teal ground,
 * a breathing particle sphere, quiet circular chrome. Deliberately one theme —
 * an immersive voice-assistant surface, not a document — the same choice
 * Siri/Assistant/Alexa make for their listening screens.
 */

:root {
  --bg: #20292b;
  --bg-2: #252f31;
  --dot: #aeb9b9;
  --dot-hot: #d8e2e1;
  --btn: #394447;
  --btn-hover: #445154;
  --btn-active: #e7eeee;
  --btn-active-text: #233033;
  --text: #e6eded;
  --muted: #aeb8b8;
  --faint: #7c8888;
  --panel: rgba(37, 47, 49, 0.5);
  --panel-border: rgba(174, 185, 185, 0.12);
  --danger: #e2a08a;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.03), transparent 38%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection {
  background: rgba(216, 226, 225, 0.18);
}

/* ---------------- layout ---------------- */

.screen {
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  position: relative;
  isolation: isolate;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 4px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot-hot);
  box-shadow: 0 0 10px rgba(216, 226, 225, 0.4);
}

.brand-name {
  color: var(--text);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  font-size: 11px;
  color: var(--faint);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* ---------------- circular chrome, matching the reference exactly ---------------- */

.icon-btn {
  width: 50px;
  height: 50px;
  border: 0;
  border-radius: 50%;
  background: rgba(63, 75, 78, 0.78);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 8px 25px rgba(0, 0, 0, 0.12);
  transition: 0.2s ease;
  flex: none;
}

.icon-btn:hover {
  background: var(--btn-hover);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.96);
}

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

#mute-toggle {
  width: 44px;
  height: 44px;
}

#mute-toggle[aria-pressed="true"] {
  color: var(--faint);
}

/* Grid-item blockification on an inline <svg> can outrank the UA [hidden]
   rule in some engines — pin it explicitly rather than rely on that. */
.icon-btn svg[hidden] {
  display: none;
}

/* ---------------- orb ---------------- */

.orb-stage {
  position: relative;
  width: min(62vw, 320px);
  aspect-ratio: 1;
  margin: 10px auto 0;
  display: grid;
  place-items: center;
  flex: none;
}

#orb {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 18px rgba(190, 210, 210, 0.05));
  transition: filter 0.3s ease;
}

body[data-state="listening"] #orb,
body[data-state="speaking"] #orb {
  filter: drop-shadow(0 0 26px rgba(190, 210, 210, 0.09));
}

/* ---------------- content stage (scrolls when an answer needs room) ---------------- */

.stage {
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  padding: 8px 2px 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--btn) transparent;
}

.empty-state {
  text-align: center;
  animation: rise 0.5s ease both;
}

.empty-state h1 {
  font-size: clamp(21px, 4.6vw, 27px);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.hint {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 auto 18px;
  max-width: 32ch;
  line-height: 1.5;
}

.exchange {
  animation: rise 0.4s ease both;
}

.label {
  color: var(--faint);
  font-size: 10.5px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  margin: 0 0 5px;
}

.answer-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.chip {
  background: rgba(174, 185, 185, 0.1);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  text-transform: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.chip.miss {
  background: rgba(226, 160, 138, 0.14);
  color: var(--danger);
}

.question {
  font-size: 15.5px;
  color: var(--muted);
  margin: 0;
  line-height: 1.45;
}

.parsed-note {
  color: var(--faint);
  font-size: 11px;
  margin: 5px 0 0;
}

.parsed-note[hidden] {
  display: none;
}

.answer {
  font-size: clamp(17px, 3vw, 20px);
  line-height: 1.55;
  margin: 0;
  letter-spacing: -0.005em;
  min-height: 1.55em;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 0.95em;
  margin-left: 2px;
  vertical-align: -0.14em;
  background: var(--dot-hot);
  animation: blink 1s steps(1) infinite;
}

.caret[hidden] {
  display: none;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  padding: 2px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(174, 185, 185, 0.4);
}

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

.detail-toggle {
  display: inline-block;
  margin-top: 14px;
}

.detail-toggle[hidden] {
  display: none;
}

.detail {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.62;
  animation: rise 0.3s ease both;
}

.detail[hidden] {
  display: none;
}

.detail p {
  margin: 0 0 11px;
}

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

/* ---------------- footer ---------------- */

.controls {
  padding: 10px 2px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.live-transcript {
  color: var(--dot-hot);
  font-size: 13px;
  margin: 0;
  min-height: 18px;
  text-align: center;
  opacity: 0.85;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0 0 12px;
  min-height: 16px;
  text-align: center;
  letter-spacing: 0.01em;
}

.status.error {
  color: var(--danger);
}

.button-row {
  display: flex;
  align-items: center;
  gap: 22px;
}

.icon-btn.mic {
  width: 62px;
  height: 62px;
}

body[data-state="listening"] .icon-btn.mic,
body[data-state="speaking"] .icon-btn.mic {
  background: var(--btn-active);
  color: var(--btn-active-text);
  box-shadow:
    0 0 0 7px rgba(231, 238, 238, 0.05),
    0 10px 28px rgba(0, 0, 0, 0.16);
}

body[data-state="thinking"] .icon-btn.mic {
  opacity: 0.6;
  cursor: default;
}

body[data-state="thinking"] .icon-btn.mic svg {
  animation: pulse 1.1s ease-in-out infinite;
}

.fallback-form {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 380px;
  margin-top: 16px;
  animation: rise 0.25s ease both;
}

.fallback-form[hidden] {
  display: none;
}

.fallback-input {
  flex: 1;
  background: var(--btn);
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
}

.fallback-input:focus {
  border-color: var(--dot-hot);
}

.fallback-input::placeholder {
  color: var(--faint);
}

.fallback-send {
  background: var(--dot-hot);
  border: none;
  border-radius: 12px;
  color: #1c2426;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 0 18px;
}

/* ---------------- motion ---------------- */

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 420px) {
  .screen {
    padding: 0 16px;
  }
  .orb-stage {
    width: min(78vw, 300px);
  }
  .icon-btn {
    width: 46px;
    height: 46px;
  }
  .icon-btn.mic {
    width: 58px;
    height: 58px;
  }
  .button-row {
    gap: 18px;
  }
}

@media (max-height: 700px) {
  .orb-stage {
    width: min(56vw, 240px);
    margin-top: 4px;
  }
}
