@media (max-width: 600px) {
  .overlay { padding: 16px; }
  .auth-page { padding: 72px 12px 20px; }
  .auth-card, .role-modal { width: 100%; max-width: 440px; }
  .auth-corner-btn { top: 12px; right: 12px; padding: 8px 14px; }
  .role-cards { grid-template-columns: 1fr; }
  .role-card .role-desc { max-width: 30rem; }
}

@media (max-width: 420px) {
  .overlay {
    padding: 8px;
    overflow: hidden;
  }

  .role-modal {
    padding: 14px 10px 12px;
    width: min(100%, 340px);
    max-height: calc(100vh - 16px);
    border-radius: 18px;
  }

  .role-modal-logo {
    margin-bottom: 4px;
  }

  .role-modal-logo img {
    width: 42px;
  }

  .role-modal-sub {
    margin-bottom: 12px;
    font-size: 0.7rem;
    line-height: 1.4;
  }

  .role-modal h2 {
    font-size: 1.1rem;
    margin-bottom: 6px;
  }

  .role-modal .prompt {
    font-size: 0.72rem;
    margin-bottom: 12px;
  }

  .role-cards {
    gap: 8px;
  }

  .role-card {
    padding: 10px 8px;
    min-height: 116px;
  }

  .role-card .role-emoji {
    font-size: 1.7rem;
    line-height: 1;
  }

  .role-card .role-emoji img {
    width: 36px;
    height: 36px;
  }

  .role-card .role-label {
    font-size: 0.82rem;
  }

  .role-card .role-desc {
    font-size: 0.64rem;
    line-height: 1.35;
  }
}
/* ══════════════════════════════════════════════════════════════
   AUTH STYLES (Login / Signup / Role Modal)
══════════════════════════════════════════════════════════════ */

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30,14,3,0.6);
  backdrop-filter: blur(4px);
  z-index: 800;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.overlay.open { display: flex; }

.role-modal {
  background: var(--sand-light);
  border-radius: 24px;
  padding: 44px 40px 40px;
  width: min(500px, 95vw);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(30,14,3,0.38);
  border: 2px solid var(--sand-warm);
  animation: popIn 0.28s cubic-bezier(.34,1.45,.64,1) both;
  text-align: center;
  position: relative;
}

.role-modal-close {
  position: absolute;
  top: 14px; right: 18px;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--brown-warm);
  line-height: 1;
  transition: color 0.15s, transform 0.15s;
}
.role-modal-close:hover { color: var(--brown-dark); transform: rotate(90deg); }

.role-modal-logo {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--brown-dark);
  letter-spacing: 2px;
  margin-bottom: 6px;
}
.role-modal-sub {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text-mid);
  margin-bottom: 32px;
}
.role-modal h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brown-dark);
  margin-bottom: 10px;
}
.role-modal .prompt {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--text-mid);
  margin-bottom: 28px;
}

.role-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.role-card {
  background: var(--white);
  border: 2.5px solid var(--sand-warm);
  border-radius: 16px;
  padding: 28px 20px 22px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: border-color 0.18s, background 0.18s, transform 0.18s, box-shadow 0.18s;
  text-decoration: none;
  color: inherit;
}
.role-card:hover {
  border-color: var(--brown-btn);
  background: var(--sand-light);
  transform: translateY(-4px);
  box-shadow: 0 10px 32px rgba(59,31,10,0.18);
}
.role-card .role-emoji { font-size: 3rem; }
.role-card .role-label {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--brown-dark);
  letter-spacing: 0.3px;
}
.role-card .role-desc {
  font-family: var(--font-serif);
  font-size: 0.82rem;
  color: var(--text-mid);
  text-align: center;
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════
   AUTH PAGES (Login / Signup)
══════════════════════════════════════════════════════════════ */
.auth-page {
  display: none;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(210,155,90,0.22) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(180,120,60,0.14) 0%, transparent 50%),
    linear-gradient(155deg, #C9A87C 0%, #D9BE9A 35%, #EDD8B4 65%, #F5EDD8 100%);
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.auth-page.visible { display: flex; }

.auth-deco {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.07;
  background: var(--brown-dark);
}
.auth-deco-1 { width: 380px; height: 380px; bottom: -120px; left: -100px; }
.auth-deco-2 { width: 240px; height: 240px; top: -70px; right: -50px; }

.auth-corner-btn {
  position: fixed;
  top: 18px; right: 20px;
  background: var(--brown-btn);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-family: var(--font-body);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.92rem;
  z-index: 900;
  transition: background 0.15s;
}
.auth-corner-btn:hover { background: var(--brown-dark); }

.auth-card {
  background: var(--sand-light);
  border-radius: 22px;
  padding: 42px 44px;
  width: min(440px, 95vw);
  box-shadow: 0 16px 60px rgba(59,31,10,0.28);
  border: 2px solid var(--sand-warm);
  position: relative;
  z-index: 2;
  animation: popIn 0.32s cubic-bezier(.34,1.4,.64,1) both;
}

.auth-logo-area {
  text-align: center;
  margin-bottom: 22px;
}
.auth-role-badge {
  display: inline-block;
  background: var(--brown-btn);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  margin-top: 6px;
}

.auth-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brown-dark);
  text-align: center;
  margin-bottom: 24px;
}

