:root {
  --bg: #f2f2f7;
  --surface: #fff;
  --raised: #e4e4ea;
  --text: #111113;
  --muted: #5c5c66;
  --accent: #39b54a;
  --on-accent: #06150a;
  --warn: #c4271d;
  --control: 48px;
  --radius: 18px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0f;
    --surface: #1c1c1f;
    --raised: #2a2a2e;
    --text: #fff;
    --muted: #a6a6ad;
    --accent: #39b54a;
    --on-accent: #06150a;
    --warn: #ff6961;
  }
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px/1.5 -apple-system,
    system-ui,
    sans-serif;
}
main {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
header,
.row,
.me {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
h1 {
  margin: 0;
  font-size: 26px;
}
p {
  margin: 0;
}
.hint {
  color: var(--muted);
  font-size: 14px;
}
.center {
  text-align: center;
}
.icon {
  display: inline-grid;
  font-style: normal;
  line-height: 0;
}
.icon svg {
  width: 1.15em;
  height: 1.15em;
}
.btn {
  position: relative;
  min-height: var(--control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--raised);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.btn:active {
  transform: scale(0.97);
}
.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.btn.small {
  min-height: 44px;
  padding: 0 14px;
  font-size: 14px;
}
:focus-visible,
.btn:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.card,
.me {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
}
.me > .icon {
  font-size: 22px;
  color: var(--accent);
}
.me > span,
.me > form {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.me > form {
  flex-direction: row;
  gap: 8px;
}
.me small {
  color: var(--muted);
}
.me strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
input:not([type='file']) {
  flex: 1;
  min-width: 0;
  min-height: var(--control);
  padding: 0 14px;
  border: 1px solid var(--raised);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.tools {
  display: flex;
  gap: 8px;
}
.radar {
  position: relative;
  height: 320px;
  flex-shrink: 0;
  overflow: hidden;
}
.radar > i {
  position: absolute;
  width: 250px;
  height: 250px;
  left: calc(50% - 125px);
  top: calc(50% - 125px);
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0.12;
}
.radar.on > i {
  animation: ripple 2.4s ease-out infinite;
}
.radar.on > i:nth-child(2) {
  animation-delay: 0.8s;
}
.radar.on > i:nth-child(3) {
  animation-delay: 1.6s;
}
@keyframes ripple {
  from {
    transform: scale(0.35);
    opacity: 0.7;
  }
  to {
    transform: scale(1.18);
    opacity: 0;
  }
}
.radar-me {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 20px;
  transform: translate(-50%, -50%);
}
.peers {
  position: absolute;
  inset: 0;
}
.peer {
  position: absolute;
  width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transform: translate(-50%, -50%);
  animation: appear 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
  transition:
    transform 0.2s cubic-bezier(0.2, 1.6, 0.4, 1),
    left 0.4s ease,
    top 0.4s ease;
}
@keyframes appear {
  from {
    transform: translate(-50%, -50%) scale(0);
  }
}
.peer:active,
.peer.over {
  transform: translate(-50%, -50%) scale(1.14);
}
.peer b {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--raised);
  font-size: 26px;
}
.peer.over b,
.peer.ready b {
  box-shadow: 0 0 0 3px var(--accent);
}
.peer span {
  max-width: 100%;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

/* Files in flight, as in the app. */
.stage {
  display: flex;
  align-items: center;
  gap: 8px;
  direction: ltr;
}
.stage .end {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--raised);
  font-size: 24px;
}
.wire {
  position: relative;
  flex: 1;
  height: 40px;
}
.wire::before {
  content: '';
  position: absolute;
  inset-inline: 0;
  top: calc(50% - 1px);
  border-top: 3px dashed var(--accent);
}
.packet {
  position: absolute;
  top: 50%;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  opacity: 0;
}
.stage.moving .packet {
  animation: fly 0.96s cubic-bezier(0.45, 0.05, 0.35, 1) infinite;
}
.stage.incoming .packet {
  animation-direction: reverse;
}
@keyframes fly {
  0% {
    left: 0;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1) rotate(-8deg);
  }
  80% {
    opacity: 1;
  }
  100% {
    left: 100%;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) rotate(8deg);
  }
}
.ring {
  position: relative;
  width: 170px;
  height: 170px;
  flex-shrink: 0;
  align-self: center;
}
.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring circle {
  fill: none;
  stroke: var(--raised);
  stroke-width: 8;
}
.ring circle.value {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear;
}
.ring-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.speed {
  color: var(--muted);
  font-size: 14px;
}
.track {
  position: relative;
  height: 6px;
  flex-shrink: 0;
  margin: 10px 12px;
  border-radius: 3px;
  background: var(--raised);
}
.track .fill {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 0;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.15s linear;
}
.track .plane {
  position: absolute;
  top: -9px;
  inset-inline-start: 0;
  margin-inline-start: -12px;
  color: var(--accent);
  font-size: 21px;
  transition: inset-inline-start 0.15s linear;
}
[dir='rtl'] .plane {
  transform: scaleX(-1);
}
.burst {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  align-self: center;
}
.burst span {
  position: absolute;
  inset: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 24px;
  animation: stamp 0.5s cubic-bezier(0.2, 1.8, 0.4, 1);
}
.burst > i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 12px;
  margin: -6px 0 0 -2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  animation: spark 0.7s ease-out;
}
@keyframes stamp {
  from {
    transform: scale(0);
  }
}
@keyframes spark {
  from {
    opacity: 1;
    transform: rotate(var(--turn)) translateY(-18px) scaleY(0.4);
  }
  to {
    opacity: 0;
    transform: rotate(var(--turn)) translateY(-46px);
  }
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.kind input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
#selected {
  margin-top: 12px;
}
.names {
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}
.names li {
  padding: 4px 0;
  overflow-wrap: anywhere;
}
.names .btn {
  width: 100%;
  justify-content: flex-start;
  border-radius: 14px;
}
.send-bar {
  position: sticky;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.send-bar:empty {
  display: none;
}
.send-bar .btn {
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.3);
}
summary {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
details[open] {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#public,
#private {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#join {
  display: flex;
  gap: 8px;
}
#qr {
  align-self: center;
  border-radius: 12px;
  background: #fff;
}
.code {
  display: block;
  text-align: center;
  font-size: 34px;
  letter-spacing: 6px;
}
dialog {
  width: min(440px, calc(100% - 24px));
  max-height: 88dvh;
  padding: 20px;
  border: 0;
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
}
#sheet-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  text-align: center;
}
.who {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 20px;
}
.percent {
  font-size: 40px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}
progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
}
.good {
  color: var(--accent);
}
.warn {
  color: var(--warn);
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
  }
}

/* Frosted glass, as on the iPhone, in the app's own flat colors. It shows
   where something floats over the page: the title, the send bar and windows. */
:root {
  --glass: rgb(245 245 247 / 0.72);
  --edge: rgb(0 0 0 / 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --glass: rgb(28 28 31 / 0.66);
    --edge: rgb(255 255 255 / 0.1);
  }
}
header,
.send-bar .btn,
dialog {
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}
/* A bar across the whole screen; what is in it lines up with the cards below. */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, calc((100% - 488px) / 2)) 8px;
  background: var(--glass);
  border-bottom: 1px solid var(--edge);
}
.send-bar {
  z-index: 10;
}
.send-bar .btn.primary {
  background: color-mix(in srgb, var(--accent) 84%, transparent);
}
dialog {
  background: var(--glass);
  border: 1px solid var(--edge);
  box-shadow: 0 24px 70px rgb(0 0 0 / 0.45);
}
dialog::backdrop {
  background: rgb(0 0 0 / 0.35);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.names li,
#selected,
dialog[open] #sheet-body {
  animation: enter 0.25s ease;
}
@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.btn {
  transition: transform 0.12s ease;
}
@media (prefers-reduced-motion: reduce) {
  .packet,
  .burst > i {
    display: none;
  }
}
@media (prefers-reduced-transparency: reduce) {
  header,
  dialog {
    background: var(--surface);
  }
}
.busy .radar > i {
  animation: none;
}

#group-new,
#group-on {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.qr {
  align-self: center;
  border-radius: 12px;
  background: #fff;
}
.peer.mine span {
  color: var(--accent);
  font-weight: 600;
}
/* Where to let go of dragged files. It never takes the drop itself. */
.dropzone {
  position: fixed;
  inset: 12px;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 24px;
  border: 3px dashed var(--accent);
  border-radius: 24px;
  pointer-events: none;
  opacity: 0;
  transform: scale(1.03);
  transition:
    opacity 0.18s ease,
    transform 0.25s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.dragging .dropzone {
  opacity: 1;
  transform: scale(1);
}
.dropzone strong {
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  text-align: center;
  animation: bob 1s ease-in-out infinite;
}
.dragging .peer b {
  outline: 2px dashed var(--accent);
  outline-offset: 6px;
  animation: bob 0.9s ease-in-out infinite;
}
.dragging .peer.over b {
  background: var(--accent);
  color: var(--on-accent);
  animation: none;
}
@keyframes bob {
  50% {
    transform: translateY(-6px);
  }
}
