:root {
  --bg: #12121f;
  --surface: #1e1e32;
  --surface-2: #28283f;
  --accent: #4f8cff;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --text: #f1f1f6;
  --text-dim: #9c9cb5;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}

.app-header h1 { font-size: 1.15rem; font-weight: 700; }

.icon-btn {
  background: var(--surface);
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
}

/* ---- Langues ---- */
.lang-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 4px 16px 10px;
}

.lang-select { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.lang-select label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.lang-select select {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--surface-2);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
}

.icon-btn.swap { flex-shrink: 0; margin-bottom: 1px; }

/* ---- Onglets ---- */
.tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px 8px;
}

.tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.tab.active { background: var(--accent); color: #fff; }

/* ---- Conversation ---- */
.conversation {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hint {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 24px;
}

.bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.45;
  animation: pop 0.15s ease-out;
}

@keyframes pop { from { transform: scale(0.95); opacity: 0; } }

.bubble.them { align-self: flex-start; background: var(--surface-2); }
.bubble.me   { align-self: flex-end;   background: #1d4ed8; }

.bubble .original {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.bubble.me .original { color: #bfdbfe; }

.bubble .translated { font-size: 1.05rem; font-weight: 500; }

.bubble .translated.pending { color: var(--text-dim); font-style: italic; }

.bubble .replay {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  margin-left: 6px;
  vertical-align: middle;
}

/* ---- Interim + status ---- */
.interim {
  margin: 0 16px 4px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.95rem;
}

.status {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 2px 16px 6px;
  min-height: 1.4em;
}

.status.listening { color: var(--accent-2); }
.status.error { color: var(--danger); }

/* ---- Panneaux ---- */
.panel { padding: 6px 16px calc(16px + env(safe-area-inset-bottom)); }

.mic-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent-2);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.mic-btn .mic-icon { font-size: 1.5rem; }

.mic-btn.on {
  background: var(--danger);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  70%  { box-shadow: 0 0 0 16px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.reply-row { display: flex; gap: 8px; align-items: stretch; }

#reply-text {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--surface-2);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  resize: none;
}

.round-btn {
  width: 54px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
}

.round-btn.on { background: var(--danger); animation: pulse 1.4s infinite; }

.send-btn {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.send-btn:disabled { opacity: 0.5; }

/* ---- Réglages ---- */
dialog {
  margin: auto;
  width: min(92vw, 420px);
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 20px;
}

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

dialog h2 { margin-bottom: 14px; font-size: 1.1rem; }

.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.95rem;
}

.setting-row.column { flex-direction: column; align-items: stretch; }

.setting-row input[type="email"] {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--surface-2);
  background: var(--bg);
  color: var(--text);
}

.setting-row input[type="range"] { flex: 1; }

.setting-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.setting-actions button {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.setting-actions .danger { background: var(--danger); color: #fff; }

.about {
  margin-top: 16px;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}
