:root {
  --bg: #141414;
  --bg-2: #1c1c1c;
  --card: #232323;
  --ink: #f2f2f2;
  --muted: #a3a3a3;
  --line: #333;
  --accent: #e50914;
  --accent-hover: #f6121d;
  --accent-ink: #fff;
  --video: #e50914;
  --audio: #46b3c9;
  --image: #8fbf4a;
  --folder: #e8b04a;
  --radius: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body.no-scroll { overflow: hidden; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

#app { padding: 0 0 60px; }
.pad { padding-left: 4vw; padding-right: 4vw; }

/* ── wordmark ── */
.wordmark {
  font-weight: 900;
  font-size: 30px;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  line-height: 1;
  transform: scaleY(1.12);
  display: inline-block;
}

/* ── icons ── */
.icon { display: inline-flex; width: 1.4em; height: 1.4em; }
.icon svg { width: 100%; height: 100%; }
.icon-video { color: var(--video); }
.icon-audio { color: var(--audio); }
.icon-image { color: var(--image); }
.icon-folder { color: var(--folder); }

/* ── login ── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    radial-gradient(ellipse at top, rgba(229, 9, 20, .22), transparent 60%),
    linear-gradient(180deg, #000 0%, var(--bg) 100%);
}
.login-top { padding: calc(24px + env(safe-area-inset-top)) 4vw 0; }
.login-top .wordmark { font-size: 40px; }
.login-center { display: grid; place-items: center; padding: 20px 16px 60px; }
.login-card {
  width: min(440px, 100%);
  background: rgba(0, 0, 0, .75);
  border-radius: 8px;
  padding: 44px 36px;
  display: grid;
  gap: 16px;
}
.login-card h1 { margin: 0 0 6px; font-size: 32px; }
.login-card label { color: var(--muted); }
.login-card input {
  font: inherit;
  font-size: 20px;
  padding: 16px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #333;
  color: #fff;
}
.login-card input:focus { border-color: #fff; outline: none; }
.login-error { color: #ff6b6b; min-height: 1.4em; margin: 0; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 4px;
  padding: 14px 20px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .6; }
.btn-quiet {
  background: transparent;
  border: 1px solid #666;
  border-radius: 4px;
  padding: 6px 14px;
  cursor: pointer;
  color: var(--ink);
  font-size: 15px;
}
.btn-quiet:hover { border-color: #fff; }

/* ── header ── */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 4vw 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .85) 0%, rgba(0, 0, 0, 0) 100%);
}
.top.solid { background: var(--bg); }
.top-right { display: flex; align-items: center; gap: 14px; }
.hello { color: var(--ink); font-size: 16px; }

/* ── hero ── */
.hero {
  position: relative;
  min-height: min(72vh, 620px);
  margin-top: calc(-70px - env(safe-area-inset-top));
  display: flex;
  align-items: flex-end;
  background: #000;
  overflow: hidden;
}
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .5s; }
.hero-bg.loaded { opacity: .85; }
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .8) 0%, rgba(0, 0, 0, .35) 45%, transparent 75%),
    linear-gradient(0deg, var(--bg) 0%, rgba(20, 20, 20, 0) 35%);
}
.hero-body { position: relative; z-index: 1; padding: 0 4vw 9vh; max-width: 760px; }
.hero-tag { color: var(--muted); font-weight: 700; letter-spacing: .2em; font-size: 14px; text-transform: uppercase; }
.hero-tag b { color: var(--accent); }
.hero-title { font-size: clamp(32px, 5vw, 60px); line-height: 1.05; margin: 8px 0 14px; text-shadow: 0 2px 12px rgba(0, 0, 0, .6); overflow-wrap: anywhere; }
.hero-meta { color: #ddd; margin: 0 0 20px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-play, .btn-more {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 4px;
  padding: 12px 28px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn-play { background: #fff; color: #000; }
.btn-play:hover { background: rgba(255, 255, 255, .78); }
.btn-more { background: rgba(109, 109, 110, .7); color: #fff; }
.btn-more:hover { background: rgba(109, 109, 110, .45); }

.welcome { padding-top: 30px; }
.page-title { font-size: 34px; margin: 10px 0 4px; }

/* ── folder page ── */
.crumb-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 16px 0 4px; }
.btn-back {
  text-decoration: none;
  background: #2b2b2b;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 600;
}
.btn-back:hover { background: #3a3a3a; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 17px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: #fff; }
.crumbs [aria-current] { color: var(--ink); font-weight: 700; font-size: 26px; }
.crumbs .sep { opacity: .5; }

/* ── rows (home) and grids (folders) ── */
.section { position: relative; z-index: 1; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin: 34px 0 10px; }
.section-head h2 { font-size: 22px; margin: 0; }
.see-all { color: #54b9c5; font-size: 15px; font-weight: 600; text-decoration: none; }
.see-all:hover { text-decoration: underline; }

.row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(200px, 22vw, 300px);
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding: 10px 4vw 18px;
  scroll-padding: 0 4vw;
  scrollbar-width: none;
}
.row::-webkit-scrollbar { display: none; }
.row > * { scroll-snap-align: start; }

.grid { display: grid; gap: 22px 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); padding-bottom: 10px; }

.card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  text-decoration: none;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  min-width: 0;
  transition: transform .2s ease;
}
.card:hover, .card:focus-visible { transform: scale(1.06); z-index: 2; }
.card:active { transform: scale(1.02); }

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--card);
  margin-bottom: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}
