/* portal/templates/assets/auth.css
   The customer pages the Go engine renders (base_auth.html and its children: sign in, recover, set password,
   payment received, free 60 days, activate). TradersProxy v3 brand (website-v2/docs/handover-v3/Brand guide.dc.html).

   Tokens are the same names and values as website-v2/site/src/styles/global.css and
   website-v2/dashboard/src/tokens/tokens.css. Dark is the default for everyone; light is an explicit choice,
   stored under localStorage 'tp-theme' and applied as <html data-theme="light"> by assets/js/theme.js.
   Colour is written in the two token blocks below and nowhere else.

   Fonts are self-hosted (CSP font-src 'self'): Manrope and Martian Mono, latin subset, from @fontsource-variable
   (SIL OFL 1.1, licences beside the files in assets/fonts/). */

@font-face {
  font-family: "Manrope Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("fonts/manrope-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Martian Mono Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url("fonts/martian-mono-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens (Brand guide §02) ---------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0a0a;
  --bg2: #0e0e0e;
  --panel: #131313;
  --panel2: #191919;

  --line: rgb(255 255 255 / 0.09);
  --line2: rgb(255 255 255 / 0.17);

  --fg: #ededed;
  --fg2: #a3a3a3;
  --fg3: #808080;

  --ac: oklch(0.82 0.12 195);
  --ac2: oklch(0.82 0.12 195 / 0.13);
  --acl: oklch(0.82 0.12 195 / 0.45);

  --inv: #ededed;
  --invfg: #0a0a0a;

  /* Status only, always beside a word. -t is the same status as TEXT (in light the dot colour is too pale for
     4.5:1 as text). */
  --ok: oklch(0.78 0.16 150);
  --ok-t: oklch(0.78 0.16 150);
  --warn: oklch(0.82 0.13 75);
  --warn-t: oklch(0.82 0.13 75);
  --warn-line: oklch(0.82 0.13 75 / 0.45);

  --scrim: rgb(0 0 0 / 0.55);
  --shadow-window: 0 24px 60px -30px rgb(0 0 0 / 0.6);
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #fafafa;
  --bg2: #f3f3f3;
  --panel: #ffffff;
  --panel2: #f6f6f6;

  --line: rgb(0 0 0 / 0.08);
  --line2: rgb(0 0 0 / 0.16);

  --fg: #0a0a0a;
  --fg2: #4a4a4a;
  --fg3: #6a6a6a;

  --ac: oklch(0.52 0.1 205);
  --ac2: oklch(0.52 0.1 205 / 0.09);
  --acl: oklch(0.52 0.1 205 / 0.4);

  --inv: #0a0a0a;
  --invfg: #fafafa;

  --ok: oklch(0.52 0.14 150);
  --ok-t: oklch(0.49 0.14 150);
  --warn: oklch(0.55 0.13 65);
  --warn-t: oklch(0.5 0.13 65);
  --warn-line: oklch(0.55 0.13 65 / 0.45);

  --scrim: rgb(0 0 0 / 0.55);
  --shadow-window: 0 24px 60px -30px rgb(0 0 0 / 0.22);
}

:root {
  --font-sans: "Manrope Variable", "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Martian Mono Variable", "Martian Mono", ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  /* Spacing in 4px units (Brand guide §04). */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* Radii: chip 6, input 10, card 14, panel 18, pill. */
  --radius-chip: 6px;
  --radius-input: 10px;
  --radius-card: 14px;
  --radius-panel: 18px;
  --radius-pill: 9999px;

  /* Touch targets: 44px for actions, 36px at the least. */
  --hit: 44px;
  --hit-min: 36px;

  /* The page frame (handover §03). */
  --frame-max: 1240px;
  --frame-pad: clamp(12px, 2.5vw, 28px);

  --dur-fast: 160ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ac);
  outline-offset: 2px;
}

::selection {
  background: var(--ac2);
  color: var(--fg);
}

code {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-chip);
  background: var(--panel2);
  color: var(--fg);
  font: 400 0.9em/1.4 var(--font-mono);
  overflow-wrap: anywhere;
}

.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;
}

/* Skip link: the first focusable element, hidden until focused. */
.skip-link {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: 100;
  display: inline-flex;
  align-items: center;
  min-height: var(--hit);
  padding: 0 var(--sp-5);
  border-radius: var(--radius-pill);
  background: var(--inv);
  color: var(--invfg);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(calc(-100% - var(--sp-6)));
}

.skip-link:focus {
  transform: none;
}

