:root {
  --bg: #0e100c;
  --bg-2: #171a13;
  --bg-3: #22271b;
  --ink: #14160f;
  --text: #f4f3ea;
  --muted: #a3aa94;
  --line: rgba(223, 242, 90, 0.22);
  --lime: #dff25a;
  --lime-2: #c6db45;
  --danger: #ff7a59;
  --ok: #b6f2a2;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --safe-t: max(16px, env(safe-area-inset-top));
  --safe-b: max(16px, env(safe-area-inset-bottom));
  --safe-l: max(16px, env(safe-area-inset-left));
  --safe-r: max(16px, env(safe-area-inset-right));
  color-scheme: dark;
  font-family: "Segoe UI", "Avenir Next", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { min-height: 100vh; min-height: 100dvh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--lime); }
img { display: block; max-width: 100%; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--lime);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(56px, 9vw, 92px);
  line-height: 0.86;
  letter-spacing: -0.055em;
  font-weight: 760;
}

h2 { margin: 0; font-size: 22px; letter-spacing: -0.03em; }

.lead { margin: 0; font-size: 18px; line-height: 1.4; color: var(--text); }
.fine { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.mono-link {
  display: inline-block;
  margin-top: 10px;
  font-family: "IBM Plex Mono", "SFMono-Regular", ui-monospace, monospace;
  font-size: 16px;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  word-break: break-all;
}

.home, .upload {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: var(--safe-t) var(--safe-r) calc(var(--safe-b) + 24px) var(--safe-l);
}

.mast, .section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
}
.mast { margin-bottom: 22px; }
.health { margin: 0; max-width: 240px; text-align: right; color: var(--muted); font-size: 14px; }

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 40%), var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.field-label, legend {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
  color: var(--muted);
}
fieldset { border: 0; margin: 14px 0; padding: 0; }

input[type="text"], input[type="url"] {
  width: 100%;
  min-height: 64px;
  border-radius: 16px;
  border: 1px solid #3a412e;
  background: #10130d;
  padding: 0 18px;
  font-size: 18px;
  outline: none;
}
input[type="text"]:focus, input[type="url"]:focus { border-color: var(--lime); }

.qualities, .q-inline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.q-card, .q-inline button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #343b2b;
  background: #12150f;
  text-align: left;
}
.q-card input { position: absolute; opacity: 0; pointer-events: none; }
.q-card strong, .q-inline button { font-size: 16px; font-weight: 700; }
.q-card small { color: var(--muted); font-size: 12px; }
.qualities legend { grid-column: 1 / -1; }
.q-card.is-on, .q-inline button[aria-pressed="true"] {
  background: var(--lime);
  color: var(--ink);
  border-color: var(--lime);
}
.q-card.is-on small { color: #3d4618; }

.go, .transport button, .text-btn, .center-play, .drop {
  border: 0;
  border-radius: 14px;
}
.go {
  width: 100%;
  min-height: 64px;
  background: var(--lime);
  color: var(--ink);
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.go:disabled { opacity: 0.6; }
.text-btn {
  min-height: 48px;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid #343b2b;
}

.banner, .toast {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 122, 89, 0.14);
  color: #ffd0c4;
  border: 1px solid rgba(255, 122, 89, 0.4);
}
.banner[data-kind="ok"] {
  background: rgba(182, 242, 162, 0.1);
  color: var(--ok);
  border-color: rgba(182, 242, 162, 0.35);
}

.library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.card {
  min-height: 112px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid #343b2b;
  background: #12150f;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}
.card strong { font-size: 18px; letter-spacing: -0.02em; }
.card em {
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--lime);
  align-self: flex-start;
  padding: 3px 6px;
  border-radius: 999px;
  font-weight: 750;
}
.card.new { outline: 2px solid var(--lime); }

.inbox { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.inbox button {
  min-height: 64px;
  border-radius: 14px;
  border: 1px solid var(--lime);
  background: #1c220f;
  text-align: left;
  padding: 10px 14px;
  font-size: 17px;
}

.qr-row { display: flex; gap: 18px; align-items: center; }
.qr-row img {
  width: 168px;
  height: 168px;
  border-radius: 16px;
  background: #f4f3ea;
  padding: 8px;
  flex: none;
}

.audio-sink {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.player {
  position: fixed;
  inset: 0;
  background: #050604;
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
}
.player[hidden], .home[hidden] { display: none; }
#screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #050604;
}
.edge-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: 0;
  background: var(--lime);
  z-index: 3;
  pointer-events: none;
}

.topbar, .controls {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 4;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  transition: opacity 180ms ease;
}
.topbar {
  top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: var(--safe-t);
  padding-bottom: 18px;
  background: linear-gradient(180deg, rgba(5, 6, 4, 0.88), rgba(5, 6, 4, 0));
}
.now { flex: 1; min-width: 0; }
.now p { margin: 0; }
#now-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}
#sync-readout {
  color: var(--lime);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  margin-top: 2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}
