:root{
  --brand:#4B1D2C; --brand-2:#6E2B40; --brand-dark:#3A1622; --accent:#F2871E;
  --bg:#F5F2F3; --card:#fff; --text:#1F1A1C; --muted:#6B6366;
  --border:#E4DDDF; --input:#FAF8F9;
  --danger:#B42318; --danger-bg:#FEF3F2; --danger-border:#FECDCA;
  --ok:#067647; --ok-bg:#ECFDF3; --ok-border:#ABEFC6;
}
*{box-sizing:border-box;margin:0}
html,body{width:100%;max-width:100%;overflow-x:hidden;-webkit-text-size-adjust:100%;text-size-adjust:100%}
html{touch-action:manipulation;overscroll-behavior:none}
body{
  font-family:'Poppins',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
  background:var(--bg);color:var(--text);-webkit-font-smoothing:antialiased;
  min-height:100vh;min-height:100dvh;display:flex;align-items:center;justify-content:center;
  padding:24px 16px;
}

/* ---------- Layout ---------- */
.shell{
  width:100%;max-width:940px;display:grid;grid-template-columns:1fr;
  background:var(--card);border:1px solid var(--border);border-radius:20px;overflow:hidden;
  box-shadow:0 1px 2px rgba(16,24,40,.04),0 16px 48px rgba(75,29,44,.10);
}
@media (min-width:860px){ .shell{grid-template-columns:1.05fr 1fr;min-height:560px} }

