/* ShareHere — interface inspired by Snapdrop's peer-to-peer design language.
   Circular avatars, a centred stage, dotted beams, floating transfer cards. */

:root {
  --primary: #4285f4;
  --primary-2: #3367d6;
  --primary-soft: rgba(66, 133, 244, 0.35);
  --bg: #fafafa;
  --bg-2: #f1f3f4;
  --card: #ffffff;
  --fg: #1f2733;
  --muted: #6b7280;
  --line: rgba(15, 21, 30, 0.08);
  --line-strong: rgba(15, 21, 30, 0.16);
  --bad: #d64545;
  --good: #1a9e5c;
  --av-shadow: 0 0 18px rgba(0, 0, 0, 0.14);
  --av-shadow-self: 0 0 0 6px rgba(138, 180, 248, 0.5), 0 8px 26px rgba(51, 103, 214, 0.35);
  --av-shadow-hover: 0 0 0 4px #8ab4f8, 0 0 22px rgba(51, 103, 214, 0.35);
  --card-shadow: 0 6px 28px rgba(0, 0, 0, 0.16);
  --fall-op: 0.5;
}

html[data-theme="dark"] {
  --primary: #6ea2ff;
  --primary-2: #3367d6;
  --bg: #0f151e;
  --bg-2: #18202c;
  --card: #161e2a;
  --fg: #e6eaf0;
  --muted: #9aa4b4;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --av-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 6px 22px rgba(0, 0, 0, 0.45);
  --av-shadow-self: 0 0 0 6px rgba(110, 162, 255, 0.22), 0 0 0 14px rgba(110, 162, 255, 0.08), 0 10px 40px rgba(47, 107, 224, 0.45);
  --av-shadow-hover: 0 0 0 4px rgba(138, 180, 248, 0.9), 0 0 22px rgba(51, 103, 214, 0.5);
  --card-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --fall-op: 0.4;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- falling file icons (ambient) ---- */
.fall { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; opacity: var(--fall-op);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 82%, transparent 96%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 16%, #000 82%, transparent 96%); }
.fall i { position: absolute; top: -70px; left: var(--x, 10%); width: 32px; height: 41px;
  background: var(--card); border: 1px solid var(--line); border-radius: 5px; opacity: 0.5;
  animation: fall var(--d, 26s) linear var(--t, 0s) infinite; }
.fall i::after { content: ""; position: absolute; top: -1px; right: -1px; width: 11px; height: 11px;
  background: var(--bg); border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0 4px 0 3px; }
@keyframes fall { from { transform: translate3d(0, -70px, 0) rotate(var(--r, -10deg)); }
  to { transform: translate3d(0, 100vh, 0) rotate(calc(var(--r, -10deg) * -1.4)); } }
.fall i:nth-child(1) { --x: 5%;  --d: 30s; --t: -4s;  --r: -14deg; }
.fall i:nth-child(2) { --x: 18%; --d: 40s; --t: -22s; --r: 12deg; }
.fall i:nth-child(3) { --x: 33%; --d: 24s; --t: -12s; --r: -8deg; }
.fall i:nth-child(4) { --x: 70%; --d: 36s; --t: -28s; --r: 16deg; }
.fall i:nth-child(5) { --x: 84%; --d: 28s; --t: -9s;  --r: -12deg; }
.fall i:nth-child(6) { --x: 93%; --d: 44s; --t: -34s; --r: 10deg; }
.fall i:nth-child(7) { --x: 46%; --d: 50s; --t: -18s; --r: 6deg; }
.fall i:nth-child(8) { --x: 60%; --d: 32s; --t: -2s;  --r: -18deg; }
@media (prefers-reduced-motion: reduce) { .fall { display: none; } }

/* ---- top bar ---- */
.topbar {
  width: 100%; max-width: 1300px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 22px 24px 18px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 24px; height: 24px; color: var(--primary); flex: none; }
.wordmark { font-size: 19px; letter-spacing: -0.02em; }
.wordmark b { font-weight: 700; }
.wordmark i { font-style: normal; font-weight: 300; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.status { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.online .dot { background: var(--primary); box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.18); }
.status.offline .dot { background: var(--bad); }

.iconbtn {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: var(--card); border: 1px solid var(--line); color: var(--fg);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, transform 0.1s;
}
.iconbtn:hover { border-color: var(--line-strong); }
.iconbtn:active { transform: scale(0.95); }
.iconbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn .sun { display: none; }
html[data-theme="dark"] .iconbtn .sun { display: block; }
html[data-theme="dark"] .iconbtn .moon { display: none; }

.chip {
  height: 38px; padding: 0 14px; border-radius: 999px; display: inline-flex; align-items: center; gap: 9px;
  background: var(--card); border: 1px solid var(--line); cursor: pointer; font-size: 13px; font-weight: 600;
  max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.chip:hover { border-color: var(--line-strong); }
.me-color { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); flex: none; }

/* hover tooltips on any control carrying data-tip */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  background: #1f2733; color: #fff; font-size: 12px; font-weight: 500; line-height: 1.25;
  padding: 6px 9px; border-radius: 7px; white-space: nowrap; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity 0.12s ease; z-index: 130;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; visibility: visible; }
html[data-theme="dark"] [data-tip]::after { background: #2b3442; }

/* collapsible QR popover */
.qr-wrap { position: relative; display: inline-flex; }
.qr-pop {
  position: absolute; top: calc(100% + 10px); right: 0; width: 206px; z-index: 90;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--card-shadow); padding: 14px; text-align: center;
}
.qr-pop[hidden] { display: none; }
.qr-pop .qr-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; width: fit-content; margin: 0 auto; line-height: 0; }
.qr-pop .qr-box svg, .qr-pop .qr-box img { width: 150px; height: 150px; display: block; }
.qr-pop .qr-hint { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: var(--muted); margin: 10px 0; word-break: break-all; }

/* ---- stage ---- */
/* ---- main layout: details · ring · send/transfers ---- */
.app-main {
  flex: 1 1 auto; width: 100%; max-width: 1300px; margin: 0 auto;
  display: grid; gap: 26px; align-items: start;
  padding: 10px 24px 0;
}
.side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 18px; }
.card > h3 { margin: 0 0 14px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.11em; color: var(--muted); font-weight: 700; }
.me-row { display: flex; align-items: center; gap: 12px; }
.me-av { width: 46px; height: 46px; flex: none; border-radius: 50%; background: var(--primary-2); color: #fff; display: grid; place-items: center; }
.me-av svg { width: 52%; height: 52%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.me-txt { min-width: 0; }
.me-txt b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-txt .muted { font-size: 12px; }
.mini-qr { display: grid; place-items: center; margin-bottom: 14px; }
.mini-qr #qrSide { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; line-height: 0; }
.mini-qr #qrSide svg, .mini-qr #qrSide img { width: 150px; height: 150px; display: block; }
.stage-col { display: flex; justify-content: center; align-items: center; min-width: 0; }
.send-card { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.send-card > h3 { align-self: flex-start; }
.send-card .btn { width: 100%; justify-content: center; }
.send-card .btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.stage {
  position: relative;
  width: min(100%, 560px, 58vh);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}
@media (min-width: 1060px) {
  .app-main { grid-template-columns: minmax(210px, 286px) minmax(0, 1fr) minmax(232px, 300px); }
}
@media (max-width: 1059px) {
  .app-main { grid-template-columns: 1fr; gap: 20px; }
  .stage-col { order: 1; }
  .side-right { order: 2; }
  .side-left { order: 3; }
}
.pings { position: absolute; inset: 0; pointer-events: none; }
.pings i {
  position: absolute; left: 50%; top: 50%; width: 100%; height: 100%;
  margin: -50% 0 0 -50%; border-radius: 50%; border: 2px solid var(--primary-soft);
  opacity: 0; animation: ping 4.2s cubic-bezier(0.2, 0.6, 0.4, 1) infinite;
}
.pings i:nth-child(2) { animation-delay: 1.4s; }
.pings i:nth-child(3) { animation-delay: 2.8s; }
@keyframes ping { 0% { transform: scale(0.12); opacity: 0; } 12% { opacity: 1; } 100% { transform: scale(0.74); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pings { display: none; } }

.beams { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.beams line { stroke: var(--primary-soft); stroke-width: 1.5; stroke-dasharray: 1.5 3; stroke-linecap: round; }
.beams line.flow { stroke: var(--primary-2); stroke-width: 3; stroke-dasharray: 0.6 3.4; animation: flow 0.7s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -4; } }

.node {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 64px; height: 64px; padding: 0; border: 0; background: none;
  cursor: pointer; color: inherit; border-radius: 50%;
}
.node .av {
  position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%;
  background: var(--card); box-shadow: var(--av-shadow);
  display: grid; place-items: center; color: var(--primary-2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.node .av svg { width: 44%; height: 44%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.node:hover .av, .node:focus-visible .av { transform: scale(1.08); box-shadow: var(--av-shadow-hover); }
.node.selected .av { box-shadow: var(--av-shadow-hover); }
.node.drop .av { transform: scale(1.14); box-shadow: var(--av-shadow-hover); }
.node .name {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 8px;
  font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 132px;
}
.node .sub {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 27px;
  font-size: 11px; color: var(--muted); white-space: nowrap;
}

/* keep the ring readable as it fills up */
.stage.crowded .node { width: 52px; height: 52px; }
.stage.crowded .node .name { font-size: 12px; max-width: 96px; }
.stage.crowded .node.you { width: 74px; height: 74px; }

/* the "you" node */
.node.you { z-index: 3; width: 88px; height: 88px; }
.node.you .av { background: var(--primary-2); color: #fff; box-shadow: var(--av-shadow-self); }
.node.you:hover .av { transform: scale(1.05); }
.node.you .name { font-weight: 700; max-width: 200px; }
html[data-theme="dark"] .node.you .av { background: linear-gradient(145deg, #5a9bff 0%, #2f6be0 55%, #2556c4 100%); }

/* progress ring while busy */
.node .av::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%; opacity: 0; pointer-events: none;
  background: conic-gradient(var(--primary-2) calc(var(--p, 0) * 360deg), rgba(51, 103, 214, 0.14) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  transition: opacity 0.2s;
}
.node.busy .av::after { opacity: 1; }
.node.busy .av { animation: breathe 1.5s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 6px rgba(138, 180, 248, 0.45), 0 0 26px rgba(51, 103, 214, 0.4); } }
@media (prefers-reduced-motion: reduce) { .node.busy .av { animation: none; } }

.everyone .av::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; opacity: 0; pointer-events: none;
  background: conic-gradient(var(--primary-2) calc(var(--p, 0) * 360deg), rgba(51, 103, 214, 0.14) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  transition: opacity 0.2s;
}
.everyone.busy .av::after { opacity: 1; }

.peers { position: absolute; inset: 0; }

.stage-empty {
  position: absolute; left: 50%; top: 50%; transform: translateX(-50%); margin-top: 108px;
  width: min(320px, 86%); text-align: center; color: var(--muted); pointer-events: none;
}
.stage-empty[hidden] { display: none; }
.stage-empty svg { width: 44px; height: 44px; fill: none; stroke: var(--primary-soft); stroke-width: 1.6; stroke-linecap: round; margin-bottom: 8px; }
.stage-empty p { margin: 0 0 4px; font-size: 15px; color: var(--fg); font-weight: 600; }
.stage-empty span { font-size: 13px; }
.stage-empty b { color: var(--primary); font-weight: 600; word-break: break-all; }

/* ---- stage bar ---- */
/* ---- stage bar (controls now live in the right card) ---- */
.everyone {
  display: inline-flex; align-items: center; gap: 12px; padding: 8px 18px 8px 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.06); cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.everyone:hover { border-color: var(--line-strong); }
.everyone.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.18); }
.everyone.drop { transform: scale(1.03); border-color: var(--primary); }
.everyone .av { position: relative; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--primary-2); color: #fff; display: grid; place-items: center; }
.everyone .av svg { width: 60%; height: 60%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.everyone-txt { text-align: start; line-height: 1.25; }
.everyone-txt b { display: block; font-size: 14px; font-weight: 700; }
.everyone-txt i { display: block; font-style: normal; font-size: 11px; color: var(--muted); }

.hint { margin: 0; font-size: 14px; color: var(--muted); }
.hint .count { display: block; margin-top: 5px; font-size: 12px; }
.hint .count b { color: var(--primary); }
.link { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
.link:hover { text-decoration: underline; }

.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg-btn { border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600; padding: 7px 18px; border-radius: 999px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.seg-btn.active { background: var(--primary-2); color: #fff; }

/* ---- footer ---- */
.foot {
  position: relative; z-index: 45;
  width: 100%; max-width: 1300px; margin: 0 auto;
  display: flex; justify-content: flex-start; gap: 18px; flex-wrap: wrap;
  padding: 22px 24px 26px; color: var(--muted); font-size: 12px;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- transfer cards (in the right column) ---- */
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-height: 44vh; overflow-y: auto; }
.cards-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 8px; }
.transfer {
  position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--card-shadow); padding: 14px 16px;
  animation: card-in 0.22s ease-out;
}
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .transfer { animation: none; } }
.transfer.recv { border-left: 4px solid var(--primary-2); }
.transfer.error { border-left: 4px solid var(--bad); }
.t-x { position: absolute; top: 8px; right: 10px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; }
.t-x:hover { background: var(--bg-2); color: var(--fg); }
.t-name { font-weight: 600; font-size: 14px; padding-right: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-sub { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.t-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.t-actions:empty { display: none; }
.bar { height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--primary-2); transition: width 0.3s linear; }
.transfer.done .bar > i { background: var(--good); }
.transfer.error .bar > i { background: var(--bad); }

.btn {
  appearance: none; border: 1px solid transparent; background: var(--primary-2); color: #fff;
  padding: 8px 16px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; color: var(--primary); border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--primary); }
.btn.small { padding: 6px 13px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(15, 21, 30, 0.45); display: grid; place-items: center; padding: 16px; overscroll-behavior: contain; }
.modal[hidden] { display: none; }
.modal-card { position: relative; background: var(--card); border-radius: 18px; padding: 26px; width: min(440px, 100%); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); text-align: center; }
.modal-card h3 { margin: 0 0 8px; font-size: 19px; }
.modal-x { position: absolute; top: 10px; right: 14px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.modal-x:hover { background: var(--bg-2); color: var(--fg); }
.modal-card label { display: block; text-align: start; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 8px; }
.modal-card input[type="text"] { width: 100%; margin-top: 7px; padding: 11px 12px; font-size: 15px; color: var(--fg); background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: 10px; }
.modal-card input[type="text"]:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.modal-actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 6px; }

.invite-card .qr { display: grid; place-items: center; margin: 14px 0 8px; }
.invite-card .qr #qr { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px; line-height: 0; }
.invite-card .qr #qr svg, .invite-card .qr #qr img { display: block; width: 168px; height: 168px; }
.qr-hint { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--muted); margin: 0 0 12px; word-break: break-all; }
.address-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.address-list li { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; }

/* ---- gate ---- */
.gate { position: fixed; inset: 0; z-index: 80; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.gate[hidden] { display: none; }
.gate-card { text-align: center; width: min(320px, 100%); }
.gate-mark { width: 46px; height: 46px; color: var(--primary); margin-bottom: 14px; }
.gate-card .wordmark { display: block; font-size: 22px; margin-bottom: 26px; }
.gate-card h3 { margin: 0 0 4px; font-size: 18px; }
.gate-card input { width: 100%; text-align: center; letter-spacing: 0.5em; font-size: 22px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--card); border: 1px solid var(--line-strong); color: var(--fg); padding: 14px; border-radius: 12px; margin: 18px 0 12px; }
.gate-card input:focus { outline: none; border-color: var(--primary); }
.gate-card .btn { width: 100%; justify-content: center; }
.gate-err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 12px 0 0; }

/* ---- toasts ---- */
.toasts { position: fixed; top: 82px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { background: #323232; color: rgba(255, 255, 255, 0.96); border-radius: 10px; padding: 11px 16px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); animation: toast-in 0.2s ease-out; border-left: 3px solid var(--primary); }
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ---- search nearby ---- */
.searchbtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.scan { display: flex; justify-content: center; gap: 8px; margin: 4px 0 16px; }
.scan span { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); opacity: 0.3; animation: scanpulse 1.2s ease-in-out infinite; }
.scan span:nth-child(2) { animation-delay: 0.18s; }
.scan span:nth-child(3) { animation-delay: 0.36s; }
.scan.done { display: none; }
@keyframes scanpulse { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .scan span { animation: none; opacity: 0.7; } }
.nearby-list { text-align: start; display: flex; flex-direction: column; gap: 16px; max-height: 46vh; overflow-y: auto; }
.nearby-group h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; }
.nearby-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); margin-bottom: 6px; }
.nearby-item .av { width: 30px; height: 30px; border-radius: 50%; background: var(--card); display: grid; place-items: center; color: var(--primary-2); flex: none; }
.nearby-item .av svg { width: 60%; height: 60%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nearby-item .ni-txt { min-width: 0; flex: 1; }
.nearby-item .ni-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nearby-item .ni-sub { font-size: 12px; color: var(--muted); }
.nearby-item a.open { color: var(--primary); font-weight: 600; text-decoration: none; font-size: 13px; white-space: nowrap; flex: none; }
.nearby-item a.open:hover { text-decoration: underline; }
.nearby-empty { color: var(--muted); font-size: 13px; padding: 2px 0 6px; }

/* ---- responsive ---- */
@media (max-width: 768px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 16px; }
  .wordmark { font-size: 17px; }
  .top-actions { width: 100%; justify-content: flex-start; flex-wrap: nowrap; gap: 8px; }
  .status { font-size: 0; order: 0; }              /* dot only on small screens */
  .status .dot { width: 9px; height: 9px; }
  .searchbtn span { display: none; }               /* icon-only, aria-labelled */
  .searchbtn { padding: 9px 11px; }
  .chip { margin-left: auto; min-width: 0; flex: 0 1 auto; }
  .app-main { padding: 8px 16px 0; gap: 16px; }
  .stage { width: min(100%, 80vw, 50vh); }
  .node { width: 54px; height: 54px; }
  .node.you { width: 74px; height: 74px; }
  .cards { max-height: none; }
  .foot { padding: 16px 16px 20px; }
  .hint { font-size: 13px; }
  .toasts { top: 128px; }
}
@media (max-width: 400px) {
  .chip { max-width: 120px; }
}
