/* The workspace and viewer: stage, frame, overlays, loupe, toast, stage messages. */
/* ---------- workspace ---------- */
.work {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--canvas);
}
.stage {
  position: relative;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: var(--stage-bg, var(--canvas));
}
.bgwrap {
  position: relative;
  display: inline-flex;
}
#bgBtn {
  position: relative;
}
.bgicon {
  width: 16px;
  height: 16px;
  margin-top: -3px;
}
.bgsw {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 5px;
  height: 4px;
  border-radius: 1.5px;
  background: var(--stage-bg, var(--canvas));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}
.bgpop {
  top: calc(100% + 10px);
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: auto;
  gap: 10px;
  padding: 12px;
}
.bgrow {
  display: flex;
  gap: 6px;
}
.bgrow button,
.bgcustom {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.bgrow button span,
.bgcustom span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  /* a faint edge so white and black swatches don't vanish into the panel, in either theme */
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 11%, transparent);
}
/* the chosen swatch: a ring hugging the circle, with a gap in the panel's colour */
.bgrow button[aria-pressed='true'] span,
.bgcustom.on span {
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--text) 11%, transparent),
    0 0 0 2px var(--panel),
    0 0 0 3.5px var(--accent);
}
.bgcustom span {
  display: grid;
  place-items: center;
  background: var(--custom, var(--panel-2));
  color: var(--text-2);
}
.bgcustom .i {
  width: 13px;
  height: 13px;
}
.bgcustom.on .i,
.bgcustom.has .i {
  display: none;
}
/* the in-app colour picker: a shade square (saturation × brightness) and a hue strip */
.bgpick {
  display: grid;
  gap: 10px;
}
.bgpick .sv {
  position: relative;
  height: 120px;
  border-radius: 8px;
  background: linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, hsl(var(--h, 230) 100% 50%));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  cursor: crosshair;
  touch-action: none;
}
.bgpick .hue {
  position: relative;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  touch-action: none;
}
.bgpick i {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--c, transparent);
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 3px rgba(0, 0, 0, 0.18),
    0 2px 6px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.bgpick .hue i {
  top: 50%;
}
.bgpick .sv:focus-visible,
.bgpick .hue:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.bgdot {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 6px;
  background: var(--stage-bg, var(--canvas));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
}
.bghex {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
}
.bghex input {
  flex: 1;
  height: 28px;
  min-width: 0;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: var(--panel-2);
  font: 500 12px var(--f-mono);
  color: var(--text);
  text-transform: uppercase;
}
.stage.t-region {
  cursor: crosshair;
}
.stage.t-pick {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M20.71 5.63l-2.34-2.34a1 1 0 0 0-1.41 0l-3.12 3.12-1.93-1.91-1.41 1.41 1.42 1.42L3 16.25V21h4.75l8.92-8.92 1.42 1.42 1.41-1.41-1.92-1.92 3.12-3.12a1 1 0 0 0 .01-1.42z' fill='%2318181B' stroke='%23fff' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E")
      3 21,
    crosshair;
}
.stage.can-pan {
  cursor: grab;
}
.stage.panning {
  cursor: grabbing;
}
.stage.on-wipe {
  cursor: ew-resize;
}
.frame {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  height: 180px;
  box-shadow:
    0 0 0 1px rgba(16, 16, 24, 0.08),
    0 18px 48px rgba(16, 16, 24, 0.18);
}
.frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}
#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  z-index: 1;
}
.frame.px #view {
  image-rendering: pixelated;
}
/* with no overlay (and below 200% zoom when paused) the browser shows the video itself; the canvas on top only
   carries guides and regions (see draw() in playback.js) */
.frame.direct #vMain {
  z-index: 1;
}
.frame.direct #view {
  background: transparent;
  z-index: 2;
}
.hd {
  position: absolute;
  z-index: 2;
  width: 7px;
  height: 7px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--accent);
  pointer-events: none;
}
.hd.a {
  left: -4px;
  top: -4px;
}
.hd.b {
  right: -4px;
  top: -4px;
}
.hd.c {
  left: -4px;
  bottom: -4px;
}
.hd.d {
  right: -4px;
  bottom: -4px;
}
.chip {
  position: absolute;
  z-index: 6;
  display: flex;
  gap: 7px;
  align-items: center;
  height: 30px;
  padding: 0 6px 0 11px;
  border-radius: 15px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}
