/* The site's one stylesheet. The same slate and sky the app is drawn in, dark
   only: it is mostly a wall of thumbnails and a video, which read best on
   black, and a phone at night is where it will be watched. */

:root {
  --bg: #020617;
  --panel: #0f172a;
  --line: #1e293b;
  --text: #e2e8f0;
  --quiet: #94a3b8;
  --faint: #64748b;
  --accent: #38bdf8;
  --bad: #f87171;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(2, 6, 23, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-weight: 650; letter-spacing: -0.01em; }
.grow { flex: 1; }
.who { color: var(--faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.out { font-size: 13px; white-space: nowrap; }

.status {
  margin: 14px 16px 4px;
  color: var(--faint);
  font-size: 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px 14px;
  padding: 10px 16px calc(28px + env(safe-area-inset-bottom));
}

.tile { display: block; color: inherit; }
.tile:hover { text-decoration: none; }
.tile:hover .t { color: var(--accent); }

.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: var(--panel);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.len {
  position: absolute;
  right: 7px;
  bottom: 7px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font: 500 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.meta { display: block; padding: 8px 2px 0; }
.t {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 560;
  line-height: 1.3;
}
.c, .d { display: block; color: var(--quiet); font-size: 13px; margin-top: 2px; }
.d { color: var(--faint); font-size: 12px; }

.watch {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 0 calc(28px + env(safe-area-inset-bottom));
}
.watch video {
  display: block;
  width: 100%;
  max-height: 78vh;
  background: #000;
}
.watch h1 { font-size: 19px; margin: 14px 16px 4px; line-height: 1.3; }
.watch .quiet { margin: 2px 16px; }

.centre {
  min-height: 80vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.card {
  width: 100%;
  max-width: 380px;
  padding: 26px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.tile.card { max-width: none; padding: 0; border: 0; background: none; }
.card h1 { margin: 0 0 6px; font-size: 20px; }
.quiet { color: var(--quiet); font-size: 13px; }
.note { margin: 0 0 14px; color: var(--quiet); text-align: center; }
.note.bad { color: var(--bad); }

input {
  width: 100%;
  margin: 14px 0 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* anything smaller and iOS zooms in on focus */
}
input[name="code"] { letter-spacing: 0.35em; text-align: center; font-variant-numeric: tabular-nums; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #020617;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }

/* ---- On this device ------------------------------------------------- */

.device {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin: 4px 16px 6px;
  color: var(--quiet);
  font-size: 12px;
}
.device label { display: inline-flex; align-items: center; gap: 8px; }
.device select {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
}
.device-note { color: var(--faint); }
.device .save-now {
  width: auto;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 560;
}

.here {
  position: absolute;
  left: 7px;
  bottom: 7px;
  padding: 1px 7px;
  border-radius: 5px;
  background: rgba(14, 165, 233, 0.92);
  color: #020617;
  font-size: 11px;
  font-weight: 650;
}

/* Offline, a video not on this device cannot play: say so by fading it. */
.tile.absent { opacity: 0.35; pointer-events: none; }

.keep { margin: 12px 16px 0; }
.keep-btn {
  width: auto;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-weight: 560;
  font-size: 13px;
}
.keep-btn.on { border-color: var(--accent); color: var(--accent); }
.keep-btn:disabled { opacity: 0.7; cursor: default; }

/* ---- The list's own player ------------------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  background: var(--bg);
}
body.watching { overflow: hidden; }
.overlay .back {
  width: auto;
  padding: 0;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 560;
}

.overlay .pip {
  width: auto;
  padding: 0;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 560;
}

/* ---- Watched, here or on the Mac ------------------------------------ */

.seen {
  position: absolute;
  right: 7px;
  top: 7px;
  padding: 1px 7px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.tile.done .thumb img { opacity: 0.55; }

/* How far it was watched: a thin red line along the bottom, as on YouTube. */
.seen-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 4px;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.28);
}
.seen-bar::-webkit-progress-bar { background: rgba(255, 255, 255, 0.28); }
.seen-bar::-webkit-progress-value { background: #ef4444; }
.seen-bar::-moz-progress-bar { background: #ef4444; }

/* ---- Pull to refresh ------------------------------------------------- */

.pull {
  position: fixed;
  top: calc(56px + env(safe-area-inset-top));
  left: 50%;
  z-index: 20;
  transform: translate(-50%, -12px);
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--quiet);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.pull.showing { opacity: 1; transform: translate(-50%, 0); }

/* ---- Asking before saving ------------------------------------------- */

.device .free-in { display: inline-flex; align-items: center; gap: 8px; }
.device .free-in select { max-width: 11rem; }
.ask {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 6px 16px 10px;
  padding: 10px 12px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 12px;
  background: rgba(251, 191, 36, 0.08);
  color: var(--text);
  font-size: 13px;
}
.ask-text { flex: 1 1 14rem; }
.ask button {
  width: auto;
  padding: 6px 12px;
  font-size: 13px;
}
.ask .ask-no {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}
