.auth-modal[hidden] {
  display: none;
}

.auth-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.auth-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(36, 30, 24, 0.55);
  backdrop-filter: blur(6px);
}

.auth-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 32px));
  border-radius: 24px;
  border: 1px solid rgba(160, 150, 136, 0.45);
  background: linear-gradient(160deg, rgba(255, 253, 247, 0.98) 0%, rgba(244, 236, 224, 0.94) 100%);
  box-shadow: 0 28px 58px rgba(56, 50, 45, 0.28);
  padding: 32px 32px 30px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  color: #2f2a26;
}

.auth-modal__dialog:focus {
  outline: none;
}

.auth-modal__header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-modal__title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.85rem;
  letter-spacing: -0.01em;
  color: #305b45;
}

.auth-modal__description {
  font-size: 0.95rem;
  color: rgba(63, 55, 48, 0.75);
}

.auth-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  border: none;
  background: rgba(248, 244, 236, 0.85);
  color: #6d665c;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-modal__close:hover,
.auth-modal__close:focus-visible {
  background: rgba(240, 232, 216, 0.95);
  color: #305b45;
  box-shadow: 0 0 0 3px rgba(63, 122, 92, 0.18);
}

.auth-modal__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-modal__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-modal__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #3f372f;
}

.auth-modal__input {
  font: inherit;
  border-radius: 14px;
  border: 1px solid rgba(160, 150, 136, 0.5);
  padding: 10px 14px;
  background: rgba(255, 253, 247, 0.94);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-modal__input:focus {
  outline: none;
  border-color: rgba(63, 122, 92, 0.55);
  box-shadow: 0 0 0 3px rgba(63, 122, 92, 0.18);
}

.auth-modal__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}

.auth-modal__switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: rgba(63, 55, 48, 0.8);
}

body.dark-mode .auth-modal__switch {
  color: rgba(223, 220, 255, 0.78);
}

.auth-modal__submit {
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(140deg, #3f7a5c 0%, #305b45 100%);
  color: #f6f3eb;
  box-shadow: 0 20px 40px rgba(48, 91, 69, 0.24);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.auth-modal__submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 22px 44px rgba(48, 91, 69, 0.28);
}

.auth-modal__submit:disabled {
  opacity: 0.7;
  cursor: progress;
}

.auth-modal__toggle {
  background: none;
  border: none;
  color: #305b45;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.auth-modal__error {
  font-size: 0.85rem;
  color: #b45309;
  background: rgba(244, 221, 197, 0.85);
  border: 1px solid rgba(197, 129, 76, 0.45);
  border-radius: 12px;
  padding: 10px 12px;
}

.auth-modal__message {
  font-size: 0.85rem;
  color: #305b45;
  background: rgba(205, 232, 217, 0.75);
  border: 1px solid rgba(122, 189, 152, 0.45);
  border-radius: 12px;
  padding: 10px 12px;
}

body.modal-open {
  overflow: hidden;
}

body.dark-mode .auth-modal__backdrop {
  background: rgba(12, 8, 24, 0.7);
}

body.dark-mode .auth-modal__dialog {
  background: linear-gradient(165deg, rgba(33, 27, 54, 0.96) 0%, rgba(27, 21, 44, 0.94) 100%);
  border-color: rgba(142, 123, 189, 0.6);
  color: #e7e3ff;
  box-shadow: 0 26px 60px rgba(8, 6, 20, 0.55);
}

body.dark-mode .auth-modal__title {
  color: #ffb87d;
}

body.dark-mode .auth-modal__description {
  color: rgba(223, 220, 255, 0.78);
}

body.dark-mode .auth-modal__close {
  background: rgba(52, 44, 92, 0.85);
  color: rgba(223, 220, 255, 0.78);
}

body.dark-mode .auth-modal__close:hover,
body.dark-mode .auth-modal__close:focus-visible {
  background: rgba(74, 64, 122, 0.95);
  box-shadow: 0 0 0 3px rgba(159, 140, 219, 0.35);
}

body.dark-mode .auth-modal__label {
  color: rgba(223, 220, 255, 0.78);
}

body.dark-mode .auth-modal__input {
  background: rgba(39, 31, 68, 0.9);
  border-color: rgba(142, 123, 189, 0.6);
  color: #f6f3ff;
}

body.dark-mode .auth-modal__input:focus {
  border-color: rgba(255, 184, 125, 0.75);
  box-shadow: 0 0 0 3px rgba(255, 184, 125, 0.2);
}

body.dark-mode .auth-modal__submit {
  background: linear-gradient(140deg, #7151c9 0%, #4a3aa2 100%);
  box-shadow: 0 20px 42px rgba(38, 30, 80, 0.4);
  color: #f6f3ff;
}

body.dark-mode .auth-modal__toggle {
  color: #ffb87d;
}

body.dark-mode .auth-modal__error {
  background: rgba(88, 44, 60, 0.75);
  border-color: rgba(204, 94, 126, 0.55);
  color: #f9d7e2;
}

body.dark-mode .auth-modal__message {
  background: rgba(54, 94, 82, 0.75);
  border-color: rgba(108, 185, 150, 0.55);
  color: #e2f7ec;
}

@media (max-width: 480px) {
  .auth-modal__dialog {
    padding: 26px 22px 24px;
    border-radius: 20px;
  }
}
