.museum-panel {
  padding: 16px 18px 20px;
  background: var(--chrome);
}

.museum-panel .hero {
  text-align: center;
}

/* ---------- "on this day" strip ---------- */

.museum-otd {
  /* Hug the icons and sit centered, instead of a wide bar with empty space. */
  width: fit-content;
  max-width: 100%;
  margin: 12px auto 2px;
  padding: 8px 16px 10px;
  background: linear-gradient(180deg, #fbfbf7, #edf1f7);
  border: 1px solid #c7cfdb;
  border-radius: 8px;
  text-align: center;
}

.museum-otd-head {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.museum-otd-title {
  font-weight: bold;
  color: var(--title-start);
  font-size: .9rem;
}

.museum-otd-date {
  /* Now inline inside the sentence, so it matches the title styling. */
  color: var(--title-start);
  font-weight: bold;
  font-size: .9rem;
}

/* Tagline relocated to sit just above the search box. */
.museum-tagline {
  text-align: center;
  margin: 0 0 2px;
}

.museum-otd-strip {
  display: flex;
  gap: 12px;
  justify-content: center;
  overflow-x: auto;
  padding-bottom: 2px;
  max-width: 100%;
  scrollbar-width: thin;
}

.museum-otd-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 52px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.museum-otd-icon {
  width: 52px;
  height: 52px;
  /* content box = 52 - 2px border - 2*2px padding = 48px (native icon size).
     Smooth rendering (not pixelated) avoids the shimmer/warp that pixelated
     scaling causes on fractional-DPR screens at this small size. */
  padding: 2px;
  border: 1px solid #9aa6b2;
  border-radius: 4px;
  background-color: #e9e9e9;
  background-repeat: no-repeat;
  background-position: center;
  background-origin: content-box;
  background-clip: content-box;
  box-shadow: inset 0 0 0 2px #e9e9e9;
  image-rendering: auto;
}

.museum-otd-item:hover .museum-otd-icon {
  border-color: var(--title-end);
  outline: 2px solid rgba(58,110,165,.4);
}

.museum-otd-year {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 8px;
  color: var(--ink-muted);
}

/* ---------- toolbar: search / sort / categories ---------- */

.museum-toolbar {
  margin: 14px auto 10px;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.museum-search-row {
  display: flex;
  gap: 8px;
}

.museum-search {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 12px;
  border: 2px inset #b8b5a8;
  border-radius: 3px;
  font: inherit;
  /* 16px min so iOS Safari doesn't auto-zoom when this input is focused. */
  font-size: 16px;
  background: #fff;
}

.museum-search:focus {
  outline: 2px solid var(--title-end);
  outline-offset: 0;
}

.museum-sort {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid #7f9db9;
  border-radius: 3px;
  font: inherit;
  background: #fff;
}

.museum-cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  /* Narrower than the toolbar so the ~10 category pills + NSFW toggle split
     into two balanced rows instead of 9-on-top and a lonely straggler. */
  max-width: 560px;
  margin: 0 auto;
}

.museum-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid #7f9db9;
  border-radius: 999px;
  background: linear-gradient(180deg, #fdfdfd, #e7ebf2);
  color: var(--title-start);
  font-size: .72rem;
  font-weight: bold;
  cursor: pointer;
  line-height: 1.4;
}

.museum-chip:hover { filter: brightness(1.03); }

.museum-chip.is-on {
  background: linear-gradient(180deg, #3a6ea5, #0a246a);
  color: #fff;
  border-color: #0a246a;
}

.museum-chip-count {
  font-size: .62rem;
  opacity: .7;
  font-weight: normal;
}
.museum-chip.is-on .museum-chip-count { opacity: .85; }

.museum-toolbar-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.museum-result-count {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 10px;
  color: var(--ink-muted);
}

.museum-naughty-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  /* Pill-shaped so it sits in line with the category chips, but pink + dashed
     so it still reads as the distinct "adult content" control, not a category. */
  padding: 3px 10px;
  border: 1px dashed #d09a9a;
  border-radius: 999px;
  background: #fbf1f1;
  font-size: .72rem;
  font-weight: bold;
  color: #8a2a2a;
  cursor: pointer;
  user-select: none;
  line-height: 1.4;
}
.museum-naughty-toggle input { width: 14px; height: 14px; margin: 0; }

/* ---------- focused viewer + detail ---------- */

.museum-stage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px 26px;
  margin: 6px auto 14px;
  max-width: 760px;
}

.museum-viewer-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.museum-viewer {
  width: 240px;
  height: 240px;
  background: #e9e9e9;
  border: 3px solid #000;
  border-radius: 6px;
  box-shadow: 0 0 18px 2px rgba(255,255,255,.75);
  overflow: hidden;
  cursor: grab;
  touch-action: pan-y;
}

.museum-viewer:active { cursor: grabbing; }

.museum-icon {
  width: 100%;
  height: 100%;
  /* Padded tile: the icon sits inside a light-gray matte, classic BadassBuddy. */
  padding: 18px;
  background-color: #e9e9e9;
  background-repeat: no-repeat;
  background-origin: content-box;
  background-clip: content-box;
  image-rendering: pixelated;
  transition: opacity .12s ease;
}

.museum-icon.is-changing { opacity: 0; }

.museum-nav-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid #7f9db9;
  background: linear-gradient(180deg, #fdfdfd, #e4e4e4);
  font-size: 22px;
  line-height: 1;
  color: var(--title-start);
  box-shadow: inset 1px 1px 0 #fff;
  cursor: pointer;
}

.museum-nav-btn:hover { filter: brightness(1.05); }

.museum-detail {
  flex: 1 1 260px;
  min-width: 240px;
  max-width: 340px;
  text-align: left;
}

.museum-label {
  display: block;
  font-family: Tahoma, Verdana, "Segoe UI", Arial, sans-serif;
  font-size: 24px;
  font-weight: bold;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--title-start);
  margin-bottom: 12px;
  word-break: break-word;
}

