:root {
  color-scheme: light dark;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-pressed: #0068d1;
  --page: #ffffff;
  --footer: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --line: #86868b;
  --line-soft: #d2d2d7;
  --focus: rgba(0, 113, 227, .24);
  --error: #e30000;
  --success: #248a3d;
  --header-height: 52px;
  --footer-height: 82px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--page); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.page-shell {
  min-height: 100svh;
  display: grid;
  grid-template-rows: var(--header-height) 1fr auto;
  background: var(--page);
}

.site-header {
  position: relative;
  z-index: 10;
  height: var(--header-height);
  background: rgba(255,255,255,.9);
  border-bottom: 1px solid rgba(0,0,0,.08);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
}

.nav-inner {
  width: min(980px, 100%);
  height: 100%;
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  outline: 0;
}
.brand-mark { width: 24px; height: 24px; display: block; }
.brand-name { font-size: 18px; line-height: 1; font-weight: 600; letter-spacing: -.022em; }

.account-nav { display: flex; align-items: center; gap: 23px; }
.nav-link, .nav-create {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.nav-link { color: var(--text); }
.nav-link.is-current { cursor: default; opacity: .72; }
.nav-create {
  min-width: 80px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
}
.nav-create:hover { background: var(--accent-hover); }
.nav-create:active { transform: scale(.97); background: var(--accent-pressed); }

.brand:focus-visible, .nav-link:focus-visible, .nav-create:focus-visible,
.secondary-actions button:focus-visible, .create-account button:focus-visible,
.footer-links button:focus-visible, .account-chip:focus-visible,
.mascot-button:focus-visible, .remember-row input:focus-visible + .checkmark {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus);
}

.main-content {
  min-height: calc(100svh - var(--header-height) - var(--footer-height));
  display: grid;
  place-items: start center;
  padding: clamp(72px, 10vh, 112px) 24px 96px;
}

.auth-panel { width: min(480px, 100%); text-align: center; }

.mascot-button {
  width: 78px;
  height: 78px;
  margin: 0 auto 24px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  outline: 0;
  animation: mascot-enter .55s cubic-bezier(.2,.8,.2,1) both;
}
.kron-head { width: 80px; height: 80px; display: block; overflow: visible; }
.kron-head .quill { will-change: transform; }
.mascot-button:active { transform: scale(.96); }

.heading-group { margin-bottom: 36px; }
.heading-group h1 {
  margin: 0;
  font-size: clamp(30px, 4.5vw, 40px);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -.038em;
}
.heading-group p {
  margin: 12px 0 0;
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.45;
  letter-spacing: -.01em;
}

.auth-form, .stage { width: 100%; }
.stage[hidden] { display: none; }

.field-wrap {
  position: relative;
  width: 100%;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.field-wrap:hover { border-color: #6e6e73; }
.field-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus); }
.field-wrap.has-error { border-color: var(--error); box-shadow: 0 0 0 4px rgba(227,0,0,.12); }
.field-wrap.is-success { border-color: var(--success); }

.field-wrap label {
  position: absolute;
  z-index: 1;
  left: 17px;
  top: 50%;
  max-width: calc(100% - 86px);
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1;
  transform: translateY(-50%);
  transform-origin: left top;
  pointer-events: none;
  transition: top .14s ease, transform .14s ease, font-size .14s ease, color .14s ease;
}
.field-wrap:focus-within label, .field-wrap.has-value label {
  top: 10px;
  transform: none;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .01em;
}
.field-wrap input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 20px 62px 4px 17px;
  border: 0;
  border-radius: inherit;
  outline: 0;
  background: transparent;
  color: var(--text);
  caret-color: var(--accent);
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -.01em;
}
.field-wrap input:-webkit-autofill,
.field-wrap input:-webkit-autofill:hover,
.field-wrap input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  transition: background-color 9999s ease-out;
}

.continue-button {
  position: absolute;
  z-index: 2;
  right: 8px;
  top: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  transform: translateY(-50%);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform .1s ease, background-color .12s ease, opacity .12s ease;
}
.continue-button:disabled {
  background: transparent;
  color: #a1a1a6;
  cursor: default;
  box-shadow: inset 0 0 0 1px #a1a1a6;
}
.continue-button:not(:disabled):hover { background: var(--accent-hover); }
.continue-button:not(:disabled):active { transform: translateY(-50%) scale(.92); background: var(--accent-pressed); }
.continue-button:focus-visible { outline: 0; box-shadow: 0 0 0 4px var(--focus); }
.continue-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.spinner { width: 17px; height: 17px; display: none; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.continue-button.is-loading svg { display: none; }
.continue-button.is-loading .spinner { display: block; }

.password-stage { animation: stage-in .28s cubic-bezier(.2,.8,.2,1) both; }
.account-chip {
  max-width: 100%;
  min-height: 32px;
  margin: 0 auto 12px;
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  outline: 0;
  font-size: 13px;
}
.account-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chip svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.remember-row {
  width: fit-content;
  min-height: 44px;
  margin: 13px auto 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}
.remember-row input { position: absolute; opacity: 0; pointer-events: none; }
.checkmark {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid #86868b;
  border-radius: 4px;
  background: #fff;
  transition: background-color .12s ease, border-color .12s ease, transform .1s ease;
}
.checkmark svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.remember-row input:checked + .checkmark { border-color: var(--accent); background: var(--accent); }
.remember-row input:checked + .checkmark svg { opacity: 1; }
.remember-row:active .checkmark { transform: scale(.92); }

.form-message {
  min-height: 18px;
  margin: 1px 8px 0;
  color: var(--error);
  text-align: center;
  font-size: 12px;
  line-height: 1.35;
}
.form-message.success { color: var(--success); }

.secondary-actions {
  margin-top: 19px;
  display: grid;
  justify-items: center;
  gap: 10px;
}
.secondary-actions button, .create-account button, .footer-links button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}
.primary-link {
  min-height: 38px;
  padding: 4px 7px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border-radius: 8px !important;
  font-size: 15px;
}
.primary-link svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.quiet-link { min-height: 32px; padding: 3px 6px; border-radius: 7px !important; font-size: 13px; }

