:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #334155;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --mine: #4f46e5;
  --theirs: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --danger: #ef4444;
  --ok: #22c55e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1e293b, var(--bg));
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 16px;
}

.app-header { text-align: center; margin: 8px 0 16px; }
.app-header h1 { margin: 0; font-size: 1.5rem; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }

.controls { margin-bottom: 12px; }
.lang-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--panel);
  padding: 10px;
  border-radius: 14px;
}
.lang-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lang-row select {
  margin-top: 4px;
  padding: 10px;
  border-radius: 10px;
  border: none;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.95rem;
}
.swap {
  background: var(--panel-2);
  border: none;
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}
.swap:hover { background: var(--accent); transform: rotate(180deg); }

.conversation {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.empty-hint {
  text-align: center;
  color: var(--muted);
  margin: auto;
  font-size: 0.95rem;
}

.bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.4;
  word-wrap: break-word;
  animation: pop 0.18s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bubble.mine {
  align-self: flex-end;
  background: var(--mine);
  border-bottom-right-radius: 4px;
}
.bubble.theirs {
  align-self: flex-start;
  background: var(--theirs);
  border-bottom-left-radius: 4px;
}
.bubble .orig { font-size: 1rem; }
.bubble .trans {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.18);
  font-size: 1rem;
  font-weight: 600;
}
.bubble .meta {
  margin-top: 6px;
  font-size: 0.68rem;
  opacity: 0.7;
  display: flex;
  gap: 8px;
  align-items: center;
}
.bubble .play {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  border-radius: 12px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 0.7rem;
}

.composer {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--panel);
  border-radius: 16px;
  margin-top: 8px;
}
.composer input {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--panel-2);
  color: var(--text);
  font-size: 1rem;
}
.composer input:focus { outline: 2px solid var(--accent); }

.send, .mic {
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.2rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s, background 0.2s;
}
.send { background: var(--accent); color: #fff; }
.send:hover { transform: scale(1.05); }
.mic {
  background: var(--accent-2);
  color: #fff;
  position: relative;
}
.mic:hover { transform: scale(1.05); }
.mic.listening {
  background: var(--danger);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.6); }
  70%  { box-shadow: 0 0 0 14px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

.status {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 18px;
  margin-top: 6px;
}
.status.error { color: var(--danger); }
.status.busy::after {
  content: " …";
}

.debug {
  margin: 6px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}
.debug summary {
  cursor: pointer;
  user-select: none;
  opacity: 0.8;
}
.debug-log {
  margin-top: 4px;
  max-height: 120px;
  overflow-y: auto;
  background: #0b1220;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 6px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  line-height: 1.5;
  color: #94a3b8;
}
.debug-log:empty::before {
  content: "Tap the mic — steps and any errors will appear here.";
  opacity: 0.6;
}
