
.auth-root { position: fixed; inset: 0; z-index: 110; }
.auth-root[hidden] { display: none; }

.auth-scrim {
  position: absolute; inset: 0;
  background: rgba(44, 44, 42, .48);
  animation: auth-fade var(--t-panel);
}
[data-theme="dark"] .auth-scrim { background: rgba(0, 0, 0, .62); }

.auth-dialog {
  position: relative;
  width: 100%; max-width: 400px;
  max-height: 100%;
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-drawer);
  display: flex; flex-direction: column;
  animation: auth-rise var(--t-panel);
  overflow: hidden;
}

@keyframes auth-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes auth-rise { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

.auth-root {
  display: grid; place-items: center;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.auth-head { flex: none; position: relative; border-bottom: 1px solid var(--border); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; }
.auth-tab {
  appearance: none; background: none; border: 0; cursor: pointer;
  height: 52px; font-family: var(--font-sans); font-size: 15px; font-weight: 500;
  color: var(--ink-3); position: relative;
  transition: color var(--t-micro);
}
.auth-tab:hover { color: var(--ink-2); }
.auth-tab[aria-selected="true"] { color: var(--brand-600); }
.auth-tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 24px; right: 24px; bottom: -1px;
  height: 2px; background: var(--brand-600); border-radius: 2px;
}
.auth-tab:focus-visible { outline: 2px solid var(--brand-600); outline-offset: -2px; border-radius: var(--r-sm); }

.auth-close {
  position: absolute; right: 8px; top: 8px;
  width: 36px; height: 36px; border-radius: var(--r-pill);
  background: none; border: 0; cursor: pointer; color: var(--ink-3);
  display: grid; place-items: center;
}
.auth-close:hover { background: var(--surface-2); color: var(--ink); }
.auth-close:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 1px; }
.auth-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.auth-reason {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0; padding: 11px 24px;
  font-size: 12.5px; line-height: 1.5;
  color: var(--brand-800);
  background: var(--brand-tint);
  border-bottom: 1px solid var(--border);
}
.auth-reason[hidden] { display: none; }
.auth-reason::before {
  content: ""; flex: 0 0 14px; height: 14px; margin-top: 2px;
  background: currentColor;
  -webkit-mask: no-repeat center/14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E");
  mask: no-repeat center/14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E");
}

.auth-body { flex: 1; overflow-y: auto; padding: 22px 24px 20px; overscroll-behavior: contain; }
.auth-pane[hidden] { display: none; }
.auth-title { margin: 0 0 4px; font-size: 19px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.auth-sub { margin: 0 0 20px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.auth-sub a { color: var(--brand-600); text-decoration: underline; text-underline-offset: 2px; }

.auth-steps { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; }
.auth-step { display: flex; align-items: center; gap: 7px; flex: 0 1 auto; min-width: 0; }
.auth-step-dot {
  flex: 0 0 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; font-family: var(--font-sans);
  background: var(--surface-2); color: var(--ink-3);
  border: 1px solid var(--border);
  transition: background var(--t-micro), color var(--t-micro), border-color var(--t-micro);
}
.auth-step.is-on .auth-step-dot { background: var(--brand-solid); color: #fff; border-color: var(--brand-solid); }
.auth-step.is-done .auth-step-dot { background: var(--brand-tint); color: var(--brand-600); border-color: var(--brand-600); }
.auth-step-label { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.auth-step.is-on .auth-step-label { color: var(--ink); font-weight: 500; }
.auth-step-line { flex: 1 1 12px; min-width: 8px; height: 1px; background: var(--border-strong); }
.auth-step.is-done + .auth-step-line { background: var(--brand-600); }

.auth-field { margin-bottom: 16px; }
.auth-field:last-child { margin-bottom: 0; }
.auth-label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 500; color: var(--ink);
}
.auth-input-wrap { position: relative; display: flex; align-items: center; }
.auth-input {
  width: 100%; height: 44px; padding: 0 12px;
  font-family: var(--font-sans); font-size: 15px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  transition: border-color var(--t-micro), box-shadow var(--t-micro);
}
.auth-input::placeholder { color: var(--ink-3); }
.auth-input:hover { border-color: var(--ink-3); }
.auth-input:focus { outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-tint); }
.auth-input[aria-invalid="true"] { border-color: var(--down); }
.auth-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--down-tint); }
.auth-input.has-btn { padding-right: 44px; }

.auth-eye {
  position: absolute; right: 4px;
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: none; border: 0; cursor: pointer; color: var(--ink-3);
  display: grid; place-items: center;
}
.auth-eye:hover { color: var(--ink-2); }
.auth-eye:focus-visible { outline: 2px solid var(--brand-600); outline-offset: -2px; }
.auth-eye svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.auth-hint { margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: var(--ink-3); }

