/* HK WhatsApp Hub — glass HUD floating over the live 3D scene. Dark by design. */
:root {
  --bg: #08090b;
  --ink: #f2f3f5;
  --muted: #9a9fa8;
  --line: rgba(255, 255, 255, .09);
  --glass: rgba(20, 21, 24, .66);
  --glass-strong: rgba(16, 17, 20, .9);
  --ok: #3ecf8e;
  --link: #f2b04a;
  --busy: #5aa9f0;
  --down: #f0605a;
  --tone: var(--ok);
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --serif: "Instrument Serif", Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }
em { font-family: var(--serif); font-style: italic; font-weight: 400; }
.muted { color: var(--muted); }
.error { color: var(--down); min-height: 1.4em; font-size: .9rem; margin: 6px 0; }
.eyebrow { font: 500 .66rem/1 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }

/* ---------- the stage ---------- */
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
body.no3d #scene { display: none; }
body.no3d { background: radial-gradient(900px 600px at 50% 20%, #1a1c20, var(--bg) 70%); overflow: auto; }
.vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 42%, transparent 50%, rgba(0, 0, 0, .5) 100%); }
body.signed-out #scene { filter: blur(6px) brightness(.6); }
body.signed-out .tags { display: none; }

.glass {
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px;
  -webkit-backdrop-filter: blur(22px) saturate(120%); backdrop-filter: blur(22px) saturate(120%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .4), 0 20px 48px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .06);
}

/* ---------- floating name tags (positioned by the scene) ---------- */
.tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; white-space: nowrap; will-change: transform;
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px; border-radius: 999px;
  background: var(--glass-strong); border: 1px solid var(--line); color: var(--ink);
  font: 500 .8rem/1.2 var(--sans); box-shadow: 0 8px 22px rgba(0, 0, 0, .4);
  transition: box-shadow .2s, border-color .2s, background .2s, opacity .25s;
}
.tag[data-tone="ok"] { --tone: var(--ok); } .tag[data-tone="link"] { --tone: var(--link); }
.tag[data-tone="busy"] { --tone: var(--busy); } .tag[data-tone="down"] { --tone: var(--down); }
.tag i { width: 7px; height: 7px; border-radius: 50%; background: var(--tone); }
.tag b { font-weight: 600; }
.tag span { font: 500 .64rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tag.hover, .tag.on, .tag:hover { border-color: rgba(255, 255, 255, .28); background: rgba(34, 36, 40, .94); }
.tag.add { border-style: dashed; color: var(--muted); }
/* a phone is open: its panel carries the name, so the floating tags step aside */
.tags.focus .tag { opacity: 0; pointer-events: none; }

/* ---------- controls ---------- */
.btn {
  font: 600 .9rem/1 var(--sans); color: var(--ink); background: rgba(255, 255, 255, .05); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 16px; min-height: 44px; cursor: pointer; transition: transform .08s, background .15s, box-shadow .2s, border-color .15s;
}
.btn:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .22); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: #f2f3f5; border-color: transparent; color: #0b0c0e; }
.btn.primary:hover { background: #fff; }
.btn.small { min-height: 38px; padding: 0 13px; font-size: .86rem; }
.btn.wide { width: 100%; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 9px; min-width: 34px; min-height: 34px; font-size: .95rem; }
.icon-btn:hover { background: rgba(255, 255, 255, .08); color: var(--ink); }
:focus-visible { outline: 2px solid #f2f3f5; outline-offset: 2px; }
label { display: block; font: 500 .7rem/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
input {
  font: 500 1rem/1 var(--sans); width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; color: var(--ink);
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line);
}
input:focus { border-color: rgba(255, 255, 255, .5); outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, .1); }

/* ---------- sign in ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(390px, 100%); padding: 34px 28px 28px; text-align: center; border-radius: 26px; }
.login-card label { text-align: left; }
.login-card h1 { font-size: 2.3rem; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; margin: 8px 0 6px; }
.login-mark { border-radius: 16px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); margin-bottom: 14px; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.hud > * { pointer-events: auto; }
.top { display: flex; align-items: center; gap: 12px; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 9px 16px 9px 10px; }
.brand img { border-radius: 11px; }
.brand h1 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.summary { display: flex; align-items: center; gap: 10px; padding: 0 16px; min-height: 44px; font: 500 .8rem/1 var(--mono); letter-spacing: .04em; margin-inline: auto; white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: beat 2.2s ease-in-out infinite; }
.summary.warn .live-dot { background: var(--link); }
.summary.bad .live-dot { background: var(--down); }
@keyframes beat { 50% { opacity: .35; } }
.top-actions { display: flex; gap: 8px; }
.attention { position: absolute; left: 50%; top: calc(max(14px, env(safe-area-inset-top)) + 62px); transform: translateX(-50%); padding: 9px 16px; font-size: .86rem; max-width: min(640px, calc(100% - 28px)); text-align: center;
  color: var(--muted); }
.attention strong { color: var(--link); font-weight: 600; }

/* ---------- selected account panel ---------- */
.panel { position: absolute; right: max(14px, env(safe-area-inset-right)); top: calc(max(14px, env(safe-area-inset-top)) + 70px); width: min(372px, calc(100% - 28px));
  max-height: calc(100% - 190px); overflow: auto; padding: 22px; border-radius: 22px; background: var(--glass-strong);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .4), 0 28px 70px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .06); animation: slide .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes slide { from { opacity: 0; transform: translateX(24px); } }
