/* CLAUDE 10-19 (the owner: the sign-up box "looks like shit"): the sign-in / create-account / reset / email-code dialog
   (#loginDialog in index.html, app-account.js). One sheet that fits one screen with no inner scroll: 400 px on a desktop,
   the full screen on a phone. Fields are clear boxes with a label above and their error below (the owner asked for boxes
   here, over Graphite's "no box at rest"); one primary button; the logo is the real R mark. Everything is scoped to
   #loginDialog so the older dialog rules (style.css, studio.css, phone.css) cannot leak in. */
#loginDialog {
  --af-h: var(--h-lg);
  width: min(400px, calc(100vw - var(--s-6)));
  max-width: none;
  max-height: calc(100dvh - var(--s-6));
  padding: var(--s-5);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--c-surface);
  color: var(--c-fg);
  border: 0;
  border-radius: var(--r-lg);
  box-shadow: var(--hl), var(--e-float);
  font-size: var(--t-body);
  line-height: 20px;
}
#loginDialog::backdrop {
  background: rgba(6, 6, 9, 0.72);
}
#loginDialog :is(p, h2, form, fieldset) {
  margin: 0;
}
#loginDialog form,
#loginDialog .gate {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
#loginDialog .auth-step:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

/* ----- header: the R mark and the wordmark, the close button ----- */
#loginDialog .auth-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-5);
}
#loginDialog .auth-brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-title);
  font-weight: 600;
  letter-spacing: -0.01em;
}
#loginDialog .auth-brand img {
  display: block;
  border-radius: var(--r-sm);
}
#loginDialog .auth-close {
  position: static;
  display: grid;
  place-items: center;
  width: var(--h-md);
  height: var(--h-md);
  min-height: 0;
  padding: 0;
  margin: 0 calc(-1 * var(--s-2)) 0 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--c-fg-2);
}
#loginDialog .auth-close svg,
#loginDialog .af-eye svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (hover: hover) and (pointer: fine) {
  #loginDialog .auth-close:hover {
    background: var(--c-raised);
    color: var(--c-fg);
  }
}

/* ----- Sign in / Create account (the .m-seg control in controls.css) ----- */
#loginDialog .auth-tabs {
  display: flex;
  width: 100%;
  margin-bottom: var(--s-5);
}
#loginDialog .auth-tabs button {
  flex: 1;
  font-weight: 500;
}

/* ----- headings and the lines under them ----- */
#loginDialog h2 {
  font-size: var(--t-page);
  line-height: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-fg);
}
#loginDialog .auth-hint {
  font-size: var(--t-label);
  line-height: 18px;
  color: var(--c-fg-3);
}
#loginDialog :is(.auth-hint, .auth-sub) b {
  color: var(--c-fg);
  font-weight: 500;
}
#loginDialog .auth-sub {
  margin-top: calc(-1 * var(--s-2));
  font-size: var(--t-body);
  line-height: 20px;
  color: var(--c-fg-2);
}
#loginDialog .auth-hint a,
#loginDialog .auth-legal a,
#loginDialog .af-consent a,
#loginDialog .af-label a {
  color: var(--c-fg);
  text-decoration: underline;
  text-decoration-color: rgba(242, 240, 235, 0.35);
}
#loginDialog .auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-1) var(--s-4);
  font-size: var(--t-label);
  line-height: 18px;
}
#loginDialog .auth-links a {
  color: var(--c-fg-2);
  text-decoration: none;
}
#loginDialog .auth-links a:hover {
  color: var(--c-fg);
}

