:root {
  color-scheme: dark;
  --bg: #07080b;
  --bg-soft: #0c0f15;
  --panel: rgba(20, 25, 34, 0.92);
  --panel-strong: rgba(244, 242, 223, 0.98);
  --text: #f7f3d6;
  --text-muted: #91a0ae;
  --text-soft: #c8d1db;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #f5f1d5;
  --accent-text: #11151b;
  --danger: #ff7a7a;
  --ok: #79e6b0;
  --radius-lg: 28px;
  --radius-md: 18px;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.55);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "PingFang SC", "Hiragino Sans", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
}

button,
select,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100dvh;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding:
    max(18px, env(safe-area-inset-top))
    clamp(16px, 4vw, 34px)
    max(18px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: clamp(14px, 3dvh, 26px);
  background:
    radial-gradient(circle at 50% 112%, rgba(255, 244, 188, 0.13), transparent 34%),
    linear-gradient(180deg, #080a0f 0%, #06070a 52%, #050608 100%);
}

.topbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.status-pill {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(15px, 3.8vw, 20px);
  font-weight: 650;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: #68727e;
  box-shadow: 0 0 0 0 rgba(120, 230, 176, 0.0);
}

.status-dot.listening {
  background: var(--ok);
  box-shadow: 0 0 0 8px rgba(121, 230, 176, 0.12);
}

.status-dot.connecting {
  background: #ffd36b;
  box-shadow: 0 0 0 8px rgba(255, 211, 107, 0.10);
}

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

.mode-strip {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: #a7b2be;
  font-size: clamp(12px, 2.8vw, 16px);
  font-weight: 650;
  text-transform: uppercase;
}

.model-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-select {
  min-height: 36px;
  max-width: 92px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  padding: 0 10px;
  outline: none;
}

.language-select:focus-visible,
.control-btn:focus-visible,
.access-panel input:focus-visible,
.access-panel button:focus-visible {
  outline: 3px solid rgba(245, 241, 213, 0.72);
  outline-offset: 3px;
}

.access-panel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-soft);
}

.access-panel input {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.22);
  padding: 0 12px;
}

.access-panel button {
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  color: var(--accent-text);
  background: var(--accent);
  padding: 0 14px;
  font-weight: 750;
}

.stage {
  position: relative;
  min-height: 0;
  display: flex;
  align-items: flex-end;
}

.empty-hint {
  position: absolute;
  top: clamp(60px, 13dvh, 160px);
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(200, 209, 219, 0.35);
  font-size: clamp(15px, 3.2vw, 18px);
  line-height: 1.6;
  pointer-events: none;
}

.empty-hint.hidden {
  opacity: 0;
}

.caption-card {
  width: 100%;
  max-height: 58dvh;
  overflow-y: auto;
  padding: clamp(10px, 2.5vw, 18px) 2px 0 0;
  text-shadow: 0 8px 34px rgba(0, 0, 0, 0.86);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.caption-card::-webkit-scrollbar {
  display: none;
}

.source-caption,
.target-caption {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  line-break: auto;
}

.source-caption {
  min-height: 0;
  color: rgba(207, 217, 229, 0.78);
  font-size: clamp(13px, 3.4vw, 18px);
  line-height: 1.34;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.target-caption {
  min-height: 0;
  margin-top: clamp(8px, 1.8dvh, 14px);
  color: var(--text);
  font-size: clamp(20px, 5.8vw, 34px);
  line-height: 1.2;
  font-weight: 850;
  letter-spacing: -0.02em;
}

.controls {
  display: grid;
  grid-template-columns: minmax(150px, 1.35fr) repeat(3, minmax(70px, 0.55fr));
  gap: clamp(10px, 2.8vw, 18px);
}

.control-btn {
  min-height: clamp(64px, 13vw, 92px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  color: var(--text);
  background: #171d28;
  box-shadow: var(--shadow);
  font-size: clamp(17px, 4.4vw, 24px);
  font-weight: 780;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, opacity 160ms ease;
}

.control-btn:active {
  transform: scale(0.985);
}

.control-btn.primary {
  color: var(--accent-text);
  background: var(--panel-strong);
  font-size: clamp(21px, 5vw, 28px);
}

.control-btn[disabled] {
  cursor: wait;
  opacity: 0.62;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%);
  width: min(92vw, 520px);
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  color: #fff;
  background: rgba(17, 22, 31, 0.94);
  box-shadow: var(--shadow);
  text-align: center;
  font-size: 14px;
  z-index: 10;
}

.high-contrast {
  --bg: #000;
  --text: #fffbd3;
  --text-muted: #cbd7e4;
  --accent: #ffffff;
}

.app-shell.high-contrast {
  background: #000;
}

.app-shell.high-contrast .source-caption {
  color: rgba(255, 255, 255, 0.86);
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
  }

  .mode-strip {
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
  }

  .controls {
    grid-template-columns: 1.35fr repeat(3, 0.55fr);
  }

  .control-btn {
    border-radius: 17px;
  }
}

@media (min-width: 760px) {
  .app-shell {
    max-width: 760px;
    padding-left: 32px;
    padding-right: 32px;
    gap: 18px;
  }

  .stage {
    align-items: center;
  }

  .caption-card {
    max-height: 52dvh;
    padding-top: 0;
    padding-bottom: 0;
  }

  .source-caption {
    font-size: clamp(14px, 1.8vw, 18px);
    line-height: 1.3;
  }

  .target-caption {
    font-size: clamp(24px, 3.4vw, 38px);
    line-height: 1.18;
    letter-spacing: -0.015em;
  }

  .controls {
    max-width: 620px;
    width: 100%;
    margin: 0 auto;
    gap: 12px;
  }

  .control-btn {
    min-height: 64px;
    font-size: 18px;
  }

  .control-btn.primary {
    font-size: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .control-btn {
    transition: none;
  }
}
