:root {
  color-scheme: light;
  --paper-black: #262626;
  --scope-yellow: #fae557;
  --page: #f2f4f0;
  --surface: #fbfcf9;
  --ink: #20241f;
  --muted: #687067;
  --hairline: rgba(24, 31, 24, 0.13);
  --hairline-strong: rgba(24, 31, 24, 0.24);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(rgba(31, 39, 31, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 39, 31, 0.018) 1px, transparent 1px),
    var(--page);
  background-size: 40px 40px;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid #9f8d00;
  outline-offset: 3px;
}

.app-shell {
  min-height: 100svh;
}

.topbar {
  position: relative;
  z-index: 20;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 11px clamp(18px, 2.4vw, 36px);
  border-bottom: 1px solid var(--hairline);
  background: rgba(251, 252, 249, 0.94);
  backdrop-filter: blur(18px);
}

/* Fig. 1 lockup rebuilt with HD character artwork and vector glyph paths. */
.paper-lockup {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.paper-lockup__asset {
  width: auto;
  height: 38px;
  display: block;
  mix-blend-mode: multiply;
}

.topbar-controls {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.case-picker {
  display: flex;
  align-items: center;
  gap: 10px;
}

.case-picker > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.practice-menu {
  position: relative;
}

.practice-menu__trigger {
  width: 238px;
  height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: #fff;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.practice-menu__trigger > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.practice-menu__trigger svg {
  width: 12px;
  height: 8px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 150ms ease;
}

.practice-menu__trigger[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.practice-menu__popover {
  position: absolute;
  z-index: 80;
  top: calc(100% + 9px);
  right: 0;
  width: min(630px, calc(100vw - 36px));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: 5px;
  background: rgba(255, 255, 253, 0.98);
  box-shadow: 0 18px 48px rgba(31, 38, 31, 0.16);
  backdrop-filter: blur(18px);
  transform-origin: top right;
  animation: menu-in 140ms cubic-bezier(.2, .7, .2, 1) both;
}

.practice-menu__popover[hidden] {
  display: none;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.practice-menu__group {
  min-width: 0;
  padding: 5px 10px 9px;
  border-right: 1px solid var(--hairline);
}

.practice-menu__group:last-child {
  border-right: 0;
}

.practice-menu__group h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.045em;
  white-space: nowrap;
}

.practice-menu__options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.practice-menu__option {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
}

.practice-menu__option:hover,
.practice-menu__option:focus-visible {
  border-color: var(--hairline);
  background: #f5f6f2;
}

.practice-menu__option.is-selected {
  border-color: rgba(173, 151, 0, 0.34);
  background: rgba(250, 229, 87, 0.24);
  font-weight: 720;
}

.layer-controls {
  display: flex;
  align-items: stretch;
  min-height: 48px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: #fff;
  overflow: hidden;
}

.layer-toggle {
  position: relative;
  min-width: 250px;
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 0;
  border-right: 1px solid var(--hairline);
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, opacity 160ms ease;
}

.layer-toggle:last-child {
  border-right: 0;
}

.layer-toggle::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 2px;
  background: var(--scope-yellow);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 160ms ease;
}

.layer-toggle:hover:not(:disabled) {
  background: #f8f9f5;
  color: var(--ink);
}

.layer-toggle.is-active {
  background: rgba(250, 229, 87, 0.12);
  color: var(--ink);
}

.layer-toggle.is-active::after {
  transform: scaleX(1);
}

.layer-toggle:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.layer-toggle__glyph {
  position: relative;
  width: 23px;
  height: 21px;
}

.layer-toggle__glyph i {
  position: absolute;
  width: 16px;
  height: 12px;
  border: 1px solid currentColor;
  border-radius: 2px;
  background: #fff;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.layer-toggle__glyph i:first-child {
  top: 2px;
  left: 5px;
  opacity: 0.5;
}

.layer-toggle__glyph i:last-child {
  top: 7px;
  left: 1px;
}

.layer-toggle.is-active .layer-toggle__glyph i:first-child {
  transform: translate(2px, -1px);
  border-color: #9d8a00;
  background: #fffdf0;
}

.layer-toggle.is-active .layer-toggle__glyph i:last-child {
  transform: translate(-1px, 1px);
  border-color: #8d7c00;
  background: var(--scope-yellow);
}

.layer-toggle__copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.layer-toggle__copy > span {
  overflow: hidden;
  font-size: 13px;
  font-weight: 670;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-toggle__copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-toggle__switch {
  position: relative;
  width: 28px;
  height: 17px;
  border: 1px solid var(--hairline-strong);
  border-radius: 99px;
  background: #e9ece7;
  transition: background 160ms ease, border-color 160ms ease;
}

.layer-toggle__switch i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 24, 20, 0.22);
  transition: transform 160ms ease;
}

.layer-toggle.is-active .layer-toggle__switch {
  border-color: #c5ae05;
  background: var(--scope-yellow);
}

.layer-toggle.is-active .layer-toggle__switch i {
  transform: translateX(11px);
}

.workspace {
  min-height: calc(100svh - 76px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(22px, 3vw, 46px) clamp(16px, 3.1vw, 48px) 54px;
}

.video-panel {
  width: min(100%, 1280px);
  animation: interface-in 360ms cubic-bezier(.2, .7, .2, 1) both;
}

@keyframes interface-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.video-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  isolation: isolate;
  border: 1px solid #252b25;
  border-radius: 5px 5px 0 0;
  background: #020302;
  box-shadow: 0 22px 64px rgba(31, 38, 31, 0.16), 0 0 0 1px rgba(255, 255, 255, 0.68);
}

.video-stage video,
.video-stage .posthoc-background,
.video-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.video-stage video {
  z-index: 0;
  display: block;
  object-fit: contain;
}

.posthoc-background {
  z-index: 0;
  display: block;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
}

.video-stage.is-output video {
  visibility: hidden;
}

.video-stage.is-output .posthoc-background {
  opacity: 1;
}

.video-stage canvas {
  z-index: 1;
  pointer-events: none;
}

.stage-progress {
  position: absolute;
  z-index: 6;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--scope-yellow);
  transition: width 80ms linear;
}

