:root {
  color-scheme: dark light;
  --bg: #111318;
  --panel: #1b1e26;
  --text: #f2f3f5;
  --muted: #9aa0ab;
  --accent: #4f8cff;
  --danger: #ff5a5a;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --text: #14161b;
    --muted: #5b606b;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.lang-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 16px;
}

.lang-pill {
  background: var(--panel);
  color: var(--text);
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
}

.swap-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  padding: 4px 0;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 16px;
  overflow-y: auto;
}

.transcript-area,
.translation-area {
  background: var(--panel);
  border-radius: 16px;
  padding: 16px;
  position: relative;
}

.translation-area:not(#thirdTranslationArea) {
  border: 1px solid #d4af37;
  box-shadow:
    0 0 12px rgba(212, 175, 55, 0.45),
    0 0 24px rgba(212, 175, 55, 0.25),
    inset 0 0 16px rgba(212, 175, 55, 0.08);
}

.label {
  margin: 0 0 6px;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.transcript {
  margin: 0;
  font-size: 1.1rem;
  min-height: 1.4em;
}

.translation {
  margin: 0;
  font-size: 1.92rem;
  font-weight: 600;
  min-height: 1.92em;
  color: #f0c85a;
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.replay-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.3rem;
}

.replay-btn.no-voice {
  color: #ff3b30;
  filter: drop-shadow(0 0 4px rgba(255, 59, 48, 0.7));
}

.status {
  min-height: 1.2em;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.controls {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.toggle-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: auto;
}

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

#apiKeyDialog .toggle {
  margin: 8px 0 16px;
  font-size: 0.85rem;
  color: var(--muted);
}

.settings-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 4px 6px;
  line-height: 1;
}

.talk-btn {
  align-self: center;
  width: 100%;
  max-width: 320px;
  padding: 22px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.talk-btn.recording {
  background: var(--danger);
}

.lang-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 50vh;
  overflow-y: auto;
}

.lang-list li button {
  width: 100%;
  text-align: left;
  padding: 10px;
  background: none;
  border: none;
  font-size: 1rem;
  color: inherit;
}

dialog {
  border: none;
  border-radius: 16px;
  padding: 20px;
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

#secretInput,
#apiKeyInput {
  width: 100%;
  padding: 10px;
  margin: 12px 0;
  border-radius: 8px;
  border: 1px solid var(--muted);
  background: transparent;
  color: var(--text);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
