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

/* Light theme tokens (semantic aliases for surfaces + accent) */
:root {
  color-scheme: light;
  --brand: #98ca3f;
  --brand-dark: #7da833;
  --brand-light: #f0f7e4;
  --danger: #c5221f;
  --danger-bg: #fce8e6;
  --danger-border: #f5c6c2;

  --surface-page: #f2f2f7;
  --surface-card: #ffffff;
  --surface-elevated: #ffffff;
  --surface-input: #ffffff;

  --text: #1c1c1e;
  --muted: #636366;
  --border: #c6c6c8;
  --separator: rgba(60, 60, 67, 0.29);

  --link: var(--brand-dark);
  --focus-ring: rgba(152, 202, 63, 0.35);
  --focus-ring-inner: rgba(152, 202, 63, 0.18);

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-card-mobile: 0 0 0 1px var(--separator);

  --radius: 12px;
  --radius-pill: 9999px;
  --input-height: 48px;
  --tap-min: 44px;

  --transition-fast: 0.15s ease;
  --transition-medium: 0.2s ease;

  --alert-success-border: rgba(152, 202, 63, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --brand: #a8d956;
    --brand-dark: #98ca3f;
    --brand-light: rgba(168, 214, 86, 0.18);
    --danger: #ff453a;
    --danger-bg: rgba(255, 69, 58, 0.15);
    --danger-border: rgba(255, 69, 58, 0.35);

    --surface-page: #000000;
    --surface-card: #1c1c1e;
    --surface-elevated: #2c2c2e;
    --surface-input: #2c2c2e;

    --text: #f2f2f7;
    --muted: #98989d;
    --border: #38383a;
    --separator: rgba(84, 84, 88, 0.65);

    --link: #a8d956;
    --focus-ring: rgba(168, 214, 86, 0.45);
    --focus-ring-inner: rgba(168, 214, 86, 0.22);

    --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-card-mobile: 0 0 0 1px var(--separator);

    --alert-success-border: rgba(168, 214, 86, 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  background: var(--surface-page);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(24px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.auth-shell {
  justify-content: flex-start;
  padding: 0;
  align-items: stretch;
  width: 100%;
}

body.auth-shell .auth-card {
  margin: auto;
  flex-shrink: 0;
  align-self: center;
  width: calc(100% - 2rem);
  max-width: 448px;
}

body.auth-shell--landing {
  min-height: 100dvh;
}

body.auth-shell--console {
  justify-content: flex-start;
  padding: 0;
  align-items: stretch;
  width: 100%;
}

body.auth-shell--embedded {
  justify-content: center;
  align-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
}

body.auth-shell--embedded .auth-card {
  margin: 0 auto;
  width: calc(100% - 2rem);
  max-width: 448px;
}

.auth-landing {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 2rem max(1.25rem, env(safe-area-inset-right, 0px)) 3rem
    max(1.25rem, env(safe-area-inset-left, 0px));
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: max(12px, env(safe-area-inset-top, 0px));
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.auth-card {
  background: var(--surface-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 48px 40px 36px;
  width: 100%;
  max-width: 448px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-brand img {
  height: 40px;
  width: auto;
}

.auth-brand__link {
  display: inline-block;
  border-radius: calc(var(--radius) - 4px);
  line-height: 0;
  text-decoration: none;
}

.auth-brand__link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

.auth-brand__client-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
}

.auth-brand-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-top: 8px;
  letter-spacing: -0.02em;
}

.auth-heading {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  text-align: center;
  letter-spacing: -0.02em;
}

.auth-subheading {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
  line-height: 1.4;
}

.auth-subheading--passwordless-lead {
  margin-top: -8px;
  margin-bottom: 16px;
}

.field-errors--tight-bottom {
  margin-bottom: 12px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.password-label-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  margin-bottom: 0.35rem;
}

.password-label-row label {
  margin-bottom: 0;
  padding-top: 2px;
}

.password-visibility-btn {
  border: none;
  background: none;
  padding: 4px 8px;
  min-height: auto;
  min-width: 2.75rem;
  font-size: 13px;
  font-weight: 600;
  color: var(--link);
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border-radius: 8px;
}

.password-visibility-btn:hover {
  text-decoration: underline;
}

.password-visibility-btn:active {
  opacity: 0.65;
}

.password-input-wrap {
  width: 100%;
}

.form-control {
  width: 100%;
  height: var(--input-height);
  min-height: var(--tap-min);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--text);
  background: var(--surface-input);
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring-inner);
}

.form-control:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring-inner), 0 0 0 1px var(--brand);
}

.form-control.is-invalid {
  border-color: var(--danger);
}

.form-control::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

textarea.form-control {
  height: auto;
  padding: 12px 14px;
  resize: vertical;
}

.phone-row {
  display: flex;
  gap: 8px;
}

.phone-row .country-select {
  width: 110px;
  flex-shrink: 0;
}

.phone-row .phone-number {
  flex: 1;
}

.country-select {
  height: var(--input-height);
  min-height: var(--tap-min);
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--text);
  background: var(--surface-input);
  outline: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}