.conn {
  margin: 0;
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid #343b2b;
}
.conn[data-state="open"] { color: var(--ok); border-color: rgba(182, 242, 162, 0.4); }
.conn[data-state="reconnecting"], .conn[data-state="connecting"] { color: #ffd27a; }
.conn[data-state="closed"] { color: var(--danger); }

.controls {
  bottom: 0;
  padding-bottom: calc(var(--safe-b) + 8px);
  background: linear-gradient(0deg, rgba(5, 6, 4, 0.92), rgba(5, 6, 4, 0));
}
.scrub-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
}
#scrub { height: 40px; }
#scrub::-webkit-slider-runnable-track {
  height: 6px;
  background: #3a412e;
  border-radius: 99px;
}
#scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--lime);
  border: 0;
}
#scrub::-moz-range-track { height: 6px; background: #3a412e; border-radius: 99px; }
#scrub::-moz-range-thumb { width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--lime); }

.transport {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}
.transport button, .q-inline button {
  min-height: 56px;
  padding: 0 14px;
  background: var(--bg-3);
  border: 1px solid #343b2b;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 650;
}
.transport button[aria-pressed="true"] { background: var(--lime); color: var(--ink); border-color: var(--lime); }
.volume { width: 120px; display: flex; align-items: center; }
#volume { height: 36px; }
#volume::-webkit-slider-runnable-track { height: 4px; background: #3a412e; border-radius: 99px; }
#volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--text);
}
.q-inline { display: flex; gap: 8px; }
.q-inline button { min-width: 0; }

.center-play, .buffering, .ended, .toast {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
}
.center-play {
  min-width: 148px;
  min-height: 148px;
  border-radius: 50%;
  background: var(--lime);
  color: var(--ink);
  font-size: 28px;
  font-weight: 760;
  box-shadow: var(--shadow);
}
.buffering, .ended {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-radius: 18px;
  background: rgba(8, 10, 6, 0.78);
  border: 1px solid var(--line);
}
.ended { width: min(360px, calc(100% - 32px)); text-align: center; }
.ended p { margin: 0; font-size: 20px; }
.toast { top: auto; bottom: 140px; width: min(520px, calc(100% - 32px)); text-align: center; }
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #3a412e;
  border-top-color: var(--lime);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.player.chrome-off .topbar,
.player.chrome-off .controls,
.player.chrome-off .center-play { opacity: 0; pointer-events: none; }

.upload h1 { margin-bottom: 8px; }
.drop {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  min-height: 160px;
  width: 100%;
  padding: 20px;
  border: 1.5px dashed #5c6844;
  background: #12150f;
  text-align: left;
}
.drop-title { font-size: 28px; font-weight: 740; letter-spacing: -0.03em; }
.drop input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.progress-wrap {
  margin-top: 12px;
  height: 10px;
  border-radius: 99px;
  background: #2a3122;
  overflow: hidden;
}
.progress { height: 100%; width: 0; background: var(--lime); }

button:focus-visible, input:focus-visible, .card:focus-visible, .q-card:focus-visible {
  outline: 3px solid var(--lime);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .mast, .qr-row { flex-direction: column; align-items: flex-start; }
  .health { text-align: left; max-width: none; }
  .qualities { grid-template-columns: 1fr; }
  h1 { font-size: 64px; }
  .center-play { min-width: 120px; min-height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .topbar, .controls { transition: none; }
}

.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 8px;
}
.tile {
  min-height: 148px;
  border-radius: 22px;
  border: 1px solid var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-2);
}
.tile strong { font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.04em; line-height: 0.95; }
.tile-kicker { color: var(--muted); font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; }
.tile-youtube { background: #231f10; }
.tile-netflix { background: #2a1214; }
.tile-yttv { background: #121820; }
.tile-note { margin: 0 0 16px; }

.full-btn {
  min-height: 56px;
  padding: 0 16px;
  border-radius: 14px;
  border: 0;
  background: var(--lime);
  color: var(--ink);
  font-weight: 750;
  flex: none;
}
.player:fullscreen,
.player.is-fill {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #050604;
}
.player:fullscreen #screen,
.player.is-fill #screen {
  width: 100%;
  height: 100%;
}

.gate {
  width: min(520px, 100%);
  margin: 0 auto;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}
.pin-dots {
  font-size: 36px;
  letter-spacing: 0.4em;
  margin: 8px 0 16px;
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.keypad button {
  min-height: 84px;
  border: 0;
  border-radius: 18px;
  background: var(--bg-3);
  font-size: 32px;
  font-weight: 700;
}
.keypad button[data-key="clear"],
.keypad button[data-key="back"] { font-size: 18px; }

@media (max-width: 720px) {
  .tiles { grid-template-columns: 1fr; }
  .tile { min-height: 112px; }
}