/* ----- a field: the label above, the box, then one line of help or the error ----- */
#loginDialog .af {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: var(--s-2);
  margin: 0;
  color: var(--c-fg-2);
}
#loginDialog .af-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: var(--t-label);
  line-height: 16px;
  font-weight: 500;
  color: var(--c-fg-2);
}
#loginDialog .af-label a {
  font-weight: 400;
  color: var(--c-fg-2);
}
#loginDialog .af-ctl {
  position: relative;
}
#loginDialog .af-input {
  display: block;
  width: 100%;
  height: var(--af-h);
  min-height: var(--af-h);
  margin: 0;
  padding: 0 var(--s-3);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-sm);
  background: var(--c-raised);
  background-image: none;
  color: var(--c-fg);
  font-size: var(--t-body);
  transition:
    border-color var(--d-hover) ease,
    background-color var(--d-hover) ease,
    box-shadow var(--d-hover) ease;
}
#loginDialog .af-input::placeholder {
  color: var(--c-fg-3);
}
@media (hover: hover) and (pointer: fine) {
  #loginDialog .af-input:hover {
    border-color: rgba(255, 255, 255, 0.2);
  }
}
#loginDialog .af-input:focus {
  border-color: rgba(242, 240, 235, 0.45);
  background: var(--c-raised);
  box-shadow: var(--e-1);
}
#loginDialog .af-input:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
}
#loginDialog .af-input[aria-invalid='true'] {
  border-color: var(--c-danger);
}
#loginDialog .af-input:-webkit-autofill {
  -webkit-text-fill-color: var(--c-fg);
  box-shadow: inset 0 0 0 40px var(--c-raised);
  caret-color: var(--c-fg);
}
#loginDialog .af-pw {
  padding-right: var(--s-7);
}
#loginDialog .af-eye {
  position: absolute;
  top: 50%;
  right: var(--s-1);
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: var(--h-md);
  height: var(--h-md);
  min-height: 0;
  padding: 0;
  border-radius: var(--r-sm);
  color: var(--c-fg-3);
  background: transparent;
}
#loginDialog .af-eye[aria-pressed='true'] {
  color: var(--c-fg);
}
#loginDialog .af-eye .eye-off,
#loginDialog .af-eye[aria-pressed='true'] .eye-on {
  display: none;
}
#loginDialog .af-eye[aria-pressed='true'] .eye-off {
  display: inline;
}
@media (hover: hover) and (pointer: fine) {
  #loginDialog .af-eye:hover {
    color: var(--c-fg);
    background: var(--c-overlay);
  }
}
#loginDialog :is(#verifyCode, #resetCode) {
  font-size: var(--t-page);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.4em;
  text-align: center;
  padding-left: 0.4em; /* the last digit's letter-spacing would push the group off centre */
}
#loginDialog #verifyCode {
  --af-h: 52px;
}
#loginDialog .af-help,
#loginDialog .af-err,
#loginDialog .email-check {
  min-height: 0;
  font-size: var(--t-label);
  line-height: 16px;
  color: var(--c-fg-3);
}
#loginDialog .email-check.good {
  color: var(--c-fg-2);
}
#loginDialog :is(.af-err, .email-check.bad, .auth-error) {
  color: var(--c-danger);
}
#loginDialog .email-check a {
  color: var(--c-fg);
}
#loginDialog :is(.af-err, .email-check, .auth-error):empty,
#loginDialog .af-err:not(:empty) ~ :is(.af-help, .email-check) {
  display: none; /* one line under a field: the error replaces the rule or the live check while it shows */
}
#loginDialog .auth-error {
  margin: 0;
  font-size: var(--t-label);
  line-height: 18px;
}

/* ----- consent: one required box, then two optional ones, smaller ----- */
#loginDialog .af-consent {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: var(--s-1) var(--s-3);
  align-items: start;
  margin: 0;
  font-size: var(--t-label);
  line-height: 18px;
  font-weight: 400;
  color: var(--c-fg-2);
  cursor: pointer;
}
#loginDialog .af-consent .af-err {
  grid-column: 2;
}
#loginDialog .auth-optional {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start; /* style.css "dialog form > div" right-aligns every div in a dialog form */
  gap: var(--s-2) var(--s-4);
  margin-top: calc(-1 * var(--s-1));
  padding-left: calc(16px + var(--s-3));
}
#loginDialog .auth-opt-label {
  flex-basis: 100%;
  font-size: var(--t-meta);
  line-height: 16px;
  color: var(--c-fg-3);
}
#loginDialog .auth-optional .af-consent {
  grid-template-columns: 14px auto;
  gap: var(--s-2);
  font-size: var(--t-meta);
  line-height: 16px;
  color: var(--c-fg-3);
}
#loginDialog input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-content: center;
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--r-xs);
  background: var(--c-raised);
  cursor: pointer;
  transition:
    background-color var(--d-hover) ease,
    border-color var(--d-hover) ease;
}
#loginDialog .auth-optional input[type='checkbox'] {
  width: 14px;
  height: 14px;
}
#loginDialog input[type='checkbox']::after {
  content: '';
  width: 10px;
  height: 10px;
  background: var(--c-primary-ink);
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 37% 70%);
  opacity: 0;
  scale: 0.5;
  transition:
    opacity var(--d-hover) ease,
    scale var(--d-ui) var(--ease-out);
}
#loginDialog input[type='checkbox']:checked {
  background: var(--c-fg);
  border-color: var(--c-fg);
}
#loginDialog input[type='checkbox']:checked::after {
  opacity: 1;
  scale: 1;
}
#loginDialog input[type='checkbox'][aria-invalid='true'] {
  border-color: var(--c-danger);
}
#loginDialog input[type='checkbox']:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
}

