:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #07111f;
  color: #e5edf7;
  --surface: rgba(15, 23, 42, 0.88);
  --surface-2: rgba(30, 41, 59, 0.8);
  --border: rgba(148, 163, 184, 0.18);
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --green: #34d399;
  --red: #fb7185;
  --amber: #fbbf24;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 10% 0%, rgba(14, 165, 233, 0.16), transparent 30rem),
    #07111f;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
select,
textarea,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding:
    max(24px, env(safe-area-inset-top))
    18px
    max(34px, env(safe-area-inset-bottom));
}

.hero {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px 2px 22px;
}

.brand-mark {
  width: 62px;
  height: 62px;
  flex: 0 0 62px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  font-size: 32px;
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.2), rgba(14, 165, 233, 0.06));
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 800;
  color: #7dd3fc;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 5px;
  font-size: clamp(2rem, 8vw, 3rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.95rem;
}

.card,
.status-card {
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.2);
  margin-bottom: 15px;
}

.status-card {
  padding: 14px 16px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-row strong {
  font-size: 1rem;
}

.status-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.status-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex: 0 0 13px;
  background: var(--muted);
  box-shadow: 0 0 0 5px rgba(148, 163, 184, 0.08);
}

.status-dot.listening {
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.12);
  animation: pulse 1.3s infinite;
}

.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(251, 113, 133, 0.1);
}

.status-dot.speaking {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.12);
}

@keyframes pulse {
  50% {
    transform: scale(1.13);
    opacity: 0.72;
  }
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.badge {
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.badge.ok {
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(52, 211, 153, 0.18);
}

.badge.warn {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(251, 191, 36, 0.16);
}

.badge.bad {
  color: #fecdd3;
  background: rgba(244, 63, 94, 0.08);
  border-color: rgba(251, 113, 133, 0.16);
}

.controls-card label,
.advanced-card label {
  display: block;
  margin-bottom: 8px;
  color: #cbd5e1;
  font-size: 0.88rem;
  font-weight: 700;
}

select,
textarea {
  width: 100%;
  color: #f8fafc;
  background: var(--surface-2);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 14px;
  outline: none;
}

select {
  height: 52px;
  padding: 0 14px;
  margin-bottom: 15px;
}

textarea {
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.5;
}

select:focus,
textarea:focus,
input:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.28);
  outline-offset: 2px;
}

.primary-button {
  width: 100%;
  min-height: 78px;
  border: 0;
  border-radius: 20px;
  color: #00111b;
  background: linear-gradient(145deg, #7dd3fc, #38bdf8);
  font-size: 1.22rem;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.22);
}

.primary-button.active {
  color: #fff;
  background: linear-gradient(145deg, #e11d48, #be123c);
  box-shadow: 0 12px 30px rgba(225, 29, 72, 0.18);
}

.button-icon {
  margin-right: 7px;
}

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 10px;
}

.secondary-button,
.repeat-button {
  min-height: 46px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  color: #e2e8f0;
  background: rgba(30, 41, 59, 0.8);
  font-weight: 750;
}

.secondary-button:disabled,
.repeat-button:disabled {
  opacity: 0.45;
}

.full-width {
  width: 100%;
  margin-top: 9px;
}

.route-hint {
  margin: 13px 2px 0;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.45;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.listening-pill {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
  font-size: 0.72rem;
  font-weight: 800;
}

.listening-pill.active {
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.1);
}

.live-block {
  min-height: 110px;
  padding: 15px;
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.48);
  border: 1px solid rgba(148, 163, 184, 0.11);
}

.live-block.translated {
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(56, 189, 248, 0.2);
}

.live-label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.live-text {
  margin: 0;
  font-size: clamp(1.05rem, 4.6vw, 1.4rem);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.live-text.emphasized {
  color: #f0f9ff;
  font-weight: 760;
}

.muted {
  color: #cbd5e1;
}

.interim-text {
  margin: 9px 0 0;
  color: #64748b;
  font-style: italic;
  line-height: 1.4;
}

.translation-arrow {
  padding: 7px 0;
  text-align: center;
  color: #38bdf8;
  font-size: 1.3rem;
}

.repeat-button {
  width: 100%;
  margin-top: 12px;
}

.advanced-card summary {
  cursor: pointer;
  color: #dbeafe;
  font-weight: 800;
}

.advanced-card[open] summary {
  margin-bottom: 20px;
}

.slider-row {
  margin-bottom: 18px;
}

.slider-row label {
  display: flex;
  justify-content: space-between;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.text-button {
  border: 0;
  background: transparent;
  color: #7dd3fc;
  font-size: 0.82rem;
  font-weight: 800;
}

.empty-state {
  padding: 20px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  padding: 14px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.history-item:first-child {
  border-top: 0;
}

.history-original {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.history-translation {
  margin-top: 5px;
  color: #f0f9ff;
  font-weight: 720;
  line-height: 1.45;
}

.history-time {
  display: block;
  margin-top: 7px;
  color: #64748b;
  font-size: 0.68rem;
}

footer {
  padding: 8px 8px 0;
  color: #64748b;
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

@media (max-width: 480px) {
  .secondary-actions {
    grid-template-columns: 1fr;
  }

  .hero {
    align-items: flex-start;
  }

  .brand-mark {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
    border-radius: 17px;
    font-size: 27px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    scroll-behavior: auto !important;
  }
}


.language-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  margin-bottom: 16px;
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.46);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.language-flow > div {
  display: grid;
  gap: 4px;
}

.language-flow > div:last-child {
  text-align: right;
}

.flow-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.flow-arrow {
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 900;
}

.live-indicator {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: -4px 0 14px;
  opacity: 0.35;
}

.live-indicator span {
  width: 5px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent);
}

.live-indicator.active {
  opacity: 1;
}

.live-indicator.active span {
  animation: audioBar 0.9s ease-in-out infinite alternate;
}

.live-indicator.active span:nth-child(2) {
  animation-delay: 0.13s;
}

.live-indicator.active span:nth-child(3) {
  animation-delay: 0.26s;
}

.live-indicator.active span:nth-child(4) {
  animation-delay: 0.39s;
}

.live-indicator.active span:nth-child(5) {
  animation-delay: 0.52s;
}

@keyframes audioBar {
  from {
    height: 10px;
  }
  to {
    height: 36px;
  }
}

.latency-note {
  margin: 13px 3px 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.help-card h2 {
  margin-bottom: 12px;
}

.help-card ol {
  margin: 0;
  padding-left: 1.3rem;
  color: #cbd5e1;
  line-height: 1.55;
}

.help-card li + li {
  margin-top: 7px;
}

audio {
  display: none;
}

@media (max-width: 480px) {
  .language-flow {
    gap: 8px;
    font-size: 0.9rem;
  }
}
