:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #04050d;
  color: #f6f4ff;
  font-synthesis: none;
  --cyan: #54e8ff;
  --violet: #8f6cff;
  --magenta: #ff4fc8;
  --panel: rgba(12, 13, 28, 0.64);
  --muted: rgba(230, 229, 247, 0.62);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #04050d;
}

body {
  min-height: 100svh;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

#visualizer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: radial-gradient(circle at 50% 50%, #111229 0%, #050611 58%, #02030a 100%);
}

.grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.75'/%3E%3C/svg%3E");
  animation: grain-shift 0.24s steps(2) infinite;
  mix-blend-mode: soft-light;
}

.interface {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(24px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) 20px max(28px, env(safe-area-inset-left));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-decoration: none;
  text-transform: uppercase;
  pointer-events: auto;
}

.brand-mark {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(102, 105, 255, 0.22);
}

.brand-mark i {
  display: block;
  width: 1.5px;
  border-radius: 4px;
  background: linear-gradient(to top, var(--violet), var(--cyan));
}

.brand-mark i:nth-child(1) { height: 5px; }
.brand-mark i:nth-child(2) { height: 10px; }
.brand-mark i:nth-child(3) { height: 7px; }

.live-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  justify-content: flex-end;
  color: rgba(230, 229, 247, 0.5);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #777688;
  box-shadow: 0 0 0 4px rgba(140, 139, 158, 0.08);
  transition: background 300ms ease, box-shadow 300ms ease;
}

.live-status[data-state="active"] {
  color: rgba(220, 255, 248, 0.78);
}

.live-status[data-state="active"] .status-dot {
  background: #68ffd0;
  box-shadow: 0 0 12px rgba(104, 255, 208, 0.9), 0 0 0 4px rgba(104, 255, 208, 0.12);
  animation: status-pulse 2s ease-in-out infinite;
}

.live-status[data-state="error"] {
  color: rgba(255, 180, 198, 0.9);
}

.live-status[data-state="error"] .status-dot {
  background: #ff668f;
  box-shadow: 0 0 12px rgba(255, 73, 128, 0.55);
}

.welcome {
  position: absolute;
  top: 50%;
  left: clamp(28px, 7vw, 108px);
  width: min(560px, calc(100vw - 56px));
  transform: translateY(-54%);
  transition: opacity 800ms ease, transform 900ms cubic-bezier(0.16, 1, 0.3, 1), visibility 800ms;
}

.interface.is-active .welcome {
  opacity: 0;
  transform: translateY(-50%) translateX(-18px);
  visibility: hidden;
}

.eyebrow {
  margin: 0 0 16px;
  color: rgba(145, 231, 255, 0.76);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(48px, 7.2vw, 104px);
  font-weight: 300;
  line-height: 0.91;
  letter-spacing: -0.065em;
  text-wrap: balance;
  text-shadow: 0 2px 20px rgba(3, 4, 13, 0.92), 0 0 56px rgba(86, 80, 201, 0.12);
}

.intro {
  max-width: 430px;
  margin: 28px 0 30px;
  color: var(--muted);
  font-size: clamp(14px, 1.4vw, 17px);
  line-height: 1.65;
  text-shadow: 0 1px 12px #03040d, 0 0 24px #03040d;
}

.listen-button,
.control-button,
.icon-button {
  border: 0;
  cursor: pointer;
  pointer-events: auto;
}

