/* Studio OS dark login (passwordless + password). Uses core tokens via var() with fallbacks.
   Every rule is prefixed `html:root #screen-login.screen` so it also wins over legacy
   `:is(html, html.theme-light) #screen-login ...` rules if refresh*.css are still loaded. */

/* Local tokens (values from CONTRACT.md) so the login never depends on load order or legacy theme vars. */
html:root #screen-login.screen {
  --l-bg:#0E0E10; --l-bg2:#161618; --l-bg3:#1E1E21; --l-border2:rgba(255,255,255,.16);
  --l-text:#fff; --l-text2:#B8B8BE; --l-text3:#8693A8;
  --l-accent:#FF3B30; --l-accent-dark:#D92B22; --l-accent-dim:rgba(255,59,48,.14);
  --l-r-card:24px; --l-r-ctl:14px;
}

html:root #screen-login.screen .login-wrap {
  background:
    radial-gradient(900px 520px at 85% -10%, rgba(255,59,48,.16), transparent 60%),
    radial-gradient(700px 480px at -10% 110%, rgba(76,141,255,.10), transparent 60%),
    var(--l-bg);
  padding: calc(32px + env(safe-area-inset-top, 0px)) 20px calc(32px + env(safe-area-inset-bottom, 0px));
  align-items: center; justify-content: center;
  min-height: 100%; overflow-y: auto; overflow-x: hidden;
}
html:root #screen-login.screen .login-wrap::before { display: none; }
html:root #screen-login.screen .login-watermark,
html:root #screen-login.screen .login-pattern-bg { display: none; }

html:root #screen-login.screen .login-card {
  background: var(--l-bg2);
  border: 1px solid var(--l-border2);
  border-radius: var(--l-r-card);
  padding: 36px 32px 28px;
  max-width: 420px; width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
  color: var(--l-text);
  box-sizing: border-box;
}
html:root #screen-login.screen .login-wordmark {
  font-family: 'Manrope', var(--font-display, 'Plus Jakarta Sans'), sans-serif;
  font-size: 40px; font-weight: 800; letter-spacing: -1.6px; line-height: 1.05;
  color: var(--l-text); margin: 0 0 6px;
}
html:root #screen-login.screen .login-wordmark span { color: var(--l-accent); font-weight: 800; }
html:root #screen-login.screen .login-tagline {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .28em;
  color: var(--l-text3); margin-bottom: 40px;
}

html:root #screen-login.screen .lv2-title,
html:root #screen-login.screen .page-title {
  font-family: 'Manrope', var(--font-display, sans-serif), sans-serif;
  font-size: 28px; font-weight: 800; letter-spacing: -.6px; line-height: 1.15;
  color: var(--l-text); margin: 0 0 8px;
}
html:root #screen-login.screen .lv2-title:focus { outline: none; }
html:root #screen-login.screen .page-sub,
html:root #screen-login.screen .lv2-sub {
  font-size: 15px; line-height: 1.5; color: var(--l-text2); margin: 0 0 24px;
}
html:root #screen-login.screen .lv2-sub strong { color: var(--l-text); font-weight: 600; overflow-wrap: anywhere; }

html:root #screen-login.screen .form-group { margin-bottom: 16px; }
html:root #screen-login.screen .form-label {
  display: block; font-size: 13px; font-weight: 600; color: var(--l-text2); margin-bottom: 8px;
}
html:root #screen-login.screen .form-input {
  width: 100%; box-sizing: border-box; min-height: 52px; padding: 0 16px;
  font-size: 16px; /* 16px stops iOS zoom-on-focus */
  font-family: 'Inter', var(--font, sans-serif), sans-serif;
  background: var(--l-bg3); color: var(--l-text);
  border: 1px solid var(--l-border2); border-radius: var(--l-r-ctl);
  transition: border-color .15s ease, box-shadow .15s ease;
}
html:root #screen-login.screen .form-input::placeholder { color: var(--l-text3); }
html:root #screen-login.screen .form-input:focus {
  outline: none; border-color: var(--l-accent); box-shadow: 0 0 0 3px var(--l-accent-dim);
  background: var(--l-bg3);
}
html:root #screen-login.screen select.form-input { padding-right: 12px; }

