:root {
  --bg: #070b14;
  --panel: rgba(16, 23, 38, 0.82);
  --panel-strong: rgba(20, 29, 48, 0.94);
  --text: #f7f9ff;
  --muted: #94a3b8;
  --soft: #cbd5e1;
  --line: rgba(148, 163, 184, 0.18);
  --accent: #7c6cff;
  --accent-2: #23d3ee;
  --danger: #fb7185;
  --ok: #34d399;
  --warn: #fbbf24;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); -webkit-text-size-adjust: 100%; }
body.mine-auth-body {
  min-height: 100svh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, rgba(124,108,255,.22), transparent 34%), #070b14;
  overflow-x: hidden;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
input { font-size: 16px; }

.auth-bg { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.auth-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}
.auth-bg span { position: absolute; border-radius: 999px; filter: blur(28px); opacity: .55; }
.auth-bg span:nth-child(1) { width: 260px; height: 260px; left: 8%; top: 12%; background: rgba(124,108,255,.35); }
.auth-bg span:nth-child(2) { width: 220px; height: 220px; right: 10%; top: 20%; background: rgba(35,211,238,.22); }
.auth-bg span:nth-child(3) { width: 180px; height: 180px; left: 48%; bottom: 5%; background: rgba(52,211,153,.13); }

.back-link {
  position: fixed;
  z-index: 5;
  top: calc(env(safe-area-inset-top, 0px) + 18px);
  left: calc(env(safe-area-inset-left, 0px) + 18px);
  color: rgba(226, 232, 240, .78);
  text-decoration: none;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, .54);
  border-radius: 999px;
  backdrop-filter: blur(16px);
  transition: .2s ease;
}
.back-link:hover { color: #fff; border-color: rgba(124,108,255,.45); transform: translateY(-1px); }

.auth-container {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 72px) max(18px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 28px) max(18px, env(safe-area-inset-left, 0px));
}
.auth-shell {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(390px, 480px);
  gap: 28px;
  align-items: center;
  animation: authIn .38s ease both;
}
.auth-hero {
  min-height: 560px;
  padding: 44px;
  border: 1px solid var(--line);
  border-radius: 36px;
  background: linear-gradient(145deg, rgba(18, 26, 43, .72), rgba(10, 15, 27, .42));
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.auth-hero::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  right: -180px;
  bottom: -160px;
  background: radial-gradient(circle, rgba(124,108,255,.38), transparent 66%);
}
.mine-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 900;
  letter-spacing: -0.08em;
  box-shadow: 0 18px 50px rgba(124,108,255,.32);
}
.mine-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}
.mine-mark.small { width: 44px; height: 44px; border-radius: 15px; font-size: 20px; }
.auth-eyebrow { margin: 34px 0 12px; color: var(--accent-2); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 800; }
.auth-hero h1 { max-width: 620px; margin: 0; font-size: clamp(36px, 5vw, 62px); line-height: .96; letter-spacing: -.055em; }
.auth-hero p:not(.auth-eyebrow) { max-width: 530px; color: var(--soft); font-size: 17px; line-height: 1.6; }
.auth-hero-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 34px; }
.auth-hero-pills span { padding: 9px 12px; border-radius: 999px; color: #dbeafe; border: 1px solid var(--line); background: rgba(255,255,255,.045); }

.auth-panel {
  width: 100%;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px);
  animation: panelIn .28s ease both;
}
.auth-panel.wide { max-width: 560px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand strong { display: block; font-size: 20px; letter-spacing: -.03em; }
.auth-brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.auth-panel h2 { margin: 0 0 8px; font-size: 32px; letter-spacing: -.04em; }
.auth-subtitle { margin: 0 0 22px; color: var(--muted); line-height: 1.55; }
.auth-form { display: grid; gap: 14px; }
.auth-grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-field { display: grid; gap: 7px; }
.auth-field > span { color: #dbe3f0; font-size: 13px; font-weight: 700; }
.auth-field input, .code-grid input {
  width: 100%;
  min-height: 52px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(2, 6, 23, .36);
  outline: none;
  padding: 0 15px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.auth-field input::placeholder { color: rgba(148,163,184,.58); }
.auth-field input:focus, .code-grid input:focus {
  border-color: rgba(35,211,238,.65);
  background: rgba(15,23,42,.72);
  box-shadow: 0 0 0 4px rgba(35,211,238,.12);
}
.auth-field.is-error input { border-color: rgba(251,113,133,.72); box-shadow: 0 0 0 4px rgba(251,113,133,.12); }
.auth-field.is-ok input { border-color: rgba(52,211,153,.68); }
.auth-field small, .field-error { min-height: 16px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.auth-field.is-error small, .field-error.is-visible { color: var(--danger); }
.auth-field.is-ok small { color: var(--ok); }
.auth-password-box { position: relative; display: flex; align-items: center; }
.auth-password-box input { padding-right: 92px; }
.ghost-icon { position: absolute; right: 8px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 12px; color: var(--soft); background: rgba(255,255,255,.06); cursor: pointer; }
.ghost-icon:hover { background: rgba(255,255,255,.1); color: white; }
.auth-row { display: flex; align-items: center; gap: 10px; }
.auth-row.between { justify-content: space-between; }
.auth-check { display: flex; align-items: center; gap: 9px; color: var(--soft); font-size: 14px; user-select: none; }
.auth-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.auth-check.terms { align-items: flex-start; line-height: 1.35; }
.auth-link { border: 0; background: transparent; color: var(--accent-2); padding: 0; cursor: pointer; text-decoration: none; font-weight: 700; }
.auth-link:hover { color: white; }
.auth-back { border: 0; background: rgba(255,255,255,.06); color: var(--soft); border-radius: 999px; padding: 9px 12px; cursor: pointer; margin-bottom: 18px; }
.auth-submit {
  position: relative;
  min-height: 54px;
  border: 0;
  border-radius: 18px;
  color: white;
  background: linear-gradient(135deg, #7567ff, #16c7e8);
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 18px 42px rgba(35,211,238,.18);
  transition: transform .18s ease, filter .18s ease, opacity .18s ease;
  overflow: hidden;
}
.auth-submit:hover { transform: translateY(-1px); filter: brightness(1.04); }
.auth-submit:active { transform: translateY(0); }
.auth-submit:disabled { opacity: .68; cursor: wait; transform: none; }
.auth-submit i { display: none; position: absolute; width: 20px; height: 20px; inset: 0; margin: auto; border: 2px solid rgba(255,255,255,.4); border-top-color: white; border-radius: 50%; animation: spin .75s linear infinite; }
.auth-submit.is-loading span { opacity: 0; }
.auth-submit.is-loading i { display: block; }
.auth-switch { margin: 18px 0 0; text-align: center; color: var(--muted); }
.auth-switch a { color: var(--accent-2); text-decoration: none; font-weight: 800; }
.auth-notice { margin-bottom: 14px; padding: 12px 14px; border-radius: 16px; border: 1px solid rgba(251,113,133,.22); color: #fecdd3; background: rgba(251,113,133,.09); line-height: 1.4; }
.auth-notice.success { border-color: rgba(52,211,153,.24); color: #bbf7d0; background: rgba(52,211,153,.09); }
.auth-pwa-install {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.045);
}
.auth-pwa-install[hidden] { display: none; }
.auth-pwa-install img { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; background: rgba(255,255,255,.08); }
.auth-pwa-install strong { display: block; color: #fff; }
.auth-pwa-install p { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.auth-pwa-install ol { margin: 8px 0 0; padding-left: 18px; color: var(--soft); font-size: 12px; line-height: 1.45; }
.auth-pwa-actions { display: flex; gap: 6px; align-items: center; }
.auth-pwa-actions button { border: 0; border-radius: 12px; min-height: 36px; padding: 0 10px; color: #fff; background: rgba(124,108,255,.3); cursor: pointer; }
.auth-pwa-actions [data-auth-install-hide] { width: 36px; padding: 0; background: rgba(255,255,255,.08); color: var(--muted); font-size: 20px; line-height: 1; }
.password-meter { height: 5px; border-radius: 999px; background: rgba(148,163,184,.14); overflow: hidden; }
.password-meter i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--danger); transition: .2s ease; }
.password-meter[data-score="2"] i { width: 50%; background: var(--warn); }
.password-meter[data-score="3"] i { width: 100%; background: var(--ok); }
.code-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.code-grid input { text-align: center; font-size: 22px; font-weight: 900; padding: 0; }
.resend { justify-self: center; margin-top: 2px; }
.resend:disabled { color: var(--muted); cursor: not-allowed; }
.success-panel { text-align: center; }
.success-orb { width: 78px; height: 78px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 26px; background: rgba(52,211,153,.16); color: #86efac; font-size: 34px; font-weight: 900; }
.saved-accounts { margin-top: 18px; display: grid; gap: 8px; }
.saved-account { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.035); }
.saved-account strong { display: block; }
.saved-account small { color: var(--muted); }
.saved-account button { border: 0; border-radius: 12px; padding: 8px 10px; color: white; background: rgba(124,108,255,.22); cursor: pointer; }
.auth-toast-stack { position: fixed; z-index: 20; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%); display: grid; gap: 10px; width: min(420px, calc(100vw - 28px)); pointer-events: none; }
.auth-toast { padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; color: #fff; background: rgba(15,23,42,.9); box-shadow: var(--shadow); animation: toastIn .22s ease both; }
.auth-toast.success { border-color: rgba(52,211,153,.28); }
.auth-toast.error { border-color: rgba(251,113,133,.3); }

@keyframes authIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes panelIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (max-width: 920px) {
  .auth-container { place-items: start center; padding-top: calc(env(safe-area-inset-top, 0px) + 68px); }
  .auth-shell { grid-template-columns: 1fr; width: min(560px, 100%); }
  .auth-hero { min-height: auto; padding: 22px; border-radius: 26px; }
  .auth-hero h1 { font-size: 32px; }
  .auth-hero p:not(.auth-eyebrow), .auth-hero-pills { display: none; }
  .mine-mark:not(.small) { width: 54px; height: 54px; border-radius: 18px; }
}
@media (max-width: 560px) {
  .back-link { left: 14px; top: calc(env(safe-area-inset-top, 0px) + 12px); padding: 8px 11px; font-size: 13px; }
  .auth-container { padding-left: 12px; padding-right: 12px; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }
  .auth-shell { gap: 12px; }
  .auth-hero { display: none; }
  .auth-panel { padding: 20px; border-radius: 24px; }
  .auth-panel h2 { font-size: 28px; }
  .auth-grid.two { grid-template-columns: 1fr; }
  .auth-row.between { align-items: flex-start; flex-direction: column; }
  .code-grid { gap: 6px; }
  .code-grid input { min-height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