.country-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring-inner);
}

.country-select:focus-visible {
  outline: none;
}

/*
 * Segmented control — iOS UISegmentedControl-style (neutral track, elevated selection).
 * See Apple HIG “Segmented controls” / common mobile pattern: related choices, equal widths,
 * no decorative brand tint on the track (accent stays on CTAs elsewhere).
 */
.identifier-toggle {
  --seg-track: rgba(120, 120, 128, 0.12);
  --seg-thumb: var(--surface-card);
  --seg-text-idle: var(--muted);
  --seg-text-active: var(--text);
  --seg-thumb-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: stretch;
  background: var(--seg-track);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
  min-height: 44px;
  max-width: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.identifier-toggle button {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 0;
  min-height: 36px;
  margin: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--seg-text-idle);
  cursor: pointer;
  transition:
    color var(--transition-medium),
    background var(--transition-medium),
    box-shadow var(--transition-medium),
    font-weight var(--transition-fast);
  touch-action: manipulation;
}

.identifier-toggle button.active {
  z-index: 1;
  color: var(--seg-text-active);
  background: var(--seg-thumb);
  font-weight: 600;
  box-shadow: var(--seg-thumb-shadow);
}

.identifier-toggle button:not(.active):hover {
  color: var(--text);
}

.identifier-toggle button:active:not(:disabled) {
  opacity: 0.72;
}

.identifier-toggle button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.identifier-toggle button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.identifier-toggle button:disabled.active {
  opacity: 0.55;
}

@media (prefers-color-scheme: dark) {
  .identifier-toggle {
    --seg-track: rgba(118, 118, 128, 0.24);
    --seg-thumb: #636366;
    --seg-text-idle: #ebebf5;
    --seg-text-active: #ffffff;
    --seg-thumb-shadow:
      0 1px 0 rgba(255, 255, 255, 0.08),
      0 1px 3px rgba(0, 0, 0, 0.35);
  }

  .identifier-toggle button:not(.active):hover {
    color: var(--text);
  }
}

.field-errors {
  margin-top: 5px;
}

.field-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 3px;
}

.non-field-errors {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 20px;
}

.non-field-errors p {
  font-size: 13px;
  color: var(--danger);
}

.btn-primary {
  display: block;
  width: 100%;
  min-height: var(--tap-min);
  height: auto;
  padding: 12px 20px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--transition-fast),
    opacity var(--transition-fast),
    transform var(--transition-fast);
  margin-top: 8px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-primary:active {
  opacity: 0.88;
  transform: scale(0.985);
}

.btn-primary:focus {
  outline: none;
}

.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  height: auto;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 600;
  color: var(--link);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition:
    background var(--transition-fast),
    opacity var(--transition-fast);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-secondary:hover {
  background: var(--brand-light);
}

.btn-secondary:active {
  opacity: 0.75;
}

.btn-secondary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring-inner);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  height: auto;
  padding: 10px 20px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 600;
  color: var(--danger);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-danger:active {
  opacity: 0.85;
}

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

.btn-primary.is-loading,
.btn-secondary.is-loading,
button.auth-link.is-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
  text-shadow: none;
}

