html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Pixelify Sans", monospace;
  background: radial-gradient(circle at top, #242424 0%, #1b1b1b 70%);
  color: #e6e6e6;
  overflow: hidden;
}

* { box-sizing: border-box; }

/* ---------- top bar (separates home/back nav from the rest of the UI) ---------- */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #1b1b1b;
  border-bottom: 2px dashed rgba(230, 230, 230, 0.25);
  z-index: 9998;
  pointer-events: none;
}

.top-bar > * { pointer-events: auto; }

/* ---------- left/right frame lines ---------- */
.frame-line {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px dashed rgba(230, 230, 230, 0.25);
  z-index: 9998;
  pointer-events: none;
}

.frame-line-left { left: 0; }
.frame-line-right { right: 0; border-left: none; border-right: 2px dashed rgba(230, 230, 230, 0.25); }

/* ---------- top links (matches cabinet/opencabinet) ---------- */
.home-link, .back-link {
  position: fixed;
  top: 20px;
  padding: 8px 16px;
  background: rgba(18, 18, 18, 0.85);
  color: #e6e6e6;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.9rem;
  z-index: 9999;
  transition: all 0.3s ease;
}

.home-link { left: 20px; }
.back-link { left: 100px; }

.home-link:hover, .back-link:hover {
  background: rgba(18, 18, 18, 0.95);
  transform: translateX(-2px);
  color: #ffffff;
}

.drawer-title {
  position: fixed;
  top: 20px;
  right: 20px;
  margin: 0;
  padding: 8px 16px;
  background: rgba(18, 18, 18, 0.85);
  color: #e6e6e6;
  border-radius: 6px;
  font-size: 0.9rem;
  z-index: 9999;
}

/* ---------- mobile category toggle ---------- */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: rgba(18, 18, 18, 0.9);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  color: #e6e6e6;
  font-family: inherit;
  font-size: 0.85rem;
  z-index: 9999;
  cursor: pointer;
}

/* ---------- layout ---------- */
.layout {
  display: flex;
  height: 100vh;
  padding-top: 70px;
}

/* ---------- sidebar ---------- */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 10px 14px 40px 14px;
  border-right: 1px solid rgba(255,255,255,0.08);
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.cat-group { margin-bottom: 18px; }

.cat-title {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9a9a9a;
  margin: 0 0 8px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 4px;
}

.uni-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  color: #d8d8d8;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.uni-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.2);
}

.uni-btn.active {
  background: rgba(180, 140, 90, 0.2);
  border-color: rgba(200, 160, 100, 0.6);
  color: #ffd9a0;
  font-weight: bold;
}

/* ---------- viewer ---------- */
.viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  position: relative;
}

.image-stage {
  position: relative;
  width: min(62vw, 780px);
  height: 74vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  image-rendering: auto;
  border-radius: 4px;
  border: 2px dashed rgba(230, 230, 230, 0.25);
}

.hotspot-layer {
  position: absolute;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(18, 18, 18, 0.75);
  border: 2px solid rgba(230, 230, 230, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #e6e6e6;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.hotspot:hover, .hotspot.active {
  background: rgba(230, 230, 230, 0.9);
  color: #121212;
  border-color: #ffffff;
  transform: translate(-50%, -50%) scale(1.15);
}

.uniform-caption {
  margin-top: 14px;
  text-align: center;
  max-width: 640px;
}

.uniform-caption h2 {
  margin: 0 0 4px 0;
  font-size: 1.3rem;
  letter-spacing: 0.03em;
}

.uniform-caption p {
  margin: 0;
  font-size: 0.9rem;
  color: #b7b7b7;
  line-height: 1.4;
}

/* ---------- detail / zoom panel ---------- */
.detail-panel {
  width: 300px;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,0.08);
  padding: 24px 18px;
  overflow-y: auto;
}

.detail-panel::-webkit-scrollbar { width: 6px; }
.detail-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.detail-panel-heading {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a8a8a;
  margin: 0 0 12px 0;
}

.detail-zoom {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background: #141414;
  border: 2px dashed rgba(230, 230, 230, 0.25);
}

.detail-zoom-inner {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-color: #141414;
  transition: background-position 0.3s ease, background-size 0.3s ease, opacity 0.2s ease;
  opacity: 0;
}

.detail-zoom-inner.visible { opacity: 1; }

.detail-zoom-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255,255,255,0.8);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.detail-zoom-marker.visible { opacity: 0.9; }

.detail-text {
  margin-top: 16px;
}

.detail-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(230,230,230,0.9);
  color: #121212;
  font-size: 0.68rem;
  font-weight: bold;
  margin-bottom: 8px;
}

.detail-label {
  margin: 4px 0 6px 0;
  font-size: 1rem;
  color: #f0f0f0;
}

.detail-note {
  margin: 0;
  font-size: 0.85rem;
  color: #b7b7b7;
  line-height: 1.5;
}

/* ---------- mobile ---------- */
@media (max-width: 768px), (pointer: coarse) {
  html, body { overflow: auto; }

  .home-link, .back-link, .drawer-title {
    font-size: 0.78rem;
    padding: 6px 12px;
    top: 10px;
  }
  .home-link { left: 10px; }
  .back-link { left: 78px; }
  .drawer-title { right: 10px; }

  .top-bar { height: 48px; }

  .mobile-menu-toggle { display: block; }

  .layout {
    flex-direction: column;
    height: auto;
    padding-top: 60px;
  }

  .sidebar {
    width: 100%;
    max-height: 0;
    overflow: hidden;
    padding: 0 14px;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    transition: max-height 0.3s ease, padding 0.3s ease;
  }

  .sidebar.open {
    max-height: 60vh;
    padding: 14px 14px 20px 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .viewer {
    padding: 16px 10px 24px 10px;
  }

  .image-stage {
    width: 100%;
    height: 50vh;
    max-width: 100%;
  }

  .detail-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 18px 16px 90px 16px;
  }

  .detail-zoom {
    max-width: 280px;
    margin: 0 auto;
  }
}
