body {
  margin: 0;
  background: #f4f1ec;
  color: #1f1f1f;
  font-family: sans-serif;
  line-height: 2;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
textarea {
  font: inherit;
}

#web-gallery-app {
  padding-bottom: 48px;
}

section {
  margin-top: 24px;
}

#app-header {
  margin-top: 24px;
  padding: 24px;
  background: #fff;
  border: 1px solid #ded8cf;
  border-radius: 8px;
}

#app-header h1 {
  margin: 0;
}

#gallery-image-count {
  margin: 0;
  text-align: right;
  color: #77716a;
}

#image-count-value {
  color: #5f4a31;
}

.image-author-name {
  margin: 0 0 12px;
  color: #5f4a31;
}

h2,
h3,
h4 {
  margin: 0 0 12px;
}

button {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

#toggle-add-image-form-button,
#submit-image-button,
.submit-comment-button,
.open-comments-view-button,
.older-comments-button,
.newer-comments-button {
  padding: 10px 16px;
  background: #1f1f1f;
  color: #fff;
}

#toggle-add-image-form-button:hover,
#submit-image-button:hover,
.submit-comment-button:hover,
.open-comments-view-button:hover,
.older-comments-button:hover,
.newer-comments-button:hover {
  background: #5f4a31;
}

.delete-image-button,
.delete-comment-button,
.close-comments-view-button {
  padding: 8px 14px;
  background: #f8e8e6;
  color: #9f3a38;
}

.delete-image-button:hover,
.delete-comment-button:hover,
.close-comments-view-button:hover {
  background: #9f3a38;
  color: #fff;
}

#add-image-section,
.inline-full-comments-view {
  padding: 24px;
  background: #fff;
  border: 1px solid #ded8cf;
  border-radius: 8px;
}

#add-image-form-container {
  margin-top: 16px;
}

#add-image-form .col-4,
#add-image-form .col-12 {
  padding: 0 8px 12px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: #77716a;
}

input,
textarea {
  width: 100%;
  border: 1px solid #ded8cf;
  border-radius: 6px;
  background: #faf8f5;
  padding: 10px 12px;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

#gallery-feed-section {
  margin-top: 32px;
}

#web-gallery-app,
#gallery-feed-section,
#gallery-feed {
  width: 100%;
}

#gallery-feed {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.gallery-image-card {
  box-sizing: border-box;
  width: 100%;
  padding: 24px;
  background: #fff;
  border: 1px solid #ded8cf;
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  column-gap: 20px;
  align-items: start;
}

.gallery-image-panel,
.gallery-comment-panel {
  min-width: 0;
}

.gallery-comment-panel {
  padding-left: 20px;
  border-left: 1px solid #ded8cf;
}

.image-display {
  margin: 0;
  width: 100%;
}

.image-frame {
  box-sizing: border-box;
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 12px;
  border-radius: 6px;
  background: #e8e1d7;
  overflow: hidden;
}

.gallery-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.comment-form-section {
  padding: 16px;
  background: #faf8f5;
  border: 1px solid #ded8cf;
  border-radius: 6px;
}

.comment-form .col-12 {
  padding-bottom: 12px;
}

.comment-form .col-12:last-child {
  padding-bottom: 0;
}

.recent-comments-section {
  margin-top: 16px;
}

.recent-comments-list,
.full-comments-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comment-item {
  margin-bottom: 12px;
}

.comment {
  padding: 12px;
  background: #fff;
  border: 1px solid #ded8cf;
  border-radius: 6px;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.comment-date {
  color: #77716a;
  white-space: nowrap;
}

.comment-text {
  margin: 0 0 8px;
}

.open-comments-view-button {
  margin-top: 4px;
}

.inline-full-comments-view {
  grid-column: 1 / -1;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #ded8cf;
}

.gallery-image-card > .inline-full-comments-view {
  padding-left: 0;
  padding-right: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  background: transparent;
}

.full-comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.full-comments-image-title {
  margin: 0 0 16px;
  color: #77716a;
}

.comment-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.comment-pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.comment-pagination button:disabled:hover {
  background: #1f1f1f;
  transform: none;
}

[hidden] {
  display: none !important;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(244, 241, 236, 0.82);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #ded8cf;
  border-top-color: #5f4a31;
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

.loading-text {
  margin: 0;
  color: #5f4a31;
  font-weight: 600;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 768px) {
  .gallery-image-card {
    grid-template-columns: 1fr;
    row-gap: 20px;
  }

  .gallery-comment-panel {
    padding-left: 0;
    border-left: none;
    border-top: 1px solid #ded8cf;
    padding-top: 20px;
  }
}

/* Auth Screen Styles */
#auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f4f1ec;
}

.auth-screen {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-form-wrapper {
  box-sizing: border-box;
  width: 100%;
  max-width: 400px;
  padding: 48px;
  background: #fff;
  border: 1px solid #ded8cf;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(31, 31, 31, 0.1);
}

.auth-form-wrapper h2 {
  text-align: center;
  margin-bottom: 32px;
  color: #1f1f1f;
}

.auth-form-wrapper h3 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 18px;
}

#login-form-container,
#register-form-container {
  display: flex;
  flex-direction: column;
}

#login-form,
#register-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#login-form > div,
#register-form > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#login-form label,
#register-form label {
  font-weight: 500;
  color: #1f1f1f;
}

#login-form input,
#register-form input {
  padding: 12px;
  border: 1px solid #ded8cf;
  border-radius: 6px;
  font-size: 14px;
}

#login-form button,
#register-form button {
  padding: 12px;
  background: #1f1f1f;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 8px;
}

#login-form button:hover,
#register-form button:hover {
  background: #5f4a31;
}

.auth-form-wrapper p {
  text-align: center;
  margin-top: 16px;
  color: #77716a;
  font-size: 14px;
}

.auth-form-wrapper button[type="button"] {
  background: none;
  color: #5f4a31;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  font: inherit;
}

.auth-form-wrapper button[type="button"]:hover {
  color: #1f1f1f;
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

#logout-button {
  padding: 8px 12px;
  background: #9f3a38;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

#logout-button:hover {
  background: #7f2a28;
}

.gallery-updates-indicator {
  cursor: pointer;
  color: #5f4a31;
  font-weight: 600;
  text-decoration: underline;
}

.gallery-list-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
