:root {
  --ink: #17285c;
  --lava-deep: #4b0b25;
  --lava-wine: #741335;
  --lava-rose: #a84062;
  --lava-light: #dfa0b0;
}

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

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

body {
  position: relative;
  isolation: isolate;
  min-height: 100dvh;
  color: #171717;
  background: var(--lava-deep);
  font-family: Arial, Helvetica, sans-serif;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: -18%;
  content: "";
  background:
    radial-gradient(
      ellipse at 12% 14%,
      var(--lava-light) 0 9%,
      transparent 38%
    ),
    radial-gradient(
      ellipse at 86% 84%,
      var(--lava-rose) 0 11%,
      transparent 40%
    ),
    radial-gradient(
      ellipse at 48% 45%,
      var(--lava-wine) 0 20%,
      transparent 58%
    ),
    linear-gradient(125deg, var(--lava-light), var(--lava-wine) 48%, var(--lava-deep));
  background-size: 155% 155%, 145% 145%, 135% 135%, 100% 100%;
  filter: blur(32px);
  transform: scale(1.08);
}

button,
a {
  font: inherit;
}

.auth-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 72px 24px 40px;
}

.back-button {
  position: fixed;
  top: 24px;
  left: 28px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #ffffff;
  text-decoration: none;
}

.back-button svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.auth-card {
  display: flex;
  width: min(100%, 780px);
  flex-direction: column;
  align-items: center;
}

.auth-logo {
  display: block;
  width: min(78vw, 290px);
  max-height: 96px;
  object-fit: contain;
}

.auth-card h1 {
  max-width: 100%;
  margin: 26px 0 34px;
  color: #ffffff;
  font-size: clamp(16px, 2.25vw, 30px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.12;
  text-align: center;
}

.auth-title-main-line {
  display: block;
  white-space: nowrap;
}

.auth-title-last-line {
  display: block;
}

.auth-form {
  width: min(100%, 360px);
}

.auth-label {
  margin: 0 0 12px;
  color: #ffffff;
  font-size: 16px;
  text-align: center;
}

.auth-option {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 8px 0;
  padding: 9px 16px;
  border: 2px solid #f3e8dc;
  border-radius: 16px;
  color: #ffffff;
  background: transparent;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.auth-telegram-group {
  display: grid;
  justify-items: center;
}

.auth-telegram-group .auth-option {
  margin-bottom: 4px;
}

.auth-telegram-note {
  color: rgb(255 255 255 / 76%);
  font-size: 11px;
  text-align: center;
}

.auth-option:hover {
  background: rgb(243 232 220 / 10%);
  box-shadow: 0 8px 22px rgb(35 0 16 / 16%);
  transform: translateY(-1px);
}

.auth-option:focus-visible,
.back-button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.auth-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 50%;
}

.auth-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.auth-icon-image {
  display: block;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  object-fit: contain;
}

.auth-option-text {
  display: grid;
  gap: 2px;
  justify-items: center;
}

.auth-option-text strong {
  font-size: 16px;
  font-weight: 500;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 17px 0;
  color: rgb(255 255 255 / 88%);
  font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
  width: 100%;
  height: 1px;
  content: "";
  background: rgb(255 255 255 / 50%);
}

.email-modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
}

.email-modal.is-open {
  display: grid;
}

.email-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(25 0 14 / 28%);
  backdrop-filter: blur(9px);
}

.email-modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 440px);
  min-height: 33vh;
  padding: 52px 40px 40px;
  border-radius: 28px;
  background: #f3e8dc;
  box-shadow: 0 24px 70px rgb(35 0 16 / 32%);
  color: #4b0b25;
  text-align: center;
}

.email-modal-close {
  position: absolute;
  top: 18px;
  right: 20px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.email-modal-close svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #4b0b25;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.email-modal-card h2 {
  margin: 0 0 12px;
  font-size: clamp(25px, 4vw, 34px);
  font-weight: 500;
}

.email-modal-card p {
  margin: 0 0 28px;
  font-size: 16px;
}

