:root {
  --bg: #100e0c;
  --raise: #1c1914;
  --ink: #1a140c;
  --line: rgba(244, 236, 220, 0.14);
  --text: #f6f1e7;
  --muted: #c4b8a6;
  --brass: #e2b15a;
  --brass-deep: #a97828;
  --danger: #ff8d7d;
  --ok: #b7d7a8;
  --shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
  --serif: "Liberation Serif", "Nimbus Roman", Georgia, serif;
  --sans: Quicksand, "Liberation Sans", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(1100px 480px at 8% -10%, rgba(226, 177, 90, 0.16), transparent 55%),
    radial-gradient(800px 420px at 100% 0%, rgba(120, 52, 28, 0.18), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.45;
}

::selection { background: var(--brass); color: var(--ink); }

a { color: inherit; }

.sprocket {
  height: 26px;
  background-color: #1a1612;
  background-image: radial-gradient(circle at center, #070605 0 5px, transparent 5.5px);
  background-size: 32px 26px;
  background-repeat: repeat-x;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}

.wrap {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

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

.top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin: 28px 0 18px;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--brass);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3rem, 7vw, 4.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 0.88;
}

h1 a { text-decoration: none; }

.lede {
  max-width: 34ch;
  margin: 0;
  color: var(--muted);
}

.banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #3a2a14;
  color: #f0d7a4;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content max-content;
  gap: 10px;
  padding: 12px;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.composer .field { min-width: 0; }

input, select, button { font: inherit; color: inherit; }

#url,
input[type="text"],
input[type="url"],
input[type="search"],
select {
  width: 100%;
  min-height: 48px;
  padding: 0.85rem 1rem;
  background: #100e0c;
  border: 1px solid var(--line);
  border-radius: 12px;
}

#url { min-width: 0; }

#quality { width: auto; min-width: 11rem; }

input:focus, select:focus {
  outline: none;
  border-color: var(--brass);
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.force {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 10px 2px 0;
  color: var(--muted);
}

.force input { width: 1.05rem; height: 1.05rem; accent-color: var(--brass); }

.hint {
  max-width: 72ch;
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.error {
  margin: 8px 2px 0;
  color: var(--danger);
}

.error:empty { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.7rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  color: var(--text);
}

.composer .btn-primary { min-height: 48px; }
.btn-primary { background: var(--brass); color: var(--ink); }
.btn-primary:hover { background: #f0c56e; }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }

.btn-ghost { border-color: var(--line); }
.btn-ghost:hover { border-color: var(--brass); color: var(--brass); }

.btn-danger { border-color: rgba(255, 141, 125, 0.5); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 141, 125, 0.12); border-color: var(--danger); }
.btn-danger:disabled { opacity: 0.6; cursor: progress; }

.btn-tiny {
  min-height: 36px;
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--line);
}

.jobs {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.jobs:empty { display: none; }

.job {
  padding: 12px 14px;
  background: var(--raise);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  border-radius: 16px;
}

.job.error { border-left-color: var(--danger); }
.job.done, .job.exists { border-left-color: var(--ok); }
.job.cancelled { border-left-color: var(--muted); }

.job-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.job strong { overflow-wrap: anywhere; }

.job p { margin: 6px 0 0; color: var(--muted); font-size: 0.92rem; }
.job .errmsg { color: var(--danger); }

.bar {
  position: relative;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  background: #100e0c;
  border-radius: 99px;
}

.bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brass-deep), var(--brass));
  border-radius: inherit;
}

.bar.indeterminate > span {
  position: absolute;
  width: 35%;
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  from { left: -40%; }
  to { left: 100%; }
}

.library-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin: 8px 0 14px;
}

.library-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 700;
}

.count { margin: 4px 0 0; color: var(--muted); }

.search { max-width: 280px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.card:hover { border-color: rgba(226, 177, 90, 0.5); }

.thumb-link {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(160deg, #3a3126, #221c16 55%, #14110e);
  color: inherit;
}

.thumb-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.play {
  position: absolute;
  inset: 0;
  width: 52px;
  height: 52px;
  margin: auto;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(16, 14, 12, 0.55);
  display: grid;
  place-items: center;
}

.play::before {
  content: "";
  margin-left: 3px;
  border-style: solid;
  border-width: 8px 0 8px 13px;
  border-color: transparent transparent transparent #fff;
}

.time, .kind {
  position: absolute;
  bottom: 8px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.78);
  color: white;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.time { right: 8px; }
.kind { left: 8px; }

.card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  padding: 12px 14px 14px;
}

.card h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 700;
  line-height: 1.25;
}

.card h3 a { text-decoration: none; }
.card h3 a:hover { color: var(--brass); }

.channel, .facts {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: start;
  margin-top: auto;
}

.grid > .empty { grid-column: 1 / -1; }

.empty, .missing, .unplayable {
  padding: 42px 20px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  text-align: center;
  color: var(--muted);
}

.empty h3, .missing h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.7rem;
}

.back {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--brass);
  text-decoration: none;
}

.stage {
  overflow: hidden;
  background: #000;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.stage video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #000;
}

.stage audio,
.watch > audio {
  display: block;
  width: 100%;
}

.stage audio { padding: 28px 16px; }

.watch > audio { margin: 0 0 18px; }

.solo-title {
  margin: 4px 0 8px;
  font-family: var(--serif);
  font-size: 1.15rem;
}

.watch h2 {
  margin: 16px 0 6px;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  font-weight: 700;
  line-height: 1.15;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 18px;
}

.text-link { color: var(--brass); }

.desc-title {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.desc {
  margin: 0;
  color: #efe7da;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

footer {
  margin: 36px 0 28px;
  color: var(--muted);
  font-size: 0.88rem;
}

footer code { color: var(--text); }

.quote-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 48px 0;
  text-align: center;
}

.quote-page blockquote {
  margin: 0;
  max-width: 18em;
}

.quote-page p {
  margin: 0;
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4.4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.35;
}

.quote-page cite {
  display: block;
  margin-top: 1.4rem;
  color: var(--muted);
  font-size: 1rem;
  font-style: normal;
  letter-spacing: 0.04em;
}

.quote-page[hidden] { display: none; }

.users { margin-top: 28px; }

.user-composer {
  margin-top: 12px;
  grid-template-columns: minmax(0, 1fr) max-content;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr) max-content;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.user-row strong { display: block; }

.user-row .channel { margin: 2px 0 0; }

.hash-url {
  font-family: ui-monospace, "Liberation Mono", monospace;
  font-size: 0.92rem;
}

.noscript {
  width: min(1120px, calc(100% - 32px));
  margin: 12px auto;
  color: var(--danger);
}

@media (max-width: 720px) {
  .wrap { width: min(1120px, calc(100% - 20px)); }
  .top { flex-direction: column; align-items: start; margin-top: 20px; }
  .composer { grid-template-columns: 1fr; }
  #quality { width: 100%; }
  .library-head { flex-direction: column; align-items: stretch; }
  .search { max-width: none; }
  .user-row { grid-template-columns: 1fr; }
  .stage video { max-height: 56vh; }
}

@media (prefers-reduced-motion: reduce) {
  .bar.indeterminate > span {
    animation: none;
    left: 0;
    width: 100%;
    opacity: 0.45;
  }
}
