:root {
  --bg: #f6f7f9; --fg: #15171a; --muted: #6b7280; --card: #fff; --line: #e3e5e8;
  --accent: #2563eb; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --fg: #e8eaed; --muted: #9aa0a6; --card: #181b21; --line: #2a2e36; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
code { background: var(--line); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
button, select, input { font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 8px; padding: 7px 14px; font-weight: 500; }
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.big { padding: 11px 22px; font-size: 16px; }
button.link { background: none; border: 0; color: var(--accent); padding: 6px 4px; }
button.icon { background: none; border: 0; padding: 4px 6px; font-size: 15px; opacity: .65; }
button.icon:hover { opacity: 1; }
button.wide { width: 100%; padding: 10px; font-weight: 600; }
button.danger.wide { border-color: var(--bad); }
.center { text-align: center; }

#top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1080px; margin: 0 auto; padding: 14px 16px; }
#top[hidden] { display: none; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 18px; color: var(--fg); }
.brand:hover { text-decoration: none; }
#nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; font-size: 14px; }
#nav a.muted { color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view { max-width: 1080px; margin: 0 auto; padding: 8px 16px 48px; }
#view[hidden] { display: none; }
h1 { margin: 8px 0 12px; font-size: 24px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 24px 0 8px; }
h3 { margin: 4px 0; font-size: 16px; }

.landing .hero { text-align: center; padding: 56px 0 40px; }
.landing .hero h1 { font-size: clamp(32px, 6vw, 52px); line-height: 1.1; margin-bottom: 16px; }
.lead { font-size: 18px; color: var(--muted); max-width: 640px; margin: 0 auto 28px; }
.cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 24px 0 40px; }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.feature p { margin: 6px 0 0; font-size: 14px; }
.ficon { font-size: 24px; }
.steps { max-width: 640px; margin: 0 auto; }
.steps ol { padding-left: 20px; display: grid; gap: 10px; }

.auth { max-width: 420px; margin: 32px auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.stack { display: grid; gap: 4px; }
.form { display: grid; gap: 14px; margin-top: 8px; }
.form label { display: grid; gap: 5px; font-size: 14px; font-weight: 500; }
.form input { padding: 10px 12px; font-size: 15px; }
.form input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form small { font-weight: 400; }
.msg { margin: 0; font-size: 14px; min-height: 1em; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--ok); }
.alt { text-align: center; font-size: 14px; margin: 16px 0 0; }
.spinner.dark { border-color: var(--line); border-top-color: var(--accent); }
.linkdev { display: flex; gap: 12px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 8px 0 12px; }

.panelhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 12px; align-content: start; }
.card.online { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.card.offline .devicon { filter: grayscale(1); opacity: .6; }
.card.empty { grid-column: 1 / -1; max-width: 560px; }
.card pre { margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 13px; }
.card pre code { background: none; padding: 0; }
.chead { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.devicon { font-size: 30px; line-height: 1; }
.name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opts select { min-width: 0; }
.card > button.primary { padding: 9px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.hint { font-size: 13px; color: var(--ok); }
.fp { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); word-break: break-all; }

#session { position: fixed; inset: 0; background: #000; }
#screen { width: 100%; height: 100%; object-fit: contain; outline: none; cursor: default; touch-action: none; }
#overlay { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #ddd; background: #000c; }
#overlay[hidden] { display: none; }
.spinner { width: 34px; height: 34px; margin: 0 auto 12px; border: 3px solid #555; border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toolbar { position: absolute; top: 0; left: 50%; transform: translate(-50%, -82%); transition: transform .2s; display: flex; gap: 6px; align-items: center;
  background: #16181ce6; color: #eee; padding: 6px 8px; border-radius: 0 0 12px 12px; max-width: calc(100vw - 16px); flex-wrap: wrap; z-index: 2; }
#toolbar:hover, #toolbar:focus-within, #toolbar.pinned { transform: translate(-50%, 0); }
#toolbar button, #toolbar select { background: #24272d; border-color: #33363d; color: #eee; padding: 4px 8px; }
.toggle { display: flex; gap: 4px; align-items: center; font-size: 13px; }
.spacer { flex: 1; }
.badge { padding: 2px 8px; border-radius: 999px; font-weight: 600; font-size: 12px; background: #444; }
.badge.LAN { background: var(--ok); } .badge.P2P { background: var(--accent); } .badge.Relay { background: var(--warn); }
#filesPanel { position: absolute; right: 8px; top: 48px; bottom: 8px; width: min(380px, calc(100vw - 16px)); background: var(--card); color: var(--fg);
  border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; overflow: hidden; z-index: 3; }
#filesPanel[hidden] { display: none; }
#filesPanel header { display: flex; justify-content: space-between; align-items: center; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 16px; text-align: center; cursor: pointer; }
.drop.over { border-color: var(--accent); }
.pathrow { display: flex; gap: 6px; } .pathrow input { flex: 1; min-width: 0; }
#listing { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; border-top: 1px solid var(--line); }
#listing li { padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#listing li:hover { background: var(--line); }
#transfers { list-style: none; margin: 0; padding: 0; font-size: 13px; max-height: 30%; overflow: auto; }
#transfers progress { width: 100%; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: #16181cf0; color: #eee; padding: 8px 14px; border-radius: 10px;
  max-width: min(600px, calc(100vw - 32px)); white-space: pre-wrap; word-break: break-word; z-index: 4; }
