:root {
  color-scheme: dark;
  --bg: #0d0f14;
  --panel: rgba(11, 14, 18, 0.72);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f4f4f0;
  --muted: #bcc5d3;
  --accent: #ff8156;
  --accent-strong: #ff5b3c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --body-font: "Aptos", "Trebuchet MS", "Segoe UI", sans-serif;
  --title-font: "Bahnschrift", "Aptos Display", "Aptos", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(255, 129, 86, 0.14), transparent 38%),
    radial-gradient(circle at top right, rgba(66, 180, 255, 0.16), transparent 30%),
    linear-gradient(180deg, #111723 0%, #090a0d 100%);
  color: var(--text);
  font-family: var(--body-font);
}

body {
  overflow: hidden;
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
}

.top-bar,
.hud {
  position: fixed;
  left: max(1rem, env(safe-area-inset-left));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 10;
  pointer-events: none;
}

.top-bar {
  top: max(1.15rem, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.7rem;
}

.top-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(5, 6, 8, 0.72), rgba(5, 6, 8, 0.46)),
    rgba(5, 6, 8, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
}

.brand-lockup:hover .brand-mark,
.brand-lockup:focus-visible .brand-mark {
  transform: translateY(-1px);
}

.brand-lockup:focus-visible {
  outline: 2px solid rgba(255, 129, 86, 0.72);
  outline-offset: 5px;
  border-radius: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  flex: 0 0 auto;
  border-radius: 15px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02)),
    rgba(5, 7, 10, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  transition: transform 160ms ease;
}

.brand-symbol {
  display: block;
  width: 2.05rem;
  height: 2.05rem;
}

.brand-copy {
  display: grid;
  gap: 0.05rem;
  margin: 0;
  line-height: 0.95;
}

.brand-name,
.brand-mode {
  display: block;
  text-shadow: 0 8px 26px rgba(0, 0, 0, 0.42);
}

.brand-name {
  font-family: var(--title-font);
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  font-weight: 800;
  color: var(--text);
}

.brand-mode {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #9fe6ff;
}

.collection-bar {
  position: fixed;
  top: calc(max(1.15rem, env(safe-area-inset-top)) + 6.05rem);
  left: max(1rem, env(safe-area-inset-left));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 9;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.hud {
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
}

body[data-view="feed"] .hud {
  display: none;
}

.hud-card,
.top-bar-actions .icon-button {
  backdrop-filter: blur(14px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.hud-card {
  min-width: min(88vw, 320px);
  padding: 0.9rem 1rem;
  border-radius: 18px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-family: var(--title-font);
  letter-spacing: 0.01em;
}

.subtle {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  pointer-events: auto;
}

.desktop-only {
  display: none;
}

.icon-link,
.icon-button,
.play-toggle {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    opacity 160ms ease;
}

.icon-link,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 1.15rem;
  color: var(--text);
  text-decoration: none;
  backdrop-filter: blur(14px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.icon-link:hover,
.icon-button:hover,
.play-toggle:hover {
  transform: translateY(-1px);
}

.collection-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.45rem;
  border-radius: 999px;
  pointer-events: auto;
  backdrop-filter: blur(14px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.collection-button {
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  cursor: pointer;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    color 160ms ease;
}

.collection-button:hover {
  transform: translateY(-1px);
}

.collection-button[data-active="true"] {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--text);
}

.collection-button[data-locked="true"] {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(244, 244, 240, 0.74);
}

.library {
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  padding:
    calc(max(1.15rem, env(safe-area-inset-top)) + 10.9rem)
    max(0.75rem, env(safe-area-inset-right))
    5rem
    max(0.75rem, env(safe-area-inset-left));
  background: #050608;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 1.45rem 1.1rem;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.library-tile {
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.library-thumb-frame {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 129, 86, 0.18), rgba(66, 180, 255, 0.12)),
    #11151c;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32);
  transform: translateZ(0);
}

.library-preview,
.library-fallback,
.library-gradient {
  position: absolute;
  inset: 0;
}

.library-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #080a0f;
  opacity: 0;
  transition:
    filter 180ms ease,
    opacity 180ms ease,
    transform 180ms ease;
  z-index: 1;
}

.library-preview[data-loaded="true"] {
  opacity: 1;
}

.library-fallback {
  display: grid;
  place-items: center;
  color: rgba(244, 244, 240, 0.48);
  font-family: var(--title-font);
  font-size: 2rem;
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 255, 255, 0.1), transparent 30%),
    linear-gradient(145deg, rgba(255, 129, 86, 0.16), rgba(66, 180, 255, 0.1));
  z-index: 0;
}

.library-preview[data-loaded="true"] + .library-fallback {
  opacity: 0;
}

.library-gradient {
  background: linear-gradient(180deg, transparent 48%, rgba(0, 0, 0, 0.68) 100%);
  z-index: 2;
}

.library-play-count {
  position: absolute;
  left: 0.72rem;
  bottom: 0.65rem;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  color: #fff;
  font-weight: 800;
  text-shadow: 0 2px 9px rgba(0, 0, 0, 0.72);
}

