/* =========================================================
   Notebook film (film.js, film-player.js): the filming pill, the camera
   while filming, the film's card in the notes, the full-window player and
   Save as a video. Tokens only, so dark and light both work; the player
   wears the film's own look while it plays.
   ========================================================= */

/* ── While filming: a breathing dot, the time, Pause and Stop ── */
.nbf-pill {
  --nbf-pill-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  position: fixed;
  left: 50%;
  bottom: var(--nbf-pill-bottom);
  z-index: 1150;
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: calc(100vw - 32px);
  padding: 4px;
  border: 1px solid color-mix(in srgb, var(--red) 28%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.55);
  color: var(--text);
  transform: translateX(-50%);
  animation: nbfRise 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
:root[data-theme="light"] .nbf-pill { box-shadow: 0 10px 26px -14px rgba(20, 24, 40, 0.3); }
@keyframes nbfRise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.nbf-pill button { border: 0; background: transparent; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.nbf-pill-face { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 10px; border-radius: 999px; font: 600 0.78rem/1 var(--font-heading); }
.nbf-pill-k { color: var(--text-dim); }
.nbf-time { min-width: 3.2em; font: 400 0.78rem/1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text); }
.nbf-dot { position: relative; width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--red); }
.nbf-dot::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; background: var(--red); opacity: 0; animation: nbfBreathe 2.4s ease-in-out infinite; }
@keyframes nbfBreathe { 0%, 100% { opacity: 0; transform: scale(0.6); } 45% { opacity: 0.28; transform: scale(1); } }
.nbf-pill[data-phase="paused"] .nbf-dot { background: var(--text-muted); }
.nbf-pill[data-phase="paused"] .nbf-dot::after,
.nbf-pill[data-phase="saving"] .nbf-dot::after { animation: none; }
.nbf-pill-b { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--text-dim) !important; transition: background 0.15s ease, color 0.15s ease; }
.nbf-pill-b svg { width: 15px; height: 15px; }
.nbf-pill-b:hover, .nbf-pill-b:focus-visible { background: color-mix(in srgb, var(--text) 9%, transparent) !important; color: var(--text) !important; outline: none; }
.nbf-pill[data-phase="paused"] [data-film-pause] { color: var(--red) !important; }
.nbf-pill-stop { width: auto; gap: 6px; padding: 0 14px 0 11px; border-radius: 999px; background: color-mix(in srgb, var(--red) 13%, transparent) !important; color: var(--text) !important; font: 600 0.78rem/1 var(--font-heading); display: inline-flex; align-items: center; }
.nbf-pill-stop svg { width: 12px; height: 12px; color: var(--red); }
.nbf-pill-stop:hover, .nbf-pill-stop:focus-visible { background: color-mix(in srgb, var(--red) 22%, transparent) !important; }
.nbf-pill button:disabled { opacity: 0.4; cursor: default; }
@media (pointer: coarse) { .nbf-pill-b, .nbf-pill-face { height: 44px; } .nbf-pill-b:not(.nbf-pill-stop) { width: 44px; } }
/* Phones: above the thumb bar (and the keyboard). */
@media (max-width: 880px) {
  .nbf-pill { --nbf-pill-bottom: calc(var(--nb-kb, 0px) + var(--nb-mobile-bar-h, 64px) + env(safe-area-inset-bottom, 0px) + 12px); }
}
/* Focus: quieter. Flow State: only the dot and the time, in the corner,
   clear of the page and the tools (a tap shows Pause and Stop for a moment). */