/* ---------- Top bar: the logo top-left at 22px (Brand guide §01), the way back, the theme switch ---------- */
.auth-bar {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.auth-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  max-width: var(--frame-max);
  min-height: 64px;
  margin-inline: auto;
  padding-inline: var(--frame-pad);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  min-height: var(--hit);
  color: var(--fg);
  text-decoration: none;
}

.brand-mark {
  display: block;
  flex: none;
}

.brand-node {
  fill: var(--ac);
}

.brand-ink {
  fill: var(--fg);
}

/* Traders in 700, Proxy in 400, -0.02em, one word. 16px sits beside the 22px mark as on the website. */
.brand-wordmark {
  font: 400 16px/1 var(--font-sans);
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--fg);
}

.brand-wordmark b {
  font-weight: 700;
}

.auth-bar-end {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: var(--hit);
  min-height: var(--hit);
  padding: 0 var(--sp-3);
  border-radius: var(--radius-pill);
  color: var(--fg2);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.back-link:hover {
  color: var(--fg);
}

.back-link svg {
  flex: none;
}

/* The theme switch: one round button, half filled (as the website and the dashboard). */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--hit);
  height: var(--hit);
  padding: 0;
  border: 1px solid var(--line2);
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--fg3);
}

.theme-toggle .ring {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.theme-toggle .half {
  fill: currentColor;
}

/* ---------- Main ---------- */
.auth-main {
  position: relative;
  flex: 1 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(28px, 6vw, 72px) var(--frame-pad) clamp(40px, 8vw, 96px);
}

/* The quiet grid behind the form, fading out from the top (v3.css .tp-gridbg). */
.auth-main::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.6;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(70% 60% at 50% 0%, black, transparent 75%);
  mask-image: radial-gradient(70% 60% at 50% 0%, black, transparent 75%);
}

.auth-container,
.auth-container-wide {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 480px;
}

.auth-container-wide {
  max-width: 640px;
}

/* The form panel: --panel ground, hairline, 18px radius. No shadow (shadows are for floating windows only). */
.auth-card,
.card {
  min-width: 0;
  padding: clamp(20px, 5vw, 40px);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--panel);
}

/* ---------- Headings ---------- */
.auth-intro {
  margin-bottom: var(--sp-6);
}

/* The mono eyebrow (Brand guide §03): 11px, 500, uppercase, accent. */
.auth-eyebrow {
  margin: 0 0 var(--sp-4);
  font: 500 11px/1.3 var(--font-mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ac);
}

/* The page heading. The guide's display h1 (40 to 76px) is for marketing heroes; inside a form panel the heading
   follows the h2 proportions (-0.04em, 700, balanced) at a size that fits a 480px column. */
.auth-title {
  margin: 0;
  font-size: clamp(26px, 1.6vw + 20px, 34px);
  line-height: 1.08;
  letter-spacing: -0.04em;
  font-weight: 700;
  color: var(--fg);
  text-wrap: balance;
}

.auth-subtitle {
  margin: var(--sp-3) 0 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--fg2);
  text-wrap: pretty;
}

.auth-subtitle + .auth-subtitle {
  margin-top: var(--sp-2);
}

/* A status: always a word plus a dot, never colour alone. */
.auth-status {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0 0 var(--sp-4);
  font: 500 10px/1.3 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ok-t);
}

.auth-status::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

/* ---------- Messages ---------- */
/* Every message carries a word and a dot ahead of the text (CSS generated, so a message set by script with
   textContent keeps it). The text itself says what happened and what to do next. */
.auth-alert {
  margin: 0 0 var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--bg2);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* A message box with nothing in it is never shown: scripts fill these in, and an empty one would read "Error". */
.auth-alert:empty,
.auth-alert[hidden] {
  display: none;
}

.auth-alert::before {
  content: "Note";
  display: block;
  margin-bottom: 6px;
  padding-left: 16px;
  font: 500 10px/12px var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ac);
  /* The dot: a filled circle at the start of the word, in the word's colour. */
  background: radial-gradient(circle at 4px 50%, currentColor 0 4px, transparent 4.5px) no-repeat;
}

.auth-alert-error {
  border-color: var(--warn-line);
}

.auth-alert-error::before {
  content: "Error";
  color: var(--warn-t);
}

.auth-alert-warning::before {
  content: "Check";
  color: var(--warn-t);
}

.auth-alert-success::before {
  content: "Done";
  color: var(--ok-t);
}

.auth-alert strong {
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.93em;
}

