:root {
  --bg: #121212;
  --panel: #1a1a1a;
  --panel-2: #222222;
  --ink: #ffffff;
  --muted: #b0b0b0;
  --line: #2a2a2a;
  --accent: #7c5cff;
  --accent-hover: #8f74ff;
  --danger: #f07178;
  --youtube: #ff0000;
  --discord: #5865f2;
  --twitter: #1d9bf0;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  --radius-sm: 10px;
  --max: 1180px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color-scheme: dark;
}

/* Same-document / cross-document soft fade (Chromium) */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 140ms;
  animation-timing-function: ease;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font);
  background: var(--bg);
  line-height: 1.45;
  position: relative;
  z-index: 0;
  isolation: isolate;
}

main,
.nav-shell,
.flash-stack,
.page-wrap,
.form-panel,
.simple-page {
  position: relative;
  z-index: 1;
}

/* Background media host is created in JS (shadow DOM). Debug preview: */
body.yt-bg-debug .nav-shell,
body.yt-bg-debug main,
body.yt-bg-debug .flash-stack {
  position: relative;
  z-index: 60;
}

.yt-debug-chip {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  margin: 0;
}

.yt-debug-chip button {
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.admin-yt-panel {
  margin-top: 1.35rem;
  padding: 1rem;
  border: 1px solid #333;
  border-radius: var(--radius);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-yt-panel h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-wrap {
  width: min(100% - 2rem, var(--max));
  margin: 0 auto;
}

/* Floating pill nav */
.nav-shell {
  position: sticky;
  top: 0.85rem;
  z-index: 40;
  display: flex;
  justify-content: center;
  padding: 0 1rem;
  margin-bottom: 1.75rem;
}

.site-nav {
  width: min(100%, 1040px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  background: #0e0e0e;
  border: 1px solid #242424;
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  padding-left: 0.35rem;
  white-space: nowrap;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.15rem;
  font-size: 0.95rem;
  color: #d8d8d8;
}

.nav-links a:hover,
.nav-links a.active {
  color: #fff;
}

.socials {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
}

.social {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  overflow: hidden;
}

.social svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
}

.social-yt svg {
  width: 18px;
  height: 18px;
}

.social-dc svg {
  width: 20px;
  height: 20px;
}

.social-yt { background: var(--youtube); }
.social-dc { background: var(--discord); }
.social-tw { background: var(--twitter); }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.5rem 0 1.35rem;
}

.toolbar h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 1.9rem);
  font-weight: 700;
}

.site-blurb {
  margin: -0.35rem 0 1.15rem;
  max-width: 52ch;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.filter {
  position: relative;
}

.filter-btn,
.search-input {
  background: var(--panel);
  border: 1px solid #3a3a3a;
  color: #fff;
  border-radius: 10px;
  padding: 0.65rem 0.95rem;
}

.filter-btn {
  cursor: pointer;
  white-space: nowrap;
}

.filter-btn:hover,
.filter.open .filter-btn {
  border-color: #555;
}

.filter-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  min-width: 180px;
  max-height: 260px;
  overflow: auto;
  background: #171717;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 0.4rem;
  z-index: 20;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.filter.open .filter-menu {
  display: grid;
  gap: 0.2rem;
}

.filter-menu a {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  color: #ddd;
  font-size: 0.92rem;
}

.filter-menu a:hover,
.filter-menu a.active {
  background: #2a2a2a;
  color: #fff;
}

.search-form {
  display: flex;
}

.search-input {
  width: min(280px, 55vw);
}

.search-input::placeholder {
  color: #888;
}

.search-input:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.15rem 1rem;
  padding-bottom: 2.5rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
  transition: transform 0.28s ease, filter 0.28s ease;
}

.card:hover {
  transform: translateY(-5px);
  filter: drop-shadow(0 10px 18px rgba(124, 92, 255, 0.18));
}

.card-panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 0.7rem 0.7rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  border: 1px solid transparent;
  transition: border-color 0.28s ease, background 0.28s ease;
}

.card:hover .card-panel {
  border-color: rgba(124, 92, 255, 0.35);
  background: #1e1e24;
}

.card-thumb {
  display: block;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #2a2a2a;
  position: relative;
}

.card-thumb img,
.card-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.card:hover .card-thumb img,
.card:hover .card-thumb video {
  transform: scale(1.04);
}

.card-thumb-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  background: linear-gradient(145deg, #3b2a7a, #1b1238 55%, #4c1d95);
}

.card-title {
  margin: 0;
  text-align: center;
  color: var(--accent);
  font-size: 1.02rem;
  font-weight: 600;
  transition: color 0.28s ease;
}

.card:hover .card-title {
  color: var(--accent-hover);
}

.btn-download {
  display: block;
  text-align: center;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0.78rem 0.75rem;
  border: 0;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.28s ease;
}

.btn-download:hover {
  background: var(--accent-hover);
}

.card:hover .btn-download {
  transform: translateY(1px);
}

.empty {
  grid-column: 1 / -1;
  color: var(--muted);
  padding: 2rem 0;
}

.empty.is-hidden,
.card.is-hidden {
  display: none;
}

/* Forms / admin */
.form-panel,
.simple-page {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.simple-page {
  width: min(100%, var(--max));
}

.form-panel h1,
.simple-page h1 {
  margin: 0 0 0.35rem;
  font-size: 1.7rem;
}

.lede {
  margin: 0;
  color: var(--muted);
}

.stack-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.25rem;
}

