:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: #10161b;
  --panel-soft: #182028;
  --text: #f4fbff;
  --muted: #b7c5cd;
  --line: rgba(255, 255, 255, 0.14);
  --cyan: #25c6d9;
  --cyan-dark: #097887;
  --red: #ff3b3b;
  --red-glow: rgba(255, 59, 59, 0.5);
  --amber: #f0b429;
  --amber-glow: rgba(240, 180, 41, 0.42);
  --gray: #8b98a1;
  --gray-glow: rgba(139, 152, 161, 0.26);
  --danger-bg: #2c1114;
  --danger-line: rgba(255, 80, 80, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0%, rgba(37, 198, 217, 0.18), transparent 32rem),
    linear-gradient(180deg, #05070a 0%, #0b1115 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.voice-shell {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.voice-panel {
  width: min(100%, 500px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 22, 27, 0.92);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.voice-analysis-mode .voice-panel {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.voice-analysis-mode .voice-panel > :not(.brand-logo):not(.analysis-loading-panel) {
  display: none !important;
}

.voice-analysis-mode .voiceAnnouncementCarousel {
  display: none;
}

.brand-logo {
  width: min(62vw, 288px);
  height: auto;
  display: block;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  align-self: center;
}

.voice-analysis-mode .brand-logo {
  animation: analysis-logo-pulse 1.8s ease-in-out infinite;
}

.voice-analysis-ending .brand-logo {
  animation: none;
  opacity: 1;
  filter: none;
}

.voice-back-link {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 4px 2px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.voice-back-link:hover,
.voice-back-link:focus-visible {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.voiceAnnouncementCarousel {
  width: min(100%, 500px);
}

.voiceCarouselViewport {
  width: 100%;
  aspect-ratio: 5 / 3;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.voiceCarouselItem {
  display: none;
  width: 100%;
  height: 100%;
}

.voiceCarouselItem.is-active {
  display: block;
}

.voiceCarouselVideo {
  display: block;
  width: 100%;
  height: 100%;
  background: #020712;
  object-fit: contain;
}

.voiceCarouselControls {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.voiceAnnouncementCarousel.has-multiple .voiceCarouselControls {
  display: flex;
}

.voiceCarouselArrow {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.voiceCarouselDots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.voiceCarouselDot {
  width: 7px;
  height: 7px;
  border: 0;
  border-radius: 999px;
  background: var(--muted);
  opacity: 0.55;
  padding: 0;
  cursor: pointer;
}

.voiceCarouselDot.is-active {
  background: var(--cyan);
  opacity: 1;
}

.status-card {
  width: 100%;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.status-light {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--gray);
  box-shadow: 0 0 0 6px var(--gray-glow), 0 0 20px var(--gray-glow);
}

.status-idle {
  background: var(--gray);
  box-shadow: 0 0 0 6px var(--gray-glow), 0 0 20px var(--gray-glow);
}

.status-permission {
  background: var(--amber);
  box-shadow: 0 0 0 6px var(--amber-glow), 0 0 24px var(--amber-glow);
}

.status-listening {
  background: var(--red);
  box-shadow: 0 0 0 7px var(--red-glow), 0 0 34px var(--red-glow);
  animation: listening-pulse 2.4s ease-in-out infinite;
}

.status-paused {
  background: var(--gray);
  box-shadow: 0 0 0 6px var(--gray-glow), 0 0 20px var(--gray-glow);
}

.status-text {
  font-size: 1.18rem;
  font-weight: 780;
}

.waveform-shell {
  width: 100%;
  padding: 0;
  border: 1px solid rgba(0, 255, 223, 0.54);
  border-radius: 8px;
  background: #01040d;
  box-shadow: inset 0 0 0 1px rgba(0, 255, 223, 0.12), 0 0 32px rgba(0, 123, 247, 0.22);
  overflow: hidden;
}

.waveform-canvas {
  width: 100%;
  height: 128px;
  min-height: 128px;
  display: block;
}

.risk-banner {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--danger-line);
  border-radius: 8px;
  color: #fff3f3;
  background: var(--danger-bg);
}

.risk-banner[hidden] {
  display: none;
}

.risk-banner strong {
  color: #ffb0b0;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.risk-reason {
  color: #ffd5d5;
  font-size: 0.9rem;
  line-height: 1.35;
}

.control-stack {
  width: 100%;
  display: grid;
  gap: 10px;
}

.listen-button {
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  color: #001418;
  background: linear-gradient(180deg, #43e0ef, var(--cyan));
  font: inherit;
  font-size: 1.08rem;
  font-weight: 850;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 12px 28px rgba(37, 198, 217, 0.22);
}

.secondary-button,
.tertiary-button {
  width: 100%;
  min-height: 54px;
  border-radius: 8px;
  font: inherit;
  font-size: 1rem;
  font-weight: 850;
  cursor: pointer;
  touch-action: manipulation;
}

.secondary-button {
  border: 1px solid rgba(0, 255, 223, 0.38);
  color: #dcffff;
  background: linear-gradient(180deg, rgba(0, 123, 247, 0.34), rgba(0, 80, 150, 0.42));
}

.report-button {
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff5f5;
  background: linear-gradient(180deg, #d23232, #a81919);
  font: inherit;
  font-size: 1rem;
  font-weight: 850;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 12px 28px rgba(255, 59, 59, 0.18);
}

.tertiary-button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f1f5f7;
  background: rgba(255, 255, 255, 0.06);
}

.listen-button[hidden],
.secondary-button[hidden],
.tertiary-button[hidden],
.report-button[hidden] {
  display: none;
}

.listen-button:active,
.secondary-button:active,
.tertiary-button:active,
.report-button:active {
  transform: translateY(1px);
}

.listen-button:focus-visible,
.secondary-button:focus-visible,
.tertiary-button:focus-visible,
.report-button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 4px;
}

.error-message,
.report-message {
  width: 100%;
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.45;
  text-align: center;
}

.error-message,
.report-message {
  padding: 12px;
  border-radius: 8px;
}

.error-message {
  border: 1px solid rgba(240, 180, 41, 0.35);
  color: #fff4cf;
  background: rgba(91, 63, 0, 0.32);
}

.report-message {
  border: 1px solid rgba(37, 198, 217, 0.32);
  color: #dffbff;
  background: rgba(37, 198, 217, 0.12);
}

.error-message[hidden],
.report-message[hidden] {
  display: none;
}

.results-panel,
.debug-transcript {
  width: 100%;
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  text-align: left;
}

.results-panel {
  border: 1px solid rgba(37, 198, 217, 0.32);
  color: #e7fcff;
  background: rgba(37, 198, 217, 0.1);
}

#resultsPanel.results-panel {
  gap: 14px;
  padding: 0;
  border: 0;
  color: #111827;
  background: transparent;
}

.voice-results-heading {
  margin: 0;
  color: var(--cyan);
  font-size: 1.05rem;
  line-height: 1.2;
}

.voice-results-heading:focus {
  outline: none;
}

.voice-score-card {
  width: 100%;
  min-height: 104px;
  display: grid;
  grid-template-columns: minmax(118px, 34%) 1px 1fr;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  border: 2px solid currentColor;
  border-radius: 14px;
  color: #9aa3af;
  background: #101010;
  box-shadow: 0 0 18px rgba(154, 163, 175, 0.28);
}

.voice-score-card.danger {
  color: #ff2727;
  box-shadow: 0 0 18px rgba(255, 39, 39, 0.5);
}

.voice-score-card.warning {
  color: #ff6a00;
  box-shadow: 0 0 18px rgba(255, 106, 0, 0.45);
}

.voice-score-card.caution {
  color: #ffb020;
  box-shadow: 0 0 18px rgba(255, 176, 32, 0.42);
}

.voice-score-card.safe {
  color: #00d084;
  box-shadow: 0 0 18px rgba(0, 208, 132, 0.42);
}

.voice-trust-status,
.voice-trust-score {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.voice-trust-status {
  align-items: center;
  gap: 6px;
  text-align: center;
}

.voice-trust-score {
  align-items: flex-start;
  gap: 6px;
}

.voice-trust-divider {
  width: 1px;
  height: 66px;
  background: rgba(32, 191, 216, 0.28);
}

.voice-trust-shield {
  width: 54px;
  height: 62px;
  color: inherit;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.voice-shield-outline {
  stroke-width: 2;
}

.voice-shield-mark {
  stroke-width: 3;
}

.voice-score-tier {
  color: currentColor;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
}

.voice-score-label {
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
}

.voice-score-value {
  color: currentColor;
  font-size: clamp(2rem, 9vw, 2.65rem);
  font-weight: 900;
  line-height: 1;
}

.voice-result-card {
  width: 100%;
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 14px;
  color: #111827;
  background: #ffffff;
  text-align: left;
}

.voice-result-card h3 {
  margin: 0;
  color: var(--cyan);
  font-size: 1.25rem;
  line-height: 1.2;
}

.voice-result-card h4 {
  margin: 0 0 7px;
  color: #111827;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.25;
}

.voice-result-card p {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.55;
}

.voice-result-list {
  margin: 0;
  padding-left: 22px;
}

.voice-result-list li {
  font-size: 0.96rem;
  line-height: 1.5;
}

.voice-result-list li + li {
  margin-top: 7px;
}

.voice-adviser-card {
  border-color: rgba(37, 198, 217, 0.38);
  box-shadow: inset 0 0 18px rgba(37, 198, 217, 0.06);
}

.voice-adviser-summary {
  margin: 0;
}

.voice-adviser-subsection {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid rgba(15, 23, 42, 0.12);
}

.voice-urgent-section {
  margin-top: 6px;
  padding: 12px;
  border: 1px solid rgba(239, 68, 68, 0.32);
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.09);
}

.voice-suggested-reply {
  margin: 0;
  padding: 12px;
  border-left: 4px solid var(--cyan);
  border-radius: 8px;
  background: rgba(37, 198, 217, 0.08);
  white-space: pre-wrap;
}

.voice-results-footer {
  width: 100%;
  display: grid;
  gap: 6px;
  color: rgba(231, 252, 255, 0.7);
  font-size: 0.82rem;
  line-height: 1.4;
}

.voice-results-footer p {
  margin: 0;
}

.analysis-loading-panel {
  align-items: center;
  gap: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
}

.analysis-video {
  width: 100%;
  max-width: 500px;
  height: auto;
  margin: 0 auto;
  display: block;
  border-radius: 8px;
  background: #020712;
  opacity: 1;
  transition: opacity 300ms ease;
}

.voice-analysis-ending .analysis-video {
  opacity: 0;
}

.analysis-loading-text {
  color: #e7fcff;
  font-weight: 760;
}

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

.results-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.debug-transcript {
  border: 1px dashed rgba(255, 255, 255, 0.26);
  color: #d9e7ee;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.86rem;
  line-height: 1.4;
  max-height: 160px;
  overflow: auto;
}

.debug-transcript strong {
  color: #ffffff;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.results-panel[hidden],
.analysis-loading-panel[hidden],
.debug-transcript[hidden] {
  display: none;
}

@keyframes listening-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 6px rgba(255, 59, 59, 0.36), 0 0 24px rgba(255, 59, 59, 0.42);
  }
  50% {
    box-shadow: 0 0 0 9px rgba(255, 59, 59, 0.48), 0 0 42px rgba(255, 59, 59, 0.58);
  }
}

@keyframes analysis-logo-pulse {
  0%,
  100% {
    opacity: 0.56;
    filter: drop-shadow(0 0 8px rgba(37, 198, 217, 0.24));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 18px rgba(37, 198, 217, 0.72));
  }
}

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

  .status-listening {
    animation: none;
  }

  .listen-button:active {
    transform: none;
  }

  .secondary-button:active,
  .tertiary-button:active,
  .report-button:active {
    transform: none;
  }

}

@media (max-width: 360px) {
  .voice-panel {
    padding: 18px 14px 16px;
    gap: 12px;
  }

  .brand-logo {
    width: 252px;
  }

  .waveform-canvas {
    height: 112px;
    min-height: 112px;
  }

  .voice-score-card {
    min-height: 92px;
    grid-template-columns: minmax(92px, 32%) 1px 1fr;
    gap: 12px;
    padding: 12px;
  }

  .voice-trust-divider {
    height: 56px;
  }

  .voice-trust-shield {
    width: 42px;
    height: 48px;
  }

  .voice-score-tier {
    font-size: 0.78rem;
  }

  .voice-score-label {
    font-size: 0.68rem;
  }

  .voice-result-card {
    padding: 14px;
  }
}