.panel.ok { --tone: var(--ok); } .panel.link { --tone: var(--link); } .panel.busy { --tone: var(--busy); } .panel.down { --tone: var(--down); }
.close { position: absolute; top: 10px; right: 10px; }
.panel-head { display: flex; align-items: center; gap: 13px; padding-right: 30px; }
.avatar { flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font: 600 1rem/1 var(--sans); color: var(--ink);
  background: linear-gradient(160deg, #3a3d43, #1d1f23); box-shadow: 0 0 0 2px var(--glass-strong), 0 0 0 3.5px var(--tone); }
.who { min-width: 0; flex: 1; }
.name-row { display: flex; align-items: center; gap: 4px; }
.name { font-size: 1.2rem; font-weight: 600; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { color: var(--muted); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 9px; margin-top: 16px; padding: 7px 14px 7px 11px; border-radius: 999px; color: var(--tone);
  background: color-mix(in srgb, var(--tone) 11%, transparent); border: 1px solid color-mix(in srgb, var(--tone) 28%, transparent); font: 600 .72rem/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: beat 2.2s ease-in-out infinite; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.fact { background: rgba(0, 0, 0, .28); border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; }
.fact span { display: block; font: 500 .62rem/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.fact b { display: block; margin-top: 6px; font: 600 1.05rem/1.1 var(--sans); }
.hint { margin-top: 14px; font-size: .9rem; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* link box */
.linkbox { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); }
.tab { font: 600 .86rem/1 var(--sans); min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.tab[aria-selected="true"] { background: rgba(255, 255, 255, .1); color: var(--ink); }
.steps { margin: 12px 0 0; padding-left: 20px; color: var(--muted); font-size: .88rem; }
.steps li + li { margin-top: 3px; }
.qr { display: grid; place-items: center; margin-top: 12px; padding: 12px; min-height: 220px; border-radius: 16px; background: #fff; }
.qr img { width: min(250px, 100%); height: auto; display: block; }
.qr p { color: #456; text-align: center; padding: 18px; }
.code { margin-top: 14px; padding: 18px 10px; text-align: center; border-radius: 16px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); }
.code-value { font: 600 2rem/1.1 var(--mono); letter-spacing: .14em; user-select: all; }
.code-note { font-size: .82rem; color: var(--muted); margin-top: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 20px; }
.row input { flex: 1; min-width: 0; }
.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; display: inline-block; vertical-align: -3px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { color: var(--busy); margin-top: 10px; }

/* ---------- roster ---------- */
.roster-wrap { position: absolute; left: 0; right: 0; bottom: max(12px, env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.roster { display: flex; gap: 8px; max-width: calc(100% - 28px); overflow-x: auto; padding: 6px; pointer-events: auto; scrollbar-width: none; }
.roster::-webkit-scrollbar { display: none; }
.chip { --tone: var(--ok); flex: none; display: flex; align-items: center; gap: 9px; min-height: 46px; padding: 0 15px 0 12px; border-radius: 14px; cursor: pointer; color: var(--ink);
  background: var(--glass); border: 1px solid var(--line); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); font: 600 .88rem/1.2 var(--sans); text-align: left; transition: border-color .2s, box-shadow .2s, transform .1s; }
.chip.ok { --tone: var(--ok); } .chip.link { --tone: var(--link); } .chip.busy { --tone: var(--busy); } .chip.down { --tone: var(--down); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--tone); flex: none; }
.chip small { display: block; font: 500 .62rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.chip:hover { border-color: rgba(255, 255, 255, .24); }
.chip.on { border-color: rgba(255, 255, 255, .5); background: rgba(40, 42, 47, .92); }
.chip:active { transform: scale(.97); }
.updated { font: 500 .64rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); opacity: .8; }
.help { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); font: 500 .64rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); opacity: .7; pointer-events: none; }
body.no3d .help { display: none; }

/* ---------- dialog, toast ---------- */
dialog { color: var(--ink); width: min(440px, calc(100% - 28px)); padding: 26px; border-radius: 24px; background: var(--glass-strong); }
dialog::backdrop { background: rgba(0, 0, 0, .6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; margin: 8px 0 6px; }
.toast { position: fixed; left: 50%; top: max(84px, env(safe-area-inset-top)); transform: translateX(-50%); padding: 12px 18px; z-index: 30; font-weight: 500; max-width: calc(100% - 28px); }

@media (prefers-reduced-motion: reduce) { .dot, .live-dot, .spinner, .panel { animation: none !important; } }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  .top { flex-wrap: wrap; }
  .brand { padding: 7px 12px 7px 8px; }
  .brand img { width: 32px; height: 32px; }
  .brand h1 { font-size: 1.05rem; }
  .brand .eyebrow { display: none; }
  .summary { order: 3; width: 100%; justify-content: center; margin: 0; min-height: 38px; }
  .top-actions { margin-left: auto; }
  .top-actions .btn { padding: 0 12px; font-size: .84rem; min-height: 42px; }
  .attention { display: none; }
  .help { display: none; }
  /* the panel becomes a bottom sheet above the roster */
  .panel { left: 10px; right: 10px; top: auto; bottom: 86px; width: auto; max-height: 58%; border-radius: 22px; animation-name: rise; }
  @keyframes rise { from { opacity: 0; transform: translateY(24px); } }
  /* small screens: the roster and the phone screens carry the names */
  .tags .tag:not(.add) { display: none !important; }
}