.stack-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.stack-form input,
.stack-form select,
.stack-form textarea {
  width: 100%;
  border: 1px solid #3a3a3a;
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  padding: 0.7rem 0.85rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.config-only {
  display: none;
}

.stack-form.show-config .config-only {
  display: grid;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--panel-2);
  color: var(--ink);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: #3a3a3a;
}

.btn-danger {
  background: transparent;
  border-color: rgba(240, 113, 120, 0.45);
  color: var(--danger);
}

.btn-small {
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
}

.pack-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.pack-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--line);
}

.pack-meta {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.sub-modal[hidden] {
  display: none !important;
}

.sub-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.sub-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.sub-modal-panel {
  position: relative;
  width: min(100%, 420px);
  padding: 1.35rem 1.25rem 1.25rem;
  border: 1px solid #2e2e2e;
  border-radius: var(--radius);
  background: var(--panel);
  display: grid;
  gap: 0.85rem;
}

.sub-modal-panel h2 {
  margin: 0;
  font-size: 1.25rem;
}

.sub-modal-check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.sub-modal-check input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
}

.sub-modal-panel .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sub-modal-status {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid #3a3a3a;
  background: #191919;
  color: #f0c6c8;
  font-size: 0.92rem;
}

.sub-modal-status.is-ok {
  color: #c8f0d0;
  border-color: #2f4a36;
}

.sub-modal-actions {
  display: grid;
  gap: 0.85rem;
}

.sub-modal-actions[hidden],
.sub-modal-loading[hidden] {
  display: none !important;
}

.sub-modal-loading {
  display: grid;
  justify-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0 0.25rem;
  text-align: center;
}

.sub-spinner {
  width: 1.75rem;
  height: 1.75rem;
  border: 2px solid #3a3a3a;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sub-spin 0.7s linear infinite;
}

@keyframes sub-spin {
  to {
    transform: rotate(360deg);
  }
}

.detail-video {
  margin-top: 1rem;
  aspect-ratio: 16 / 9;
  max-width: 720px;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-video iframe,
.detail-video video {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* Full uncropped preview on the detail page (gallery cards still crop) */
.detail-image {
  margin-top: 1rem;
  max-width: 720px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid #2a2a2a;
}

.detail-image img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.detail-thumb-note {
  margin-top: 0.75rem;
  width: 88px;
  opacity: 0.45;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #2a2a2a;
}

.detail-thumb-note img {
  display: block;
  width: 100%;
  height: auto;
}

.form-preview {
  margin-top: 0.45rem;
  max-width: 160px;
  max-height: 100px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #333;
}

.form-error {
  color: var(--danger);
}

.flash-stack {
  width: min(100% - 2rem, var(--max));
  margin: 0 auto 0.85rem;
  display: grid;
  gap: 0.4rem;
}

.flash {
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid #333;
}

.flash-ok { border-color: rgba(124, 92, 255, 0.5); }
.flash-error { border-color: rgba(240, 113, 120, 0.5); color: var(--danger); }

.site-footer {
  width: min(100% - 2rem, var(--max));
  margin: 0 auto 2rem;
  padding-top: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer a {
  color: var(--muted);
}

.site-footer a:hover {
  color: #fff;
}

.privacy-page {
  max-width: 720px;
}

.privacy-body {
  margin-top: 1.25rem;
  display: grid;
  gap: 0.85rem;
  color: #d0d0d0;
  line-height: 1.55;
}

.privacy-body h2 {
  margin: 0.6rem 0 0;
  font-size: 1.1rem;
  color: #fff;
}

.privacy-body p,
.privacy-body ul {
  margin: 0;
}

.privacy-body ul {
  padding-left: 1.2rem;
}

.privacy-body a {
  color: var(--accent-hover);
}

.privacy-body code {
  font-size: 0.9em;
  color: #cfcfcf;
}

/* Footer */
.site-footer {
  margin-top: auto;
  border-top: 1px solid #2a2a2a;
  padding: 1.5rem 0 2rem;
  color: #9a9a9a;
  font-size: 0.88rem;
}

.footer-top,
.footer-bottom {
  width: min(100% - 2rem, var(--max));
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-top {
  padding-bottom: 1rem;
}

.footer-bottom {
  padding-top: 1rem;
  border-top: 1px solid #222;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.1rem;
}

.footer-links a:hover {
  color: #fff;
}

.disclaimer {
  max-width: 42ch;
  text-align: right;
}

@media (max-width: 1000px) {
  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .site-nav {
    grid-template-columns: 1fr;
    border-radius: 18px;
    justify-items: center;
    gap: 0.65rem;
    padding: 0.8rem;
  }

  .socials,
  .brand {
    justify-content: center;
  }

  .nav-links {
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar-controls {
    margin-left: 0;
    width: 100%;
  }

  .search-input {
    width: 100%;
  }

  .disclaimer {
    text-align: left;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card-panel,
  .card-thumb img,
  .card-thumb video,
  .card-title,
  .btn-download {
    transition: none !important;
  }

  .card:hover {
    transform: none;
    filter: none;
  }

  .card:hover .card-thumb img,
  .card:hover .card-thumb video,
  .card:hover .btn-download {
    transform: none;
  }
}
