/* LocalDrop. Layout: a full-height "signal field" - your device at the bottom with rings
   spreading up, the nearby devices floating above it as cards; dialogs slide up as sheets. */
:root {
    --bg: #f3f1ec;
    --bg-deep: #e7e3da;
    --panel: #ffffff;
    --ink: #17202f;
    --muted: #5f6878;
    --line: #dcd6ca;
    --accent: #f2643f;          /* the drop: coral */
    --accent-2: #e8457a;
    --on-accent: #ffffff;
    --signal: #2f9f92;          /* the rings: teal */
    --ok: #1f8a5b;
    --bad: #c2412d;
    --shadow: 0 18px 40px -24px rgba(23, 32, 47, .45);
    --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
    --body: "Figtree", "Segoe UI", system-ui, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, monospace;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1a2e;
        --bg-deep: #0a1322;
        --panel: #172540;
        --ink: #edf1f8;
        --muted: #9aa7bd;
        --line: #273857;
        --accent: #ff7a52;
        --accent-2: #ff5d8f;
        --signal: #7fd1c7;
        --ok: #5fd39a;
        --bad: #ff8a75;
        --shadow: 0 18px 40px -20px rgba(0, 0, 0, .7);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: radial-gradient(ellipse 90% 70% at 50% 100%, var(--bg-deep), var(--bg) 70%);
    color: var(--ink);
    font: 16px/1.5 var(--body);
    -webkit-tap-highlight-color: transparent;
}
.sprite { display: none; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 22px/1 var(--display); letter-spacing: -.01em; }
.bar__actions { display: flex; align-items: center; gap: 8px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
    font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .15s, background .2s, box-shadow .2s;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); box-shadow: 0 10px 22px -12px var(--accent); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--panel); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.link { padding: 0; border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 6px 0 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; }
.chip b { font-family: var(--mono); letter-spacing: .08em; }
.chip button { display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 50%; background: transparent; cursor: pointer; color: var(--muted); }
.chip button .ic { width: 16px; height: 16px; }
.chip .ic { width: 16px; height: 16px; color: var(--signal); }

/* ---------- the field ---------- */
.stage { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 20px; padding: 8px max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left)); overflow: clip; }
.stage__hint { margin: 0; color: var(--muted); font-size: 15px; text-align: center; min-height: 1.5em; }

.rings { position: absolute; left: 50%; bottom: 46px; width: 0; height: 0; pointer-events: none; z-index: 0; }
.rings span { position: absolute; left: 0; top: 0; width: 140px; height: 140px; margin: -70px 0 0 -70px; border-radius: 50%; border: 1.5px solid var(--signal); opacity: 0; animation: ring 4.5s cubic-bezier(.2, .6, .3, 1) infinite; }
.rings span:nth-child(2) { animation-delay: 1.5s; }
.rings span:nth-child(3) { animation-delay: 3s; }
@keyframes ring { 0% { transform: scale(.4); opacity: .55; } 100% { transform: scale(6); opacity: 0; } }

.me { position: sticky; bottom: max(14px, env(safe-area-inset-bottom)); margin-top: auto; align-self: center; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.me__icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: color-mix(in srgb, var(--signal) 18%, transparent); color: var(--signal); }
.me__icon .ic { width: 24px; height: 24px; }
.me__text { min-width: 0; }
.me__text small { display: block; color: var(--muted); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.me__name { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 0; border: 0; background: none; cursor: pointer; font: 700 18px/1.25 var(--display); }
.me__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me__name .ic { width: 16px; height: 16px; color: var(--muted); }

/* ---------- devices ---------- */
.peers { position: relative; z-index: 1; display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; margin: 0; padding: 12px 0 24px; list-style: none; width: 100%; max-width: 900px; }
.peer { position: relative; width: 170px; }
.peer__card {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%;
    padding: 18px 12px 16px; border-radius: 24px; border: 1px solid var(--line); background: var(--panel);
    box-shadow: var(--shadow); cursor: pointer; text-align: center; transition: transform .2s, border-color .2s;
    animation: arrive .45s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes arrive { from { opacity: 0; transform: translateY(16px) scale(.92); } to { opacity: 1; transform: none; } }
.peer__card:hover, .peer.is-drop .peer__card { transform: translateY(-4px); border-color: var(--accent); }
.peer__avatar { position: relative; display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--panel)), color-mix(in srgb, var(--accent-2) 18%, var(--panel))); color: var(--accent); }
.peer__avatar .ic { width: 32px; height: 32px; }
.peer__ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); }
.peer__ring circle { fill: none; stroke-width: 4; }
.peer__ring .track { stroke: var(--line); }
.peer__ring .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .25s; }
.peer__name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 16px/1.2 var(--display); }
.peer__status { min-height: 1.4em; font-size: 13px; color: var(--muted); }
.peer__status.is-busy { color: var(--accent); font-weight: 600; }
.peer__status.is-ok { color: var(--ok); font-weight: 600; }
.peer__status.is-bad { color: var(--bad); font-weight: 600; }
.peer__text { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; }
.peer__text:hover { color: var(--accent); border-color: var(--accent); }
.peer__text .ic { width: 17px; height: 17px; }
.peer__via { position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--signal); }