html.nb-focus .nbf-pill { opacity: 0.86; }
html.nb-notes-only .nbf-pill {
  --nbf-pill-bottom: calc(max(var(--nb-kb, 0px), env(safe-area-inset-bottom, 0px)) + 6px);
  left: calc(14px + env(safe-area-inset-left, 0px));
  transform: none;
  opacity: 0.7;
  animation-name: nbfRiseC;
}
@keyframes nbfRiseC { from { opacity: 0; transform: translateY(12px); } to { opacity: 0.7; transform: none; } }
html.nb-notes-only .nbf-pill:hover, html.nb-notes-only .nbf-pill:focus-within, html.nb-notes-only .nbf-pill.open { opacity: 1; }
html.nb-notes-only .nbf-pill:not(.open):not(:hover):not(:focus-within) .nbf-pill-b { display: none; }
html.nb-notes-only .nbf-pill:not(.open):not(:hover):not(:focus-within) .nbf-pill-k { display: none; }
@media (max-width: 880px) {
  html.nb-notes-only .nbf-pill { --nbf-pill-bottom: calc(var(--nb-kb, 0px) + var(--nb-mobile-bar-h, 64px) + env(safe-area-inset-bottom, 0px) + 10px); }
  html.nb-notes-only.nb-tray .nbf-pill { --nbf-pill-bottom: calc(var(--nb-kb, 0px) + var(--nb-mobile-bar-h, 64px) + env(safe-area-inset-bottom, 0px) + 62px); }
}
@media print { .nbf-pill { display: none !important; } }

/* Your face while filming: a small circle in the pill. */
.nbf-cam { flex: none; width: 30px; height: 30px; margin-left: -4px; border-radius: 50%; overflow: hidden; border: 1.5px solid color-mix(in srgb, var(--warm) 60%, transparent); background: var(--bg); }
.nbf-cam video, .nbf-cam canvas { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }

/* ── Where Film this session lives ── */
.nbf-fd svg { width: 18px; height: 18px; }
.nbf-fd span { display: none; }
.nbf-fd[aria-pressed="true"] { color: var(--red); }
html.nbf-filming .nbf-fd svg { color: var(--red); }
/* The writing tray (phones): a round button before + Page. */
.nb-tray-pill.nbf-tray { width: 44px; padding: 0; justify-content: center; }
.nb-tray-pill.nbf-tray span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nb-tray-pill.nbf-tray svg { width: 19px; height: 19px; }
.nb-tray-pill.nbf-tray[aria-pressed="true"] { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--border)); }
.nbf-ft .nbf-ft-ic svg { width: 20px; height: 20px; display: block; }
.nbf-ft.on .nbf-ft-ic { color: var(--red); }
.nb-pop-item[data-film-start] .nb-pop-ic { width: 18px; height: 18px; }

/* The question before filming. */
.nbf-ask-lead { margin: 0 0 14px; color: var(--text-dim); font-size: 0.9rem; line-height: 1.55; }
.nbf-ask-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--border); cursor: pointer; }
.nbf-ask-row .nb-set-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.nbf-ask-row .nb-set-title { font: 600 0.92rem/1.3 var(--font-heading); color: var(--text); }
.nbf-ask-row .nb-set-desc { font-size: 0.82rem; line-height: 1.4; color: var(--text-muted); }

/* With the camera: see yourself first, choose the blur, then 3, 2, 1. */
.nbf-ready { display: flex; flex-direction: column; gap: 12px; }
.nbf-ready-view {
  position: relative;
  width: clamp(176px, 54vw, 232px);
  aspect-ratio: 1;
  margin: 2px auto 0;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--warm) 55%, transparent);
  background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--warm) 12%, var(--bg)), var(--bg) 70%);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.nbf-ready-face { position: absolute; inset: 0; }
