:root {
  color-scheme: light;
  --page: #f4f5f6;
  --surface: #ffffff;
  --surface-soft: #eef1f2;
  --ink: #15191c;
  --muted: #667077;
  --line: #d7dcdf;
  --line-strong: #abb4b9;
  --base: #2d6772;
  --candidate: #d54b3d;
  --candidate-soft: #fff0ed;
  --focus: #1877b8;
  --shadow: 0 14px 32px rgba(23, 30, 34, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  color: var(--ink);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 30%, transparent);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 10px max(24px, calc((100vw - 1560px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.brand-block {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}

.topbar h1 {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  font-weight: 750;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

main {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 0 24px 40px;
}

.control-band {
  display: grid;
  grid-template-columns: 190px minmax(340px, 1.25fr) minmax(280px, 0.9fr) auto;
  align-items: end;
  gap: 22px;
  padding: 22px 0 18px;
}

.selector-group {
  min-width: 0;
}

.task-selector {
  width: 100%;
}

.task-selector button {
  flex: 1 1 0;
}

.field-label,
.eyebrow,
.model-role {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  text-transform: uppercase;
}

.prompt-picker {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 6px;
}

select,
.icon-button,
.command-button,
.text-button,
.segmented-control button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0 34px 0 12px;
  text-overflow: ellipsis;
}

.icon-button,
.command-button,
.text-button,
.segmented-control button {
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 40px;
  padding: 0;
  place-items: center;
  font-size: 18px;
}

.icon-button:hover,
.command-button:hover,
.text-button:hover,
.segmented-control button:hover {
  border-color: var(--ink);
  background: var(--surface-soft);
}

.command-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  white-space: nowrap;
}

.prompt-index {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.prompt-index span + span {
  padding-left: 10px;
  border-left: 1px solid var(--line);
  color: var(--ink);
  font-weight: 650;
}

.prompt-band {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.prompt-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.prompt-heading h2,
.model-heading h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.text-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.prompt-preview {
  display: -webkit-box;
  overflow: hidden;
  margin: 12px 0 0;
  color: #343b3f;
  font-size: 13px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.prompt-body.has-reference {
  display: grid;
  grid-template-columns: minmax(260px, 34%) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  margin-top: 14px;
}

.prompt-body.has-reference .prompt-preview {
  margin-top: 0;
}

.reference-frame {
  min-width: 0;
  margin: 0;
}

.reference-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 7 / 4;
  border: 1px solid var(--line);
  border-radius: 4px;
  object-fit: contain;
  background: #0c0e0f;
}

.reference-frame figcaption {
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.prompt-details {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 0;
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.prompt-details[hidden] {
  display: none;
}

.prompt-body.has-reference .prompt-details {
  grid-template-columns: 1fr 1fr;
}

.prompt-body.has-reference .detail-section:nth-child(3) {
  padding-left: 0;
  border-left: 0;
}

.prompt-body.has-reference .detail-section:nth-child(n + 3) {
  border-top: 1px solid var(--line);
}

.detail-section {
  padding: 16px 18px 0 0;
}

.detail-section + .detail-section {
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.detail-section h3 {
  margin: 0 0 7px;
  font-size: 12px;
}

.detail-section p {
  margin: 0;
  color: #475055;
  font-size: 12px;
  line-height: 1.55;
}

.compare-section {
  margin-top: 18px;
}

.playback-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  min-height: 52px;
  padding: 6px 0;
}

.transport-controls,
.audio-control,
.segmented-control,
.switch-control {
  display: flex;
  align-items: center;
}

.transport-controls {
  gap: 7px;
}

.transport-button {
  color: #fff;
  border-color: var(--ink);
  background: var(--ink);
}

.transport-button:hover {
  color: var(--ink);
}

.switch-control {
  min-height: 40px;
  gap: 8px;
  margin-left: 6px;
  color: #3d4549;
  cursor: pointer;
  font-size: 12px;
}

.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.switch-track {
  display: block;
  width: 34px;
  height: 20px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  transition: background 150ms ease;
}

.switch-track span {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 150ms ease, background 150ms ease;
}

.switch-control input:checked + .switch-track {
  border-color: var(--base);
  background: var(--base);
}

.switch-control input:checked + .switch-track span {
  transform: translateX(14px);
  background: #fff;
}

.audio-control {
  justify-content: center;
  gap: 9px;
}

.audio-control .field-label {
  margin: 0;
}

.segmented-control {
  overflow: hidden;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

.segmented-control button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  font-size: 12px;
}

.segmented-control button + button {
  border-left: 1px solid var(--line);
}

.segmented-control button.is-active {
  color: #fff;
  background: var(--ink);
}

.load-status {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
}

.video-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.video-column {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--base);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.candidate-column {
  border-top-color: var(--candidate);
}

.model-heading {
  display: flex;
  min-height: 48px;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 10px;
}

.model-heading > div {
  min-width: 0;
  flex: 1 1 auto;
}

.model-role {
  margin-bottom: 4px;
}

.model-checkpoint {
  max-width: 520px;
  overflow: hidden;
  margin: 4px 0 0;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nfe-value {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid color-mix(in srgb, var(--base) 42%, var(--line));
  border-radius: 4px;
  color: var(--base);
  background: #edf6f7;
  font-size: 12px;
  font-weight: 750;
}

.candidate-nfe {
  border-color: color-mix(in srgb, var(--candidate) 42%, var(--line));
  color: #a92f26;
  background: var(--candidate-soft);
}

.video-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 7 / 4;
  border-radius: 4px;
  background: #0c0e0f;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0c0e0f;
  cursor: pointer;
}

.video-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #e9ecee;
  background: #15191c;
  font-size: 12px;
  pointer-events: none;
}

.video-state.is-hidden {
  display: none;
}

.video-state.is-error {
  color: #fff;
  background: #7d241f;
}

video.is-pending {
  cursor: default;
  opacity: 0.82;
}

.video-state.is-pending {
  inset: auto 12px 12px;
  display: block;
  width: auto;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  background: rgba(21, 25, 28, 0.86);
  color: #fff;
  font-weight: 650;
  backdrop-filter: blur(6px);
}

.model-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 10px 0 0;
  border-top: 1px solid var(--line);
}

.model-meta div {
  min-width: 0;
  padding: 9px 9px 2px;
}

.model-meta div + div {
  border-left: 1px solid var(--line);
}

.model-meta dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.model-meta dd {
  overflow: hidden;
  margin: 0;
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 10px;
  padding: 14px 4px 0;
}

.timecode {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

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

#timeline {
  width: 100%;
  accent-color: var(--candidate);
}

.method-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.method-band p {
  margin: 0;
  font-size: 12px;
}

.method-facts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 18px;
  color: var(--muted);
  font-size: 11px;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 22px;
  bottom: 22px;
  padding: 10px 13px;
  border-radius: 5px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .topbar {
    padding: 10px 16px;
  }

  .topbar p {
    display: none;
  }

  main {
    padding-right: 14px;
    padding-left: 14px;
  }

  .control-band {
    grid-template-columns: 1fr 1fr;
  }

  .prompt-index {
    display: none;
  }

  .prompt-details {
    grid-template-columns: 1fr;
  }

  .prompt-body.has-reference {
    grid-template-columns: minmax(220px, 34%) minmax(0, 1fr);
  }

  .detail-section + .detail-section {
    padding-left: 0;
    border-left: 0;
  }

  .playback-toolbar {
    grid-template-columns: 1fr auto;
  }

  .audio-control {
    justify-content: flex-end;
  }

  .load-status {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .brand-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .topbar h1 {
    max-width: 210px;
    font-size: 14px;
    white-space: normal;
  }

  .command-button span:last-child {
    display: none;
  }

  .command-button {
    width: 40px;
    flex: 0 0 40px;
    padding: 0;
    justify-content: center;
  }

  .control-band {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .prompt-heading {
    align-items: center;
    gap: 8px;
  }

  .prompt-heading > div {
    min-width: 0;
  }

  .prompt-heading .text-button {
    flex: 0 0 auto;
  }

  .prompt-heading h2 {
    font-size: 15px;
  }

  .prompt-body.has-reference {
    grid-template-columns: 1fr;
  }

  .prompt-body.has-reference .prompt-details {
    grid-template-columns: 1fr;
  }

  .prompt-body.has-reference .detail-section {
    padding-left: 0;
    border-left: 0;
  }

  .playback-toolbar {
    grid-template-columns: 1fr;
  }

  .audio-control {
    justify-content: flex-start;
  }

  .video-column {
    padding: 8px;
  }

  .model-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-meta div:nth-child(3) {
    border-left: 0;
  }

  .model-meta div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .method-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .method-facts {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
