/* ==========================================================================
   Stellion — paramètres et documents légaux
   Maquettes : Parametres, ParamDetail, BureauParametres, LegalModal.
   Mobile : la liste, puis une rubrique en plein écran (classe « is-detail »).
   Ordinateur : la liste à gauche, la rubrique à droite.
   ========================================================================== */

/* Affiché par le JS (style.display = 'flex') */
.st-settings {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: none;
  background: var(--bg);
  overflow: hidden;
}

.st-settings__nav {
  width: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 var(--space-4) calc(var(--nav-space) + var(--space-6));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.st-settings__head {
  height: 56px;
  margin: 0 calc(var(--space-2) * -1);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.st-settings__title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}

.st-set {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.st-set__title {
  margin: 0;
  padding: 0 var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  color: var(--text-muted);
}

.st-set__group {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.st-set__group > * + * {
  border-top: 1px solid var(--hairline);
}

.st-set__row {
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  letter-spacing: 0;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  cursor: pointer;
}

.st-set__row:hover,
.st-set__row[aria-current="page"] {
  background: var(--surface-2);
  filter: none;
  transform: none;
  box-shadow: none;
}

.st-set__icon {
  width: 22px;
  flex-shrink: 0;
  display: flex;
  color: var(--icon);
}

.st-set__label {
  flex: 1;
  min-width: 0;
  font-size: var(--text-base);
}

.st-set__value {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.st-set__chev {
  flex-shrink: 0;
  color: var(--text-muted);
}

.st-set__block {
  padding: var(--space-3) 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.st-set__line {
  display: flex;
  align-items: center;
  gap: 14px;
}

.st-set__switch {
  min-height: 60px;
  padding: var(--space-2) 14px;
}

.st-settings__logout {
  margin-top: var(--space-2);
}

/* ---------- Rubrique ---------- */

.st-settings__content {
  display: none;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
}

.st-settings__detail-head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 56px;
  padding: env(safe-area-inset-top, 0px) var(--space-2) 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.st-settings__detail-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

.st-settings__panels {
  width: 100%;
  max-width: 740px;
  padding: var(--space-4) var(--space-4) calc(var(--nav-space) + var(--space-6));
}

.settings-panel[hidden] {
  display: none;
}

/* Mobile : la rubrique remplace la liste ; son propre titre est déjà dans l'en-tête */
@media (max-width: 768px) {
  .st-settings.is-detail .st-settings__nav {
    display: none;
  }

  .st-settings.is-detail .st-settings__content {
    display: flex;
    flex: 1;
  }

  .settings-panel > h2:first-child {
    display: none;
  }
}

@media (min-width: 769px) {
  .st-settings {
    left: var(--side-w);
  }

  .st-settings__nav {
    width: 320px;
    flex-shrink: 0;
    padding: var(--space-4) var(--space-4) var(--space-8);
    border-right: 1px solid var(--border);
  }

  .st-settings__content {
    display: flex;
    flex: 1;
  }

  .st-settings__detail-head {
    display: none;
  }

  .st-settings__panels {
    padding: var(--space-10) var(--space-10) var(--space-10);
  }
}

/* ---------- Contenu d'une rubrique (maquette ParamContenu) ----------
   <div class="st-pane"> <h2 class="st-pane__title"> puis des cartes :
   <section class="st-card"> <h3 class="st-card__title"> + des lignes .st-item
   (icône, nom, explication, action). Une carte d'une seule ligne : .st-card.st-item */

.st-pane {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.st-pane__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-title);
  color: var(--text);
}

.st-pane__intro {
  margin: calc(var(--space-4) * -1) 0 0;
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
}

.st-pane__h {
  margin: var(--space-4) 0 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text);
}

.st-card {
  padding: var(--space-4);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.st-card__title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  color: var(--text-muted);
}

.st-card__title--danger {
  color: var(--danger);
}

.st-card--danger {
  border-color: var(--danger);
}

.st-card__sep {
  height: 1px;
  margin: 0 calc(var(--space-4) * -1);
  background: var(--hairline);
}

.st-item {
  display: flex;
  align-items: center;
  gap: 14px;
}

.st-card.st-item {
  flex-direction: row;
}

.st-item__icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--icon);
  display: flex;
  align-items: center;
  justify-content: center;
}

.st-item__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.st-item__name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text);
}

.st-item__h {
  margin: 0;
  font: inherit;
  color: inherit;
}

