html {
  font-size: 15px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  background: #f4f5f7;
}

.btn:focus, .btn:active:focus, .form-control:focus, .form-select:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.track-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9rem;
  height: 1.9rem;
  margin-right: 0.6rem;
  border-radius: 50%;
  background: #212529;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
}

.player-slot video {
  display: block;
  width: 100%;
  max-height: 75vh;
  background: #000;
  border-radius: 0.375rem;
}

/* Watch page: the video fills the tab, with a title bar over the top that fades out while it plays. */
.watch-page {
  height: 100vh;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: #000;
}

.watch-player {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.watch-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 0.75rem 1rem 2.5rem;
  background: linear-gradient(rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.7) calc(100% - 2.5rem), transparent);
  transition: opacity 0.4s;
}

/* Solid backgrounds so the loop controls stay readable over a bright picture. */
.watch-overlay .loop-toolbar .btn,
.watch-overlay .loop-chip:not(.active) {
  background-color: rgba(33, 37, 41, 0.9);
}

.watch-overlay .loop-strip {
  background: rgba(255, 255, 255, 0.15);
}

.watch-overlay a {
  color: #fff;
  text-decoration: none;
}

.watch-overlay .form-select {
  max-width: min(32rem, calc(100vw - 2rem));
}

.watch-page.idle {
  cursor: none;
}

.watch-page.idle .watch-overlay {
  opacity: 0;
  pointer-events: none;
}

/* Each track's upload form, opened from its header. Without JavaScript the form is simply always open. */
.upload-toggle {
  padding: 0;
  border: 0;
  background: none;
  color: var(--bs-link-color);
}

.upload-toggle:hover {
  color: var(--bs-link-hover-color);
}

.upload-toggle::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.3rem;
  transition: transform 0.15s;
}

.upload-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

html:not(.js) .upload-toggle,
.js .upload:not(.open),
.version-count:empty {
  display: none;
}

/* One line per version, with its buttons. The one in the player is highlighted. */
.version {
  margin: 0 -0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.375rem;
}

.version + .version {
  margin-top: 0.125rem;
}

.version-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* "★ Favourite" and "☆ Make favourite" take the same room, so the buttons line up from one version to the next. */
.version .favorite-button {
  min-width: 10em;
}

.version.playing {
  background: var(--bs-primary-bg-subtle);
}

.version.playing .version-name {
  font-weight: 600;
}

.upload-progress {
  height: 1.1rem;
}

.pending .progress {
  height: 0.4rem;
}

/* The loop buttons hand focus back to the video so the keyboard controls it; no need to ring it for that. */
.player-slot video:focus:not(:focus-visible),
.watch-player:focus:not(:focus-visible) {
  outline: none;
}

/* Mirror. `scale`, not `transform`, because full-screen mode resets transform. The player's own controls are drawn
   inside the video, so they're flipped back to read normally (in browsers that let them be styled). */
video.mirrored {
  scale: -1 1;
}

video.mirrored::-webkit-media-controls {
  scale: -1 1;
}

/* Loop sections */
.loop-panel {
  margin-top: 0.5rem;
}

.loop-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.loop-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.loop-chip {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.loop-chip button {
  padding: 0.15rem 0.55rem;
  border: 0;
  background: transparent;
  color: inherit;
}

.loop-chip button:hover {
  background: var(--bs-secondary-bg);
}

.loop-chip .loop-chip-remove {
  padding-left: 0.25rem;
  color: var(--bs-secondary-color);
}

.loop-chip.active {
  border-color: var(--bs-primary);
  background: var(--bs-primary);
  color: #fff;
}

.loop-chip.active button:hover {
  background: rgba(0, 0, 0, 0.15);
}

.loop-chip.active .loop-chip-remove {
  color: rgba(255, 255, 255, 0.8);
}

.loop-strip {
  position: relative;
  margin-bottom: 0.5rem;
  border-radius: 3px;
  background: var(--bs-secondary-bg);
}

.loop-segment {
  position: absolute;
  height: 8px;
  min-width: 3px;
  border-radius: 3px;
  background: rgba(var(--bs-primary-rgb), 0.4);
  cursor: pointer;
}

.loop-segment.active {
  background: var(--bs-primary);
}

.loop-playhead {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  margin-left: -1px;
  background: var(--bs-danger);
  pointer-events: none;
}

.loop-status {
  margin-top: 0.25rem;
}

.loop-status:empty {
  display: none;
}

.watch-loops {
  flex-basis: 100%;
}

.watch-loops .loop-panel {
  margin-top: 0;
}

.delete-dialog {
  width: min(28rem, calc(100vw - 2rem));
  padding: 1.5rem;
  border: 0;
  border-radius: 0.5rem;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.3);
}

.delete-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}
