:root {
  color-scheme: light;
  --page: #eef1f3;
  --surface: #ffffff;
  --ink: #171b1d;
  --muted: #677176;
  --line: #cfd6d9;
  --accent: #d64d2f;
  --accent-strong: #b83c22;
  --success: #14715d;
  --warning: #ad6a12;
  --danger: #b53333;
  --player: #090b0c;
  font-family: "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 27, 29, 0.04) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--page);
}

button,
select,
input {
  font: inherit;
}

button,
select {
  min-height: 44px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 30px 0 22px;
  border-bottom: 1px solid var(--line);
}

.identity {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

.wordmark,
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.wordmark {
  color: var(--accent);
}

.eyebrow {
  color: var(--muted);
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

h1 {
  font-size: clamp(22px, 2.8vw, 34px);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-top: 5px;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.service-state {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}

.service-state[data-state="ready"] .state-dot {
  background: var(--success);
}

.service-state[data-state="error"] .state-dot {
  background: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  width: min(1480px, calc(100% - 48px));
  margin: 28px auto 40px;
  align-items: start;
}

.player-column {
  min-width: 0;
}

.player-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid #2d3336;
  border-radius: 6px;
  background: var(--player);
  box-shadow: 0 18px 45px rgba(16, 20, 22, 0.16);
}

#player {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--player);
  object-fit: contain;
}

.start-layer,
.load-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  color: #f4f7f8;
  background: rgba(9, 11, 12, 0.72);
}

.start-layer[hidden],
.load-layer[hidden] {
  display: none;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 160px;
  padding: 0 22px;
  border: 0;
  border-radius: 4px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.primary-action:focus-visible,
.icon-button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(214, 77, 47, 0.28);
  outline-offset: 2px;
}

.icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  background: currentColor;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
}

.icon-play {
  mask-image: url("./icons/play.svg");
  -webkit-mask-image: url("./icons/play.svg");
}

.icon-refresh {
  mask-image: url("./icons/rotate-ccw.svg");
  -webkit-mask-image: url("./icons/rotate-ccw.svg");
}

.icon-wave {
  mask-image: url("./icons/audio-waveform.svg");
  -webkit-mask-image: url("./icons/audio-waveform.svg");
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.now-playing {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 22px 2px 0;
}

.media-facts {
  display: flex;
  gap: 26px;
}

.media-facts div {
  min-width: 62px;
}

.media-facts dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.media-facts dd {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.test-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.panel-heading,
.monitor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  min-width: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.icon-button:hover {
  border-color: #aeb8bc;
  background: #f5f7f8;
}

.selector-label {
  margin-bottom: -10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  width: 100%;
  padding: 0 38px 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
}

.status-list {
  border-top: 1px solid var(--line);
}

.status-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.status-row strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #adb5b8;
}

.status-row[data-state="ok"] .status-icon {
  background: var(--success);
}

.status-row[data-state="ok"] strong {
  color: var(--success);
}

.status-row[data-state="error"] .status-icon {
  background: var(--danger);
}

.status-row[data-state="error"] strong {
  color: var(--danger);
}

.status-row[data-state="loading"] .status-icon {
  background: var(--warning);
}

.status-row[data-state="loading"] strong {
  color: var(--warning);
}

.audio-monitor {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.monitor-heading {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 13px;
}

.monitor-heading strong {
  margin-left: auto;
  color: var(--ink);
  font-size: 12px;
}

.level-track {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 2px;
  background: #e2e6e8;
}

.level-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--success);
  transition: width 80ms linear;
}

.human-check {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0;
  border: 0;
}

.human-check legend {
  width: 100%;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.human-check label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}

.human-check input {
  width: 17px;
  height: 17px;
  accent-color: var(--success);
}

.error-message {
  padding: 12px;
  border-left: 3px solid var(--danger);
  color: var(--danger);
  background: #fff4f2;
  font-size: 13px;
  line-height: 1.5;
}

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

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .test-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .panel-heading,
  .selector-label,
  #episodeSelect,
  .status-list,
  .catalog-time {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .topbar,
  .workspace {
    width: min(100% - 28px, 1480px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding-top: 22px;
  }

  .identity {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .service-state {
    width: 100%;
  }

  .workspace {
    margin-top: 18px;
  }

  .player-frame {
    aspect-ratio: 9 / 13;
  }

  .now-playing {
    align-items: flex-start;
    flex-direction: column;
  }

  .media-facts {
    width: 100%;
    justify-content: space-between;
  }

  .test-panel {
    display: flex;
  }

  .human-check {
    grid-template-columns: 1fr;
  }
}

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