.library-title {
  display: -webkit-box;
  margin-top: 0.55rem;
  overflow: hidden;
  color: rgba(244, 244, 240, 0.92);
  font-weight: 700;
  line-height: 1.28;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.library-date {
  display: block;
  margin-top: 0.28rem;
  color: rgba(188, 197, 211, 0.86);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
}

.library-tile:hover .library-preview,
.library-tile:focus-visible .library-preview {
  filter: saturate(1.08) contrast(1.04);
  transform: scale(1.035);
}

.library-tile:focus-visible {
  outline: 2px solid rgba(255, 129, 86, 0.72);
  outline-offset: 4px;
  border-radius: 8px;
}

.feed {
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  touch-action: pan-y;
}

.feed::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.video-card,
.empty-state {
  position: relative;
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.video-card {
  padding: 1rem;
}

.video-frame {
  position: relative;
  height: 100%;
  width: min(100%, 560px);
  margin: 0 auto;
  border-radius: 28px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    rgba(8, 9, 13, 0.92);
  box-shadow: var(--shadow);
}

.video-player {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.play-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  padding: 0.65rem 0.9rem;
  background: rgba(5, 8, 13, 0.7);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
}

.video-overlay {
  position: absolute;
  inset: auto 1rem 1rem 1rem;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.video-meta {
  width: min(100%, 560px);
  padding: 4rem 1.25rem 1.25rem;
  border-radius: 0 0 28px 28px;
  background:
    linear-gradient(180deg, rgba(7, 10, 15, 0), rgba(7, 10, 15, 0.86) 44%, rgba(7, 10, 15, 0.94)),
    linear-gradient(135deg, rgba(255, 129, 86, 0.12), rgba(0, 0, 0, 0) 62%);
}

.video-index {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffd9cc;
}

.video-posted-date {
  margin: -0.1rem 0 0.5rem;
  color: rgba(188, 197, 211, 0.92);
  font-size: 0.84rem;
  font-weight: 800;
}

.video-title {
  margin: 0;
  font-size: clamp(1.25rem, 2.6vw, 1.8rem);
  font-family: var(--title-font);
  letter-spacing: 0.01em;
}

.video-description {
  margin: 0.6rem 0 0;
  max-width: 44ch;
  color: var(--muted);
  line-height: 1.5;
}

.video-description:empty {
  display: none;
}

.empty-state {
  display: grid;
  place-items: center;
  padding: 2rem;
}

.empty-state-card {
  max-width: 560px;
  padding: 1.4rem;
  border-radius: 28px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.empty-state h2 {
  margin-top: 0;
}

.empty-state p,
.empty-state li {
  color: var(--muted);
  line-height: 1.6;
}

.empty-state code {
  color: #ffd9cc;
}

.admin-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  overflow: auto;
}

.admin-layout {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 3.5rem 0 1.25rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.admin-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 1.35rem;
}

.admin-card h2,
.admin-card h3 {
  margin-top: 0;
  font-family: var(--title-font);
}

.admin-card p,
.admin-card li,
.admin-card label,
.admin-card dt,
.admin-card dd {
  color: var(--muted);
  line-height: 1.6;
}

.admin-card code {
  color: #ffd9cc;
}

.endpoint-link {
  color: #ffd9cc;
  text-decoration: none;
}

.endpoint-link:hover {
  text-decoration: underline;
}

.admin-card dl {
  display: grid;
  grid-template-columns: minmax(0, 150px) minmax(0, 1fr);
  gap: 0.5rem 0.75rem;
  margin: 0;
}

.admin-card dt {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-card dd {
  margin: 0;
}

.admin-card ul {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
}

.field-label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.text-input {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(7, 10, 15, 0.66);
  color: var(--text);
}

.text-input:focus {
  outline: 2px solid rgba(255, 129, 86, 0.45);
  outline-offset: 2px;
}

.form-stack {
  display: grid;
  gap: 1rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.primary-button,
.secondary-button {
  border-radius: 999px;
  padding: 0.9rem 1.15rem;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text);
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background-color 160ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 16px 40px rgba(255, 91, 60, 0.26);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.14);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.inline-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  word-break: break-word;
}

.result-panel {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(7, 10, 15, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.result-panel pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.status-pill[data-state="ready"] {
  background: rgba(98, 214, 152, 0.18);
  color: #c9f6d5;
}

.status-pill[data-state="missing"] {
  background: rgba(255, 129, 86, 0.18);
  color: #ffd9cc;
}

@media (min-width: 820px) and (hover: hover) and (pointer: fine) {
  .desktop-only:not([hidden]) {
    display: inline-flex;
  }

  body[data-view="library"] .hud-card {
    min-width: auto;
    padding: 0.7rem 0.9rem;
  }
}

@media (max-width: 640px) {
  .hud {
    display: none;
  }

  .video-card {
    padding: 0;
  }

  .video-frame {
    width: 100%;
    border-radius: 0;
  }

  .video-overlay {
    inset: auto 0 calc(max(4.75rem, env(safe-area-inset-bottom) + 3rem)) 0;
  }

  .video-meta {
    width: 100%;
    padding: 3.75rem 1rem 0.35rem;
    border-radius: 0;
  }

  .top-bar {
    align-items: center;
    padding: 0.42rem 0.48rem;
  }

  .top-bar::before {
    border-radius: 20px;
  }

  .brand-lockup {
    gap: 0.55rem;
  }

  .brand-mark {
    width: 2.55rem;
    height: 2.55rem;
    border-radius: 14px;
  }

  .brand-symbol {
    width: 1.9rem;
    height: 1.9rem;
  }

  .brand-name {
    font-size: 1.2rem;
  }

  .brand-mode {
    font-size: 0.62rem;
    letter-spacing: 0.16em;
  }

  .collection-bar {
    top: calc(max(1.15rem, env(safe-area-inset-top)) + 4.75rem);
  }

  .eyebrow {
    font-size: 0.66rem;
  }

  .icon-button {
    padding: 0.8rem 1rem;
  }

  .admin-layout {
    padding-top: 1.5rem;
  }

  .admin-card dl {
    grid-template-columns: 1fr;
  }
}