.nbf-ready-face video, .nbf-ready-face canvas { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.nbf-ready-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0 14%;
  text-align: center;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-dim);
}
.nbf-ready-view[data-state="ready"] .nbf-ready-msg { display: none; }
.nbf-ready-view[data-state="opening"] { animation: nbfOpening 1.6s ease-in-out infinite; }
@keyframes nbfOpening { 50% { border-color: color-mix(in srgb, var(--warm) 22%, transparent); } }
.nbf-ready-view[data-state="failed"] { border-color: var(--border); }
/* The count: a big number over your face, the ring turns red. */
.nbf-ready-view.counting { border-color: var(--red); box-shadow: 0 0 0 5px color-mix(in srgb, var(--red) 16%, transparent); }
.nbf-ready-view.counting::after { content: ''; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.32); pointer-events: none; }
.nbf-count {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  font: 400 clamp(4.6rem, 26vw, 6.6rem)/1 var(--font-display);
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.nbf-count:empty { display: none; }
.nbf-count.tick { animation: nbfTick 1s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes nbfTick { 0% { opacity: 0; transform: scale(1.35); } 18% { opacity: 1; transform: scale(1); } 82% { opacity: 1; } 100% { opacity: 0.25; transform: scale(0.94); } }
.nbf-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
.nbf-blur { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.nbf-blur-k { font: 600 0.7rem/1 var(--font-heading); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.nbf-blur-seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); }
.nbf-blur-o { position: relative; display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border-radius: 999px; font: 600 0.8rem/1 var(--font-heading); color: var(--text-dim); cursor: pointer; transition: background 0.15s ease, color 0.15s ease; -webkit-tap-highlight-color: transparent; }
.nbf-blur-o input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.nbf-blur-o:hover { color: var(--text); }
.nbf-blur-o:has(input:checked) { background: color-mix(in srgb, var(--warm) 20%, var(--bg-elevated)); color: var(--text); }
.nbf-blur-o:has(input:focus-visible) { outline: 2px solid var(--warm); outline-offset: 1px; }
@media (pointer: coarse) { .nbf-blur-o { min-height: 40px; } }
.nbf-ready[data-state="failed"] .nbf-blur, .nbf-ready[data-state="failed"] .nbf-blur-says { display: none; }
.nbf-blur-says { margin: -2px 0 0; min-height: 2.6em; text-align: center; font-size: 0.82rem; line-height: 1.45; color: var(--text-muted); }
@media (prefers-reduced-motion: reduce) {
  .nbf-count.tick, .nbf-ready-view[data-state="opening"] { animation: none; }
}

/* ── The film in the notes ── */
.nb-block.film { align-items: center; }
.nbf-card {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 6px 0;
  padding: 12px 12px 12px 26px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--warm) 9%, transparent), transparent 55%),
    var(--bg-card, var(--bg2));
  overflow: hidden;
  user-select: none;
}
/* A strip of film down the left edge. */
.nbf-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 14px;
  background: radial-gradient(circle at 50% 50%, var(--bg) 0 2.2px, transparent 2.7px) 0 3px / 14px 11px repeat-y, color-mix(in srgb, var(--text) 9%, var(--bg-card, var(--bg2)));
  border-right: 1px solid var(--border);
}
.nbf-pending { min-height: 72px; }
.nbf-card-play {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--warm);
  color: #1a1612;
  cursor: pointer;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--warm) 80%, transparent);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), filter 0.15s ease;
}
.nbf-card-play svg { width: 20px; height: 20px; margin-left: 3px; }
.nbf-card-play:hover { transform: scale(1.05); filter: brightness(1.05); }
.nbf-card-play:focus-visible { outline: 2px solid var(--warm); outline-offset: 3px; }
.nbf-card-body { flex: 1; min-width: 0; }
.nbf-card-body p { margin: 0; }
.nbf-card-top { display: flex; align-items: baseline; gap: 8px; }
.nbf-card-k { font: 400 0.68rem/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--warm); }
.nbf-card-dur { font: 400 0.74rem/1 var(--font-mono); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.nbf-card-first { margin-top: 5px !important; font-family: var(--font-display); font-style: italic; font-size: 1.02rem; line-height: 1.35; color: var(--text); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.nbf-card-meta { margin-top: 5px !important; font-size: 0.76rem; line-height: 1.35; color: var(--text-muted); overflow-wrap: anywhere; }
.nbf-card-save {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border2, var(--border));
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font: 600 0.76rem/1 var(--font-heading);
  cursor: pointer;
}
.nbf-card-save svg { width: 15px; height: 15px; }
.nbf-card-save:hover, .nbf-card-save:focus-visible { color: var(--text); border-color: var(--border-hover); background: color-mix(in srgb, var(--text) 5%, transparent); outline: none; }
@media (pointer: coarse) { .nbf-card-save { min-height: 44px; } .nbf-card-play { width: 48px; height: 48px; } }
@media (max-width: 520px) {
  .nbf-card { gap: 11px; padding-right: 8px; }
  .nbf-card-save { width: 44px; padding: 0; justify-content: center; }
  .nbf-card-save span { display: none; }
}

/* ── The player ── */
html.nbf-watching, html.nbf-watching body { overflow: hidden !important; }
.nbf-player {
  position: fixed;
  inset: 0;
  z-index: 10100;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(90% 60% at 50% 0%, color-mix(in srgb, var(--warm) 5%, transparent), transparent 70%),
    var(--bg);
  color: var(--text);
  animation: nbfFade 0.36s ease both;
}
@keyframes nbfFade { from { opacity: 0; } to { opacity: 1; } }
.nbf-stage { position: relative; flex: 1; min-height: 0; }
/* The soundscape as it was (js/ambient.js styles .em-wash, .em-particles and
   the .amb-* particles): behind the page, resting while the film rests. */
.nbf-amb { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.nbf-player:not(.playing) .nbf-amb .em-particles * { animation-play-state: paused; }
.nbf-scroll { position: absolute; inset: 0; z-index: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; }
.nbf-scroll:focus { outline: none; }
.nbf-page {
  --nb-h1: 1.85rem;
  --nb-h2: 1.4rem;
  --nb-h3: 1.1rem;
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  padding: 76px 48px 46vh;
}
.nbf-page .nb-block { padding-left: 22px; }
.nbf-page .nb-block-content.nbf-text { line-height: 1.72; word-break: break-word; outline: none; }
.nbf-page .nb-block-content.nbf-text:empty::before { content: '\200b'; }
.nbf-page .nb-block.h1 .nbf-text, .nbf-page .nb-block.h2 .nbf-text, .nbf-page .nb-block.h3 .nbf-text { line-height: 1.25; }
.nbf-cover { margin-bottom: 22px; }
.nbf-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 2.2rem; line-height: 1.12; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.nbf-where { margin: 10px 0 0; font: 400 0.7rem/1.3 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.nbf-where:empty { display: none; }
/* Code, cards and pictures are the editor's own views, still: nothing to press, nothing that plays. */
.nbf-page .nb-code-pre { position: static; overflow: hidden; }
.nbf-page .nbf-static, .nbf-page .nb-web { pointer-events: none; }
.nbf-page .nb-web-more, .nbf-page .nb-vid-note { display: none !important; }
/* The video's own copy of the page, laid out where nobody sees it (never hidden: it must lay out and load). */
.nbf-vstage { position: fixed; left: -40000px; top: 0; z-index: -1; pointer-events: none; contain: layout style; }
.nbf-vstage .nbf-page { margin: 0; padding: 0; max-width: none; }
.nbf-static { min-width: 0; }
.nbf-unseen { color: var(--text-muted); font-style: italic; }
/* The caret, the selection, the clicks. */
.nbf-caret {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 22px;
  border-radius: 1px;
  background: var(--warm);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warm) 14%, transparent), 0 0 14px color-mix(in srgb, var(--warm) 55%, transparent);
  pointer-events: none;
  transition: transform 0.07s linear, height 0.12s ease;
  will-change: transform;
}
.nbf-caret.jump { transition: height 0.12s ease; }
.nbf-caret.idle { animation: nbfBlink 1.06s steps(1) infinite; }
@keyframes nbfBlink { 50% { opacity: 0; } }
.nbf-sel { position: absolute; inset: 0 auto auto 0; pointer-events: none; }
.nbf-sel i { position: absolute; border-radius: 3px; background: color-mix(in srgb, var(--warm) 26%, transparent); }
.nbf-ripples { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.nbf-ripple {
  position: absolute;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--warm) 70%, transparent);
  background: radial-gradient(circle, color-mix(in srgb, var(--warm) 16%, transparent), transparent 70%);
  animation: nbfRipple 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes nbfRipple { from { opacity: 0.9; transform: scale(0.2); } to { opacity: 0; transform: scale(1); } }
/* Captions and the face. */
.nbf-cc {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 2;
  max-width: min(680px, calc(100% - 32px));
  margin: 0;
  padding: 9px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text);
  font: 500 1rem/1.4 var(--font-heading);
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}
.nbf-cc[hidden] { display: none; }
.nbf-face {
  position: absolute;
  right: 22px;
  bottom: 18px;
  z-index: 2;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--warm) 55%, transparent);
  background: var(--bg-elevated);
  box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.55);
}
.nbf-face[hidden] { display: none; }
.nbf-face video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
/* The top: what this is, and the way out. */
.nbf-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px 20px;
  background: linear-gradient(to bottom, var(--bg) 30%, color-mix(in srgb, var(--bg) 0%, transparent));
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.nbf-top > * { pointer-events: auto; }
.nbf-top-t { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.nbf-top-k { display: inline-flex; align-items: center; gap: 7px; font: 400 0.7rem/1 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); }
.nbf-top-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.nbf-player.playing .nbf-top-dot { animation: nbfPulse 2.4s ease-in-out infinite; }
@keyframes nbfPulse { 50% { opacity: 0.35; } }
.nbf-top-w { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nbf-top-s { font-size: 0.78rem; color: var(--text-dim); white-space: nowrap; }
.nbf-top-s::before { content: '·'; margin-right: 10px; color: var(--text-muted); }
@media (max-width: 760px) { .nbf-top-t:has(.nbf-top-s:not([hidden])) .nbf-top-w { display: none; } }   /* a phone: the soundscape's name instead of the date */
.nbf-x { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: color-mix(in srgb, var(--bg-elevated) 85%, transparent); color: var(--text-dim); cursor: pointer; }
.nbf-x svg { width: 18px; height: 18px; }
.nbf-x:hover, .nbf-x:focus-visible { color: var(--text); border-color: var(--border-hover); outline: none; }
/* The bar. */
.nbf-bar {
  position: relative;
  z-index: 3;
  flex: none;
  padding: 6px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--bg-elevated) 86%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.nbf-player.playing:not(.bar-on) .nbf-bar { opacity: 0; transform: translateY(10px); pointer-events: none; }
.nbf-player.playing:not(.bar-on) .nbf-top { opacity: 0; }
.nbf-player.playing:not(.bar-on) .nbf-top .nbf-x { pointer-events: none; }
.nbf-player.playing:not(.bar-on) { cursor: none; }
.nbf-scrub-row { display: flex; align-items: center; height: 26px; }
.nbf-scrub {
  --v: 0%;
  flex: 1;
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.nbf-scrub::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--warm) var(--v), color-mix(in srgb, var(--text) 16%, transparent) var(--v)); }
.nbf-scrub::-moz-range-track { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--text) 16%, transparent); }
.nbf-scrub::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--warm); }
.nbf-scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: var(--warm); border: 2px solid var(--bg); box-shadow: 0 0 0 1px color-mix(in srgb, var(--warm) 60%, transparent); }
.nbf-scrub::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--warm); border: 2px solid var(--bg); }
.nbf-scrub:focus-visible { outline: none; }
.nbf-scrub:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--warm) 35%, transparent); }
.nbf-row { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.nbf-row button { -webkit-tap-highlight-color: transparent; }
.nbf-play { flex: none; display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: var(--warm); color: #1a1612; cursor: pointer; }
.nbf-play svg { width: 20px; height: 20px; }
.nbf-play:focus-visible { outline: 2px solid var(--warm); outline-offset: 3px; }
.nbf-time { flex: none; font: 400 0.78rem/1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-muted); white-space: nowrap; }
.nbf-time b { font-weight: 400; color: var(--text); }
.nbf-gap { flex: 1; }
.nbf-speed { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: 999px; background: color-mix(in srgb, var(--bg) 50%, transparent); }
.nbf-speed button { min-width: 40px; height: 34px; padding: 0 11px; border: 0; border-radius: 999px; background: transparent; color: var(--text-dim); font: 600 0.76rem/1 var(--font-heading); cursor: pointer; white-space: nowrap; }
.nbf-speed button[aria-checked="true"] { background: color-mix(in srgb, var(--warm) 18%, var(--bg-elevated)); color: var(--text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warm) 40%, transparent); }
.nbf-speed button:focus-visible { outline: 2px solid var(--warm); outline-offset: 1px; }
.nbf-ib { flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-dim); cursor: pointer; }
.nbf-ib svg { width: 20px; height: 20px; }
.nbf-ib[aria-pressed="false"] { color: var(--text-muted); }
.nbf-ib:hover, .nbf-ib:focus-visible { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); outline: none; }
.nbf-save { flex: none; display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 16px 0 13px; border: 1px solid var(--border2, var(--border)); border-radius: 999px; background: transparent; color: var(--text); font: 600 0.8rem/1 var(--font-heading); cursor: pointer; white-space: nowrap; }
.nbf-save svg { width: 16px; height: 16px; }
.nbf-save:hover, .nbf-save:focus-visible { border-color: var(--border-hover); background: color-mix(in srgb, var(--text) 6%, transparent); outline: none; }
/* Phones: the page to the edges (16 px), the bar in two rows. */
@media (max-width: 760px) {
  .nbf-page { padding: 72px 16px 44vh; }
  .nbf-page .nb-block { padding-left: 0; }
  .nbf-title { font-size: 1.7rem; }
  .nbf-face { width: 84px; height: 84px; right: 16px; }
  .nbf-cc { font-size: 0.92rem; bottom: 14px; }
  .nbf-bar { padding: 4px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .nbf-row { flex-wrap: wrap; row-gap: 6px; column-gap: 6px; }
  .nbf-speed { order: 9; flex: 1 1 100%; justify-content: space-between; }
  .nbf-speed button { flex: 1; height: 36px; padding: 0 6px; }
  .nbf-save { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .nbf-save span { display: none; }
  .nbf-top { padding-left: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .nbf-player, .nbf-pill { animation: none; }
  .nbf-caret { transition: none; }
  .nbf-dot::after, .nbf-player.playing .nbf-top-dot { animation: none; }
}

/* ── Save as a video ── */
.nbf-x-sheet { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; padding: 16px; }
.nbf-x-back { position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.nbf-x-panel {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100% - 8px);
  overflow-y: auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-elevated);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.6);
  animation: nbfRiseIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes nbfRiseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.nbf-x-t { margin: 0 0 14px; font-family: var(--font-display); font-weight: 400; font-size: 1.45rem; }
.nbf-x-k { margin: 14px 0 7px; font: 400 0.68rem/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.nbf-x-seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.nbf-x-speeds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.nbf-x-seg button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 64px; padding: 8px 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-card, var(--bg2)); color: var(--text-dim); font: 600 0.82rem/1.2 var(--font-heading); cursor: pointer; }
.nbf-x-seg button small { font: 400 0.72rem/1 var(--font-mono); color: var(--text-muted); }
.nbf-x-seg button[aria-checked="true"] { border-color: color-mix(in srgb, var(--warm) 65%, transparent); background: color-mix(in srgb, var(--warm) 10%, var(--bg-card, var(--bg2))); color: var(--text); }
.nbf-x-seg button:focus-visible { outline: 2px solid var(--warm); outline-offset: 2px; }
.nbf-x-ar { display: block; border: 1.6px solid currentColor; border-radius: 3px; opacity: 0.8; }
.nbf-x-ar.wide { width: 30px; height: 17px; }
.nbf-x-ar.tall { width: 15px; height: 26px; }
.nbf-x-note { margin: 14px 0 0; font-size: 0.8rem; line-height: 1.5; color: var(--text-muted); }
/* This tab runs an older video maker than the site has now: reload first. */
.nbf-x-new { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; margin: 14px 0 0; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--warm) 13%, transparent); border: 1px solid color-mix(in srgb, var(--warm) 42%, transparent); }
.nbf-x-new[hidden] { display: none; }
.nbf-x-new p { flex: 1 1 210px; margin: 0; font-size: 0.85rem; line-height: 1.45; color: var(--text); }
.nbf-x-new button { min-height: 44px; flex: none; }
.nbf-x-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.nbf-x-acts button { min-height: 44px; }
.nbf-x-prev { display: flex; justify-content: center; border-radius: 12px; overflow: hidden; background: var(--bg); border: 1px solid var(--border); }
.nbf-x-canvas { display: block; max-width: 100%; max-height: 46vh; height: auto; }
.nbf-x-bar { height: 4px; margin-top: 14px; border-radius: 2px; background: color-mix(in srgb, var(--text) 14%, transparent); overflow: hidden; display: flex; justify-content: center; }
.nbf-x-bar i { display: block; width: 0; height: 100%; background: var(--warm); transition: width 0.25s linear; }
.nbf-x-st { margin: 12px 0 0; font-size: 0.88rem; color: var(--text-dim); }
.nbf-x-ready { color: var(--text); font-size: 0.95rem; }