.auth-btn-inline {
  position: absolute; right: 5px;
  height: 34px; padding: 0 12px;
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 500;
  color: var(--brand-600); background: var(--brand-tint);
  border: 1px solid transparent; border-radius: var(--r-sm);
  cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--t-micro), color var(--t-micro);
}
.auth-btn-inline:hover:not([disabled]) { background: var(--brand-solid); color: #fff; }
.auth-btn-inline:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 1px; }
.auth-btn-inline[disabled] { color: var(--ink-3); background: var(--surface-2); cursor: default; }
.auth-btn-inline[data-busy="1"] { pointer-events: none; opacity: .7; }
.auth-err {
  margin: 6px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--down);
  display: none; align-items: flex-start; gap: 5px;
}
.auth-err.is-on { display: flex; }
.auth-err::before {
  content: ""; flex: 0 0 13px; height: 13px; margin-top: 2px; border-radius: 50%;
  background: var(--down);
  -webkit-mask: no-repeat center/13px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 7v6M12 17h.01'/%3E%3C/svg%3E");
  mask: no-repeat center/13px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 7v6M12 17h.01'/%3E%3C/svg%3E");
}

.auth-code-row { display: flex; gap: 8px; }
.auth-code-cell {
  flex: 1; height: 52px; min-width: 0;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 20px; font-weight: 500; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  transition: border-color var(--t-micro), box-shadow var(--t-micro);
}
.auth-code-cell.is-filled { border-color: var(--brand-600); }
.auth-code-cell.is-active { border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-tint); }
.auth-code-input {
  position: absolute; opacity: 0; pointer-events: none;
  width: 1px; height: 1px;
}
.auth-code-row:focus-within .auth-code-cell.is-caret { border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-tint); }
.auth-code-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 10px; font-size: 12.5px;
}
.auth-code-meta a, .auth-code-meta button {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--font-sans); font-size: 12.5px; color: var(--brand-600);
}
.auth-code-meta a:hover, .auth-code-meta button:hover:not([disabled]) { color: var(--brand-800); text-decoration: underline; }
.auth-code-meta button[disabled] { color: var(--ink-3); cursor: default; }
.auth-code-sent { color: var(--ink-3); }
.auth-code-sent b { color: var(--ink); font-weight: 500; }

.auth-pw-meter { display: flex; gap: 4px; margin-top: 8px; }
.auth-pw-seg { flex: 1; height: 3px; border-radius: 2px; background: var(--border); transition: background var(--t-micro); }
.auth-pw-seg.on-weak { background: var(--down); }
.auth-pw-seg.on-mid { background: var(--accent); }
.auth-pw-seg.on-strong { background: var(--up); }
.auth-pw-note { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); }

.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -2px 0 18px; }
.auth-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.auth-check input { width: 16px; height: 16px; accent-color: var(--brand-600); cursor: pointer; margin: 0; }
.auth-check input:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }
.auth-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--font-sans); font-size: 13px; color: var(--brand-600);
}
.auth-link:hover { color: var(--brand-800); text-decoration: underline; }
.auth-link:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; border-radius: 3px; }

.auth-submit {
  width: 100%; height: 46px; margin-top: 4px;
  font-family: var(--font-sans); font-size: 15px; font-weight: 500;
  color: #fff; background: var(--brand-solid);
  border: 1px solid var(--brand-solid); border-radius: var(--r-md);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background var(--t-micro), border-color var(--t-micro);
}
.auth-submit:hover:not([data-busy="1"]) { background: var(--brand-hover); border-color: var(--brand-hover); }
.auth-submit:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }
.auth-submit[data-busy="1"] { pointer-events: none; opacity: .75; }
.auth-spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff;
  animation: auth-spin .7s linear infinite;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

.auth-alt {
  margin: 18px 0 0; padding-top: 16px; text-align: center;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--ink-2);
}
.auth-alt button {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500; color: var(--brand-600);
}
.auth-alt button:hover { color: var(--brand-800); text-decoration: underline; }

.auth-legal { margin: 14px 0 0; font-size: 11.5px; line-height: 1.65; color: var(--ink-3); text-align: center; }
.auth-legal a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }

@media (max-width: 560px) {
  .auth-root { padding: 0; place-items: end stretch; }
  .auth-dialog {
    width: 100%; max-width: 100%;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    max-height: 94vh; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: auth-sheet var(--t-panel);
  }
  @keyframes auth-sheet { from { transform: translateY(100%); } to { transform: none; } }
  .auth-body { padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
  .auth-step-label { display: none; }
  .auth-step-line { flex: 1; }
  .auth-code-cell { height: 56px; font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-scrim, .auth-dialog, .auth-spinner { animation: none; }
  .auth-input, .auth-code-cell, .auth-step-dot, .auth-pw-seg { transition: none; }
}
