.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;

  &__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
  }

  &__title {
    font-family: var(--heading);
    font-size: 20px;
    font-weight: 500;
    color: var(--text-h);
    margin: 0;
  }

  &__close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text);
    font-size: 20px;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    &:hover {
      color: var(--text-h);
    }
    &:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }
  }

  &__form {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  &__field {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  &__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-h);
  }

  &__input {
    font-size: 15px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text-h);
    font-family: var(--sans);
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;

    &:focus {
      outline: none;
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--accent-bg);
    }
  }

  &__error {
    font-size: 13px;
    color: #ef4444;
    padding: 8px 12px;
    background: rgba(11, 0, 0, 0.499);
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.2);
  }

  &__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
  }

  &__submit,
  &__other {
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 500;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
    min-width: 100px;
    color: #fff;

    &:hover:not(:disabled) {
      opacity: 0.85;
    }

    &:disabled {
      opacity: 0.6;
      cursor: not-allowed;
    }

    &:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }
  }

  &__submit {
    background: var(--accent);
  }

  &--expanded {
    max-height: 70vh;
  }

  &__results {
    overflow-y: auto;
    flex: 1;
    min-height: 0; // required: flex children won't shrink without this
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  &__results-count {
    font-size: 12px;
    color: var(--text);
    margin: 0 0 8px 0;
  }

  &__result-item {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
  }

  &__result-title {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-h);
    margin: 0;
  }

  &__result-desc {
    font-size: 13px;
    color: var(--text);
    margin: 4px 0 0 0;
  }
}
