/* Orizon : page de configuration. Mobile d'abord ; barre latérale à partir de 960 px. */

:root {
  color-scheme: dark;
  --bg: #0d0918;
  --surface: #17112a;
  --surface-2: #1e1735;
  --surface-3: #261d43;
  --field: #0f0a1d;
  --line: #2a2144;
  --line-2: #3a2f5e;
  --text: #f1edfb;
  --muted: #b0a6cc;
  --faint: #8a80a8;
  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --accent-3: #c4b5fd;
  --accent-deep: #6d28d9;
  --accent-bg: rgba(139, 92, 246, 0.14);
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.12);
  --err: #fb8a8a;
  --err-bg: rgba(248, 113, 113, 0.12);
  --warn: #fcd34d;
  --warn-bg: rgba(252, 211, 77, 0.09);
  --radius: 16px;
  --radius-sm: 12px;
  --gutter: 16px;
  --tap: 44px;
  --side-w: 272px;
  --bar-space: 0px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 72px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(900px 480px at 50% -260px, rgba(124, 58, 237, 0.32), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent-3); text-underline-offset: 2px; }
a:hover { color: #ddd6fe; }
code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--field);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 6px;
  overflow-wrap: anywhere;
}
strong { font-weight: 650; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
}
.skip:focus { top: 8px; }

.noscript {
  margin: 16px;
  padding: 14px;
  border-radius: 12px;
  background: var(--err-bg);
  color: var(--err);
}

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---------- Structure (mobile) ---------- */
.shell { min-height: 100vh; }
.side { display: contents; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) calc(var(--gutter) + env(safe-area-inset-right)) 10px calc(var(--gutter) + env(safe-area-inset-left));
}
.brand img { width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto; box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35); }
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: -0.01em; }
.brand .ver { font-size: 12px; font-weight: 500; color: var(--faint); margin-left: 2px; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }

.tabs {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 8px calc(var(--gutter) + env(safe-area-inset-right)) 8px calc(var(--gutter) + env(safe-area-inset-left));
  background: rgba(13, 9, 24, 0.88);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  backdrop-filter: saturate(140%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.tabs button .i { width: 18px; height: 18px; }
.tabs button:not([aria-selected="true"]):hover { color: var(--text); border-color: var(--line-2); }
.tabs button[aria-selected="true"] {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
}
.tab-label .long { display: none; }
.tab-dot { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.tabs button[data-dirty] .tab-dot { display: inline-block; }

.main {
  display: block;
  padding: 18px calc(var(--gutter) + env(safe-area-inset-right)) calc(var(--bar-space) + 32px + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left));
  outline: none;
}
/* Barre d'enregistrement visible : le champ qui reçoit le focus s'arrête au-dessus. */
html.has-bar {
  --bar-space: 84px;
  scroll-padding-bottom: calc(var(--bar-space) + 16px + env(safe-area-inset-bottom));
}

/* ---------- Barre d'enregistrement (en bas sur mobile) ---------- */
.savebar {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px calc(var(--gutter) + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left));
  background: rgba(20, 14, 37, 0.94);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  backdrop-filter: saturate(140%) blur(16px);
  border-top: 1px solid var(--line-2);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s var(--ease);
}
.savebar[data-hide] { transform: translateY(calc(100% + 4px)); visibility: hidden; transition: transform 0.25s var(--ease), visibility 0s 0.25s; }
.save-state { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }
.save-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--faint);
}
.savebar[data-state="dirty"] .save-dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(252, 211, 77, 0.16); }
.savebar[data-state="new"] .save-dot { background: var(--accent-2); box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.18); }
.savebar[data-state="saved"] .save-dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.16); }
.savebar[data-state="saving"] .save-dot { background: var(--accent-2); animation: pulse 1s infinite; }
.save-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.save-text strong { font-size: 15px; }
.savebar[data-state="saved"] .save-text strong { color: var(--ok); }
.save-text small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-actions { flex: 0 0 auto; display: flex; gap: 8px; }

@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- Panneaux et cartes ---------- */
.panel { animation: enter 0.22s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } }
.panel-head { margin: 2px 2px 16px; }
.panel-head h2 { margin: 0 0 2px; font-size: 22px; line-height: 1.25; letter-spacing: -0.015em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 15px; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
.cols > * { min-width: 0; }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 120px), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  min-width: 0;
}
.card.narrow { max-width: 640px; }
.card h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.step {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent-3);
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 auto;
}
.count { color: var(--faint); font-size: 14px; }

