:root {
  --card-radius: 1.25rem;
  --auth-header-height: 60px;
  --bs-breakpoint-sm: 576px;
  --bs-breakpoint-md: 768px;
  --bs-breakpoint-lg: 992px;
  --bs-breakpoint-xl: 1200px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f5f5f7;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}


/* ── Title + tools inline row ── */
.title-tools-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}

.title-tools-row h4 { margin-bottom: 2px !important; }
.title-tools-row p  { margin-bottom: 0 !important; }

/* header-tools when inside title row: compact, no full width */
.title-tools-row .header-tools {
  position: static !important;
  width: auto !important;
  margin-bottom: 0 !important;
  padding: .3rem .45rem;
  flex-shrink: 0;
  border-radius: .75rem;
  background: rgba(0,0,0,.04);
}

body.dark-mode .title-tools-row .header-tools {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
}


/* ── Login form: shrinks to content, no phantom height ── */
.card-face.front form {
  display: flex;
  flex-direction: column;
}

/* CAPTCHA wrapper: no min-height, shrinks to content */
.cap-panel#p-grid {
  /* grid panel has no fixed height — it shrinks to its emoji rows */
  min-height: 0 !important;
}

/* Remove bottom gap on the captcha form-group when grid is active */
.form-group-inline:has(#p-grid.on) {
  margin-bottom: 0;
}

/* Ensure the emoji grid itself never reserves empty rows */
#emojiGrid {
  min-height: 0 !important;
  height: auto !important;
}

/* ─────────────────────────────────────────────────────────
   AUTH WRAPPER & CARD
───────────────────────────────────────────────────────── */
.auth-wrapper {
  width: 100%;
  max-width: 100%;
  perspective: 1200px;
  position: relative;
}

@media (min-width: 576px)  { .auth-wrapper { max-width: 420px; } }
@media (min-width: 768px)  { .auth-wrapper { max-width: 460px; } }
@media (min-width: 992px)  { .auth-wrapper { max-width: 480px; } }
@media (min-width: 1200px) { .auth-wrapper { max-width: 520px; } }

.auth-card {
  position: relative;
  width: 100%;
  border-radius: var(--card-radius);
  background: #fff;
  /* NOTE: overflow:hidden must NOT be set here — it breaks preserve-3d in all browsers */
  transform-style: preserve-3d;
  transition: transform .4s cubic-bezier(.4, 0, .2, 1);
}

.auth-card.flip { transform: rotateY(180deg); }

/* ── Both faces: hidden backside, no overflow clipping ── */
.card-face {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  width: 100%;
  padding: 2rem;
  border-radius: var(--card-radius);
}

/* Front: sits at Z=0 (default), visible when card is not flipped */
.card-face.front {
  position: relative;
  z-index: 2;
  background: inherit;
  visibility: visible; /* explicit — overrides any inherited hidden */
}

/* Back: pre-rotated 180deg so it faces forward when card flips */
.card-face.back {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  /* rotateY(180deg) alone — NO translateZ — avoids compositing conflicts */
  transform: rotateY(180deg);
  background: #fff;
  border-radius: var(--card-radius);
  /* Hidden by default; JS reveals it after flip animation completes */
  visibility: hidden;
  overflow-y: auto;
  max-height: 100vh;
}