/* ---------- Form (Brand guide §05; inputs as the dashboard) ---------- */
.auth-form {
  display: grid;
  gap: var(--sp-5);
}

.field {
  display: grid;
  gap: var(--sp-2);
  min-width: 0;
  margin: 0;
}

.field-label {
  font: 500 10px/1.5 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg3);
}

.field-optional {
  color: var(--fg3);
  text-transform: none;
  letter-spacing: 0;
}

.field-wrap {
  position: relative;
  min-width: 0;
}

.field-icon {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--hit);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg3);
  pointer-events: none;
}

.input-control {
  display: block;
  width: 100%;
  min-height: var(--hit);
  margin: 0;
  padding: 10px var(--sp-3);
  border: 1px solid var(--line2);
  border-radius: var(--radius-input);
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.4 var(--font-sans);
  transition: border-color var(--dur-fast) var(--ease-out);
}

.input-control.with-icon {
  padding-left: var(--hit);
}

.input-control::placeholder {
  color: var(--fg3);
  opacity: 1;
}

.input-control:hover {
  border-color: var(--fg3);
}

.input-control:focus {
  outline: 2px solid var(--ac);
  outline-offset: 1px;
  border-color: var(--ac);
}

.input-control[aria-invalid="true"] {
  border-color: var(--warn);
}

/* Separate rule: a selector list containing an unknown pseudo-class would be dropped whole. */
.input-control:user-invalid {
  border-color: var(--warn);
}

/* Values a trader copies or compares are set in mono. */
.input-mono {
  font-family: var(--font-mono);
  font-size: 14px;
}

select.input-control {
  -webkit-appearance: none;
  appearance: none;
  padding-right: var(--sp-10);
  cursor: pointer;
}

/* The select's chevron, drawn with borders (no image, no colour written). */
.field-select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 18px;
  width: 7px;
  height: 7px;
  border: solid var(--fg2);
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.code-textarea {
  min-height: 96px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
}

.helper-text,
.field-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--fg3);
}

.helper-text code,
.field-hint code {
  color: var(--fg2);
}

/* Password strength: four bars and a word. auth-base.js colours them with the status tokens. */
.strength-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-1);
  margin-top: var(--sp-1);
}

.strength-bar {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--line2);
}

.strength-label {
  min-height: 16px;
  font: 500 10px/1.6 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg3);
}

/* ---------- Buttons and links ---------- */
.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 48px;
  margin: 0;
  padding: 0 var(--sp-6);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--fg);
  font: 700 15px/1.2 var(--font-sans);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

/* Primary: --inv fill, the brightest thing on screen. One per view. */
.btn-primary {
  background: var(--inv);
  color: var(--invfg);
}

.btn-primary:hover {
  opacity: 0.88;
  color: var(--invfg);
}

.btn-secondary {
  border-color: var(--line2);
  color: var(--fg);
  font-weight: 600;
}

.btn-secondary:hover {
  border-color: var(--fg3);
  color: var(--fg);
}

.btn-block {
  display: flex;
  width: 100%;
  white-space: normal;
  padding-block: var(--sp-2);
}

.btn.is-submitting,
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  flex: none;
}

.link-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 var(--sp-2);
  margin-top: var(--sp-4);
  font-size: 14px;
  color: var(--fg2);
  text-align: center;
}

/* Text link (Brand guide §05): weight 600, hairline underline, ends with an arrow. 44px tall to tap. */
.link-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--hit);
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--line2);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.link-inline:hover {
  color: var(--ac);
  text-decoration-color: var(--ac);
}

.muted-link {
  color: var(--fg);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--line2);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.muted-link:hover {
  color: var(--ac);
  text-decoration-color: var(--ac);
}

.link-line .muted-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit);
}

/* ---------- Lists ---------- */
/* Numbered steps in the setup style: a mono number, then the line. */
.inline-list {
  margin: var(--sp-5) 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.inline-list li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: var(--sp-1);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg2);
}

.inline-list .index {
  font: 500 12px/1.9 var(--font-mono);
  color: var(--fg3);
}

/* A check list with accent ticks drawn in CSS (no glyph ticks). */
.check-list {
  display: grid;
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg2);
}

.check-list li {
  display: flex;
  gap: var(--sp-2);
  align-items: baseline;
}

.check-list li::before {
  content: "";
  flex: none;
  align-self: flex-start;
  width: 5px;
  height: 10px;
  margin: 5px 5px 0 3px;
  border: solid var(--ac);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ---------- Panels ---------- */
.panel {
  margin-top: var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--bg2);
}

