body { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
.demo { min-height: 0; padding-top: clamp(8px, 1.5vh, 16px); }
.demo-workspace { display: flex; flex-direction: column; max-height: 100%; padding-bottom: 6px; }
.demo-workspace > * { flex: none; }
.demo-workspace > .demo-view { flex-shrink: 1; min-height: min(140px, 30dvh); }
.demo-wordmark { width: clamp(112px, 14vw, 148px); height: auto; }
.back-link { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; min-height: 36px; padding: 5px 13px; border-radius: 5px; background: var(--blue); color: white; font-size: 14px; font-weight: 600; }
.back-link:hover { background: var(--blue-dark); text-decoration: none; }
.intro { margin-top: 3px; padding: 10px 0 40px; color: var(--muted); font-size: 15px; line-height: 1.65; }
.intro p { margin: 0; }
.intro p + p { margin-top: 5px; }
.toolbar, .actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar { border-block-end: 1px solid var(--line); padding-block: 6px; gap: 6px 18px; }
.actions { margin-right: auto; gap: 8px; }
.file-action { position: relative; cursor: pointer; color: var(--blue); border: 1px solid var(--blue); padding: 5px 14px; min-height: 36px; display: inline-grid; place-items: center; font-size: 15px; font-weight: 600; border-radius: 5px; }
.actions .resource { width: 7em; white-space: nowrap; min-height: 36px; padding: 5px 14px; }
.file-action:hover { background: var(--soft); }
.file-action:focus-within, select:focus-visible { outline: 3px solid #988fee; outline-offset: 3px; }
.field { font-size: 12px; font-weight: 550; color: var(--muted); }
.field select { display: block; }
select { font: inherit; color: var(--ink); background: white; padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; }
.threshold { min-width: 120px; }
.threshold output { float: right; font-variant-numeric: tabular-nums; }
.threshold input { display: block; width: 100%; margin: 6px 0; accent-color: var(--blue); }
.task-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); min-width: 0; padding: 0; margin: 4px 0 6px; border: 0; border-bottom: 1px solid var(--line); }
.task-picker label { position: relative; display: grid; align-content: end; gap: 2px; padding: 5px clamp(4px, 1vw, 12px); margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; }
.task-name { font-size: clamp(13px, 1.8vw, 16px); font-weight: 600; line-height: 1.3; }
.task-picker small { font-size: 12px; }
.task-picker label:has(input:checked) { color: var(--blue); border-color: var(--blue); background: var(--soft); }
.task-picker label:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: -2px; }
.task-picker label:hover { background: var(--soft); }
.task-picker label:has(input:disabled) { opacity: .6; cursor: default; background: none; }
#idle p, .video-actions { color: var(--muted); font-size: 14px; }
.demo-view { position: relative; display: grid; place-items: center; overflow: hidden; aspect-ratio: 16 / 9; background: var(--soft); border: 1px solid var(--line); border-radius: 5px; }
.screen, .screen canvas, #clip-result { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#idle { text-align: center; padding: 12px; }
#idle h2 { font-size: clamp(19px, 3vw, 25px); margin: 0 0 4px; }
#idle p { margin: 0; }
#idle.loading::after, #video-stage.waiting::before {
  content: '';
  display: block;
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: model-loading .8s linear infinite;
}
#idle.loading::after { margin: 14px auto 0; }
#video-stage.waiting::before { width: 17px; height: 17px; flex: none; }
@keyframes model-loading { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) {
  #idle.loading::after, #video-stage.waiting::before { animation: none; }
}
.video-actions { display: flex; flex-wrap: wrap; margin-top: 2px; justify-content: flex-end; align-items: center; gap: 4px 12px; }
#video-stage { margin-right: auto; }
#video-stage.waiting { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px; background: var(--soft); color: var(--blue-dark); font-weight: 600; border-radius: 4px; }
#download-video { min-height: 32px; padding: 4px 12px; font-size: 14px; }
#clear-video { min-width: 9em; text-align: right; border: 0; background: none; color: var(--blue); padding: 4px 0; font-size: inherit; }
#status { overflow-wrap: anywhere; }
#status.error { color: #9c2828; }
#progress { display: block; width: 100%; height: 5px; accent-color: var(--blue); }
.video-actions:has(#clear-video[hidden]) { display: none; }
#metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px 8px; margin: 0; padding: 6px 0; }
#metrics > div { display: flex; align-items: baseline; gap: 6px; }
@media (max-width: 850px) {
  #metrics > div { flex-direction: column; gap: 0; }
}
@media (max-width: 600px) {
  #metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
dt { color: var(--muted); font-size: 12px; }
dd { font-size: 14px; font-weight: 600; margin: 0; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .top-nav .nav-inner { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
  .back-link { margin-left: auto; padding-inline: 8px; font-size: 13px; }
  .actions { width: 100%; }
}
