* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b1120;
  color: #dbe4ff;
}

body {
  min-height: 100vh;
}

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

button,
select,
.file-input-button {
  border: 1px solid rgb(148 163 184 / 25%);
  background: #18233b;
  color: #f8fbff;
  padding: 8px 12px;
  border-radius: 8px;
  font: inherit;
}

button:hover,
select:hover,
.file-input-button:hover {
  background: #223254;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.viewer-page {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.viewer-shell-bar {
  display: flex;
  align-items: center;
}

.shell-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid rgb(148 163 184 / 20%);
  border-radius: 999px;
  background: rgb(12 20 35 / 78%);
  color: #f8fbff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.shell-link:hover {
  background: rgb(24 35 59 / 96%);
}

.player-panel {
  position: relative;
  display: grid;
  gap: 12px;
}

.viewport {
  --bg-accent-strength: 0.18;
  --bg-accent-rgb: 92, 200, 255;
  --bg-drift-x: 0px;
  --bg-drift-y: 0px;
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background:
    radial-gradient(circle at calc(18% + var(--bg-drift-x)) calc(10% + var(--bg-drift-y)), rgb(var(--bg-accent-rgb) / var(--bg-accent-strength)), transparent 34%),
    radial-gradient(circle at calc(82% - var(--bg-drift-x)) calc(16% - var(--bg-drift-y)), rgb(139 255 165 / calc(var(--bg-accent-strength) * 0.18)), transparent 26%),
    linear-gradient(180deg, #07101f 0%, #0b1120 100%);
  padding-top: 6px;
}

.viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgb(7 16 31 / 2%) 0%, rgb(7 16 31 / 8%) 55%, rgb(7 16 31 / 40%) 100%);
}

.three-mount {
  width: 100%;
  min-height: 700px;
  height: min(74vh, 860px);
  overflow: hidden;
}

.player-chrome {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
}

.player-chrome[data-visible="true"] {
  opacity: 1;
}

.player-chrome::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 160px;
  background: linear-gradient(180deg, rgb(7 16 31 / 0%) 0%, rgb(7 16 31 / 84%) 100%);
}

.player-controls {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 12px;
  display: grid;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgb(7 16 31 / 50%);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.player-chrome[data-visible="false"] .player-controls {
  pointer-events: none;
}

.player-controls-scrubber {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.player-controls-scrubber input {
  width: 100%;
  margin: 0;
}

.player-title {
  min-width: 0;
  color: #f8fbff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playback-time {
  min-width: 118px;
  text-align: right;
  font-size: 13px;
  color: #dbe4ff;
}

.player-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.player-controls-transport,
.player-controls-utility {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-controls-transport {
  flex-wrap: wrap;
  row-gap: 10px;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  border-radius: 999px;
}

.control-icon {
  width: 20px;
  height: 20px;
  display: block;
  color: currentColor;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.icon-button--transport .control-icon {
  width: 21px;
  height: 21px;
}

#loadReplayButton .control-icon path:first-child,
#playPauseButton .control-icon--play path,
#stopButton .control-icon path,
#stepBackButton .control-icon path:last-child,
#stepButton .control-icon path:last-child {
  fill: currentColor;
  stroke: none;
}

#playPauseButton .control-icon--pause,
#fullscreenButton .control-icon--exit-fullscreen {
  display: none;
}

#playPauseButton[data-playing="true"] .control-icon--play,
#fullscreenButton[data-fullscreen="true"] .control-icon--enter-fullscreen {
  display: none;
}

#playPauseButton[data-playing="true"] .control-icon--pause,
#fullscreenButton[data-fullscreen="true"] .control-icon--exit-fullscreen {
  display: block;
}

.icon-button--transport {
  width: 44px;
  height: 44px;
}

.load-progress {
  display: grid;
  gap: 6px;
}

.load-progress[hidden] {
  display: none !important;
}

.load-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgb(148 163 184 / 14%);
}

.load-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5cc8ff 0%, #8bffa5 100%);
  transition: width 90ms linear;
}

.load-progress-text {
  font-size: 12px;
  color: #8da2c9;
}

.source-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  pointer-events: auto;
}

.source-control {
  display: grid;
  gap: 5px;
}

.source-control span:first-child {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #7890bd;
}

