:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --line: #e8e8ed;
  --field-line: #d2d2d7;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --link: #0066cc;
  --error: #b3261e;
  --error-bg: #fdf3f2;
  --error-line: #f2c9c5;
  --ok-bg: #f2f7fd;
  --ok-line: #c9dcf3;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
}

.page {
  container-type: inline-size;
  container-name: page;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 3px solid rgba(0, 113, 227, 0.5); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.topbar-inner {
  max-width: 1024px; margin: 0 auto; height: 48px; padding: 0 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  color: var(--text); font-weight: 600; font-size: 17px;
  letter-spacing: -0.02em; min-height: 44px; display: inline-flex; align-items: center;
}
.brand:hover { text-decoration: none; }
.topbar-right { display: flex; align-items: center; gap: 20px; min-width: 0; }
.lang-switch {
  color: var(--text-2); font-size: 12px; min-height: 44px; display: inline-flex; align-items: center;
}
.lang-switch:hover { color: var(--text); text-decoration: none; }
.account { display: flex; align-items: center; gap: 14px; font-size: 12px; min-width: 0; }
.account a, .account .linkbutton { font-size: 12px; min-height: 44px; display: inline-flex; align-items: center; }
.account-name { color: var(--text); font-weight: 500; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-loading { width: 64px; height: 12px; border-radius: 6px; background: var(--surface); }

.linkbutton {
  appearance: none; background: none; border: 0; padding: 0; margin: 0;
  color: var(--link); font: inherit; cursor: pointer;
}
.linkbutton:hover { text-decoration: underline; }

/* Main */
main { flex: 1; padding: 88px 22px 96px; }
.auth { max-width: 440px; margin: 0 auto; }
.auth-head { text-align: center; margin-bottom: 40px; }
h1 {
  margin: 0; font-weight: 600; letter-spacing: -0.035em; line-height: 1.05;
  font-size: clamp(44px, 5vw, 64px);
}
.subtitle {
  margin: 14px 0 0; font-weight: 500; color: var(--text-2);
  font-size: clamp(19px, 2vw, 24px); line-height: 1.25; letter-spacing: -0.01em;
}

/* Segmented control */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px;
  background: var(--surface); border-radius: 980px; margin: 0 0 28px;
}
.segmented button {
  appearance: none; border: 0; background: transparent; border-radius: 980px;
  min-height: 44px; font: inherit; font-size: 15px; font-weight: 500; color: var(--text-2);
  cursor: pointer;
}
.segmented button[aria-selected="true"] {
  background: #fff; color: var(--text); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* Form */
form { display: grid; gap: 16px; }
.field { display: grid; gap: 8px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
label { font-size: 15px; font-weight: 500; }
.field-head a { font-size: 15px; min-height: 44px; display: inline-flex; align-items: center; margin: -12px 0; }
input[type="email"], input[type="password"], input[type="text"] {
  width: 100%; min-height: 52px; padding: 0 16px;
  border: 1px solid var(--field-line); border-radius: 12px; background: #fff;
  font: inherit; font-size: 17px; color: var(--text);
}
input::placeholder { color: #86868b; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.2); }
input[aria-invalid="true"] { border-color: var(--error); }
input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.15); }
.hint { margin: 0; font-size: 13px; color: var(--text-2); }
.field-error { margin: 0; font-size: 13px; color: var(--error); }

.alert {
  border-radius: 18px; padding: 14px 18px; font-size: 15px; line-height: 1.4;
  border: 1px solid var(--error-line); background: var(--error-bg); color: var(--error);
}
.alert.ok { border-color: var(--ok-line); background: var(--ok-bg); color: var(--text); }
.alert strong { display: block; font-weight: 600; margin-bottom: 2px; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 28px; border-radius: 980px;
  background: var(--accent); color: #fff; font: inherit; font-size: 17px; font-weight: 500;
  width: 100%; text-decoration: none;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn.secondary {
  background: #fff; color: var(--text); box-shadow: inset 0 0 0 1px var(--field-line);
}
.btn.secondary:hover { background: var(--surface); }
.btn svg { width: 18px; height: 18px; flex: none; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45); border-top-color: #fff;
}
.btn.secondary .spinner { border-color: rgba(0, 0, 0, 0.15); border-top-color: var(--text); }
@media (prefers-reduced-motion: no-preference) {
  .spinner { animation: spin 0.8s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
}

.divider {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px;
  color: var(--text-2); font-size: 13px; margin: 12px 0;
}
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); }
.providers { display: grid; gap: 12px; }

.switch { text-align: center; margin: 32px 0 0; color: var(--text-2); font-size: 15px; }
.switch a { display: inline-flex; min-height: 44px; align-items: center; }

/* Account card */
.card {
  background: var(--surface); border-radius: 28px; padding: 32px; text-align: center;
}
.card dl { margin: 0 0 24px; display: grid; gap: 4px; }
.card dt { font-size: 13px; color: var(--text-2); }
.card dd { margin: 0 0 12px; font-size: 17px; font-weight: 500; word-break: break-word; }

.footer { background: var(--surface); font-size: 12px; color: var(--text-2); }
.footer-inner {
  max-width: 1024px; margin: 0 auto; padding: 16px 22px;
  display: flex; gap: 20px; flex-wrap: wrap; align-items: center;
}
.footer a { color: var(--text-2); min-height: 44px; display: inline-flex; align-items: center; }
.footer .copy { margin-right: auto; }

@container page (max-width: 760px) {
  .topbar-right { gap: 16px; }
  .account { gap: 12px; }
  .account-name { max-width: 10ch; }
  main { padding: 56px 22px 72px; }
  .auth-head { margin-bottom: 32px; }
  .card { padding: 28px 22px; }
}

.lead { margin: 0 0 4px; font-size: 15px; color: var(--text-2); }
.noscript { margin: 16px 22px; }
