/* MCQ Forge Online — auth pages (login, sign-up, forgot, reset), public-route shell, sidebar account block.
   Uses the tokens from base.css only. */

/* ---------- public routes: no app chrome (the shell sets body.public-mode) ---------- */
body.public-mode .sidebar,
body.public-mode .topbar,
body.public-mode .bottomnav,
body.public-mode #banner-slot { display: none !important; }
body.public-mode .app { grid-template-columns: minmax(0, 1fr); }
body.public-mode .main { padding: 0; }
body.public-mode .view { max-width: none; }

body.bare-mode .sidebar,
body.bare-mode .topbar,
body.bare-mode .bottomnav,
body.bare-mode #banner-slot { display: none !important; }
body.bare-mode .app { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 900px) {
  body.bare-mode .main { padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: 40px; }
}

.boot-wait { min-height: 60vh; display: grid; place-items: center; }
.boot-wait .spin { width: 28px; height: 28px; border-width: 3px; }

/* ---------- auth layout ---------- */
.auth-wrap {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.auth-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; max-width: 1180px; margin: 0 auto;
  padding: 4px clamp(0px, 2vw, 24px);
}
.auth-home {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px 8px 10px; border-radius: 12px;
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: var(--fs-sm);
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.auth-home svg { width: 17px; height: 17px; }
.auth-home:hover { background: var(--surface-2); color: var(--text); }
.auth-center {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: clamp(12px, 4vh, 48px) 0 clamp(12px, 3vh, 32px);
}
.auth-brand { justify-content: center; margin-bottom: 22px; padding: 0; }
.auth-brand .brand-mark { width: 44px; height: 44px; filter: drop-shadow(0 8px 22px rgba(242, 181, 68, 0.45)); }
.auth-brand .brand-name { font-size: 1.7rem; }

.auth-card {
  position: relative;
  width: min(460px, 100%);
  padding: clamp(24px, 5vw, 38px) clamp(20px, 5vw, 38px) clamp(20px, 4vw, 28px);
  border-radius: var(--r-xl);
  background:
    radial-gradient(120% 70% at 50% -10%, color-mix(in srgb, var(--gold) 9%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(22px) saturate(1.25);
  -webkit-backdrop-filter: blur(22px) saturate(1.25);
  animation: auth-in 0.5s var(--ease) both;
}
.auth-card.wide { width: min(560px, 100%); }
/* a thin molten edge along the top of the card */
.auth-card::before {
  content: '';
  position: absolute; left: 22px; right: 22px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-hi), var(--ember), transparent);
  opacity: 0.8;
}
@keyframes auth-in { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }

.auth-head { text-align: center; margin-bottom: 22px; }
.auth-title { font-size: clamp(1.75rem, 5vw, 2.15rem); line-height: 1.1; text-wrap: balance; }
.auth-sub { margin: 10px auto 0; max-width: 36ch; color: var(--text-2); font-size: 0.95rem; text-wrap: balance; }

.auth-form { display: flex; flex-direction: column; }
.auth-form .field + .field { margin-top: 15px; }
.auth-field .input-wrap.has-ic > .input { padding-left: 42px; }
.auth-field .input-wrap.has-eye > .input { padding-right: 46px; }
.auth-field .input { min-height: 48px; font-size: 1rem; }
.auth-field .input-wrap > svg { left: 14px; }
.auth-field .auth-eye { width: 40px; height: 40px; }
.auth-field.has-error .input { border-color: var(--bad); }
.auth-field.has-error .input:focus { box-shadow: 0 0 0 3px var(--bad-soft); }
.auth-field.has-error .input-wrap > svg { color: var(--bad); }
.auth-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.auth-forgot { font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
.auth-forgot:hover { text-decoration: underline; }

.auth-err {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: var(--fs-sm); color: var(--bad); line-height: 1.4;
}
.auth-err:empty { display: none; }
.auth-err svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }

/* password rules */
.pw-rules { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.pw-rules li {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px 3px 7px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--line);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.pw-rules li svg { width: 13px; height: 13px; opacity: 0.45; transition: opacity 0.2s; }
.pw-rules li.ok { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.pw-rules li.ok svg { opacity: 1; }

/* terms checkbox */
.auth-check { margin-top: 18px; display: flex; flex-direction: column; gap: 6px; }
.auth-check-label {
  position: relative;
  display: flex; align-items: flex-start; gap: 11px;
  font-size: var(--fs-sm); color: var(--text-2); line-height: 1.5; cursor: pointer;
}
.auth-check-input { position: absolute; opacity: 0; width: 22px; height: 22px; margin: 0; cursor: pointer; }
.auth-check-box {
  flex: none; width: 22px; height: 22px; margin-top: -1px;
  display: grid; place-items: center;
  border-radius: 7px; border: 1.5px solid var(--line-strong);
  background: color-mix(in srgb, var(--surface-solid) 70%, transparent);
  color: transparent;
  transition: background 0.18s var(--ease), border-color 0.18s, color 0.18s, box-shadow 0.18s;
}
.auth-check-box svg { width: 15px; height: 15px; stroke-width: 2.6; }
.auth-check-input:checked + .auth-check-box {
  background: linear-gradient(135deg, var(--gold-hi), var(--gold) 60%, var(--ember));
  border-color: transparent; color: var(--on-gold);
}
.auth-check-input:focus-visible + .auth-check-box { box-shadow: 0 0 0 3px var(--gold-soft); border-color: var(--gold); }
.auth-check.has-error .auth-check-box { border-color: var(--bad); }

.auth-submit { width: 100%; margin-top: 22px; }
.auth-submit .spin { border-color: rgba(29, 20, 4, 0.25); border-top-color: var(--on-gold); }

/* form-level alert */
.auth-alert {
  display: flex; gap: 12px; align-items: flex-start;
  margin-bottom: 18px; padding: 12px 14px;
  border-radius: 14px; border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-size: var(--fs-sm); line-height: 1.5;
  animation: auth-in 0.3s var(--ease) both;
}
.auth-alert .aa-ic { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; }
.auth-alert .aa-ic svg { width: 16px; height: 16px; }
.auth-alert .aa-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.auth-alert.is-error { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-soft); }
.auth-alert.is-error .aa-ic { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.auth-alert.is-ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); }
.auth-alert.is-ok .aa-ic { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.auth-alert.is-info { border-color: color-mix(in srgb, var(--gold) 35%, transparent); background: var(--gold-soft); }
.auth-alert.is-info .aa-ic { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold-text); }
.auth-alert a { font-weight: 600; }

/* "or try the demo" */
.auth-or { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.auth-or-line { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.12em; }
.auth-or-line::before, .auth-or-line::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); }
.auth-demo { width: 100%; border-color: var(--line-strong); }
.auth-demo svg { color: var(--gold-text); }