.btn-primary.is-loading:active,
.btn-secondary.is-loading:active {
  transform: none;
  opacity: 1;
}

.btn-primary.is-loading::after,
.btn-secondary.is-loading::after,
button.auth-link.is-loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.35em;
  height: 1.35em;
  margin: -0.675em 0 0 -0.675em;
  border-radius: 50%;
  animation: auth-spin 0.65s linear infinite;
}

.btn-primary.is-loading::after {
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
}

.btn-secondary.is-loading::after {
  border: 2px solid var(--focus-ring-inner);
  border-top-color: var(--brand);
}

button.auth-link.is-loading {
  min-height: var(--tap-min);
  min-width: 7em;
}

button.auth-link.is-loading::after {
  width: 1.1em;
  height: 1.1em;
  margin: -0.55em 0 0 -0.55em;
  border: 2px solid var(--focus-ring-inner);
  border-top-color: var(--link);
}

@media (prefers-color-scheme: dark) {
  .btn-secondary.is-loading::after {
    border: 2px solid var(--focus-ring-inner);
    border-top-color: var(--brand);
  }

  button.auth-link.is-loading::after {
    border: 2px solid var(--focus-ring-inner);
    border-top-color: var(--link);
  }
}

.auth-footer {
  margin-top: 28px;
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 20px;
  text-align: right;
}

.auth-footer--centered {
  justify-content: center;
  text-align: center;
  margin-top: 20px;
  flex-direction: column;
  align-items: center;
}

.auth-session-line {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.auth-session-line strong {
  color: var(--text);
  font-weight: 600;
}

.auth-inline-form {
  display: contents;
}

.auth-footer__session-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
}

.auth-footer__sep {
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}

.auth-link {
  font-size: 15px;
  font-weight: 600;
  color: var(--link);
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 6px 2px;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-link:active {
  opacity: 0.65;
}

button.auth-link {
  font: inherit;
  background: none;
  border: none;
  padding: 6px 4px;
  margin: 0;
  cursor: pointer;
  color: var(--link);
}

body.auth-shell--consent {
  position: relative;
  background: var(--surface-page);
  overflow-x: hidden;
}

body.auth-shell--consent::before,
body.auth-shell--consent::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

body.auth-shell--consent::before {
  width: min(420px, 70vw);
  height: min(420px, 70vw);
  top: -120px;
  left: -100px;
  background: radial-gradient(circle, rgba(152, 202, 63, 0.22) 0%, rgba(152, 202, 63, 0) 70%);
}

body.auth-shell--consent::after {
  width: min(360px, 65vw);
  height: min(360px, 65vw);
  right: -80px;
  bottom: -100px;
  background: radial-gradient(circle, rgba(152, 202, 63, 0.16) 0%, rgba(152, 202, 63, 0) 72%);
}

body.auth-shell--consent .auth-main-column,
body.auth-shell--consent .auth-card {
  position: relative;
  z-index: 1;
}

.auth-main-column {
  width: calc(100% - 2rem);
  max-width: 448px;
  margin: auto;
  flex-shrink: 0;
  align-self: center;
}

body.auth-shell--consent .auth-main-column .auth-card {
  width: 100%;
  max-width: none;
  margin: 0;
}

body.auth-shell--consent .auth-card {
  padding: 32px 28px 28px;
  border-radius: 20px;
}

body.auth-shell--consent main {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.consent-header {
  text-align: center;
  margin-bottom: 20px;
}

.consent-header .consent-app-identity {
  justify-content: center;
}

.consent-header .consent-app-identity__party {
  align-items: center;
  min-width: 0;
}

.consent-title {
  margin: 16px 0 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.3;
}

.consent-footer {
  margin-top: 20px;
  padding-top: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}

.consent-account-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--brand-light);
  text-align: left;
}

.consent-account-bar__icon {
  flex-shrink: 0;
  color: var(--brand);
}

.consent-account-bar__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.consent-account-bar__label {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}

.consent-account-bar__name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.consent-account-bar__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.consent-account-bar__link {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 2px 0;
  min-height: auto;
  white-space: nowrap;
}