.create-account {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-secondary);
  font-size: 14px;
}
.create-account button { min-height: 32px; padding: 3px 4px; border-radius: 7px; font-size: 14px; }

.site-footer {
  min-height: var(--footer-height);
  background: var(--footer);
  color: var(--text-secondary);
  font-size: 11px;
}
.footer-inner {
  width: min(980px, 100%);
  min-height: var(--footer-height);
  margin: 0 auto;
  padding: 18px 22px max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.footer-inner p { margin: 0; }
.footer-links { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.footer-links span { color: #d2d2d7; }
.footer-links button { min-height: 28px; padding: 2px; color: var(--text-secondary); border-radius: 5px; font-size: 11px; }

.sheet {
  width: min(390px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: rgba(255,255,255,.92);
  color: var(--text);
  box-shadow: 0 22px 80px rgba(0,0,0,.2), 0 2px 10px rgba(0,0,0,.08);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
.sheet::backdrop { background: rgba(0,0,0,.22); backdrop-filter: blur(2px); }
.sheet[open] { animation: sheet-in .28s cubic-bezier(.2,.8,.2,1) both; }
.sheet-content { padding: 24px; text-align: center; }
.sheet-handle { display: none; }
.sheet-icon { width: 52px; height: 52px; margin: 0 auto 13px; border-radius: 16px; background: rgba(0,113,227,.1) url("assets/logo.svg") center/44px 44px no-repeat; }
.sheet h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.sheet p { margin: 8px auto 20px; max-width: 290px; color: var(--text-secondary); font-size: 14px; line-height: 1.48; }
.sheet-button { width: 100%; min-height: 44px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; cursor: pointer; font-weight: 600; }
.sheet-button:active { transform: scale(.985); }

@keyframes mascot-enter { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes stage-in { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sheet-in { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 680px) {
  :root { --header-height: 48px; --footer-height: 112px; }
  .nav-inner { padding-inline: 16px; }
  .brand-mark { width: 23px; height: 23px; }
  .brand-name { font-size: 16px; }
  .account-nav { gap: 12px; }
  .nav-link.is-current { display: none; }
  .nav-link { font-size: 12px; }
  .nav-create { min-width: 72px; padding-inline: 12px; }
  .main-content { padding: clamp(54px, 8vh, 76px) 20px 68px; }
  .auth-panel { width: min(100%, 420px); }
  .mascot-button { width: 68px; height: 68px; margin-bottom: 21px; }
  .kron-head { width: 70px; height: 70px; }
  .heading-group { margin-bottom: 31px; }
  .heading-group h1 { font-size: 31px; }
  .heading-group p { margin-top: 10px; font-size: 16px; }
  .create-account { margin-top: 34px; padding-top: 24px; }
  .footer-inner { min-height: var(--footer-height); padding: 16px 18px max(18px, env(safe-area-inset-bottom)); flex-direction: column-reverse; justify-content: center; gap: 7px; text-align: center; }
  .footer-links { flex-wrap: wrap; justify-content: center; }
  .sheet { width: 100%; max-width: none; margin: auto 0 0; border-radius: 24px 24px 0 0; }
  .sheet-content { padding: 10px 20px max(20px, env(safe-area-inset-bottom)); }
  .sheet-handle { display: block; width: 36px; height: 5px; margin: 0 auto 20px; border-radius: 99px; background: rgba(60,60,67,.22); }
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #000;
    --footer: #1d1d1f;
    --surface: #1c1c1e;
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #86868b;
    --line: #86868b;
    --line-soft: #38383a;
  }
  .site-header { background: rgba(0,0,0,.82); border-bottom-color: rgba(255,255,255,.12); }
  .checkmark { background: #1c1c1e; }
  .footer-links span { color: #48484a; }
  .sheet { background: rgba(28,28,30,.94); }
  .continue-button:disabled { color: #8e8e93; box-shadow: inset 0 0 0 1px #8e8e93; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .site-header, .sheet { background: var(--page); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