.stage-play {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  padding: 0 0 0 4px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 50%;
  background: var(--scope-yellow);
  color: #15170e;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32), 0 0 0 7px rgba(250, 229, 87, 0.12);
  transition: opacity 140ms ease, transform 140ms ease;
}

.stage-play:hover {
  transform: translate(-50%, -50%) scale(1.04);
}

.video-stage.is-playing .stage-play {
  opacity: 0;
  pointer-events: none;
}

.loading-state {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: rgba(247, 248, 245, 0.97);
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.loading-state.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.loading-state.is-error {
  color: #8f2a23;
}

.loading-state img {
  width: auto;
  height: 54px;
  object-fit: contain;
}

.loading-ring {
  position: absolute;
  top: calc(50% - 43px);
  left: calc(50% - 34px);
  width: 68px;
  height: 68px;
  border: 1px solid rgba(38, 38, 38, 0.12);
  border-top-color: var(--scope-yellow);
  border-radius: 50%;
  animation: spin 680ms linear infinite;
}

.loading-state.is-error .loading-ring {
  display: none;
}

.loading-state p {
  margin: 0;
  font-size: 14px;
}

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

.transport {
  display: grid;
  grid-template-columns: 38px 32px 68px minmax(0, 1fr) 68px;
  align-items: center;
  gap: 12px;
  height: 54px;
  padding: 0 15px;
  border: 1px solid #252b25;
  border-top: 0;
  border-radius: 0 0 5px 5px;
  background: #10130f;
  color: #f5f5ef;
}

.transport-play {
  width: 32px;
  height: 32px;
  padding: 0 0 0 2px;
  border: 0;
  border-radius: 50%;
  background: var(--scope-yellow);
  color: #11150e;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.transport-audio {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: transparent;
  color: #d5d9d1;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.transport-audio:hover {
  border-color: rgba(250, 229, 87, 0.55);
  background: rgba(250, 229, 87, 0.08);
  color: var(--scope-yellow);
}

.transport-audio:disabled {
  opacity: 0.38;
  cursor: default;
}

.transport-audio:disabled:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #929991;
}

.transport-audio svg {
  width: 17px;
  height: 17px;
  overflow: visible;
}

.audio-speaker {
  fill: currentColor;
}

.audio-waves,
.audio-slash {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.audio-slash {
  display: none;
}

.transport-audio.is-muted {
  color: #929991;
}

.transport-audio.is-muted .audio-waves {
  display: none;
}

.transport-audio.is-muted .audio-slash {
  display: block;
}

.timecode {
  color: #c6cac3;
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.timecode:last-child {
  text-align: right;
}

#scrubber {
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background-image:
    linear-gradient(
      to right,
      transparent calc(var(--phase-split, 100%) - 1px),
      rgba(255, 255, 255, 0.72) calc(var(--phase-split, 100%) - 1px),
      rgba(255, 255, 255, 0.72) calc(var(--phase-split, 100%) + 1px),
      transparent calc(var(--phase-split, 100%) + 1px)
    ),
    linear-gradient(
      to right,
      var(--scope-yellow) var(--progress, 0%),
      rgba(255, 255, 255, 0.16) var(--progress, 0%)
    );
  cursor: pointer;
}

#scrubber::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--scope-yellow);
  box-shadow: 0 0 0 3px rgba(250, 229, 87, 0.15);
}

@media (max-width: 820px) {
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
    padding-block: 10px 13px;
  }

  .topbar-controls {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .layer-toggle {
    min-width: 230px;
  }

  .workspace {
    min-height: 0;
    padding: 22px 14px 36px;
  }
}

@media (max-width: 620px) {
  .paper-lockup__asset {
    height: 35px;
  }

  .topbar-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .case-picker {
    display: grid;
    grid-template-columns: 100px 1fr;
  }

  .practice-menu,
  .practice-menu__trigger,
  .layer-controls {
    width: 100%;
  }

  .layer-toggle {
    flex: 1;
    min-width: 0;
  }

  .workspace {
    padding-inline: 10px;
  }

  .transport {
    grid-template-columns: 34px 30px 58px minmax(0, 1fr) 58px;
    gap: 8px;
    height: 50px;
    padding-inline: 10px;
  }

  .timecode {
    font-size: 11px;
  }

  .stage-play {
    width: 52px;
    height: 52px;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