/* buttons: white on #D92B22 = 4.9:1 */
html:root #screen-login.screen .btn {
  display: flex; align-items: center; justify-content: center; width: 100%; box-sizing: border-box;
  min-height: 52px; padding: 0 20px; border-radius: var(--l-r-ctl);
  font-size: 16px; font-weight: 700; letter-spacing: .01em; cursor: pointer; border: 0;
  font-family: 'Inter', var(--font, sans-serif), sans-serif;
  transition: transform .08s ease, background .15s ease, opacity .15s ease;
}
html:root #screen-login.screen .btn-green {
  background: var(--l-accent-dark); color: #fff; box-shadow: 0 8px 22px rgba(255,59,48,.28);
}
html:root #screen-login.screen .btn-green:hover:not(:disabled) { background: #C9261E; } /* QA: was #E5322A = 4.36:1 with white text */
html:root #screen-login.screen .btn:active:not(:disabled) { transform: scale(.985); }
html:root #screen-login.screen .btn:disabled { opacity: .6; cursor: not-allowed; box-shadow: none; }
html:root #screen-login.screen .btn-dim {
  background: transparent; color: var(--l-text); border: 1px solid var(--l-border2);
}
html:root #screen-login.screen .btn-dim:hover:not(:disabled) { background: var(--l-bg3); }
html:root #screen-login.screen .btn:focus-visible,
html:root #screen-login.screen .lv2-link:focus-visible,
html:root #screen-login.screen .lv2-eye:focus-visible,
html:root #screen-login.screen .lv2-box:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

html:root #screen-login.screen .lv2-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; margin: 0;
  background: none; border: 0; cursor: pointer; font-size: 14px; font-weight: 600;
  font-family: 'Inter', var(--font, sans-serif), sans-serif;
  color: var(--l-accent); text-decoration: none;
}
html:root #screen-login.screen .lv2-link:hover:not(:disabled) { text-decoration: underline; }
html:root #screen-login.screen .lv2-link:disabled { color: var(--l-text3); cursor: default; text-decoration: none; }
html:root #screen-login.screen .lv2-center { display: flex; justify-content: center; width: 100%; margin-top: 4px; }
html:root #screen-login.screen .lv2-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
html:root #screen-login.screen #lv2-use-password { margin-top: 8px; }
html:root #screen-login.screen #forgot-pw-btn { margin-top: 8px; }

html:root #screen-login.screen .lv2-divider {
  display: flex; align-items: center; gap: 12px; margin: 16px 0 14px; color: var(--l-text3); font-size: 12px;
}
html:root #screen-login.screen .lv2-divider::before,
html:root #screen-login.screen .lv2-divider::after { content: ''; flex: 1; height: 1px; background: var(--l-border2); }
html:root #screen-login.screen .lv2-hint { font-size: 12.5px; line-height: 1.5; color: var(--l-text3); margin: 10px 0 4px; }

/* alerts */
html:root #screen-login.screen .lv2-alert {
  margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.45;
  background: rgba(255,59,48,.12); border: 1px solid rgba(255,59,48,.38); color: #FFC9C5;
}
html:root #screen-login.screen .lv2-alert[hidden] { display: none; }
html:root #screen-login.screen .lv2-alert.lv2-ok { background: rgba(52,199,89,.12); border-color: rgba(52,199,89,.4); color: #BDF0CB; }

/* six code boxes */
html:root #screen-login.screen .lv2-codes { display: flex; gap: 8px; margin: 4px 0 20px; }
html:root #screen-login.screen .lv2-box {
  flex: 1 1 0; min-width: 0; width: 100%; box-sizing: border-box; height: 58px; padding: 0;
  text-align: center; font-size: 26px; font-weight: 700; font-family: 'Manrope', var(--font, sans-serif), sans-serif;
  color: var(--l-text); background: var(--l-bg3);
  border: 1px solid var(--l-border2); border-radius: 14px;
  caret-color: var(--l-accent); -webkit-appearance: none; appearance: none;
}
html:root #screen-login.screen .lv2-box:focus { outline: none; border-color: var(--l-accent); box-shadow: 0 0 0 3px var(--l-accent-dim); }
html:root #screen-login.screen .lv2-box:disabled { opacity: .6; }
html:root #screen-login.screen .lv2-box.lv2-bad { border-color: var(--l-accent); animation: lv2-shake .32s ease; }
@keyframes lv2-shake { 20%{transform:translateX(-4px)} 40%{transform:translateX(4px)} 60%{transform:translateX(-3px)} 80%{transform:translateX(3px)} }

