/* Umbra : feuille de style principale, identité « Horizon ».
   Les tokens viennent de docs/DESIGN.md. Toute couleur ou taille passe par une
   variable. Deux thèmes, la nuit (sombre) et l'aube (clair) : chaque couleur
   est écrite une fois avec ses deux valeurs, `light-dark(aube, nuit)`, et le
   navigateur choisit selon `color-scheme`. Par défaut le thème suit
   l'appareil ; le bouton de l'en-tête (js/theme-toggle.js) peut l'imposer
   avec l'attribut `data-theme` de <html>. */

/* Polices auto-hébergées (licence OFL, fichiers et licences dans
   static/vendor/fonts/) : aucun appel à un service extérieur. */
@font-face {
  font-family: "Outfit";
  src: url("/static/vendor/fonts/outfit-5.3.0-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("/static/vendor/fonts/manrope-5.3.0-latin-wght.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/vendor/fonts/ibm-plex-mono-5.3.0-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/vendor/fonts/ibm-plex-mono-5.3.0-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Couleurs : light-dark(aube, nuit) */
  --bg: light-dark(#f5f8ff, #0c1230);
  --surface: light-dark(#ffffff, #151d45);
  --surface-hover: light-dark(#eef3ff, #1b2552);
  --field: light-dark(#f5f8ff, #0f1638);
  --border: light-dark(#d9e2f5, #2a3570);
  --border-dashed: light-dark(#b9c7e6, #3a4686);
  --text: light-dark(#111a3a, #eef2ff);
  --text-muted: light-dark(#4f5b80, #a9b4dd);
  --text-faint: light-dark(#56628a, #9aa6d2);
  --accent: light-dark(#2b5fd9, #8ab8ff);
  --accent-hover: light-dark(#1f4bb5, #a9caff);
  --on-accent: light-dark(#ffffff, #0c1230);
  --accent-soft: light-dark(#e6eeff, rgba(138, 184, 255, 0.16));
  --accent-ink: light-dark(#1f4bb5, #cfe0ff);
  --nav-current: light-dark(rgba(255, 255, 255, 0.7), rgba(238, 242, 255, 0.12));
  --status-warn: light-dark(#8a4b00, #f2b65a);
  --warn-bg: light-dark(#fff1dc, rgba(242, 182, 90, 0.1));
  --warn-border: light-dark(#f0c987, rgba(242, 182, 90, 0.4));
  --status-off: light-dark(#b9c7e6, #4a5590);
  --danger: light-dark(#b42318, #ff9b9b);
  --danger-bg: light-dark(#fdecea, rgba(255, 155, 155, 0.1));
  --danger-border: light-dark(#f3b8b2, rgba(255, 155, 155, 0.4));
  --success: light-dark(#1e6b40, #8fe3b0);
  --success-bg: light-dark(#e7f6ee, rgba(143, 227, 176, 0.1));
  --success-border: light-dark(#b7e2c8, rgba(143, 227, 176, 0.35));
  --shadow: 0 12px 30px light-dark(rgba(43, 95, 217, 0.08), rgba(3, 6, 20, 0.35));
  --shadow-lg: 0 24px 60px light-dark(rgba(43, 95, 217, 0.14), rgba(3, 6, 20, 0.45));

  /* Logo */
  --logo-line: light-dark(#4f5b80, #a9b4dd);
  --logo-star: light-dark(#111a3a, #eef2ff);

  /* Paysage : ciel bleu pâle et pêche à l'aube, indigo étoilé la nuit ;
     planète blanche comme une lune en plein jour, bleu pâle la nuit. */
  --sky-1: light-dark(#b9d2ff, #070b24);
  --sky-2: light-dark(#dce8ff, #1b2b66);
  --sky-3: light-dark(#ffe6d4, #3c4e93);
  --sky-glow: light-dark(rgba(255, 201, 163, 0.7), rgba(240, 162, 126, 0.5));
  --sky-glow-edge: light-dark(rgba(255, 201, 163, 0), rgba(240, 162, 126, 0));
  --star: light-dark(transparent, #ffffff);
  --planet: light-dark(#ffffff, #9fc0ff);
  --planet-shade: light-dark(rgba(185, 210, 255, 0.45), rgba(27, 43, 102, 0.55));
  --ring: light-dark(#ffffff, #c9dbff);
  --orb-ring: light-dark(#7fa3f0, #c9dbff);
  --mountain-far: light-dark(#a9c0ee, #1a2556);
  --mountain-mid: light-dark(#c7d6f5, #131b45);

  /* Typographie */
  --font-display: "Outfit", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  /* Formes et espacements */
  --radius-xl: 28px;
  --radius-lg: 24px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --radius-pill: 999px;
  --container: 1200px;
  --gutter: 24px;

  /* Thème de l'appareil par défaut ; nuit quand il n'en exprime aucun. */
  color-scheme: dark light;
}

/* Thème imposé par le bouton de l'en-tête. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* Repli pour les navigateurs d'avant 2024 qui ne connaissent pas
   `light-dark()` (iOS 16, par exemple) : sans lui, toutes les couleurs
   ci-dessus seraient ignorées. Ces navigateurs ont toujours la nuit ; le
   bouton de thème n'y change rien. Valeurs identiques aux secondes valeurs de
   `light-dark()` : les garder alignées. */
@supports not (color: light-dark(#000000, #ffffff)) {
  :root {
    --bg: #0c1230;
    --surface: #151d45;
    --surface-hover: #1b2552;
    --field: #0f1638;
    --border: #2a3570;
    --border-dashed: #3a4686;
    --text: #eef2ff;
    --text-muted: #a9b4dd;
    --text-faint: #9aa6d2;
    --accent: #8ab8ff;
    --accent-hover: #a9caff;
    --on-accent: #0c1230;
    --accent-soft: rgba(138, 184, 255, 0.16);
    --accent-ink: #cfe0ff;
    --nav-current: rgba(238, 242, 255, 0.12);
    --status-warn: #f2b65a;
    --warn-bg: rgba(242, 182, 90, 0.1);
    --warn-border: rgba(242, 182, 90, 0.4);
    --status-off: #4a5590;
    --danger: #ff9b9b;
    --danger-bg: rgba(255, 155, 155, 0.1);
    --danger-border: rgba(255, 155, 155, 0.4);
    --success: #8fe3b0;
    --success-bg: rgba(143, 227, 176, 0.1);
    --success-border: rgba(143, 227, 176, 0.35);
    --shadow: 0 12px 30px rgba(3, 6, 20, 0.35);
    --shadow-lg: 0 24px 60px rgba(3, 6, 20, 0.45);
    --logo-line: #a9b4dd;
    --logo-star: #eef2ff;
    --sky-1: #070b24;
    --sky-2: #1b2b66;
    --sky-3: #3c4e93;
    --sky-glow: rgba(240, 162, 126, 0.5);
    --sky-glow-edge: rgba(240, 162, 126, 0);
    --star: #ffffff;
    --planet: #9fc0ff;
    --planet-shade: rgba(27, 43, 102, 0.55);
    --ring: #c9dbff;
    --orb-ring: #c9dbff;
    --mountain-far: #1a2556;
    --mountain-mid: #131b45;

    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.2;
}

a {
  color: var(--accent);
}

/* Focus toujours visible au clavier, avec la couleur d'accent */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

@media (max-width: 480px) {
  :root {
    --gutter: 16px;
  }
}

/* Logo (partials/logo.html) : couleurs du thème, aplats seulement. */
.logo {
  display: block;
  width: 100%;
  height: 100%;
}

.logo__line {
  fill: none;
  stroke: var(--logo-line);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logo__stars {
  fill: var(--logo-star);
}

.logo__spark {
  fill: var(--accent);
}

/* Paysage (partials/sky_*.html) : posé derrière le contenu de son bloc. Les
   couleurs viennent des variables, donc du thème. */
.sky {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.sky__top {
  stop-color: var(--sky-1);
}

.sky__middle {
  stop-color: var(--sky-2);
}

.sky__horizon {
  stop-color: var(--sky-3);
}

.sky__glow-center {
  stop-color: var(--sky-glow);
}

.sky__glow-edge {
  stop-color: var(--sky-glow-edge);
}

.sky__stars {
  fill: var(--star);
}

.sky__planet {
  fill: var(--planet);
}

.sky__moon {
  fill: var(--planet);
  opacity: 0.8;
}

.sky__shade {
  fill: var(--planet-shade);
}

.sky__ring {
  fill: none;
  stroke: var(--ring);
  opacity: 0.8;
}

.sky__far {
  fill: var(--mountain-far);
}

.sky__mid {
  fill: var(--mountain-mid);
}

/* La dernière crête a la couleur du fond : la page la prolonge. */
.sky__near {
  fill: var(--bg);
}

/* Bloc d'en-tête posé sur le paysage : fine bande sur les pages pratiques,
   grand bandeau avec la salutation sur l'accueil. */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.hero--banner {
  min-height: 360px;
}

.hero__greeting {
  margin-top: auto;
  padding-top: 40px;
  padding-bottom: 56px;
}

.hero__eyebrow {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hero__title {
  margin: 0;
  font-weight: 300;
  font-size: 48px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

@media (max-width: 480px) {
  .hero__title {
    font-size: 38px;
  }
}

/* En-tête : trois colonnes, le nom du site à gauche, les boutons de
   navigation au centre de la page, le thème, le compte et la déconnexion à
   droite. Les colonnes de côté ont la même largeur : la navigation reste
   centrée quelle que soit la longueur de la rubrique ou de l'identifiant. */
.site-header__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "brand nav user";
  align-items: center;
  gap: 12px 20px;
  min-height: 72px;
  padding-block: 16px;
}

/* Logo (constellation en U) suivi du nom du site et de la rubrique. */
.brand {
  grid-area: brand;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
}

.brand__logo {
  flex: none;
  display: block;
  width: 36px;
  height: 36px;
}

/* Une rubrique trop longue pour sa colonne finit par « … ». */
.brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

/* Majuscules en CSS : les lecteurs d'écran lisent « Umbra », pas « U-M-B-R-A » */
.brand__name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.brand__sub {
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-nav {
  grid-area: nav;
}

.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Boutons de l'en-tête : posés sur le ciel, sans bordure. */
.site-header .button--ghost {
  border-color: transparent;
  font-weight: 400;
}

.site-header .button--ghost:hover {
  background: var(--nav-current);
}

.user-menu {
  grid-area: user;
  justify-self: end;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

/* Profil (icône et identifiant) : lien vers « Mon compte » */
.user-menu__user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  color: var(--text);
  text-decoration: none;
  -webkit-user-drag: none;
}

.user-menu__user:hover {
  background: var(--nav-current);
}

.user-menu__user--current {
  background: var(--nav-current);
}

.user-menu__name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}

.user-menu form {
  margin: 0;
}

/* En-tête sur mobile : ligne 1 = logo et nom à gauche, compte et
   déconnexion à droite ; ligne 2 = boutons de navigation. */
@media (max-width: 640px) {
  .site-header__inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand user"
      "nav nav";
  }

  .site-nav__list {
    justify-content: flex-start;
  }
}

/* Très petit écran : la rubrique sous le nom du site est masquée, le bouton
   actif de la navigation l'indique déjà. */
@media (max-width: 400px) {
  .brand__sub {
    display: none;
  }
}

/* Boutons : zone cliquable d'au moins 44 px, en pilule */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
}

.button--primary {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.button--primary:hover {
  background: var(--accent-hover);
}

.button--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.button--ghost:hover {
  background: var(--nav-current);
}

a.button {
  text-decoration: none;
  -webkit-user-drag: none;
}

/* Un bouton maintenu ne sélectionne pas son texte. */
.button,
.icon-button {
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Survol : le fond et la bordure s'éclairent doucement. */
.button,
.icon-button {
  transition:
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease;
}

/* Bouton de la rubrique affichée (navigation) : fond clair sur le ciel. */
.button--current,
.site-header .button--current {
  background: var(--nav-current);
  font-weight: 500;
}

/* Bouton de suppression : texte rosé. */
.button--danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.button--danger:hover {
  border-color: var(--danger);
}

.button--block {
  width: 100%;
  text-decoration: none;
}

/* Formulaires */
.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.field input {
  min-height: 50px;
  padding: 0 16px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
}

.field input:focus-visible {
  border-color: var(--accent);
  outline-offset: 1px;
}

/* Champ affiché mais non modifiable (identifiant d'une invitation, lien créé) */
.field input[readonly] {
  background: var(--surface-hover);
  color: var(--text-muted);
}

.field__hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-faint);
}

.field__optional {
  font-weight: 400;
  color: var(--text-faint);
}

/* Icônes (Lucide, intégrées dans les templates) : traits fins, couleur du texte */
.icon {
  display: inline-flex;
}

.icon[hidden] {
  display: none;
}

.icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.75;
}

/* Bouton rond ne contenant qu'une icône : 44 px, libellé dans aria-label */
.icon-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  cursor: pointer;
}

.icon-button[hidden] {
  display: none;
}

.icon-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Bouton d'icône sans bordure (déconnexion dans l'en-tête). */
.icon-button--bare {
  border-color: transparent;
  color: var(--text);
}

.icon-button--bare:hover {
  background: var(--nav-current);
}

/* Champ mot de passe avec le bouton œil (affiché par JS) dans le champ */
.password-input {
  position: relative;
  display: flex;
}

.password-input input {
  flex: 1;
  min-width: 0;
  padding-right: 56px;
}

.password-input .icon-button {
  position: absolute;
  top: 3px;
  right: 3px;
  border-color: transparent;
  border-radius: 12px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
  cursor: pointer;
}

.checkbox input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.checkbox__hint {
  color: var(--text-muted);
}

.alert {
  margin: 0 0 20px;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
}

.alert--error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.alert--success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.alert--warning {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--status-warn);
}

/* Texte lu par les lecteurs d'écran, invisible à l'écran. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Pages de connexion : paysage plein écran, carte posée devant */
.login {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  min-height: 100vh;
  padding: 48px 16px 40px;
}

.login__card {
  width: 100%;
  max-width: 420px;
  padding: 36px 32px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

@media (max-width: 400px) {
  .login__card {
    padding: 28px 22px 24px;
  }
}

.login__heading {
  margin-bottom: 24px;
  text-align: center;
}

.login__logo {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
}

.login__eyebrow {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.login__heading h1 {
  margin: 8px 0;
  font-weight: 300;
  font-size: 40px;
  line-height: 1.1;
}

.login__subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.5;
}

.login .button--primary {
  min-height: 52px;
  margin-top: 4px;
  font-size: 16px;
}

.login__card--wide {
  max-width: 480px;
}

.login__alt {
  margin: 16px 0 0;
  text-align: center;
  font-size: 14px;
}

/* Double authentification : étapes d'activation et codes de secours */
.setup-steps {
  display: grid;
  gap: 14px;
  margin: 0 0 20px;
  padding-left: 22px;
  color: var(--text-muted);
  font-size: 14px;
}

.setup-steps strong {
  color: var(--text);
}

.setup-steps__qr {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  margin: 12px auto;
  /* Fond blanc et marge : contraste net pour l'appareil photo, même en
     thème sombre. */
  padding: 8px;
  background: #ffffff;
  border-radius: var(--radius-sm);
}

.setup-steps__manual {
  display: block;
}

.secret-key {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.05em;
  overflow-wrap: anywhere;
  user-select: all;
}

.recovery-codes {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.recovery-codes__list {
  width: 100%;
  padding: 12px 14px;
  resize: none;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.7;
  text-align: center;
}

.recovery-codes .button {
  justify-self: center;
}

/* Lien-bouton pleine largeur (« Entrer dans Umbra ») : `flex` garde le
   centrage vertical et horizontal de `.button`. */
.login__card > .button--primary {
  display: flex;
  width: 100%;
}

.form__after {
  margin-top: 12px;
}

.login__signature {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* Contenu */
main {
  flex: 1;
}

.empty-state {
  margin-block: 8px 40px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.empty-state h1,
.empty-state h2 {
  margin-top: 0;
  font-size: 24px;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--text-muted);
}

/* Tableau de bord : cartes des applications */
.section-title {
  margin: 0 0 16px;
  font-size: 22px;
}

.section-lead {
  max-width: 640px;
  margin: -6px 0 16px;
  color: var(--text-muted);
  line-height: 1.5;
}

.app-section {
  margin-top: 44px;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Carte d'une app : sa petite planète, son nom, sa description, une flèche. */
.app-card {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  -webkit-user-drag: none;
  transition: border-color 250ms ease, background-color 250ms ease;
}

a.app-card:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.app-card__text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.app-card__name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.2;
}

.app-card__description {
  color: var(--text-muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.app-card__arrow {
  flex: none;
  color: var(--text-muted);
  transition: transform 250ms ease, color 250ms ease;
}

a.app-card:hover .app-card__arrow {
  color: var(--accent);
  transform: translateX(3px);
}

.app-card__status {
  font-size: 13px;
  color: var(--text-faint);
}

.app-card__action {
  margin: 0;
}

/* Petite planète à anneau (partials/orb.html) */
.orb {
  flex: none;
  width: 52px;
  height: 52px;
}

.orb__body {
  fill: var(--accent);
}

.orb__shade {
  fill: var(--surface);
  opacity: 0.35;
}

.orb__ring {
  fill: none;
  stroke: var(--orb-ring);
  stroke-width: 1.5;
}

/* Application sans accès : visible, mais en retrait, sans lien, avec un
   cadenas à la place de sa planète. */
.app-card--locked {
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  background: transparent;
  border: 1px dashed var(--border-dashed);
  box-shadow: none;
}

.app-card__head {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.app-card__lock {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
}

.app-card--locked .button--ghost {
  background: var(--surface);
}

/* Pied de page */
.site-footer {
  padding-block: 20px;
  text-align: center;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* Toutes les animations se coupent si l'utilisateur le demande */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Indicateurs de chargement htmx (`hx-indicator`). htmx ajoute normalement
   ces règles lui-même dans une balise <style>, que la CSP interdit : elles
   sont donc ici (voir la configuration htmx dans base.html). */
.htmx-indicator {
  opacity: 0;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
  transition: opacity 200ms ease-in;
}

/* Pages intérieures (administration…) : le titre suit la bande de paysage */
.page {
  padding-block: 8px 56px;
}

.page__heading {
  margin-bottom: 24px;
}

.page__heading h1 {
  margin: 0;
  font-weight: 300;
  font-size: 44px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

@media (max-width: 480px) {
  .page__heading h1 {
    font-size: 36px;
  }
}

.page__lead,
.page__badges {
  margin: 8px 0 0;
  color: var(--text-muted);
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 8px;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

/* Pastilles (rôle, statut) */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-muted);
  white-space: nowrap;
}

.badge--role {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
}

.badge--off {
  border-color: var(--status-off);
  color: var(--text-faint);
}

/* Liste des comptes */
.account-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.account-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
  transition: border-color 250ms ease, background-color 250ms ease;
}

a.account-row:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

/* Compte dont la fiche n'est pas consultable : ligne sans lien, en retrait. */
.account-row--locked {
  background: transparent;
  border: 1px dashed var(--border-dashed);
}

.account-row--disabled .account-row__name {
  color: var(--text-faint);
}

.account-row__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.account-row__name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.account-row__meta {
  font-size: 13px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* Panneaux (compte, fiche d'un compte, administration) */
.panel {
  margin-bottom: 24px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

@media (max-width: 480px) {
  .panel {
    padding: 20px;
  }
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

.panel__text {
  margin: 0 0 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.panel__text:last-child {
  margin-bottom: 0;
}

.panel__subtitle {
  margin: 20px 0 10px;
  font-size: 15px;
  color: var(--text-muted);
}

.panel__hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-faint);
}

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

.panel--danger h2 {
  color: var(--danger);
}

.facts {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  gap: 8px 24px;
  margin: 0;
}

.facts dt {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions form {
  margin: 0;
}

/* Historique des modifications et sessions */
.history {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history__item {
  display: flex;
  flex-direction: column;
  padding-left: 14px;
  border-left: 2px solid var(--border);
}

.history__text {
  overflow-wrap: anywhere;
}

.history__meta {
  font-size: 13px;
  color: var(--text-faint);
}

/* Informations en lecture, avec un bouton crayon pour celles qui se
   modifient : une ligne par information, séparées par un trait fin. */
.facts--editable {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.facts__row {
  display: grid;
  grid-template-columns: minmax(12rem, max-content) minmax(0, 1fr) 44px;
  align-items: center;
  gap: 4px 24px;
  min-height: 56px;
  padding-block: 6px;
  border-top: 1px solid var(--border);
}

.facts__row dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.facts__action {
  grid-column: 3;
}

.facts__action .icon-button {
  border-color: transparent;
  color: var(--accent);
}

a.icon-button {
  text-decoration: none;
  -webkit-user-drag: none;
}

/* Pastille à côté d'un texte (« Cet appareil ») */
.history__badge {
  margin-left: 10px;
}

/* Bouton sous une liste, détaché du texte */
.panel__actions {
  margin: 16px 0 0;
}

/* Boutons d'un formulaire : valider, annuler */
.form__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Pagination d'un historique : deux colonnes de même largeur autour du
   numéro de page, qui reste ainsi centré quelle que soit la largeur des
   boutons. */
.pagination {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "newer status older";
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.pagination__newer {
  grid-area: newer;
  justify-self: start;
}

.pagination__older {
  grid-area: older;
  justify-self: end;
}

.pagination__status {
  grid-area: status;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* Bouton sans effet (première ou dernière page) : visible mais éteint. */
.button--disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.pagination .button {
  white-space: nowrap;
}

.pagination__short {
  display: none;
}

/* Écran étroit : le numéro au-dessus, les deux boutons dessous, de même
   largeur, avec un libellé court. */
@media (max-width: 480px) {
  .pagination {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "status status"
      "newer older";
  }

  .pagination .button {
    justify-self: stretch;
    padding-inline: 8px;
  }

  .pagination__long {
    display: none;
  }

  .pagination__short {
    display: inline;
  }
}

/* Fiche d'un compte : accès aux applications */
.app-access-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-access {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-left: 14px;
  border-left: 2px solid var(--border);
}

.app-access__form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin: 0;
}

.app-access__right {
  padding-left: 28px;
}

.app-access__form .button {
  margin-top: 6px;
}

.app-access__name {
  font-weight: 600;
}

/* Boutons Accorder / Refuser d'une demande */
.request-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.request-actions form {
  margin: 0;
}

/* Pastille d'un onglet (demandes en attente) */
.tab-count {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

/* Onglets de l'administration (Comptes, Invitations) */
.tabs {
  margin-bottom: 20px;
}

.tabs__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Formulaire dans un panneau : champ de largeur raisonnable, bouton à sa taille */
.form--inline {
  align-items: flex-start;
}

.form--inline .field {
  width: 100%;
  max-width: 420px;
}

/* Lien à usage unique tout juste créé, avec son bouton « Copier » */
.created-link {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.copy-input {
  display: flex;
  gap: 8px;
}

.copy-input input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* Invitations en attente et passées */
.invitation-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.invitation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding-left: 14px;
  border-left: 2px solid var(--border);
}

.invitation form {
  margin: 0;
}

.invitation__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.invitation__name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.invitation__meta {
  font-size: 13px;
  color: var(--text-faint);
}

@media (max-width: 480px) {
  .facts {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .facts dd {
    margin-bottom: 8px;
  }

  /* Libellé au-dessus de la valeur, crayon à droite des deux. */
  .facts__row {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 2px 12px;
    padding-block: 10px;
  }

  .facts__row > * {
    grid-column: 1;
  }

  .facts__row > .facts__action {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
  }

  .facts__row dd {
    margin-bottom: 0;
  }
}