.source-control select,
.source-action,
.file-input-button {
  min-height: 36px;
  border: 1px solid rgb(148 163 184 / 24%);
  border-radius: 8px;
  background: rgb(7 16 31 / 72%);
  color: #f8fbff;
  font: inherit;
}

.source-control select {
  min-width: 220px;
  padding: 0 34px 0 10px;
}

.source-action,
.file-input-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  cursor: pointer;
}

.source-action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.source-action--secondary {
  color: #cbd8f5;
}

.source-control--file {
  position: relative;
}

.source-control--file[hidden] {
  display: none !important;
}

.source-control--file input {
  position: absolute;
  inset: auto 0 0;
  height: 36px;
  opacity: 0;
  cursor: pointer;
}

.info-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.info-modal[hidden] {
  display: none !important;
}

.info-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(3 8 20 / 72%);
  backdrop-filter: blur(8px);
}

.info-modal-panel {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  margin: 24px auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgb(148 163 184 / 22%);
  border-radius: 16px;
  background: rgb(7 16 31 / 96%);
  box-shadow: 0 20px 50px rgb(3 8 20 / 42%);
}

.info-modal-panel--compact {
  width: min(520px, calc(100vw - 48px));
}

.info-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgb(148 163 184 / 16%);
}

.info-modal-header h2,
.info-section h3 {
  margin: 0;
  color: #f8fbff;
}

.modal-description {
  margin: 6px 0 0;
  max-width: 58ch;
  color: #a8b9dc;
  font-size: 13px;
  line-height: 1.48;
}

.icon-button--close {
  width: 38px;
  height: 38px;
  font-size: 16px;
}

.info-modal-body {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.45fr) minmax(250px, 0.95fr);
  gap: 0;
  min-height: 0;
}

.info-modal-body--compact {
  grid-template-columns: 1fr;
  padding: 18px 20px;
}

.source-modal-panel {
  width: min(560px, calc(100vw - 48px));
}

.source-modal-body {
  gap: 14px;
}

.modal-field {
  display: grid;
  gap: 8px;
}

.modal-field > span:first-child {
  font-size: 13px;
  color: #a8b9dc;
}

.file-input {
  position: relative;
}

.file-input[hidden] {
  display: none !important;
}

.file-input input {
  position: absolute;
  inset: auto 0 0;
  height: 42px;
  opacity: 0;
  cursor: pointer;
}

.file-input-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
}

.source-controls--modal {
  display: grid;
  gap: 14px;
  align-items: stretch;
}

.source-controls--modal .source-control,
.source-controls--modal .source-control select,
.source-controls--modal .file-input-button {
  width: 100%;
}

.source-modal-status {
  min-height: 20px;
  color: #8da2c9;
  font-size: 13px;
  line-height: 1.45;
}

.source-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.info-section {
  padding: 18px 20px;
}

.info-section--replay-summary,
.info-section--run-parameters {
  border-right: 1px solid rgb(148 163 184 / 12%);
}

.info-section--replay-summary,
.info-section--run-parameters {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
}

.info-section--aux {
  display: grid;
  align-content: start;
  gap: 20px;
}

.run-parameters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
  overflow: auto;
  padding-right: 4px;
}

.replay-summary {
  display: grid;
  gap: 10px;
  align-content: start;
}

.replay-summary-entry {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgb(148 163 184 / 10%);
}

.replay-summary-entry span {
  color: #7890bd;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.replay-summary-entry strong {
  color: #f8fbff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.run-parameters-empty {
  grid-column: 1 / -1;
  font-size: 12px;
  color: #a8b9dc;
}

.run-parameters-section {
  display: grid;
  gap: 7px;
}

.run-parameters-section-title {
  font-size: 12px;
  font-weight: 700;
  color: #f8fbff;
}

.run-parameters-list {
  display: grid;
  gap: 6px;
}

.run-parameters-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.run-parameters-label,
.run-parameters-value,
.legend-item {
  font-size: 12px;
  line-height: 1.32;
}

.run-parameters-label,
.legend-item {
  color: #a8b9dc;
}

.run-parameters-value {
  color: #f8fbff;
  text-align: right;
  word-break: normal;
  overflow-wrap: anywhere;
}

.await-unit-entry {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
}