.chip b {
  font-weight: 500;
  color: var(--text);
}
.chip svg.i {
  width: 14px;
  height: 14px;
}
.chip button {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text-3);
}
.chip button:hover {
  background: var(--panel-2);
  color: var(--text);
}
.chip button svg.i {
  width: 12px;
  height: 12px;
}
#refOv {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
}
#readout {
  bottom: 16px;
  left: calc(var(--lw) + 26px);
  padding: 0 12px;
  pointer-events: none;
  font-family: var(--f-mono);
  font-size: 11.5px;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
#readout .sw {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
#readout .dim {
  color: var(--text-3);
}
.loupe {
  position: absolute;
  z-index: 7;
  pointer-events: none;
  display: grid;
  gap: 5px;
  padding: 6px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-pop);
}
.loupe canvas {
  display: block;
  width: 121px;
  height: 121px;
  image-rendering: pixelated;
  border-radius: 7px;
}
.loupe span {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text);
  text-align: center;
}
.stage-msg {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
}
.stage-msg span {
  white-space: pre-line;
}
.stage-msg div {
  max-width: 420px;
  background: var(--panel);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow-pop);
  font-size: 12.5px;
  color: var(--text-2);
}
.stage-msg strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
/* Toast: a card for messages, a slim pill for progress. It sits on a raised surface that stays readable on
   both the light canvas and the dark theme. */
.toast {
  position: absolute;
  z-index: 9;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 10px;
  width: max-content;
  max-width: min(380px, calc(100% - 32px));
  padding: 10px 12px 10px 12px;
  border-radius: 14px;
  background: var(--toast-bg);
  color: var(--bar-text);
  box-shadow:
    inset 0 0 0 1px var(--toast-edge),
    0 12px 32px rgba(0, 0, 0, 0.3);
  font-size: 12.5px;
  line-height: 1.4;
  animation: toastIn 0.18s ease-out;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 6px);
  }
}
.ticon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  align-self: start;
  color: #fff;
}
.ticon:empty {
  display: none;
}
.ticon svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.toast.ok .ticon {
  background: #2e9e6b;
}
.toast.warn .ticon {
  background: #e5484d;
}
.toast.info {
  grid-template-columns: minmax(0, 1fr) auto;
  padding-left: 14px;
}
.toast.info .ticon {
  display: none;
}
.toast.info .bar {
  grid-column: 1/2;
}
.toast.info button {
  grid-column: 2;
}

/* progress ring: fills to --p percent; spins while the amount of work is unknown */
.toast.busy .ticon {
  width: 18px;
  height: 18px;
  align-self: center;
}
.toast.busy .ticon svg {
  width: 18px;
  height: 18px;
  transform: rotate(-90deg);
  stroke-width: 2.4;
}
.ticon .trk {
  stroke: var(--toast-edge);
  stroke-width: 2.4;
}
.ticon .val {
  stroke: var(--toast-accent);
  stroke-dasharray: var(--p, 0) 100;
  transition: stroke-dasharray 0.25s ease-out;
}
.ticon.spin svg {
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    rotate: 360deg;
  }
}

.tbody {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.tbody b {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.005em;
}
.tbody span {
  color: var(--bar-dim);
  font-size: 12px;
}
.tbody kbd {
  display: inline-block;
  margin: 0 1px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--toast-edge);
  color: var(--bar-text);
  font: 500 11px/16px var(--f-mono);
}

