:root {
  --bg: #0a0a0a;
  --panel: rgba(18, 18, 18, 0.94);
  --panel-soft: rgba(255, 255, 255, 0.045);
  --gold: #c9a84c;
  --gold-strong: #e2c769;
  --text: #ffffff;
  --muted: #a0a0a0;
  --danger: #ef4444;
  --success: #34d399;
  --border: rgba(201, 168, 76, 0.2);
  --border-strong: rgba(201, 168, 76, 0.38);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.kt-shell { min-height: 100vh; display: flex; background: radial-gradient(circle at 20% 0, rgba(201,168,76,0.08), transparent 34%), var(--bg); }
.kt-sidebar {
  width: 280px;
  flex: 0 0 280px;
  min-height: 100vh;
  padding: 24px;
  background: rgba(5, 5, 5, 0.86);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  align-self: flex-start;
}
.kt-main { flex: 1; min-width: 0; padding: 28px; }
.kt-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.kt-brand { display: flex; align-items: center; gap: 12px; font-weight: 900; letter-spacing: 0; text-transform: uppercase; }
.kt-logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--gold), #7a5e16);
  color: #0a0a0a;
  font-size: 26px;
  box-shadow: 0 12px 34px rgba(201,168,76,0.2);
}
.kt-brand small { display: block; color: var(--gold); font-size: 12px; letter-spacing: 0.14em; }
.kt-nav { margin-top: 28px; display: grid; gap: 8px; }
.kt-nav a, .kt-nav button {
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  padding: 12px 14px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: 0.3s ease;
}
.kt-nav a:hover, .kt-nav a.active, .kt-nav button:hover {
  color: var(--text);
  border-color: var(--border);
  background: rgba(201,168,76,0.08);
}
.kt-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.kt-card-pad { padding: 22px; }
.kt-grid { display: grid; gap: 18px; }
.kt-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kt-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kt-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kt-title { margin: 0; font-size: clamp(26px, 3vw, 42px); line-height: 1.05; letter-spacing: 0; }
.kt-muted { color: var(--muted); }
.kt-gold { color: var(--gold); }
.kt-btn {
  border: 1px solid var(--border-strong);
  background: rgba(201,168,76,0.1);
  color: var(--text);
  border-radius: 8px;
  min-height: 42px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: 0.3s ease;
}
.kt-btn.primary { background: var(--gold); color: #101010; font-weight: 800; }
.kt-btn.danger { border-color: rgba(239,68,68,0.4); color: #fecaca; background: rgba(239,68,68,0.08); }
.kt-btn:hover { transform: translateY(-1px); box-shadow: 0 0 30px rgba(201,168,76,0.16); }
.kt-input, .kt-select, .kt-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #090909;
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}
.kt-input:focus, .kt-select:focus, .kt-textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,168,76,0.12); }
.kt-textarea { resize: vertical; min-height: 110px; }
.kt-form { display: grid; gap: 14px; }
.kt-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.kt-table th, .kt-table td { padding: 13px 12px; border-bottom: 1px solid rgba(255,255,255,0.07); text-align: left; vertical-align: top; }
.kt-table th { color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.kt-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--gold); background: rgba(201,168,76,0.08); font-size: 12px; }
.kt-progress { height: 10px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.kt-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--gold-strong)); transition: width 0.35s ease; }
.kt-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0, rgba(201,168,76,0.12), transparent 36%), var(--bg);
}
.kt-auth-card { width: min(460px, 100%); padding: 30px; }
.kt-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  z-index: 50;
  padding: 14px 16px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.kt-chat { height: calc(100vh - 56px); display: grid; grid-template-columns: 280px 1fr; gap: 18px; }
