  :root {
    --bg: #fafaf8;
    --ink: #333333;
    --yellow: #f5c400;
    --yellow-dim: #f5c40033;
    --line: #e3e0d9;
    --error: #c94b3f;
  }

  * { box-sizing: border-box; }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  html, body {
    margin: 0;
    min-height: 100%;
  }

  body {
    background:
      radial-gradient(circle at 12% 10%, rgba(245,196,0,0.12), transparent 50%),
      radial-gradient(circle at 88% 90%, rgba(51,51,51,0.06), transparent 50%),
      var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
  }

  .form-wrap {
    width: 100%;
    max-width: 360px;
  }

  .card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 2.2rem 2rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    position: relative;
  }

  .logo {
    display: block;
    width: 110px;
    margin: 0 auto 1.5rem;
  }

  h1 {
    font-size: 1.18rem;
    font-weight: 600;
    text-align: center;
    margin: 0 0 1.3rem;
  }

  .method-switch {
    display: flex;
    background: #f1efe9;
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 1.3rem;
  }

  .method-switch button {
    flex: 1;
    padding: 0.52rem 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #77766f;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s ease, color 0.2s ease;
  }

  .method-switch button.active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  }

  label {
    display: block;
    font-size: 0.69rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #77766f;
    font-weight: 700;
    margin-bottom: 0.35rem;
  }

  label .opt {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    color: #a8a69e;
  }

  label .req {
    color: var(--error);
  }

  p.legend {
    font-size: 0.76rem;
    color: #a8a69e;
    text-align: center;
    margin: 0 0 1.4rem;
  }

  .field { margin-bottom: 0.95rem; }
  .field:last-child { margin-bottom: 0; }

  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="password"] {
    width: 100%;
    padding: 0.68rem 0.85rem;
    font-size: 0.93rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-family: inherit;
  }

  input:focus {
    outline: none;
    border-color: var(--yellow);
    box-shadow: 0 0 0 3px var(--yellow-dim);
  }

  input::placeholder {
    font-style: italic;
    color: #b8b6ad;
  }

  input.invalid { border-color: var(--error); }
  input.invalid:focus { box-shadow: 0 0 0 3px rgba(201,75,63,0.15); }

  .field-consent { margin-top: 0.3rem; }

  .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    background: #f1efe9;
    border-radius: 8px;
    padding: 0.65rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.4;
    cursor: pointer;
  }
  .checkbox-label input[type="checkbox"] {
    flex-shrink: 0;
    width: 17px;
    height: 17px;
    accent-color: var(--ink);
    cursor: pointer;
  }
  .checkbox-label a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
  .field-consent.has-error .checkbox-label { color: var(--error); background: rgba(201,75,63,0.08); }

  .error-text {
    display: none;
    color: var(--error);
    font-size: 0.72rem;
    margin-top: 0.35rem;
  }
  .field.has-error .error-text { display: block; }

  .info-text {
    background: var(--yellow-dim);
    color: var(--ink);
    font-size: 0.82rem;
    line-height: 1.5;
    border-radius: 8px;
    padding: 0.65rem 0.8rem;
    margin-bottom: 0.9rem;
  }

  input[type="password"]::-ms-reveal,
  input[type="password"]::-ms-clear {
    display: none;
  }

  .pw-row { position: relative; }
  .pw-row input { padding-right: 2.6rem; }

  .pw-eye {
    position: absolute;
    right: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    color: #9a9994;
    -webkit-user-select: none;
    user-select: none;
  }
  .pw-eye:active { color: var(--ink); }
  .pw-eye svg { width: 18px; height: 18px; }

  button.submit, a.submit {
    display: block;
    width: 100%;
    padding: 0.78rem;
    margin-top: 1.05rem;
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.93rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
    cursor: pointer;
  }
  button.submit:hover, a.submit:hover { background: #1f1f21; }
  button.submit:disabled { background: #a8a69e; cursor: not-allowed; }

  .forgot {
    display: block;
    text-align: center;
    margin-top: 0.9rem;
    font-size: 0.81rem;
    color: #77766f;
    text-decoration: none;
  }
  .forgot:hover { color: var(--ink); text-decoration: underline; }

  button.secondary {
    width: 100%;
    padding: 0.74rem;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
  }
  button.secondary:hover { border-color: #cac7bd; }

  .back-icon-btn {
    display: none;
    position: absolute;
    top: 1.15rem;
    left: 1.15rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--line);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ink);
    z-index: 2;
    padding: 0;
  }
  .back-icon-btn:hover { border-color: #cac7bd; }
  .back-icon-btn svg { width: 15px; height: 15px; }

  /* the back button only makes sense once we've left the login page */
  .card[data-page="signup"] .back-icon-btn,
  .card[data-page="confirm"] .back-icon-btn,
  .card[data-page="forgot"] .back-icon-btn {
    display: flex;
  }

  p.sub {
    font-size: 0.83rem;
    color: #77766f;
    text-align: center;
    margin: -0.6rem 0 1.35rem;
    line-height: 1.5;
  }

  /*
    One single, deliberately simple transition mechanism drives every
    "page swap" in this UI (login <-> signup <-> confirmation, and the
    small identifiants/email switch below): a cross-fade between
    absolutely-positioned panels, with the shared "stage" wrapper
    animating its own height to match whichever panel becomes active.

    No 3D transforms, no perspective/backface-visibility, and no
    setTimeout calls tuned to guess an animation's invisible midpoint —
    all of that is what made the previous flip-card version fragile and
    inconsistent across browsers. Opacity, transform: translateY and
    height transitions are about as broadly and consistently supported
    as CSS animation gets, so this behaves the same everywhere.
  */
  .stage {
    position: relative;
    overflow: hidden;
    transition: height 0.28s ease;
  }

  .page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.22s ease, transform 0.22s ease;
    pointer-events: none;
  }

  .page.is-active {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .method-stage { margin-bottom: 0.95rem; }

  #signup-success {
    text-align: center;
    padding: 0 0 0.4rem;
  }

  .success-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--yellow-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
  }
  .success-icon svg { width: 22px; height: 22px; color: var(--ink); }

  #signup-success h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
  }
  #signup-success p {
    font-size: 0.87rem;
    color: #77766f;
    line-height: 1.5;
    margin: 0;
  }

  @media (prefers-reduced-motion: reduce) {
    .stage, .page { transition: none !important; }
  }
