:root {
  --bg: #0b1020;
  --panel: #101a33;
  --panel-2: #0f172a;
  --text: #f4f6ff;
  --muted: #b6c0da;
  --link: #79b8ff;
  --accent: #7c3aed;
  --border: rgba(255, 255, 255, 0.12);
  --ring: rgba(121, 184, 255, 0.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(900px circle at 10% 0%, rgba(121, 184, 255, 0.18), transparent 45%),
    radial-gradient(900px circle at 90% 15%, rgba(124, 58, 237, 0.14), transparent 45%),
    var(--bg);
  background-attachment: fixed, fixed, fixed;
  background-repeat: no-repeat;
  color: var(--text);
  line-height: 1.45;
  overflow: hidden;
}

h1, h2, h3 { line-height: 1.15; }
h1 { font-size: 2rem; margin: 0.25rem 0 0.75rem; }
h2 { font-size: 1.4rem; margin: 1.25rem 0 0.5rem; }
h3 { font-size: 1.1rem; margin: 1rem 0 0.35rem; }
p { margin: 0.5rem 0; }

.container {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
  transition: color 160ms ease;
}

.brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.brand:hover {
  color: var(--link);
}

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
}

.sidebar {
  width: 280px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%), var(--panel);
  border-right: 1px solid var(--border);
  padding: clamp(0.35rem, 1.2vh, 0.65rem) clamp(0.55rem, 1.6vw, 0.85rem);
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  margin-top: clamp(0.25rem, 0.9vh, 0.6rem);
  overflow-y: auto;
  flex: 1;
  scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.menu-button {
  display: none;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.45rem 0.7rem;
  transition: transform 120ms ease, background-color 160ms ease, border-color 160ms ease;
}

.menu-button:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.menu-button:active {
  transform: translateY(0);
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 0.28rem 0.4rem;
  border-radius: 0.55rem;
  font-size: clamp(0.84rem, 1.45vh, 0.97rem);
  line-height: 1.25;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  transform: translateX(2px);
}

.nav-link:focus-visible,
.menu-button:focus-visible,
.gallery-close:focus-visible,
.gallery-prev:focus-visible,
.gallery-next:focus-visible,
.image-rotator:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.content {
  padding: clamp(0.9rem, 2.5vh, 1.25rem) 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(255, 255, 255, 0.06);
}

/* Modern, subtle scrollbar (WebKit/Blink) */
.content::-webkit-scrollbar {
  width: 10px;
}

.content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

.content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  border: 3px solid rgba(0, 0, 0, 0);
  background-clip: content-box;
}

.content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
  border: 3px solid rgba(0, 0, 0, 0);
  background-clip: content-box;
}

.content > :first-child { margin-top: 0; }

a { color: var(--link); }
img { max-width: 100%; height: auto; }
iframe { max-width: 100%; }

.home-logo {
  text-align: center;
  margin: 0 0 1rem;
}

.home-logo img {
  display: block;
  margin: 0 auto;
}

.home-intro {
  text-align: center;
  margin: 0 auto 1rem;
  max-width: 72ch;
}

.home-intro p {
  color: var(--muted);
}

.embedded-video {
  margin: 0.75rem auto;
  max-width: 760px;
}
  .embedded-video .video-fallback-note {
    margin-top: 0.25rem;
    font-size: 0.9em;
    opacity: 0.8;
  }

.embedded-video video {
  width: 100%;
  height: auto;
  display: block;
}

.video-meta {
  text-align: center;
}

.video-title {
  font-weight: 600;
}

.video-download {
  display: block;
  margin-top: 0.15rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 0.75rem 0;
  color: var(--muted);
}

.site-footer .container {
  text-align: center;
}

.legacy-content table { width: 100%; }
.legacy-content td { vertical-align: top; }

.legacy-content {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  overflow-x: auto;
}

.legacy-content table { max-width: 100%; }
.legacy-content iframe,
.legacy-content embed,
.legacy-content object {
  max-width: 100%;
}

/* Hard-hide common legacy embed artifacts */
.legacy-content object,
.legacy-content embed,
.legacy-content applet {
  display: none;
}

/* Multi-image rotator + gallery */
.legacy-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  align-items: start;
}

.legacy-gallery img {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

/* New image gallery grid */
.new-image-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: start;
}

@media (max-width: 1000px) {
  .new-image-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 740px) {
  .new-image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
  .new-image-grid { grid-template-columns: 1fr; }
}

.new-image-grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  content-visibility: auto;
  contain-intrinsic-size: 640px 640px;
}

.image-rotator {
  display: block;
  width: 100%;
  max-width: 100%;
  cursor: pointer;
  position: relative;
}

.image-rotator img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  transition: opacity 520ms ease;
  will-change: opacity;
}

.image-rotator img.is-active {
  opacity: 1;
}

.gallery-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.gallery-overlay[hidden] {
  display: none;
}

.gallery-dialog {
  width: min(1000px, 100%);
  max-height: calc(100vh - 2rem);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.75rem;
}

.gallery-topbar {
  display: flex;
  justify-content: flex-end;
}

.gallery-close,
.gallery-prev,
.gallery-next {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.45rem 0.7rem;
  transition: transform 120ms ease, background-color 160ms ease, border-color 160ms ease;
}

.gallery-close:hover,
.gallery-prev:hover,
.gallery-next:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.gallery-stage {
  position: relative;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
}

.gallery-stage img {
  max-width: 100%;
  max-height: calc(100vh - 10rem);
}

.gallery-controls {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.legacy-content a { word-break: break-word; }

@media (max-width: 780px) {
  body {
    /* Mobile browsers often struggle with fixed backgrounds */
    background-attachment: scroll;
  }

  .menu-button {
    display: inline-flex;
    position: fixed;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
  }

  .menu-button:hover {
    transform: translate(-50%, -1px);
  }

  .menu-button:active {
    transform: translate(-50%, 0);
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: auto;
    z-index: 40;
    transform: translateX(-100%);
    overflow-y: auto;
    transition: transform 220ms cubic-bezier(0.2, 0.9, 0.2, 1);
  }

  .sidebar[data-open="true"] {
    transform: translateX(0);
  }

  .content {
    padding-top: 3.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * {
    transition: none !important;
    animation: none !important;
  }
}