/* password step */
html:root #screen-login.screen .lv2-pw { position: relative; }
html:root #screen-login.screen .lv2-pw .form-input { padding-right: 76px; }
html:root #screen-login.screen .lv2-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-width: 56px; min-height: 44px;
  background: none; border: 0; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--l-text2);
}
html:root #screen-login.screen .lv2-attempts { font-size: 12px; color: var(--l-text3); text-align: center; margin-top: 8px; }

/* link step spinner */
html:root #screen-login.screen .lv2-linkstep { padding: 12px 0 4px; }
html:root #screen-login.screen .lv2-spinner {
  width: 40px; height: 40px; margin: 0 auto 20px; border-radius: 50%;
  border: 3px solid var(--l-border2); border-top-color: var(--l-accent);
  animation: lv2-spin .8s linear infinite;
}
@keyframes lv2-spin { to { transform: rotate(360deg); } }

@media (max-width: 480px) {
  html:root #screen-login.screen .login-wrap { padding-left: 16px; padding-right: 16px; align-items: stretch; justify-content: flex-start; padding-top: calc(40px + env(safe-area-inset-top, 0px)); }
  html:root #screen-login.screen .login-card { padding: 28px 20px 22px; border-radius: 20px; background: transparent; border-color: transparent; box-shadow: none; }
  html:root #screen-login.screen .login-wordmark { font-size: 36px; }
  html:root #screen-login.screen .login-tagline { margin-bottom: 36px; }
  html:root #screen-login.screen .lv2-codes { gap: 6px; }
  html:root #screen-login.screen .lv2-box { height: 54px; font-size: 24px; }
}
/* login code boxes stay >=44px wide at 320px */
@media (max-width: 340px) {
  html:root #screen-login.screen .login-wrap { padding-left: 10px; padding-right: 10px; }
  html:root #screen-login.screen .login-card { padding-left: 6px; padding-right: 6px; }
  html:root #screen-login.screen .lv2-codes { gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  html:root #screen-login.screen .lv2-spinner { animation-duration: 2.4s; }
  html:root #screen-login.screen .lv2-box.lv2-bad { animation: none; }
  html:root #screen-login.screen .btn { transition: none; }
}

/* ==== GAPS: studio photo behind the login card (real studio photo, dark shade, gradient fallback) ==== */
/* The login screen fills the whole viewport at every width (the #app column is 480px wide below 1024px). */
body[data-screen="login"] #app { max-width: none; }
html:root #screen-login.screen .lv2-bg {
  position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 30% 40%;
  z-index: 0; pointer-events: none; filter: saturate(.8);
}
html:root #screen-login.screen .lv2-bg-shade {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(14,14,16,.9) 0%, rgba(14,14,16,.86) 45%, rgba(14,14,16,.94) 100%),
    radial-gradient(900px 520px at 85% -10%, rgba(255,59,48,.14), transparent 60%);
}
html:root #screen-login.screen .login-card { position: relative; z-index: 1; }
@media (min-width: 481px) {
  html:root #screen-login.screen .login-card {
    background: rgba(22,22,24,.94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  }
  html:root #screen-login.screen .lv2-bg-shade {
    background:
      linear-gradient(100deg, rgba(14,14,16,.92) 0%, rgba(14,14,16,.74) 55%, rgba(14,14,16,.82) 100%),
      radial-gradient(900px 520px at 85% -10%, rgba(255,59,48,.14), transparent 60%);
  }
}
@media (max-width: 480px) {
  /* card was fully transparent; give it a quiet panel so text never sits straight on the photo */
  html:root #screen-login.screen .login-card {
    background: rgba(14,14,16,.62); border-color: var(--l-border2);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
  html:root #screen-login.screen .lv2-bg-shade {
    background: linear-gradient(180deg, rgba(14,14,16,.8) 0%, rgba(14,14,16,.72) 50%, rgba(14,14,16,.88) 100%);
  }
}