#loginDialog .turnstile {
  justify-content: center;
  margin: 0;
}

/* ----- the one primary button ----- */
#loginDialog button.primary {
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 0 var(--s-4);
  border: 0;
  border-radius: var(--r-sm);
  color: var(--c-primary-ink);
  font-size: var(--t-body);
  font-weight: 600;
}
#loginDialog button.primary[aria-busy='true'] {
  opacity: 0.7;
}

/* ----- Google and the social sign-ins: quiet, outlined; the "or" rule; their legal line ----- */
#loginDialog .google-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
#loginDialog .google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s-4);
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--c-fg);
  font-size: var(--t-body);
  font-weight: 500;
  text-decoration: none;
}
@media (hover: hover) and (pointer: fine) {
  #loginDialog .google-btn:hover {
    background: var(--c-raised);
    border-color: rgba(255, 255, 255, 0.2);
  }
}
#loginDialog .google-btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}
#loginDialog #googleBtn:empty {
  display: none;
}
#loginDialog .social-login {
  display: grid;
  gap: var(--s-2);
}
#loginDialog .auth-legal {
  margin: 0;
  font-size: var(--t-meta);
  line-height: 16px;
  color: var(--c-fg-3);
  text-align: left;
}
#loginDialog .auth-or {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--t-meta);
  color: var(--c-fg-3);
}
#loginDialog .auth-or::before,
#loginDialog .auth-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-line-strong);
}
#loginDialog .auth-or span {
  color: var(--c-fg-3);
}

/* ----- the code shown when email sending is off (development) ----- */
#loginDialog .dev-code {
  margin: 0;
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--c-raised);
  font-size: var(--t-label);
  line-height: 18px;
  color: var(--c-fg-2);
}
#loginDialog .dev-code b {
  display: block;
  margin-top: var(--s-1);
  font-size: var(--t-page);
  letter-spacing: 0.2em;
  color: var(--c-fg);
  font-variant-numeric: tabular-nums;
}

/* ----- a phone: the full screen, safe areas, 44 px targets ----- */
@media (max-width: 767.98px) {
  #loginDialog {
    --af-h: var(--h-touch);
    width: 100%;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: max(var(--s-3), env(safe-area-inset-top)) var(--s-4) max(var(--s-5), env(safe-area-inset-bottom));
    border-radius: 0;
    box-shadow: none;
  }
  #loginDialog .auth-head {
    margin-bottom: var(--s-4);
  }
  #loginDialog .auth-close,
  #loginDialog .af-eye {
    width: var(--h-touch);
    height: var(--h-touch);
  }
  #loginDialog .af-eye {
    right: 0;
  }
  #loginDialog .auth-tabs {
    margin-bottom: var(--s-4);
  }
  #loginDialog .auth-optional input[type='checkbox'] {
    width: 16px;
    height: 16px;
  }
  #loginDialog .auth-optional .af-consent {
    grid-template-columns: 16px auto;
  }
}
/* a short phone (an SE at 640 px): tighter rhythm so more of the form fits; past that the sheet scrolls */
@media (max-width: 767.98px) and (max-height: 700px) {
  #loginDialog :is(form, .gate, .auth-step:not([hidden])) {
    gap: var(--s-3);
  }
  #loginDialog :is(.auth-head, .auth-tabs) {
    margin-bottom: var(--s-3);
  }
  #loginDialog .google-wrap {
    gap: var(--s-2);
    margin-bottom: var(--s-3);
  }
}
/* CLAUDE 10-23 (LOOSE-ENDS B10): under 680 px tall (an SE at 360 x 640) Create account with Google on still scrolled
   50 px; one step tighter again, so it fits: the fields' label sits closer to its box, the rows and the blocks 8 px
   apart, less padding under the last line. The 44 px targets and the type sizes stay. */
@media (max-width: 767.98px) and (max-height: 680px) {
  #loginDialog {
    padding-bottom: max(var(--s-3), env(safe-area-inset-bottom));
  }
  #loginDialog :is(form, .gate, .auth-step:not([hidden])) {
    gap: var(--s-2);
  }
  #loginDialog :is(.auth-head, .auth-tabs, .google-wrap) {
    margin-bottom: var(--s-2);
  }
  #loginDialog .af {
    gap: var(--s-1);
  }
}
@media (pointer: coarse) {
  #loginDialog .auth-links a,
  #loginDialog .af-label a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
  }
}
