:root {
  --heritage-red: #8d2424;
  --heritage-red-dark: #671919;
  --heritage-gold: #c09853;
  --heritage-gold-soft: #ead8b7;
  --heritage-cream: #f9f6f0;
  --heritage-ink: #2f2d2b;
  --heritage-muted: #6b665f;
  --line: rgba(141, 36, 36, 0.14);
  --shadow-soft: 0 18px 45px rgba(47, 45, 43, 0.12);
  --shadow-card: 0 14px 30px rgba(47, 45, 43, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--heritage-cream);
  color: var(--heritage-ink);
  font-family: "Roboto", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

a {
  color: inherit;
}

.museum-shell {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.78), rgba(249,246,240,0.92)),
    var(--heritage-cream);
}

.museum-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(103, 25, 25, 0.96);
  color: #fff;
  border-bottom: 1px solid rgba(234, 216, 183, 0.45);
  box-shadow: 0 8px 24px rgba(47, 45, 43, 0.18);
  backdrop-filter: blur(14px);
}

.museum-nav {
  min-height: 72px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.museum-brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.11);
  color: var(--heritage-gold-soft);
  border: 1px solid rgba(234, 216, 183, 0.42);
}

.museum-nav-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: rgba(255,255,255,0.88);
  font-weight: 700;
  transition: color 180ms ease, transform 180ms ease;
}

.museum-nav-link:hover,
.museum-nav-link:focus-visible {
  color: var(--heritage-gold-soft);
  transform: translateY(-1px);
}

.museum-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 0.78rem 1.1rem;
  font-weight: 800;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, color 180ms ease;
}

.museum-button-primary {
  background: var(--heritage-gold);
  color: #fff;
  box-shadow: 0 12px 24px rgba(141, 36, 36, 0.22);
}

.museum-button-primary:hover {
  background: #ab8446;
  transform: translateY(-1px);
}

.museum-button-outline {
  border: 1px solid rgba(255,255,255,0.38);
  color: #fff;
}

.museum-button-outline:hover {
  background: rgba(255,255,255,0.11);
  color: var(--heritage-gold-soft);
}

.museum-hero {
  min-height: min(650px, calc(100vh - 72px));
  display: flex;
  align-items: center;
  color: #fff;
  background-image:
    linear-gradient(90deg, rgba(71, 18, 18, 0.88), rgba(71, 18, 18, 0.56), rgba(47, 45, 43, 0.46)),
    url("./bg.jpg");
  background-size: cover;
  background-position: center;
}

.museum-hero h1,
.museum-hero p {
  max-width: 100%;
  overflow-wrap: break-word;
}

.museum-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(234, 216, 183, 0.58);
  background: rgba(0, 0, 0, 0.24);
  color: var(--heritage-gold-soft);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.museum-section {
  padding: clamp(52px, 7vw, 92px) 0;
}

.museum-section-muted {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.56), rgba(249,246,240,1)),
    var(--heritage-cream);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.museum-section-heading {
  color: var(--heritage-red);
  font-family: "Merriweather", Georgia, serif;
  font-weight: 800;
  line-height: 1.18;
}

.museum-section-heading::after {
  content: "";
  display: block;
  width: 86px;
  height: 3px;
  margin: 18px auto 0;
  background: var(--heritage-gold);
}

.museum-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 22px;
}

@media (min-width: 640px) {
  .museum-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .museum-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
  .museum-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.museum-card {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(141, 36, 36, 0.12);
  box-shadow: 0 6px 18px rgba(47,45,43,0.08);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.museum-card:hover {
  transform: translateY(-3px);
  border-color: rgba(192, 152, 83, 0.75);
  box-shadow: var(--shadow-card);
}

.museum-card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #efe8dc;
}

.museum-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 260ms ease;
}

.museum-card:hover .museum-card-media img {
  transform: scale(1.035);
}

.museum-card-body {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.museum-card-title {
  min-height: 3.45em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--heritage-ink);
  font-family: "Merriweather", Georgia, serif;
  font-weight: 800;
  line-height: 1.42;
}

.museum-card-action {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(47,45,43,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--heritage-red);
  font-weight: 800;
}

.museum-empty,
.museum-error {
  grid-column: 1 / -1;
  border: 1px dashed rgba(141, 36, 36, 0.28);
  background: rgba(255,255,255,0.7);
  color: var(--heritage-muted);
  padding: 28px;
  text-align: center;
  border-radius: 8px;
}

.museum-error {
  color: #9f1d1d;
  border-color: rgba(159, 29, 29, 0.32);
}

.museum-skeleton {
  min-height: 360px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid rgba(141, 36, 36, 0.1);
  overflow: hidden;
}

