:root {
  color-scheme: dark;
  --bg: #09090b;
  --panel: #141419;
  --panel-2: #1d1d24;
  --text: #f7f7f8;
  --muted: #a8a8b3;
  --line: #2a2a33;
  --accent: #ff4b6e;
  --header-h: 64px;
  --glide-footer-h: 46px;
  --safe: max(16px, env(safe-area-inset-left));
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: inherit; }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--header-h);
  padding: 10px max(18px, env(safe-area-inset-right)) 10px var(--safe);
  background: rgba(9, 9, 11, .92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand { font-weight: 900; letter-spacing: .02em; text-decoration: none; white-space: nowrap; }
.site-nav { display: flex; gap: 8px; align-items: center; }
.nav-link, .pill, .action {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.045);
  border-radius: 999px;
  padding: 9px 14px;
  text-decoration: none;
  cursor: pointer;
}
.nav-link:hover, .pill:hover, .action:hover { background: rgba(255,255,255,.09); }
.primary { background: var(--text); color: #101014; border-color: transparent; font-weight: 800; }
.danger-soft { background: rgba(255,75,110,.12); border-color: rgba(255,75,110,.28); }

.site-footer { border-top: 1px solid rgba(255,255,255,.07); background: #0d0d10; color: var(--muted); }
.site-footer-inner { min-height: 96px; display: flex; align-items: center; justify-content: space-between; gap: 18px 28px; padding: 22px max(18px, 4vw); }
.footer-identity { display: grid; gap: 8px; min-width: 0; }
.footer-brand { color: var(--text); font-weight: 800; text-decoration: none; white-space: nowrap; }
.footer-identity small { color: var(--muted); font-size: 12px; line-height: 1.6; }
.footer-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 22px; }
.footer-nav a { color: #c8c8d1; font-size: 13px; text-decoration: none; }
.footer-nav a:hover, .footer-nav a:focus-visible { color: #fff; text-decoration: underline; }

.home-main { padding-bottom: 72px; }
.hero {
  min-height: min(72vh, 720px);
  display: grid;
  align-items: end;
  padding: 58px max(24px, 7vw);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(180deg, #1e1d24 0%, #111116 62%, var(--bg) 100%);
}
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(9,9,11,.94) 0%, rgba(9,9,11,.58) 48%, rgba(9,9,11,.18) 76%), linear-gradient(0deg, var(--bg) 0%, transparent 34%); }
.hero-bg { position: absolute; inset: 0; z-index: -2; overflow: hidden; background: linear-gradient(135deg, #282833, #141419 58%, #331923); }
.hero-video, .hero-frame-fallback, .hero-bg .hiv-frame-video { width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; object-position: center 28%; filter: saturate(.9); }
.hero-copy { max-width: min(760px, 72vw); position: relative; z-index: 2; }
.eyebrow { color: var(--accent); font-weight: 800; letter-spacing: .08em; }
.hero h1 { margin: 10px 0 14px; font-size: clamp(34px, 4.5vw, 64px); line-height: 1.03; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero p { color: #d2d2d7; max-width: 58ch; font-size: clamp(15px, 1.7vw, 19px); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.shelf { padding: 12px 0 30px; }
.shelf-head { display: flex; align-items: center; justify-content: space-between; padding: 0 max(18px, 4vw) 12px; gap: 16px; }
.shelf h2 { margin: 0; font-size: clamp(22px, 2.5vw, 31px); }
.shelf-category-link { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-height: 34px; padding: 7px 12px; border: 1px solid rgba(255,255,255,.15); border-radius: 999px; background: rgba(255,255,255,.045); color: #dddde4; font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.shelf-category-link:hover, .shelf-category-link:focus-visible { color: #fff; text-decoration: underline; }
.shelf-row { display: grid; grid-auto-flow: column; grid-auto-columns: clamp(320px, 30vw, 520px); gap: 16px; overflow-x: auto; padding: 0 max(18px, 4vw) 10px; scroll-snap-type: x proximity; scrollbar-width: none; -ms-overflow-style: none; }
.shelf-row::-webkit-scrollbar { display: none; width: 0; height: 0; }
.shelf-desktop-controls { display: flex; gap: 6px; align-items: center; }
.shelf-arrow { width: 42px; height: 42px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.05); cursor: pointer; }
.shelf-arrow:disabled { opacity: .35; cursor: default; }
.work-card { scroll-snap-align: start; text-decoration: none; min-width: 0; }
.work-art { aspect-ratio: 16 / 9; border-radius: 16px; background: linear-gradient(135deg, #282833, #141419 58%, #331923); border: 1px solid rgba(255,255,255,.07); overflow: hidden; position: relative; }
.work-art video { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center; }
.hiv-frame-video { position: absolute; inset: 0; opacity: 0; transition: opacity .18s ease; background: #000; }
.hiv-frame-video.is-ready { opacity: 1; }
.hiv-frame-thumb.is-frame-unavailable::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 40%, #2d2d36, #131318 68%); }
.work-card strong { display: block; margin-top: 10px; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.work-card span { color: var(--muted); font-size: 13px; }

.glide-body { overflow: hidden; --glide-footer-h: 0px; }
.glide-body .site-header { position: relative; }
.glide-body .site-footer { display: none; }
.glide-feed { height: calc(100dvh - var(--header-h) - var(--glide-footer-h)); overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior-y: contain; overflow-anchor: none; scrollbar-width: none; -ms-overflow-style: none; }
.glide-feed::-webkit-scrollbar { display: none; width: 0; height: 0; }
.glide-card { min-height: calc(100dvh - var(--header-h) - var(--glide-footer-h)); position: relative; scroll-snap-align: start; display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: minmax(0,1fr) auto; background: #050506; overflow: hidden; }
.glide-media { position: relative; grid-column: 1 / -1; grid-row: 1; min-height: 0; overflow: hidden; background: #000; }
.glide-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; opacity: 0; transition: opacity .18s ease; }
.glide-video.is-ready { opacity: 1; }
.glide-copy { grid-column: 1; grid-row: 2; min-width: 0; padding: 16px 22px 18px; background: #111116; border-top: 1px solid rgba(255,255,255,.07); }
.glide-copy h2 { margin: 5px 0 8px; font-size: clamp(20px, 2.6vw, 34px); line-height: 1.14; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.glide-copy p { margin: 0 0 10px; color: #c8c8cf; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; color: #d9d9df; font-size: 13px; }
.glide-rail { grid-column: 2; grid-row: 2; position: static; z-index: 4; display: flex; align-items: center; gap: 8px; padding: 14px 16px 16px 4px; background: #111116; border-top: 1px solid rgba(255,255,255,.07); }
.rail-btn { width: 70px; min-height: 60px; display: grid; place-items: center; align-content: center; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.045); border-radius: 18px; cursor: pointer; font-size: 12px; text-align: center; text-decoration: none; padding: 6px; }
.rail-btn b { display: block; font-size: 21px; line-height: 1; margin-bottom: 4px; }
.rail-btn.is-active { background: rgba(255,75,110,.19); border-color: rgba(255,75,110,.48); }
.glide-seek-controls { position: absolute; left: 50%; bottom: 14px; z-index: 6; width: min(760px, calc(100% - 40px)); transform: translate(-50%, 8px); opacity: 0; pointer-events: none; transition: opacity .16s ease, transform .16s ease; display: grid; grid-template-columns: auto minmax(120px,1fr) auto auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: rgba(10,10,13,.82); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,.12); }
.glide-media:hover .glide-seek-controls, .glide-seek-controls:focus-within { opacity: 1; transform: translate(-50%,0); pointer-events: auto; }
.glide-seek-controls button { border: 0; border-radius: 999px; padding: 6px 10px; background: rgba(255,255,255,.09); cursor: pointer; }
.glide-seek-controls input { width: 100%; accent-color: #fff; }
.glide-seek-controls span { font-variant-numeric: tabular-nums; color: #e6e6ea; font-size: 12px; white-space: nowrap; }

/* Indexed Watch pages use the same vertical discovery surface as MOOD while
   keeping the canonical /watch/{id}/ URL and SSR work details intact. */
.watch-entry-copy h1 { margin: 5px 0 8px; font-size: clamp(20px, 2.6vw, 34px); line-height: 1.14; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.watch-entry-card .glide-video { opacity: 1; }
.watch-mood-hint { position: absolute; left: 50%; bottom: 70px; z-index: 7; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 999px; background: rgba(8,8,11,.76); border: 1px solid rgba(255,255,255,.14); color: #f3f3f5; font-size: 12px; font-weight: 700; backdrop-filter: blur(10px); pointer-events: none; }
.watch-mood-hint span { font-size: 16px; line-height: 1; }

.watch-detail-sheet { position: fixed; inset: 0; z-index: 120; pointer-events: none; }
.watch-detail-backdrop { position: absolute; inset: 0; border: 0; padding: 0; background: rgba(0,0,0,.66); opacity: 0; transition: opacity .18s ease; cursor: default; }
.watch-detail-panel { position: absolute; left: 50%; bottom: 0; width: min(820px, calc(100% - 28px)); max-height: min(84dvh, 920px); overflow-y: auto; transform: translate(-50%, 102%); transition: transform .22s ease; padding: 22px 24px calc(24px + env(safe-area-inset-bottom)); border: 1px solid rgba(255,255,255,.12); border-bottom: 0; border-radius: 24px 24px 0 0; background: #141419; box-shadow: 0 -24px 80px rgba(0,0,0,.5); }
.watch-detail-sheet.is-open { pointer-events: auto; }
.watch-detail-sheet.is-open .watch-detail-backdrop { opacity: 1; }
.watch-detail-sheet.is-open .watch-detail-panel { transform: translate(-50%, 0); }
.watch-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.watch-detail-head h2 { margin: 4px 0 0; font-size: clamp(22px, 4vw, 34px); line-height: 1.2; }
.watch-detail-close { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.05); cursor: pointer; font-size: 23px; }
.watch-detail-intro { color: #c9c9d0; line-height: 1.7; }
.watch-detail-tags { margin-top: 16px; }
.watch-detail-fanza { display: block; margin-top: 20px; text-align: center; }
.watch-detail-links { margin-top: 20px; }
.watch-detail-related { display: grid; gap: 8px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.watch-detail-related h3 { margin: 0 0 4px; }
.watch-detail-related a { display: grid; gap: 3px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; background: rgba(255,255,255,.025); }
.watch-detail-related small { color: var(--muted); }
.watch-detail-open .watch-mood-feed { overflow: hidden; }

.watch-main { max-width: 1320px; margin: 0 auto; padding: 26px max(18px, 4vw) 80px; }
.watch-media { aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; background: linear-gradient(135deg, #24242c, #101014 60%, #2c1820); border: 1px solid var(--line); }
.watch-media video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.watch-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; margin-top: 24px; }
.watch-copy h1 { margin: 0 0 10px; font-size: clamp(28px, 4vw, 48px); }
.watch-copy p { color: #c4c4cc; line-height: 1.7; }
.facts { display: grid; gap: 10px; margin: 22px 0; }
.fact { display: grid; grid-template-columns: 90px 1fr; gap: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.fact span:first-child { color: var(--muted); }
.watch-actions { display: grid; gap: 10px; align-content: start; position: sticky; top: 88px; }
.watch-actions .action { text-align: center; }
.watch-related { margin-top: 44px; }

.saved-main { max-width: 1500px; margin: 0 auto; padding: 42px max(18px, 4vw) 80px; }
.page-heading { max-width: 760px; margin-bottom: 28px; }
.page-heading h1 { margin: 6px 0 10px; font-size: clamp(32px, 5vw, 54px); }
.page-heading p { color: var(--muted); }
.saved-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.saved-card { min-width: 0; }
.saved-card-link { display: block; text-decoration: none; }
.saved-card strong { display: block; margin-top: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-card span { color: var(--muted); font-size: 13px; }
.saved-remove { margin-top: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.04); border-radius: 999px; padding: 7px 12px; cursor: pointer; }
.saved-empty { display: grid; gap: 16px; justify-items: start; padding: 36px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }

.age-gate { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; background: rgba(5,5,7,.94); }
.age-card { width: min(520px, 100%); padding: 28px; border-radius: 22px; background: #17171d; border: 1px solid var(--line); box-shadow: 0 24px 90px rgba(0,0,0,.55); }
.age-card h2 { margin-top: 0; }
.age-card p { color: var(--muted); line-height: 1.6; }
.age-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

@media (max-width: 760px) {
  :root { --header-h: 58px; --glide-footer-h: 0px; }
  .site-header { gap: 8px; padding: 8px 10px; }
  .brand { font-size: 14px; }
  .site-nav { gap: 4px; }
  .nav-link { padding: 7px 9px; font-size: 13px; }
  .site-footer-inner { flex-wrap: wrap; gap: 14px; min-height: 0; padding: 20px 16px; }
  .footer-identity { width: 100%; }
  .footer-nav { margin: 0; gap: 18px; }

  .hero { min-height: 72svh; padding: 32px 16px 28px; align-items: end; }
  .hero::after { background: linear-gradient(0deg, rgba(9,9,11,.97) 0%, rgba(9,9,11,.7) 42%, rgba(9,9,11,.25) 100%); }
  .hero-video, .hero-frame-fallback, .hero-bg .hiv-frame-video { object-position: center center; }
  .hero-copy { max-width: 100%; }
  .hero h1 { font-size: clamp(28px, 9vw, 42px); -webkit-line-clamp: 4; }
  .hero p { font-size: 14px; -webkit-line-clamp: 3; }
  .hero-actions { margin-top: 16px; }
  .hero-actions .pill { padding: 8px 11px; font-size: 13px; }

  .shelf-row { grid-auto-columns: minmax(160px, 68vw); gap: 12px; }
  .shelf-desktop-controls { display: none; }
  .work-card strong { font-size: 14px; }

  .watch-mood-hint { bottom: 58px; font-size: 11px; padding: 7px 10px; }
  .watch-entry-copy h1 { font-size: 20px; -webkit-line-clamp: 2; }
  .watch-detail-panel { width: 100%; max-height: 88dvh; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; }
  .watch-detail-head h2 { font-size: 22px; }

  .glide-card { grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr) auto auto; }
  .glide-media { grid-column: 1; grid-row: 1; }
  .glide-copy { grid-column: 1; grid-row: 2; padding: 12px 14px; }
  .glide-copy h2 { font-size: 20px; -webkit-line-clamp: 2; }
  .glide-copy p { display: none; }
  .glide-copy .tags { max-height: 38px; overflow: hidden; }
  .glide-rail { grid-column: 1; grid-row: 3; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); padding: 8px 10px 10px; gap: 6px; }
  .rail-btn { width: 100%; min-height: 48px; border-radius: 14px; grid-auto-flow: column; gap: 4px; }
  .rail-btn b { display: inline; font-size: 17px; margin: 0; }
  .glide-seek-controls { bottom: 8px; width: calc(100% - 18px); grid-template-columns: auto minmax(80px,1fr) auto; }
  .glide-seek-controls span { display: none; }
  .glide-media:hover .glide-seek-controls { opacity: 0; pointer-events: none; }
  .glide-seek-controls:focus-within { opacity: 1; pointer-events: auto; }

  .watch-grid { grid-template-columns: 1fr; }
  .watch-actions { position: static; }
  .saved-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
  .saved-main { padding-top: 28px; }
}

@media (max-width: 420px) {
  .brand { max-width: 128px; overflow: hidden; text-overflow: ellipsis; }
  .saved-grid { grid-template-columns: 1fr; }
}

/* MOOD / Watch: only after every playback candidate failed.
   Overlay is removed on successful playback; original rail and swipe remain. */
.glide-card.is-media-failed .glide-seek-controls,
.glide-card.is-media-failed .watch-mood-hint { display: none; }
.glide-playback-fallback { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 22px; isolation: isolate; color: #fff; background: radial-gradient(ellipse at 50% 40%, #28282d, #08080a 75%); }
.glide-playback-fallback-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: brightness(.32); opacity: .75; z-index: 0; pointer-events: none; }
.glide-playback-fallback-content { position: relative; z-index: 1; width: min(420px, 100%); text-align: center; background: rgba(8,8,11,.78); border: 1px solid rgba(255,255,255,.15); border-radius: 18px; padding: 22px 20px; box-shadow: 0 15px 50px rgba(0,0,0,.32); }
.glide-playback-fallback-content strong { font-size: clamp(17px, 2vw, 21px); line-height: 1.35; display: block; }
.glide-playback-fallback-content p { color: #d1d1d7; font-size: 13px; line-height: 1.65; margin: 12px 0 0; }
.glide-playback-fallback-link { display: inline-flex; align-items: center; justify-content: center; margin-top: 17px; min-height: 43px; padding: 9px 18px; border-radius: 999px; background: #e5415f; color: #fff; text-decoration: none; font-weight: 750; font-size: 13px; }
.glide-playback-fallback-link:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@media(max-width:680px) {
  .glide-playback-fallback { padding: 14px; }
  .glide-playback-fallback-content { padding: 16px 13px; border-radius: 15px; }
  .glide-playback-fallback-content strong { font-size: 16px; }
  .glide-playback-fallback-content p { font-size: 12px; }
}
