/* Relay — a small dark instrument for flinging media at WhatsApp.
   Palette: ink green-black, bone text, one signal-green accent. */

:root {
  --bg: #0c1210;
  --surface: #151d1a;
  --surface-2: #1d2823;
  --line: #2a3831;
  --text: #e9efe9;
  --dim: #8fa39a;
  --accent: #3fd98a;
  --accent-ink: #06281a;
  --danger: #e07a5f;
  --r: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* beats display:flex on #busy / #crumbs */
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.mono { font-family: ui-monospace, "Cascadia Mono", monospace; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint { color: var(--dim); font-size: .875rem; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px 10px;
}
.wordmark { font-weight: 800; letter-spacing: .04em; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.tick { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); display: inline-block; }
.head-right { display: flex; gap: 8px; align-items: center; }
.pill {
  font-size: .72rem; padding: 3px 9px; border-radius: 99px;
  background: var(--surface-2); color: var(--dim); border: 1px solid var(--line);
}
.pill.ok { color: var(--accent-ink); background: var(--accent); border-color: transparent; font-weight: 700; }

main { flex: 1; padding: 6px 18px 90px; max-width: 560px; width: 100%; margin: 0 auto; }
section { animation: rise .18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { section { animation: none; } }

h2 { font-size: 1.15rem; margin: 14px 0 10px; }

input[type=url], input[type=search], input[type=password], input[type=text] {
  width: 100%; padding: 13px 14px; margin: 6px 0;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r);
  font-size: 1rem;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button {
  font: inherit; border: 0; border-radius: var(--r); cursor: pointer;
  color: var(--text); background: var(--surface-2); padding: 12px 16px;
}
button.primary {
  width: 100%; margin-top: 12px;
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
}
button.primary:disabled { opacity: .45; }
button.big { padding: 16px; font-size: 1.05rem; }
button.ghost { background: transparent; border: 1px solid var(--line); padding: 8px 12px; }

/* source picker */
.drop {
  display: flex; gap: 14px; align-items: center;
  border: 1.5px dashed var(--line); border-radius: var(--r);
  background: var(--surface); padding: 18px 16px; cursor: pointer;
}
.drop-icon { font-size: 1.6rem; color: var(--accent); }
.or { display: flex; align-items: center; gap: 12px; color: var(--dim); margin: 16px 0 6px; font-size: .8rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.chips { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.chips.col { flex-direction: column; }
.chip {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 99px; padding: 9px 14px; text-align: left;
}
.chips.col .chip { border-radius: var(--r); padding: 13px 15px; }
.chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.chip .sub { display: block; color: var(--dim); font-size: .8rem; }

/* player + trim — the signature */
#playerBox video, #playerBox audio { width: 100%; border-radius: var(--r); background: #000; }
#playerBox audio { margin-top: 6px; }

.trim {
  position: relative; height: 76px; margin-top: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; touch-action: none;
}
.wave { position: absolute; inset: 0; display: flex; align-items: center; gap: 2px; padding: 0 6px; }
.wave i { flex: 1; background: #33463d; border-radius: 2px; min-width: 2px; }
.win {
  position: absolute; top: 0; bottom: 0; left: 0%; right: 20%;
  border: 2px solid var(--accent); border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.handle {
  position: absolute; top: 0; bottom: 0; width: 26px; cursor: ew-resize;
  display: flex; align-items: center; justify-content: center;
}
.handle::after { content: ""; width: 4px; height: 26px; border-radius: 2px; background: var(--accent); }
.handle.l { left: -13px; } .handle.r { right: -13px; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .8; left: 0; pointer-events: none; }
.times { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

/* chat list */
.chatlist { list-style: none; margin: 8px 0 0; padding: 0; }
.chatlist li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 6px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: var(--surface-2); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.avatar.grp { border-radius: 12px; }
.chatlist .who { min-width: 0; }
.chatlist .who b { display: block; }
.chatlist .who span { color: var(--dim); font-size: .8rem; }

/* voice effects */
#voiceFx { margin-top: 10px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.fx-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.stepper { display: flex; gap: 10px; align-items: center; }
.stepper .ghost { padding: 6px 14px; font-weight: 800; }
.stepper input[type=range] { width: 130px; accent-color: var(--accent); }

/* misc */
nav#crumbs {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; gap: 10px; align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  color: var(--dim); font-size: .9rem;
}
nav#crumbs button { padding: 8px 14px; }

#busy {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(4px);
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }

.done-mark {
  width: 84px; height: 84px; margin: 40px auto 10px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-size: 2.4rem; display: flex; align-items: center; justify-content: center;
}
#qrImg { width: 260px; max-width: 100%; border-radius: var(--r); margin-top: 8px; background: #fff; padding: 8px; }
.err { color: var(--danger); }
