:root {
  --bg: #121212;
  --bg-2: #1b1b1b;
  --panel: #1e1e1e;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f2ef;
  --muted: #a8a29e;
  --red: #d92b2b;
  --red-deep: #7a1717;
  --paper: #faf7f3;
  --ink: #1a1a1a;
  --radius: 14px;
  --topbar-h: 64px;
  --controls-h: 124px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(120% 90% at 100% 100%, rgba(122, 23, 23, 0.55), transparent 60%),
    radial-gradient(80% 60% at 0% 0%, rgba(255, 255, 255, 0.04), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body.gated { overflow: hidden; }
button { font: inherit; color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-left));
  padding-inline: clamp(16px, 3vw, 40px);
}
.brand { flex: 1 1 0; }
.brand img {
  height: 30px;
  display: block;
  background: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  box-sizing: content-box;
}
.topbar-meta { display: flex; justify-content: flex-end; flex: 1 1 0; align-items: center; gap: 12px; min-width: 0; }
.badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  background: var(--red);
  padding: 5px 10px;
  border-radius: 999px;
}
.viewer {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Stage / book ---------- */
.stage {
  height: calc(100dvh - var(--topbar-h));
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  transition: opacity 0.5s ease, filter 0.5s ease;
}
body.gated .stage { opacity: 0.15; filter: blur(6px); pointer-events: none; }

.reader { display: flex; flex-direction: column; align-items: center; width: 100%; }
.reader[hidden], .library[hidden] { display: none; }
.book-wrap {
  /* --spread = width/height of an open two-page spread, set per document from JS.
     Fit to whichever of width/height runs out first. */
  --spread: 3.5556;
  width: min(100%, calc((100dvh - var(--topbar-h) - var(--controls-h)) * var(--spread)));
  max-width: 1500px;
  display: flex;
  justify-content: center;
}
.book-wrap.single { --spread: calc(var(--page-ratio, 1.7778)); }
.book { width: 100%; }
.book .page {
  background: var(--paper);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.book .page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}
.wm {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 1.4% 2%;
  pointer-events: none;
  font-size: clamp(7px, 0.75vw, 11px);
  letter-spacing: 0.04em;
  color: rgba(120, 120, 120, 0.75);
  mix-blend-mode: difference;
}
.wm span { color: rgba(200, 200, 200, 0.8); }
.stf__parent { margin: 0 auto; min-width: 0 !important; }

/* ---------- Controls ---------- */
.controls {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px;
  backdrop-filter: blur(10px);
  max-width: 100%;
}
.ctl {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  transition: background 0.15s;
}
.ctl:hover { background: rgba(255, 255, 255, 0.08); }
.ctl:disabled { opacity: 0.3; cursor: default; background: transparent; }
.ctl svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ctl:focus-visible, .btn:focus-visible, .scrub input:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.scrub { display: flex; align-items: center; gap: 12px; padding: 0 6px; min-width: 0; }
.scrub input[type="range"] {
  width: clamp(80px, 22vw, 260px);
  accent-color: var(--red);
}
.counter { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; min-width: 58px; text-align: center; }
.divider { width: 1px; height: 22px; background: var(--line); }
.hint { margin: 12px 0 0; font-size: 12px; color: #77716c; text-align: center; }

/* ---------- NDA gate ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 8, 8, 0.6);
  backdrop-filter: blur(4px);
  overflow-y: auto;
  transition: opacity 0.35s ease;
}
.gate.leaving { opacity: 0; pointer-events: none; }
.gate[hidden], .nda[hidden], .declined[hidden] { display: none; }

.nda, .declined {
  color-scheme: light;
  width: min(680px, 100%);
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  padding: clamp(20px, 4vw, 36px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  animation: rise 0.45s cubic-bezier(.2, .8, .2, 1);
}
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.logo-chip img { height: 30px; display: block; }
.eyebrow {
  margin: 18px 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--red);
}
.nda h1, .declined h2 { margin: 0; font-size: clamp(22px, 3.2vw, 28px); font-weight: 800; letter-spacing: -0.02em; }
.lede { margin: 8px 0 0; color: #5f5a55; font-size: 14px; line-height: 1.5; }

.nda-body {
  margin-top: 18px;
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  border: 1px solid #e6e0d8;
  background: #fff;
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 13px;
  line-height: 1.6;
  color: #3b3733;
}
.nda-body p { margin: 0 0 10px; }
.nda-body ol { margin: 0; padding-left: 20px; }
.nda-body li { margin-bottom: 8px; }
.nda-body strong { color: var(--ink); }
.nda-body:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: #4a4540; }
.field em { font-style: normal; font-weight: 400; color: #8b847c; }
.field-wide { grid-column: 1 / -1; }
.field input {
  font: inherit;
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid #d9d2c8;
  border-radius: 8px;
  background: #fff;
}
.field input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(217, 43, 43, 0.15); }
.field input[aria-invalid="true"] { border-color: var(--red); }

.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; font-size: 13px; line-height: 1.45; color: #3b3733; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--red); flex: none; }

.error { min-height: 18px; margin: 10px 0 0; font-size: 13px; color: var(--red); }

.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.btn {
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #c02121; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost { background: transparent; color: #5f5a55; border: 1px solid #d9d2c8; }
.btn-ghost:hover { background: #f0ebe4; }

.declined { gap: 14px; }
.declined p { margin: 0; color: #5f5a55; line-height: 1.55; font-size: 14px; }
.declined a { color: var(--red); }
.declined .btn { align-self: flex-start; }

/* ---------- Document tabs ---------- */
.doc-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.doc-tabs[hidden] { display: none; }
.doc-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.doc-tab:hover { color: var(--text); }
.doc-tab[aria-current="true"] { background: var(--red); color: #fff; }
.doc-tab:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------- Library ---------- */
.library {
  width: min(1180px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 8px 0 32px;
}
.library .eyebrow { margin-top: 0; }
.library h1 { margin: 0; font-size: clamp(26px, 4vw, 38px); font-weight: 800; letter-spacing: -0.02em; }
.library .lede { color: var(--muted); }
.cards {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.card {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(30, 30, 30, 0.75);
  border-radius: 16px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); border-color: rgba(217, 43, 43, 0.6); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45); outline: none; }
.card-cover {
  height: 240px;
  display: grid;
  place-items: center;
  background: radial-gradient(90% 90% at 50% 100%, rgba(122, 23, 23, 0.45), transparent 70%), #181818;
  padding: 20px;
}
.card-cover { overflow: hidden; }
.card-cover img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 200px;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  background: var(--paper);
}
.card-body { padding: 18px 20px 20px; }
.card-kicker { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--red); }
.card h2 { margin: 6px 0 6px; font-size: 20px; font-weight: 700; color: var(--text); }
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.card-meta { margin-top: 14px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.card-open { color: var(--text); font-weight: 600; }

/* ---------- Demos ---------- */
.demos {
  width: min(1440px, 100%);
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  padding-bottom: 20px;
  min-height: 0;
}
.demos[hidden] { display: none; }
.demo-main { min-width: 0; min-height: 0; overflow-y: auto; }
.player {
  position: relative;
  width: 100%;
  max-height: calc(100dvh - var(--topbar-h) - 200px);
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  margin-inline: auto;
}
.player video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.player .wm { padding: 1.2% 1.6%; mix-blend-mode: normal; }
.player .wm span { color: rgba(255, 255, 255, 0.55); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.demo-info { padding: 18px 2px 0; }
.demo-info .eyebrow { margin: 0 0 6px; }
.demo-info h2 { margin: 0; font-size: clamp(20px, 2.4vw, 28px); font-weight: 800; letter-spacing: -0.02em; }
.demo-blurb { margin: 8px 0 0; color: var(--muted); font-size: 15px; line-height: 1.55; max-width: 70ch; }
.demo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 16px; }
.btn-dark { background: rgba(255, 255, 255, 0.06); color: var(--text); border: 1px solid var(--line); padding: 10px 14px; }
.btn-dark:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.btn-dark:disabled { opacity: 0.35; cursor: default; }
.autoplay { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.autoplay input { accent-color: var(--red); width: 16px; height: 16px; margin: 0; }

.playlist-wrap {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(30, 30, 30, 0.75);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.playlist-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 6px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.playlist { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.playlist button {
  width: 100%;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.playlist button:hover { background: rgba(255, 255, 255, 0.05); }
.playlist button[aria-current="true"] { background: rgba(217, 43, 43, 0.16); box-shadow: inset 3px 0 0 var(--red); }
.playlist button:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #000; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.thumb .dur { position: absolute; right: 4px; bottom: 4px; font-size: 10px; font-weight: 600; background: rgba(0, 0, 0, 0.75); color: #fff; padding: 1px 5px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.thumb .done { position: absolute; left: 4px; top: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--red); color: #fff; font-size: 10px; display: grid; place-items: center; }
.pl-num { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--red); }
.pl-title { display: block; margin-top: 2px; font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.3; }

@media (max-width: 980px) {
  .demos { display: flex; flex-direction: column; height: auto; max-height: 100%; overflow-y: auto; }
  .demos[hidden] { display: none; }
  .demo-main { overflow: visible; flex: none; }
  .playlist-wrap { flex: none; }
  .playlist-wrap { overflow: visible; }
  .playlist { overflow: visible; }
}
@media (max-width: 640px) {
  .player { border-radius: 10px; }
  .demo-actions .btn { flex: 1; }
  .playlist button { grid-template-columns: 96px minmax(0, 1fr); }
}

/* ---------- Zoom ---------- */
.zoom {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 10, 10, 0.96);
  display: flex;
  flex-direction: column;
}
.zoom[hidden] { display: none; }
.zoom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px clamp(16px, 3vw, 40px);
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.zoom-scroll {
  flex: 1;
  overflow: auto;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.zoom-page {
  position: relative;
  width: min(100%, var(--zoom-w, 1000px));
  background: var(--paper);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  user-select: none;
  -webkit-user-select: none;
}
.zoom-page img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.zoom-page .wm { font-size: 11px; }

@media (max-width: 640px) {
  :root { --topbar-h: 56px; --controls-h: 96px; }
  .brand { flex: 1 1 0; }
.brand img { height: 22px; }
  .viewer { display: none; }
  .fields { grid-template-columns: 1fr; }
  .actions { flex-direction: column-reverse; }
  .actions .btn { width: 100%; }
  .hint { display: none; }
  .ctl-fs, .divider { display: none; }
  .doc-tab { padding: 7px 10px; font-size: 12px; }
  .topbar-meta { display: none; }
  .brand { flex: 0 0 auto; margin-right: 10px; }
  .card-cover { height: 190px; }
  .card-cover img { max-height: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  .nda, .declined { animation: none; }
  .stage, .gate { transition: none; }
}

@media print {
  body * { display: none !important; }
  body::after { content: "This document is confidential and may not be printed."; display: block !important; }
}
