:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --text: #121527;
  --muted: #646a82;
  --border: #e2e5ef;
  --accent: #4f46e5;
  --accent-2: #06b6d4;
  --accent-soft: #e9e8fd;
  --danger: #dc2626;
  --ok: #16a34a;
  --shadow: 0 10px 30px rgba(20, 22, 50, .08), 0 2px 6px rgba(20, 22, 50, .05);
  --radius: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f1a;
    --surface: #161928;
    --surface-2: #1f2336;
    --text: #eceefa;
    --muted: #9198b3;
    --border: #272c43;
    --accent: #818cf8;
    --accent-soft: #23264a;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
h2, h3 { margin: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  padding-top: max(14px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 20px; letter-spacing: -.02em; }
.brand img { border-radius: 9px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; }
.status.online i { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.status.offline i { background: var(--danger); }

main { max-width: 860px; margin: 0 auto; padding: 8px 16px 60px; }

.you { text-align: center; padding: 24px 0 32px; }
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.me {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; background: none; padding: 4px 10px; border-radius: 10px;
  font-size: 28px; font-weight: 750; letter-spacing: -.02em;
}
.me svg { color: var(--muted); opacity: .6; }
.me:hover { background: var(--surface-2); }
.me:hover svg { opacity: 1; }
.muted { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.center { text-align: center; }

.section-title { font-size: 15px; font-weight: 650; color: var(--muted); margin: 0 4px 14px; }

.peers { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.peer {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 24px 14px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform .15s ease, border-color .15s ease;
  animation: pop .25s ease;
}
.peer:hover { transform: translateY(-3px); border-color: var(--accent); }
.peer.dragover { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.03); }
.peer-name { font-weight: 650; font-size: 16px; word-break: break-word; }
.peer-type { font-size: 13px; color: var(--muted); }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }

.avatar {
  width: 64px; height: 64px; border-radius: 20px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.avatar svg { width: 32px; height: 32px; }
.avatar.big { width: 76px; height: 76px; border-radius: 24px; }
.avatar.big svg { width: 38px; height: 38px; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin: 18px 0 6px; font-size: 18px; }
.empty p { margin: 0 0 14px; }
.urls { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.urls code {
  font-family: ui-monospace, "Cascadia Code", Menlo, monospace; font-size: 15px;
  background: var(--surface); border: 1px solid var(--border); padding: 8px 14px; border-radius: 10px; color: var(--text);
}
.pulse { position: relative; display: inline-grid; place-items: center; width: 120px; height: 120px; }
.pulse img { border-radius: 12px; position: relative; z-index: 1; }
.pulse::before, .pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--accent); opacity: 0; animation: ring 2.4s ease-out infinite;
}
.pulse::after { animation-delay: 1.2s; }
@keyframes ring { 0% { transform: scale(.35); opacity: .6; } 100% { transform: scale(1); opacity: 0; } }

/* Dialogs */
dialog.sheet {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--border); border-radius: 22px; padding: 22px;
  background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(0,0,0,.3);
}
dialog.sheet[open] { animation: rise .2s ease; }
dialog::backdrop { background: rgba(10, 12, 25, .45); backdrop-filter: blur(3px); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@media (max-width: 520px) {
  dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 22px 22px 0 0; padding-bottom: max(22px, env(safe-area-inset-bottom)); }
}

.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h3 { font-size: 20px; }
.icon-btn { border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 50%; color: var(--muted); }

.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 30px 16px; border: 2px dashed var(--border); border-radius: 14px;
  color: var(--muted); text-align: center; cursor: pointer; word-break: break-word;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.dragover { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { color: var(--accent); }
.drop b { color: var(--accent); }
.drop.has-file { border-style: solid; border-color: var(--accent); color: var(--text); }

textarea {
  width: 100%; resize: vertical; min-height: 140px;
  padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 15px; line-height: 1.45;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.primary, .secondary {
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 650; font-size: 15px;
}
.primary { background: var(--accent); color: #fff; }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.secondary { background: var(--surface-2); }
.wide { width: 100%; margin-top: 16px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.error { color: var(--danger); font-size: 14px; margin: 12px 0 0; }

#progress-view { text-align: center; padding: 6px 0 0; }
.progress-icon { display: grid; place-items: center; margin: 4px auto 14px; }
.progress-text { font-weight: 650; font-size: 17px; margin: 0; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 18px 0 4px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid var(--surface-2); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.check { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 26px; font-weight: 700; }
.check.ok { background: var(--ok); }
.check.bad { background: var(--danger); }

.incoming-hero { text-align: center; padding: 8px 0 0; }
.incoming-hero .avatar { margin: 0 auto 14px; }
.incoming-hero h3 { font-size: 18px; line-height: 1.35; word-break: break-word; }

.received {
  margin: 0; max-height: 50vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 14px;
  font-family: inherit; font-size: 15px; line-height: 1.45;
}
.received a { color: var(--accent); }

.toasts {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 10; pointer-events: none;
  width: calc(100vw - 32px);
}
.toast {
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 550; box-shadow: var(--shadow); animation: rise .2s ease; max-width: 100%;
}
