:root{
  --bg:#f4f8fb;
  --panel:#ffffff;
  --panel-2:#eef5fb;
  --text:#17212b;
  --muted:#6f8193;
  --line:#dce7f1;
  --blue:#3390ec;
  --blue2:#12e6d4;
  --green:#31b545;
  --danger:#e53935;
  --soft:rgba(51,144,236,.12);
  --shadow:0 28px 80px rgba(21,45,72,.18);
}

@media (prefers-color-scheme: dark){
  :root{
    --bg:#0f1821;
    --panel:#17212b;
    --panel-2:#1d2b37;
    --text:#f4f8fb;
    --muted:#9aabba;
    --line:#263747;
    --soft:rgba(18,230,212,.13);
    --shadow:0 28px 80px rgba(0,0,0,.42);
  }
}

*{box-sizing:border-box}
html{min-height:100%;background:var(--bg)}
body{
  min-height:100%;
  margin:0;
  font-family:Vazirmatn,Vazir,Tahoma,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
  overflow:auto;
}

.auth-page{
  min-height:100dvh;
  display:grid;
  grid-template-columns:minmax(460px,1fr) minmax(390px,500px);
  direction:ltr;
  position:relative;
}

.auth-visual{
  position:relative;
  display:grid;
  place-items:center;
  overflow:hidden;
  min-height:100dvh;
  background:
    radial-gradient(circle at 18% 26%,rgba(51,144,236,.28),transparent 18rem),
    radial-gradient(circle at 84% 82%,rgba(49,181,69,.22),transparent 16rem),
    linear-gradient(135deg,#0e2030 0%,#0d1b25 52%,#0b2018 100%);
}

.auth-visual:before{
  content:"";
  position:absolute;
  inset:0;
  background:linear-gradient(90deg,rgba(255,255,255,.04),transparent 42%,rgba(255,255,255,.02));
}

.orb{position:absolute;border-radius:999px;filter:blur(3px);opacity:.95}
.orb-one{width:260px;height:260px;background:rgba(51,144,236,.22);left:10%;top:14%}
.orb-two{width:210px;height:210px;background:rgba(49,181,69,.22);right:12%;bottom:8%}

.phone-preview{
  width:min(350px,74%);
  height:min(610px,78vh);
  min-height:500px;
  border-radius:38px;
  background:rgba(23,33,43,.78);
  border:1px solid rgba(255,255,255,.58);
  box-shadow:0 38px 90px rgba(0,0,0,.32);
  padding:22px;
  backdrop-filter:blur(18px);
  position:relative;
  z-index:2;
  direction:rtl;
}
.preview-top{height:46px;border-radius:20px;display:flex;align-items:center;gap:12px;padding:0 14px}
.preview-top span{width:34px;height:34px;border-radius:50%;background:linear-gradient(135deg,var(--blue),#5ab3ff)}
.preview-top b{height:12px;width:130px;border-radius:20px;background:#36526a}
.preview-story-row{display:flex;gap:10px;margin:20px 2px}
.preview-story-row i{width:48px;height:48px;border-radius:50%;border:3px solid var(--green);background:#142434}
.preview-chat{display:flex;align-items:center;gap:12px;border-radius:20px;padding:12px;margin:10px 0;border:1px solid rgba(255,255,255,.12)}
.preview-chat.active{border-color:rgba(51,144,236,.45);box-shadow:0 8px 24px rgba(51,144,236,.12)}
.preview-chat em{width:46px;height:46px;border-radius:50%;background:#2d5675;flex:none}
.preview-chat div{display:grid;gap:8px;flex:1}
.preview-chat strong,.preview-chat span{height:11px;border-radius:20px;background:#36526a}
.preview-chat strong{width:66%}.preview-chat span{width:92%}
.preview-message{width:74%;height:46px;border-radius:18px 18px 18px 4px;background:rgba(255,255,255,.1);margin:22px auto 0 0}
.preview-message.mine{margin:26px 0 0 auto;background:rgba(49,181,69,.38);border-radius:18px 18px 4px 18px}
.preview-input{position:absolute;bottom:22px;left:22px;right:22px;height:52px;border-radius:24px;display:flex;align-items:center;gap:12px;padding:0 14px}
.preview-input span{height:12px;flex:1;border-radius:20px;background:#36526a}
.preview-input b{width:34px;height:34px;border-radius:50%;background:var(--blue)}

.auth-panel{
  direction:rtl;
  min-height:100dvh;
  max-height:100dvh;
  overflow-y:auto;
  display:flex;
  flex-direction:column;
  justify-content:flex-start;
  padding:clamp(18px,4vh,40px);
  background:var(--bg);
  scrollbar-width:thin;
}

.auth-card{
  width:100%;
  max-width:430px;
  margin:0 auto;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:30px;
  padding:clamp(20px,3vh,28px);
  box-shadow:var(--shadow);
}

.welcome-hero{
  display:grid;
  justify-items:center;
  text-align:center;
  margin-bottom:18px;
}
.welcome-hero img{
  width:clamp(116px,18vh,166px);
  max-width:48%;
  height:auto;
  display:block;
  object-fit:contain;
  filter:drop-shadow(0 22px 34px rgba(18,230,212,.16));
}
.welcome-hero h1{
  margin:10px 0 0;
  font-size:clamp(22px,2.7vw,28px);
  line-height:1.45;
  letter-spacing:-.45px;
}

.brand-row{display:none;align-items:center;gap:14px;margin-bottom:20px}
.brand-mark{
  width:58px;
  height:58px;
  border-radius:21px;
  background-color:var(--panel-2);
  background-image:url("../icons/icon-192.png");
  background-size:72%;
  background-repeat:no-repeat;
  background-position:center;
  color:transparent;
  box-shadow:0 14px 30px rgba(18,230,212,.14);
  flex:none;
}
.brand-row h1{margin:0;font-size:24px;line-height:1.2;letter-spacing:-.3px}
.brand-row p{margin:5px 0 0;color:var(--muted);font-size:13px;line-height:1.7}
.auth-copy{display:none}
.auth-copy h2{margin:0 0 6px;font-size:26px;letter-spacing:-.5px;line-height:1.45}
.auth-copy p{margin:0 0 16px;color:var(--muted);line-height:1.9;font-size:14px}

.auth-tabs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:0 0 18px}
.auth-tabs.single{grid-template-columns:1fr}
.auth-tabs button{
  height:44px;
  border:1px solid var(--line);
  border-radius:15px;
  background:rgba(127,151,174,.08);
  color:var(--muted);
  font:inherit;
  font-weight:900;
  cursor:pointer;
  transition:.18s ease;
}
.auth-tabs button:hover{border-color:rgba(51,144,236,.35);color:var(--text)}
.auth-tabs button.active{background:linear-gradient(135deg,rgba(18,230,212,.18),rgba(51,144,236,.15));color:var(--blue);border-color:rgba(18,230,212,.36)}

.auth-form{display:grid;gap:11px}
.auth-form[hidden]{display:none}
.auth-form.register-grid{grid-template-columns:repeat(2,minmax(0,1fr));column-gap:10px;row-gap:10px}
.form-field{display:grid;gap:6px;min-width:0}
.form-field.full,.auth-submit.full{grid-column:1/-1}
.auth-form label{font-size:12.5px;font-weight:900;color:var(--muted)}
.field-shell{
  height:48px;
  border:1px solid var(--line);
  background:rgba(127,151,174,.08);
  border-radius:16px;
  display:flex;
  align-items:center;
  gap:10px;
  padding:0 13px;
  transition:.18s ease;
}
.field-shell:focus-within{border-color:var(--blue);box-shadow:0 0 0 4px rgba(51,144,236,.11);background:var(--panel)}
.field-shell span{direction:ltr;color:var(--muted);font-weight:900;border-left:1px solid var(--line);padding-left:11px}
.field-shell input{border:0;outline:0;background:transparent;color:var(--text);font:inherit;flex:1;min-width:0;width:100%}
.field-shell.plain{padding:0 15px}

.auth-submit{
  margin-top:6px;
  border:0;
  border-radius:17px;
  background:linear-gradient(135deg,var(--blue),#2185e5);
  height:50px;
  color:#fff;
  font:inherit;
  font-weight:950;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  cursor:pointer;
  box-shadow:0 16px 28px rgba(51,144,236,.28);
  transition:.18s ease;
}
.auth-submit:hover{transform:translateY(-1px)}
.auth-submit:disabled{opacity:.65;cursor:wait;transform:none}
.auth-submit b{font-size:21px;transform:rotate(180deg)}
.auth-tools{display:flex;flex-wrap:wrap;gap:10px;margin-top:14px}
.auth-tools button,.auth-tools a{border:1px solid var(--line);background:var(--soft);color:var(--blue);border-radius:14px;padding:9px 12px;font:inherit;font-size:13px;font-weight:900;text-decoration:none;cursor:pointer}
.auth-message,.auth-error{margin-top:12px;border-radius:14px;padding:10px 12px;font-size:13px;line-height:1.8;display:none}
.auth-message.show{display:block;background:rgba(49,181,69,.11);color:var(--green)}
.auth-message.show.error{background:rgba(229,57,53,.11);color:var(--danger)}
.auth-message:empty{display:none}
.auth-error{display:block;background:rgba(229,57,53,.11);color:var(--danger)}
.auth-footer{max-width:440px;margin:14px auto 0;display:none;justify-content:center;gap:8px;flex-wrap:wrap;color:var(--muted);font-size:12px;padding-bottom:10px}
.auth-footer span{background:var(--panel);border:1px solid var(--line);border-radius:999px;padding:6px 10px}
.auth-footer a{color:inherit;text-decoration:none}

@media (min-height:860px){
  .auth-panel{justify-content:center}
}

@media (max-height:760px) and (min-width:921px){
  .auth-panel{padding:18px 28px;justify-content:flex-start}
  .auth-card{padding:21px;border-radius:26px;max-width:430px}
  .welcome-hero{margin-bottom:12px}
  .welcome-hero img{width:112px;max-width:42%}
  .welcome-hero h1{font-size:22px;margin-top:6px}
  .brand-row{margin-bottom:14px}
  .brand-mark{width:50px;height:50px;border-radius:18px}
  .brand-row h1{font-size:22px}
  .auth-copy h2{font-size:23px}
  .auth-copy p{margin-bottom:12px;font-size:13px;line-height:1.75}
  .auth-tabs{margin-bottom:12px}
  .field-shell{height:44px;border-radius:14px}
  .auth-submit{height:46px;border-radius:15px}
  .auth-form.register-grid{row-gap:8px}
}

@media (max-width:920px){
  .auth-page{grid-template-columns:1fr;min-height:100dvh}
  .auth-visual{display:none}
  .auth-panel{min-height:100dvh;max-height:none;padding:20px;justify-content:flex-start}
  .auth-card{max-width:520px;border-radius:26px;padding:24px;margin:0 auto}
  .auth-form.register-grid{grid-template-columns:1fr}
  .welcome-hero img{max-width:46%;width:132px}
  .auth-copy h2{font-size:24px}
}

@media (max-width:460px){
  .auth-panel{padding:14px}
  .auth-card{padding:20px;border-radius:24px}
  .welcome-hero img{width:118px;max-width:54%}
  .welcome-hero h1{font-size:22px}
  .brand-row{align-items:flex-start}
  .brand-mark{width:50px;height:50px;border-radius:18px}
  .brand-row h1{font-size:22px}
  .auth-copy h2{font-size:22px}
  .auth-tabs button{height:42px}
  .field-shell{height:46px}
}


/* v1.0.3 production login: mobile first PWA polish */
@media (max-width: 720px){
  html,body{min-height:100dvh;overflow-x:hidden;background:#0f1821;color:var(--text)}
  .auth-page{display:block;min-height:100dvh;background:
    radial-gradient(circle at 50% -8%,rgba(18,230,212,.18),transparent 14rem),
    linear-gradient(180deg,#0f1821 0%,#111d28 100%);direction:rtl}
  .auth-visual{display:none!important}
  .auth-panel{display:block;min-height:100dvh;max-height:none;padding:0;overflow:visible;background:transparent}
  .auth-card{width:100%;max-width:none;min-height:100dvh;margin:0;border:0;border-radius:0;box-shadow:none;background:transparent;padding:calc(env(safe-area-inset-top,0px) + 22px) 18px calc(env(safe-area-inset-bottom,0px) + 24px);display:flex;flex-direction:column;justify-content:flex-start}
  .welcome-hero{margin:0 auto 18px;width:100%;display:grid;justify-items:center;gap:8px}
  .welcome-hero img{width:104px;max-width:38vw;filter:drop-shadow(0 18px 32px rgba(18,230,212,.18))}
  .welcome-hero h1{font-size:24px;line-height:1.45;margin:0;text-align:center;letter-spacing:-.35px}
  .auth-tabs{position:relative;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:0 0 16px;padding:4px;border:1px solid rgba(255,255,255,.08);border-radius:20px;background:rgba(255,255,255,.035)}
  .auth-tabs button{height:48px;border-radius:16px;border:0;background:transparent;color:var(--muted);font-size:15px;font-weight:950}
  .auth-tabs button.active{background:linear-gradient(135deg,rgba(18,230,212,.20),rgba(51,144,236,.18));color:#5ab3ff;box-shadow:inset 0 0 0 1px rgba(18,230,212,.35)}
  .auth-form{gap:13px;width:100%}
  .auth-form.register-grid{grid-template-columns:1fr;gap:11px}
  .form-field{gap:7px}.auth-form label{font-size:12.5px;padding-inline:4px;color:#b9c7d4}
  .field-shell{height:54px;border-radius:18px;background:rgba(255,255,255,.055);border-color:rgba(255,255,255,.08);box-shadow:inset 0 1px 0 rgba(255,255,255,.04)}
  .field-shell:focus-within{border-color:rgba(18,230,212,.45);box-shadow:0 0 0 4px rgba(18,230,212,.10)}
  .field-shell input{font-size:16px;font-weight:850;color:#fff;padding-inline:16px}
  .field-shell span{color:#c8d3df;border-color:rgba(255,255,255,.08)}
  .auth-submit{height:58px;border-radius:18px;margin-top:8px;font-size:17px;box-shadow:0 14px 32px rgba(51,144,236,.25)}
  .auth-tools{justify-content:center;margin-top:12px}.auth-tools a,.auth-tools button{border-radius:999px;background:rgba(255,255,255,.05);border-color:rgba(255,255,255,.08)}
  .auth-message,.auth-error{border-radius:18px;margin-top:14px;text-align:center;font-weight:900}
}
@media (max-width: 380px){
  .auth-card{padding-inline:14px}.welcome-hero img{width:92px}.welcome-hero h1{font-size:22px}.auth-tabs button{height:45px}.field-shell{height:51px}.auth-submit{height:54px}
}
@media (min-width:721px){
  .auth-card{overflow:visible}.auth-panel{overflow:auto}.welcome-hero img{width:112px}.auth-form.register-grid{align-items:end}
}

/* E-chat v1.0.5 Mobile Icon Fixed auth polish */
.field-shell.with-action{padding-inline-end:8px}
.password-toggle{height:34px;border:0;border-radius:999px;background:rgba(51,144,236,.10);color:var(--blue);padding:0 11px;font-weight:900;font-size:12px;flex:0 0 auto}
.remember-row{display:flex;align-items:center;gap:9px;color:var(--muted);font-size:12.5px;font-weight:900;line-height:1.6;cursor:pointer;user-select:none;margin:1px 4px 0}
.remember-row input{width:18px;height:18px;accent-color:var(--blue)}
.register-stepper{display:none;grid-column:1/-1;grid-template-columns:repeat(3,1fr);gap:7px;margin-bottom:2px}
.register-stepper span{height:5px;border-radius:999px;background:rgba(127,151,174,.24);transition:.18s}
.register-stepper span.active{background:linear-gradient(135deg,var(--blue2),var(--blue))}
.signup-step{display:none}.signup-step.active{display:contents}.step-title{display:grid;grid-column:1/-1;gap:3px;padding:10px 12px;border:1px solid var(--line);background:rgba(127,151,174,.06);border-radius:16px}.step-title strong{font-size:14px}.step-title span{font-size:12px;color:var(--muted);line-height:1.7}.register-nav{display:grid;grid-column:1/-1;gap:8px;grid-template-columns:1fr 1fr}.auth-secondary{height:48px;border:1px solid var(--line);border-radius:16px;background:rgba(127,151,174,.08);color:var(--text);font:inherit;font-weight:950;cursor:pointer}.auth-secondary.primary-step{background:linear-gradient(135deg,rgba(18,230,212,.20),rgba(51,144,236,.16));border-color:rgba(18,230,212,.32);color:var(--blue)}
@media (max-width:720px){
  body{min-height:var(--auth-vh,100dvh);overscroll-behavior:none;touch-action:manipulation}
  .auth-page{min-height:var(--auth-vh,100dvh)}
  .auth-card{min-height:var(--auth-vh,100dvh)!important;justify-content:flex-start;gap:0;padding-top:calc(env(safe-area-inset-top,0px) + 18px)!important;padding-bottom:calc(env(safe-area-inset-bottom,0px) + 18px)!important}
  .welcome-hero{margin-bottom:16px!important}.welcome-hero img{width:92px!important;max-width:32vw!important}.welcome-hero h1{font-size:23px!important}
  .auth-tabs{margin-bottom:14px!important}.auth-tabs button{height:50px!important;font-size:16px!important}
  .auth-form{gap:12px}.field-shell{height:56px!important;border-radius:19px!important}.field-shell input{font-size:16px!important}.auth-submit{height:60px!important;border-radius:20px!important}.remember-row{margin-block:0 2px;color:#c2cfdb}.auth-message,.auth-error{font-size:13px;padding:12px 14px}
  #registerForm.mobile-step-form{display:grid;grid-template-columns:1fr;gap:12px;min-height:0}
  #registerForm.mobile-step-form[hidden]{display:none}
  .mobile-step-form .register-stepper{display:grid}
  .mobile-step-form .signup-step{display:none;grid-template-columns:1fr;gap:12px;animation:authStepIn .18s ease-out}
  .mobile-step-form .signup-step.active{display:grid}
  .mobile-step-form .step-title{display:grid;gap:3px;padding:12px 13px;border:1px solid rgba(255,255,255,.08);background:rgba(255,255,255,.045);border-radius:18px;margin-bottom:1px}.step-title strong{font-size:15px}.step-title span{font-size:12px;color:#aebdcb;line-height:1.7}
  .mobile-step-form .register-nav{display:grid}.mobile-step-form .register-nav button[hidden]{display:none}.mobile-step-form .register-nav:has(button[hidden]){grid-template-columns:1fr}
  .mobile-step-form #registerSubmit:not([hidden]){display:flex}.mobile-step-form #registerSubmit[hidden]{display:none!important}
}
@keyframes authStepIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
@media (display-mode:standalone) and (max-width:720px){.auth-card{padding-top:calc(env(safe-area-inset-top,0px) + 26px)!important}.auth-tools{display:none}}


/* v1.0.7 Clean Mobile Rebuild auth: fixed viewport, no overlap, faster taps */
@media (hover:none) and (pointer:coarse){
  .auth-tabs button,.auth-submit,.auth-secondary,.password-toggle,.field-shell{transition:none!important;animation:none!important;}
  .auth-submit:active,.auth-secondary:active,.auth-tabs button:active,.password-toggle:active{transform:none!important;}
  .auth-card,.field-shell,.auth-submit,.auth-tabs button.active{box-shadow:none!important;}
  .phone-preview,.auth-card,.toast{backdrop-filter:none!important;-webkit-backdrop-filter:none!important;}
  .welcome-hero img{filter:none!important;}
}
@media(max-width:720px){
  html,body{
    width:100%!important;
    min-height:var(--auth-vh,100svh)!important;
    height:var(--auth-vh,100svh)!important;
    max-height:var(--auth-vh,100svh)!important;
    overflow:hidden!important;
    position:fixed!important;
    inset:0!important;
    -webkit-text-size-adjust:100%;
    touch-action:manipulation;
  }
  .auth-page,.auth-panel{
    width:100vw!important;
    height:var(--auth-vh,100svh)!important;
    min-height:0!important;
    max-height:var(--auth-vh,100svh)!important;
    overflow:hidden!important;
  }
  .auth-card{
    height:var(--auth-vh,100svh)!important;
    min-height:0!important;
    max-height:var(--auth-vh,100svh)!important;
    overflow-y:auto!important;
    -webkit-overflow-scrolling:touch!important;
    padding:calc(env(safe-area-inset-top,0px) + 14px) 16px calc(env(safe-area-inset-bottom,0px) + 16px)!important;
    contain:layout paint!important;
  }
  .welcome-hero{margin-bottom:12px!important;gap:5px!important;}
  .welcome-hero img{width:84px!important;max-width:30vw!important;}
  .welcome-hero h1{font-size:21px!important;line-height:1.35!important;}
  .auth-tabs{margin-bottom:12px!important;border-radius:18px!important;}
  .auth-tabs button{height:46px!important;border-radius:14px!important;}
  .auth-form{gap:10px!important;}
  .form-field{gap:5px!important;}
  .auth-form label{font-size:12px!important;}
  .field-shell{height:50px!important;border-radius:16px!important;}
  .field-shell input{font-size:16px!important;font-weight:800!important;}
  .auth-submit{height:54px!important;border-radius:17px!important;margin-top:5px!important;}
  .remember-row{font-size:12px!important;margin:0 3px!important;}
  .register-stepper{gap:6px!important;margin-bottom:0!important;}
  .mobile-step-form .step-title{padding:10px 12px!important;border-radius:16px!important;}
  .register-nav{gap:7px!important;}
  .auth-secondary{height:46px!important;border-radius:15px!important;}
  .auth-message,.auth-error{margin-top:10px!important;padding:10px 12px!important;border-radius:16px!important;}
}
@supports (-webkit-touch-callout:none){
  @media(max-width:720px){
    body.auth-ios .auth-card{transform:translateZ(0);}
    body.auth-ios input,body.auth-ios textarea,body.auth-ios select{font-size:16px!important;}
  }
}
@media(max-height:640px) and (max-width:720px){
  .welcome-hero img{width:68px!important;}
  .welcome-hero h1{font-size:19px!important;}
  .auth-tabs button{height:42px!important;}
  .field-shell{height:46px!important;}
  .auth-submit{height:50px!important;}
}
.auth-link-button{align-self:flex-start;background:transparent;color:var(--auth-accent,#3390ec);font-weight:800;font-size:13px;padding:2px 0;border:0;cursor:pointer}.auth-link-button:hover{text-decoration:underline}
