:root {
  color-scheme: dark;
  --ink: #0f0e0d;
  --surface: #171614;
  --surface-raised: #1f1d1b;
  --surface-hover: #272523;
  --surface-pressed: #121110;
  --line: #2b2926;
  --line-strong: #3c3935;
  --line-hover: #4b4742;
  --track: #302e2a;
  --icon-alert: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill-rule='evenodd' d='M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1Zm-.75 3.5h1.5v4.5h-1.5Zm0 6h1.5V12h-1.5Z'/></svg>");
  --text: #eeebe6;
  --text-muted: #a29c93;
  --accent: #5aa9ff;
  --accent-ink: var(--ink);
  --text-s: 13px;
  --text-m: 15px;
  --text-l: 17px;
  --leading: 1.5;
  --radius: 8px;
  --radius-small: 6px;
  --gap: 12px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-m);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

h1,
h2,
p,
ul,
dl,
dd {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-m);
}

.muted {
  color: var(--text-muted);
}

.masthead {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 18px clamp(14px, 3vw, 28px) 10px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

.masthead h1 {
  font-size: var(--text-m);
  font-weight: 600;
}

.masthead-note {
  color: var(--text-muted);
  font-size: var(--text-s);
}

.app {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 0 clamp(14px, 3vw, 28px) 28px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* Opener / drop target */

.opener {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  min-height: 132px;
  padding: 20px 22px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  transition:
    min-height 140ms ease,
    padding 140ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.opener.is-dragging {
  border-color: var(--accent);
  background: var(--surface-raised);
}

.opener.is-compact {
  min-height: 0;
  padding: 10px 12px 10px 16px;
  align-items: center;
}

.opener.is-compact .opener-copy {
  display: none;
}

.opener-title {
  font-size: var(--text-l);
  font-weight: 600;
}

.opener-sub {
  color: var(--text-muted);
  font-size: var(--text-s);
  margin-top: 2px;
}

.opener-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.opener-file {
  font-size: var(--text-s);
  color: var(--text-muted);
  max-width: 46ch;
  overflow-wrap: anywhere;
}

/* Buttons */

.button {
  appearance: none;
  font: inherit;
  font-size: var(--text-m);
  font-weight: 400;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  padding: 8px 13px;
  cursor: pointer;
  transition: background 110ms ease, border-color 110ms ease, color 110ms ease;
}

.button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--line-hover);
}

.button:active:not(:disabled) {
  background: var(--surface-pressed);
}

.button:disabled {
  opacity: 0.45;
  cursor: default;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.button-primary:hover:not(:disabled) {
  background: #7bbcff;
  border-color: #7bbcff;
}

.button-primary:active:not(:disabled) {
  background: #3f93e6;
  border-color: #3f93e6;
}

.button-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  padding: 6px 8px;
  font-size: var(--text-s);
}

.button-quiet:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--line);
  color: var(--text);
}

.icon-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  cursor: pointer;
  transition: background 110ms ease, border-color 110ms ease;
}

.icon-button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--line-hover);
}

.icon-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill-rule: evenodd;
}

#prev-frame svg,
#next-frame svg {
  fill: currentColor;
  stroke-width: 2;
}

.icon-button-play {
  background: var(--surface-hover);
}

.icon-button-play svg {
  width: 20px;
  height: 20px;
}

.pause-glyph,
.is-playing .play-glyph {
  display: none;
}

.is-playing .pause-glyph {
  display: block;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Stage */

.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  height: clamp(240px, 52vh, 620px);
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
}

.stage.is-pannable {
  cursor: grab;
  touch-action: none;
}

.stage.is-panning {
  cursor: grabbing;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  display: block;
  background: #000;
}

.zoom[hidden] {
  display: none;
}

.zoom {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.zoom .icon-button {
  width: 32px;
  height: 32px;
  font-size: var(--text-m);
}

.zoom .button {
  height: 32px;
  padding: 0 10px;
  background: var(--surface-raised);
  border-color: var(--line-strong);
  color: var(--text);
}

.zoom .button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--line-hover);
}

.zoom-readout {
  font-variant-numeric: tabular-nums;
  font-size: var(--text-s);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 4.2ch;
  padding: 0 8px;
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  color: var(--text);
}

/* Status line */

.status {
  display: none;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
  font-size: var(--text-m);
  min-height: 0;
}

.status.is-visible {
  display: flex;
}

.status.is-error {
  border-color: var(--line-strong);
  background: var(--surface-raised);
}

.status.is-error::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  background: currentColor;
  -webkit-mask: var(--icon-alert) center / contain no-repeat;
  mask: var(--icon-alert) center / contain no-repeat;
}

.status.is-busy {
  color: var(--text);
}

.status-spinner {
  flex: none;
  width: 13px;
  height: 13px;
  margin-top: 3px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 760ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-spinner {
    animation-duration: 2.4s;
  }
}

/* Transport */

.transport {
  display: flex;
  align-items: center;
  gap: var(--gap);
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.transport-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.transport-buttons {
  gap: 6px;
}

.transport-time {
  gap: 6px;
  white-space: nowrap;
}

.transport-time .sep {
  color: var(--text-muted);
  font-size: var(--text-s);
}

#frame {
  margin-left: 6px;
  font-size: var(--text-s);
}

.transport-scrub {
  flex: 1 1 220px;
  min-width: 180px;
}

.transport-tail {
  gap: 10px;
  margin-left: auto;
}

.select-label {
  color: var(--text-muted);
  font-size: var(--text-s);
}

select {
  appearance: none;
  font: inherit;
  font-size: var(--text-m);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface-raised)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M2 4.5 6 8.5 10 4.5' fill='none' stroke='%23a29c93' stroke-width='1.4' stroke-linecap='round'/></svg>")
    no-repeat right 7px center / 12px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  padding: 7px 26px 7px 9px;
  cursor: pointer;
}

select:hover {
  border-color: var(--line-hover);
}

/* Scrub input */

#scrub {
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
  --progress: 0%;
}

#scrub::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--progress),
    var(--track) var(--progress),
    var(--track) 100%
  );
}

#scrub::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--text);
  border: 1px solid var(--ink);
}

#scrub::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--track);
}

#scrub::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}

#scrub::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text);
  border: 1px solid var(--ink);
}

#scrub:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Meta */

.meta dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px 24px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.meta div {
  min-width: 0;
}

.meta dt {
  color: var(--text-muted);
  font-size: var(--text-s);
}

.meta dd {
  overflow-wrap: anywhere;
}

/* Limits */

.limits {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.limits summary {
  cursor: pointer;
  width: fit-content;
  font-size: var(--text-s);
  font-weight: 600;
  color: var(--text-muted);
}

.limits summary:hover,
.limits summary:focus-visible {
  color: var(--text);
}

.limits ul {
  max-width: 78ch;
  margin-top: 8px;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: var(--text-m);
}

@media (max-width: 720px) {
  .opener {
    min-height: 108px;
    padding: 16px;
  }

  .transport-tail {
    margin-left: 0;
  }

  .transport {
    gap: 10px;
  }

  .stage {
    height: clamp(200px, 40vh, 420px);
  }

  .transport-time {
    flex-wrap: wrap;
  }

  #frame {
    flex-basis: 100%;
    margin-left: 0;
  }
}

/* Licences page and footer */

.site-footer {
  width: 100%;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: var(--text-s);
}

.site-footer-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px clamp(14px, 3vw, 28px) 24px;
  max-width: 1240px;
  margin: 0 auto;
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--text);
  text-decoration: underline;
}

.site-footer a[aria-current="page"] {
  color: var(--text);
}
