.form-panel {
  overflow: hidden;
  transition:
    opacity 240ms ease,
    transform 240ms ease,
    max-height 240ms ease,
    margin-top 240ms ease;
}

.form-panel.is-open {
  opacity: 1;
  transform: translateY(0);
  max-height: 32rem;
  margin-top: 0;
  margin-bottom: 0;
  pointer-events: auto;
}

.form-panel.is-collapsed {
  opacity: 0;
  transform: translateY(-6px);
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  pointer-events: none;
}

#add-image-form,
.add-comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1.15rem;
  background: #fcfdff;
  border: 1px solid #e5ebf1;
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(31, 41, 51, 0.08);
}

#add-image-form.form-panel.is-collapsed,
.add-comment-form.form-panel.is-collapsed {
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
}

#add-image-form.form-panel.is-open,
.add-comment-form.form-panel.is-open {
  margin-top: 0;
  margin-bottom: 0;
}

#add-image-form label,
.add-comment-form label,
.auth-form label {
  display: block;
  margin: 0.1rem 0 0.05rem;
  font-weight: 700;
}

#add-image-form input,
.add-comment-form input,
.auth-form input,
.add-comment-form textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.72rem 0.9rem;
  border: 1px solid #d7dee8;
  border-radius: 12px;
  font: inherit;
  background: #ffffff;
  box-sizing: border-box;
}

#add-image-form input:focus,
.add-comment-form input:focus,
.auth-form input:focus,
.add-comment-form textarea:focus {
  outline: 2px solid #c8d7ee;
  border-color: #9eb7dc;
  outline-offset: 1px;
}

.add-comment-form textarea {
  min-height: 5.75rem;
  resize: vertical;
}

.auth-form input[type="password"],
.auth-form input[type="text"],
#add-image-form input[type="text"],
#add-image-form input[type="file"],
.add-comment-form input[type="text"],
.add-comment-form textarea {
  min-height: 2.9rem;
}

.auth-form input[type="file"],
#add-image-form input[type="file"] {
  padding-top: 0.58rem;
  padding-bottom: 0.58rem;
}

button:not(#load-more-galleries-button):not(#previous-gallery-page-button):not(
    #next-gallery-page-button
  ):not(.display-image-delete-button):not(.display-comment-delete-button):not(
    .more-comments-button
  ):not(.less-comments-button):not(.newer-comments-button):not(
    .older-comments-button
  ),
#add-image-form-toggle-button,
.add-comment-form-toggle-button,
.view-gallery-button,
#new-image-submit,
.new-comment-submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.8rem 1.2rem;
  border: 1px solid #d7dee8;
  border-radius: 999px;
  background: #ffffff;
  color: #1f2933;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-sizing: border-box;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease,
    border-color 180ms ease;
}

#new-image-submit,
.new-comment-submit-button {
  background: #1f2933;
  border-color: #1f2933;
  color: #ffffff;
}

button:not(#load-more-galleries-button):not(#previous-gallery-page-button):not(
    #next-gallery-page-button
  ):not(.display-image-delete-button):not(.display-comment-delete-button):not(
    .more-comments-button
  ):not(.less-comments-button):not(.newer-comments-button):not(
    .older-comments-button
  ):hover:not(:disabled),
#add-image-form-toggle-button:hover:not(:disabled),
.add-comment-form-toggle-button:hover:not(:disabled),
.view-gallery-button:hover:not(:disabled),
#new-image-submit:hover:not(:disabled),
.new-comment-submit-button:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 10px 22px rgba(31, 41, 51, 0.12);
  background: #f9fbfd;
}

#new-image-submit:hover:not(:disabled),
.new-comment-submit-button:hover:not(:disabled) {
  background: #27323d;
}

button:not(#load-more-galleries-button):not(#previous-gallery-page-button):not(
    #next-gallery-page-button
  ):not(.display-image-delete-button):not(.display-comment-delete-button):not(
    .more-comments-button
  ):not(.less-comments-button):not(.newer-comments-button):not(
    .older-comments-button
  ):disabled,
#add-image-form-toggle-button:disabled,
.add-comment-form-toggle-button:disabled,
.view-gallery-button:disabled,
#new-image-submit:disabled,
.new-comment-submit-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.view-gallery-button {
  min-height: 2rem !important;
  min-width: auto !important;
  padding: 0.35rem 0.8rem !important;
  font-size: 0.92rem;
}

/* Fix: keep space between the add image toggle button and its open form. */
#add-image-form.form-panel.is-open {
  margin-top: 0.75rem;
}
