:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #e8efff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b22;
    --text: #e8eaf0;
    --muted: #9aa3b2;
    --line: #2a2f3a;
    --accent: #4f8cff;
    --accent-soft: #1d2a45;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
h1 { font-size: 24px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0 0 8px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
main { max-width: 760px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid2 .card { margin-bottom: 0; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.field > span { font-size: 13px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; margin: 0; }

input, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.code-input { flex: 1; text-transform: uppercase; letter-spacing: 4px; font-weight: 600; font-family: ui-monospace, Consolas, monospace; }

button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent; padding: 10px 16px; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.secondary { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ghost { background: transparent; color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.ghost:hover { background: var(--bg); }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
.danger-link { background: none; color: var(--danger); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.on { background: var(--ok); }

.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px 16px;
  text-align: center; transition: background .15s, border-color .15s;
}
.drop p { margin: 0 0 10px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }

.picked { list-style: none; margin: 12px 0 0; padding: 0; }
.picked li, .t-files li {
  display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line);
}
.picked li:last-child, .t-files li:last-child { border-bottom: 0; }
.fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsize { color: var(--muted); font-size: 13px; white-space: nowrap; }
.picked .rm { background: none; border: 0; color: var(--muted); padding: 2px 6px; }

.send-bar { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.send-bar select { max-width: 60vw; }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.ptext { margin: 6px 0 0; }

.notice { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.section-title { margin: 22px 4px 10px; display: flex; align-items: center; gap: 8px; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 99px; font-size: 12px; padding: 1px 8px; }
.badge:empty { display: none; }

.transfer .t-title { font-weight: 600; }
.transfer.incoming { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pop .25s ease-out; }
.t-files { list-style: none; margin: 10px 0; padding: 0; }
.t-actions { margin-top: 6px; }
.t-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
@keyframes pop { from { transform: scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

.status { font-size: 13px; white-space: nowrap; }
.status.pending { color: var(--warn); }
.status.received { color: var(--ok); }
.status.declined { color: var(--danger); }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text);
  width: min(440px, calc(100vw - 32px)); padding: 18px;
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.dlg-head h2 { margin: 0; }
.close { padding: 4px 10px; }
.dlg-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.devices { list-style: none; padding: 0; margin: 0; }
.devices li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.devices .me { color: var(--muted); font-size: 13px; }
.devices .rm { margin-left: auto; background: none; color: var(--danger); padding: 4px 8px; }

.pair-code {
  font: 700 38px/1.2 ui-monospace, Consolas, monospace; letter-spacing: 8px; text-align: center;
  margin: 14px 0 10px; user-select: all;
}
.qr { display: block; width: 200px; height: 200px; margin: 0 auto; background: #fff; border-radius: 10px; padding: 6px; }

.toasts { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: pop .2s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
