/* Appels — thème sombre par défaut, clair au choix (data-theme="light"). */
:root {
  color-scheme: dark;
  --bg: #12100d;
  --surface: #1c1915;
  --surface-2: #26221d;
  --line: #322d26;
  --text: #f3eee6;
  --muted: #a39b8f;
  --faint: #6f685e;
  --accent: #ff6f4f;
  --accent-ink: #1a0d08;
  --accent-soft: rgba(255, 111, 79, 0.14);
  --pro: #7fb0ff;
  --pro-soft: rgba(127, 176, 255, 0.14);
  --perso: #ff8fb0;
  --perso-soft: rgba(255, 143, 176, 0.14);
  --wait: #f2c14e;
  --wait-soft: rgba(242, 193, 78, 0.15);
  --ok: #6fd39a;
  --danger: #ff6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --line: #e4ded4;
  --text: #1d1a16;
  --muted: #6e675d;
  --faint: #a49c90;
  --accent: #e5532f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(229, 83, 47, 0.1);
  --pro: #2459a6;
  --pro-soft: #e3edf9;
  --perso: #a3324c;
  --perso-soft: #f8e6ea;
  --wait: #8a6200;
  --wait-soft: #fff4d6;
  --ok: #2e7d4f;
  --danger: #c62828;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }

/* ── Mise en page ───────────────────────────────────────────── */
.app { max-width: 720px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { font-size: 22px; line-height: 1; }
main { flex: 1; padding: 12px 16px 96px; }
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { display: flex; width: 100%; max-width: 720px; }
.nav a {
  flex: 1; text-align: center; padding: 9px 0 10px; text-decoration: none;
  color: var(--muted); font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.nav a .ico { display: block; }
.nav a.on .ico { color: var(--accent); }
.nav a.on { color: var(--text); font-weight: 600; }
.nav a.add .ico { color: var(--accent); }

/* ── Éléments ───────────────────────────────────────────────── */
.icon-btn {
  border: 0; background: transparent; padding: 7px; border-radius: 10px; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.ico { flex: none; }
.search-wrap { position: relative; margin-bottom: 10px; }
.search-wrap .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search-wrap .search { margin: 0; padding-left: 38px; }
.menu .btn { gap: 10px; }
.switch .ico { color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  padding: 9px 14px; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; font-weight: 600; }
.input, textarea.input {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: none;
}
.input:focus { border-color: var(--accent); }
.search { margin-bottom: 10px; }
.chips { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 4px 12px; border-radius: 99px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.tag.pro { background: var(--pro-soft); color: var(--pro); }
.tag.perso { background: var(--perso-soft); color: var(--perso); }
.tag.wait { background: var(--wait-soft); color: var(--wait); }
.tag.err { background: rgba(255, 107, 107, 0.15); color: var(--danger); }
button.tag { border: 0; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 40px 12px; }
.banner { background: var(--wait-soft); color: var(--text); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.banner.info { background: var(--accent-soft); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 18px 0 8px; font-weight: 700; }

/* ── Liste d'appels ─────────────────────────────────────────── */
.row {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 11px 13px; margin-bottom: 9px;
}
.row:active { transform: scale(0.995); }
.row.pending { border-color: var(--wait); }
.row-head { display: flex; align-items: center; gap: 8px; }
.row-title { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.row-sum { font-size: 13.5px; margin-top: 5px; color: var(--text); opacity: 0.88; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.steps { font-size: 12.5px; margin-top: 7px; display: grid; gap: 2px; }
.steps .done { color: var(--ok); }
.steps .now { color: var(--wait); }
.steps .later { color: var(--faint); }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin: 8px 0 4px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width 0.2s; }
.ask-name { background: var(--wait-soft); border-radius: 10px; padding: 9px 10px; margin-top: 8px; font-size: 13.5px; display: grid; gap: 7px; }
.ask-name .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Fiche d'un appel ───────────────────────────────────────── */
.call-head { margin-bottom: 12px; }
.call-head .meta { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.player { width: 100%; margin: 4px 0 12px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; position: sticky; top: 58px; z-index: 3; background: var(--bg); padding: 6px 0; }
.tabs button { flex: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 0; cursor: pointer; font-size: 13.5px; }
.tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 13px; margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.card-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.card p { margin: 0; }
.card ul { margin: 0; padding-left: 18px; }
.card li { margin: 3px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.two .card { margin: 0; }
.who { font-weight: 700; font-size: 13px; margin-bottom: 3px; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.task input { width: 19px; height: 19px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.task.done span { text-decoration: line-through; color: var(--muted); }
.line { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line .t { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 0; font-variant-numeric: tabular-nums; align-self: start; margin-top: 2px; }
.line .sp { font-weight: 700; font-size: 13px; }
.line .sp.me { color: var(--accent); }
.line .tx { grid-column: 2; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }
.err-box { border: 1px solid var(--danger); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }

/* ── Questions à l'IA ───────────────────────────────────────── */
.chat { display: grid; gap: 8px; margin-bottom: 12px; }
.bubble { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: 14.5px; white-space: pre-wrap; }
.bubble.me { justify-self: end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.bubble.ai { justify-self: start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.cite { display: block; width: 100%; text-align: left; margin-top: 6px; font-size: 12.5px; color: var(--muted); border: 0; border-left: 2px solid var(--accent); background: none; padding: 2px 0 2px 8px; cursor: pointer; }
.ask-form { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: 70px; background: var(--bg); padding: 8px 0; }
.ask-form textarea { resize: none; min-height: 44px; max-height: 140px; }
.typing { color: var(--muted); font-size: 13px; }

/* ── Ajout, file d'envoi ────────────────────────────────────── */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px 16px; text-align: center; margin-bottom: 14px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.queue-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; margin-bottom: 8px; font-size: 13.5px; }
.queue-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Connexion ──────────────────────────────────────────────── */
.login { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; display: grid; gap: 12px; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto; }

/* ── Interrupteur de thème ──────────────────────────────────── */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--muted); }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); position: relative; cursor: pointer; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform 0.15s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(16px); background: #fff; }

/* ── Dialogues et messages ──────────────────────────────────── */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); padding: 18px; width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h2 { font-size: 17px; margin-bottom: 8px; }
dialog p { margin: 0 0 12px; color: var(--muted); }
dialog .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.menu { display: grid; gap: 6px; }
.menu .btn { justify-content: flex-start; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 12px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

@media (min-width: 760px) {
  main { padding-bottom: 100px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