.kt-messages { min-height: 0; overflow: auto; padding: 18px; display: grid; align-content: start; gap: 14px; }
.kt-message { max-width: 780px; border-radius: 8px; padding: 13px 15px; white-space: pre-wrap; line-height: 1.55; }
.kt-message.user { justify-self: end; background: var(--gold); color: #111; }
.kt-message.ai { justify-self: start; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); }
.kt-chatbar { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border); }
.kt-inbox { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 18px; min-height: calc(100vh - 120px); }
.kt-inbox-list { display: grid; gap: 8px; max-height: calc(100vh - 160px); overflow: auto; }
.kt-inbox-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  padding: 12px 14px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: 0.2s ease;
}
.kt-inbox-item:hover, .kt-inbox-item.active { border-color: var(--gold); background: rgba(201,168,76,0.08); }
.kt-inbox-item strong { display: block; margin-bottom: 4px; }
.kt-inbox-item small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kt-unread { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: #111; font-size: 11px; font-weight: 800; align-items: center; justify-content: center; }
.kt-msg-panel { display: grid; grid-template-rows: auto 1fr auto; min-height: calc(100vh - 160px); }
.kt-msg-feed { overflow: auto; padding: 16px; display: grid; align-content: start; gap: 12px; }
.kt-msg { display: flex; }
.kt-msg.mine { justify-content: flex-end; }
.kt-msg.theirs { justify-content: flex-start; }
.kt-msg-bubble { max-width: min(78%, 520px); border-radius: 12px; padding: 12px 14px; border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.05); }
.kt-msg.mine .kt-msg-bubble { background: rgba(201,168,76,0.18); border-color: rgba(201,168,76,0.35); }
.kt-msg-text { margin: 0 0 8px; white-space: pre-wrap; line-height: 1.5; }
.kt-msg-meta { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); }
.kt-msg-image { display: block; max-width: 100%; border-radius: 8px; margin-top: 6px; border: 1px solid var(--border); }
.kt-msg-preview { max-width: 120px; max-height: 120px; border-radius: 8px; border: 1px solid var(--border); margin-top: 8px; }
.kt-msg-compose { display: grid; gap: 10px; padding: 14px; border-top: 1px solid var(--border); }
.kt-msg-compose-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.kt-file-btn { position: relative; overflow: hidden; }
.kt-file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.kt-mobile-toggle { display: none; }
.kt-course-layout { grid-template-columns: minmax(240px, 30%) 1fr; }
.kt-lesson-text { line-height: 1.75; color: #ddd; margin: 16px 0; font-size: 15px; }
.kt-media-block { padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,0.02); }
.kt-media-video { margin-bottom: 8px; }

/* ── Appel Vocal (WebRTC) ────────────────────────────────────────────── */
.kt-voice-btn {
  position: relative;
  border: 1px solid var(--border-strong);
  background: rgba(201,168,76,0.08);
  color: var(--text);
  border-radius: 8px;
  min-height: 42px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  transition: 0.25s ease;
  flex-shrink: 0;
}
.kt-voice-btn:hover { transform: translateY(-1px); box-shadow: 0 0 24px rgba(201,168,76,0.18); }
.kt-voice-btn.active {
  background: rgba(239,68,68,0.14);
  border-color: rgba(239,68,68,0.45);
  color: #fca5a5;
}
.kt-voice-btn .kt-voice-icon { font-size: 17px; line-height: 1; }

/* Indicateur animé (cercles pulsants) affiché pendant l'écoute/parole */
.kt-voice-indicator {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 20px;
}
.kt-voice-indicator.visible { display: flex; }
.kt-voice-indicator span {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  animation: kt-pulse 1.1s ease-in-out infinite;
}
.kt-voice-indicator span:nth-child(2) { animation-delay: 0.18s; }
.kt-voice-indicator span:nth-child(3) { animation-delay: 0.36s; }
@keyframes kt-pulse {
  0%, 100% { transform: scaleY(1);   opacity: 0.55; }
  50%       { transform: scaleY(2.2); opacity: 1;    }
}

/* Label de statut vocal sous la barre de chat */
.kt-voice-status {
  font-size: 12px;
  color: var(--gold);
  padding: 4px 14px 8px;
  min-height: 20px;
  letter-spacing: 0.04em;
}

/* Message transcription IA (style distinct des messages texte) */
.kt-message.voice-ai {
  justify-self: start;
  background: rgba(201,168,76,0.07);
  border: 1px solid rgba(201,168,76,0.22);
  color: #f5e9c8;
  font-style: italic;
}
.kt-message.voice-ai::before {
  content: "🎙 ";
  font-style: normal;
}

@media (max-width: 900px) {
  .kt-shell { display: block; }
  .kt-sidebar { width: 100%; min-height: auto; position: static; display: none; }
  .kt-sidebar.open { display: block; }
  .kt-main { padding: 18px; }
  .kt-mobile-toggle { display: inline-flex; }
  .kt-grid.cols-2, .kt-grid.cols-3, .kt-grid.cols-4 { grid-template-columns: 1fr; }
  .kt-topbar { align-items: flex-start; flex-wrap: wrap; }
  .kt-chat { height: auto; grid-template-columns: 1fr; }
  .kt-inbox { grid-template-columns: 1fr; }
  .kt-inbox-list { max-height: 240px; }
  .kt-msg-panel { min-height: 60vh; }
  .kt-table { display: block; overflow-x: auto; white-space: nowrap; }
  .kt-auth-card { padding: 22px; }
  .kt-card-pad { padding: 16px; }
  .kt-course-layout { grid-template-columns: 1fr !important; }
}
