:root {
  --bg: #000;
  --surface: #0c0c0c;
  --surface2: #151515;
  --surface3: #1c1c1c;
  --line: #212121;
  --line2: #303030;
  --text: #f5f5f5;
  --muted: #8d8d8d;
  --muted2: #5d5d5d;
  --white: #fff;
  --danger: #d6d6d6;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(0,0,0,.5);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  font-size: 15px; line-height: 1.5; overflow: hidden; user-select: none;
  -webkit-font-smoothing: antialiased;
}
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app {
  max-width: 480px; height: 100%; margin: 0 auto; display: flex; flex-direction: column;
  background: radial-gradient(1100px 380px at 50% -12%, #191919 0%, #000 62%);
}
header {
  padding: calc(14px + env(safe-area-inset-top)) 18px 13px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; }
.logo {
  width: 36px; height: 36px; border-radius: 11px; flex: 0 0 auto;
  border: 1px solid var(--line2); display: grid; place-items: center;
  background: linear-gradient(150deg, #202020, #050505);
  font-weight: 800; font-size: 16px; color: var(--white); letter-spacing: -.5px;
}
.logo.xl { width: 68px; height: 68px; border-radius: 20px; font-size: 30px; margin: 0 auto 18px; }
.brand h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: -.3px; }
.brand p { margin: 0; font-size: 10px; color: var(--muted2); letter-spacing: .6px; text-transform: uppercase; }
.headright { display: flex; align-items: center; gap: 8px; }
.iconbtn {
  width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line2);
  background: var(--surface2); color: var(--text); display: grid; place-items: center; cursor: pointer;
}
.avatarbtn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line2);
  background: var(--white); color: #000; font-weight: 800; cursor: pointer; font-size: 14px;
}
.status {
  font-size: 11px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line2);
  color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.status:not(.on):not(.pair) { display: none; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted2); }