/* the pill: one line, title on the left, a quiet measure (31%, 3 of 11) on the right */
.toast.pill {
  min-height: 38px;
  padding: 0 8px 0 11px;
  border-radius: 999px;
}
.toast.pill:not(:has(#jobCancel:not([hidden]))) {
  padding-right: 16px;
}
.toast.pill .tbody {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.toast.pill .tbody b {
  white-space: nowrap;
}
.toast.pill .tbody em {
  margin-left: auto;
  font-size: 12.5px;
  font-weight: 500;
  font-style: normal;
  color: var(--bar-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.toast.pill button {
  grid-row: 1;
  border-radius: 999px;
}

.toast .bar {
  grid-column: 2/3;
  grid-row: 2;
  width: auto;
  margin-top: 8px;
}
.bar {
  height: 3px;
  border-radius: 2px;
  background: var(--toast-edge);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--toast-accent);
  transition: width 0.2s ease-out;
}
.toast button {
  grid-column: 3;
  grid-row: 1/3;
  height: 26px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  background: var(--toast-edge);
  color: var(--bar-text);
  font-size: 12px;
  font-weight: 500;
}
.toast button:hover {
  background: color-mix(in srgb, var(--toast-edge) 70%, #fff);
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* ---------- empty state: before the first clip ---------- */
.welcome {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}
.wcard {
  width: min(460px, 100%);
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 34px 32px 26px;
  border-radius: 20px;
  border: 1.5px dashed color-mix(in srgb, var(--text) 18%, transparent);
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  text-align: center;
  transition:
    border-color 0.15s,
    background-color 0.15s;
}
.app.dragging .wcard {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}
.wicon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.wicon svg.i {
  width: 26px;
  height: 26px;
}
.wcard h1 {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
}
.wsub {
  margin: 0;
  max-width: 36ch;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-2);
}
.wacts {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.wacts .btn {
  height: 38px;
  padding: 0 16px;
  font-size: 13.5px;
}
.wacts .btn .keys {
  margin-left: 4px;
}
.wacts .btn kbd {
  margin: 0;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font: 500 11px/18px var(--f-mono);
}
.wacts .btn kbd:empty {
  display: none;
}
.wsteps {
  list-style: none;
  margin: 8px 0 0;
  padding: 14px 0 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-2);
}
.wsteps li {
  display: grid;
  justify-items: center;
  align-content: start; /* labels of different lengths share a top edge */
  gap: 6px;
  text-wrap: balance;
}
.wsteps b {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-2);
  font: 600 11px var(--f-ui);
  color: var(--text);
}
.wnote {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--text-3);
}
.werr {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, #e5484d 10%, var(--panel));
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  color: var(--text-2);
  white-space: pre-line;
}
.werr strong {
  color: var(--text);
  font-size: 12.5px;
}

/* until there's a clip, everything that needs one is quiet and out of the way */
/* the chosen viewer background is for looking at frames; the welcome screen always uses the theme */
.app.no-clip .stage {
  background: var(--canvas);
}
.app.no-clip .frame,
.app.no-clip .tb-center,
.app.no-clip .zwrap {
  visibility: hidden;
}
.app.no-clip .timeline,
.app.no-clip .fpanel,
.app.no-clip .tabs {
  opacity: 0.45;
  pointer-events: none;
  filter: saturate(0.6);
}
.app.no-clip #fnameT {
  color: var(--bar-dim);
}
@media (max-width: 720px) {
  .wcard {
    padding: 26px 20px 20px;
  }
  .wcard h1 {
    font-size: 19px;
  }
  .wacts {
    width: 100%;
    flex-direction: column;
  }
  /* the phone's viewer is short: keep the card to what's needed to start */
  .wsteps,
  .wacts .btn kbd {
    display: none;
  }
  .wcard {
    gap: 10px;
  }
}
/* short windows: drop the steps so the card stays clear of the playback bar */
@media (max-height: 760px) {
  .wsteps {
    display: none;
  }
}
@media (max-height: 680px) {
  .welcome .wicon,
  .welcome .wnote {
    display: none;
  }
}
/* ---------- the guided tour (tour.js) ---------- */
.tour {
  position: fixed;
  inset: 0;
  z-index: 100;
  animation: tour-in 0.2s ease-out;
}
.tour.out {
  opacity: 0;
  transition: opacity 0.18s;
}
@keyframes tour-in {
  from {
    opacity: 0;
  }
}
/* the lit-up area: a clear box whose huge shadow dims everything else */
.tour-hole {
  position: absolute;
  border-radius: 12px;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, 0.55);
  transition:
    left 0.32s cubic-bezier(0.3, 0.7, 0.2, 1),
    top 0.32s cubic-bezier(0.3, 0.7, 0.2, 1),
    width 0.32s cubic-bezier(0.3, 0.7, 0.2, 1),
    height 0.32s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.tour.loading .tour-hole {
  left: 50% !important;
  top: 50% !important;
  width: 0 !important;
  height: 0 !important;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, 0.55);
}
.tour.loading .tour-card {
  visibility: hidden;
}
.tour-card {
  position: absolute;
  width: min(320px, calc(100vw - 24px));
  display: grid;
  gap: 6px;
  padding: 16px 16px 12px;
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-pop);
  transition:
    left 0.32s cubic-bezier(0.3, 0.7, 0.2, 1),
    top 0.32s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.tour-card.in {
  animation: tour-card 0.24s ease-out;
}
@keyframes tour-card {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
.tour-card .tc-n {
  font: 500 11px var(--f-ui);
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}
.tour-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.tour-card p {
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-2);
}
.tc-acts {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tc-sp {
  flex: 1;
}
.tc-skip {
  margin-left: -8px;
}
@media (prefers-reduced-motion: reduce) {
  .tour,
  .tour-card.in {
    animation: none;
  }
  .tour-hole,
  .tour-card {
    transition: none;
  }
}
