:root {
  --bg: #F4F5F7;
  --card: #FFFFFF;
  --line: #E4E7EC;
  --text: #162136;
  --muted: #6B7385;
  --accent: #1560E8;
  --accent-soft: #EAF1FE;
  --good: #15803D;
  --good-soft: #DDF3E3;
  --bad: #C0362C;
  --bad-soft: #FDF1EF;
  --track: #E6E8EE;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0 auto; max-width: 760px; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(18px + env(safe-area-inset-top)) 2px 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.pill { background: var(--good-soft); color: var(--good); border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.pill.wait { background: #EEF0F4; color: var(--muted); }
.pill.off { background: var(--bad-soft); color: var(--bad); }

.banner { background: var(--bad-soft); color: var(--bad); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px;
  box-shadow: 0 1px 3px rgba(22, 33, 54, .05); margin-bottom: 14px;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
h2 { font-size: 19px; margin: 0; }
.muted { color: var(--muted); margin: 0 0 12px; }
.small { font-size: 13.5px; }
.or { margin-top: 18px; }
.empty { color: var(--muted); margin: 6px 0 0; }
.status { min-height: 22px; margin: 10px 0 0; color: var(--muted); font-size: 14.5px; }
.status.bad { color: var(--bad); font-weight: 600; }
.status.good { color: var(--good); font-weight: 600; }

.link { background: none; border: 0; color: var(--accent); font-weight: 650; cursor: pointer; padding: 6px 2px; }
.link.danger { color: var(--bad); }
.btn {
  display: block; width: 100%; background: var(--accent); color: #fff; border: 0; border-radius: 12px;
  padding: 14px; font-weight: 700; cursor: pointer; margin-top: 12px;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn2 {
  border: 1.5px solid var(--accent); color: var(--accent); background: #fff; border-radius: 10px;
  padding: 9px 14px; font-weight: 650; font-size: 15px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-block;
}
.btn2.quiet { border-color: var(--line); color: var(--text); }
.btn2:disabled { opacity: .45; cursor: default; }

input[type=text], textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; outline: none; font-size: 16px;
}
input[type=text]:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 76px; resize: vertical; margin-top: 12px; }
select { width: auto; max-width: 60%; padding: 7px 10px; }
.namefield { display: block; margin-top: 16px; color: var(--muted); font-size: 14px; }
.namefield input { margin-top: 4px; }
.linkrow { display: flex; gap: 8px; align-items: center; }
.linkrow input { min-width: 0; flex: 1; font-size: 14px; }

/* Devices */
.devices { list-style: none; margin: 0; padding: 0; }
.devices li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.devices li:first-child { border-top: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #D9E7FD; color: var(--accent); display: grid; place-items: center; font-weight: 650; flex-shrink: 0; }
.dname { flex: 1; min-width: 0; font-weight: 550; overflow-wrap: anywhere; }
.dstate { color: var(--muted); font-size: 14px; text-align: right; }
.dstate.on { color: var(--good); font-weight: 650; }

/* Pairing */
.qr { display: grid; place-items: center; padding: 6px 0 14px; }
.qr svg { width: 230px; height: 230px; display: block; }

/* Send */
.drop {
  border: 2px dashed #8FB4F3; border-radius: 14px; padding: 26px 14px; text-align: center; cursor: pointer;
  display: grid; gap: 2px; outline: none; transition: background .15s, border-color .15s;
}
.drop strong { color: var(--accent); font-size: 20px; }
.drop span { color: var(--muted); font-size: 14.5px; }
.drop:hover, .drop.over, .drop:focus-visible { background: var(--accent-soft); border-color: var(--accent); }
.disabled .drop, .disabled textarea, .disabled .btn { opacity: .45; pointer-events: none; }

/* Lists */
.list { list-style: none; margin: 10px 0 0; padding: 0; }
.list li { padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.line { overflow-wrap: anywhere; }
.line b { font-weight: 650; }
.sub { color: var(--muted); font-size: 14px; }
.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; margin: 9px 0 8px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .25s linear; }
li.done .bar i { background: var(--good); }
li.failed .bar i { background: var(--bad); }
.foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ok { color: var(--good); font-weight: 650; }
.err { color: var(--bad); font-weight: 600; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.note { white-space: pre-wrap; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }
.note a { color: var(--accent); }

footer { color: var(--muted); font-size: 13.5px; padding: 6px 4px 0; }
footer p { margin: 0 0 8px; }