.status.on { color: #fff; border-color: #3b3b3b; }
.status.on .dot { background: #fff; box-shadow: 0 0 8px #fff; }
.status.pair .dot { background: #bbb; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

main { flex: 1; overflow-y: auto; padding: 18px 18px 128px; -webkit-overflow-scrolling: touch; }
main::-webkit-scrollbar { width: 0; }
.hidden { display: none !important; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.cardhead { font-size: 13px; margin: 0 0 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .9px; font-weight: 700; }
.sechead { font-size: 12px; color: var(--muted2); text-transform: uppercase; letter-spacing: 1px; margin: 22px 4px 12px; }

.field { margin-bottom: 12px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 6px; font-weight: 500; }
input, textarea, select {
  width: 100%; background: var(--surface2); border: 1px solid var(--line2); color: var(--text);
  border-radius: 13px; padding: 13px 14px; font-size: 16px; outline: none; font-family: inherit;
  transition: border-color .18s, background .18s;
}
input:focus, textarea:focus, select:focus { border-color: #4d4d4d; background: var(--surface3); }
textarea { resize: vertical; min-height: 118px; font-family: ui-monospace, monospace; font-size: 13px; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }

.btn {
  width: 100%; border: none; border-radius: 14px; padding: 15px; font-size: 15px; font-weight: 700;
  background: var(--white); color: #000; cursor: pointer; transition: transform .07s, opacity .15s;
  letter-spacing: .2px;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--line2); font-weight: 600; }
.btn.danger { background: transparent; border: 1px solid #3a3a3a; color: var(--danger); }
.btn.sq { width: 50px; flex: 0 0 auto; padding: 0; font-size: 22px; }
.addrow { display: flex; gap: 9px; margin-bottom: 10px; } .addrow input { flex: 1; }

.pw { position: relative; }
.pw button {
  position: absolute; right: 6px; top: 6px; bottom: 6px; width: 40px; border: none;
  background: transparent; color: var(--muted); font-size: 15px; cursor: pointer; border-radius: 9px;
}

.seg { display: flex; background: var(--surface2); border: 1px solid var(--line2); border-radius: 13px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { flex: 1; border: none; background: transparent; color: var(--muted); padding: 10px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; transition: .15s; }
.seg button.active { background: var(--white); color: #000; }
.seg.sm { margin-bottom: 12px; }
.seg.sm button { padding: 8px; font-size: 12px; }

.chips, .presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.chip, .presets button {
  border: 1px solid var(--line2); background: var(--surface2); color: var(--text);
  padding: 9px 14px; border-radius: 11px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--white); color: #000; border-color: var(--white); }
.presets button { font-size: 12px; padding: 7px 12px; color: var(--muted); }

.greetcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.greet { font-size: 23px; font-weight: 800; letter-spacing: -.6px; }
.clock { font-family: ui-monospace, monospace; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.greetmeta { font-size: 12px; color: var(--muted2); margin-top: 10px; }

.livegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.live { display: flex; align-items: center; gap: 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 13px; }
.live b { display: block; font-size: 16px; font-weight: 800; }
.live small { font-size: 10.5px; color: var(--muted2); text-transform: uppercase; letter-spacing: .5px; }
.livedot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted2); flex: 0 0 auto; }
.livedot.on { background: #fff; box-shadow: 0 0 8px #fff; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick button {
  background: var(--surface); border: 1px solid var(--line); border-radius: 15px; color: var(--text);
  padding: 16px 15px; text-align: left; cursor: pointer; transition: background .15s, border-color .15s;
}
.quick button:active { background: var(--surface3); border-color: var(--line2); }
.quick .qt { font-size: 18px; font-weight: 800; display: block; margin-bottom: 3px; letter-spacing: -.4px; }
.quick small { color: var(--muted2); font-weight: 500; font-size: 11.5px; }

.paircode { font-family: ui-monospace, monospace; font-size: 36px; font-weight: 800; letter-spacing: 7px; color: var(--white); margin: 8px 0 12px; }
.copybtn { background: var(--surface2); border: 1px solid var(--line2); color: var(--text); border-radius: 10px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.spinner { width: 26px; height: 26px; border: 2.5px solid var(--line2); border-top-color: #fff; border-radius: 50%; margin: 16px auto 0; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.targetlist { display: flex; flex-direction: column; gap: 8px; max-height: 230px; overflow-y: auto; margin: 10px 0; }
.targetlist::-webkit-scrollbar { width: 4px; }
.targetlist::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 2px; }
.tg { display: flex; align-items: center; gap: 10px; padding: 11px 12px; background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: .12s; }
.tg.sel { border-color: #565656; background: var(--surface3); }
.tg .chk { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line2); display: grid; place-items: center; font-size: 11px; color: #000; flex: 0 0 auto; }
.tg.sel .chk { background: #fff; border-color: #fff; }
.tg .nm { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg .sz { font-size: 11px; color: var(--muted2); }
.targetfoot { display: flex; align-items: center; justify-content: space-between; }
.linkbtn { background: transparent; border: none; color: var(--muted); font-size: 12px; cursor: pointer; }

.stats { display: flex; gap: 8px; margin-bottom: 10px; text-align: center; }
.stat { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.stat b { display: block; font-size: 17px; font-weight: 800; }
.stat span { font-size: 10px; color: var(--muted2); text-transform: uppercase; letter-spacing: .5px; }
.footer { padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to top, #000 62%, transparent); border-top: 1px solid var(--line); }

.log { font-family: ui-monospace, monospace; font-size: 12px; background: var(--surface2); border: 1px solid var(--line); border-radius: 11px; padding: 12px; white-space: pre-wrap; max-height: 220px; overflow-y: auto; color: #bdbdbd; margin: 0; }

.userrow { display: flex; align-items: center; justify-content: space-between; padding: 12px; background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.userrow .u { font-weight: 700; font-size: 14px; }
.badge { font-size: 10px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line2); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.badge.owner { color: #000; background: #fff; border-color: #fff; }
.rm { background: transparent; border: 1px solid var(--line2); color: var(--muted); border-radius: 9px; padding: 7px 12px; cursor: pointer; font-size: 12px; }

.auth { display: flex; flex-direction: column; justify-content: center; min-height: 100%; padding: 8px 4px; }
.hero { text-align: center; margin-bottom: 26px; }
.hero h1 { font-size: 25px; margin: 0; letter-spacing: -.6px; }
.hero p { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.center { text-align: center; }
.note { font-size: 11.5px; color: var(--muted2); margin-top: 10px; line-height: 1.5; }

.avatarXL { width: 70px; height: 70px; border-radius: 50%; background: #fff; color: #000; font-size: 28px; font-weight: 800; display: grid; place-items: center; margin: 4px auto 14px; }
.profname { margin: 0 0 8px; font-size: 20px; letter-spacing: -.4px; }

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px);
  background: #fff; color: #000; padding: 11px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; z-index: 99;
  max-width: 82vw; text-align: center; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.fade { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