.museum-meta-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.museum-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-size: .82rem;
}

.museum-meta-key {
  font-weight: bold;
  color: var(--ink-muted);
}

.museum-meta-val {
  color: var(--ink);
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.museum-meta-naughty {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  background: #f6dede;
  border: 1px solid #e0b4b4;
  color: #8a2a2a;
  font-size: .72rem;
  font-weight: bold;
  white-space: nowrap;
}

.museum-meta-cat {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  background: linear-gradient(180deg, #fdfdfd, #e7ebf2);
  border: 1px solid #7f9db9;
  font-size: .74rem;
  font-weight: bold;
  color: var(--title-start);
  cursor: pointer;
}
.museum-meta-cat:hover { filter: brightness(1.04); }

.museum-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.museum-counter {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 10px;
  color: var(--ink-muted);
  margin-left: auto;
}

/* ---------- results grid ---------- */

.museum-grid-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  max-width: 900px;
  margin: 6px auto 6px;
  padding: 0 2px 4px;
  border-bottom: 1px solid var(--chrome-dark);
}

.museum-grid-title {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 11px;
  color: var(--title-start);
}

.museum-grid-hint {
  font-size: .7rem;
  color: var(--ink-muted);
}

.museum-grid {
  max-width: 900px;
  margin: 0 auto;
  max-height: 560px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, 108px);
  gap: 18px;
  justify-content: center;
  padding: 24px;
  background: #cfd8cf;
  border: 2px inset #b8b5a8;
  border-radius: 4px;
}

.museum-cell {
  position: relative;
  width: 108px;
  height: 108px;
  /* Padded tile: content box is exactly 96px so icons render at a clean 2x of
     the 48px native art (crisp, no fractional warp) and static sprites clip
     cleanly with no neighbor bleed. 108 - 2px border - 2*5px padding = 96px. */
  padding: 5px;
  border: 1px solid #9aa6b2;
  border-radius: 3px;
  background-color: #e9e9e9;
  background-repeat: no-repeat;
  background-position: center;
  background-origin: content-box;
  background-clip: content-box;
  /* Fill the padding ring with the same gray so the matte reaches the border. */
  box-shadow: inset 0 0 0 5px #e9e9e9;
  image-rendering: pixelated;
  cursor: pointer;
}

.museum-cell:hover {
  border-color: var(--title-end);
  outline: 2px solid rgba(58,110,165,.45);
}

.museum-cell.is-current {
  border-color: #ffcc00;
  box-shadow: inset 0 0 0 5px #e9e9e9, 0 0 0 2px #ffcc00, 0 0 10px rgba(255,204,0,.6);
}

.museum-cell.is-naughty::after {
  content: "🔞";
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: 12px;
  line-height: 1;
}

.museum-empty {
  text-align: center;
  color: var(--ink-muted);
  font-size: .85rem;
  padding: 24px 12px;
}

@media (max-width: 640px) {
  .museum-viewer { width: 200px; height: 200px; }
  .museum-viewer-frame { gap: 8px; }
  .museum-stage { gap: 14px; }
  .museum-detail { text-align: center; max-width: none; }
  .museum-meta-rows, .museum-keywords, .museum-controls { justify-content: center; }
  .museum-counter { margin-left: 0; width: 100%; text-align: center; }
  /* Reclaim the window's own side padding on phones so the 96px icons can
     pack 3-across on most devices. Content box stays 96px (104 - 2px border
     - 2*3px padding), so icons keep their crisp 2x render with a thin matte. */
  .museum-panel { padding: 14px 8px 16px; }
  .museum-grid { grid-template-columns: repeat(auto-fill, 104px); gap: 6px; padding: 6px; }
  .museum-cell {
    width: 104px;
    height: 104px;
    padding: 3px;
    box-shadow: inset 0 0 0 3px #e9e9e9;
  }
  .museum-cell.is-current {
    box-shadow: inset 0 0 0 3px #e9e9e9, 0 0 0 2px #ffcc00, 0 0 10px rgba(255,204,0,.6);
  }
}