:root {
  --bg-main: #08090d;
  --bg-card: #11131c;
  --bg-card-hover: #171a26;
  --bg-input: #0b0d14;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f4f8;
  --text-muted: #9499ad;
  --accent: #ef4444;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at 15% 0%, rgba(59, 130, 246, 0.11), transparent 36%),
    radial-gradient(circle at 85% 0%, rgba(239, 68, 68, 0.11), transparent 36%),
    var(--bg-main);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 100px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
  background: rgba(8, 9, 13, 0.82);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.brand-title {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-ver {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-strip {
  max-width: 1320px;
  margin: 16px auto 0;
  padding: 0 24px;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 0.8rem;
}

.status-label {
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 4px;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: #d5d9e6;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
}
.dot.ok {
  background: var(--success);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.65);
}
.dot.err {
  background: var(--accent);
}

.layout {
  max-width: 1320px;
  margin: 20px auto 0;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 22px;
  align-items: start;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 18px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.16);
  color: #93c5fd;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid rgba(59, 130, 246, 0.32);
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 11px;
}

.card-title {
  font-size: 1.02rem;
  font-weight: 700;
}

.card-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Presets rapides */
.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.preset-chip {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.preset-chip.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(239, 68, 68, 0.22));
  border-color: rgba(147, 197, 253, 0.5);
  color: #fff;
}

/* Liste ordonnée des langues */
.lang-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 16px;
}

.lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.lang-item.disabled {
  opacity: 0.45;
}

.lang-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-rank {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
}

.lang-name {
  font-weight: 700;
  font-size: 0.92rem;
}

.lang-hint {
  font-size: 0.77rem;
  color: var(--text-muted);
}

.lang-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-strong);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Segmented controls */
.field-block {
  margin-top: 15px;
}

.field-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 7px;
  color: #e2e8f0;
}

.field-help {
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  background: var(--bg-input);
  padding: 5px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.seg-btn {
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fff;
}

/* Toggle rows */
.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 15px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 12px;
}

.toggle-card.highlight-aiom {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(59, 130, 246, 0.08));
  border-color: rgba(139, 92, 246, 0.38);
}

.toggle-title {
  font-size: 0.88rem;
  font-weight: 600;
}

.toggle-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #272b3a;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s;
}

.slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch.purple input:checked + .slider {
  background: var(--accent-purple);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* Sources grid */
.sources-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 640px) {
  .sources-grid {
    grid-template-columns: 1fr;
  }
}

.source-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s;
}

.source-check:hover {
  border-color: var(--border-strong);
}

.source-check input {
  margin-top: 3px;
  accent-color: var(--accent-blue);
  width: 16px;
  height: 16px;
}

.source-check-title {
  font-size: 0.85rem;
  font-weight: 600;
}

.source-check-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Inputs */
.input-row {
  display: flex;
  gap: 8px;
}

.text-input {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.86rem;
  outline: none;
}

.text-input:focus {
  border-color: var(--accent-blue);
}

.server-key-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.3);
  margin-left: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-strong);
}

.btn-primary {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border-color: #ef4444;
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #f87171, #ef4444);
}

.btn-aiom {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  border-color: rgba(139, 92, 246, 0.6);
  color: #fff;
}

.btn-aiom:hover {
  filter: brightness(1.1);
}

/* Panneau droit : Testeur Temps Réel */
.sticky-col {
  position: sticky;
  top: 82px;
}

.quick-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.sample-btn {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: #cbd5e1;
  cursor: pointer;
}

.sample-btn:hover {
  border-color: var(--accent-blue);
  color: #fff;
}

.search-dropdown {
  margin-top: 6px;
  background: #0d1018;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  max-height: 250px;
  overflow-y: auto;
  display: none;
}

.search-dropdown.open {
  display: block;
}

.search-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.search-opt:hover {
  background: rgba(255, 255, 255, 0.06);
}

.search-opt img {
  width: 32px;
  height: 46px;
  object-fit: cover;
  border-radius: 5px;
  background: #1e293b;
}

.preview-media-banner {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-top: 14px;
}

.preview-media-banner img {
  width: 54px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  background: #1e293b;
}

.preview-streams {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.stream-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.stream-left {
  min-width: 105px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: pre-line;
  color: #f8fafc;
}

.stream-mid {
  flex: 1;
  font-size: 0.8rem;
  color: #cbd5e1;
  white-space: pre-line;
}

.play-mini-btn {
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.45);
  color: #bfdbfe;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.play-mini-btn:hover {
  background: rgba(59, 130, 246, 0.32);
  color: #fff;
}

.player-box {
  margin-top: 14px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: #000;
  display: none;
}

.player-box.open {
  display: block;
}

.player-box iframe,
.player-box video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  display: block;
}

/* Barre d'installation fixe en bas */
.install-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
  background: rgba(11, 13, 20, 0.92);
  border-top: 1px solid var(--border-strong);
  padding: 13px 24px;
}

.install-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.manifest-input {
  flex: 1;
  min-width: 240px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #07080c;
  color: #94a3b8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

/* Modale Overrides */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.toast {
  position: fixed;
  bottom: 80px;
  right: 24px;
  z-index: 120;
  padding: 10px 16px;
  border-radius: 10px;
  background: #1e293b;
  border: 1px solid rgba(34, 197, 94, 0.5);
  color: #f8fafc;
  font-size: 0.84rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: all 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}
