@layer components {
  /* « Mon compte »: a column of cards under a head with tabs; on the phone each tab is a pushed screen with its own bar. */
  .page--account { max-width: 800px; }
  /* Under the header, in the page's own gap. */
  .page--account > .flashes { margin: 0; }

  .account-head { display: flex; flex-direction: column; gap: 4px; }
  .account-head h1 { font-size: 22px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
  .account-tabs {
    display: flex; gap: 4px; margin-top: 12px; border-bottom: 1px solid var(--border); overflow-x: auto;
    overflow-y: hidden; /* A tab's underline overlaps the border by 1 px: without this, the bar scrolls vertically. */
  }
  .account-tab {
    display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; margin-bottom: -1px; white-space: nowrap;
    border-bottom: 2px solid transparent; color: var(--muted-foreground); text-decoration: none; font-weight: 500;
  }
  .account-tab:hover { color: var(--foreground); text-decoration: none; }
  .account-tab[aria-current="page"] { color: var(--foreground); border-bottom-color: var(--jx-accent); }
  .account-tab:focus-visible { outline: 2px solid transparent; box-shadow: 0 0 0 3px var(--jx-accent); border-radius: var(--radius-sm); }

  .account-pushed-head { display: none; }
  .account-back {
    display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap);
    border-radius: var(--radius-sm); color: var(--muted-foreground); text-decoration: none;
  }
  .account-back:focus-visible { outline: 2px solid transparent; box-shadow: 0 0 0 3px var(--jx-accent); }
  @media (max-width: 1099px) {
    .account-head { display: none; }
    .account-pushed-head {
      position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 4px; min-height: 52px;
      margin: 0 calc(-1 * var(--gutter)); padding: var(--safe-top) 8px 0;
      border-bottom: 1px solid var(--border); background: var(--background);
    }
    /* The top bar opens the screen, against its top edge (as a document's or Nouveautés'): no padding of the page above it. */
    .app-main:has(> .page > .account-pushed-head) { padding-top: 0; }
    .account-pushed-head h1 { font-size: 17px; line-height: 1.3; font-weight: 600; }
    .account-pushed-head:not(:has(.account-back)) h1 { padding-left: 8px; }
  }

  .account-card { display: flex; flex-direction: column; }
  ul.account-card { margin: 0; padding: 0; list-style: none; }
  .account-row {
    display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border);
  }
  .account-row:last-child { border-bottom: 0; }
  .account-row__icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; color: var(--muted-foreground); }
  .account-row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .account-row__title { font-weight: 500; }
  .account-row__desc, .account-row__meta { color: var(--muted-foreground); font-size: 14px; }
  .account-row__aside { flex: none; display: flex; align-items: center; gap: 8px; }
  @media (max-width: 767px) {
    .account-row { flex-wrap: wrap; }
    .account-row__aside { flex: 1 0 100%; padding-left: 48px; }
    .account-row:has(.icon-tile) .account-row__aside { padding-left: 52px; }
    /* A long label wraps inside the card: a button never breaks its line by default. */
    .account-row__aside form { min-width: 0; }
    .account-row__aside .button { height: auto; min-height: var(--tap); max-width: 100%; padding-block: 8px; line-height: 1.3; text-align: start; white-space: normal; }
  }

  /* A warning line: the triangle carries the state with the text, never color alone. */
  .account-alert {
    display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: var(--radius-md);
    border: 1px solid var(--border); background: var(--surface);
  }
  .account-alert svg { flex: none; margin-top: 2px; color: var(--jx-wait); }

  /* A calm note in a grey box; the info icon goes with the text. */
  .account-note {
    display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 12px 14px; border-radius: var(--radius-md);
    background: var(--muted); color: var(--muted-foreground); font-size: 14px; line-height: 1.45;
  }
  .account-note svg { flex: none; margin-top: 2px; }

  /* The info banner of the account pages: tinted in the accent, the icon in the accent. */
  .page--account .alert--tint { background: var(--jx-accent-soft); border-color: transparent; color: var(--foreground); }
  .page--account .alert--tint svg { color: var(--jx-accent); }

  /* « Vos informations »: the save button at the right of the footer, its sentence on the left. */
  .account-info-footer { justify-content: flex-end; }

  /* Shown only while its form is being sent. */
  .account-pending { display: none; }
  form[aria-busy="true"] .account-pending { display: inline; }

  /* Connections: one frame per service row, so a row can reload alone while its check runs. */
  .connection-frame { display: block; }
  .connection { border-bottom: 1px solid var(--border); }
  .connection-frame:last-child .connection { border-bottom: 0; }
  .connection .connection-line { border-bottom: 0; align-items: flex-start; }
  .connection-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .connection-name h2 { font-size: 16px; }
  .connection-details { display: flex; flex-direction: column; gap: 8px; }
  .connection-details p, .connection-details ul { margin: 0; }
  .connection-dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  .connection-dialog-actions form { display: contents; }
  .account-missing { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding-inline: 4px; color: var(--muted-foreground); }
  .account-missing svg { flex: none; margin-top: 3px; }
  @media (max-width: 767px) {
    .connection .account-row__aside { flex-wrap: wrap; }
    .connection-dialog-actions .button { flex: 1 1 100%; min-height: var(--tap); }
  }

  /* Profile: the photo, the name, the read-only lines, the published card and its documents. */
  .profile-photo { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
  .profile-photo [hidden] { display: none; }
  .profile-photo-body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
  .profile-photo-form, .profile-photo-remove { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
  .profile-photo-body > .hint, .profile-photo-body > .field-error { flex: 1 0 100%; margin: 0; }
  .field-error { margin: 4px 0 0; font-size: 13px; line-height: 1.45; color: var(--jx-no); }
  .field-error[hidden] { display: none; }
  .field-count { margin: 4px 0 0; font-size: 13px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
  .field-count--over { color: var(--jx-no); font-weight: 600; }
  .profile-readonly {
    margin: 16px 0; padding: 12px 14px; border-radius: var(--radius-md); background: var(--muted);
    display: flex; flex-direction: column; gap: 8px;
  }
  .profile-readonly .hint { margin: 0; }
  .profile-readonly .dl { grid-template-columns: max-content 1fr; gap: 8px 24px; }
  .profile-readonly .dl dd { margin-bottom: 0; overflow-wrap: anywhere; }
  .profile-saved { color: var(--jx-ok); }
  .profile-field--changed { border-color: var(--jx-accent-line); box-shadow: inset 3px 0 0 var(--jx-accent); }
  .profile-draft-footer { align-items: center; }
  .profile-publish { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
  .profile-draft-footer:has(.profile-publish[aria-busy="true"]) .profile-footer-status { display: none; }
  .validated-document-icon { flex: none; display: grid; place-items: center; color: var(--muted-foreground); }
  .validated-document-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  @media (max-width: 767px) {
    .account-info-footer .button { width: 100%; }
    .profile-photo { gap: 12px; }
    .profile-photo-body { gap: 8px; }
    .profile-photo-remove .button { padding-inline: 12px; }
    .profile-draft-footer .profile-publish, .profile-draft-footer .profile-publish .button { width: 100%; }
  }
  /* Touch sizes hold up to the tablet, where the account pages keep the pushed header. */
  @media (max-width: 1099px) {
    .page--account .button { min-height: var(--tap); }
    .profile-field .button--icon { min-width: var(--tap); }
  }

  /* Security */
  .account-row__title.status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
  .account-row__title[title] { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
  .account-sessions-foot { align-items: center; }
  .account-password-form { display: flex; flex-direction: column; gap: 16px; }
  .account-password-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
  .account-link-button {
    padding: 0; border: 0; background: none; color: var(--jx-accent); font: inherit; cursor: pointer; text-decoration: underline;
  }
  .account-link-button:focus-visible { outline: 2px solid transparent; box-shadow: 0 0 0 3px var(--jx-accent); border-radius: var(--radius-sm); }
  .account-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

  /* The strength gauge: three segments; the text next to it carries the level, never the color alone. */
  .strength { display: flex; gap: 4px; margin-top: 8px; }
  .strength span { flex: 1; height: 6px; border-radius: 3px; background: var(--border); }
  .strength[data-level="weak"] span:nth-child(1) { background: var(--jx-no); }
  .strength[data-level="medium"] span:nth-child(-n + 2) { background: var(--jx-wait); }
  .strength[data-level="strong"] span { background: var(--jx-ok); }
  .account-match[data-state="match"] { color: var(--jx-ok); }
  .account-match[data-state="mismatch"] { color: var(--jx-no); }
  .account-match[data-state="match"]::before { content: "\2713\00a0"; }
  .account-match[data-state="mismatch"]::before { content: "!\00a0"; }
  .account-match:empty { display: none; }
  @media (max-width: 767px) {
    .account-dialog-actions { flex-direction: column-reverse; }
    .account-dialog-actions .button { width: 100%; min-height: var(--tap); }
  }

  /* A phone's sign-in code (ADR-0029 § 5): dark modules on white in every theme, or cameras miss it. */
  .phone-link__body { display: flex; align-items: center; gap: 24px; padding: 0 var(--space-4, 16px) var(--space-4, 16px); }
  .phone-link__code { margin: 0; flex: none; padding: 12px; background: #fff; border-radius: var(--radius-md, 12px); border: 1px solid var(--border); }
  .phone-link-qr { display: block; width: 208px; height: 208px; }
  .phone-link-qr path { fill: #000; }
  .phone-link__steps { margin: 0; padding-left: 1.2em; display: grid; gap: 10px; line-height: 1.45; }
  .phone-link__validity { padding: 0 var(--space-4, 16px) var(--space-4, 16px); margin: 0; }
  .phone-link__done { display: grid; justify-items: center; gap: 8px; padding: 24px 16px 28px; text-align: center; }
  .phone-link__done[hidden], .phone-link [hidden] { display: none; }
  .phone-link__done svg { color: var(--jx-ok); }
  @media (max-width: 767px) {
    .phone-link__body { flex-direction: column; align-items: stretch; }
    .phone-link__code { align-self: center; }
  }
}
