:root {
  --mm-page-bg: #0f1720;
  --mm-page-bg-alt: #121b28;
  --mm-text: #f4f7fb;
  --mm-text-muted: #a2b4c7;
  --mm-surface: rgba(255, 255, 255, 0.04);
  --mm-surface-strong: rgba(8, 14, 22, 0.82);
  --mm-border: rgba(255, 255, 255, 0.08);
  --mm-accent: #00c4b4;
  --mm-accent-text: #07262b;
  --mm-danger: #d64545;
  --mm-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

html[data-theme="light"] {
  --mm-page-bg: #eef3f8;
  --mm-page-bg-alt: #f7f9fc;
  --mm-text: #0f1720;
  --mm-text-muted: #526273;
  --mm-surface: rgba(255, 255, 255, 0.92);
  --mm-surface-strong: rgba(255, 255, 255, 0.94);
  --mm-border: rgba(15, 23, 32, 0.12);
  --mm-accent: #00b5a7;
  --mm-accent-text: #ffffff;
  --mm-danger: #c93b3b;
  --mm-shadow: 0 14px 36px rgba(14, 29, 45, 0.12);
}

.hidden {
  display: none !important;
}

.mm-gate {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mm-gate-button {
  border: 1px solid var(--mm-border);
  background: var(--mm-surface);
  color: var(--mm-text);
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
  font-size: clamp(15px, 1.25vw, 17px);
  line-height: 1.2;
  min-width: 48px;
  white-space: nowrap;
  position: relative;
  z-index: 3;
  touch-action: manipulation;
}

.mm-gate-button.primary {
  background: var(--mm-accent);
  color: var(--mm-accent-text);
  border-color: transparent;
}

.mm-gate-button:hover,
.mm-gate-menu-item:hover {
  opacity: 0.92;
}

.mm-gate-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--mm-surface-strong);
  border: 1px solid var(--mm-border);
  border-radius: 14px;
  box-shadow: var(--mm-shadow);
  padding: 8px;
  z-index: 60;
}

.mm-gate-menu.hidden {
  display: none;
}

.mm-gate-menu-title {
  padding: 8px 10px 10px;
  color: var(--mm-text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mm-gate-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--mm-text);
  text-align: left;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mm-gate-menu-item.danger {
  color: #ffb4b4;
}

.mm-gate-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 9, 16, 0.58);
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 28px);
  backdrop-filter: blur(8px);
  z-index: 90;
  pointer-events: auto;
}

.mm-gate-modal-backdrop.hidden {
  display: none;
}

.mm-gate-page-shell {
  display: block;
}

.mm-gate-modal {
  box-sizing: border-box;
  width: min(calc(100vw - 24px), 560px);
  max-height: min(92svh, 760px);
  overflow-y: auto;
  background: var(--mm-surface-strong);
  border: 1px solid var(--mm-border);
  border-radius: 22px;
  box-shadow: var(--mm-shadow);
  padding: clamp(20px, 2.6vw, 32px);
  color: var(--mm-text);
  display: grid;
  gap: 18px;
  position: relative;
  z-index: 91;
  pointer-events: auto;
}

.mm-gate-modal--page {
  width: 100%;
  max-width: none;
  max-height: none;
  overflow: visible;
  background: linear-gradient(180deg, rgba(37, 28, 24, 0.94), rgba(26, 20, 18, 0.96));
  border: 1px solid rgba(214, 146, 98, 0.16);
  box-shadow: 0 28px 60px rgba(7, 6, 6, 0.22);
}

.mm-gate-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--mm-border);
  border-radius: 12px;
  background: var(--mm-surface);
  color: var(--mm-text);
  display: grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.mm-gate-modal * {
  pointer-events: auto;
}

.mm-gate-modal-head {
  display: grid;
  gap: 12px;
}