.await-unit-entry .run-parameters-label {
  overflow-wrap: anywhere;
}

.speed-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 0;
  padding: 0;
  border: 0;
}

.speed-group--inline {
  gap: 8px 10px;
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid rgb(148 163 184 / 18%);
}

.speed-group label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #dbe4ff;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgb(24 35 59 / 82%);
  border: 1px solid rgb(148 163 184 / 18%);
}

.speed-group input[type="radio"] {
  margin: 0;
  accent-color: #8bffa5;
  transform: scale(1.18);
}

.legend-list {
  display: grid;
  gap: 7px;
}

.legend-list + h4 {
  margin-top: 18px;
}

.info-section-legend h4 {
  margin: 12px 0 9px;
  color: #dbe4ff;
  font-size: 12px;
  font-weight: 700;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-item--throughput {
  align-items: center;
}

.legend-counter-sample {
  position: relative;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.legend-counter-text {
  position: relative;
  z-index: 1;
  color: #f8fbff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-shadow: 0 0 8px rgb(7 16 31 / 80%);
}

.legend-pressure-ring {
  position: absolute;
  inset: 3px;
  border-radius: 999px;
  background:
    conic-gradient(from 225deg, #ffd166 0deg 200deg, rgb(148 163 184 / 24%) 200deg 270deg, transparent 270deg 360deg);
  box-shadow: 0 0 12px rgb(255 209 102 / 32%);
}

.legend-pressure-ring::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: inherit;
  background: #07101f;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #7ad7ff;
  box-shadow: 0 0 12px rgb(122 215 255 / 40%);
}

.legend-swatch--start {
  background: #7ad7ff;
}

.legend-swatch--emit {
  background: #8bffa5;
  box-shadow: 0 0 12px rgb(139 255 165 / 40%);
}

.legend-swatch--retry {
  background: #ffb454;
  box-shadow: 0 0 12px rgb(255 180 84 / 40%);
}

.legend-swatch--error {
  background: #ff647c;
  box-shadow: 0 0 12px rgb(255 100 124 / 40%);
}

.legend-swatch--branch {
  background: #caa6ff;
  box-shadow: 0 0 12px rgb(202 166 255 / 40%);
}

.legend-swatch--cache {
  background: #8bffa5;
  box-shadow: 0 0 12px rgb(139 255 165 / 40%);
}

.legend-list--support {
  gap: 9px;
}

.legend-actor {
  position: relative;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #caa6ff;
  box-shadow: 0 0 16px rgb(202 166 255 / 34%);
}

.legend-actor--store {
  background: #67b2f3;
  box-shadow: 0 0 16px rgb(103 178 243 / 34%);
}

.legend-actor--cache {
  background: #8bffa5;
  box-shadow: 0 0 16px rgb(139 255 165 / 34%);
}

.legend-actor--cache-invalidate {
  background: #ffd166;
  box-shadow: 0 0 16px rgb(255 209 102 / 34%);
}

.legend-actor--cache-invalidate-all {
  background: #ff9f68;
  box-shadow: 0 0 16px rgb(255 159 104 / 34%);
}

.legend-actor--broker {
  background: #8f7aea;
  box-shadow: 0 0 16px rgb(143 122 234 / 34%);
}

.legend-actor--provider {
  background: #b08cff;
  box-shadow: 0 0 16px rgb(176 140 255 / 34%);
}

.legend-actor--reject {
  background: #ff7c8f;
  box-shadow: 0 0 16px rgb(255 124 143 / 34%);
}

.legend-icon,
.legend-icon::before,
.legend-icon::after {
  box-sizing: border-box;
}

.legend-icon {
  position: relative;
  width: 18px;
  height: 18px;
  display: inline-block;
}

.legend-icon--database {
  width: 15px;
  height: 16px;
  border: 2px solid #f8fbff;
  border-top: 0;
  border-radius: 0 0 7px 7px;
}

.legend-icon--database::before,
.legend-icon--database::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  height: 7px;
  border: 2px solid #f8fbff;
  border-radius: 999px;
}

.legend-icon--database::before {
  top: -4px;
}

.legend-icon--database::after {
  top: 5px;
  border-left-color: transparent;
  border-right-color: transparent;
  border-bottom-color: transparent;
}

.legend-icon--cache::before,
.legend-icon--cache::after,
.legend-icon--broker::before,
.legend-icon--broker::after {
  content: "";
  position: absolute;
  border: 2px solid #f8fbff;
}

.legend-icon--cache,
.legend-icon--cache::before,
.legend-icon--cache::after {
  border: 2px solid #f8fbff;
  border-radius: 6px;
}

.legend-icon--cache {
  width: 16px;
  height: 7px;
  transform: translateY(-5px);
}

.legend-icon--cache::before {
  left: -4px;
  top: 6px;
  width: 20px;
  height: 7px;
}

.legend-icon--cache::after {
  left: -7px;
  top: 12px;
  width: 26px;
  height: 7px;
}

.legend-icon--broker,
.legend-icon--broker::before,
.legend-icon--broker::after {
  border: 2px solid #f8fbff;
  border-radius: 4px;
}

.legend-icon--broker {
  width: 5px;
  height: 17px;
}

.legend-icon--broker::before {
  left: -8px;
  top: 3px;
  width: 5px;
  height: 14px;
}

.legend-icon--broker::after {
  right: -8px;
  top: -3px;
  width: 5px;
  height: 20px;
}

.legend-icon--provider {
  width: 15px;
  height: 16px;
  border: 2px solid #f8fbff;
  border-radius: 5px;
}

.legend-icon--provider::before,
.legend-icon--provider::after {
  content: "";
  position: absolute;
  right: -7px;
  width: 6px;
  border-top: 2px solid #f8fbff;
}

.legend-icon--provider::before {
  top: 4px;
}

.legend-icon--provider::after {
  top: 10px;
}

.legend-icon--reject {
  width: 18px;
  height: 13px;
  border: 2px solid #f8fbff;
  border-radius: 5px;
}

.legend-icon--reject::before {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: -8px;
  height: 8px;
  border: 2px solid #f8fbff;
  border-top: 0;
  transform: skewX(-18deg);
}

.legend-actor-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffdf8f;
  border-radius: 999px;
  background: rgb(7 16 31 / 84%);
  color: #ffdf8f;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

@media (max-width: 1024px) {
  .info-modal-body {
    grid-template-columns: 1fr;
  }

  .info-section--replay-summary,
  .info-section--run-parameters {
    border-right: 0;
    border-bottom: 1px solid rgb(148 163 184 / 12%);
  }
}

@media (max-width: 820px) {
  .viewer-page {
    padding: 8px;
    min-height: 100dvh;
  }

  .viewer-shell-bar {
    justify-content: flex-start;
  }

  .shell-link {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
  }

  .viewport {
    border-radius: 10px;
  }

  .three-mount {
    min-height: 0;
    height: calc(100dvh - 58px);
  }

  .player-controls {
    left: 8px;
    right: 8px;
    bottom: 8px;
    gap: 5px;
    padding: 6px;
    max-width: none;
    border-radius: 10px;
  }

  .player-controls-scrubber {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .player-title {
    font-size: 12px;
  }

  .playback-time {
    min-width: 84px;
    text-align: right;
    font-size: 11px;
  }

  .player-controls-bar {
    align-items: center;
    gap: 8px;
  }

  .player-controls-transport,
  .player-controls-utility {
    justify-content: flex-start;
    flex-wrap: nowrap;
    min-width: 0;
    gap: 5px;
  }

  .player-controls-transport {
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .player-controls-transport::-webkit-scrollbar {
    display: none;
  }

  .icon-button,
  .icon-button--transport {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
  }

  .control-icon,
  .icon-button--transport .control-icon {
    width: 17px;
    height: 17px;
  }

  .speed-group--inline {
    flex: 0 0 auto;
    justify-content: flex-start;
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
    width: auto;
    gap: 5px;
  }

  .speed-group label {
    min-height: 28px;
    padding: 0 6px;
    font-size: 11px;
  }

  .source-controls {
    align-items: stretch;
  }

  .source-control,
  .source-control select,
  .source-action,
  .file-input-button {
    width: 100%;
  }

  .source-modal-actions {
    flex-direction: column;
  }

  .info-modal-panel,
  .info-modal-panel--compact {
    width: 100vw;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .run-parameters {
    grid-template-columns: 1fr;
  }
}