.st-item__sub {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--text-muted);
}

.st-item > .st-btn {
  flex-shrink: 0;
}

/* Mobile étroit : le bouton passe sous le texte */
@media (max-width: 480px) {
  .st-item {
    flex-wrap: wrap;
  }

  .st-item > .st-item__text {
    flex-basis: calc(100% - 54px);
  }

  .st-item > .st-btn {
    margin-left: 54px;
  }

  .st-card--danger .st-item > .st-btn {
    margin-left: 0;
  }
}

.st-item__icon--ok {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.st-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.st-card__btn {
  align-self: flex-start;
}

.st-perm:not(:has(> :not([hidden]))) {
  display: none;
}

.st-card[hidden],
.st-field[hidden],
.st-field__hint[hidden],
.st-btn[hidden] {
  display: none;
}

/* Liste déroulante : même champ que .st-input, avec un chevron dessiné en CSS */
.st-select {
  appearance: none;
  padding-right: 40px;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.st-select:focus {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
}

.st-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.st-range {
  width: 100%;
  height: var(--tap-min);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Niveau du micro : barre segmentée (role="meter") */
.st-meter {
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
}

.st-meter::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(100% / 24 - 2px), var(--surface) calc(100% / 24 - 2px) calc(100% / 24));
}

.st-meter__fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 60ms linear;
}

/* Futur et abonnement */
.st-pane__note {
  margin: calc(var(--space-2) * -1) 0 0;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--text-muted);
}

.st-future {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 14px;
}

.st-future__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.st-future__body .st-item__sub {
  margin: 0;
}

.st-future__list {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text);
}

.st-tag--dev-icon {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.st-tag--idea {
  background: var(--surface-2);
  color: var(--text-muted);
}

.st-tag--idea-icon {
  background: var(--surface-2);
  color: var(--icon);
}

.st-plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
}

.st-plan {
  position: relative;
  padding: var(--space-4);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.st-plan--best {
  border: 2px solid var(--accent);
}

.st-plan--maybe {
  border: 1.5px dashed var(--border-strong);
}

.st-plan--flat {
  background: var(--surface-2);
  border-color: transparent;
}

.st-plan__best {
  position: absolute;
  top: -10px;
  right: var(--space-3);
}

.st-plan__note {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  color: var(--text-muted);
}

/* Comptes sur cet appareil */
.st-accounts {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.st-account {
  min-height: 64px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.st-account.is-current {
  border-color: var(--accent);
  background: var(--surface-2);
}

.st-account > .st-btn,
.st-account > .st-icon-btn,
.st-account > .st-tag {
  flex-shrink: 0;
}

.st-card .st-accounts__add {
  width: 100%;
  min-height: 64px;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.st-card .st-accounts__add:hover {
  background: var(--surface-2);
  filter: none;
  transform: none;
}

/* Mot de passe */
.st-pwd {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.st-pwd[hidden] {
  display: none;
}

.st-pwd__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
}

.st-pwd__rules {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.st-pwd__rules li {
  height: 26px;
  padding: 0 10px 0 8px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.st-pwd__rules li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}

.st-pwd__rules li.is-ok {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.st-pwd__rules li.is-ok::before {
  width: 10px;
  height: 6px;
  border-radius: 0;
  background: none;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(-45deg);
}

.st-pwd__submit {
  align-self: flex-start;
}

/* Fenêtre de double authentification */
.st-tfa {
  width: min(440px, calc(100vw - var(--space-8)));
}

.st-tfa__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.st-tfa__steps {
  margin: 0;
  padding-left: 20px;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--text);
}

/* Le QR garde un fond blanc dans les deux thèmes (lisible par les applications) */
.st-tfa__qr {
  align-self: center;
  width: 200px;
  height: 200px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: #FFFFFF;
}

.st-tfa__key summary {
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
}

.st-tfa__key code {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  word-break: break-all;
  color: var(--text);
}

.st-tfa__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ---------- Documents légaux ---------- */

.st-legal {
  height: min(860px, calc(100dvh - var(--space-8)));
}

.st-legal__head {
  padding: var(--space-3) var(--space-2) var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--hairline);
}

.st-legal__tabs {
  flex: 1;
  min-width: 0;
}

.st-legal__frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 0;
  background: var(--bg);
}

/* Zone qui défile : atteignable au clavier (flèches), sans contour au clic */
.st-settings__content:focus:not(:focus-visible) {
  outline: none;
}