.empty { position: relative; z-index: 1; max-width: 460px; margin: auto 0; text-align: center; }
.empty h1 { margin: 0 0 8px; font: 700 clamp(26px, 5vw, 36px)/1.15 var(--display); letter-spacing: -.01em; text-wrap: balance; }
.empty p { margin: 6px 0; color: var(--muted); }
.empty b { color: var(--ink); }
.empty__alt { font-size: 15px; }

.foot { padding: 10px max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); text-align: center; font-size: 13px; color: var(--muted); }
.foot p { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 0; }
.foot .ic { width: 15px; height: 15px; color: var(--signal); }

/* ---------- dialogs (sheets) ---------- */
.sheet { width: min(480px, calc(100% - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 26px; background: var(--panel); color: var(--ink); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6); }
.sheet::backdrop { background: rgba(10, 16, 28, .55); backdrop-filter: blur(3px); }
.sheet[open] { animation: rise .3s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.sheet form { display: flex; flex-direction: column; gap: 12px; padding: 22px; }
.sheet h2 { margin: 0; font: 700 24px/1.2 var(--display); text-wrap: balance; }
.sheet p { margin: 0; color: var(--muted); }
.sheet__eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent) !important; }
.sheet__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.sheet textarea, .field input { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
#roomInput { font: 500 26px/1 var(--mono); letter-spacing: .3em; text-transform: uppercase; text-align: center; }
.code { font: 500 44px/1.1 var(--mono); letter-spacing: .25em; color: var(--ink) !important; text-align: center; }
.linkbox { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-radius: 14px; background: var(--bg); font: 500 13px/1.4 var(--mono); word-break: break-all; }
.linkbox span { flex: 1; min-width: 0; }
.message { margin: 0; max-height: 50vh; overflow: auto; padding: 14px; border-radius: 14px; background: var(--bg); font: 15px/1.55 var(--body); white-space: pre-wrap; word-break: break-word; }
.files { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow: auto; margin: 0; padding: 0; list-style: none; }
.files li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--bg); min-width: 0; }
.files .ic { color: var(--accent); }
.files .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.files .size { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.files--done img { width: 44px; height: 44px; object-fit: cover; border-radius: 10px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.muted { font-size: 14px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 16px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: var(--shadow); animation: rise .25s ease; pointer-events: auto; }
.toast.is-bad { background: var(--bad); color: #fff; }

@media (max-width: 600px) {
    .bar .btn span { display: none; }
    .bar .btn { padding: 0 12px; }
    .brand { font-size: 20px; }
    .peers { gap: 12px; }
    .peer { width: calc(50% - 6px); max-width: 180px; }
    .peer__avatar { width: 64px; height: 64px; }
    .sheet { margin: auto auto 0; width: 100%; max-width: none; border-radius: 26px 26px 0 0; }
    .sheet form { padding: 20px 18px max(20px, env(safe-area-inset-bottom)); }
    .sheet__actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .rings span, .peer__card, .sheet[open], .toast { animation: none; }
    .rings span:first-child { opacity: .3; transform: scale(2); }
}

/* A green dot: connected directly (files go device to device) */
.peer__avatar::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--panel); background: var(--line); transition: background .3s; }
.peer.is-direct .peer__avatar::after { background: var(--ok); }