.auth-form { display: flex; flex-direction: column; gap: 13px; }

.auth-input {
  width: 100%;
  background: var(--sand-mid);
  border: 1.5px solid var(--brown-warm);
  border-radius: var(--radius-btn);
  padding: 13px 18px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-dark);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input:focus {
  border-color: var(--brown-dark);
  box-shadow: 0 0 0 3px rgba(123,74,30,0.15);
}
.auth-input::placeholder { color: #b09870; }

.forgot-link {
  align-self: flex-end;
  font-size: 0.85rem;
  color: var(--brown-mid);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-body);
}

.btn-auth-submit {
  width: 100%;
  background: var(--brown-btn);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  padding: 14px;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.18s, transform 0.12s;
  margin-top: 4px;
}
.btn-auth-submit:hover { background: var(--brown-dark); transform: translateY(-1px); }

.btn-google {
  width: 100%;
  background: #fff;
  color: var(--text-dark);
  border: 1.5px solid var(--sand-warm);
  border-radius: var(--radius-btn);
  padding: 13px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.15s;
}
.btn-google:hover { background: var(--sand-mid); }
.google-g {
  font-size: 1.1rem;
  font-weight: 900;
  background: linear-gradient(to bottom right, #4285F4, #34A853, #FBBC05, #EA4335);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sand-warm);
  font-size: 0.85rem;
}
.auth-divider::before,
.auth-divider::after { content:''; flex:1; border-top:1px solid var(--sand-warm); }

.auth-switch {
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-mid);
  margin-top: 4px;
}
.auth-switch a {
  color: var(--brown-mid);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

/* ── Responsive Auth Styles ────────────────────────────────── */
@media (max-width: 1024px) {
  .role-modal { padding: 36px 32px 32px; width: min(450px, 90vw); }
  .role-cards { gap: 14px; }
  .role-card { padding: 24px 18px 20px; }
  .role-card .role-emoji { font-size: 2.8rem; }
  .role-card .role-label { font-size: 1rem; }
  .role-card .role-desc { font-size: 0.8rem; }
}

@media (max-width: 768px) {
  .auth-card { padding: 32px 26px; }
  .role-modal { padding: 32px 24px 28px; width: min(400px, 85vw); }
  .role-modal-close { top: 12px; right: 16px; }
  .role-modal-logo { font-size: 1.4rem; }
  .role-modal-sub { font-size: 0.9rem; margin-bottom: 24px; }
  .role-modal h2 { font-size: 1.4rem; }
  .role-modal .prompt { font-size: 0.9rem; margin-bottom: 20px; }
  .role-cards { gap: 12px; }
  .role-card { padding: 20px 16px 18px; }
  .role-card .role-emoji { font-size: 2.5rem; }
  .role-card .role-label { font-size: 0.95rem; }
  .role-card .role-desc { font-size: 0.78rem; }
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 18px; }
  .role-modal { padding: 24px 20px 24px; width: min(350px, 80vw); }
  .role-modal-close { top: 10px; right: 14px; font-size: 1.2rem; }
  .role-modal-logo { font-size: 1.2rem; margin-bottom: 4px; }
  .role-modal-sub { font-size: 0.85rem; margin-bottom: 20px; }
  .role-modal h2 { font-size: 1.2rem; margin-bottom: 8px; }
  .role-modal .prompt { font-size: 0.85rem; margin-bottom: 16px; }
  .role-cards { gap: 10px; }
  .role-card { padding: 16px 14px 16px; }
  .role-card .role-emoji { font-size: 2rem; }
  .role-card .role-label { font-size: 0.9rem; }
  .role-card .role-desc { font-size: 0.75rem; }
}

@media (max-width: 600px) {
  .auth-page { padding: 72px 12px 20px; }
  .auth-card, .role-modal { width: 100%; max-width: 440px; }
  .auth-corner-btn { top: 12px; right: 12px; padding: 8px 14px; }
  .role-cards { grid-template-columns: 1fr; }
  .role-card .role-desc { max-width: 30rem; }
}
/* ============================================================
   MOBILE ROLE PICKER FIX
   Current role picker contains Teacher + Parent/Guardian.
   Keep both cards visible side-by-side on small screens.
   ============================================================ */
