/* New API authentication pages. Keep the existing React form and controls in place. */
#root > .relative.grid.h-svh.max-w-none:has(
  > .container > div > .w-full > div:first-child > p > a:is([href="/sign-up"], [href="/sign-in"]),
  > .container > div > .w-full > form input[name="username"]
) {
  --auth-ink: #151515;
  --auth-action: #141414;
  --auth-muted: #606060;
  --auth-line: #dedede;
  min-height: 100svh;
  height: auto;
  background: #fff;
  color: var(--auth-ink);
  color-scheme: light;
  font-family: system-ui, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;

  > a:first-child {
    inset-block-start: 26px;
    inset-inline-start: 26px;
    gap: 10px;
    color: inherit;
    text-decoration: none;

    img { width: 35px; height: 35px; }
    h1 { font: inherit; font-size: 24px; line-height: 1; font-weight: 700; letter-spacing: -.06em; }
  }

  > .container {
    display: grid;
    place-items: center;
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    padding: 76px 24px;
  }

  > .container > div {
    width: min(100%, 380px);
    padding: 0;
  }

  > .container > div > .w-full {
    display: grid;
    reading-flow: grid-rows;
    color: inherit;

    > * { margin-block: 0; min-width: 0; }

    > div:first-child {
      display: contents;

      > h2 {
        order: -1;
        margin: 0;
        text-align: start;
        font-size: clamp(35px, 3.2vw, 49px);
        line-height: 1.14;
        letter-spacing: -.062em;
        font-weight: 720;
      }

      > p {
        order: 1;
        margin: 9px 0 0;
        text-align: center;
        color: var(--auth-muted);
        font-size: 14px;
        line-height: 1.5;
      }
    }

    > form {
      display: grid;
      gap: 14px;
      margin-block: 29px 0;
    }

    > :not(form):not(:first-child) { order: 2; margin-block-start: 9px; }

    a:is([href="/sign-in"], [href="/sign-up"], [href="/forgot-password"]) {
      display: inline-flex;
      align-items: center;
      min-height: 44px;
      color: #262626;
      font-size: 14px;
      font-weight: 650;
      text-decoration: underline;
      text-underline-offset: 4px;

      &:hover { text-decoration-thickness: 2px; }
    }

    a[href="/forgot-password"] {
      position: static;
      justify-self: end;
      margin-block: -4px -5px;
    }

    :focus-visible { outline: 2px solid #696969; outline-offset: 3px; }
  }

  form {
    [data-slot="form-item"] { gap: 6px; min-width: 0; }
    label { font-size: 14px; line-height: 1.5; font-weight: 650; }

    input:is([data-slot="form-control"], [data-slot="input"]):not([type="checkbox"]):not([type="hidden"]) {
      width: 100%;
      min-width: 0;
      min-height: 48px;
      padding: 10px 15px;
      border: 1px solid var(--auth-line);
      border-radius: 11px;
      background: #fff;
      color: var(--auth-ink);
      box-shadow: none;
      font-size: 16px;

      &::placeholder { color: #737373; }
      &:focus { outline: none; border-color: #696969; box-shadow: 0 0 0 3px #ededed; }
      &[aria-invalid="true"] { border-color: #b42318; }
    }

    [data-slot="form-item"] > div:has(> input:is([name="password"], [name="confirmPassword"]) + button) {
      > input[data-slot="form-control"] { padding-inline-end: 51px; }
      > button {
        inset-block-start: 2px;
        inset-inline-end: 3px;
        width: 44px;
        height: 44px;
        border-radius: 8px;
        color: var(--auth-muted);
        &:hover { background: #f2f2f2; color: var(--auth-ink); }
      }
    }

    > button[type="submit"] {
      justify-content: center;
      width: 100%;
      min-height: 48px;
      border-radius: 999px;
      background: var(--auth-action);
      color: #fff;
      font-size: 14px;
      font-weight: 650;

      &:hover:not(:disabled) { background: #303030; }
      > svg.lucide-log-in { display: none; }
    }

    > div:has(> div > input[data-slot="input"]):has(> button[type="button"]) {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 9px;

      > button {
        min-height: 48px;
        padding-inline: 13px;
        border: 1px solid #e3e3e3;
        border-radius: 999px;
        background: #f3f3f3;
        color: #252525;
        font-size: 14px;
        font-weight: 650;
        &:hover:not(:disabled) { background: #e9e9e9; }
      }
    }
  }

  &:has(form input[name="confirmPassword"]) > .container > div > .w-full {
    > div:first-child > h2 { font-size: clamp(33px, 3vw, 44px); }
    > form { margin-block-start: 20px; gap: 11px; }
  }

  @media (min-width: 481px) and (pointer: fine) {
    > .container > div { zoom: .737; }
    > a:first-child img { width: 38.5px; height: 38.5px; }
    > a:first-child h1 { font-size: 26.4px; }
  }

  @media (max-width: 480px) {
    > .container > div > .w-full > form { margin-block-start: 21px; gap: 12px; }
  }
}
