/* =========================
   Base layout helpers
   ========================= */

.wrap {
  max-width: 980px;
  margin: 0 auto;
}

textarea,
input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

pre,
code {
  overflow-x: auto;
}

/* =========================
   Gallery layout
   ========================= */

.gallery-grid {
  margin-left: -8px;
  margin-right: -8px;
}

.gallery-item {
  padding-left: 8px;
  padding-right: 8px;
  margin-bottom: 16px;
}

.gallery-img {
  width: 100%;
  display: block;
  object-fit: cover;
  border-radius: 8px;
}

/* =========================
   Aspect ratios
   ========================= */

.ratio-16-9 {
  aspect-ratio: 16 / 9;
}

.ratio-4-3 {
  aspect-ratio: 4 / 3;
}

.ratio-1-1 {
  aspect-ratio: 1 / 1;
}

/* =========================
   Fixed thumbnail heights
   (used only when no ratio)
   ========================= */

.thumb-140 {
  height: 140px;
}

.thumb-200 {
  height: 200px;
}

.thumb-300 {
  height: 300px;
}
/* =========================
   Dark mode (prefers-color-scheme)
   ========================= */
@media (prefers-color-scheme: dark) {
  body.w3-light-grey {
    background-color: #111 !important;
    color: #e8e8e8;
  }

  .w3-white {
    background-color: #1b1b1b !important;
    color: #e8e8e8;
  }

  .w3-bar.w3-white {
    background-color: #1b1b1b !important;
    color: #e8e8e8;
  }

  .w3-border-bottom,
  .w3-border {
    border-color: #333 !important;
  }

  .w3-card {
    box-shadow: none;
  }

  a {
    color: #9bd1ff;
  }

  .w3-text-grey,
  .w3-small.w3-text-grey {
    color: #b0b0b0 !important;
  }

  pre, code {
    background: #161616;
  }

  /* Buttons (keep readable) */
  .w3-button.w3-light-grey {
    background-color: #2a2a2a !important;
    color: #e8e8e8 !important;
  }
}
/* =========================
   Manual theme override
   ========================= */

/* Force light */
html[data-theme="light"] body {
  background-color: #f1f1f1;
  color: #000;
}

html[data-theme="light"] .w3-white {
  background-color: #fff;
  color: #000;
}

/* Force dark */
html[data-theme="dark"] body {
  background-color: #111;
  color: #e8e8e8;
}

html[data-theme="dark"] .w3-white {
  background-color: #1b1b1b;
  color: #e8e8e8;
}
