:root {
  --ink: #0c0a09;
  --bone: #f5efe8;
  --mute: #b8aca1;
  --line: rgba(245, 239, 232, 0.22);
  --line-strong: rgba(245, 239, 232, 0.55);
  /* Overridden per client by /brand/<slug>/brand.css. */
  --accent: #9b3b3b;        /* button background; light text on it stays >= 4.5:1 */
  --accent-hover: #a75353;  /* button hover; same contrast rule */
  --accent-text: #b84a47;   /* italic accents and decorative lines on the dark scrim */
  --error: #e48a7a;
  --ring: 0 0 0 2px var(--ink), 0 0 0 4px var(--bone);

  --font-display: "Cormorant Garamond", "Times New Roman", serif;
  --font-ui: "Jost", system-ui, -apple-system, sans-serif;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 200ms;

  --z-backdrop: 0;
  --z-scrim: 10;
  --z-content: 20;

  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- Backdrop ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-backdrop);
  background-color: var(--ink);
  background-image: url("assets/portrait-1200.jpg");
  background-size: cover;
  background-position: 55% 8%;
  animation: settle 1.8s var(--ease-out) both;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-scrim);
  pointer-events: none;
  background:
    linear-gradient(to bottom,
      rgba(12, 10, 9, 0.55) 0%,
      rgba(12, 10, 9, 0) 14%,
      rgba(12, 10, 9, 0) 30%,
      rgba(12, 10, 9, 0.82) 52%,
      rgba(12, 10, 9, 0.96) 70%,
      var(--ink) 100%);
}

@keyframes settle {
  from { transform: scale(1.06); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* ---------- Top bar ---------- */

.topbar {
  position: relative;
  z-index: var(--z-content);
  padding: max(20px, env(safe-area-inset-top)) 24px 0;
}

.wordmark {
  display: inline-block;
  padding: 10px 0;
  color: var(--bone);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  border-radius: 2px;
}

/* ---------- Panel ---------- */

.panel {
  position: relative;
  z-index: var(--z-content);
  display: flex;
  justify-content: center;
  padding: 34vh 24px 72px;
}

.panel__inner {
  width: 100%;
  max-width: 420px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--mute);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 28px;
  height: 1px;
  margin-right: 12px;
  vertical-align: middle;
  background: var(--accent-text);
}

.title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.75rem, 5vw, 4.5rem);
  line-height: 1;
  letter-spacing: -0.01em;
}

.title em {
  font-style: italic;
  color: var(--accent-text);
}

.lede {
  margin: 14px 0 36px;
  color: var(--mute);
  font-weight: 300;
}

/* ---------- Form ---------- */

.form { display: grid; gap: 6px; }

.field { display: grid; }

.field label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
}

.field__control { position: relative; }

.field input {
  width: 100%;
  height: 48px;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--bone);
  font: inherit;
  font-size: 1.0625rem;
  caret-color: var(--accent-text);
  transition: border-color var(--fast) ease, box-shadow var(--fast) ease;
}

.field__control input { padding-right: 48px; }

.field input:hover { border-bottom-color: rgba(245, 239, 232, 0.75); }

.field input:focus { outline: none; border-bottom-color: var(--bone); box-shadow: 0 1px 0 0 var(--bone); }

.field input:focus-visible { box-shadow: 0 2px 0 0 var(--bone); }

.field input[aria-invalid="true"] { border-bottom-color: var(--error); box-shadow: 0 1px 0 0 var(--error); }

/* Keep autofilled fields transparent so they match the underline style. */
.field input:-webkit-autofill {
  -webkit-text-fill-color: var(--bone);
  caret-color: var(--accent-text);
  transition: background-color 9999s ease-out 9999s;
}

.reveal-toggle {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--mute);
  cursor: pointer;
  transition: color var(--fast) ease, background-color var(--fast) ease;
}

.reveal-toggle:hover { color: var(--bone); background: rgba(245, 239, 232, 0.08); }

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--hide { display: none; }
.reveal-toggle[aria-pressed="true"] .icon--show { display: none; }
.reveal-toggle[aria-pressed="true"] .icon--hide { display: block; }

.hint {
  margin: 6px 0 0;
  color: var(--mute);
  font-size: 0.875rem;
  line-height: 1.4;
}

.error {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  margin: 6px 0 4px;
  color: var(--error);
  font-size: 0.875rem;
  line-height: 1.3;
}

.error:not(:empty)::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm1 15h-2v-2h2v2Zm0-4h-2V7h2v6Z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm1 15h-2v-2h2v2Zm0-4h-2V7h2v6Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- Row: remember / forgot ---------- */

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 22px;
  font-size: 0.9375rem;
}

.check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--mute);
  cursor: pointer;
  transition: color var(--fast) ease;
}

.check:hover { color: var(--bone); }

.check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.check__box {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  transition: background-color var(--fast) ease, border-color var(--fast) ease;
}

.check__box svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--bone);
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity var(--fast) ease;
}

.check input:checked + .check__box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check__box svg { opacity: 1; }
.check input:focus-visible + .check__box { box-shadow: var(--ring); }

.link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--bone);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
  border-radius: 2px;
  cursor: pointer;
  transition: text-decoration-color var(--fast) ease, color var(--fast) ease;
}

.link:hover { text-decoration-color: currentColor; }

