:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --text: #11142a;
  --muted: #6a6f8a;
  --line: #dfe2ee;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #b45309;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #151b30;
    --text: #eef0fb;
    --muted: #9aa1c2;
    --line: #262d4a;
    --accent: #7c83ff;
    --accent-text: #0b1020;
    --ok: #4ade80;
    --bad: #f87171;
    --warn: #fbbf24;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: 6px; }
.logo { color: var(--accent); font-size: 1.4rem; }
.header-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.status { font-size: .8rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; margin-right: 4px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status[data-state="online"]::before { background: var(--ok); }
.status[data-state="offline"]::before { background: var(--bad); }

main { max-width: 720px; margin: 0 auto; padding: 0 16px 32px; }

button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent; padding: 8px 14px; color: inherit; background: none; }
button.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
button.ghost { border-color: var(--line); background: var(--surface); }
button.small { padding: 4px 10px; font-size: .85rem; }
button.link { padding: 0; border: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--accent); color: var(--accent-text); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px;
}
.banner[hidden] { display: none; }
.banner .ghost { color: var(--text); }

.radar {
  position: relative; min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden; padding: 24px 0;
}
.rings { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.rings i {
  position: absolute; border: 1px solid var(--line); border-radius: 50%;
  width: 140px; height: 140px; animation: pulse 4s ease-out infinite;
}
.rings i:nth-child(2) { animation-delay: 1.3s; }
.rings i:nth-child(3) { animation-delay: 2.6s; }
@keyframes pulse { from { transform: scale(.4); opacity: 1; } to { transform: scale(3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .rings i { animation: none; opacity: .5; } }

.peers { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; z-index: 1; }
.peer {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 104px;
  background: none; border: 0; padding: 4px;
}
.peer .avatar {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem;
  background: var(--surface); border: 2px solid var(--line); transition: transform .15s, border-color .15s;
}
.peer:hover .avatar, .peer.drag .avatar { transform: scale(1.06); border-color: var(--accent); }
.peer.own .avatar { border-color: var(--accent); }
.peer .pname { font-weight: 600; font-size: .9rem; word-break: break-word; }
.peer .psub { font-size: .75rem; color: var(--muted); }

.empty { position: relative; z-index: 1; text-align: center; color: var(--muted); margin: 0; padding: 0 16px; }
.empty[hidden] { display: none; }
.me { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: .9rem; }

.transfers-head { display: flex; align-items: center; justify-content: space-between; }
h2 { font-size: 1rem; margin: 0 0 8px; }
.muted { color: var(--muted); font-size: .9rem; }
#list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.t-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.t-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.t-name { font-weight: 600; word-break: break-all; }
.t-meta { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.t-item progress { width: 100%; height: 6px; margin-top: 8px; accent-color: var(--accent); }
.t-item[data-state="done"] .t-status { color: var(--ok); }
.t-item[data-state="fail"] .t-status { color: var(--bad); }
.t-actions { display: flex; gap: 8px; margin-top: 8px; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(92vw, 380px); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dlg-body { padding: 18px; display: grid; gap: 10px; }
.dlg-body h3 { margin: 0; }
.dlg-body p { margin: 0; }
.dlg-body label { font-size: .85rem; color: var(--muted); }
.dlg-body input {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); width: 100%;
}
.row { display: flex; gap: 8px; }
.dlg-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.dlg-actions.start { justify-content: flex-start; }
.file-line { font-weight: 600; word-break: break-all; }
.file-line small { color: var(--muted); font-weight: 400; }
.warn { color: var(--warn); font-size: .85rem; }
.error { color: var(--bad); font-size: .9rem; }
.code { font: 700 2rem/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .2em; text-align: center; padding: 8px 0; }
[hidden] { display: none !important; }

.qr-wrap { display: grid; place-items: center; }
#pair-qr { width: 200px; height: 200px; background: #fff; border-radius: 12px; image-rendering: pixelated; }
.center { text-align: center; }

.head-actions { display: flex; gap: 6px; }
label.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); font-size: .95rem; }
label.check input { width: auto; margin-top: 4px; }