.panel-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  font-weight: 700;
  color: var(--fg);
}

.panel-copy {
  margin: var(--sp-2) 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg2);
}

.panel-copy:first-child {
  margin-top: 0;
}

.panel-actions {
  display: grid;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}

/* The progress line while the payment is confirmed (auth-success.js sets the width). */
.progress-track {
  height: 4px;
  margin-top: var(--sp-3);
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--line2);
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--ac);
  transition: width 250ms linear;
}

/* Activate: the result rows, the set-password panel, the confirmation dialog. */
.activation-results {
  display: none;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}

.activation-results.is-visible {
  display: grid;
}

.result-row {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--bg2);
}

.result-row.error {
  border-color: var(--warn-line);
}

.result-code {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font: 500 12px/1.5 var(--font-mono);
  color: var(--fg);
  overflow-wrap: anywhere;
}

.result-code::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.result-row.error .result-code::before {
  background: var(--warn);
}

.result-copy {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--fg2);
}

.claim-panel {
  display: none;
}

.claim-panel.is-visible {
  display: block;
}

.entitlement-line {
  margin: var(--sp-2) 0 0;
  font: 400 13px/1.55 var(--font-mono);
  color: var(--fg);
  overflow-wrap: anywhere;
}

.entitlement-line:empty {
  display: none;
}

.confirmation-dialog {
  width: min(calc(100vw - 24px), 480px);
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--line2);
  border-radius: var(--radius-panel);
  background: var(--panel);
  color: var(--fg);
  box-shadow: var(--shadow-window);
}

.confirmation-dialog::backdrop {
  background: var(--scrim);
}

.confirmation-card {
  display: grid;
  gap: var(--sp-4);
  padding: clamp(20px, 5vw, 28px);
}

.confirmation-card header {
  display: grid;
  gap: var(--sp-2);
}

.confirmation-card .auth-title {
  font-size: 24px;
}

.confirmation-box {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--bg2);
}

.kicker-text {
  margin: 0;
  font: 500 10px/1.4 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg3);
}

.mono-11 {
  margin: 6px 0 0;
  font: 400 13px/1.55 var(--font-mono);
  color: var(--fg);
  overflow-wrap: anywhere;
}

.grid-gap-2 {
  display: grid;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}

.grid-gap-3 {
  display: grid;
  gap: var(--sp-2);
}

.flex-end-gap {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-2);
}

.m-0 {
  margin: 0;
}

.mt-2 {
  margin-top: var(--sp-2);
}

/* ---------- The automatic anti-bot check (cap-widget.js builds the inside) ---------- */
.cap-widget-wrap {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--line2);
  border-radius: var(--radius-input);
  background: var(--bg);
}

.cap-widget-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  min-height: 38px;
}

.cap-status-group {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.cap-checkbox-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line2);
  border-radius: var(--radius-chip);
  color: var(--fg2);
}

.cap-widget-wrap.is-solved .cap-checkbox-icon {
  border-color: var(--ok);
  color: var(--ok-t);
}

.cap-widget-wrap.is-error {
  border-color: var(--warn-line);
}

.cap-widget-wrap.is-error .cap-checkbox-icon {
  border-color: var(--warn);
  color: var(--warn-t);
}

.cap-checkbox-icon svg {
  width: 14px;
  height: 14px;
}

.cap-status-text {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--fg);
}

.cap-widget-wrap.is-error .cap-status-text {
  color: var(--warn-t);
}

.cap-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex: none;
  font: 500 10px/1.2 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg3);
}

.cap-badge-title {
  color: var(--fg2);
}

.cap-spinner-icon {
  display: block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--line2);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: cap-spin 0.8s linear infinite;
}

@keyframes cap-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Footer ---------- */
.auth-foot {
  border-top: 1px solid var(--line);
}

.auth-foot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 var(--sp-4);
  max-width: var(--frame-max);
  min-height: 64px;
  margin-inline: auto;
  padding: var(--sp-2) var(--frame-pad);
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg3);
}

.auth-foot-row p {
  margin: 0;
}

.auth-foot a {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit);
  color: var(--fg2);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--line2);
  text-underline-offset: 4px;
  overflow-wrap: anywhere;
}

.auth-foot a:hover {
  color: var(--ac);
  text-decoration-color: var(--ac);
}

/* ---------- Narrow phones: the way back keeps its name for screen readers, shows only the arrow ---------- */
@media (max-width: 439px) {
  .back-link {
    justify-content: center;
    padding: 0;
  }

  .back-link-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