@media (max-width: 600px) {
  .role-modal {
    width: min(94vw, 500px);
    max-width: 500px;
    max-height: calc(100vh - 24px);
    padding: 20px 12px 16px;
    border-radius: 20px;
    overflow-y: auto;
  }

  .role-modal-logo {
    font-size: 1.15rem;
    margin-bottom: 3px;
  }

  .role-modal-sub {
    font-size: .72rem;
    margin-bottom: 10px;
  }

  .role-modal h2 {
    font-size: 1.15rem;
    margin-bottom: 5px;
  }

  .role-modal .prompt {
    font-size: .72rem;
    margin-bottom: 10px;
  }

  .role-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .role-card {
    min-width: 0;
    min-height: 118px;
    padding: 11px 7px 10px;
    gap: 6px;
    border-radius: 13px;
  }

  .role-card .role-emoji {
    font-size: 1.6rem;
    line-height: 1;
  }

  .role-card .role-emoji img {
    width: 38px !important;
    height: 38px !important;
    object-fit: contain;
  }

  .role-card .role-label {
    font-size: .78rem;
    line-height: 1.1;
  }

  .role-card .role-desc {
    max-width: none;
    font-size: .6rem;
    line-height: 1.25;
  }
}

@media (max-width: 380px) {
  .role-modal {
    width: calc(100vw - 20px);
    padding: 16px 9px 13px;
  }

  .role-modal-logo {
    font-size: 1.05rem;
  }

  .role-modal-sub,
  .role-modal .prompt {
    font-size: .66rem;
  }

  .role-cards {
    gap: 5px;
  }

  .role-card {
    min-height: 108px;
    padding: 9px 5px;
  }

  .role-card .role-emoji img {
    width: 34px !important;
    height: 34px !important;
  }

  .role-card .role-label {
    font-size: .72rem;
  }

  .role-card .role-desc {
    font-size: .56rem;
  }
}

/* ============================================================
   FINAL MOBILE ROLE PICKER OVERRIDE
   Teacher + Parent/Guardian must remain visible side-by-side.
   ============================================================ */
@media (max-width: 600px) {
  .overlay {
    padding: 8px !important;
    overflow: hidden !important;
  }

  .overlay.open {
    display: flex !important;
  }

  .role-modal {
    width: min(94vw, 430px) !important;
    max-width: 430px !important;
    max-height: calc(100svh - 16px) !important;
    padding: 18px 10px 14px !important;
    border-radius: 18px !important;
    overflow: hidden !important;
  }

  .role-modal-close {
    top: 9px !important;
    right: 11px !important;
    font-size: 1.1rem !important;
  }

  .role-modal-logo {
    margin-bottom: 2px !important;
  }

  .role-modal-logo img {
    width: 42px !important;
  }

  .role-modal-sub {
    font-size: .68rem !important;
    line-height: 1.25 !important;
    margin: 0 20px 8px !important;
  }

  .role-modal h2 {
    font-size: 1.12rem !important;
    margin: 0 0 4px !important;
  }

  .role-modal .prompt {
    font-size: .7rem !important;
    margin: 0 0 9px !important;
  }

  .role-cards {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
    width: 100% !important;
  }

  .role-card {
    min-width: 0 !important;
    min-height: 112px !important;
    padding: 10px 6px !important;
    gap: 5px !important;
    border-radius: 13px !important;
  }

  .role-card .role-emoji {
    font-size: 1.55rem !important;
    line-height: 1 !important;
  }

  .role-card .role-emoji img {
    width: 36px !important;
    height: 36px !important;
    object-fit: contain !important;
  }

  .role-card .role-label {
    font-size: .76rem !important;
    line-height: 1.1 !important;
  }

  .role-card .role-desc {
    max-width: none !important;
    font-size: .58rem !important;
    line-height: 1.2 !important;
  }
}

@media (max-width: 380px) {
  .role-modal {
    width: calc(100vw - 16px) !important;
    padding: 15px 7px 12px !important;
  }

  .role-cards {
    gap: 5px !important;
  }

  .role-card {
    min-height: 104px !important;
    padding: 8px 5px !important;
  }

  .role-card .role-emoji img {
    width: 32px !important;
    height: 32px !important;
  }

  .role-card .role-label {
    font-size: .7rem !important;
  }

  .role-card .role-desc {
    font-size: .54rem !important;
  }
}

/* ============================================================
   ROLE PICKER — MOBILE BACKGROUND FLIP / COMPOSITING FIX
   Prevent the fixed modal backdrop from creating a transformed
   rendering layer over the landing-page sections on mobile.
   ============================================================ */