.consent-account-bar__link--secondary {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.consent-privacy-notice {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}

.consent-privacy-notice__icon {
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--muted);
}

.consent-privacy-notice__link {
  color: var(--link);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.consent-privacy-notice__link:hover {
  color: var(--brand-dark);
}

.consent-security-tagline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 1rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.consent-security-tagline__icon {
  flex-shrink: 0;
  color: var(--muted);
}

.consent-subtitle {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.35;
}


.scope-intro {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 4px;
  line-height: 1.35;
}

.scope-list {
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  margin: 12px 0 24px;
  background: var(--surface-elevated);
  overflow: hidden;
}

.scope-list li,
.scope-row {
  font-size: 14px;
  color: var(--text);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.scope-row__icon {
  flex-shrink: 0;
  color: var(--brand);
  margin-top: 1px;
}

.scope-row__text {
  line-height: 1.4;
}

.scope-row__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.scope-row__badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.scope-row--write .scope-row__icon {
  color: var(--danger);
}

.scope-row--write .scope-row__badge {
  color: var(--danger);
}

.scope-row--read .scope-row__icon,
.scope-row--access .scope-row__icon {
  color: var(--brand);
}

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

.scope-list li + li,
.scope-row + .scope-row {
  border-top: 1px solid var(--separator);
}

.scope-panel {
  border: 1px solid rgba(60, 60, 67, 0.12);
  background: rgba(60, 60, 67, 0.04);
  border-radius: var(--radius);
  margin: 0 0 20px;
  overflow: hidden;
  text-align: left;
}

.scope-panel .scope-list.scope-list--panel {
  border: none;
  background: transparent;
  margin: 0;
  border-radius: 0;
}

.scope-panel .scope-list--panel-nested {
  border: none;
  background: transparent;
  margin: 0;
  border-radius: 0;
  border-top: 1px solid rgba(60, 60, 67, 0.08);
}

.scope-row--summary .scope-row__text {
  font-weight: 500;
}

.scope-panel__more {
  border-top: 1px solid rgba(60, 60, 67, 0.08);
}

.scope-panel__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap-min);
  padding: 10px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--link);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.scope-panel__toggle::-webkit-details-marker {
  display: none;
}

.scope-panel__toggle::after {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  margin-top: -0.15em;
  transition: transform var(--transition-fast);
}

.scope-panel__more[open] .scope-panel__toggle::after {
  transform: rotate(-135deg);
  margin-top: 0.15em;
}

.scope-panel__more[open] .scope-panel__toggle-more {
  display: none;
}

.scope-panel__more:not([open]) .scope-panel__toggle-less {
  display: none;
}

.scope-panel__toggle:hover {
  color: var(--brand-dark);
}

.scope-panel__toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

.scope-list.scope-list--panel {
  border: 1px solid rgba(60, 60, 67, 0.12);
  background: rgba(60, 60, 67, 0.04);
  padding: 8px 14px;
  margin: 0 0 20px;
  overflow: hidden;
  text-align: left;
  border-radius: var(--radius);
}

.scope-list.scope-list--panel .scope-row {
  padding: 10px 0;
  gap: 12px;
  align-items: center;
}

.scope-list.scope-list--panel .scope-row + .scope-row {
  border-top: 1px solid rgba(60, 60, 67, 0.08);
}

.scope-list.scope-list--panel .scope-row__icon {
  margin-top: 0;
  color: var(--muted);
  flex-shrink: 0;
}

.scope-list.scope-list--panel .scope-row__text {
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--text);
}

.scope-list.scope-list--panel .scope-row--write .scope-row__icon {
  color: var(--danger);
}

.scope-list.scope-list--compact {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0 0 24px;
  overflow: visible;
  text-align: left;
}

.scope-list.scope-list--compact .scope-row {
  padding: 4px 0;
  gap: 10px;
  align-items: center;
}

.scope-list.scope-list--compact .scope-row + .scope-row {
  border-top: none;
}

.scope-list.scope-list--compact .scope-row__icon {
  margin-top: 0;
  color: var(--muted);
}

