/* auth.css: sign in, free trial, header account area, toasts and dialogs.
   All selectors are scoped to .au*, #acct/.au-acct, .bar, #toast and #modal. */

/* ---------- Header ---------- */
.bar .bar-in { gap: 12px; flex-wrap: nowrap; }
.bar .brand { min-width: 0; white-space: nowrap; gap: 9px; }
.bar .brand-mark { width: 28px; height: 28px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), 0 1px 2px rgba(10,80,176,.25); flex: none; }
.bar .brand-mark svg { width: 16px; height: 16px; }
.bar .demo-tag { margin-left: 2px; padding: 2px 8px; }
#acct.au-acct { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; min-width: 0; }
.au-acct .au-avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-fg); font-weight: 600; font-size: .86rem; }
.au-acct .who { min-width: 0; max-width: 260px; display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.au-acct .who b, .au-acct .who span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-acct .who b { font-size: .84rem; font-weight: 500; color: var(--fg); }
.au-acct .who span { font-size: .74rem; color: var(--muted); }
.au-acct .btn.sm { white-space: nowrap; flex: none; }
@media (max-width: 640px) {
  .au-acct .who { max-width: 130px; }
  .au-acct .who b { display: none; }
  .au-acct .who span { font-size: .78rem; color: var(--fg); }
}
@media (max-width: 400px) {
  .au-acct .au-avatar { display: none; }
  .au-acct .who { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .bar .brand { font-size: .98rem; }
}

/* ---------- Auth layout ---------- */
.au { max-width: 1040px; margin: clamp(8px, 4vw, 40px) auto 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: stretch; }
.au-card { background: var(--surface); border-radius: 24px; padding: clamp(24px, 4vw, 44px); box-shadow: 0 0 0 1px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.05), 0 24px 60px rgba(0,0,0,.06); min-width: 0; }
.au-card h1 { font-size: clamp(1.9rem, 3.4vw, 2.4rem); line-height: 1.1; letter-spacing: -.03em; margin-top: 22px; }
.au-sub { color: var(--muted); margin-top: 10px; font-size: 1rem; line-height: 1.5; max-width: 42ch; }

/* steps */
.au-steps { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 10px; font-size: .82rem; color: var(--muted); }
.au-steps li { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.au-sn { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .74rem; font-weight: 600; background: var(--surface-2); color: var(--muted); transition: background .3s, color .3s; }
.au-s1 { color: var(--fg); font-weight: 500; }
.au-s1 .au-sn { background: var(--accent); color: #fff; }
.au-sbar { flex: 1 1 auto; max-width: 64px; height: 2px; border-radius: 2px; background: var(--line); position: relative; overflow: hidden; }
.au-sbar::after { content: ""; position: absolute; inset: 0; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .5s cubic-bezier(.2,.7,.2,1); }
.au-card:has(.cf-code:not([hidden])) .au-sbar::after { transform: scaleX(1); }
.au-card:has(.cf-code:not([hidden])) .au-s1 { color: var(--muted); font-weight: 400; }
.au-card:has(.cf-code:not([hidden])) .au-s1 .au-sn { background: var(--accent-soft); color: var(--accent-fg); }
.au-card:has(.cf-code:not([hidden])) .au-s2 { color: var(--fg); font-weight: 500; }
.au-card:has(.cf-code:not([hidden])) .au-s2 .au-sn { background: var(--accent); color: #fff; }

/* form */
.au-form { display: grid; gap: 16px; margin-top: 28px; }
.au-form.au-grid { grid-template-columns: 1fr 1fr; gap: 16px 14px; }
.au-form .au-wide { grid-column: 1 / -1; }
.au-cf { display: grid; gap: 16px; }
.au-form label.f { color: var(--fg); font-size: .86rem; gap: 6px; }
.au-form label.f input, .au-form label.f select { font-size: 1rem; padding: 13px 14px; min-height: 48px; transition: background .2s, box-shadow .2s, border-color .2s; }
.au-form label.f input[readonly]:not(.au-codein) { color: var(--muted); background: var(--surface-2); box-shadow: none; border-color: transparent; }
.au-opt { color: var(--muted); font-weight: 400; }
.au-form .au-code { display: grid; gap: 10px; }
.au-form .au-code:not([hidden]) { animation: au-rise .35s cubic-bezier(.2,.7,.2,1); }
.au-form label.f .au-codein { font-size: 1.9rem; font-weight: 600; letter-spacing: .5em; text-indent: .5em; text-align: center; font-variant-numeric: tabular-nums; padding: 14px 10px; min-height: 64px; border-radius: 16px; background: var(--surface); border: 1.5px solid var(--line); }
.au-form label.f .au-codein::placeholder { color: #C7C7CC; letter-spacing: .5em; }
.au-form label.f .au-codein:focus { border-color: var(--accent); }
.au-form:has(.au-err:not(:empty)) .au-codein { border-color: var(--bad); }
.au-form:has(.au-err:not(:empty)) .au-codein:focus { box-shadow: 0 0 0 4px var(--bad-soft); }
.au-hint { margin: 0; line-height: 1.5; color: var(--muted); }
.au-hint:empty { display: none; }
.au-hint-t { display: block; font-weight: 600; color: var(--fg); margin-bottom: 2px; }
.au-hint .cf-resend { margin-left: 2px; }
.au-democode { display: inline-block; font-weight: 600; color: var(--accent-fg); background: var(--accent-soft); border-radius: 8px; padding: 1px 8px; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.au-err { margin: 0; color: var(--bad); font-weight: 500; display: flex; gap: 8px; align-items: flex-start; }
.au-err:empty { display: none; }
.au-err::before { content: ""; flex: none; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; background: var(--bad) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 4v5' stroke='%23fff' stroke-width='1.8' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11.6' r='1' fill='%23fff'/%3E%3C/svg%3E") center/16px no-repeat; }
.au-submit.btn { width: 100%; justify-content: center; min-height: 50px; font-size: 1.02rem; font-weight: 500; position: relative; transition: background .2s, transform .1s; }
.au-submit.btn:hover:not(:disabled) { background: #0858BD; filter: none; }
.au-submit.btn:active:not(:disabled) { transform: scale(.99); }
.au-submit.btn:disabled { opacity: .78; color: transparent; }
.au-submit.btn:disabled::after { content: ""; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; animation: au-spin .7s linear infinite; }

.au-switch { margin-top: 20px; text-align: center; font-size: .92rem; color: var(--muted); }
.au-switch .linkbtn { font-size: inherit; font-weight: 500; }
.au-switch .linkbtn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* demo accounts */
.au-demo { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.au-demo-k { font-size: .8rem; font-weight: 600; color: var(--fg); }
.au-demo-h .small { margin-top: 2px; }
.demo-accts.au-da { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.au-da button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); min-width: 0; transition: background .2s, box-shadow .2s; font: inherit; color: var(--fg); }
.au-da button:hover { background: var(--accent-soft); }
.au-da button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.au-da-ini { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--accent-fg); font-size: .76rem; font-weight: 600; box-shadow: 0 0 0 1px rgba(0,0,0,.05); }
.au-da-t { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.au-da-t b { font-size: .86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-da-t span { font-size: .76rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-da-go { flex: none; width: 16px; height: 16px; color: var(--muted); transition: transform .2s, color .2s; }
.au-da-go svg { width: 16px; height: 16px; display: block; }
.au-da button:hover .au-da-go { color: var(--accent-fg); transform: translateX(2px); }

/* brand panel */
.au-side { position: relative; overflow: hidden; justify-content: center; border-radius: 24px; padding: clamp(24px, 4vw, 44px); background: linear-gradient(170deg, #F4F8FE 0%, #EEF4FD 55%, #E6EFFC 100%); display: flex; flex-direction: column; min-width: 0; }
.au-side::before { content: ""; position: absolute; width: 420px; height: 420px; right: -160px; top: -180px; border-radius: 50%; background: radial-gradient(closest-side, rgba(10,102,216,.10), transparent); pointer-events: none; }
.au-art { width: 100%; max-width: 380px; height: auto; margin: 0 auto 28px; display: block; position: relative; }
.au-side-k { font-size: .82rem; font-weight: 600; color: var(--accent-fg); position: relative; }
.au-side-h { font-size: clamp(1.35rem, 2.2vw, 1.6rem); line-height: 1.2; letter-spacing: -.025em; margin-top: 8px; color: var(--fg); position: relative; max-width: 24ch; }
.au-pts { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 16px; position: relative; }
.au-pts li { display: flex; gap: 12px; align-items: flex-start; }
.au-tick { flex: none; width: 24px; height: 24px; border-radius: 50%; background: #fff; color: var(--accent); display: grid; place-items: center; box-shadow: 0 1px 2px rgba(10,102,216,.12), 0 0 0 1px rgba(10,102,216,.10); margin-top: 1px; }
.au-tick svg { width: 13px; height: 13px; }
.au-pts b { display: block; font-size: .95rem; font-weight: 600; color: var(--fg); }
.au-pts li > span:last-child > span { display: block; font-size: .9rem; color: var(--muted); margin-top: 1px; line-height: 1.45; }

/* self-drawing lines */
.au-draw { stroke-dasharray: 1; stroke-dashoffset: 0; }
@media (prefers-reduced-motion: no-preference) {
  .au-draw { stroke-dashoffset: 1; animation: au-draw 1.1s cubic-bezier(.45,.05,.25,1) forwards; animation-delay: calc(var(--d, 0s) + .15s); }
  .au-dlg-ico .au-draw { animation-duration: .5s; animation-delay: .15s; }
}
@keyframes au-draw { to { stroke-dashoffset: 0; } }
@keyframes au-spin { to { transform: rotate(360deg); } }
@keyframes au-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .au-form .au-code:not([hidden]), #modal:not([hidden]), #modal:not([hidden]) .dialog, #toast:not([hidden]) { animation: none !important; }
  .au-sbar::after, .au-sn { transition: none; }
}

/* mobile */
@media (max-width: 860px) {
  .au { grid-template-columns: minmax(0, 1fr); max-width: 520px; gap: 16px; }
  .au-side { padding: 24px; }
  .au-art { max-width: 300px; margin-bottom: 20px; }
}
@media (max-width: 480px) {
  .au { margin-top: 4px; }
  .au-card { padding: 24px 20px 26px; border-radius: 22px; }
  .au-card h1 { margin-top: 18px; }
  .au-form { margin-top: 22px; }
  .au-form.au-grid { grid-template-columns: minmax(0, 1fr); }
  .demo-accts.au-da { grid-template-columns: minmax(0, 1fr); }
  .au-form label.f .au-codein { font-size: 1.6rem; letter-spacing: .4em; text-indent: .4em; }
  .au-side { padding: 22px 20px; border-radius: 22px; }
  .au-art { max-width: 260px; }
}

/* ---------- Dialogs ---------- */
#modal.overlay { background: rgba(29,29,31,.38); -webkit-backdrop-filter: blur(6px) saturate(140%); backdrop-filter: blur(6px) saturate(140%); padding: 16px; }
#modal:not([hidden]) { animation: au-fade .2s ease; }
#modal .dialog { position: relative; border-radius: 22px; padding: clamp(22px, 4vw, 32px); box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.12), 0 40px 80px rgba(0,0,0,.12); width: min(560px, 100%); max-height: min(88vh, 900px); outline: none; }
#modal:not([hidden]) .dialog { animation: au-pop .28s cubic-bezier(.2,.8,.2,1); }
#modal .dialog > h2, #modal .dialog > p.eyebrow:first-of-type, #modal .au-confirm > h2 { padding-right: 36px; }
#modal .dialog h2 { font-size: 1.35rem; letter-spacing: -.02em; line-height: 1.25; }
.au-x { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: background .2s, color .2s; z-index: 1; }
.au-x:hover { background: color-mix(in srgb, var(--fg) 10%, transparent); color: var(--fg); }
.au-x svg { width: 16px; height: 16px; }
.au-dlg-ico { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 16px; }
.au-dlg-ico.good { background: var(--good-soft); color: var(--good); }
.au-dlg-ico svg { width: 22px; height: 22px; }
.au-dlg-p { margin-top: 8px; line-height: 1.5; overflow-wrap: anywhere; }
.au-msg-l { display: block; margin-top: 18px; font-size: .82rem; font-weight: 500; color: var(--muted); }
.au-msg { display: block; width: 100%; margin-top: 6px; padding: 14px 16px; border-radius: 14px; border: 0; background: var(--surface-2); color: var(--fg); font: inherit; font-size: .95rem; line-height: 1.5; resize: none; min-height: 112px; field-sizing: content; }
.au-msg:focus { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }
.au-dlg-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px; }
.au-dlg-actions .btn { justify-content: center; text-decoration: none; }
@media (max-width: 480px) {
  #modal.overlay { align-items: end; padding: 8px; }
  #modal .dialog { border-radius: 22px; max-height: 92vh; }
  #modal:not([hidden]) .dialog { animation-name: au-sheet; }
  .au-dlg-actions { flex-direction: column-reverse; }
  .au-dlg-actions .btn { width: 100%; }
}
@keyframes au-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes au-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes au-sheet { from { opacity: .6; transform: translateY(40px); } to { opacity: 1; transform: none; } }

/* ---------- Toast ---------- */
#toast.toast { display: flex; align-items: center; gap: 10px; background: rgba(29,29,31,.92); color: #fff; font-weight: 500; font-size: .92rem; line-height: 1.35; padding: 12px 18px 12px 14px; border-radius: 16px; box-shadow: 0 8px 24px rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.12); width: max-content; max-width: min(460px, calc(100% - 32px)); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 60; }
#toast.toast::before { content: ""; flex: none; width: 8px; height: 8px; margin: 0 2px 0 4px; border-radius: 50%; background: #4C9DFF; box-shadow: 0 0 0 4px rgba(76,157,255,.22); }
#toast:not([hidden]) { animation: au-toast .32s cubic-bezier(.2,.8,.2,1); }
@keyframes au-toast { from { opacity: 0; transform: translate(-50%, 12px) scale(.98); } to { opacity: 1; transform: translate(-50%, 0); } }