body.dark-mode .card-face.back { background: #1f2933; }

/* ─────────────────────────────────────────────────────────
   HEADER TOOLS — sits ABOVE the card, no overlap
───────────────────────────────────────────────────────── */
.header-tools {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  background: rgba(255, 255, 255, .75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: .35rem .6rem;
  border-radius: .85rem;
  margin-bottom: .5rem;
  width: 100%;
  box-sizing: border-box;
}

body.dark-mode .header-tools {
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 6px 10px;
}

.tool-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .5rem;
  color: #333;
  text-decoration: none;
  font-size: .95rem;
  transition: background .2s ease, color .2s ease;
}

.tool-icon:hover { background: rgba(0, 0, 0, .05); }

body.dark-mode .tool-icon { color: #facc15; font-size: 16px; }

.lang-switcher { display: flex; gap: .25rem; }

.lang-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 .4rem;
  border-radius: .5rem;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1;
  border: 1px solid #d0d7de;
  background: #fff;
  color: #333;
  transition: all .2s ease;
}

.lang-btn:hover { background: #f1f5f9; }
.lang-btn.active { background: #0d6efd; color: #fff; border-color: #0d6efd; }

body.dark-mode .lang-btn {
  background: rgba(55, 65, 81, 0.8);
  color: #e5e7eb;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  padding: 4px 8px;
}
body.dark-mode .lang-btn:hover { background: rgba(75, 85, 99, 0.9); }
body.dark-mode .lang-btn.active { background: #3b82f6; color: #fff; }

@media (max-width: 420px) {
  .header-tools { padding: .3rem .4rem; gap: .4rem; }
  .lang-btn { min-width: 28px; height: 28px; font-size: .7rem; }
  .tool-icon { width: 30px; height: 30px; font-size: .85rem; }
}

/* ─────────────────────────────────────────────────────────
   PROCESS OVERLAY — fullscreen centered modal
───────────────────────────────────────────────────────── */
.proc-ovl {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.proc-ovl.on { display: flex; }

.proc-box {
  background: #fff;
  border-radius: 1.25rem;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .22);
  animation: boxIn .3s cubic-bezier(.34, 1.56, .64, 1);
}

body.dark-mode .proc-box {
  background: #1f2933;
  border: 1px solid #2d3748;
}

/* ─────────────────────────────────────────────────────────
   SESSION OVERLAY — fullscreen centered modal
───────────────────────────────────────────────────────── */
.sess-ovl {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.sess-ovl.on { display: flex; }

.sess-box {
  background: #fff;
  border-radius: 1.25rem;
  padding: 2rem;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .22);
  animation: boxIn .35s cubic-bezier(.34, 1.56, .64, 1);
}

body.dark-mode .sess-box {
  background: #1f2933;
  border: 1px solid #2d3748;
}

@keyframes boxIn {
  from { transform: scale(.88) translateY(20px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

/* ─────────────────────────────────────────────────────────
   REDIRECT ANIMATION STRIP
───────────────────────────────────────────────────────── */
.redirect-strip {
  margin-top: 1rem;
  padding: 14px 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(13, 110, 253, .07), rgba(25, 135, 84, .05));
  border: 1px solid rgba(13, 110, 253, .2);
  display: flex;
  align-items: center;
  gap: 12px;
}

body.dark-mode .redirect-strip {
  background: linear-gradient(135deg, rgba(56, 139, 253, .1), rgba(63, 185, 80, .07));
  border-color: rgba(56, 139, 253, .25);
}

.redirect-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0d6efd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  animation: pulseIcon 1.4s ease infinite;
}

@keyframes pulseIcon {
  0%, 100% { box-shadow: 0 0 0 0   rgba(13, 110, 253, .45); }
  50%       { box-shadow: 0 0 0 9px rgba(13, 110, 253, 0);  }
}

.redirect-text { flex: 1; }

.rd-label {
  font-size: 12px;
  font-weight: 700;
  color: #0d6efd;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 5px;
}

body.dark-mode .rd-label { color: #58a6ff; }

.redirect-bar-track {
  height: 5px;
  background: #e9ecef;
  border-radius: 99px;
  overflow: hidden;
}

body.dark-mode .redirect-bar-track { background: #30363d; }

.redirect-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0d6efd, #198754);
  border-radius: 99px;
  transition: width .15s linear;
}

.redirect-counter {
  font-size: 11px;
  color: #9ca3af;
  font-family: 'DM Mono', monospace;
  margin-top: 4px;
}

/* ─────────────────────────────────────────────────────────
   LOCK OVERLAY (stays inside card)
───────────────────────────────────────────────────────── */
.lock-ovl {
  display: none;
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 60;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px;
  border-radius: var(--card-radius);
  text-align: center;
}

.lock-ovl.on { display: flex; }

body.dark-mode .lock-ovl { background: #1f2933; }

.lock-ico {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(220, 53, 69, .1);
  border: 2px solid rgba(220, 53, 69, .3);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}

.lock-title { font-size: 1rem; font-weight: 700; }

.lock-cd {
  font-family: 'DM Mono', monospace;
  font-size: 2.2rem;
  font-weight: 500;
  color: #dc3545;
  letter-spacing: 2px;
}

.lock-sub { font-size: 12px; color: #9ca3af; }

body.dark-mode .lock-cd { color: #f85149; }

/* ─────────────────────────────────────────────────────────
   PROCESS STEPS
───────────────────────────────────────────────────────── */
.proc-title { font-size: 1rem; font-weight: 700; margin-bottom: 3px; }
.proc-sub { font-size: 12px; color: #9ca3af; margin-bottom: 12px; }
.proc-steps { display: flex; flex-direction: column; gap: 7px; }

.ps-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  font-size: 13px;
  font-weight: 500;
  transition: all .3s;
}

.ps-row.run { border-color: #0d6efd; background: rgba(13, 110, 253, .04); }
.ps-row.done { border-color: #198754; background: rgba(25, 135, 84, .04); }

.ps-ico {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}

.mini-spin {
  width: 14px; height: 14px;
  border: 2px solid #dee2e6;
  border-top-color: #0d6efd;
  border-radius: 50%;
  animation: _mspin .6s linear infinite;
}

@keyframes _mspin { to { transform: rotate(360deg); } }

body.dark-mode .ps-row { background: #21262d; border-color: #30363d; }
body.dark-mode .ps-row.run  { border-color: #388bfd; background: rgba(56, 139, 253, .06); }
body.dark-mode .ps-row.done { border-color: #3fb950; background: rgba(63, 185, 80, .06); }
body.dark-mode .mini-spin { border-color: #374151; border-top-color: #388bfd; }

/* ─────────────────────────────────────────────────────────
   SESSION INFO GRID
───────────────────────────────────────────────────────── */
.sess-hdr { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }

.sess-ico {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: rgba(25, 135, 84, .1);
  border: 1px solid rgba(25, 135, 84, .25);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

.sess-title { font-size: 1rem; font-weight: 700; margin: 0; }

.sess-ok-tag { font-size: 11px; color: #198754; font-weight: 700; margin: 0; }

body.dark-mode .sess-ico { background: rgba(63, 185, 80, .08); border-color: rgba(63, 185, 80, .2); }
body.dark-mode .sess-ok-tag { color: #3fb950; }

.sess-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 9px;
}

@media(max-width: 420px) { .sess-grid { grid-template-columns: 1fr; } }

.si {
  padding: 8px 11px;
  border-radius: 8px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
}

.si-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  font-weight: 700;
  color: #9ca3af;
  margin-bottom: 2px;
}

.si-val {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: #1a202c;
  word-break: break-all;
}

.si-val.ok { color: #198754; }
.si-val.ac { color: #0d6efd; }

body.dark-mode .si { background: #21262d; border-color: #30363d; }
body.dark-mode .si-val { color: #e6edf3; }
body.dark-mode .si-val.ok { color: #3fb950; }
body.dark-mode .si-val.ac { color: #58a6ff; }

.sec-checks { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }

.sec-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 500;
  padding: 6px 10px;
  border-radius: 7px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
}

.sec-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #198754;
  flex-shrink: 0;
  animation: pdot 2s ease infinite;
}

@keyframes pdot { 0%, 100% { opacity: 1 } 50% { opacity: .4 } }

body.dark-mode .sec-row { background: #21262d; border-color: #30363d; }
body.dark-mode .sec-dot { background: #3fb950; }

/* ─────────────────────────────────────────────────────────
   SIGNIN PROGRESS (2 STEPS)
───────────────────────────────────────────────────────── */
.signin-prog-track {
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid #e9ecef;
}

body.dark-mode .signin-prog-track { border-bottom-color: #2d3748; }

.signin-step-bar { display: flex; align-items: center; margin-bottom: 5px; }

.sn-node {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid #dee2e6;
  background: #f8f9fa;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: #adb5bd;
  flex-shrink: 0;
  transition: all .3s;
}

.sn-node.active { border-color: #0d6efd; background: #0d6efd; color: #fff; }
.sn-node.done   { border-color: #198754; background: #198754; color: #fff; }

body.dark-mode .sn-node { border-color: #374151; background: #21262d; color: #6b7280; }
body.dark-mode .sn-node.active { border-color: #388bfd; background: #388bfd; }
body.dark-mode .sn-node.done   { border-color: #3fb950; background: #3fb950; }

.sn-conn { flex: 1; height: 2px; background: #e9ecef; }
.sn-conn-fill { height: 100%; width: 0%; background: #198754; transition: width .5s ease; }

body.dark-mode .sn-conn { background: #30363d; }
body.dark-mode .sn-conn-fill { background: #3fb950; }

.sn-labels { display: flex; justify-content: space-between; padding: 0 2px; }

.sn-lbl {
  font-size: 10px; font-weight: 600; color: #adb5bd;
  text-transform: uppercase; letter-spacing: .4px;
  flex: 1; text-align: center; transition: color .3s;
}

.sn-lbl:first-child { text-align: left; }
.sn-lbl:last-child  { text-align: right; }
.sn-lbl.active { color: #0d6efd; }
.sn-lbl.done   { color: #198754; }

body.dark-mode .sn-lbl { color: #6b7280; }
body.dark-mode .sn-lbl.active { color: #58a6ff; }
body.dark-mode .sn-lbl.done   { color: #3fb950; }

/* ─────────────────────────────────────────────────────────
   OAUTH SCREEN — rendered OUTSIDE the 3D card context
   so it never bleeds through during the flip animation
───────────────────────────────────────────────────────── */
.oauth-screen {
  /* Detach from the card's preserve-3d by using fixed positioning */
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateX(120vw);
  width: min(520px, calc(100vw - 24px));
  max-height: 90vh;
  overflow-y: auto;
  background: white;
  border-radius: var(--card-radius);
  padding: 2rem;
  z-index: 8000;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
  transition: transform .45s cubic-bezier(.4, 0, .2, 1);
  /* Ensure it's a flat element, never 3D-transformed by parent */
  transform-style: flat;
}

.oauth-screen.show {
  transform: translate(-50%, -50%) translateX(0);
}

/* Backdrop when oauth is open */
.oauth-screen.show::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: -1;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.oauth-header { position: relative; height: 36px; margin-bottom: .5rem; }

.oauth-back {
  position: relative; z-index: 2;
  background: none; border: none; padding: 0;
  font-size: .9rem; font-weight: 500;
  color: #0d6efd; cursor: pointer;
}

body.dark-mode .oauth-screen {
  background: #1f2933;
  border: 1px solid #2d3748;
}

body.dark-mode .oauth-screen.show::before {
  background: rgba(0, 0, 0, 0.65);
}

@media (max-width: 420px) {
  .oauth-screen { padding: 1.5rem 1.25rem; }
  .oauth-header { height: 40px; }
}

.auth-provider {
  text-decoration: none; color: #111; font-weight: 500;
  background: #fff; display: flex; align-items: center; gap: .5rem;
  padding: .65rem; border-radius: .5rem; border: 1px solid #ddd;
  width: 100%; transition: background .2s ease;
}

.auth-provider:hover { background: #f8fafc; }
.auth-provider .provider-icon { width: 20px; height: 20px; font-size: 20px; }
.auth-provider.line { border-color: #d1fae5; }
.auth-provider.line:hover { background: #ecfdf5; }

body.dark-mode .auth-provider { background: #111827; border: 1px solid #374151; color: #e5e7eb; }
body.dark-mode .auth-provider:hover { background: #1f2933; }

/* ─────────────────────────────────────────────────────────
   FORM GROUPS
───────────────────────────────────────────────────────── */
.form-group-inline { margin-bottom: 0.9rem; }

.form-group-inline label {
  font-size: .85rem; font-weight: 500;
  margin-bottom: .25rem; color: #333; display: block;
}

@media (min-width: 576px) {
  .form-group-inline {
    display: flex; flex-wrap: wrap;
    align-items: center; gap: 0.5rem 0.75rem;
  }
  .form-group-inline label {
    margin-bottom: 0; min-width: 6rem; flex-shrink: 0;
  }
  .form-group-inline input,
  .form-group-inline select,
  .form-group-inline textarea,
  .form-group-inline .form-control { flex: 1; min-width: 0; }
}

.form-group-inline.modern {
  margin-bottom: 1rem;
  display: flex; flex-direction: column;
}

.form-group-inline.modern label { font-size: .85rem; font-weight: 500; margin-bottom: .25rem; }

.form-group-inline.modern input,
.form-group-inline.modern select,
.form-group-inline.modern textarea {
  width: 100%; padding: .65rem;
  border-radius: .5rem; border: 1px solid #ddd;
  outline: none; transition: border .2s ease;
  font-size: .875rem; box-sizing: border-box;
}

.form-group-inline.modern input:focus,
.form-group-inline.modern select:focus,
.form-group-inline.modern textarea:focus { border-color: #0d6efd; }

@media (min-width: 576px) {
  .form-group-inline.modern { flex-direction: row; align-items: center; gap: 0.5rem 0.75rem; }
  .form-group-inline.modern label { margin-bottom: 0; min-width: 6rem; flex-shrink: 0; }
  .form-group-inline.modern input,
  .form-group-inline.modern select,
  .form-group-inline.modern textarea { flex: 1; min-width: 0; }
}

/* ─────────────────────────────────────────────────────────
   CAPTCHA SECTION
───────────────────────────────────────────────────────── */
.cap-divider { display: flex; align-items: center; gap: 9px; margin: 10px 0 9px; }
.cap-divider::before,
.cap-divider::after { content: ''; flex: 1; height: 1px; background: #dee2e6; }
.cap-divider span {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: #adb5bd; white-space: nowrap;
}

body.dark-mode .cap-divider::before,
body.dark-mode .cap-divider::after { background: #374151; }

.cap-tabs {
  display: flex; gap: 3px;
  background: #f1f3f5; border-radius: 7px;
  padding: 3px; margin-bottom: 9px;
}

body.dark-mode .cap-tabs { background: #21262d; }

.cap-tab {
  flex: 1; padding: 5px 4px; border-radius: 5px;
  border: none; background: transparent;
  color: #9ca3af; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all .2s; text-align: center; font-family: inherit;
}

.cap-tab.on { background: #fff; color: #1a202c; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
body.dark-mode .cap-tab.on { background: #30363d; color: #e6edf3; }

.cap-panel { display: none; }
.cap-panel.on { display: block; }

.txt-cap-wrap { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; }

#capCanvas {
  border-radius: 7px; border: 1px solid #dee2e6;
  background: #f8f9fa; cursor: pointer; flex-shrink: 0;
}

body.dark-mode #capCanvas { border-color: #374151; filter: brightness(.85) contrast(1.1); }

.cap-meta { display: flex; flex-direction: column; gap: 5px; }

.cap-timer-row {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: #9ca3af; font-family: 'DM Mono', monospace;
}

.ring-svg { width: 22px; height: 22px; flex-shrink: 0; }
.ring-bg  { fill: none; stroke: #e9ecef; stroke-width: 2.5; }
body.dark-mode .ring-bg { stroke: #30363d; }
.ring-fill {
  fill: none; stroke: #0d6efd; stroke-width: 2.5;
  stroke-linecap: round; stroke-dasharray: 66; stroke-dashoffset: 0;
  transform: rotate(-90deg); transform-origin: center;
  transition: stroke-dashoffset 1s linear, stroke .3s;
}

.ref-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 6px;
  border: 1px solid #dee2e6; background: #f8f9fa;
  color: #6c757d; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all .2s; font-family: inherit;
}

.ref-btn:hover { border-color: #0d6efd; color: #0d6efd; background: #f0f7ff; }

body.dark-mode .ref-btn { border-color: #374151; background: #21262d; color: #8b949e; }
body.dark-mode .ref-btn:hover { border-color: #388bfd; color: #58a6ff; }

.cc-counter { font-size: 11px; color: #9ca3af; text-align: right; margin-top: 2px; font-family: 'DM Mono', monospace; }

.math-disp {
  font-family: 'DM Mono', monospace;
  font-size: 22px; font-weight: 500; text-align: center;
  padding: 14px 10px; border-radius: 8px;
  border: 1px solid #dee2e6; background: #f8f9fa;
  letter-spacing: 1px; margin-bottom: 8px;
}

body.dark-mode .math-disp { background: #21262d; border-color: #374151; color: #e6edf3; }

.grid-prompt {
  font-size: 12px; font-weight: 600; text-align: center;
  margin-bottom: 7px; padding: 6px 10px;
  background: #f8f9fa; border-radius: 7px; border: 1px solid #dee2e6;
}

.grid-prompt span { color: #0d6efd; }

body.dark-mode .grid-prompt { background: #21262d; border-color: #374151; }
body.dark-mode .grid-prompt span { color: #58a6ff; }

.grid-cell {
  aspect-ratio: 1; border-radius: 8px;
  border: 2px solid #dee2e6; background: #f8f9fa;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; cursor: pointer; transition: all .2s;
  user-select: none; position: relative;
}

.grid-cell:hover { border-color: #0d6efd; background: rgba(13,110,253,.05); }

.grid-cell.sel {
  border-color: #0d6efd; background: rgba(13,110,253,.1);
  box-shadow: inset 0 0 0 2px #0d6efd;
}

.grid-cell.sel::after {
  content: '✓'; position: absolute; top: 2px; right: 5px;
  font-size: 10px; color: #0d6efd; font-weight: 700;
}

body.dark-mode .grid-cell { border-color: #374151; background: #21262d; }
body.dark-mode .grid-cell:hover { border-color: #388bfd; }
body.dark-mode .grid-cell.sel { border-color: #388bfd; background: rgba(56,139,253,.12); box-shadow: inset 0 0 0 2px #388bfd; }
body.dark-mode .grid-cell.sel::after { color: #58a6ff; }

.cap-ok {
  display: none; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: #198754;
  padding: 7px 10px; margin-top: 5px;
  background: rgba(25,135,84,.08);
  border: 1px solid rgba(25,135,84,.25); border-radius: 7px;
}

.cap-ok.on { display: flex; }

.ok-circle {
  width: 17px; height: 17px; border-radius: 50%;
  background: #198754;
  display: flex; align-items: center; justify-content: center;
  animation: popIn .4s cubic-bezier(.34,1.56,.64,1); flex-shrink: 0;
}

@keyframes popIn { 0% { transform: scale(0); opacity: 0 } 100% { transform: scale(1); opacity: 1 } }

body.dark-mode .cap-ok { color: #3fb950; background: rgba(63,185,80,.08); border-color: rgba(63,185,80,.25); }
body.dark-mode .ok-circle { background: #3fb950; }

.cap-err { font-size: 12px; color: #dc3545; margin-top: 3px; display: none; font-weight: 500; }
.cap-err.on { display: block; }
body.dark-mode .cap-err { color: #f85149; }

.cap-digit-hint { font-size: 10px; color: #6b7280; margin-top: 2px; margin-bottom: 4px; }

/* ─────────────────────────────────────────────────────────
   GENERAL ERROR
───────────────────────────────────────────────────────── */
#genErr {
  display: none; font-size: 12px; color: #dc3545;
  font-weight: 500; text-align: center; margin-top: 6px;
  padding: 7px 10px; background: rgba(220,53,69,.07);
  border-radius: 6px; border: 1px solid rgba(220,53,69,.2);
}

#genErr.on { display: block; }

body.dark-mode #genErr { color: #f85149; background: rgba(248,81,73,.08); border-color: rgba(248,81,73,.3); }

/* ─────────────────────────────────────────────────────────
   SUSPICIOUS BANNER & ATTEMPT METER
───────────────────────────────────────────────────────── */
.susp-banner {
  display: none; align-items: center; gap: 7px;
  padding: 7px 11px; border-radius: 7px;
  background: rgba(220,53,69,.07); border: 1px solid rgba(220,53,69,.25);
  font-size: 12px; color: #dc3545; font-weight: 500; margin-bottom: 9px;
}

.susp-banner.on { display: flex; }

body.dark-mode .susp-banner { color: #f85149; background: rgba(248,81,73,.09); border-color: rgba(248,81,73,.3); }

.att-meter {
  display: none; padding: 7px 11px; border-radius: 7px;
  border: 1px solid #f59e0b; background: rgba(245,158,11,.07); margin-bottom: 9px;
}

.att-meter.on { display: block; }

.att-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.att-txt { font-size: 12px; font-weight: 600; color: #d97706; }
.att-pips { display: flex; gap: 4px; }

.pip { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #dee2e6; background: #f8f9fa; transition: all .3s; }
.pip.used { background: #dc3545; border-color: #dc3545; }
.pip.warn { background: #f59e0b; border-color: #f59e0b; }

body.dark-mode .att-meter { background: rgba(210,153,34,.1); border-color: #d29922; }
body.dark-mode .att-txt { color: #d29922; }
body.dark-mode .pip { border-color: #374151; background: #21262d; }

/* ─────────────────────────────────────────────────────────
   PASSKEY BUTTON & PANEL
───────────────────────────────────────────────────────── */
#passkeyBtn {
  display: flex; justify-content: center; align-items: center;
  gap: .5rem; width: 100%; padding: .65rem;
  border-radius: 50px; font-weight: 500;
  background: #0d6efd; color: #fff;
  border: none; cursor: pointer; transition: all 0.25s ease;
}

#passkeyBtn:hover { background: #0b5ed7; }

body.dark-mode #passkeyBtn { background: linear-gradient(135deg, #6366f1, #4f46e5); border: none; }
body.dark-mode #passkeyBtn:hover { opacity: 0.95; }

/* noPasskeyPanel */
#noPasskeyPanel { background-color: #f8f9fa !important; border-color: #dee2e6 !important; color: #212529; }
#noPasskeyPanel .text-warning { color: #c78200 !important; }
#noPasskeyPanel .text-muted   { color: #6c757d !important; }
#noPasskeyPanel .form-control { background-color: #fff; border-color: #ced4da; color: #212529; }
#noPasskeyPanel .form-control::placeholder { color: #adb5bd; }
#noPasskeyPanel .form-control:focus { background-color: #fff; border-color: #86b7fe; color: #212529; box-shadow: 0 0 0 .25rem rgba(13,110,253,.25); }
#noPasskeyPanel .btn-outline-secondary { color: #6c757d; border-color: #6c757d; }
#noPasskeyPanel .btn-outline-secondary:hover { background-color: #6c757d; color: #fff; }
#noPasskeyPanel .btn-primary { background-color: #0d6efd; border-color: #0d6efd; color: #fff; }
#noPasskeyPanel .btn-primary:hover { background-color: #0b5ed7; border-color: #0a58ca; }
#noPasskeyPanel .text-danger { color: #dc3545 !important; }

body.dark-mode #noPasskeyPanel { background-color: #111827 !important; border-color: #374151 !important; color: #e5e7eb; }
body.dark-mode #noPasskeyPanel .text-warning { color: #fbbf24 !important; }
body.dark-mode #noPasskeyPanel .text-muted   { color: #9ca3af !important; }
body.dark-mode #noPasskeyPanel .form-label   { color: #d1d5db; }
body.dark-mode #noPasskeyPanel .form-control { background-color: #0d1117; border-color: #374151; color: #f9fafb; }
body.dark-mode #noPasskeyPanel .form-control::placeholder { color: #4b5563; }
body.dark-mode #noPasskeyPanel .form-control:focus { background-color: #0d1117; border-color: #3b82f6; color: #fff; box-shadow: 0 0 0 .25rem rgba(59,130,246,.25); }
body.dark-mode #noPasskeyPanel .btn-outline-secondary { color: #9ca3af; border-color: #4b5563; background-color: transparent; }
body.dark-mode #noPasskeyPanel .btn-outline-secondary:hover { background-color: #374151; color: #e5e7eb; border-color: #6b7280; }
body.dark-mode #noPasskeyPanel .btn-primary { background: linear-gradient(135deg, #3b82f6, #2563eb); border: none; color: #fff; }
body.dark-mode #noPasskeyPanel .btn-primary:hover { background: linear-gradient(135deg, #2563eb, #1d4ed8); border: none; }
body.dark-mode #noPasskeyPanel .text-danger { color: #f87171 !important; }

/* ─────────────────────────────────────────────────────────
   SIGNUP STEPPER
───────────────────────────────────────────────────────── */
.stepper-indicator {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem; position: relative;
}

.step-item { display: flex; flex-direction: column; align-items: center; font-size: .75rem; color: #888; z-index: 1; }
.step-item.active,
.step-item.completed { color: #0d6efd; }

.step-circle {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid #ddd;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 600; margin-bottom: .25rem;
  background: #fff; transition: all 0.3s ease;
}

.step-item.active .step-circle,
.step-item.completed .step-circle { border-color: #0d6efd; background: #0d6efd; color: #fff; }

.step-line { flex: 1; height: 2px; background: #ddd; margin: 0 .25rem; }

.step { display: none; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; position: relative; width: 100%; }
.step.active { display: block; opacity: 1; pointer-events: auto; z-index: 2; }

.role-options { display: flex; justify-content: space-between; gap: .5rem; }

.role-card {
  flex: 1; border: 1px solid #ddd; border-radius: .75rem;
  text-align: center; padding: 1rem; cursor: pointer;
  transition: all 0.25s ease; background: #fff;
}

.role-card i { font-size: 1.5rem; margin-bottom: .5rem; display: block; color: #555; }
.role-card span { font-size: .85rem; display: block; }
.role-card:hover { background: #f8fafc; border-color: #0d6efd; }
.role-card input[type="radio"] { display: none; }
.role-card input:checked+i,
.role-card input:checked+span,
.role-card.selected { color: #0d6efd; font-weight: 600; border-color: #0d6efd; }

body.dark-mode .role-card { background: #111827; border: 1px solid #374151; color: #e5e7eb; }
body.dark-mode .role-card:hover { border-color: #3b82f6; }

.service-card {
  border: 1px solid #ddd; border-radius: .5rem;
  cursor: pointer; transition: all 0.25s ease;
  padding: 1rem 0; text-align: center;
}

.service-card.selected { background: #e7f1ff; border-color: #0d6efd; }
.service-card i { font-size: 1.5rem; display: block; margin-bottom: .5rem; }
.service-card span { font-size: .85rem; font-weight: 500; }

.signup-nav {
  position: sticky; bottom: 0;
  background: #fff; padding: 1rem 0 0.5rem;
  margin-top: auto; border-top: 1px solid #eee; z-index: 10;
}

body.dark-mode .signup-nav { background: #1f2933; border-top: 1px solid #374151; }

button#nextBtn, button#prevBtn { min-width: 100px; padding: .55rem 1.25rem; font-size: .875rem; }

textarea { resize: none; border-radius: .5rem; padding: .75rem; font-size: .875rem; }

/* ─────────────────────────────────────────────────────────
   GLOBAL DARK MODE
───────────────────────────────────────────────────────── */
body.dark-mode { background: #0f2027; color: #e5e7eb; }

body.dark-mode .auth-card { background: #1f2933; border: 1px solid #2d3748; }

body.dark-mode h1,
body.dark-mode h4,
body.dark-mode p,
body.dark-mode label { color: #e5e7eb; }

body.dark-mode .text-muted { color: #9ca3af !important; }

body.dark-mode .form-control { background: #111827; border: 1px solid #374151; color: #f9fafb; }
body.dark-mode .form-control::placeholder { color: #6b7280; }
body.dark-mode .form-control:focus { background: #111827; border-color: #3b82f6; color: #fff; }

body.dark-mode .error { color: #f87171; }

body.dark-mode .btn-primary { background: linear-gradient(135deg, #3b82f6, #2563eb); border: none; }
body.dark-mode .btn-success { background: linear-gradient(135deg, #10b981, #059669); border: none; }
body.dark-mode .btn-outline-info,
body.dark-mode .btn-outline-secondary { color: #e5e7eb; border-color: #4b5563; }
body.dark-mode .btn-outline-info:hover,
body.dark-mode .btn-outline-secondary:hover { background: #374151; }

body.dark-mode .divider span { background: #1f2933; color: #9ca3af; }
body.dark-mode .divider::before,
body.dark-mode .divider::after { background: #374151; }

body.dark-mode .form-check-label { color: #d1d5db; }
body.dark-mode .form-check-input { background-color: #111827; border-color: #4b5563; }

body.dark-mode #darkModeToggle { color: #facc15; }

body.dark-mode .stepper-indicator { color: #9ca3af; }
body.dark-mode .step-circle { background: #374151; color: #9ca3af; }
body.dark-mode .step-item.active .step-circle { background: #3b82f6; color: #fff; }
body.dark-mode .step-line { background: #374151; }
body.dark-mode .signup-progress { background: #111827; }
body.dark-mode .progress-bar { background: linear-gradient(135deg, #3b82f6, #2563eb); }

/* ─────────────────────────────────────────────────────────
   LAYOUT — HEADER / MAIN / FOOTER
───────────────────────────────────────────────────────── */
.app-header {
  position: relative; top: 0; left: 0; right: 0; z-index: 1000;
  border-bottom: 1px solid #d9d9d9;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

.app-header-inner { padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top)); }

body.dark-mode .app-header { background: rgba(17,24,39,0.96); border-bottom-color: rgba(255,255,255,0.08); }

.brand-logo-img { height: 64px; display: none; margin-top: 2px; }

.logo-light { display: block; height: 64px; max-height: 64px; width: auto; }
.logo-dark  { height: 64px; max-height: 64px; width: auto; display: none; }

body.dark-mode .logo-light { display: none; }
body.dark-mode .logo-dark  { display: block; }

@media (max-width: 768px) {
  .brand-logo-img { height: 64px; max-height: 82px; }
  .logo-light, .logo-dark { height: 64px; max-height: 64px; width: auto; }
}

.auth-main {
  min-height: calc(100vh - 450px);
  display: flex; justify-content: center; align-items: center;
  padding: 24px 12px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0));
}

.auth-footer {
  width: 100%; font-size: 13px; color: #6b7280;
  background: transparent; padding: 20px 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px;
}

.auth-footer-inner {
  max-width: 1300px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}

.footer-brand { white-space: nowrap; }

.footer-links { display: flex; gap: 18px; }
.footer-links a { color: #6b7280; text-decoration: none; transition: color .2s ease; }
.footer-links a:hover { color: #111827; text-decoration: underline; }

.footer-lang { display: flex; gap: 8px; }
.footer-lang button {
  background: transparent; border: none; color: #6b7280;
  font-size: 13px; padding: 4px 6px; cursor: pointer;
  border-radius: 6px; transition: background .2s ease, color .2s ease;
}
.footer-lang button:hover { background: rgba(0,0,0,.05); color: #111827; }

body.dark-mode .auth-footer { color: #9ca3af; }
body.dark-mode .footer-links a { color: #9ca3af; }
body.dark-mode .footer-links a:hover { color: #e5e7eb; }
body.dark-mode .footer-lang button { color: #9ca3af; }
body.dark-mode .footer-lang button:hover { background: rgba(255,255,255,.08); color: #e5e7eb; }

.auth-links { display: flex; flex-direction: column; gap: 6px; }
.auth-link { font-size: 14px; color: #8b8f98; cursor: pointer; transition: color .2s ease; }
.auth-link:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .auth-footer-inner { flex-direction: column; text-align: center; }
  .footer-links { order: 2; }
  .footer-lang  { order: 3; }
}

/* ─────────────────────────────────────────────────────────
   DIVIDER & MISC
───────────────────────────────────────────────────────── */
.divider { display: flex; align-items: center; font-size: .85rem; color: #888; margin: 1rem 0; }
.divider::before,
.divider::after { content: ""; flex: 1; height: 1px; background: #ddd; }
.divider span { margin: 0 .75rem; }

/* Password toggle */
.pwd-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #adb5bd; cursor: pointer; padding: 4px;
}
.pwd-eye:hover { color: #6c757d; }

/* Toast */
.toast-stack { position: fixed; bottom: 18px; right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 6px; }

.toast-item {
  padding: 8px 13px; border-radius: 8px;
  background: #fff; border: 1px solid #e9ecef;
  border-left: 3px solid #0d6efd;
  font-size: 12px; font-weight: 500;
  box-shadow: 0 4px 14px rgba(0,0,0,.09);
  animation: tIn .3s ease, tOut .3s ease 2.7s forwards;
  max-width: 250px;
}

body.dark-mode .toast-item { background: #21262d; border-color: #30363d; border-left-color: #388bfd; color: #e6edf3; }

@keyframes tIn  { from { transform: translateX(100%); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes tOut { to   { transform: translateX(110%); opacity: 0 } }