.field { margin: 0 0 16px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label, .label {
  display: block;
  margin: 0 0 7px;
  font-size: 14px;
  font-weight: 650;
  color: #ddd6f3;
}
.opt { font-weight: 400; color: var(--faint); }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.hint.lead { margin: -4px 0 14px; }
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(252, 211, 77, 0.32);
  background: var(--warn-bg);
  color: #fde68a;
  font-size: 14px;
  line-height: 1.45;
}
.notice .i { width: 18px; height: 18px; margin-top: 1px; }
.notice.info { border-color: var(--line-2); background: rgba(139, 92, 246, 0.07); color: var(--muted); }
.notice.info strong { color: var(--text); }
.notice.after { margin-top: 16px; }

.status { margin: 10px 0 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.status:empty { display: none; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.warn { color: var(--warn); }
.page-status { margin: 0 2px 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.actions.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Champs ---------- */
input[type="text"], input[type="password"], input[type="number"], input[type="url"], input[type="email"], select {
  width: 100%;
  max-width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16 px : pas de zoom automatique sur iOS */
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: var(--faint); }
input:hover { border-color: #4a3d75; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.28); }
input[readonly] { color: var(--muted); font-family: var(--mono); }
input[type="number"] { -moz-appearance: textfield; }

.input-row { display: flex; gap: 8px; min-width: 0; }
.input-row > :first-child { flex: 1 1 auto; min-width: 0; }
.input-row > .btn { flex: 0 0 auto; }

.pw { position: relative; min-width: 0; }
.pw input { padding-right: 52px; }
.reveal {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  width: 46px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}
.reveal:hover, .reveal[aria-pressed="true"] { color: var(--accent-3); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 16px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s, opacity 0.15s;
}
.btn:hover { background: var(--surface-3); border-color: #4b3e78; }
.btn:active { transform: scale(0.98); }
.btn .i { width: 18px; height: 18px; }
.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.32);
}
.btn.primary:hover { background: linear-gradient(135deg, #9b70ff, #7434e6); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: #fecaca; border-color: #5b2333; background: #251320; }
.btn.danger:hover { background: #331827; border-color: #7a2d43; }
.btn.sm { min-height: var(--tap); padding: 8px 12px; font-size: 14px; }
.btn.big { min-height: 52px; font-size: 16px; }
.btn.wide { width: 100%; }
.btn.icon { width: var(--tap); padding: 0; flex: 0 0 auto; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.42; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.linkish {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-3);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* ---------- Contrôle segmenté (choix exclusif) ---------- */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--field);
}
.seg label { position: relative; flex: 1 1 0; min-width: 0; display: flex; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.seg small { font-size: 12px; font-weight: 500; color: var(--faint); }
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); color: #fff; box-shadow: 0 3px 10px rgba(124, 58, 237, 0.3); }
.seg input:checked + span small { color: rgba(255, 255, 255, 0.82); }
.seg input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---------- Puces (choix multiples) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-flex; min-width: 0; max-width: 100%; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 8px 14px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip span::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  transition: background 0.15s, border-color 0.15s;
}
.chip small { color: var(--faint); font-size: 12px; }
.chip:hover span { border-color: #4b3e78; color: var(--text); }
.chip input:checked + span { background: var(--accent-bg); border-color: var(--accent); color: var(--text); }
.chip input:checked + span::before {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 10px no-repeat;
}
.chip input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.chip.sm span { padding: 6px 12px; font-size: 14px; }

/* ---------- Interrupteurs (oui / non) ---------- */
.switches { display: flex; flex-direction: column; margin: 4px 0 12px; }
.switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.switches .switch:last-child { border-bottom: 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.sw-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; font-weight: 600; font-size: 15px; line-height: 1.3; }
.sw-text small { margin-top: 2px; color: var(--muted); font-size: 13px; font-weight: 400; }
.sw {
  position: relative;
  flex: 0 0 auto;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: #3a3157;
  transition: background 0.2s var(--ease);
}
.sw::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s var(--ease);
}
.switch input:checked ~ .sw { background: var(--accent); }
.switch input:checked ~ .sw::after { transform: translateX(20px); }
.switch input:focus-visible ~ .sw { outline: 2px solid var(--accent-2); outline-offset: 2px; }
#cardAdvanced .switch { border-bottom: 0; margin-top: 4px; }

/* ---------- Sections repliables ---------- */
.fold > summary {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  min-height: var(--tap);
  cursor: pointer;
  position: relative;
  padding-right: 32px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s var(--ease);
}
.fold[open] > summary::after { transform: rotate(-135deg); margin-top: -2px; }
.fold > summary h3 { margin: 0; }
.fold-hint { color: var(--faint); font-size: 14px; }
.fold[open] > summary { margin-bottom: 14px; }
.fold.small { margin-top: 16px; padding-top: 6px; border-top: 1px solid var(--line); }
.fold.small > summary { font-weight: 600; font-size: 15px; color: var(--accent-3); }
.grid-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 14px; }
.grid-fields .field:last-child { margin-bottom: 16px; }
/* Champs côte à côte : libellé, champ et aide alignés d'une colonne à l'autre,
   même si un libellé passe sur deux lignes. */
@supports (grid-template-rows: subgrid) {
  .grid-fields .field { display: grid; grid-template-rows: subgrid; grid-row: span 3; align-content: start; }
}

.steps { margin: 4px 0 0; padding-left: 22px; color: var(--muted); font-size: 15px; }
.steps li { margin: 6px 0; padding-left: 2px; }
.steps li::marker { color: var(--accent-2); font-weight: 700; }

/* ---------- Service debrid ---------- */
.debrid-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 24px; }

/* ---------- Sources ---------- */
.sources { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-items: start; }
.src {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--surface-2);
  animation: enter 0.2s var(--ease);
}
.src-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.src-icon, .type-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
}
.t-stremio { background: rgba(139, 92, 246, 0.18); color: var(--accent-3); }
.t-torznab { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; }
.t-zilean { background: rgba(52, 211, 153, 0.14); color: #6ee7b7; }
.src-info { flex: 1 1 auto; min-width: 0; }
.src-name { font-weight: 700; font-size: 16px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-top: 2px; color: var(--muted); font-size: 13px; min-width: 0; }
.src-meta .host { min-width: 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; }
.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
  color: var(--muted);
  white-space: nowrap;
}
.src-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.src-actions .btn { padding: 8px 6px; font-size: 14px; gap: 6px; }
.src-result { font-size: 14px; line-height: 1.45; min-width: 0; }
.src-result:empty { display: none; }
.src-result p { margin: 0; font-weight: 600; }
.src-result.ok p { color: var(--ok); }
.src-result.err p { color: var(--err); }
.src-result.warn p { color: var(--warn); }
.src-result.busy p { color: var(--muted); font-weight: 500; }
.src-result.busy p::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  vertical-align: -1px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent-2);
  animation: spin 0.8s linear infinite;
}
.sample { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.sample li {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--field);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.src.removed {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  border-style: dashed;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
}
.src.removed span { min-width: 0; overflow-wrap: anywhere; }
.sources .empty {
  padding: 18px;
  border: 1px dashed var(--line-2);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.quick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.quick-label { color: var(--muted); font-size: 14px; margin-right: 2px; }
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 8px 14px 8px 10px;
  border: 1px dashed #5b4b91;
  border-radius: 999px;
  background: transparent;
  color: var(--accent-3);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.chip-btn:hover { background: var(--accent-bg); border-style: solid; }
.chip-btn .i { width: 16px; height: 16px; }

/* Formulaire d'ajout / modification */
.source-editor { margin-top: 12px; }
.editor {
  padding: 16px 14px;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.08), rgba(139, 92, 246, 0.02)), var(--surface-2);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.08);
  animation: enter 0.2s var(--ease);
  min-width: 0;
}
.sources > li.editor-item { list-style: none; }
.editor h4 { margin: 0 0 12px; font-size: 16px; }
.types { margin: 0 0 14px; padding: 0; border: 0; display: grid; gap: 8px; min-width: 0; }
.types legend { padding: 0; margin: 0 0 8px; font-size: 14px; font-weight: 650; color: #ddd6f3; }
.type-opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--field);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.type-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.type-opt:hover { border-color: #4b3e78; }
.type-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); }
.type-opt:has(input:focus-visible) { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.type-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.type-text strong { font-size: 15px; }
.type-text small { color: var(--muted); font-size: 13px; margin-top: 2px; }
.types.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.types.compact .type-opt { flex-direction: column; justify-content: center; gap: 4px; min-height: 56px; padding: 8px 4px; text-align: center; }
.types.compact .type-icon { width: 28px; height: 28px; border-radius: 8px; }
.types.compact .type-icon .i { width: 16px; height: 16px; }
.types.compact small { display: none; }
.types.compact strong { font-size: 13px; }
.warn-line { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: #fde68a; font-size: 14px; }
.editor .src-result { margin: 0 0 8px; }

/* ---------- Préréglages ---------- */
.presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.preset {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 64px;
  padding: 12px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.preset:hover { border-color: var(--accent); background: var(--surface-3); }
.preset:active { transform: scale(0.985); }
.preset.applied { border-color: var(--ok); }
.pi { font-size: 22px; line-height: 1.1; }
.pt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.pt strong { font-size: 15px; }
.pt small { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Aperçu ---------- */
.preview { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; background: #0a0714; border: 1px solid var(--line); }
.preview:empty::before { content: "Chargement de l’aperçu…"; color: var(--faint); font-size: 14px; padding: 6px; }
.preview .empty { color: var(--muted); font-size: 14px; padding: 6px; }
.stream { display: flex; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.stream .n { flex: 0 0 auto; min-width: 70px; max-width: 40%; font-weight: 700; font-size: 14px; white-space: pre-line; line-height: 1.35; }
.stream .d { flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: 13px; white-space: pre-line; overflow-wrap: anywhere; line-height: 1.4; }

/* ---------- Listes ordonnées (langues, catalogues) ---------- */
.olist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.orow {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 56px;
  padding: 5px 5px 5px 12px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--field);
  min-width: 0;
}
.orow .num { flex: 0 0 auto; width: 20px; color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; }
.orow .name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.orow .name > span { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.orow .name small { color: var(--faint); font-size: 12.5px; }
.orow .btn.icon { width: 44px; min-height: 44px; border-radius: 10px; }
.orow.excluded .name > span { color: var(--faint); text-decoration: line-through; }
.mini {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  min-height: 32px;
  margin: 2px 0 -4px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.mini::before { content: ""; position: absolute; inset: -6px -8px; }
.mini input {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
  border: 1.5px solid var(--line-2);
  border-radius: 5px;
  background: var(--field);
  cursor: pointer;
}
.mini input:checked {
  border-color: var(--err);
  background: var(--err) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23240b12' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / 11px no-repeat;
}
.orow.excluded .mini { color: var(--err); }
.olist .empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* ---------- Catalogues et plateformes ---------- */
.mini-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-groups { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.cat-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.cat-group legend { padding: 0; margin: 0 0 8px; font-weight: 700; font-size: 15px; }
.providers { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.prov {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--field);
}
.prov img, .prov .ph { width: 32px; height: 32px; border-radius: 8px; flex: 0 0 auto; object-fit: cover; }
.ph { display: inline-grid; place-items: center; background: var(--line-2); color: var(--text); font-weight: 700; }
/* Nom en entier sur une ligne ; s'il manque de place, les cases passent dessous. */
.prov .name { flex: 1 0 auto; max-width: calc(100% - 42px); font-weight: 600; font-size: 15px; overflow-wrap: break-word; line-height: 1.25; }
.prov-types { display: flex; gap: 6px; flex: 0 0 auto; margin-left: auto; }
.prov .chip span { padding: 6px 12px; font-size: 14px; }
.prov .chip span::before { display: none; }
.prov .chip input:checked + span { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); border-color: transparent; color: #fff; }

/* ---------- Mes addons Stremio ---------- */
.st-status { margin: 0 2px 14px; }
.st-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
.st-layout > * { min-width: 0; }
.st-list-card { container-type: inline-size; }
.who { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-3); flex: 0 0 auto; }
.who-text { flex: 1 1 160px; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.who-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.addons { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.addon {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 8px 12px;
  padding: 10px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--field);
  min-width: 0;
}
.addon img, .addon .ph { width: 44px; height: 44px; border-radius: 11px; object-fit: contain; background: #0b0814; }
.addon .info { min-width: 0; }
.addon .name { font-weight: 650; overflow-wrap: anywhere; line-height: 1.3; }
.addon .host { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; font-family: var(--mono); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badges:empty { display: none; }
.badge { display: inline-block; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--muted); font-size: 11.5px; line-height: 19px; }
.badge.accent { border-color: var(--accent); color: var(--accent-3); background: var(--accent-bg); }
.acts { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 6px; }
@container (min-width: 520px) {
  .addon { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .acts { grid-column: auto; }
}
.acts .btn.icon { width: 44px; border-radius: 10px; }
.st-side h3 { margin-bottom: 12px; }
.st-commit { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.st-dirty { display: flex; gap: 8px; align-items: flex-start; margin: 0; color: var(--warn); font-size: 14px; }
.st-dirty .i { width: 18px; height: 18px; }
.st-commit.pending {
  padding: 12px;
  border: 1px solid rgba(252, 211, 77, 0.4);
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.tools { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.tools .btn { justify-content: flex-start; }
.st-side .stack .btn { justify-content: flex-start; text-align: left; }

/* ---------- Installer ---------- */
.state-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--field);
  border: 1px solid var(--line-2);
  font-weight: 600;
}
.state-line::before { content: ""; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: var(--accent-2); }
.state-line[data-state="dirty"] { border-color: rgba(252, 211, 77, 0.4); }
.state-line[data-state="dirty"]::before { background: var(--warn); }
.state-line[data-state="saved"] { border-color: rgba(52, 211, 153, 0.4); color: var(--ok); }
.state-line[data-state="saved"]::before { background: var(--ok); }
.profile-state { margin: 0 0 14px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.profile-state strong { color: var(--text); }
.gate {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px dashed var(--line-2);
  color: var(--muted);
  font-size: 14px;
}
.gate .i { width: 18px; height: 18px; margin-top: 1px; }
.install-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.install-actions .big { grid-column: 1 / -1; }
.install-actions .btn:not(.big) { padding-left: 8px; padding-right: 8px; gap: 6px; }
.result { margin-top: 14px; }
.result label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 650; color: #ddd6f3; }
#cardInstall.ready { border-color: rgba(52, 211, 153, 0.35); box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.12); }
#cardInstall.flash { animation: flash 1.2s var(--ease); }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); } 100% { box-shadow: 0 0 0 14px rgba(52, 211, 153, 0); } }

.foot { margin: 28px 2px 0; color: var(--faint); font-size: 13px; text-align: center; line-height: 1.6; }

/* ---------- Message éphémère ---------- */
.toast {
  position: fixed;
  z-index: 60;
  left: 0;
  right: 0;
  bottom: calc(var(--bar-space) + 14px + env(safe-area-inset-bottom));
  width: max-content;
  max-width: min(calc(100vw - 32px), 460px);
  margin: 0 auto;
  padding: 12px 16px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: #251d40;
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { border-color: rgba(52, 211, 153, 0.45); }
.toast.err { border-color: rgba(248, 113, 113, 0.5); }

/* ---------- Fenêtre du mot de passe ---------- */
.dialog {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 22px 20px 16px;
  border: 1px solid var(--line-2);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow-y: auto;
}
.dialog::backdrop { background: rgba(5, 3, 12, 0.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dialog[open] { animation: enter 0.2s var(--ease); }
.dialog h3 { margin: 0 0 6px; font-size: 19px; }
.dialog .hint { margin: 0 0 16px; }
.dialog-alt { display: flex; flex-direction: column; margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
.dialog-alt:not(:has(.linkish:not([hidden]))) { display: none; }

@media (max-width: 959px) {
  .st-commit.pending {
    position: fixed;
    z-index: 35;
    left: calc(var(--gutter) + env(safe-area-inset-left));
    right: calc(var(--gutter) + env(safe-area-inset-right));
    bottom: calc(var(--bar-space) + 10px + env(safe-area-inset-bottom));
    margin: 0;
  }
  html.st-pending { scroll-padding-bottom: calc(var(--bar-space) + 140px + env(safe-area-inset-bottom)); }
  html.st-pending .main { padding-bottom: calc(var(--bar-space) + 140px + env(safe-area-inset-bottom)); }
}
@media (min-width: 600px) and (max-width: 959px) {
  .st-commit.pending { flex-direction: row; align-items: center; justify-content: space-between; }
}

/* ---------- Petits écrans ---------- */
@media (max-width: 519px) {
  .presets { grid-template-columns: minmax(0, 1fr); }
  .preset { min-height: 0; align-items: center; }
}
@media (max-width: 479px) {
  .save-text small { white-space: normal; }
  /* Ordre des catalogues et des langues : place pour les noms. */
  .orow { gap: 4px; padding-left: 10px; }
  .orow .num { display: none; }
}
@media (max-width: 429px) {
  .save-text small { display: none; }
  .src { padding: 12px; }
  .src-actions .btn .i { display: none; }
  .src-actions .btn { padding: 8px 4px; }
}
@media (max-width: 359px) {
  :root { --gutter: 12px; }
  .card { padding: 16px 12px; }
  .tabs button { padding: 0 12px; font-size: 14px; }
  .seg span { padding: 6px 3px; font-size: 14px; }
  .src-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 48px; }
  .src-actions [data-act="remove"] .lbl { display: none; }
  .src-actions [data-act="remove"] .i { display: block; }
  .dialog { padding: 18px 14px 12px; }
  .dialog .actions.end { flex-direction: column-reverse; gap: 8px; }
  .dialog .actions.end > .btn { width: 100%; }
}

/* ---------- Tablette ---------- */
@media (min-width: 600px) {
  :root { --gutter: 24px; }
  .card { padding: 22px; }
  .panel-head h2 { font-size: 26px; }
  .grid-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .providers { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
}

/* ---------- Ordinateur : navigation latérale ---------- */
@media (min-width: 960px) {
  html { scroll-padding-top: 24px; }
  html.has-bar { --bar-space: 0px; scroll-padding-bottom: 0; }
  .shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .side {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 22px 14px 18px;
    border-right: 1px solid var(--line);
    background: rgba(15, 10, 28, 0.72);
    overflow-y: auto;
  }
  .brand { padding: 0 8px 22px; }
  .tabs {
    position: static;
    flex-direction: column;
    gap: 4px;
    overflow: visible;
    padding: 0;
    background: none;
    border: 0;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .tabs button {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 12px;
    border-color: transparent;
    font-size: 15px;
  }
  .tabs button:not([aria-selected="true"]):hover { background: var(--surface); border-color: transparent; }
  .tabs button[aria-selected="true"] { box-shadow: 0 6px 18px rgba(124, 58, 237, 0.3); }
  .tab-dot { margin-left: auto; }
  .tab-label .long { display: inline; }
  .tab-label .short { display: none; }
  .savebar {
    position: static;
    margin-top: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .savebar[data-hide] { transform: none; visibility: visible; }
  .save-state { align-items: flex-start; }
  .save-dot { margin-top: 5px; }
  .save-text small { white-space: normal; }
  .save-actions { flex-direction: column; }
  .save-actions .btn { width: 100%; }
  .main { width: 100%; max-width: 1240px; margin-inline: auto; padding: 36px 40px 56px; }
  .panel-head { margin-bottom: 22px; }
  .panel-head h2 { font-size: 28px; }
  .toast { left: var(--side-w); bottom: 28px; }
  .cat-groups { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .debrid-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
  .debrid-grid .field { margin-bottom: 0; }
  .st-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  .st-side { position: sticky; top: 24px; }
  .st-commit.pending { margin: 14px 0 0; box-shadow: none; }
}

/* ---------- Grand écran : cartes en grille ---------- */
@media (min-width: 520px) and (max-width: 1179px) {
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1180px) {
  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .span-2 { grid-column: 1 / -1; }
  .sources { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sources > .editor-item { grid-column: 1 / -1; }
  .presets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .st-layout { grid-template-columns: minmax(0, 1fr) 340px; }
}

@media (min-width: 1440px) {
  .main { padding-left: 56px; padding-right: 56px; }
}

@media (hover: none) {
  .btn:hover, .chip:hover span, .preset:hover, .type-opt:hover { border-color: var(--line-2); }
  .btn:hover { background: var(--surface-2); }
  .btn.primary:hover { background: linear-gradient(135deg, var(--accent), var(--accent-deep)); }
  .btn.ghost:hover { background: transparent; }
  .btn.danger:hover { background: #251320; border-color: #5b2333; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
