:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #121c29;
  --muted: #566475;
  --border: #cfd7e2;
  --field-bg: #ffffff;
  --action: #1a5fd0;
  --action-hover: #154eae;
  --action-text: #ffffff;
  --focus: #1a5fd0;
  --err-text: #9f1c12;
  --err-bg: #fef3f2;
  --err-border: #f1a39b;
  --aside-bg: #0e1c2c;
  --aside-text: #e9eff6;
  --aside-muted: #a9b9cb;
  --shadow: 0 1px 2px rgba(18, 28, 41, .06), 0 12px 32px rgba(18, 28, 41, .08);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1017;
    --surface: #121b26;
    --text: #e7edf5;
    --muted: #9aa9bb;
    --border: #28374a;
    --field-bg: #0d151e;
    --action: #6aa6ff;
    --action-hover: #86b7ff;
    --action-text: #061223;
    --focus: #8ab8ff;
    --err-text: #ffb9b0;
    --err-bg: #3a1613;
    --err-border: #7a2c25;
    --aside-bg: #0d1722;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[hidden] { display: none !important; }

.shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  min-height: 100vh;
}

/* ---------- aside ---------- */
.aside {
  background: var(--aside-bg);
  color: var(--aside-text);
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 36px; height: 36px; color: #7fb2ff; flex: none; }
.brand-name { font-weight: 650; font-size: 1.125rem; letter-spacing: .01em; }

.aside-body { margin: auto 0; max-width: 460px; }
.aside h1 {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  line-height: 1.2;
  font-weight: 650;
}
.aside-lead { margin: 0 0 28px; color: var(--aside-muted); }

.features { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.features li { display: flex; align-items: center; gap: 12px; }
.features svg { width: 22px; height: 22px; flex: none; color: #7fb2ff; }

.aside-foot { margin: 0; color: var(--aside-muted); font-size: .875rem; }

/* ---------- main ---------- */
.main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 72px 24px 40px;
}

.lang {
  position: absolute;
  top: 20px;
  right: 24px;
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.lang-btn {
  min-width: 48px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--border); }
.lang-btn[aria-pressed="true"] { background: var(--action); color: var(--action-text); }
.lang-btn:not([aria-pressed="true"]):hover { color: var(--text); }

.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.card h2 { margin: 0 0 6px; font-size: 1.5rem; line-height: 1.25; font-weight: 650; }
.card h2:focus { outline: none; }
.sub { margin: 0 0 24px; color: var(--muted); }

/* ---------- alert ---------- */
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 20px;
  padding: 12px 14px;
  border: 1px solid var(--err-border);
  border-radius: 10px;
  background: var(--err-bg);
  color: var(--err-text);
  font-size: .9375rem;
}
.alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }

/* ---------- form ---------- */
.field { margin: 0 0 18px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
label { display: block; margin: 0 0 6px; font-weight: 600; font-size: .9375rem; }

input[type="text"], input[type="password"] {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
}
input[aria-invalid="true"] { border-color: var(--err-text); }
input::placeholder { color: var(--muted); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input:focus-visible { outline-offset: 0; border-color: var(--focus); }

.pw { position: relative; }
.pw input { padding-right: 52px; }
.pw-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  height: 100%;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0 10px 10px 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle svg { width: 22px; height: 22px; }

.link {
  padding: 12px 0;
  margin: -12px 0;
  border: 0;
  background: none;
  color: var(--action);
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover { color: var(--action-hover); }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  font-weight: 400;
  cursor: pointer;
  min-height: 44px;
}
.check input { width: 20px; height: 20px; accent-color: var(--action); flex: none; }

.btn {
  position: relative;
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--action);
  color: var(--action-text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.btn:hover { background: var(--action-hover); }
.btn[aria-busy="true"] { cursor: progress; opacity: .85; }
.btn-ghost { background: transparent; color: var(--action); border-color: var(--border); }
.btn-ghost:hover { background: transparent; border-color: var(--action); }

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn[aria-busy="true"] .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.foot-note { margin: 22px 0 0; color: var(--muted); font-size: .9375rem; }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .aside { padding: 20px 24px; gap: 0; min-height: 76px; justify-content: center; }
  .aside-body, .aside-foot { display: none; }
  .main { align-items: flex-start; padding: 32px 16px 32px; }
  .lang { top: 18px; right: 16px; }
}

@media (max-width: 420px) {
  .card { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}