.museum-skeleton::before {
  content: "";
  display: block;
  height: 58%;
  background: linear-gradient(90deg, #eee7dd 0%, #f8f3eb 50%, #eee7dd 100%);
  background-size: 220% 100%;
  animation: museum-shimmer 1.3s infinite;
}

.museum-skeleton::after {
  content: "";
  display: block;
  height: 42%;
  margin: 20px;
  border-radius: 8px;
  background: linear-gradient(90deg, #efe8dc 0%, #f8f3eb 50%, #efe8dc 100%);
  background-size: 220% 100%;
  animation: museum-shimmer 1.3s infinite;
}

@keyframes museum-shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

.loader {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 5px solid rgba(192, 152, 83, 0.28);
  border-top-color: var(--heritage-red);
  animation: spin 900ms linear infinite;
}

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

.museum-footer {
  background: var(--heritage-red-dark);
  color: #fff;
  border-top: 6px solid var(--heritage-gold);
}

.viewer-toolbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(103,25,25,0.94);
  color: #fff;
  border-bottom: 1px solid rgba(234,216,183,0.4);
}

.viewer-control {
  min-height: 42px;
  border-radius: 8px;
  padding: 0.64rem 0.9rem;
  background: rgba(255,255,255,0.92);
  color: var(--heritage-red);
  font-weight: 800;
  border: 1px solid rgba(192,152,83,0.45);
  transition: background 180ms ease, transform 180ms ease;
}

.viewer-control:hover {
  background: #fff;
  transform: translateY(-1px);
}

.viewer-control-dark {
  background: var(--heritage-red);
  color: #fff;
  border-color: rgba(234,216,183,0.45);
}

.viewer-panel {
  background: rgba(255, 255, 255, 0.92);
  color: var(--heritage-ink);
  border: 1px solid rgba(141, 36, 36, 0.16);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

#loading-overlay .viewer-panel {
  width: min(384px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
}

#loading-overlay .vr-panel {
  width: min(384px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
}

.admin-card {
  border-radius: 8px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(141,36,36,0.13);
  box-shadow: var(--shadow-soft);
}

.admin-shell .admin-section {
  display: none;
}

.admin-shell .admin-section.active {
  display: block;
}

.admin-topbar {
  position: sticky;
}

.admin-nav {
  min-height: 88px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.admin-title-wrap h1 {
  line-height: 1.22;
  padding-top: 2px;
  padding-bottom: 2px;
}

.admin-tab {
  min-height: 44px;
  border-radius: 8px;
  padding: 0.7rem 0.95rem;
  color: var(--heritage-muted);
  font-weight: 800;
  background: #fff;
  border: 1px solid rgba(141,36,36,0.12);
}

.admin-tab.active {
  background: var(--heritage-red);
  color: #fff;
  border-color: var(--heritage-red);
}

.admin-tab.is-muted {
  opacity: 0.86;
}

.form-input {
  width: 100%;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(141,36,36,0.18);
  background: #fff;
  color: var(--heritage-ink);
  padding: 0.7rem 0.82rem;
  outline: none;
}

.form-input:focus {
  border-color: var(--heritage-gold);
  box-shadow: 0 0 0 3px rgba(192,152,83,0.18);
}

.status-pill {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-weight: 800;
}

.file-dropzone {
  border: 1.5px dashed rgba(141, 36, 36, 0.28);
  background: #fffaf2;
  border-radius: 8px;
  padding: 18px;
  transition: border-color 180ms ease, background 180ms ease;
}

.file-dropzone.dragover {
  border-color: var(--heritage-gold);
  background: #fff4df;
}

.native-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.selected-file-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.selected-file-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(141,36,36,0.12);
  background: #fff;
  border-radius: 8px;
  padding: 10px;
}

.selected-file-row img {
  width: 72px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #efe8dc;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.media-card {
  border: 1px solid rgba(141,36,36,0.13);
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
}

.media-card.is-selected {
  outline: 3px solid rgba(192,152,83,0.48);
  border-color: var(--heritage-gold);
}

.media-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #efe8dc;
}

.block-card {
  border: 1px solid rgba(141,36,36,0.14);
  background: #fff;
  border-radius: 8px;
  padding: 14px;
}

.block-card textarea {
  min-height: 92px;
}

.dev-placeholder {
  border: 1px dashed rgba(141,36,36,0.28);
  border-radius: 8px;
  background: #fffaf2;
  padding: 28px;
  color: var(--heritage-muted);
}

@media (max-width: 767px) {
  body,
  .museum-shell {
    max-width: 100vw;
    overflow-x: hidden;
  }

  body .container {
    width: 100% !important;
    max-width: 100vw !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .museum-nav {
    min-height: 64px;
    gap: 12px;
    width: 100%;
    max-width: 100vw;
    padding-left: 16px;
    padding-right: 16px;
  }

  .museum-nav > a {
    min-width: 0;
  }

  .museum-nav > a > span:last-child {
    min-width: 0;
  }

  .museum-brand-mark {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
  }

  .museum-header .museum-button {
    flex: 0 0 auto;
  }

  .museum-header button[aria-controls="mobile-menu"] {
    display: inline-flex !important;
    margin-left: auto;
  }

  .museum-hero {
    min-height: 500px;
    align-items: flex-end;
    padding: 78px 0 42px;
  }

  .museum-hero h1 {
    font-size: clamp(1.62rem, 7.7vw, 2rem);
    line-height: 1.12;
  }

  .museum-hero p {
    font-size: 1rem;
    line-height: 1.55;
  }

  .museum-hero .container,
  .museum-hero .max-w-3xl,
  .museum-hero .flex {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    min-width: 0;
  }

  .museum-hero .museum-button {
    width: 100%;
    min-width: 0;
  }

  .museum-eyebrow {
    max-width: 100%;
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    white-space: normal;
  }

  .museum-section {
    padding: 44px 0;
  }

  .museum-section-heading {
    font-size: clamp(1.85rem, 8vw, 2.25rem);
    overflow-wrap: break-word;
  }

  .museum-section p {
    max-width: 100%;
    overflow-wrap: break-word;
  }

  .museum-card-body {
    min-height: 168px;
    padding: 16px;
  }

  .viewer-toolbar {
    flex-wrap: wrap;
    padding: 10px 14px;
  }

  #loading-overlay {
    justify-content: flex-start !important;
    padding-left: 16px;
    padding-right: 16px;
  }

  .viewer-control {
    min-height: 44px;
  }

  #ai-box {
    width: min(360px, calc(100vw - 24px)) !important;
    height: min(540px, calc(100vh - 110px)) !important;
    right: 0 !important;
  }

  #ai-toggle {
    width: 54px !important;
    height: 54px !important;
  }
}
