:root {
  --bg: #0b0d10;
  --surface: #14171c;
  --surface-raised: #1b1f25;
  --text: #f7f4ee;
  --muted: #aeb5bf;
  --accent: #5ea4ff;
  --accent-strong: #2f83f5;
  --danger: #ff665f;
  --focus: #ffd166;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.app {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  min-height: 0;
  background:
    radial-gradient(circle at 50% -15%, rgba(94, 164, 255, 0.09), transparent 42%),
    var(--bg);
}

.transcript-panel {
  position: relative;
  min-height: 0;
  padding:
    calc(var(--safe-top) + clamp(1.25rem, 4vw, 2.5rem))
    calc(var(--safe-right) + clamp(1.3rem, 5vw, 3.5rem))
    0
    calc(var(--safe-left) + clamp(1.3rem, 5vw, 3.5rem));
  overflow: hidden;
}

.transcript-scroll {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.transcript-scroll::-webkit-scrollbar {
  display: none;
}

.transcript {
  width: 100%;
  margin: auto 0;
  padding: clamp(0.5rem, 2vh, 1.5rem) 0 clamp(1rem, 3vh, 2rem);
  color: var(--text);
  font-size: clamp(3.6rem, 17vw, 9.5rem);
  font-weight: 720;
  font-variation-settings: "wght" 720;
  line-height: 1.03;
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.transcript--medium {
  font-size: clamp(3rem, 13vw, 7.5rem);
  line-height: 1.06;
}

.transcript--long {
  font-size: clamp(2.25rem, 9.5vw, 5.5rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.transcript--dense {
  font-size: clamp(1.7rem, 7vw, 4rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.transcript--empty {
  max-width: 12ch;
  color: var(--muted);
  font-size: clamp(2.7rem, 13vw, 6.8rem);
}

.interim-text {
  color: #c3cad3;
}

.interim-text:not(:empty)::after {
  content: "";
  display: inline-block;
  width: 0.09em;
  height: 0.8em;
  margin-left: 0.08em;
  border-radius: 99px;
  vertical-align: -0.03em;
  background: var(--accent);
  animation: pulse-caret 0.9s ease-in-out infinite alternate;
}

.edge-fade {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1.25rem;
  pointer-events: none;
  background: linear-gradient(transparent, var(--bg));
}

.control-dock {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 5.3rem;
  padding:
    0.7rem
    calc(var(--safe-right) + clamp(0.85rem, 3.5vw, 1.4rem))
    calc(var(--safe-bottom) + 0.7rem)
    calc(var(--safe-left) + clamp(0.85rem, 3.5vw, 1.4rem));
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(20, 23, 28, 0.94);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  backdrop-filter: blur(18px) saturate(130%);
}

.status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  color: var(--muted);
  font-size: clamp(0.88rem, 3.7vw, 1.05rem);
  font-weight: 650;
  white-space: nowrap;
}

.status-dot {
  flex: 0 0 auto;
  width: 0.68rem;
  height: 0.68rem;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.status--listening {
  color: #80b9ff;
}

.status--listening .status-dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 0.28rem rgba(94, 164, 255, 0.16);
  animation: listening-pulse 1.4s ease-out infinite;
}

.status--error {
  color: #ffaaa5;
  white-space: normal;
}

.status--error .status-dot {
  border-color: var(--danger);
  background: linear-gradient(90deg, transparent 40%, var(--danger) 40% 60%, transparent 60%);
}

.actions {
  display: flex;
  gap: 0.55rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-width: 5.2rem;
  min-height: 3.25rem;
  padding: 0.65rem 1.05rem;
  border: 0;
  border-radius: 1rem;
  color: var(--text);
  font-size: 1rem;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.button--primary {
  background: var(--accent-strong);
  box-shadow: 0 0.25rem 1.1rem rgba(47, 131, 245, 0.22);
}

.button--primary.is-stopping {
  color: #250303;
  background: var(--danger);
  box-shadow: 0 0.25rem 1.1rem rgba(255, 102, 95, 0.2);
}

.button--secondary {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--surface-raised);
}

.button:active {
  transform: scale(0.97);
}

.button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.button:disabled {
  opacity: 0.4;
  cursor: default;
}

.mic-icon {
  position: relative;
  width: 1.05rem;
  height: 1.25rem;
}

.mic-capsule {
  position: absolute;
  top: 0;
  left: 50%;
  width: 0.55rem;
  height: 0.82rem;
  border: 2px solid currentColor;
  border-radius: 0.55rem;
  transform: translateX(-50%);
}

.mic-stem {
  position: absolute;
  right: 0.08rem;
  bottom: 0.14rem;
  left: 0.08rem;
  height: 0.65rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  border-radius: 0 0 0.55rem 0.55rem;
}

.mic-stem::after {
  content: "";
  position: absolute;
  bottom: -0.3rem;
  left: 50%;
  width: 0.55rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: translateX(-50%);
}

noscript {
  position: fixed;
  inset: 1rem;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: var(--bg);
  color: var(--text);
  font: 700 1.5rem/1.3 system-ui, sans-serif;
  text-align: center;
}

@keyframes listening-pulse {
  70%,
  100% {
    box-shadow: 0 0 0 0.6rem rgba(94, 164, 255, 0);
  }
}

@keyframes pulse-caret {
  to {
    opacity: 0.25;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .app {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 1fr;
  }

  .transcript-panel {
    padding:
      calc(var(--safe-top) + 0.8rem)
      clamp(1rem, 3vw, 2.4rem)
      calc(var(--safe-bottom) + 0.8rem)
      calc(var(--safe-left) + clamp(1.1rem, 3vw, 2.4rem));
  }

  .transcript {
    font-size: clamp(3.4rem, min(10vw, 19vh), 7.5rem);
  }

  .transcript--medium {
    font-size: clamp(2.8rem, min(8vw, 16vh), 6rem);
  }

  .transcript--long {
    font-size: clamp(2.1rem, min(6.2vw, 13vh), 4.5rem);
  }

  .transcript--dense {
    font-size: clamp(1.55rem, min(4.6vw, 10vh), 3.4rem);
  }

  .transcript--empty {
    font-size: clamp(2.6rem, min(7.4vw, 16vh), 5.8rem);
  }

  .control-dock {
    grid-template-columns: 1fr;
    align-content: center;
    width: calc(7.6rem + var(--safe-right));
    min-height: 0;
    padding:
      calc(var(--safe-top) + 0.7rem)
      calc(var(--safe-right) + 0.7rem)
      calc(var(--safe-bottom) + 0.7rem)
      0.7rem;
    border-top: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.09);
  }

  .status {
    justify-content: center;
    font-size: 0.8rem;
    white-space: normal;
    text-align: center;
  }

  .actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
    min-width: 0;
    min-height: 3rem;
    padding-inline: 0.7rem;
  }
}

@media (max-width: 350px) and (orientation: portrait) {
  .control-dock {
    gap: 0.5rem;
  }

  .button {
    min-width: 4.7rem;
    padding-inline: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
