:root {
  --bg: #000;
  --card: #0e0e0e;
  --raised: #1a1a1a;
  --line: #242424;
  --text: #dcdcdc;
  --dim: #8f8f8f;
  --faint: #555;
  --pad: 1rem;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0 auto;
  max-width: 40rem;
  min-height: 100vh;
  padding: calc(0.75rem + env(safe-area-inset-top)) var(--pad) calc(6.5rem + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }
small, .dim, time { color: var(--dim); }
h1 { font-size: 1.15rem; font-weight: 600; margin: 0.25rem 0 0.75rem; }
h2 { font-size: 1rem; font-weight: 600; margin: 1.75rem 0 0.5rem; }
p { margin: 0.5rem 0; }
[hidden] { display: none !important; }

button, .button, input, select {
  font: inherit;
  color: var(--text);
  background: var(--raised);
  border: 1px solid #2a2a2a;
  border-radius: 999px;
  min-height: 44px;
  padding: 0.5rem 1.1rem;
}
button, .button { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
  justify-content: center; gap: 0.4rem; white-space: nowrap; user-select: none; }
button:active, .button:active { background: #2a2a2a; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary, .button.primary { background: var(--text); color: #000; border-color: var(--text); }
button.ghost { background: transparent; border-color: transparent; }
input { width: 100%; border-radius: 14px; }
input:focus, select:focus { outline: 1px solid var(--dim); }
label.check { display: flex; gap: 0.6rem; align-items: center; min-height: 44px; }
label.check input { width: 1.25rem; height: 1.25rem; min-height: 0; accent-color: #dcdcdc; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  min-height: 48px; margin-bottom: 0.25rem; }
.back { padding-left: 0.8rem; font-size: 1rem; }
.back::before { content: "‹"; font-size: 1.5rem; line-height: 1; margin-top: -0.15rem; }
.brand { font-weight: 600; font-size: 1.05rem; }

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.5rem 0; }
.row > input { flex: 1; min-width: 10rem; }
.stack { display: grid; gap: 0.6rem; }
.spacer { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 1rem; }
.error { color: #fff; background: #2a1414; border-radius: 14px; padding: 0.6rem 0.9rem; }
/* Scanners want dark modules on light, so the code sits on a white tile. */
.qr { justify-self: center; background: #fff; border-radius: 14px; padding: 0.4rem; line-height: 0; }
.qr svg { width: 13rem; height: auto; }
.code { text-align: center; font-size: 1.5rem; letter-spacing: 0.15em; margin: 0;
  font-variant-numeric: tabular-nums; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(5.5rem + env(safe-area-inset-bottom)); background: var(--text); color: #000;
  border-radius: 999px; padding: 0.6rem 1.2rem; max-width: calc(100% - 2rem); }

/* record first, decide the video later */
.capture { display: grid; gap: 0.6rem; margin: 0.5rem 0 1rem; }
.record { min-height: 5.5rem; font-size: 1.3rem; font-weight: 600; gap: 0.8rem;
  background: var(--text); color: #000; border-color: var(--text); }
.record .dot, .actions .dot { width: 1.4rem; height: 1.4rem; border-radius: 50%; background: #000;
  box-shadow: 0 0 0 3px var(--text), 0 0 0 5px #000; }
.actions .dot { width: 0.8rem; height: 0.8rem; box-shadow: none; }
@media (min-width: 60rem) { .capture { max-width: 40rem; } }

/* video list */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.tile { text-decoration: none; display: block; }
.tile .thumb { aspect-ratio: 16 / 9; background: var(--raised) center / cover no-repeat;
  border-radius: 14px; margin-bottom: 0.4rem; }
.tile .thumb.portrait { aspect-ratio: 4 / 5; }

/* player and timeline */
/* Full width, and never so tall that the strip, the controls and the action
   bar below it leave the screen. The video is centered inside by object-fit. */
.player { position: relative; margin: 0 calc(-1 * var(--pad)); background: #000;
  height: min(56.25vw, calc(100svh - 21.5rem - env(safe-area-inset-bottom) - env(safe-area-inset-top)));
  min-height: 12rem; display: grid; place-items: center; overflow: hidden; }
.player.portrait { height: min(177.8vw, calc(100svh - 21.5rem - env(safe-area-inset-bottom) - env(safe-area-inset-top))); }
.top .title { flex: 1; min-width: 0; margin: 0; text-align: center; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.player video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  display: block; background: #000; }
.player .empty { position: absolute; color: var(--faint); text-align: center; padding: 1rem; }

/* The strip is a window, the track inside is as wide as the zoom says. */
.strip { position: relative; margin: 0.4rem calc(-1 * var(--pad)) 0; padding: 0.5rem var(--pad);
  overflow: hidden; touch-action: none; cursor: pointer; user-select: none; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.track { position: relative; height: 3.5rem; width: 100%; }
.ticks { position: absolute; left: 0; right: 0; bottom: 0; height: 32%; pointer-events: none;
  border-radius: 0 0 12px 12px; }
.zoom { color: var(--dim); font-size: 0.85rem; min-width: 6.5rem; text-align: center;
  align-self: center; font-variant-numeric: tabular-nums; }
.strip .clips { position: absolute; inset: 0; display: flex; border-radius: 12px; overflow: hidden;
  background: var(--raised); }
.strip .clip { height: 100%; background: #2c2c2c; border-right: 2px solid #000; font-size: 0.75rem;
  padding: 0.25rem 0.4rem; overflow: hidden; white-space: nowrap; color: #bbb; }
.strip .clip:nth-child(even) { background: #383838; }
.strip .clip:last-child { border-right: 0; }
.strip .range { position: absolute; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.18);
  border-radius: 6px; pointer-events: none; }
.strip .handle { position: absolute; top: -0.45rem; bottom: -0.45rem; width: 22px; margin-left: -11px;
  display: grid; place-items: center; touch-action: none; cursor: ew-resize; }
.strip .handle::after { content: ""; width: 8px; height: 100%; border-radius: 4px; background: #fff; }
.strip .handle.active::after { width: 12px; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25); }
.strip .head { position: absolute; top: -0.3rem; bottom: -0.3rem; width: 2px; margin-left: -1px;
  background: #fff; border-radius: 1px; pointer-events: none; }
.times { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--dim);
  font-variant-numeric: tabular-nums; }

.controls { display: flex; gap: 0.5rem; justify-content: center; margin: 0.75rem 0; }
.controls button { min-width: 3.5rem; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.list li { display: flex; gap: 0.75rem; align-items: center; background: var(--card);
  border-radius: 14px; padding: 0.5rem 0.5rem 0.5rem 0.75rem; min-height: 3.5rem; }
.list li.current { outline: 1px solid #444; }
.list .grip { touch-action: none; cursor: grab; color: var(--dim); font-size: 1.3rem; width: 1.75rem;
  margin: -0.5rem 0 -0.5rem -0.4rem; align-self: stretch; display: grid; place-items: center; user-select: none; }
.list li.dragging { position: relative; z-index: 5; background: var(--raised); outline: 1px solid var(--dim);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); }
.list li.dragging .grip { cursor: grabbing; }
.list .mini { width: 4.5rem; aspect-ratio: 16 / 9; border-radius: 8px; flex: none;
  background: var(--raised) center / cover no-repeat; }
.list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.list .grow > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .grow > small { white-space: normal; }
.list button { min-width: 44px; padding: 0.5rem 0.8rem; }
.avatar { width: 2.25rem; height: 2.25rem; border-radius: 50%; flex: none; background: #333 center / cover;
  display: grid; place-items: center; font-size: 0.8rem; color: var(--text); }
.bar-progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 0.35rem; }
.bar-progress i { display: block; height: 100%; background: var(--text); border-radius: 3px; width: 0; }

/* bottom action bar, a toolbar on desktop */
.actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 0.6rem var(--pad) calc(0.6rem + env(safe-area-inset-bottom));
  display: flex; gap: 0.5rem; justify-content: center; }
.actions button, .actions .button { flex: 1; max-width: 11rem; }

dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 22px;
  padding: 1.25rem; width: min(26rem, calc(100% - 2rem)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
dialog h2 { margin-top: 0; }
.sheet button { width: 100%; justify-content: flex-start; }

.drop { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.85); display: grid;
  place-items: center; font-size: 1.2rem; border: 2px dashed var(--dim); border-radius: 22px; margin: 1rem; }

@media (min-width: 60rem) {
  body { max-width: 72rem; padding-bottom: 3rem; --pad: 2rem; }
  .player, .player.portrait { margin: 0 auto; border-radius: 14px; height: auto; aspect-ratio: 16 / 9;
    max-height: calc(100vh - 15rem); }
  .player.portrait { aspect-ratio: 9 / 16; }
  .strip { margin: 0.4rem -12px 0; padding: 0.5rem 12px; }
  .actions { position: static; background: none; backdrop-filter: none; border: 0;
    padding: 0; justify-content: center; margin: 0.75rem 0; }
  .toast { bottom: 2rem; }
  .split { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 2rem; align-items: start; }
  .split > aside h2:first-child { margin-top: 0.25rem; }
  .narrow { max-width: 34rem; }
}

/* in-page recorder */
.recorder { position: fixed; inset: 0; z-index: 50; background: #000; display: grid; }
.rec-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.rec-top, .rec-bottom { position: absolute; left: 0; right: 0; display: flex; align-items: center;
  justify-content: space-between; padding: 0 1rem; }
.rec-top { top: calc(0.75rem + env(safe-area-inset-top)); }
.rec-bottom { bottom: calc(1.5rem + env(safe-area-inset-bottom)); justify-content: center; }
.rec-top button { width: 48px; height: 48px; padding: 0; background: rgba(0, 0, 0, 0.45); border-color: transparent;
  font-size: 1.3rem; }
.rec-live { display: flex; align-items: center; gap: 0.5rem; background: rgba(0, 0, 0, 0.45);
  border-radius: 999px; padding: 0.35rem 0.9rem; font-variant-numeric: tabular-nums; }
.rec-live i { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.rec-stop { width: 76px; height: 76px; padding: 0; border-radius: 50%; background: transparent;
  border: 4px solid #fff; }
.rec-stop span { width: 30px; height: 30px; border-radius: 6px; background: #fff; }

/* blocking card while new clips upload and process */
.adding { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.75);
  display: grid; place-items: center; padding: 1rem; }
.adding .card { width: min(24rem, 100%); }
.adding h2 { margin: 0; }