.scope-list.scope-list--compact .scope-row__text {
  font-size: 0.875rem;
  line-height: 1.35;
}

.scope-list.scope-list--compact .scope-row--write .scope-row__text {
  color: var(--text);
}

.scope-list.scope-list--compact .scope-row--write .scope-row__icon {
  color: var(--danger);
}

.consent-app-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 0;
}

.consent-app-identity__party {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 72px;
}

.consent-app-identity__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.25;
  max-width: 96px;
  word-break: break-word;
}

.consent-app-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--brand-light);
  color: var(--brand);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.consent-app-identity__logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
}

.consent-app-identity__logo--client {
  object-fit: contain;
  background: var(--brand-light);
}

.consent-trust-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.75rem;
  margin-top: 1rem;
  padding-top: 0.25rem;
  text-align: center;
}

.consent-trust-footer__link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
}

.consent-trust-footer__link:hover {
  color: var(--link);
  text-decoration: underline;
}

.consent-trust-footer__link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

.consent-app-identity__connector {
  color: var(--muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.consent-lead {
  text-align: center;
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.4;
}

.consent-lead::before {
  content: none;
}

.app-info {
  text-align: center;
  margin-bottom: 20px;
}

.app-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.app-info p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.consent-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-top: 0;
}

.consent-footer .btn-primary--consent,
.consent-footer .btn-secondary--consent-deny {
  width: 100%;
}

.btn-primary--consent {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.btn-primary__icon {
  flex-shrink: 0;
}

.btn-secondary--consent-deny {
  background: var(--surface-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  width: 100%;
}

.btn-secondary--consent-deny:hover {
  background: rgba(60, 60, 67, 0.04);
  border-color: var(--border);
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  body.auth-shell--consent::before {
    background: radial-gradient(circle, rgba(168, 214, 86, 0.14) 0%, rgba(168, 214, 86, 0) 70%);
  }

  body.auth-shell--consent::after {
    background: radial-gradient(circle, rgba(168, 214, 86, 0.1) 0%, rgba(168, 214, 86, 0) 72%);
  }

  .scope-list.scope-list--panel {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
  }

  .scope-panel {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
  }

  .scope-panel .scope-list--panel-nested,
  .scope-panel__more {
    border-top-color: rgba(255, 255, 255, 0.08);
  }

  .scope-list.scope-list--panel .scope-row + .scope-row {
    border-top-color: rgba(255, 255, 255, 0.08);
  }

  .btn-secondary--consent-deny:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

.consent-footer .btn-primary {
  width: 100%;
}

.consent-deny-link {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  width: 100%;
  min-height: var(--tap-min);
  font-size: 0.875rem;
  font-weight: 500;
}

.consent-deny-link:hover {
  background: transparent;
  color: var(--text);
  text-decoration: underline;
}

.consent-deny-link:active {
  opacity: 0.65;
  transform: none;
}

@media (prefers-color-scheme: dark) {
  .consent-deny-link:hover {
    background: transparent;
  }
}

.btn--oauth-inline {
  width: auto;
  min-width: min(140px, 100%);
  padding-left: 28px;
  padding-right: 28px;
}

.btn-secondary--oauth-deny {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.btn-secondary--oauth-deny:hover {
  background: rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  .btn-secondary--oauth-deny:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

.oauth-error-stack {
  text-align: center;
}

.oauth-error-title {
  font-size: 48px;
  font-weight: 600;
  color: var(--brand);
  line-height: 1;
  margin-bottom: 12px;
  letter-spacing: -0.03em;
}

.step-badge {
  display: inline-block;
  background: var(--brand-light);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  margin-bottom: 16px;
  text-align: center;
  width: 100%;
}

.destination-display {
  background: var(--brand-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--brand-dark);
  font-weight: 600;
  margin-bottom: 20px;
  word-break: break-all;
}

@media (prefers-color-scheme: dark) {
  .destination-display {
    color: var(--text);
  }
}

.auth-verify-page {
  width: 100%;
}

.auth-verify-lead {
  margin-bottom: 8px;
}

.auth-verify-form {
  margin-top: 4px;
}

.form-control-otp {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: center;
}

.otp-segmented {
  margin-top: 4px;
}

.otp-segmented__cells {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.otp-segmented__cell {
  width: 44px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0;
  flex: 0 0 44px;
}

.otp-segmented--invalid .otp-segmented__cell {
  border-color: var(--danger);
}

.otp-segmented__cell:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring-inner);
}

.otp-segmented__error {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
  text-align: center;
  line-height: 1.4;
  min-height: 1.25em;
}

.auth-resend-block {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.auth-resend-hint {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
}

.auth-resend-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.auth-resend-form {
  margin: 0;
}

.btn-resend {
  min-width: min(168px, 100%);
  min-height: var(--tap-min);
  touch-action: manipulation;
}

.btn-resend:disabled,
.btn-resend[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.auth-resend-timer {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin: 0;
  min-height: 1.25em;
}

.error-page {
  text-align: center;
}

.error-code {
  font-size: 72px;
  font-weight: 300;
  color: var(--brand);
  line-height: 1;
  margin-bottom: 8px;
}

.error-message {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.error-detail {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 1.45;
}

.alert {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.4;
}

.alert-success {
  background: var(--brand-light);
  color: var(--text);
  border: 1px solid var(--alert-success-border);
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.alert-info {
  background: var(--brand-light);
  color: var(--text);
  border: 1px solid var(--alert-success-border);
}

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

@media (max-width: 480px) {
  body {
    justify-content: flex-start;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
  }

  body.auth-shell {
    padding-top: 0;
  }

  body.auth-shell--embedded {
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top, 0px))
      max(12px, env(safe-area-inset-right, 0px))
      max(16px, env(safe-area-inset-bottom, 0px))
      max(12px, env(safe-area-inset-left, 0px));
  }

  body.auth-shell .auth-card {
    width: calc(100% - 1.5rem);
    margin-top: 1rem;
    margin-bottom: 1rem;
  }

  .auth-landing {
    align-items: flex-start;
    padding-top: 1.5rem;
  }

  .auth-card {
    padding: 28px 20px 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-card-mobile);
    max-width: none;
  }

  .auth-footer:not(.auth-footer--centered) {
    justify-content: stretch;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    gap: 14px;
  }

  .auth-footer:not(.auth-footer--centered) .auth-link {
    justify-content: center;
    width: 100%;
  }

  .name-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .consent-footer .btn-primary,
  .consent-footer .btn-primary--consent,
  .consent-footer .btn-secondary--consent-deny {
    width: 100%;
    justify-content: center;
  }

  .btn--oauth-inline {
    width: 100%;
  }

  .otp-segmented__cells {
    gap: 6px;
  }

  .otp-segmented__cell {
    width: 40px;
    height: 48px;
    min-height: 48px;
    flex: 0 0 40px;
    font-size: 20px;
  }
}

/* Remembered accounts strip (OAuth resume / consent) */
.lras {
  margin-bottom: 20px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--separator);
  background: var(--surface-elevated);
}

.lras__lead {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  text-align: center;
}

.lras__sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 12px;
  text-align: center;
}

.lras__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lras__li {
  margin: 0;
}

.lras__form {
  margin: 0;
}

.lras__btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.65rem;
  width: 100%;
  min-height: var(--tap-min);
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-input);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.lras__avatar {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.lras__btn-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.lras__btn:hover {
  border-color: var(--brand);
  background: var(--brand-light);
}

.lras__btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .identifier-toggle button:active:not(:disabled),
  .btn-primary:active {
    transform: none;
  }

  .btn-primary.is-loading::after,
  .btn-secondary.is-loading::after,
  button.auth-link.is-loading::after {
    animation: none;
    border-color: rgba(255, 255, 255, 0.55);
    border-top-color: #fff;
  }
}

.form-hint {
  margin-top: 0.35rem;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--muted);
}

.auth-step-indicator {
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--brand);
}

.auth-footer-hint {
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--muted);
  text-align: center;
}

.auth-footer--passwordless {
  flex-direction: column;
  gap: 0.5rem;
}