.mm-gate-auth-note {
  padding: 12px 14px;
  border: 1px solid var(--mm-border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  color: var(--mm-text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.mm-gate-auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--mm-border);
  background: var(--mm-surface);
  color: var(--mm-text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mm-gate-modal h2 {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 32px);
  line-height: 1.12;
}

.mm-gate-modal p {
  margin: 0;
  color: var(--mm-text-muted);
  font-size: 16px;
  line-height: 1.5;
}

.mm-gate-form {
  display: grid;
  gap: 14px;
}

.mm-gate-form.is-busy {
  opacity: 0.72;
}

.mm-gate-form-intro {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--mm-border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(0, 196, 180, 0.08), rgba(255, 255, 255, 0.02));
}

.mm-gate-form-title {
  color: var(--mm-text);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
}

.mm-gate-form-subtitle {
  color: var(--mm-text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.mm-gate-form-group {
  display: grid;
  gap: 14px;
}

.mm-gate-form-group--double {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mm-gate-form label {
  display: grid;
  gap: 8px;
  font-size: 15px;
  color: var(--mm-text-muted);
}

.mm-gate-field > span {
  color: var(--mm-text);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
}

.mm-gate-field-hint {
  color: var(--mm-text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.mm-gate-form input {
  width: 100%;
  box-sizing: border-box;
  min-height: 54px;
  padding: 14px 16px;
  font-size: 16px;
  border-radius: 14px;
  border: 1px solid var(--mm-border);
  background: var(--mm-surface);
  color: var(--mm-text);
}

.mm-gate-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 120px;
  padding: 14px 16px;
  font-size: 16px;
  border-radius: 14px;
  border: 1px solid var(--mm-border);
  background: var(--mm-surface);
  color: var(--mm-text);
  resize: vertical;
}

.mm-gate-form select {
  width: 100%;
  box-sizing: border-box;
  min-height: 54px;
  padding: 14px 16px;
  font-size: 16px;
  border-radius: 14px;
  border: 1px solid var(--mm-border);
  background: var(--mm-surface);
  color: var(--mm-text);
}

.mm-gate-combo {
  display: flex;
  align-items: stretch;
  min-height: 56px;
  border: 1px solid var(--mm-border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--mm-surface);
}

.mm-gate-combo:focus-within {
  border-color: rgba(0, 196, 180, 0.58);
  box-shadow: 0 0 0 3px rgba(0, 196, 180, 0.14);
}

.mm-gate-combo select,
.mm-gate-combo input,
.mm-gate-combo button {
  border: 0;
  border-radius: 0;
  background: transparent;
  margin: 0;
  box-shadow: none;
}

.mm-gate-combo select:focus,
.mm-gate-combo input:focus,
.mm-gate-combo button:focus {
  outline: none;
}

.mm-gate-combo select {
  width: auto;
  min-width: 122px;
  max-width: 150px;
  border-right: 1px solid var(--mm-border);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.mm-gate-combo input {
  flex: 1 1 auto;
  min-width: 0;
}

.mm-gate-phone-row,
.mm-gate-password-row {
  display: flex;
  gap: 0;
  align-items: stretch;
}

.mm-gate-password-toggle {
  width: 58px;
  min-width: 58px;
  border-left: 1px solid var(--mm-border);
  color: var(--mm-text);
  cursor: pointer;
  font-size: 18px;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 3;
  touch-action: manipulation;
}

.mm-gate-check {
  display: flex !important;
  align-items: center;
  gap: 10px;
  color: var(--mm-text);
  font-size: 15px;
  line-height: 1.35;
}

.mm-gate-check input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.mm-gate-inline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.mm-gate-helper-inline {
  color: var(--mm-text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.mm-gate-auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.mm-gate-auth-tab {
  border: 1px solid var(--mm-border);
  background: var(--mm-surface);
  color: var(--mm-text);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.25;
  position: relative;
  z-index: 3;
  touch-action: manipulation;
}

.mm-gate-auth-tab.active {
  background: var(--mm-accent);
  color: var(--mm-accent-text);
  border-color: transparent;
}

.mm-gate-account-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.mm-gate-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.mm-gate-error {
  min-height: 20px;
  color: #ff9d9d;
  font-size: 15px;
  line-height: 1.4;
  position: relative;
  z-index: 1;
  pointer-events: none;
  padding-inline: 2px;
}

.mm-gate-register-summary {
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px dashed var(--mm-border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--mm-text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.mm-gate-pending {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 8px 8px;
  text-align: center;
}

.mm-gate-pending.hidden {
  display: none;
}

.mm-gate-pending-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--mm-accent, #3b82f6);
  color: var(--mm-accent-text, #fff);
  font-size: 26px;
  line-height: 52px;
  text-align: center;
  flex-shrink: 0;
}

.mm-gate-pending-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  color: var(--mm-text, inherit);
}

.mm-gate-pending-message {
  font-size: 16px;
  line-height: 1.5;
  color: var(--mm-text-muted, inherit);
  margin: 0;
  max-width: 280px;
}

@media (max-width: 520px) {
  .mm-gate {
    gap: 8px;
  }

  .mm-gate-button {
    padding: 11px 14px;
    font-size: 15px;
  }

  .mm-gate-form-group--double {
    grid-template-columns: 1fr;
  }

  .mm-gate-modal-backdrop {
    padding: 14px;
  }

  .mm-gate-modal {
    width: calc(100vw - 16px);
    border-radius: 16px;
    padding: 18px;
  }

  .mm-gate-modal--page {
    width: 100%;
    max-height: none;
  }

  .mm-gate-modal-close {
    top: 12px;
    right: 12px;
  }

  .mm-gate-modal h2 {
    font-size: 24px;
  }

  .mm-gate-modal p,
  .mm-gate-auth-note,
  .mm-gate-form label,
  .mm-gate-field > span,
  .mm-gate-check,
  .mm-gate-error,
  .mm-gate-pending-message {
    font-size: 15px;
  }

  .mm-gate-form-title {
    font-size: 15px;
  }

  .mm-gate-form-subtitle,
  .mm-gate-field-hint,
  .mm-gate-helper-inline,
  .mm-gate-register-summary {
    font-size: 13px;
  }

  .mm-gate-phone-row {
    min-height: 54px;
  }

  .mm-gate-form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .mm-gate-form-actions .mm-gate-button {
    min-height: 48px;
    pointer-events: auto;
  }

  .mm-gate-auth-tabs {
    grid-template-columns: 1fr;
  }

  .mm-gate-combo select {
    min-width: 108px;
    max-width: 132px;
    padding-inline: 12px;
  }

  .mm-gate-inline-row {
    align-items: flex-start;
  }
}
