@layer components {
  .field { display: grid; gap: var(--space-1); }
  .field__label { font-size: var(--text-xs); font-weight: 500; color: var(--ink-soft); }
  .field__hint { font-size: var(--text-xs); color: var(--ink-faint); }

  /* Champs : 32 px, anneau d'accent au focus, comme les contrôles natifs du Mac. */
  .input {
    width: 100%; min-height: var(--control-lg);
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--line-strong); border-radius: var(--radius);
    background: var(--paper-raised); box-shadow: var(--shadow-xs);
    color: var(--ink); font: inherit;
    transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
  }
  .input::placeholder { color: var(--ink-faint); }
  .input:hover { border-color: color-mix(in srgb, var(--line-strong), var(--ink) 12%); }
  .input:focus { outline: none; border-color: var(--ink-soft); box-shadow: 0 0 0 3px var(--focus-ring); }
  textarea.input { resize: vertical; min-height: 8rem; padding-block: var(--space-2); font-size: var(--text-md); line-height: var(--leading); }
  select.input { padding-inline-end: var(--space-6); }
  input[type="file"].input { padding: var(--space-1); font-size: var(--text-xs); }
  input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

  .form-errors {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius); background: var(--accent-soft); color: color-mix(in srgb, var(--accent), var(--ink) 40%);
    animation: rise-in var(--duration) var(--ease-out);
  }
  .form-errors ul { padding-inline-start: var(--space-4); }

  .fieldset { border: var(--hairline); border-radius: var(--radius-lg); padding: var(--space-4); margin: 0; }
  .fieldset__legend { padding-inline: var(--space-2); font-weight: 600; }
}

@layer components {
  /* Choix du thème : trois cartes avec une miniature de l'interface */
  .themes { display: grid; gap: var(--space-2); border: 0; padding: 0; margin: 0; }
  .theme-option {
    display: flex; align-items: center; gap: var(--space-4);
    padding: var(--space-3); border: var(--hairline); border-radius: var(--radius-lg); cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
  }
  .theme-option:hover { background: var(--hover); }
  .theme-option:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
  .theme-option:has(input:focus-visible) { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
  .theme-option__text { display: grid; gap: var(--space-0); }

  .theme-option__preview {
    display: grid; grid-template-columns: 1fr 2.4fr; grid-template-rows: 1fr 1fr; gap: 3px;
    width: 4.5rem; height: 3rem; padding: 4px; flex: none; border-radius: var(--radius); border: var(--hairline);
  }
  .theme-option__preview > span { border-radius: 2px; }
  .theme-option__preview > span:first-child { grid-row: span 2; }
  .theme-option__preview--light { background: #F5F3EE; }
  .theme-option__preview--light > span { background: #FFFFFF; box-shadow: 0 0 0 1px #E8E5DE; }
  .theme-option__preview--light > span:first-child { background: #E8E5DE; box-shadow: none; }
  .theme-option__preview--dark { background: #121110; }
  .theme-option__preview--dark > span { background: #1A1918; box-shadow: 0 0 0 1px #2A2927; }
  .theme-option__preview--dark > span:first-child { background: #2A2927; box-shadow: none; }
  /* Automatique : moitié clair, moitié sombre */
  .theme-option__preview--auto { background: linear-gradient(90deg, #F5F3EE 50%, #121110 50%); }
  .theme-option__preview--auto > span { background: transparent; box-shadow: 0 0 0 1px rgb(136 136 136 / 0.5); }

  /* Bascule de thème : le nouveau thème se pose en fondu sur l'ancien, resté opaque (pas de flash). */
  .theme-switching::view-transition-old(*) { display: block; animation: none; }
  .theme-switching::view-transition-new(*) { animation: var(--duration-slow) var(--ease) both fade-in; }
}