.link--accent {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1875rem;
  color: var(--bone);
  text-decoration-color: var(--accent-text);
}

.link--accent:hover { color: var(--bone); text-decoration-color: currentColor; }

/* ---------- Buttons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 52px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 2px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color var(--fast) ease, border-color var(--fast) ease, color var(--fast) ease;
}

.btn--primary { background: var(--accent); color: var(--bone); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--primary:active { box-shadow: inset 0 0 0 999px rgba(0, 0, 0, 0.14); }

.btn--primary[aria-busy="true"] { cursor: progress; }
.btn--primary[aria-busy="true"] .btn__label { opacity: 0; }
.btn--primary[aria-busy="true"] .spinner { opacity: 1; }
.btn--primary.is-done { background: #3f5b46; cursor: default; }

.spinner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 1.5px solid rgba(245, 239, 232, 0.35);
  border-top-color: var(--bone);
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn--ghost {
  border-color: var(--line);
  background: rgba(12, 10, 9, 0.25);
  color: var(--bone);
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: 0.9375rem;
}

.btn--ghost:hover { background: rgba(245, 239, 232, 0.08); border-color: var(--line-strong); }

.brand { width: 18px; height: 18px; fill: currentColor; }

.btn:focus-visible,
.link:focus-visible,
.wordmark:focus-visible,
.reveal-toggle:focus-visible { outline: none; box-shadow: var(--ring); }

.status {
  min-height: 1.5em;
  margin: 10px 0 0;
  color: var(--mute);
  font-size: 0.875rem;
  text-align: center;
}

/* ---------- Divider / social / footer ---------- */

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 14px 0 20px;
  color: var(--mute);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.125rem;
}

.divider::before,
.divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.social { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.signup {
  margin: 28px 0 0;
  color: var(--mute);
  font-size: 0.9375rem;
  text-align: center;
}

.credit {
  position: relative;
  z-index: var(--z-content);
  margin: 0;
  padding: 0 24px max(20px, env(safe-area-inset-bottom));
  color: rgba(245, 239, 232, 0.6);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-align: center;
}

/* ---------- Entrance ---------- */

.reveal {
  animation: rise 520ms var(--ease-out) both;
  animation-delay: calc(300ms + var(--i, 0) * 60ms);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Tablet ---------- */

@media (min-width: 640px) {
  .backdrop { background-position: 55% 12%; }
  .panel { padding-top: 40vh; }
}

/* ---------- Desktop: form left, face right ---------- */

@media (min-width: 1024px) {
  body { overflow: hidden; }

  .backdrop {
    left: 20vw;
    background-image: url("assets/portrait-2000.jpg");
    background-position: 50% 30%;
  }

  .scrim {
    background:
      linear-gradient(to right,
        var(--ink) 0%,
        var(--ink) 20%,
        rgba(12, 10, 9, 0.88) 30%,
        rgba(12, 10, 9, 0.45) 44%,
        rgba(12, 10, 9, 0) 58%),
      linear-gradient(to top, rgba(12, 10, 9, 0.5) 0%, rgba(12, 10, 9, 0) 22%);
  }

  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    padding: 32px 8vw 0;
  }

  .panel {
    min-height: 100dvh;
    justify-content: flex-start;
    align-items: center;
    padding: 96px 8vw 64px;
  }

  .panel__inner { max-width: 400px; }

  .credit {
    position: fixed;
    right: 0;
    bottom: 0;
    padding: 0 32px 24px;
    text-align: right;
  }
}

@media (min-width: 1024px) and (max-height: 760px) {
  body { overflow: auto; }
  .lede { margin-bottom: 24px; }
  .signup { margin-top: 18px; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
  .spinner { animation: none; border-color: var(--bone); border-right-color: transparent; }
}

/* ---------- Hub additions: server messages, MFA, notices ---------- */

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: -12px 0 24px;
  padding: 12px 14px;
  border-left: 2px solid var(--error);
  background: rgba(228, 138, 122, 0.08);
  color: var(--bone);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.notice svg { flex: none; width: 18px; height: 18px; margin-top: 1px; fill: var(--error); }

.field input.code {
  font-size: 1.75rem;
  letter-spacing: 0.5em;
  font-variant-numeric: tabular-nums;
}

.qr {
  display: flex;
  gap: 20px;
  align-items: center;
  margin: 0 0 28px;
}

.qr svg {
  flex: none;
  width: 132px;
  height: 132px;
  padding: 10px;
  background: var(--bone);
  border-radius: 2px;
}

.qr p { margin: 0; color: var(--mute); font-size: 0.875rem; line-height: 1.5; }

.secret {
  display: block;
  margin-top: 8px;
  color: var(--bone);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  word-break: break-all;
  user-select: all;
}

.back {
  margin: 20px 0 0;
  text-align: center;
  font-size: 0.9375rem;
}

.btn--primary:disabled:not([aria-busy="true"]) { opacity: 0.6; cursor: not-allowed; }

a.btn { text-decoration: none; }

.link--button {
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  cursor: pointer;
}

/* Client logos replace the wordmark on branded sign-in pages. */
.wordmark__logo {
  display: block;
  /* A fixed height (not max-height): SVG logos exported with only a viewBox have no intrinsic
     size and would collapse to 0×0 in the shrink-to-fit top bar. Width follows the aspect ratio. */
  height: 32px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  object-position: left center;
}
