:root {
  color: #2f2f2f;
  background: #ffffff;
  font-family: Aptos, "Segoe UI", Helvetica, Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
}

button,
select {
  font: inherit;
}

.page-shell {
  width: 100%;
  margin: 0 auto;
  padding: 38px 38px 52px;
}

.page-header {
  text-align: center;
}

.page-header h1 {
  margin: 0;
  color: #424242;
  font-size: clamp(2rem, 3vw, 2.8rem);
  font-weight: 500;
  letter-spacing: -0.025em;
}

.page-header p {
  margin: 14px auto 0;
  color: #626262;
  font-size: 1.05rem;
  line-height: 1.5;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 25px 0 24px;
}

.toolbar select,
.toolbar button {
  min-height: 46px;
  border-radius: 5px;
  font-size: 1rem;
}

.toolbar select {
  min-width: 260px;
  border: 1px solid #cfcfcf;
  padding: 0 42px 0 14px;
  color: #353535;
  background: #ffffff;
}

.toolbar button {
  border: 1px solid #078f7f;
  padding: 0 21px;
  color: #ffffff;
  background: #0ab9a3;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.toolbar button:hover:not(:disabled) {
  border-color: #08796d;
  background: #08a38f;
}

.toolbar button.secondary {
  border-color: #cccccc;
  color: #444444;
  background: #ffffff;
}

.toolbar button.secondary:hover:not(:disabled) {
  border-color: #a8a8a8;
  background: #f6f6f6;
}

.toolbar button:disabled,
.toolbar select:disabled {
  cursor: default;
  opacity: 0.55;
}

.viewer-scroll {
  overflow-x: auto;
  padding: 1px 1px 8px;
}

.viewer-card {
  min-width: 930px;
  overflow: hidden;
  border: 1px solid #c9c9c9;
  border-radius: 13px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 7%);
}

.method-labels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid #d7d7d7;
  color: #454545;
  background: #fafafa;
  font-size: clamp(0.9rem, 1.1vw, 1.05rem);
  font-weight: 500;
  text-align: center;
}

.method-labels div {
  padding: 13px 10px 12px;
}

.method-labels div + div {
  border-left: 1px solid #d7d7d7;
}

.viewer-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 3;
  min-height: 174px;
  max-height: 390px;
  overflow: hidden;
  background: #ffffff;
  touch-action: none;
}

#viewerCanvas,
.viewport-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#viewerCanvas {
  display: block;
  outline: none;
  cursor: crosshair;
}

.viewer-stage.is-pointer-locked #viewerCanvas {
  cursor: none;
}

.viewport-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  z-index: 2;
  pointer-events: none;
}

.viewport-region + .viewport-region {
  border-left: 1px solid #d7d7d7;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  color: #5c5c5c;
  background: rgb(255 255 255 / 88%);
  font-size: 0.98rem;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.loading-overlay[hidden] {
  display: none;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #d5d5d5;
  border-top-color: #0ab9a3;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.viewer-help {
  border-top: 1px solid #d7d7d7;
  padding: 11px 16px 12px;
  color: #686868;
  background: #ffffff;
  font-size: 0.92rem;
  text-align: center;
}

.input-video-card {
  width: min(100%, var(--input-video-card-width, 760px));
  margin: 30px auto 0;
  overflow: hidden;
  border: 1px solid #c9c9c9;
  border-radius: 13px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 7%);
}

.input-video-card[hidden] {
  display: none;
}

.input-video-card h2 {
  margin: 0;
  border-bottom: 1px solid #d7d7d7;
  padding: 12px 16px;
  color: #454545;
  background: #fafafa;
  font-size: 1.05rem;
  font-weight: 500;
  text-align: center;
}

.input-video-card video {
  display: block;
  width: 100%;
  aspect-ratio: var(--input-video-aspect, 16 / 9);
  background: #111111;
  object-fit: contain;
}

.error-message {
  max-width: 980px;
  margin: 15px auto 0;
  border: 1px solid #e5b5b5;
  border-radius: 6px;
  padding: 11px 14px;
  color: #8b2020;
  background: #fff5f5;
  line-height: 1.45;
}

.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;
}

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

@media (max-width: 760px) {
  .page-shell {
    padding: 28px 16px 38px;
  }

  .page-header p {
    font-size: 0.98rem;
  }

  .toolbar {
    margin-top: 20px;
  }

  .toolbar select {
    width: 100%;
  }

  .input-video-card {
    margin-top: 22px;
  }
}

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