:root {
  --bg: #0e1116;
  --surface: #171c24;
  --surface-2: #1f2630;
  --border: #2a323d;
  --text: #e6e9ef;
  --muted: #8b94a3;
  --accent: #5b8cff;
  --accent-hover: #4a7bf0;
  --danger: #e5534b;
  --ok: #3fb950;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ---------- Auth ---------- */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2330, var(--bg));
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 380px;
  box-shadow: var(--shadow); text-align: center;
}
.auth-logo { font-size: 1.8rem; font-weight: 700; margin-bottom: .25rem; }
.auth-sub { color: var(--muted); margin: 0 0 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; text-align: left; }
.auth-form label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; color: var(--muted); }
.auth-error {
  background: rgba(229,83,75,.12); border: 1px solid rgba(229,83,75,.4);
  color: #ff9b94; padding: .6rem .8rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
  padding: 1rem 1.5rem; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.2rem; }
.topnav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.who { color: var(--text); font-size: .9rem; display: inline-flex; align-items: center; gap: .4rem; }
.navlink { color: var(--muted); text-decoration: none; font-size: .9rem; }
.navlink:hover { color: var(--text); }
.logout { color: var(--muted); text-decoration: none; font-size: .9rem; }
.logout:hover { color: var(--text); }

/* Petites etiquettes (role admin, "vous", etc.) */
.badge {
  background: rgba(91,140,255,.16); color: var(--accent);
  border: 1px solid rgba(91,140,255,.4);
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; padding: .08rem .4rem; border-radius: 999px;
}
.tag {
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
  font-size: .7rem; padding: .08rem .45rem; border-radius: 999px;
}
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--text); margin: .25rem 0 1rem; cursor: pointer; }
.check input { width: auto; }
.voice-info { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.error-text { color: #ff9b94; font-size: .9rem; }

/* ---------- Layout ---------- */
.container {
  max-width: 760px; margin: 2rem auto; padding: 0 1rem;
  display: flex; flex-direction: column; gap: 1.5rem;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 1.2rem; font-size: 1.15rem; }
.card h3 { margin: 0 0 .8rem; font-size: 1rem; color: var(--muted); }
.muted { color: var(--muted); font-weight: 400; font-size: .85rem; }

/* ---------- Form fields ---------- */
.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; font-size: .9rem; color: var(--muted); }
.field.grow { flex: 1; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

textarea, input[type=text], input[type=password], select {
  width: 100%; padding: .65rem .8rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  font-size: .95rem; font-family: inherit;
}
textarea { resize: vertical; }
textarea:focus, input:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(91,140,255,.2);
}
input[type=file] { color: var(--muted); font-size: .85rem; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-ghost, .btn-danger {
  border: none; border-radius: 8px; padding: .6rem 1.1rem;
  font-size: .9rem; font-weight: 600; cursor: pointer; font-family: inherit;
  text-decoration: none; display: inline-flex; align-items: center; gap: .4rem;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(229,83,75,.4); }
.btn-danger:hover { background: rgba(229,83,75,.12); }

.actions { display: flex; align-items: center; gap: 1rem; margin-top: .5rem; }
.status { font-size: .88rem; color: var(--muted); }
.status.err, .status.error { color: #ff9b94; }
.status.ok { color: var(--ok); }
.hint { font-size: .82rem; color: var(--muted); }

/* ---------- Clone panel ---------- */
.clone-panel {
  background: var(--surface-2); border: 1px dashed var(--border);
  border-radius: 8px; padding: 1rem; margin-bottom: 1rem;
}
.clone-new {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 1.2rem; margin-bottom: 1.5rem;
}

/* ---------- Result ---------- */
.result {
  margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 1rem; align-items: flex-start;
}
.result audio { width: 100%; }

/* ---------- Voice list ---------- */
.voice-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.voice-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: .7rem 1rem;
}
.voice-name { font-weight: 500; }
.voice-actions { display: flex; gap: .5rem; }

.hidden { display: none !important; }

/* ---------- Responsive mobile ---------- */
@media (max-width: 640px) {
  .topbar { padding: .8rem 1rem; }
  .brand { font-size: 1.1rem; }
  .topnav { gap: .8rem; width: 100%; justify-content: flex-start; }
  .topnav .who { order: -1; flex: 1 1 100%; }

  .container { margin: 1.2rem auto; gap: 1rem; }
  .card { padding: 1.1rem; border-radius: 10px; }
  .card h2 { font-size: 1.05rem; margin-bottom: 1rem; }

  /* Les rangees passent en colonne et les champs prennent toute la largeur. */
  .row { flex-direction: column; align-items: stretch; gap: .8rem; }
  .row .field { margin-bottom: 0; }

  /* Boutons pleine largeur et confortables au pouce. */
  .actions { flex-direction: column; align-items: stretch; gap: .7rem; }
  .actions .status { text-align: center; }
  .btn-primary, .btn-ghost, .btn-danger { width: 100%; justify-content: center; padding: .8rem 1rem; }
  input[type=file] { width: 100%; }

  /* Le panneau de clonage inline : boutons empiles. */
  .clone-panel .row .btn-ghost { width: 100%; }

  /* Liste des voix / comptes : empile l'info au-dessus des actions. */
  .voice-item { flex-direction: column; gap: .7rem; align-items: stretch; }
  .voice-actions { width: 100%; }
  .voice-actions .btn-primary,
  .voice-actions .btn-ghost,
  .voice-actions .btn-danger { flex: 1; }

  .result a.btn-primary { width: 100%; }
}

/* Tablettes etroites : on garde 1 colonne mais un peu plus d'air. */
@media (min-width: 641px) and (max-width: 820px) {
  .container { padding: 0 1.2rem; }
}

/* ---------- Quota ElevenLabs ---------- */
.quota {
  font-size: .82rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem .75rem;
  margin: .25rem 0 .75rem;
}
.quota.quota-low {
  color: #ffb4ae;
  border-color: var(--danger);
}