/* footer of the card */
.auth-foot {
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  font-size: var(--fs-sm); color: var(--text-2);
}
.auth-foot > p { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; }
.auth-foot > p > svg { width: 15px; height: 15px; }
.auth-foot a { font-weight: 600; text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }
.auth-sister { font-size: var(--fs-xs) !important; color: var(--text-3); gap: 6px !important; }
.auth-sister svg { width: 13px; height: 13px; flex: none; }
.auth-sister a { font-weight: 600; color: var(--text-2); }

.auth-legal { margin-top: 20px; display: flex; gap: 10px; justify-content: center; font-size: var(--fs-xs); color: var(--text-3); }
.auth-legal a { color: var(--text-3); text-decoration: none; }
.auth-legal a:hover { color: var(--text-2); text-decoration: underline; }

/* success state (check your inbox) */
.auth-success { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0 4px; }
.auth-success .as-ic {
  width: 72px; height: 72px; margin-bottom: 8px;
  display: grid; place-items: center; border-radius: 22px;
  background: linear-gradient(140deg, var(--gold-hi), var(--gold) 55%, var(--ember));
  color: var(--on-gold);
  box-shadow: 0 16px 40px -14px rgba(242, 160, 50, 0.8);
  animation: as-pop 0.6s var(--ease-spring) both;
}
.auth-success .as-ic svg { width: 34px; height: 34px; }
.auth-success h2 { font-size: clamp(1.5rem, 4.6vw, 1.85rem); line-height: 1.15; max-width: 18ch; text-wrap: balance; }
.auth-success p { max-width: 38ch; text-wrap: pretty; }
.auth-success .as-email { color: var(--text); overflow-wrap: anywhere; }
.auth-success .as-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; }
@keyframes as-pop { from { opacity: 0; transform: scale(0.6) rotate(-8deg); } to { opacity: 1; transform: none; } }

