:root {
  --red: #e9192f;
  --red-dark: #d90f22;
  --ink: #17181a;
  --muted: #777b84;
  --line: rgba(0, 0, 0, 0.08);
  --bg: #fafafa;
  --success: #1f8a4c;
  --danger: #d90f22;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --shadow: 0 1px 2px rgba(23, 24, 26, 0.04), 0 8px 24px rgba(23, 24, 26, 0.06);
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; background: var(--bg); }

button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 18px;
  color: #fff;
  background: var(--red);
  font-weight: 650;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color 160ms ease, border-color 160ms ease;
}

button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { cursor: not-allowed; opacity: 0.5; }
button[aria-busy="true"] { position: relative; }

button[aria-busy="true"]::after {
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  display: inline-block;
  vertical-align: -2px;
  animation: spin 700ms linear infinite;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .primary-button:hover:not(:disabled) { background: var(--red-dark); }
  .provider:hover:not(:disabled),
  .ghost:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
  .wordmark:hover { opacity: 0.8; }
}

/* ── header ── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--line);
}

.site-header-inner,
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 20px;
  max-width: 560px;
  margin: 0 auto;
}

.wordmark {
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0;
  color: var(--ink);
}

.wordmark span { color: var(--red); }

.eyebrow {
  display: inline-block;
  margin-bottom: 14px;
  padding: 5px 12px;
  border-radius: 99px;
  background: var(--bg);
  color: var(--red);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ── layout ── */

.shell {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.card, .auth-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-card { padding: clamp(28px, 6vw, 40px); }
.card + .card,
.grid,
.addresses-card { margin-top: 16px; }

.auth-mode {
  width: fit-content;
  margin-bottom: 20px;
  padding: 3px;
  border-radius: 11px;
  background: var(--bg);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-mode-button {
  min-height: 36px;
  padding: 7px 16px;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 0.84rem;
  font-weight: 600;
}

.auth-mode-button.is-active { color: var(--ink); background: #fff; box-shadow: var(--shadow); }

.auth-heading h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.auth-heading p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.providers {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.provider {
  min-width: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-weight: 600;
}

.provider svg { width: 19px; height: 19px; flex: 0 0 auto; fill: currentColor; }
.provider-vk svg { color: #2787f5; }
.provider-telegram svg { color: #229ed9; }
.provider:disabled { opacity: 0.45; }

.provider-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
  text-align: center;
}

.divider {
  margin: 22px 0 18px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
}

.divider::before, .divider::after { height: 1px; background: var(--line); content: ""; flex: 1; }

form { display: grid; gap: 10px; }
.registration-fields, .registration-consents { display: grid; gap: 10px; }
.field-hint { color: var(--muted); font-size: 0.76rem; line-height: 1.4; }

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.consent-row input { width: 17px; height: 17px; margin-top: 1px; accent-color: var(--red); flex: 0 0 auto; }
.consent-row a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.consent-row.optional { color: #96999e; }

label {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
}

.required-mark {
  color: var(--red);
  margin-left: 2px;
}

.field-shell {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-shell:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px rgba(233, 25, 47, 0.1); }

.field-shell input {
  width: 100%;
  height: 46px;
  border: 0;
  outline: 0;
  padding: 0 14px;
  background: transparent;
  color: var(--ink);
}

.field-shell input::placeholder { color: #a8acb2; }
.code-field input { letter-spacing: 0.3em; text-align: center; }

.primary-button { width: 100%; margin-top: 2px; }

#otp-form.is-revealing {
  opacity: 0;
  transform: translateY(-6px);
  animation: otp-in 220ms var(--ease-out) forwards;
}

#message {
  min-height: 22px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.84rem;
}

#message[data-tone="success"] { color: var(--success); }
#message[data-tone="error"] { color: var(--danger); }

.privacy-note {
  margin-top: 16px;
  color: #9a9da2;
  font-size: 0.72rem;
  line-height: 1.45;
  text-align: center;
}

.privacy-note a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }

.ghost {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 600;
}

.compact { min-height: 34px; padding: 6px 12px; font-size: 0.78rem; justify-self: start; }

/* ── cabinet ── */

.profile-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.profile-card h1 { margin-top: 4px; font-size: 1.3rem; font-weight: 800; letter-spacing: -0.015em; }
.profile-card p { margin-top: 2px; color: var(--muted); font-size: 0.85rem; }

.card h2 { font-size: 1rem; font-weight: 750; letter-spacing: -0.01em; }
.card p { color: var(--muted); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid .card { margin-top: 0; }
#profile-completion { margin-top: 16px; }
#profile-completion > p { margin: 5px 0 14px; font-size: 0.84rem; }
#profile-completion-form .consent-row { margin-top: 4px; }
#profile-completion-message { min-height: 20px; font-size: 0.82rem; }
#profile-completion-message[data-tone="error"] { color: var(--danger); }
#profile-completion-message[data-tone="success"] { color: var(--success); }

#orders, #favorites, #addresses { margin-top: 14px; font-size: 0.86rem; color: var(--muted); }

.order { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 0.86rem; }
.order:last-child { border-bottom: 0; }
.order strong { display: flex; justify-content: space-between; gap: 12px; color: var(--ink); font-weight: 650; }
.order small { color: var(--muted); }

.address { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 3px; font-size: 0.86rem; }
.address:last-child { border-bottom: 0; }
.address strong { color: var(--ink); }
.address small { color: var(--muted); }

.address-form { margin-top: 18px; grid-template-columns: 1fr 1fr; gap: 12px; }
.address-form label { display: grid; gap: 6px; }

.address-form input, .address-form select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

.full { grid-column: 1 / -1; }
.check { display: flex !important; align-items: center; gap: 8px !important; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--red); }

@keyframes otp-in { to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .shell { padding: 20px 16px 48px; }
  .grid, .providers, .address-form { grid-template-columns: 1fr; }
  .auth-card, .card { padding: 22px; border-radius: 18px; }
  .profile-card { flex-direction: column; align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  #otp-form { transform: none !important; }
}

@media (prefers-contrast: more) {
  .card, .auth-card, .field-shell, input, select, button { border-color: currentColor; }
}