.card:hover .thumb { box-shadow: 0 10px 30px rgba(0, 0, 0, .8); }
.thumb .icon { width: 52px; height: 52px; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
.thumb.has-img img { opacity: 1; }
.thumb.has-img > .icon { visibility: hidden; }
.thumb-folder { background: linear-gradient(135deg, #2e2e2e, #1f1f1f); }
.play-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, .65);
  border: 2px solid #fff;
  color: #fff;
  font-size: 12px;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding-left: 2px;
  opacity: .85;
}
.card:hover .play-badge { background: var(--accent); border-color: var(--accent); opacity: 1; }
.new-badge {
  position: absolute;
  left: 0;
  top: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 2px 8px;
  border-radius: 0 3px 3px 0;
}
.card-name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { color: var(--muted); font-size: 14px; }
.folder .card-name { font-size: 18px; }

.loading, .notice { padding: 60px 4vw; text-align: center; color: var(--muted); font-size: 20px; }

/* ── viewer ── */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #000;
  color: #fff;
  display: grid;
  grid-template-rows: auto 1fr;
}
.viewer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: #000;
}
.viewer-bar h2 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbtn {
  background: #2b2b2b;
  border: 0;
  color: #fff;
  border-radius: 4px;
  padding: 10px 18px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.vbtn:hover { background: #3a3a3a; }
.viewer-stage { position: relative; display: grid; place-items: center; overflow: hidden; min-height: 0; padding: 12px; }
.viewer-stage video, .viewer-stage .photo { max-width: 100%; max-height: 100%; width: auto; height: auto; background: #000; }
.viewer-stage video { width: 100%; }

.vnav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  padding-bottom: 4px;
}
.vnav:hover { background: rgba(255, 255, 255, .25); }
.vnav.prev { left: 14px; }
.vnav.next { right: 14px; }

.audio-wrap { display: grid; gap: 24px; justify-items: center; width: min(460px, 100%); }
.album { position: relative; width: min(320px, 70vw); aspect-ratio: 1; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: #222; }
.album .icon { width: 96px; height: 96px; color: var(--audio); }
.album img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.audio-wrap audio { width: 100%; }

.prep { text-align: center; max-width: 460px; display: grid; gap: 10px; justify-items: center; }
.prep-msg { font-size: 22px; margin: 0; }
.prep-sub { color: #bbb; margin: 0; font-size: 16px; }
.media-err { position: absolute; bottom: 20px; left: 0; right: 0; }
.prep-bar { width: 100%; height: 6px; border-radius: 999px; background: #333; overflow: hidden; visibility: hidden; }
.prep-bar.show { visibility: visible; }
.prep-fill { height: 100%; width: 3%; background: var(--accent); transition: width .6s ease; }
.spinner { width: 48px; height: 48px; border-radius: 50%; border: 5px solid #333; border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  body { font-size: 17px; }
  .pad { padding-left: 16px; padding-right: 16px; }
  .top { padding-left: 16px; padding-right: 16px; }
  .wordmark { font-size: 26px; }
  .hello { display: none; }
  .hero { min-height: 62vh; }
  .hero-body { padding: 0 16px 6vh; }
  .btn-play, .btn-more { padding: 10px 20px; font-size: 18px; }
  .row { grid-auto-columns: 62vw; padding-left: 16px; padding-right: 16px; scroll-padding: 0 16px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 8px; }
  .card:hover { transform: none; }
  .page-title { font-size: 28px; }
  .vbtn span { display: none; }
  .vnav { width: 44px; height: 44px; font-size: 28px; top: calc(76px + env(safe-area-inset-top)); transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 3s !important; }
  .card:hover { transform: none; }
}
