:root {
  color-scheme: dark;
  --bg: #101216;
  --panel: #171b21;
  --panel-2: #20262e;
  --text: #f2f5f8;
  --muted: #9ba7b4;
  --line: #343c47;
  --accent: #2bb673;
  --accent-strong: #38d989;
  --error: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(43, 182, 115, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(242, 91, 66, 0.08), transparent 28%),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  padding: 12px 0;
}

.workspace {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 10px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 32px;
}

.eyebrow {
  display: none;
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.status {
  min-width: 92px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(23, 27, 33, 0.8);
  font-size: 13px;
}

.url-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 33, 0.86);
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  color: var(--text);
  background: var(--panel-2);
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: #07130d;
  background: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  opacity: 0.65;
  cursor: progress;
}

.error[hidden] {
  display: none;
}

.error {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(255, 107, 107, 0.45);
  border-radius: 8px;
  color: #ffdada;
  background: rgba(255, 107, 107, 0.12);
}

.player-shell {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(180px, 1fr) auto;
  gap: 8px;
}

.player-frame {
  position: relative;
  width: 100%;
  min-height: 0;
  height: 100%;
  aspect-ratio: 16 / 9;
  max-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #050607;
}

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

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text);
  background: rgba(5, 6, 7, 0.72);
  pointer-events: none;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#loading-text {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

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

.player-controls {
  display: grid;
  grid-template-columns: auto auto minmax(180px, 1fr) auto auto minmax(82px, 120px) minmax(112px, 150px) auto;
  gap: 7px;
  align-items: center;
  min-height: 42px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 27, 33, 0.92);
}

.control-button {
  min-width: 56px;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--panel-2);
  font-size: 13px;
  font-weight: 700;
}

.icon-button {
  min-width: 38px;
  width: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-exit,
.icon-button.is-exit .icon-enter {
  display: none;
}

.icon-button.is-exit .icon-exit {
  display: block;
}

.control-button:hover,
.quality-select:hover {
  border-color: var(--accent);
}

.time-readout {
  min-width: 46px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  text-align: center;
}

.seek-slider,
.volume-slider {
  --range-progress: 0%;
  width: 100%;
  min-width: 0;
  height: 22px;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  accent-color: var(--accent-strong);
  outline: none;
  border: 0;
}

.seek-slider:focus,
.seek-slider:focus-visible,
.volume-slider:focus,
.volume-slider:focus-visible {
  outline: none;
  box-shadow: none;
}

.seek-slider::-webkit-slider-runnable-track,
.volume-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent-strong) 0,
    var(--accent-strong) var(--range-progress),
    var(--line) var(--range-progress),
    var(--line) 100%
  );
}

.seek-slider::-webkit-slider-thumb,
.volume-slider::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border: 2px solid #07130d;
  border-radius: 50%;
  background: var(--accent-strong);
  appearance: none;
  -webkit-appearance: none;
}

.seek-slider:focus::-webkit-slider-thumb,
.volume-slider:focus::-webkit-slider-thumb {
  box-shadow: none;
}

.seek-slider::-moz-range-track,
.volume-slider::-moz-range-track {
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent-strong) 0,
    var(--accent-strong) var(--range-progress),
    var(--line) var(--range-progress),
    var(--line) 100%
  );
}

.seek-slider::-moz-range-thumb,
.volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #07130d;
  border-radius: 50%;
  background: var(--accent-strong);
}

.seek-slider:focus::-moz-range-thumb,
.volume-slider:focus::-moz-range-thumb {
  outline: none;
  box-shadow: none;
}

.seek-slider:disabled {
  opacity: 0.45;
}

.quality-select {
  min-height: 32px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--panel-2);
  padding: 0 8px;
  outline: none;
}

.quality-select:disabled {
  color: var(--muted);
  opacity: 0.7;
}

.player-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  padding: 12px;
  grid-template-rows: minmax(0, 1fr) auto;
  background: #050607;
}

.player-shell:fullscreen .player-frame {
  min-height: 0;
  height: 100%;
  aspect-ratio: auto;
}

.player-shell:fullscreen video {
  object-fit: contain;
}

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

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .header {
    align-items: center;
  }

  h1 {
    font-size: 24px;
  }

  .url-bar {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .player-controls {
    grid-template-columns: auto auto minmax(90px, 1fr) auto;
  }

  .volume-slider,
  .quality-select,
  #fullscreen-toggle {
    grid-column: span 2;
  }

  .icon-button {
    width: 100%;
    min-width: 0;
  }
}