@media (max-width: 600px) {
  #rolePickerOverlay {
    position: fixed !important;
    inset: 0 !important;
    transform: none !important;
    -webkit-transform: none !important;
    perspective: none !important;
    -webkit-perspective: none !important;
    transform-style: flat !important;
    -webkit-transform-style: flat !important;
    background: rgba(30, 14, 3, 0.6) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    isolation: isolate !important;
  }

  #rolePickerOverlay .role-modal {
    transform-origin: center center !important;
    -webkit-transform-origin: center center !important;
    backface-visibility: visible !important;
    -webkit-backface-visibility: visible !important;
  }

  /* Keep the page itself in its normal orientation while the modal is open. */
  html,
  body {
    transform: none !important;
    -webkit-transform: none !important;
    perspective: none !important;
    -webkit-perspective: none !important;
  }
}

/* BARYO premium auth surfaces — visual only; auth behavior unchanged. */
.overlay {
  background: rgba(28, 16, 9, .64);
  backdrop-filter: blur(9px) saturate(110%);
  -webkit-backdrop-filter: blur(9px) saturate(110%);
}
.role-modal,
.auth-card {
  background:
    radial-gradient(ellipse at 100% 0%, rgba(225, 177, 91, .16), transparent 42%),
    linear-gradient(145deg, #fffaf0 0%, #f5e7cf 100%);
  border: 1px solid rgba(133, 82, 39, .24);
  box-shadow: 0 28px 90px rgba(24, 13, 6, .38), inset 0 1px 0 rgba(255,255,255,.8);
}
.role-card {
  background: rgba(255, 253, 247, .82);
  border: 1px solid rgba(123, 74, 30, .2);
  box-shadow: 0 5px 16px rgba(59, 31, 10, .05), inset 0 1px 0 rgba(255,255,255,.85);
  transition: transform .2s cubic-bezier(.2,.75,.25,1), border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.role-card:hover {
  background: #fffdf7;
  border-color: #a96b34;
  box-shadow: 0 14px 30px rgba(59, 31, 10, .13), inset 0 1px 0 rgba(255,255,255,.9);
  transform: translateY(-3px);
}
.btn-auth-submit,
.btn-google,
.auth-corner-btn {
  min-height: 46px;
  border-radius: 999px;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.btn-auth-submit,
.auth-corner-btn {
  background: linear-gradient(135deg, #4a2814 0%, #754019 55%, #9b5b2b 100%);
  box-shadow: 0 7px 18px rgba(74, 40, 20, .18);
}
.btn-auth-submit:hover,
.auth-corner-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 11px 24px rgba(74, 40, 20, .25);
}
.auth-input {
  border-radius: 13px;
  background: rgba(255, 253, 247, .82);
  border-color: rgba(123, 74, 30, .28);
}
.auth-input:focus {
  border-color: #9b5b2b;
  box-shadow: 0 0 0 4px rgba(155, 91, 43, .13);
}
.role-card:focus-visible,
.auth-input:focus-visible,
.btn-auth-submit:focus-visible,
.btn-google:focus-visible,
.auth-corner-btn:focus-visible {
  outline: 3px solid #c58b3e;
  outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  .role-card, .btn-auth-submit, .btn-google, .auth-corner-btn { transition: none !important; }
}


/* AUTH FEEDBACK STATES — reusable across login/signup pages. */
.auth-feedback { display:block; width:100%; box-sizing:border-box; margin:12px 0; padding:11px 14px; border:1px solid transparent; border-radius:12px; font:700 .9rem/1.45 'Nunito',sans-serif; }
.auth-feedback:empty, .auth-feedback[hidden] { display:none !important; }
.auth-feedback.is-error { color:#842d22; background:#fff0ed; border-color:#efc2b9; }
.auth-feedback.is-success { color:#245b38; background:#edf8ef; border-color:#b9dfc2; }
.auth-feedback.is-info { color:#68431b; background:#fff5df; border-color:#ecd19b; }
.auth-feedback:focus { outline:2px solid #c58b3e; outline-offset:2px; }
.btn-auth-submit.is-loading, .btn-google.is-loading { cursor:progress; opacity:.78; pointer-events:none; }
.btn-auth-submit:disabled, .btn-google:disabled { cursor:not-allowed; opacity:.68; transform:none; }
.auth-spinner { display:inline-block; width:1em; height:1em; margin-right:.55em; vertical-align:-.15em; border:2px solid currentColor; border-right-color:transparent; border-radius:50%; animation:auth-spin .7s linear infinite; }
@keyframes auth-spin { to { transform:rotate(360deg); } }
@media (prefers-reduced-motion:reduce) { .auth-spinner { animation:none; } }
