:root {
  --bg: #f7f8fc;
  --panel: #ffffff;
  --text: #1e2330;
  --muted: #667085;
  --primary: #4f46e5;
  --accent: #0ea5e9;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8f9ff 0%, #f3f5fb 100%);
}

.wg-main,
.wg-header {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
}

.wg-header-content {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: flex-start;
  gap: 1rem;
}

.wg-header-brand {
  grid-column: 2;
  text-align: center;
}

#auth-toggle-btn {
  grid-column: 3;
  justify-self: end;
}

.wg-title {
  margin: 0.25rem 0;
}
.wg-subtitle {
  margin: 0;
  color: var(--muted);
}

.wg-card,
.wg-gallery-header,
.wg-empty-state {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
}

.wg-add-image-panel {
  width: 100%;
  max-width: 36rem;
}

#add-image-form {
  margin-top: 1rem;
}

.wg-form,
.wg-comment-form {
  display: grid;
  gap: 0.65rem;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: #fff;
}

.wg-btn {
  border: none;
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
}

.wg-btn-primary {
  background: var(--primary);
  color: #fff;
}
.wg-btn-accent {
  background: var(--accent);
  color: #fff;
}
.wg-btn-danger {
  background: var(--danger);
  color: #fff;
}
.wg-btn-secondary {
  background: #111827;
  color: #fff;
}

.wg-btn-back {
  display: inline-grid;
  width: 5rem;
  height: 2.25rem;
  place-items: center;
  border: 1px solid #d0d5dd;
  padding: 0;
  color: var(--primary);
  background: #f8f9ff;
  font-size: 1.7rem;
  font-weight: 700;
}

.wg-btn-back:hover {
  border-color: var(--primary);
  background: #eef2ff;
}

.wg-btn-back:focus-visible {
  outline: 3px solid rgba(79, 70, 229, 0.2);
  outline-offset: 2px;
}

.wg-auth-message {
  margin: 0;
  color: var(--danger);
}

#auth-view {
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
}

.wg-auth-message:empty {
  display: none;
}

.wg-auth-form-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.wg-auth-form-header h3 {
  margin: 0;
  font-size: 1.7rem;
}

.wg-media-frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
}

/* Keep image ratio responsive */
.wg-image {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.wg-image:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.12);
}

.wg-card-horizontal {
  display: grid;
  grid-template-columns: 60% 1fr;
  gap: 1.5rem;
  align-items: start;
}

.wg-modal-content {
  grid-template-columns: 1fr;
}

.wg-feed .wg-card {
  width: 100%;
  height: 32rem;
  overflow: hidden;
}

.wg-feed .wg-card-horizontal {
  align-items: stretch;
}

.wg-feed .wg-card-left,
.wg-feed .wg-card-right {
  min-width: 0;
  min-height: 0;
}

.wg-feed .wg-media-frame {
  flex: 1;
  min-height: 0;
  background: #ffffff;
}

.wg-feed .wg-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wg-card-left {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wg-card-right {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wg-card-actions {
  display: flex;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.wg-open-comments-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: none;
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  background: #eef2ff;
  color: var(--text);
}

.wg-comment-count-text {
  font-weight: 700;
}

.wg-delete-image-btn {
  margin-left: auto;
}

.wg-inline-comments {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wg-feed .wg-inline-comments {
  min-height: 0;
  overflow-y: auto;
}

.wg-full-view-right-column {
  display: flex;
  flex-direction: column;
  height: auto;
  gap: 0.75rem;
}

.wg-comments-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
  border-bottom: 1px solid #f0f1f5;
}

.wg-comments-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.wg-comment-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.wg-comment-item {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.75rem;
}

.wg-comment-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0;
}

.wg-comment-author {
  font-weight: 700;
}

.wg-comment-date {
  margin-left: auto;
  color: var(--muted);
}

.wg-pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.wg-comment-form textarea {
  resize: none;
  height: 60px;
}

.wg-pagination-wrapper {
  flex-shrink: 0;
  padding: 0.25rem 0;
}

.wg-form-wrapper {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid #e5e7eb;
}

#full-view-image {
  max-height: 70vh;
  object-fit: contain;
  background-color: #fff;
}

#global-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

#global-loader.wg-hidden {
  display: none;
}

.wg-spinner {
  border: 6px solid #f3f3f3;
  border-top: 6px solid var(--primary);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  animation: spin 1s linear infinite;
}

/* Gallery Section Styles */
.wg-gallery-section {
  margin-bottom: 2rem;
}

.wg-my-gallery {
  padding: 1.25rem;
  border: 2px solid var(--primary);
  border-radius: 0.75rem;
  background: white;
}

.wg-gallery-title-with-back {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 0.75rem;
}

.wg-gallery-title-with-back .wg-btn-back {
  justify-self: start;
  align-self: center;
}

.wg-gallery-title-with-back h2 {
  grid-column: 2;
  text-align: center;
}

.wg-gallery-title-with-back h2,
.wg-gallery-owner {
  margin: 0;
}

.wg-gallery-owner {
  grid-column: 3;
  justify-self: end;
  margin-right: 2rem;
  font-size: 1.25rem;
}

.wg-gallery-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.wg-gallery-section-header h2,
.wg-gallery-section-header p {
  margin: 0;
}

.wg-gallery-title-editor {
  align-self: start;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.5rem;
}

.wg-gallery-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.wg-gallery-title-row input {
  flex: 1;
  min-width: 0;
}

.wg-gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.wg-gallery-card {
  padding: 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.75rem;
  background: white;
}

.wg-gallery-card-cover-frame {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 0.6rem;
  background: #eef2f7;
  color: var(--muted);
}

.wg-gallery-card-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.wg-gallery-card-cover:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.12);
}

.wg-gallery-card-cover-empty {
  text-align: center;
}

.wg-gallery-card-cover-icon {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 3rem;
}

.wg-gallery-card-title {
  margin-top: 0;
}

.wg-updates-indicator {
  position: sticky;
  top: 1rem;
  z-index: 10;
  display: block;
  width: fit-content;
  margin: 0 auto 1rem;
  padding: 0.65rem 1rem;
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow);
}

/* Utility */
.wg-hidden {
  display: none;
}

/* Media Queries */
@media (max-width: 768px) {
  .wg-main,
  .wg-header {
    padding: 0.75rem;
  }

  .wg-card-header {
    display: grid;
    gap: 0.5rem;
  }

  .wg-card-horizontal {
    grid-template-columns: 1fr;
  }

  .wg-feed .wg-card {
    height: 44rem;
  }

  .wg-feed .wg-card-horizontal {
    grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
  }

  .wg-full-view-right-column {
    height: auto;
  }
}

@media (max-width: 600px) {
  .wg-gallery-section-header,
  .wg-gallery-title-row {
    align-items: stretch;
    flex-direction: column;
  }
}
