.formula-video-page {
  width: min(100%, 1260px);
  margin-inline: auto;
  padding-bottom: 18px;
  box-sizing: border-box;
}
.formula-video-page__head { display: grid; gap: 8px; margin-bottom: 18px; }
.formula-video-page__head h1 { font: 600 clamp(24px, 4vw, 40px)/1.08 var(--font-heading); margin: 0; }
.formula-video-page__back { width: fit-content; color: var(--text-muted); font-size: 13px; }
.formula-video-page__back:hover { color: var(--accent); }

:is(.formula-video-editor, .ve-settings-sheet) {
  --ve-panel: var(--surface);
  --ve-stage: color-mix(in srgb, var(--surface) 36%, var(--bg));
  --ve-raised: var(--bg-card-2);
  --ve-line: color-mix(in srgb, var(--text) 13%, var(--surface));
  --ve-line-strong: color-mix(in srgb, var(--text-muted) 46%, var(--surface));
  --ve-hover: color-mix(in srgb, var(--text) 14%, var(--surface));
  --ve-accent: var(--accent);
  --ve-selected: color-mix(in srgb, var(--ve-accent) 10%, var(--surface));
  --ve-clip-radius: calc(var(--radius-sm) / 2);
  --ve-pad: clamp(10px, 2vw, 20px);
  color: var(--text);
  color-scheme: dark;
  font: 400 14px/1.35 var(--font-body);
}
.formula-video-editor {
  background: var(--ve-panel);
  border: 1px solid var(--ve-line);
  border-radius: var(--radius-xl);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  min-width: 0;
  container-type: inline-size;
}
:is(.formula-video-editor, .ve-inspector) *, .formula-video-editor *::before, .formula-video-editor *::after { box-sizing: border-box; }
:is(.formula-video-editor, .ve-inspector) [hidden], .ve-inspector[hidden] { display: none !important; }
:is(.formula-video-editor, .ve-inspector) :is(button, input):focus-visible { outline: 2px solid var(--ve-accent); outline-offset: 2px; }
:is(.formula-video-editor, .ve-inspector) button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; background: transparent; color: inherit;
  font: inherit; cursor: pointer; white-space: nowrap; border-radius: var(--radius-sm);
}
:is(.formula-video-editor, .ve-inspector) button:disabled { opacity: .36; cursor: default; }
:is(.formula-video-editor, .ve-inspector) button:hover:not(:disabled) { background-color: var(--ve-hover); }
.formula-video-editor svg { width: 19px; height: 19px; flex: 0 0 auto; display: block; }
.ve-top, .ve-transport, .ve-timeline__head, .ve-inspector { padding-inline: var(--ve-pad); }
.ve-top, .ve-source, .ve-top__actions, .ve-empty__actions, .ve-transport__group, .ve-timeline__head {
  display: flex; align-items: center; gap: 10px;
}
.ve-top { min-height: 54px; justify-content: space-between; padding-block: 8px; }
.ve-source { min-width: 0; flex: 1; }
.ve-top__actions { flex: none; }
.ve-source__icon { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: var(--radius-sm); color: var(--text-muted); background: var(--ve-raised); }
.ve-source > div { min-width: 0; }
.ve-source strong, .ve-source small { display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.ve-source strong { font-weight: 650; }
.ve-source small { color: var(--text-muted); font-size: 11px; margin-top: 3px; }
.formula-video-editor .ve-button, .ve-inspector .ve-button { padding: 7px 12px; min-height: 34px; background: var(--ve-raised); border-color: var(--ve-line); font-size: 12px; font-weight: 650; }
.formula-video-editor .ve-button:hover:not(:disabled), .ve-inspector .ve-button:hover:not(:disabled) { background: var(--ve-hover); }
.formula-video-editor .ve-button svg { width: 16px; height: 16px; }
.formula-video-editor .ve-button--primary, .ve-inspector .ve-button--primary {
  background: var(--ve-accent); color: var(--accent-foreground); border-color: var(--ve-accent);
}
.formula-video-editor .ve-button--primary:hover:not(:disabled), .ve-inspector .ve-button--primary:hover:not(:disabled) { background: var(--accent-2); }
.ve-stage {
  display: grid; place-items: center; position: relative; padding: 12px; overflow: hidden;
  background: var(--ve-stage);
  height: clamp(260px, 46vh, 530px);
}
.ve-stage.is-drop-target { box-shadow: inset 0 0 0 2px var(--ve-accent); }
.ve-empty { display: grid; justify-items: center; text-align: center; gap: 9px; }
.ve-empty__icon {
  display: grid; place-items: center; width: 58px; height: 58px;
  border: 1px solid var(--accent-line); background: var(--ve-selected); border-radius: var(--radius-md);
  color: var(--ve-accent); margin-bottom: 5px;
}
.ve-empty__icon svg { width: 27px; height: 27px; }
.ve-empty strong { font: 600 22px/1.2 var(--font-heading); }
.ve-empty p { color: var(--text-muted); margin: 0; font-size: 12px; }
.ve-empty__actions { margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.ve-picture { display: flex; align-items: center; justify-content: center; position: absolute; inset: 12px; }
.ve-picture video { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; border-radius: var(--ve-clip-radius); outline: 1px solid var(--accent-line); cursor: pointer; }
.ve-preview-frame { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; background: var(--ve-stage); border-radius: var(--ve-clip-radius); }
.ve-transport {
  background: var(--ve-stage); display: grid; align-items: center;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); min-height: 44px;
}
.ve-transport__group { gap: 4px; }
.ve-transport__group--end { justify-content: flex-end; }
.formula-video-editor .ve-icon-button { width: 34px; height: 34px; padding: 0; }
.formula-video-editor .ve-play svg { width: 23px; height: 23px; }
.ve-time { display: grid; text-align: center; gap: 4px; font: 600 12px/1 ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.ve-time__total { color: var(--text-muted); font-weight: 400; font-size: 11px; }
.ve-timeline { position: relative; background: var(--ve-stage); min-width: 0; }
.ve-timeline__head {
  position: relative; z-index: 2; height: 36px; background: var(--ve-panel);
  color: var(--text-muted); font-size: 11px; border-block: 1px solid var(--ve-line);
}
.ve-timeline__head :is(button, label) { pointer-events: auto; }
.ve-timeline__head .ve-icon-button { width: 28px; height: 28px; }
.ve-timeline__head button[aria-pressed="true"] { color: var(--ve-accent); }
.ve-zoom { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.ve-zoom svg { width: 15px; height: 15px; }
.ve-zoom input { width: clamp(58px, 14cqw, 110px); }
:is(.formula-video-editor, .ve-inspector) input[type="range"] { accent-color: var(--ve-accent); cursor: pointer; min-width: 0; }
.ve-scroll { min-width: 0; overflow-x: auto; scrollbar-width: none; overscroll-behavior-inline: contain; overflow-anchor: none; scroll-behavior: auto; }
.ve-scroll::-webkit-scrollbar { display: none; }
.ve-track {
  position: relative; min-width: 100%; height: 158px; touch-action: pan-y; user-select: none; -webkit-touch-callout: none;
  cursor: grab; overflow: hidden;
}
.ve-track:active { cursor: grabbing; }
.ve-ruler { position: relative; height: 37px; }
.ve-tick { position: absolute; top: 4px; height: 24px; padding-top: 1px; transform: translateX(-50%); font: 10px/1 ui-monospace, monospace; color: var(--text-muted); white-space: nowrap; pointer-events: none; }
.ve-tick::after { content: ""; position: absolute; bottom: 0; left: 50%; width: 1px; height: 6px; background: var(--ve-line-strong); }
.ve-tick[data-minor]::after { height: 8px; opacity: .65; }
.ve-clips { position: absolute; inset: 66px 0 auto; height: 61px; background: var(--ve-panel); }
.ve-clip {
  position: absolute; top: 0; height: 100%;
  isolation: isolate; color: var(--text); border: 1px solid var(--ve-line-strong); border-radius: var(--ve-clip-radius);
}
.ve-clip.is-selected { z-index: 1; border: 2px solid var(--ve-accent); color: var(--ve-accent); }
.ve-clips[data-reordering] .ve-clip { transition: transform 160ms cubic-bezier(.2,.8,.25,1); }
.ve-clips[data-reordering] .ve-clip.is-dragging {
  z-index: 4; transition: none; border-color: var(--ve-accent);
  box-shadow: 0 9px 18px color-mix(in srgb, var(--bg) 72%, transparent); outline: 2px solid var(--ve-accent);
}
.ve-clips[data-reordering] .ve-handle { visibility: hidden; }
@media (prefers-reduced-motion: reduce) {
  .ve-clips[data-reordering] .ve-clip { transition: none; }
}
.formula-video-editor .ve-clip__hit { position: absolute; inset: 0; width: 100%; border: 0; border-radius: var(--ve-clip-radius); overflow: hidden; padding: 0; justify-content: start; background-color: var(--ve-raised); cursor: inherit; }
.formula-video-editor .ve-clip__hit:hover:not(:disabled) { background-color: var(--ve-hover); }
.ve-clip__tiles { position: absolute; inset: 0; display: flex; pointer-events: none; }
.ve-clip__tiles span { flex: 1; min-width: 0; background-size: cover; background-position: center; background-color: var(--ve-panel); }
.ve-clip__label { position: relative; align-self: start; background: color-mix(in srgb, var(--bg) 88%, transparent); color: var(--text); font: 10px/1 ui-monospace, monospace; padding: 4px 5px; border-radius: var(--ve-clip-radius); margin: 4px 10px; pointer-events: none; }
.formula-video-editor .ve-handle {
  position: absolute; top: -2px; height: calc(100% + 4px); width: 15px;
  border: 0; border-radius: var(--ve-clip-radius); padding: 0; background: var(--ve-accent);
  color: var(--accent-foreground); cursor: ew-resize;
}
.formula-video-editor .ve-handle:hover:not(:disabled) { background: var(--accent-2); }
.ve-handle::after { content: ""; height: 18px; width: 3px; border-radius: 3px; background: currentColor; }
.ve-handle--start { left: -4px; }
.ve-handle--end { right: -4px; }
.ve-clip[data-narrow] .ve-handle--start { left: -14px; }
.ve-clip[data-narrow] .ve-handle--end { right: -14px; }
.ve-playhead { position: absolute; top: 46px; bottom: 8px; left: 50%; width: 3px; transform: translateX(-50%); border-radius: 3px; background: var(--text); z-index: 3; pointer-events: none; }
.ve-playhead[data-snapped] { background: var(--ve-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ve-accent) 20%, transparent); }
.ve-track__empty { position: absolute; inset: 66px 0 auto; height: 61px; display: grid; place-items: center; color: var(--text-muted); font-size: 12px; pointer-events: none; }
.ve-scrub { position: absolute; top: 42px; left: 60px; opacity: 0; width: 120px; pointer-events: none; }
.ve-scrub:focus-visible { z-index: 4; opacity: 1; pointer-events: auto; }
.ve-tools { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; padding: 2px var(--ve-pad) 9px; background: var(--ve-stage); }
.formula-video-editor .ve-tool { flex-direction: column; min-height: 49px; color: var(--text-muted); font-size: 11px; gap: 5px; }
.formula-video-editor .ve-tool svg { width: 22px; height: 22px; color: var(--text); }
.formula-video-editor .ve-tool[aria-expanded="true"] { background: var(--ve-selected); color: var(--ve-accent); }
.formula-video-editor .ve-tool[aria-expanded="true"] svg { color: var(--ve-accent); }
.sheet.ve-settings-sheet {
  --sheet-bg: var(--ve-panel);
  --sheet-color: var(--text);
  --sheet-muted: var(--text-muted);
  --sheet-radius: var(--radius-xl);
  --sheet-accent: var(--ve-accent);
  --sheet-handle: var(--ve-line-strong);
  --sheet-close-icon: var(--text-muted);
  --sheet-close-bg: var(--ve-raised);
  --sheet-close-bg-hov: var(--ve-hover);
}
.sheet-layer[data-mode="modal"] .sheet.ve-settings-sheet { border-radius: var(--sheet-radius); }
.ve-settings-sheet .sheet__title { font-family: var(--font-heading); }
.ve-settings-sheet > .sheet__body { padding-bottom: calc(12px + var(--sheet-safe-bottom)); }
.ve-inspector { padding: 2px 0 6px; }
.ve-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ve-fields label { color: var(--text-muted); font-size: 11px; display: grid; gap: 4px; }
.ve-fields input { display: block; width: 100%; min-height: 42px; padding: 5px 7px; font: inherit; font-size: 14px; color: var(--text); background: var(--ve-stage); border: 1px solid var(--ve-line); border-radius: var(--radius-sm); }
.ve-adjustment { display: grid; gap: 4px; font-size: 14px; }
.ve-adjustment span { display: flex; align-items: center; justify-content: space-between; }
.ve-adjustment output { color: var(--ve-accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.ve-adjustment input { display: block; height: 38px; width: 100%; margin: 0; }
.ve-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-block: 4px 14px; }
.ve-inspector .ve-presets .ve-button { flex: 1 1 38px; padding-inline: 8px; }
.ve-inspector .ve-presets .ve-button[aria-pressed="true"] { background: var(--ve-selected); border-color: var(--ve-accent); color: var(--ve-accent); }
.ve-range { margin: 0 0 14px; }
.ve-range summary { cursor: pointer; padding: 8px 0; color: var(--text-muted); }
.ve-range[open] summary { margin-bottom: 5px; }
.ve-fields--range { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ve-inspector .ve-apply { display: flex; width: 100%; min-height: 46px; }
.ve-inspector__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.ve-inspector .ve-button { min-height: 42px; }
.ve-trim-preview {
  position: relative; display: grid; place-items: center;
  height: clamp(100px, 26dvh, 220px); overflow: hidden;
  background: var(--ve-stage); border-radius: var(--radius-md);
}
.ve-trim-preview video { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.ve-trim-preview span {
  position: absolute; inset: auto auto 8px 8px; padding: 4px 8px;
  border-radius: var(--radius-sm); background: var(--ve-stage); color: var(--text); font-size: 11px;
}
.ve-trim-hint { margin: 10px 0 6px; color: var(--text-muted); font-size: 12px; }
.ve-trim-rail {
  --trim-handle: 26px; position: relative; height: 48px;
  touch-action: none; user-select: none; cursor: ew-resize;
}
.ve-trim-track {
  position: absolute; inset: 3px var(--trim-handle); overflow: hidden;
  border-radius: var(--ve-clip-radius); background: var(--ve-stage);
}
.ve-trim-selection {
  position: absolute; inset: 0 calc(100% - var(--trim-end, 100%)) 0 var(--trim-start, 0%);
  border-block: 2px solid var(--ve-accent); box-shadow: 0 0 0 100vmax #0009;
}
.ve-inspector .ve-trim-rail input {
  position: absolute; inset: 0 auto 0 0; appearance: none; width: calc(100% - var(--trim-handle)); height: 100%;
  margin: 0; padding: 0; border: 0; background: transparent; pointer-events: none;
}
.ve-inspector .ve-trim-rail input[name="endEdge"] { inset-inline: auto 0; }
.ve-trim-rail input:focus-visible { z-index: 1; }
.ve-trim-rail input::-webkit-slider-runnable-track { height: 48px; background: transparent; }
.ve-trim-rail input::-moz-range-track { height: 48px; background: transparent; }
.ve-trim-rail input::-webkit-slider-thumb {
  appearance: none; width: var(--trim-handle); height: 48px; border: 0; border-radius: var(--radius-sm);
  color: var(--accent-foreground); background: var(--ve-accent)
    linear-gradient(currentColor, currentColor) center / 3px 16px no-repeat;
}
.ve-trim-rail input::-moz-range-thumb {
  width: var(--trim-handle); height: 48px; border: 0; border-radius: var(--radius-sm);
  color: var(--accent-foreground); background: var(--ve-accent)
    linear-gradient(currentColor, currentColor) center / 3px 16px no-repeat;
}
.ve-trim-readout { display: flex; justify-content: space-between; gap: 6px; margin-block: 8px; }
.ve-trim-readout span { display: grid; gap: 3px; color: var(--text-muted); font-size: 11px; }
.ve-trim-readout span:nth-child(2) { text-align: center; }
.ve-trim-readout span:last-child { text-align: right; }
.ve-trim-readout output { color: var(--text); font: 600 12px/1.3 ui-monospace, monospace; }
[data-ve-panel="trim"] > .ve-range { margin-bottom: 8px; }
@media (max-height: 500px) {
  [data-ve-panel="trim"] > .ve-trim-preview { height: 94px; }
}
.ve-script-hint { padding-inline: var(--ve-pad); }
@container (max-width: 520px) {
  .ve-top { min-height: 51px; }
  .ve-source__icon { width: 30px; height: 30px; flex-basis: 30px; }
  .ve-top__actions { gap: 4px; }
  .formula-video-editor .ve-replace span { display: none; }
  .ve-stage { height: clamp(230px, 44dvh, 410px); }
  .ve-transport__group { gap: 1px; }
  .ve-tools { padding-inline: 3px; gap: 0; }
  .formula-video-editor .ve-tool { font-size: clamp(9px, 2.8cqw, 11px); }
  .formula-video-editor .ve-handle { width: 17px; }
  .ve-track { height: 170px; }
}
.nf-composer__sheet-host[data-mode="modal"] .nf-composer__reference-editor-sheet {
  width: min(940px, calc(100vw - 40px));
}
.nf-composer__sheet-host .nf-composer__reference-editor-sheet > .sheet__title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  margin: 0;
  padding: 0;
}
.nf-composer__sheet-host .nf-composer__reference-editor-sheet > .sheet__body {
  padding: 0 0 env(safe-area-inset-bottom, 0px);
}
.nf-composer__sheet-host .nf-composer__reference-editor-sheet > .sheet__close-icon { top: 7px; }
.nf-composer__sheet-host[data-mode="sheet"] .nf-composer__reference-editor-sheet > .sheet__close-icon { top: 32px; }
.formula-video-editor[data-ve-reference] { border: 0; border-radius: 0; }
.formula-video-editor[data-ve-reference] .ve-top { min-height: 46px; padding-block: 4px; padding-inline-end: 54px; }
.formula-video-editor[data-ve-reference] .ve-stage {
  height: clamp(84px, min(42dvh, calc(86dvh - 350px - var(--ve-role-height, 0px) - env(safe-area-inset-bottom, 0px))), 380px);
}
.formula-video-editor[data-ve-reference] .ve-track { height: 105px; }
.formula-video-editor[data-ve-reference] :is(.ve-clips, .ve-track__empty) { top: 39px; height: 53px; }
.formula-video-editor[data-ve-reference] .ve-transport { min-height: 38px; }
.formula-video-editor[data-ve-reference] .ve-tools { padding-bottom: 5px; }
.formula-video-editor[data-ve-reference] .ve-tool { min-height: 43px; padding-inline: 1px; white-space: normal; line-height: 1.15; }
.formula-video-editor[data-ve-reference] .ve-scrub { width: 120px; margin: 0; padding: 0; }
.formula-video-editor[data-ve-reference] .ve-zoom { display: flex; margin: 0 0 0 auto; }
.formula-video-editor[data-ve-reference] .ve-zoom input {
  width: clamp(58px, 14cqw, 110px);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.ve-frame-actions { display: grid; gap: 8px; }
@media (max-height: 670px) {
  .formula-video-editor[data-ve-reference] .ve-track { height: 84px; }
  .formula-video-editor[data-ve-reference] :is(.ve-clips, .ve-track__empty) { top: 32px; height: 42px; }
}
.ve-reference-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  padding: 7px var(--ve-pad);
  border-top: 1px solid var(--ve-line);
}
.ve-reference-role { margin-inline-end: auto; min-width: 0; max-width: 100%; }
.ve-reference-role > label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
@container (max-width: 520px) {
  .ve-reference-role { flex: 0 0 100%; }
  .ve-reference-actions .ve-button { flex: 1; }
  [data-ve-reference]:has(.ve-reference-role:not([hidden])) .ve-stage { --ve-role-height: 45px; }
}
@media (min-width: 600px) and (max-height: 500px) {
  .formula-video-editor[data-ve-reference] { grid-template-columns: minmax(0, 1fr) minmax(300px, 1fr); }
  [data-ve-reference] .ve-top { grid-column: 1 / -1; }
  .formula-video-editor[data-ve-reference] .ve-stage { grid-area: 2 / 1 / 6 / 2; height: auto; min-height: 110px; }
  [data-ve-reference] :is(.ve-transport, .ve-timeline, .ve-tools, .ve-reference-actions) { grid-column: 2; }
}
