@layer screens {
  /* password reset flash error (passwords/new + edit use this minimal layout) */
  .form-error { color: var(--danger); }
  /* ───────────────────────── full-screen takeover ─────────────────────────
     The auth layout already renders a bare body.auth-page (no rail/topbar).
     We claim the whole viewport with a fixed container so stacking is clean
     and the login owns the screen regardless of any surrounding context. */
  .auth-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    overflow: auto;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  .auth-split {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    min-height: 100%;
  }

  /* ───────────────────────── left · brand panel ─────────────────────────
     The panel is ALWAYS dark (--rail = #16364f light / #10222f dark), so
     fixed light foregrounds (#fff, rgba white) are safe in both modes. */
  .auth-brand {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    color: #fff;
    background:
      radial-gradient(120% 90% at 12% 8%, color-mix(in oklab, var(--rail) 78%, var(--primary)) 0%, transparent 60%),
      linear-gradient(155deg, var(--rail) 0%, color-mix(in oklab, var(--rail) 86%, #000) 100%);
    padding: clamp(2rem, 4vw, 4rem);
  }

  /* drifting water motif — soft blurred blobs + a faint engineering grid */
  .auth-brand__bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; }

  .auth-blob {
    position: absolute;
    border-radius: 999px;
    filter: blur(46px);
    opacity: 0.55;
    mix-blend-mode: screen;
    will-change: transform;
    animation: auth-drift 22s ease-in-out infinite;
  }
  .auth-blob--1 {
    width: 30rem; height: 30rem; top: -8rem; right: -10rem;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  }
  .auth-blob--2 {
    width: 24rem; height: 24rem; bottom: -7rem; left: -6rem;
    background: radial-gradient(circle, color-mix(in oklab, var(--primary) 70%, #6fd6e6) 0%, transparent 70%);
    animation-delay: -7s; animation-duration: 27s;
  }
  .auth-blob--3 {
    width: 16rem; height: 16rem; top: 40%; left: 35%;
    background: radial-gradient(circle, color-mix(in oklab, var(--primary) 60%, #fff) 0%, transparent 70%);
    opacity: 0.32; animation-delay: -13s; animation-duration: 31s;
  }
  .auth-grid {
    position: absolute; inset: 0;
    background-image:
      linear-gradient(to right, rgba(255,255,255,0.05) 1px, transparent 1px),
      linear-gradient(to bottom, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(120% 100% at 20% 18%, #000 0%, transparent 72%);
            mask-image: radial-gradient(120% 100% at 20% 18%, #000 0%, transparent 72%);
  }

  @keyframes auth-drift {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50%      { transform: translate3d(2.5rem, -1.8rem, 0) scale(1.08); }
  }

  .auth-brand__inner {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: clamp(2rem, 5vh, 4rem);
    min-height: 100%;
    max-width: 30rem;
    animation: auth-rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  /* logo lockup */
  .auth-logo { display: flex; align-items: center; gap: 0.85rem; }

  .auth-monogram {
    position: relative;
    display: grid;
    place-items: center;
    width: 3rem; height: 3rem;
    border-radius: var(--r-md);
    background: linear-gradient(150deg, #fff 0%, #dcebf7 100%);
    color: var(--rail);
    box-shadow: 0 6px 18px rgba(0,0,0,0.28), inset 0 0 0 1px rgba(255,255,255,0.5);
    flex: none;
  }
  .auth-monogram__text {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.02em;
    line-height: 1;
  }
  .auth-monogram__ripple {
    position: absolute; inset: -6px;
    border-radius: inherit;
    border: 1px solid rgba(255,255,255,0.45);
    opacity: 0;
    animation: auth-ripple 4.5s ease-out infinite;
  }
  @keyframes auth-ripple {
    0%   { transform: scale(1);    opacity: 0.5; }
    70%  { transform: scale(1.55); opacity: 0; }
    100% { transform: scale(1.55); opacity: 0; }
  }

  .auth-wordmark {
    font-weight: 700;
    font-size: 1.6rem;
    letter-spacing: 0.14em;
  }

  .auth-brand__title {
    margin: 0;
    font-size: clamp(1.9rem, 3.2vw, 2.85rem);
    font-weight: 600;
    line-height: 1.18;
    letter-spacing: -0.01em;
  }
  .auth-brand__lead {
    margin: 1rem 0 0;
    max-width: 26rem;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: rgba(255,255,255,0.78);
  }

  .auth-points {
    list-style: none;
    margin: 0 0 1.4rem;
    padding: 0;
    display: grid;
    gap: 0.6rem;
  }
  .auth-point {
    display: flex; align-items: center; gap: 0.65rem;
    font-size: 0.9375rem;
    color: rgba(255,255,255,0.82);
  }
  .auth-point__dot {
    flex: none;
    width: 0.5rem; height: 0.5rem;
    border-radius: 999px;
    background: color-mix(in oklab, var(--primary) 55%, #fff);
    box-shadow: 0 0 0 4px rgba(255,255,255,0.08);
  }
  .auth-brand__copy {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.5);
  }

  /* ───────────────────────── right · form pane ───────────────────────── */
  .auth-pane {
    display: grid;
    place-items: center;
    padding: clamp(1.5rem, 4vw, 3rem);
    background: var(--bg);
  }

  .auth-card {
    position: relative;
    width: 100%;
    max-width: 25rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-pop);
    padding: clamp(1.6rem, 3.2vw, 2.5rem);
    animation: auth-rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both;
  }
  /* tasteful glass-style top sheen (grafted from Aurora Glass) */
  .auth-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    background: linear-gradient(90deg,
      transparent,
      color-mix(in oklab, var(--surface) 55%, #fff),
      transparent);
    opacity: 0.7;
    pointer-events: none;
  }

  /* compact brand — hidden when the full brand panel is visible */
  .auth-card__brand {
    display: none;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
  }
  .auth-monogram--sm {
    width: 2.25rem; height: 2.25rem;
    border-radius: var(--r-sm);
    background: linear-gradient(150deg, var(--primary) 0%, var(--rail) 115%);
    color: #fff;
    box-shadow: 0 4px 12px color-mix(in oklab, var(--primary) 35%, transparent);
  }
  .auth-monogram--sm .auth-monogram__text { font-size: 0.875rem; }
  .auth-wordmark--ink { color: var(--text); font-size: 1.25rem; }

  .auth-card__head { margin-bottom: 1.6rem; }
  .auth-card__title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.25;
    color: var(--text);
  }
  .auth-card__sub {
    margin: 0.4rem 0 0;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text-2);
  }

  /* flashes */
  .auth-flash {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 0.85rem;
    border-radius: var(--r-md);
    font-size: 0.9375rem;
    line-height: 1.45;
    border: 1px solid transparent;
    animation: auth-rise 0.4s ease both;
  }
  .auth-flash__icon { flex: none; width: 1.25rem; height: 1.25rem; margin-top: 0.05rem; }
  .auth-flash--err {
    background: var(--danger-bg);
    color: var(--danger-fg);
    border-color: color-mix(in oklab, var(--danger) 35%, transparent);
  }
  .auth-flash--ok {
    background: var(--ok-bg);
    color: var(--ok-fg);
    border-color: color-mix(in oklab, var(--ok) 35%, transparent);
  }

  /* form */
  .auth-form { display: grid; gap: 1.1rem; }

  .auth-field { display: grid; gap: 0.45rem; }
  .auth-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
  .auth-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
  }

  /* the wrapper owns the visual field; the real <input> is transparent inside.
     Focus/hover styling lives here so the leading icon recolors with focus. */
  .auth-input {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  }
  .auth-input__icon {
    position: absolute;
    left: 0.8rem;
    width: 1.15rem; height: 1.15rem;
    color: var(--muted);
    pointer-events: none;
    transition: color 0.18s ease;
  }
  .auth-input__field {
    flex: 1;
    width: 100%;
    min-width: 0;
    appearance: none;
    background: transparent;
    border: 0;
    padding: 0.8rem 0.9rem 0.8rem 2.5rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text);
  }
  .auth-input__field::placeholder { color: var(--muted); }
  /* base.css applies its own input border/bg/padding + a global
     input:focus-visible{outline}. Neutralize both: the wrapper is the field,
     and the wrapper draws the single focus ring — no double ring. */
  .auth-input__field { outline: none; }
  .auth-input__field:focus,
  .auth-input__field:focus-visible { outline: none; }

  .auth-input:hover { border-color: var(--primary-border); }
  .auth-input:focus-within {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
  }
  .auth-input:focus-within .auth-input__icon { color: var(--primary); }

  /* tame autofill so it respects tokens */
  .auth-input__field:-webkit-autofill,
  .auth-input__field:-webkit-autofill:hover,
  .auth-input__field:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 40rem var(--surface-2) inset;
    caret-color: var(--text);
    transition: background-color 9999s ease-out;
  }

  /* submit */
  .auth-submit {
    margin-top: 0.4rem;
    width: 100%;
    appearance: none;
    cursor: pointer;
    border: 1px solid color-mix(in oklab, var(--primary) 70%, #000);
    border-radius: var(--r-md);
    padding: 0.85rem 1rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(180deg, color-mix(in oklab, var(--primary) 92%, #fff) 0%, var(--primary) 100%);
    box-shadow: 0 6px 16px color-mix(in oklab, var(--primary) 32%, transparent), inset 0 1px 0 rgba(255,255,255,0.18);
    transition: transform 0.12s ease, box-shadow 0.18s ease, filter 0.18s ease;
  }
  .auth-submit:hover {
    filter: brightness(1.04);
    box-shadow: 0 10px 22px color-mix(in oklab, var(--primary) 38%, transparent), inset 0 1px 0 rgba(255,255,255,0.18);
  }
  .auth-submit:active { transform: translateY(1px); box-shadow: 0 3px 10px color-mix(in oklab, var(--primary) 30%, transparent); }

  /* links */
  .auth-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--r-sm);
  }
  .auth-link:hover { text-decoration: underline; text-underline-offset: 2px; }
  .auth-link--inline { font-size: 0.8125rem; }

  .auth-card__legal {
    margin: 1.5rem 0 0;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.5;
    letter-spacing: 0.01em;
    color: var(--muted);
    text-align: center;
  }

  /* single, clear keyboard focus ring for non-input controls */
  .auth-link:focus-visible,
  .auth-submit:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }

  /* shared entrance */
  @keyframes auth-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ───────────────────────── dark-mode polish ─────────────────────────
     Tokens flip automatically (--rail → #10222f, surfaces darken). These
     tune only the soft fills so the navy panel reads rich and the compact
     monogram keeps contrast on dark surfaces. */
  html.sdos-darkmode .auth-monogram {
    background: linear-gradient(150deg, color-mix(in oklab, var(--primary) 30%, #fff) 0%, var(--primary) 100%);
    color: #fff;
  }
  html.sdos-darkmode .auth-card { border-color: var(--line-strong); }
  html.sdos-darkmode .auth-card::before {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.14), transparent);
  }
  /* richer blobs in dark so the panel doesn't wash out (grafted from B) */
  html.sdos-darkmode .auth-blob { mix-blend-mode: screen; }
  html.sdos-darkmode .auth-blob--1 { opacity: 0.7; }
  html.sdos-darkmode .auth-blob--2 { opacity: 0.6; }
  html.sdos-darkmode .auth-blob--3 { opacity: 0.42; }

  /* ───────────────────────── responsive ─────────────────────────────── */
  @media (max-width: 860px) {
    .auth-split { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-pane { min-height: 100dvh; align-content: center; }
    .auth-card__brand { display: flex; }
  }

  @media (max-width: 420px) {
    .auth-card {
      border: 0;
      box-shadow: none;
      background: transparent;
      padding: 0.5rem 0.25rem;
    }
    .auth-card::before { display: none; }
  }

  /* respect reduced-motion */
  @media (prefers-reduced-motion: reduce) {
    .auth-blob, .auth-monogram__ripple,
    .auth-brand__inner, .auth-card, .auth-flash { animation: none !important; }
    .auth-submit, .auth-input, .auth-input__icon { transition: none; }
  }
}