.email-modal-form {
  display: grid;
  gap: 12px;
}

.email-modal-form input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 2px solid #4b0b25;
  border-radius: 14px;
  outline: 0;
  color: #4b0b25;
  background: rgb(255 255 255 / 58%);
  font: inherit;
}

.email-modal-form input:focus {
  box-shadow: 0 0 0 3px rgb(75 11 37 / 18%);
}

.email-modal-form input.is-invalid {
  border-color: #a84062;
}

.email-modal-form input[hidden],
.email-modal-form button[hidden] {
  display: none;
}

.email-modal-form input[name="code"] {
  text-align: center;
  letter-spacing: 0.3em;
}

.email-error {
  min-height: 16px;
  margin-top: -4px;
  color: #a84062;
  font-size: 12px;
  text-align: left;
}

.email-status {
  min-height: 16px;
  margin-top: -4px;
  color: #4b0b25;
  font-size: 12px;
  text-align: left;
}

.email-modal-form button {
  height: 52px;
  border: 0;
  border-radius: 14px;
  color: #f3e8dc;
  background: #4b0b25;
  cursor: pointer;
  font: inherit;
}

.email-modal-form button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.email-modal-form .change-email-button {
  height: auto;
  min-height: 40px;
  color: #4b0b25;
  background: transparent;
  text-decoration: underline;
}

.email-modal-form button:hover {
  background: #741335;
}

.email-modal-close:focus-visible,
.email-modal-form input:focus-visible,
.email-modal-form button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

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

@media (max-width: 600px) {
  .auth-page {
    padding: 72px 20px 28px;
  }

  .back-button {
    top: max(12px, env(safe-area-inset-top));
    left: 16px;
  }

  .auth-card h1 {
    width: 100%;
    margin-top: 22px;
    margin-bottom: 28px;
    font-size: clamp(10px, 3.15vw, 18px);
    letter-spacing: -0.055em;
  }

  .email-modal {
    padding: 16px;
  }

  .email-modal-card {
    min-height: 0;
    padding: 48px 22px 28px;
    border-radius: 22px;
  }
}

/* Paper notebook theme */
:root {
  --paper: #f2f5fa;
  --grid: #dce5f2;
  --accent: #701b3d;
  --text: #29252a;
  --surface: #ffffff;
  --text-secondary: #99949a;
}

body {
  color: var(--text);
  background: var(--paper);
}

body::before {
  z-index: -2;
  inset: 0;
  background-image:
    linear-gradient(to right, rgb(220 229 242 / 58%) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(220 229 242 / 58%) 1px, transparent 1px),
    radial-gradient(circle, rgb(112 27 61 / 4%) 0.6px, transparent 0.8px);
  background-size: 28px 28px, 28px 28px, 7px 7px;
  filter: none;
  opacity: 0.9;
  transform: none;
  animation: none;
}

.back-button {
  color: var(--accent);
}

.auth-card h1,
.auth-label {
  color: var(--accent);
}

.auth-option {
  border-color: var(--grid);
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(41 37 42 / 7%);
}

.auth-option:hover {
  background: #ffffff;
  box-shadow: 0 10px 28px rgb(41 37 42 / 12%);
}

.auth-telegram-note,
.auth-divider {
  color: var(--text-secondary);
}

.auth-divider::before,
.auth-divider::after {
  background: var(--grid);
}

.email-modal-backdrop {
  background: rgb(41 37 42 / 18%);
}

.email-modal-card {
  border: 1px solid var(--grid);
  background: var(--surface);
  box-shadow: 0 24px 70px rgb(41 37 42 / 18%);
  color: var(--text);
}

.email-modal-close svg {
  stroke: var(--accent);
}

.email-modal-form input {
  border-color: var(--grid);
  color: var(--text);
  background: var(--surface);
}

.email-modal-form button {
  color: #ffffff;
  background: var(--accent);
}

.email-modal-form button:hover {
  background: #5d1734;
}

.email-status {
  color: var(--text-secondary);
}