.listen-button {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  gap: 13px;
  padding: 0 23px;
  border: 1px solid rgba(164, 174, 255, 0.34);
  border-radius: 999px;
  background: linear-gradient(115deg, rgba(103, 91, 224, 0.34), rgba(60, 206, 229, 0.17));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 12px 42px rgba(24, 17, 85, 0.3), 0 0 35px rgba(81, 196, 255, 0.07);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  backdrop-filter: blur(18px);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.listen-button:hover {
  transform: translateY(-2px);
  border-color: rgba(184, 218, 255, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 16px 50px rgba(37, 25, 117, 0.4), 0 0 40px rgba(81, 224, 255, 0.12);
}

.listen-button:active {
  transform: translateY(0) scale(0.98);
}

.listen-button:disabled,
.control-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.listen-icon {
  height: 18px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.listen-icon i {
  display: block;
  width: 2px;
  height: 7px;
  border-radius: 2px;
  background: linear-gradient(to top, var(--violet), var(--cyan));
  animation: equalize 1.1s ease-in-out infinite alternate;
}

.listen-icon i:nth-child(2) { height: 14px; animation-delay: -0.7s; }
.listen-icon i:nth-child(3) { height: 10px; animation-delay: -0.35s; }
.listen-icon i:nth-child(4) { height: 5px; animation-delay: -0.9s; }

.privacy-note {
  margin: 16px 0 0 4px;
  color: rgba(220, 221, 238, 0.36);
  font-size: 11px;
  letter-spacing: 0.035em;
}

.control-dock {
  position: absolute;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(700px, calc(100vw - 36px));
  min-height: 74px;
  padding: 12px 14px;
  border: 1px solid rgba(206, 207, 255, 0.12);
  border-radius: 22px;
  background: linear-gradient(115deg, rgba(17, 18, 39, 0.76), rgba(10, 11, 25, 0.57));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055), 0 22px 70px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(24px) saturate(130%);
  transform: translateX(-50%);
  pointer-events: auto;
  transition: border-color 500ms ease, background 500ms ease;
}

.interface.is-active .control-dock {
  border-color: rgba(132, 124, 255, 0.22);
  background: linear-gradient(115deg, rgba(19, 19, 46, 0.76), rgba(8, 12, 29, 0.6));
}

.control-button {
  min-width: 100px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 17px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.045em;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.control-button:hover,
.icon-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}

.control-button:active,
.icon-button:active {
  transform: scale(0.96);
}

.is-active .mic-button {
  border-color: rgba(108, 255, 217, 0.22);
  background: rgba(81, 225, 196, 0.08);
  color: #cffff0;
}

.mic-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dock-divider {
  width: 1px;
  height: 34px;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.09);
}

.slider-control {
  min-width: 150px;
  flex: 1 1 160px;
}

.slider-copy {
  display: flex;
  justify-content: space-between;
  margin-bottom: 9px;
  color: rgba(235, 234, 251, 0.68);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.slider-copy output {
  color: rgba(180, 220, 255, 0.58);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 14px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(111, 207, 255, 0.68), rgba(146, 91, 255, 0.55));
  box-shadow: 0 0 12px rgba(112, 116, 255, 0.14);
}

input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(111, 207, 255, 0.68), rgba(146, 91, 255, 0.55));
}

input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: #7066d8;
  box-shadow: 0 0 0 3px rgba(105, 98, 211, 0.16), 0 0 16px rgba(120, 189, 255, 0.3);
}

input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: #7066d8;
  box-shadow: 0 0 0 3px rgba(105, 98, 211, 0.16), 0 0 16px rgba(120, 189, 255, 0.3);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fullscreen-exit {
  display: none;
}

.is-fullscreen .fullscreen-enter {
  display: none;
}

.is-fullscreen .fullscreen-exit {
  display: block;
}

.message {
  position: absolute;
  left: 50%;
  bottom: max(112px, calc(env(safe-area-inset-bottom) + 102px));
  max-width: min(520px, calc(100vw - 40px));
  padding: 10px 15px;
  border: 1px solid rgba(255, 115, 150, 0.22);
  border-radius: 11px;
  background: rgba(46, 11, 28, 0.68);
  color: rgba(255, 221, 230, 0.92);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 8px);
  backdrop-filter: blur(14px);
  transition: opacity 220ms ease, transform 220ms ease, visibility 220ms;
}

.message.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(115, 224, 255, 0.86);
  outline-offset: 4px;
}

noscript {
  position: fixed;
  z-index: 5;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  padding: 20px;
  color: white;
  background: #111326;
}

@keyframes grain-shift {
  0% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(2%, -1%, 0); }
  50% { transform: translate3d(-1%, 2%, 0); }
  75% { transform: translate3d(1%, 1%, 0); }
  100% { transform: translate3d(-2%, -1%, 0); }
}

@keyframes equalize {
  from { transform: scaleY(0.55); opacity: 0.65; }
  to { transform: scaleY(1.2); opacity: 1; }
}

@keyframes status-pulse {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

@media (max-width: 720px) {
  .topbar {
    padding-left: 20px;
    padding-right: 20px;
  }

  .welcome {
    left: 24px;
    width: calc(100vw - 48px);
    transform: translateY(-60%);
  }

  h1 {
    font-size: clamp(48px, 15vw, 76px);
  }

  .intro {
    max-width: 360px;
    margin-top: 22px;
  }

  .control-dock {
    gap: 12px;
    min-height: 70px;
    padding: 10px;
  }

  .control-button {
    min-width: 48px;
    width: 48px;
    padding: 0;
  }

  .control-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .slider-control {
    min-width: 0;
  }

  .fullscreen-divider {
    display: none;
  }
}

@media (max-width: 480px) {
  .brand {
    font-size: 11px;
  }

  .live-status {
    min-width: 0;
    font-size: 9px;
  }

  .control-dock {
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    gap: 9px;
    border-radius: 18px;
  }

  .dock-divider {
    display: none;
  }

  .slider-copy {
    letter-spacing: 0.03em;
  }

  .slider-copy output {
    display: none;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .message {
    bottom: max(96px, calc(env(safe-area-inset-bottom) + 88px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .grain,
  .listen-icon i,
  .status-dot {
    animation: none !important;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
