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

:root {
  --bg: #f2f5ee;
  --card: rgba(255, 255, 255, 0.86);
  --text: #17211a;
  --muted: #66756b;
  --line: #e2e8dd;
  --accent: #16a34a;
  --accent-dark: #0d7a38;
  --danger: #dc2626;
  --radius: 20px;
}

html,
body { min-height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 28px 18px;
  position: relative;
  overflow: hidden;
}

.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(60% 60% at 15% 10%, #e4f6d8 0%, transparent 70%),
    radial-gradient(50% 50% at 90% 20%, #fff1d6 0%, transparent 70%),
    radial-gradient(60% 60% at 60% 100%, #d9f0e4 0%, transparent 70%),
    #f2f5ee;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.55;
  animation: float 14s ease-in-out infinite;
}

.blob-1 {
  width: 220px;
  height: 220px;
  left: 6%;
  top: 12%;
  background: #c8ebbd;
}

.blob-2 {
  width: 180px;
  height: 180px;
  right: 8%;
  top: 18%;
  background: #ffe0b0;
  animation-delay: -5s;
}

.blob-3 {
  width: 260px;
  height: 260px;
  left: 40%;
  bottom: -80px;
  background: #b9e7d3;
  animation-delay: -9s;
}

@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(0, -18px, 0) scale(1.04); }
}

.auth-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 430px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 750;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.auth-logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 8px 24px -12px rgba(22, 163, 74, 0.55);
  font-size: 21px;
}

.auth-card {
  width: 100%;
  padding: 30px 28px 26px;
  border-radius: 26px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow:
    0 1px 2px rgba(20, 35, 22, 0.04),
    0 30px 70px -34px rgba(20, 60, 30, 0.35);
  backdrop-filter: blur(18px);
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.03em;
}

.auth-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.45;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #3d4a41;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input::placeholder { color: #a4b0a6; }

.field input:focus {
  border-color: #86d3a4;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 4px;
  padding: 13px 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #1fb457, #128c42);
  color: #fff;
  font: inherit;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 12px 26px -14px rgba(18, 140, 66, 0.9);
  transition: transform 0.12s, box-shadow 0.15s, opacity 0.15s;
}

.btn-primary:hover { transform: translateY(-1px); }

.btn-primary:active { transform: translateY(0); }

.btn-primary:disabled {
  opacity: 0.65;
  cursor: default;
  transform: none;
}

.btn-primary.is-loading .btn-label::after {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-left: 9px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.auth-error {
  margin: 2px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff1f1;
  border: 1px solid #ffd7d7;
  color: #b91c1c;
  font-size: 13.5px;
  line-height: 1.4;
}

.auth-switch {
  margin: 20px 0 0;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

.auth-switch a {
  color: var(--accent-dark);
  font-weight: 650;
  text-decoration: none;
}

.auth-switch a:hover { text-decoration: underline; }

/* ---------------- установка на iOS ---------------- */

body.ios-install-open { overflow: hidden; }

.ios-install {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.ios-install[hidden] { display: none; }

.ios-install-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 25, 17, 0.58);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.ios-install-sheet {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 24px 22px 20px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 32px 80px -24px rgba(5, 20, 10, 0.55);
  animation: ios-sheet-in 0.24s ease-out;
  -webkit-overflow-scrolling: touch;
}

@keyframes ios-sheet-in {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ios-install-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.ios-install-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: #e8f7ec;
  font-size: 25px;
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.08);
}

.ios-install-kicker {
  margin: 1px 0 4px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.ios-install h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.ios-install h2:focus { outline: none; }

.ios-install-lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.ios-install-alert {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #f2ddb4;
  border-radius: 11px;
  background: #fff8e8;
  color: #87540a;
  font-size: 12.5px;
  line-height: 1.45;
}

.ios-install-alert[hidden] { display: none; }

.ios-install-steps {
  display: grid;
  gap: 11px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.ios-install-steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ios-install-num {
  display: grid;
  flex: 0 0 25px;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 8px;
  background: #edf8f0;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 750;
}

.ios-install-steps p {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.48;
}

.ios-install-steps b { font-weight: 700; }

.ios-burger-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  margin: 0 1px;
  color: var(--accent-dark);
  vertical-align: -5px;
}

.ios-burger-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ios-install-subnote {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.42;
}

.ios-install-note {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 11px;
  background: #f3f7f1;
  color: #5d6d61;
  font-size: 12px;
  line-height: 1.5;
}

.ios-install .btn-primary { margin-top: 0; }

@media (min-width: 640px) {
  .ios-install { align-items: center; }
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 20px 22px; border-radius: 22px; }
  .auth-card h1 { font-size: 23px; }
  .ios-install-sheet { padding: 21px 18px 18px; border-radius: 23px; }
  .ios-install h2 { font-size: 19px; }
  .ios-install-icon { width: 42px; height: 42px; border-radius: 13px; font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .ios-install-sheet { animation: none; }
}


/* Prevent iOS Safari from zooming the page when a form field gets focus. */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 720px) {
    .field input {
      font-size: 16px !important;
    }
  }
}

/* ---------------- тёмная тема ---------------- */

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b120e;
  --card: rgba(18, 27, 21, 0.92);
  --text: #e6f0e8;
  --muted: #93a698;
  --line: #293a2f;
  --accent: #22c55e;
  --accent-dark: #7ee2a3;
  --danger: #f87171;
}

html[data-theme="dark"] .auth-bg {
  background:
    radial-gradient(60% 60% at 15% 10%, rgba(34, 197, 94, 0.12) 0%, transparent 70%),
    radial-gradient(50% 50% at 90% 20%, rgba(245, 158, 11, 0.08) 0%, transparent 70%),
    radial-gradient(60% 60% at 60% 100%, rgba(34, 197, 94, 0.08) 0%, transparent 70%),
    #0b120e;
}

html[data-theme="dark"] .blob-1 { background: #14572f; opacity: 0.3; }
html[data-theme="dark"] .blob-2 { background: #6b4314; opacity: 0.25; }
html[data-theme="dark"] .blob-3 { background: #145743; opacity: 0.25; }

html[data-theme="dark"] .auth-logo {
  background: #17231b;
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.8);
}

html[data-theme="dark"] .auth-card {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 30px 70px -34px rgba(0, 0, 0, 0.9);
}

html[data-theme="dark"] .field > span { color: var(--text); }

html[data-theme="dark"] .field input {
  background: #17231b;
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .field input::placeholder { color: #718477; }

html[data-theme="dark"] .auth-error {
  background: #2a1515;
  border-color: #5a2626;
  color: #fca5a5;
}

html[data-theme="dark"] .ios-install-sheet {
  border-color: rgba(255, 255, 255, 0.08);
  background: #152019;
  box-shadow: 0 32px 80px -24px rgba(0, 0, 0, 0.9);
}

html[data-theme="dark"] .ios-install-icon {
  background: #1d3325;
  box-shadow: inset 0 0 0 1px rgba(126, 226, 163, 0.08);
}

html[data-theme="dark"] .ios-install-kicker { color: var(--accent-dark); }

html[data-theme="dark"] .ios-install-alert {
  border-color: #5a4120;
  background: #332612;
  color: #fbbf24;
}

html[data-theme="dark"] .ios-install-num {
  background: #1d3325;
  color: var(--accent-dark);
}

html[data-theme="dark"] .ios-install-note {
  background: #1a271e;
  color: var(--muted);
}