/* ---------- Brand panel ---------- */
.brand{
  position:relative;overflow:hidden;color:#fff;padding:24px;
  background:linear-gradient(150deg,var(--brand) 0%,var(--brand-2) 100%);
  display:flex;flex-direction:column;gap:14px;
}
.brand::after{
  content:'';position:absolute;right:-90px;bottom:-90px;width:260px;height:260px;border-radius:50%;
  background:radial-gradient(circle,rgba(242,135,30,.35),transparent 70%);pointer-events:none;
}
.brand-top{display:flex;align-items:center;gap:12px;position:relative;z-index:1}
.logo-tile{width:48px;height:48px;border-radius:12px;background:#fff;display:grid;place-items:center;flex:none}
.logo-tile img{width:36px;height:36px;object-fit:contain}
.brand-name{font-weight:600;font-size:1.05rem;letter-spacing:.2px}
.brand-sub{font-size:.76rem;opacity:.75}
.brand-copy,.brand-foot{display:none;position:relative;z-index:1}
@media (min-width:860px){
  .brand{padding:40px;justify-content:space-between}
  .brand-copy,.brand-foot{display:block}
  .accent-bar{width:44px;height:4px;border-radius:4px;background:var(--accent);margin-bottom:18px}
  .brand-copy h2{font-size:1.85rem;line-height:1.25;font-weight:600}
  .brand-copy p{margin-top:12px;opacity:.8;font-size:.9rem;line-height:1.65;max-width:34ch}
  .brand-foot{font-size:.74rem;opacity:.6}
}

/* ---------- Form panel ---------- */
.form-side{padding:28px 24px 24px}
@media (min-width:860px){ .form-side{padding:48px 44px;display:flex;flex-direction:column;justify-content:center} }
h1{font-size:1.5rem;font-weight:600;letter-spacing:-.2px}
.lead{color:var(--muted);font-size:.88rem;margin-top:4px}

/* ---------- Mobile: full-screen app layout ---------- */
.m-tagline{display:none}
@media (max-width:859px){
  html{background:#fff}
  body{padding:0;display:block;background:linear-gradient(var(--brand) 0 50%,#fff 50% 100%)}
  .shell{
    width:100%;max-width:100%;min-width:0;min-height:100vh;min-height:100dvh;display:flex;flex-direction:column;
    border:0;border-radius:0;box-shadow:none;background:transparent;overflow:visible;
  }
  .brand{
    align-items:center;text-align:center;gap:0;
    padding:calc(max(env(safe-area-inset-top),20px) + 28px) 24px 64px;
  }
  .brand::after{right:-80px;top:-80px;bottom:auto;width:240px;height:240px}
  .brand::before{
    content:'';position:absolute;left:-70px;bottom:-40px;width:180px;height:180px;border-radius:50%;
    background:radial-gradient(circle,rgba(255,255,255,.10),transparent 70%);pointer-events:none;
  }
  .brand-top{flex-direction:column;gap:14px}
  .logo-tile{width:76px;height:76px;border-radius:22px;box-shadow:0 10px 28px rgba(0,0,0,.22)}
  .logo-tile img{width:54px;height:54px}
  .brand-name{font-size:1.35rem}
  .brand-sub{font-size:.8rem;margin-top:2px}
  .m-tagline{
    display:inline-flex;align-items:center;gap:8px;margin-top:16px;position:relative;z-index:1;
    font-size:.74rem;padding:6px 12px;border-radius:999px;
    background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.18);
  }
  .m-tagline i{width:6px;height:6px;border-radius:50%;background:var(--accent)}

  .form-side{
    flex:1;min-width:0;width:100%;position:relative;z-index:2;margin-top:-30px;background:var(--card);
    border-radius:28px 28px 0 0;box-shadow:0 -10px 30px rgba(0,0,0,.10);
    padding:14px 22px calc(22px + env(safe-area-inset-bottom));
    display:flex;flex-direction:column;
  }
  .form-side::before{
    content:'';display:block;width:40px;height:4px;border-radius:4px;background:#E4DDDF;margin:0 auto 22px;
  }
  h1{font-size:1.4rem}
  .control input{height:52px}
  .btn{height:52px;margin-top:8px;font-size:1rem}
  .links{margin-top:2px}
  .help{margin-top:auto;padding-top:16px}
  form{margin-bottom:22px}
}
@media (max-width:359px){
  .links{flex-direction:column;align-items:center;gap:10px}
}

.alert{
  display:flex;gap:10px;align-items:flex-start;margin-top:20px;padding:11px 14px;
  border-radius:12px;font-size:.85rem;line-height:1.45;border:1px solid;
}
.alert svg{width:18px;height:18px;flex:none;margin-top:1px}
.alert.err{background:var(--danger-bg);color:var(--danger);border-color:var(--danger-border)}
.alert.ok{background:var(--ok-bg);color:var(--ok);border-color:var(--ok-border)}

form{margin-top:22px;display:grid;gap:16px}
.field label{display:block;font-size:.82rem;font-weight:500;margin-bottom:6px;color:#3A3335}
.control{position:relative;display:flex;align-items:center}
.control > .ico{position:absolute;left:14px;width:18px;height:18px;color:#9A9194;pointer-events:none}
.control input{
  width:100%;height:48px;padding:0 46px 0 42px;border:1px solid var(--border);border-radius:12px;
  background:var(--input);font:inherit;font-size:16px;color:var(--text); /* 16px stops iOS zoom */
  transition:border-color .15s,box-shadow .15s,background .15s;
}
.control input:focus{outline:none;background:#fff;border-color:var(--brand-2);box-shadow:0 0 0 4px rgba(110,43,64,.12)}
.toggle{
  position:absolute;right:6px;width:36px;height:36px;border:0;border-radius:8px;
  background:transparent;color:#8A8184;cursor:pointer;display:grid;place-items:center;
}
.toggle:hover{background:#F1ECEE;color:var(--brand)}
.toggle:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
.toggle svg{width:18px;height:18px}
.toggle .eye-off,.toggle.on .eye{display:none}
.toggle.on .eye-off{display:block}
.caps{display:none;margin-top:6px;font-size:.76rem;color:#B54708}
.caps.show{display:block}

.btn{
  height:48px;margin-top:4px;border:0;border-radius:12px;background:var(--brand);color:#fff;
  font:inherit;font-weight:600;font-size:.95rem;cursor:pointer;
  display:flex;align-items:center;justify-content:center;gap:10px;
  transition:background .15s,transform .05s;
}
.btn:hover{background:var(--brand-dark)}
.btn:active{transform:translateY(1px)}
.btn:focus-visible{outline:3px solid rgba(242,135,30,.6);outline-offset:2px}
.btn[disabled]{opacity:.85;cursor:progress}
.spinner{
  width:18px;height:18px;border:2px solid rgba(255,255,255,.35);border-top-color:#fff;
  border-radius:50%;animation:spin .7s linear infinite;display:none;
}
.btn.loading .spinner{display:block}
@keyframes spin{to{transform:rotate(360deg)}}

.links{display:flex;justify-content:space-between;gap:12px;font-size:.84rem}
.links a{color:var(--brand-2);text-decoration:none;font-weight:500}
.links a:hover{text-decoration:underline}

/* ---------- Help ---------- */
.help{margin-top:22px;border-top:1px solid var(--border);padding-top:14px}
.help summary{
  list-style:none;cursor:pointer;font-size:.84rem;color:var(--muted);
  display:flex;align-items:center;gap:8px;padding:4px 0;
}
.help summary::-webkit-details-marker{display:none}
.help summary svg{width:16px;height:16px}
.help summary .chev{margin-left:auto;transition:transform .2s}
.help[open] summary .chev{transform:rotate(180deg)}
.help ul{list-style:none;padding:0;margin-top:10px;display:grid;gap:4px}
.help a{
  display:block;padding:9px 12px;border-radius:10px;font-size:.84rem;
  color:var(--text);text-decoration:none;background:var(--input);
}
.help a:hover{background:#F1ECEE;color:var(--brand)}
.foot-mobile{text-align:center;font-size:.72rem;color:var(--muted);margin-top:18px}
@media (min-width:860px){ .foot-mobile{display:none} }

/* ---------- Splash (installed app only) ---------- */
#splash{position:fixed;inset:0;background:#fff;display:none;place-items:center;z-index:99;transition:opacity .4s}
html.splash #splash{display:grid}
#splash img{width:96px;height:96px;border-radius:22%;animation:pop .6s ease-out}
#splash.hide{opacity:0}
@keyframes pop{from{transform:scale(.9);opacity:.4}to{transform:scale(1);opacity:1}}

@media (prefers-reduced-motion:reduce){ *{animation:none!important;transition:none!important} }

/* ---------- Shared bits for other auth pages ---------- */
.back{
  display:inline-flex;align-items:center;gap:6px;font-size:.84rem;font-weight:500;
  color:var(--muted);text-decoration:none;margin-bottom:18px;
}
.back svg{width:16px;height:16px}
.back:hover{color:var(--brand)}
.hint{font-size:.76rem;color:var(--muted);margin-top:6px}
.center-link{text-align:center;font-size:.86rem}
.center-link a{color:var(--brand-2);text-decoration:none;font-weight:500}
.center-link a:hover{text-decoration:underline}

/* Password strength + rules */
.meter{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;margin-top:8px}
.meter span{height:4px;border-radius:4px;background:#ECE6E8;transition:background .2s}
.meter[data-s="1"] span:nth-child(-n+1){background:#D92D20}
.meter[data-s="2"] span:nth-child(-n+2){background:#F2871E}
.meter[data-s="3"] span:nth-child(-n+3){background:#7A9A2E}
.meter[data-s="4"] span{background:#067647}
.rules{list-style:none;padding:0;margin-top:8px;display:grid;gap:3px;font-size:.76rem;color:var(--muted)}
.rules li{display:flex;align-items:center;gap:6px}
.rules li::before{content:'';width:6px;height:6px;border-radius:50%;background:#CFC6C9;flex:none}
.rules li.ok{color:var(--ok)}
.rules li.ok::before{background:var(--ok)}
.match{font-size:.76rem;margin-top:6px;min-height:1em}
.match.ok{color:var(--ok)}
.match.bad{color:var(--danger)}

/* Success state */
.done{text-align:center;padding:12px 0 4px}
.done .tick{
  width:64px;height:64px;border-radius:50%;margin:0 auto 16px;display:grid;place-items:center;
  background:var(--ok-bg);color:var(--ok);border:1px solid var(--ok-border);
}
.done .tick svg{width:30px;height:30px}
.done h1{margin-bottom:6px}
.done .btn{margin-top:22px;text-decoration:none}