.auth-loading { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.auth-loading .spin { width: 28px; height: 28px; border-width: 3px; }

@media (max-width: 480px) {
  .auth-brand { margin-bottom: 16px; }
  .auth-brand .brand-mark { width: 38px; height: 38px; }
  .auth-brand .brand-name { font-size: 1.5rem; }
  .auth-card { border-radius: 20px; }
  .auth-head { margin-bottom: 18px; }
  .auth-success .as-actions > * { flex: 1 1 auto; }
}

/* ---------- sidebar: install button + account block ---------- */
.side-foot { flex-direction: column; align-items: stretch; gap: 10px; padding: 0; }
.side-install:empty, .side-account:empty { display: none; }
.side-install { display: flex; }
.side-install > * { width: 100%; }
.side-account {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.sa-chip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); border-radius: 10px; }
.sa-avatar {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px;
  background: linear-gradient(140deg, var(--gold-hi), var(--gold) 55%, var(--ember));
  color: var(--on-gold); font-weight: 700; font-size: 0.95rem;
}
.sa-avatar.is-guest { background: var(--steel-soft); color: var(--steel); border: 1px dashed color-mix(in srgb, var(--steel) 45%, transparent); }
.sa-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sa-text strong { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-text span { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-out { width: 34px; height: 34px; }
.sa-cta { order: 3; width: 100%; }
.side-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.side-meta #side-model { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* steel-toned banner (offline) */
.banner.banner-steel { border-color: color-mix(in srgb, var(--steel) 40%, transparent); background: linear-gradient(100deg, var(--steel-soft), transparent 80%), var(--surface); }
.banner.banner-steel .bi { background: var(--steel-soft); color: var(--steel); }

/* ---------- account section (Settings) ---------- */
.acct { display: flex; flex-direction: column; gap: 18px; }
.acct-who { display: flex; align-items: center; gap: 14px; }
.acct-who .sa-avatar { width: 48px; height: 48px; border-radius: 15px; font-size: 1.2rem; color: var(--on-gold); word-break: normal; } /* beats `.acct-who span` (the e-mail line) */
.acct-who strong { display: block; font-size: 1.05rem; }
.acct-who span { color: var(--text-2); font-size: var(--fs-sm); word-break: break-all; }
.acct-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.acct-note { font-size: var(--fs-sm); color: var(--text-2); }
.acct-danger { padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.acct-danger p { flex: 1; min-width: 220px; font-size: var(--fs-sm); color: var(--text-3); }

/* ---------- sign-out / leave-demo dialog (auth-ui.js signOutFlow) and small notes ---------- */
.so-body { display: flex; flex-direction: column; gap: 12px; padding-bottom: 6px; }
.so-note {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 12px; border-radius: 12px;
  font-size: var(--fs-sm); line-height: 1.45; color: var(--text-2);
  background: var(--steel-soft); border: 1px solid color-mix(in srgb, var(--steel) 28%, transparent);
}
.so-note svg { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--steel); }
.so-note.is-warn { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 32%, transparent); }
.so-note.is-warn svg { color: var(--gold); }
.so-check { margin-top: 4px; }
.so-check strong { display: block; font-weight: 600; color: var(--text); }
.so-hint { display: block; font-size: var(--fs-xs); color: var(--text-3); }
.pw-sister { margin-bottom: 14px; }
.reset-sister { margin: 16px 0 0; }
