/* GrexStack — вход и регистрация (раскладка как login-orbit в Guardora) */
.auth-page {
  display: flex; flex-direction: column; justify-content: center; min-height: 100vh; min-height: 100svh;
  padding: 0 max(40px, env(safe-area-inset-right)) 0 max(40px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 50%, #e5edd930, transparent 70%), var(--bg);
}
html:has(dialog[open]) { overflow: hidden; }

.auth-top, .auth-bottom { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; max-width: 1120px; margin: 0 auto; padding: 26px 0; }
.auth-top a, .auth-bottom a { font-size: 12px; color: var(--text-dim); }
.auth-top a:hover, .auth-bottom a:hover { color: var(--text); }
.auth-top > span { font: 10px var(--mono); letter-spacing: 1.7px; color: #8a9880; }
.auth-bottom { padding-bottom: max(26px, env(safe-area-inset-bottom)); }
.auth-bottom > span { font-size: 12px; color: #7d8c71; }
.auth-bottom nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }

.auth {
  display: grid; grid-template-columns: 1fr 1fr; width: 100%; max-width: 1120px; min-height: 660px; margin: 0 auto; overflow: hidden;
  border: 1px solid var(--border); border-radius: 26px; background: var(--surface); box-shadow: 0 28px 70px -40px #253b2540;
  animation: auth-arrive .7s var(--ease);
}
.auth__panel { position: relative; min-width: 0; padding: 44px; }

/* Тёмная панель с историей и 3D */
.auth__panel--action { display: flex; flex-direction: column; isolation: isolate; overflow: hidden; background: radial-gradient(ellipse at 50% 65%, #63872d30, transparent 65%), #17271e; color: var(--on-dark); }
.auth__brand { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; width: fit-content; color: #f1f8e9; text-decoration: none; }
.auth__brand:hover { text-decoration: none; }
.auth__mark { width: 32px; height: 32px; }
.auth__brand-name { font-size: 24px; font-weight: 650; letter-spacing: -.8px; }
.auth__brand-sub { margin-left: 4px; padding: 5px 7px; border: 1px solid #a9c08535; border-radius: 5px; font: 9px var(--mono); letter-spacing: 1px; color: #bdd1aa; }
.auth-story { position: relative; z-index: 2; margin-top: 48px; }
.auth-story .eyebrow { margin-bottom: 15px; font-size: 9px; letter-spacing: 1.2px; color: #9fb58a; }
.auth-story h2 { margin: 0 0 17px; font-size: 41px; font-weight: 450; line-height: 1.17; letter-spacing: -.04em; }
.auth-story h2 span { color: #d0e8a3; }
.auth-story p { margin: 0; font-size: 13px; line-height: 1.8; color: #a3b694; }
.auth-perks { position: relative; z-index: 2; display: grid; gap: 10px; margin: 24px 0 0; padding: 0; list-style: none; }
.auth-perks li { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.5; color: #c4d4b5; }
.auth-perks svg { flex: none; width: 16px; height: 16px; margin-top: 2px; color: #b9d58f; }

.auth-art { position: relative; flex: 1; min-height: 240px; margin: 0 -10px; perspective: 900px; }
.auth-art-grid {
  position: absolute; inset: -30px -10%;
  background: linear-gradient(#c4e19509 1px, transparent 1px), linear-gradient(90deg, #c4e19509 1px, transparent 1px); background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse, #000, transparent 68%); mask-image: radial-gradient(ellipse, #000, transparent 68%);
}
.auth-orbit { position: absolute; top: 50%; left: 50%; width: 285px; height: 285px; margin: -142px 0 0 -142px; border: 1px solid #9fbe6550; border-radius: 50%; transform-style: preserve-3d; }
.auth-orbit--one { transform: rotateX(60deg) rotateY(-20deg); animation: auth-orbit 25s linear infinite; }
.auth-orbit--two { transform: rotateX(25deg) rotateY(60deg); }
.auth-orbit i { position: absolute; top: 50%; left: -3px; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: #e9ffbd; box-shadow: 0 0 17px #dafa9a; }
.auth-node { position: absolute; top: 50%; left: 50%; transform-style: preserve-3d; transform: translate(-50%, -50%); }
.auth-node .gs-stack { --w: 132px; --h: 30px; --d: 82px; --gap: 9px; animation: auth-node 7s ease-in-out infinite; }
.auth-node .gs-face--front { padding: 0 10px; gap: 5px; }
.auth-node .gs-blade__id { font-size: 7px; }
.auth:has(input:focus) .auth-node .gs-stack { --gap: 13px; }
.auth:has(input:focus) .gs-led { background: #f6ffd9; box-shadow: 0 0 12px #f0ffca; animation-duration: .9s; }
.auth-art-chip {
  position: absolute; top: 30%; right: 9%; padding: 8px 9px; border: 1px solid #a4c57255; border-radius: 7px; background: #163022b3;
  font: 8px var(--mono); letter-spacing: 1px; color: #b9d58f; transform: rotate(8deg); animation: auth-chip 8s ease-in-out infinite;
}
.auth-panel-foot { position: relative; z-index: 2; display: flex; justify-content: space-between; gap: 15px; padding-top: 15px; border-top: 1px solid #b6cd961a; font: 8px var(--mono); letter-spacing: 1.2px; color: #8ca177; }

/* Форма */
.auth__panel--form { display: flex; flex-direction: column; justify-content: center; padding: 56px; background: var(--surface); }
.auth__form { width: 100%; max-width: 430px; margin: 0 auto; }
.auth-kicker { margin-bottom: 24px; font: 10px var(--mono); letter-spacing: 1.6px; color: #7f8f72; }
.auth__form h1 { margin: 0 0 12px; font-size: 34px; font-weight: 500; line-height: 1.15; letter-spacing: -.035em; }
.auth__sub { margin: 0 0 30px; font-size: 13.5px; line-height: 1.8; color: var(--text-dim); }
.auth__sub b { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.auth .btn.submit { width: 100%; min-height: 50px; margin-top: 6px; padding: 0 18px; justify-content: space-between; font-size: 13px; }
.auth-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; margin: -4px 0 22px; }
.auth-row > * { white-space: nowrap; }
.auth-row .check { color: var(--text); }
.auth-link-btn { padding: 4px 0; border: 0; background: none; color: var(--link); font-size: 13px; font-weight: 600; cursor: pointer; }
.auth-link-btn:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
.auth-link-btn:disabled { color: var(--text-faint); font-weight: 500; cursor: default; }
.auth__alt { margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--border); text-align: center; font-size: 13px; color: var(--text-dim); }
.auth__alt a { font-weight: 600; }
.auth-help { display: block; width: fit-content; margin: 18px auto 0; font-size: 12px; color: #6f7e65; }
.terms-check { margin-bottom: 14px; }
.terms-check + .btn { margin-top: 10px; }

.pass-toggle .eye-off { display: none; }
.pass-toggle[aria-pressed="true"] .eye-on { display: none; }
.pass-toggle[aria-pressed="true"] .eye-off { display: block; }

.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 10px; }
.pw-meter i { height: 4px; border-radius: 4px; background: #e3e9dc; transition: background .25s; }
.pw-meter[data-level="1"] i:nth-child(1) { background: #e38b96; }
.pw-meter[data-level="2"] i:nth-child(-n + 2) { background: #e2bd55; }
.pw-meter[data-level="3"] i:nth-child(-n + 3) { background: #a5cb69; }
.pw-meter[data-level="4"] i { background: #6f9a3a; }
.pw-hint { display: block; margin-top: 8px; font-size: 12px; line-height: 1.5; color: var(--text-dim); }

.auth-plan {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: -6px 0 24px; padding: 14px 16px;
  border: 1px solid #d0dfb3; border-radius: 12px; background: linear-gradient(130deg, #edf3df, #fafbf7 75%);
}
.auth-plan__k { font: 9px var(--mono); letter-spacing: 1.2px; color: #6f7e65; }
.auth-plan__v { margin-top: 5px; font-size: 13px; font-weight: 600; line-height: 1.45; }
.auth-plan__p { margin-top: 2px; font-size: 12px; color: var(--text-dim); }
.auth-plan a { flex: none; font-size: 12px; font-weight: 600; }

.code-input { height: 62px; padding: 0 14px 0 26px; font: 600 26px var(--mono); letter-spacing: 12px; text-align: center; }
.code-input::placeholder { letter-spacing: 12px; }
.resend { margin-top: 18px; text-align: center; font-size: 13px; line-height: 1.6; color: var(--text-dim); }
.resend .auth-link-btn { padding: 0; }

/* Диалог восстановления пароля */
.modal { width: min(100% - 24px, 440px); max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: auto; border: 1px solid var(--border); border-radius: 23px; background: var(--surface); color: var(--text); box-shadow: 0 30px 100px #0005; }
.modal[open] { animation: auth-dialog .3s ease; }
.modal::backdrop { background: #0b1a188c; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.modal__in { position: relative; padding: 32px; }
.modal h2 { margin: 4px 40px 12px 0; font-size: 23px; font-weight: 550; letter-spacing: -.5px; }
.modal__sub { margin: 0 0 22px; font-size: 13px; line-height: 1.75; color: var(--text-dim); }
.modal__close { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--text-dim); font-size: 26px; line-height: 1; cursor: pointer; }
.modal__close:hover { background: var(--surface-2); color: var(--text); }
.modal .note.ok:focus { outline: none; }

@keyframes auth-arrive { from { opacity: 0; transform: perspective(1600px) translateY(15px) rotateX(1deg); } to { opacity: 1; transform: none; } }
@keyframes auth-orbit { from { transform: rotateX(60deg) rotateY(-20deg) rotateZ(0); } to { transform: rotateX(60deg) rotateY(-20deg) rotateZ(360deg); } }
@keyframes auth-node { 0%, 100% { transform: rotateX(-18deg) rotateY(-34deg) translateY(0); } 50% { transform: rotateX(-12deg) rotateY(-25deg) translateY(-10px); } }
@keyframes auth-chip { 0%, 100% { transform: rotate(8deg) translateY(0); } 50% { transform: rotate(4deg) translateY(-8px); } }
@keyframes auth-dialog { from { opacity: 0; transform: perspective(1000px) rotateX(-6deg) translateY(15px); } to { opacity: 1; transform: none; } }

/* ---------- Адаптив ---------- */
@media (max-width: 1000px) {
  .auth-page { padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left)); }
  .auth__panel { padding: 32px; }
  .auth-story h2 { font-size: 34px; }
  .auth__panel--form { padding: 40px; }
  .auth__form h1 { font-size: 29px; }
}

@media (max-height: 760px) and (min-width: 761px) {
  .auth-page { justify-content: flex-start; }
  .auth { min-height: 0; }
  .auth-art { min-height: 200px; }
}

@media (max-width: 760px) {
  .auth-page { justify-content: flex-start; padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left)); }
  .auth-top { padding: 16px 2px; }
  .auth-top > span { display: none; }
  .auth { grid-template-columns: 1fr; max-width: 520px; min-height: 0; border-radius: 22px; }
  .auth__panel--action { min-height: 196px; padding: 24px; }
  .auth-story { max-width: 72%; margin-top: 24px; }
  .auth-story h2 { margin: 0; font-size: 27px; letter-spacing: -.03em; }
  .auth-story p, .auth-story .eyebrow, .auth-panel-foot, .auth-perks { display: none; }
  .auth-art { position: absolute; right: -8px; bottom: -34px; width: 200px; height: 220px; min-height: 0; margin: 0; opacity: .75; scale: .7; transform-origin: right center; }
  .auth-art-chip { display: none; }
  .auth__panel--form { padding: 30px 24px 28px; }
  .auth-kicker { margin-bottom: 16px; }
  .auth__form h1 { font-size: 28px; }
  .auth__sub { margin-bottom: 24px; }
  .auth-bottom { flex-wrap: wrap; justify-content: center; gap: 10px 20px; max-width: 520px; padding: 22px 0 max(22px, env(safe-area-inset-bottom)); }
  .auth-bottom > span { width: 100%; text-align: center; }
  .modal__in { padding: 28px 22px; }
}

@media (max-width: 380px) {
  .auth__panel--action { min-height: 180px; padding: 22px 20px; }
  .auth-story { max-width: 78%; }
  .auth-story h2 { font-size: 24px; }
  .auth-art { right: -34px; opacity: .45; }
  .auth__panel--form { padding: 26px 18px 24px; }
  .auth__form h1 { font-size: 26px; }
  .auth-plan { flex-direction: column; align-items: flex-start; }
  .code-input { letter-spacing: 8px; padding-left: 22px; }
}

/* ---------- Страница ошибки (404) ---------- */
.auth--single { grid-template-columns: 1fr; max-width: 760px; min-height: 0; }
.err-card { min-height: 460px; padding: 48px; }
.err-card__body { position: relative; z-index: 2; margin-top: auto; padding-top: 70px; }
.err-code { font: 600 15px var(--mono); letter-spacing: 3px; color: #d0e8a3; }
.err-card h1 { margin: 16px 0 16px; font-size: clamp(32px, 5vw, 44px); font-weight: 450; line-height: 1.15; letter-spacing: -.04em; color: #f1f8e9; }
.err-card h1 span { color: #d0e8a3; }
.err-card p { margin: 0 0 30px; font-size: 14px; line-height: 1.8; color: #a3b694; }
.err-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.err-actions .btn:not(.primary) { border-color: #d9efa929; background: #ffffff05; color: #dfebd3; }
.err-actions .btn:not(.primary):hover { border-color: #d9efa955; background: #ffffff0f; }
.err-rings { position: absolute; z-index: -1; top: -60px; right: -80px; width: 380px; height: 380px; transform-style: preserve-3d; opacity: .4; animation: gs-spin-y 60s linear infinite; }
.err-rings i { position: absolute; inset: 0; border: 1px solid #9fbe6570; border-radius: 50%; }
.err-rings i:nth-child(2) { transform: rotateY(60deg); }
.err-rings i:nth-child(3) { transform: rotateY(120deg); }
@media (max-width: 760px) {
  .err-card { min-height: 420px; padding: 28px 24px; }
  .err-card__body { padding-top: 56px; }
  .err-rings { top: -40px; right: -160px; }
  .err-actions .btn { flex: 1 1 auto; }
}
