:root {
  --wa-green: #00a884;
  --wa-green-dark: #008069;
  --ink: #41525d;
  --ink-strong: #111b21;
  --muted: #667781;
  --line: #e9edef;
  --canvas: #f0f2f5;
}

* { box-sizing: border-box; }

/* Author `display:` rules beat the UA's [hidden] rule, which silently un-hides
   every panel we toggle from JS (overlay, skeleton, success, phone form).
   This one line is load-bearing: without it the "Click to reload" overlay and
   the "Connecting…" panel are permanently visible on top of the QR. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.45 "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- top bar ---------- */
.topbar {
  background: var(--wa-green);
  color: #fff;
  box-shadow: 0 1px 3px rgb(11 20 26 / 20%);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 58px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 13px;
}

.glyph { width: 26px; height: 26px; fill: currentColor; }

.topnav { display: flex; gap: 22px; }
.topnav a {
  color: #ffffffdd;
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.topnav a:hover { color: #fff; }

/* ---------- card ---------- */
.stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 16px;
}

.card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 2px 8px rgb(11 20 26 / 12%);
  padding: 26px 34px 34px;
  text-align: center;
}

.tabs {
  display: flex;
  justify-content: center;
  gap: 26px;
  border-bottom: 1px solid var(--line);
  margin: -6px 0 24px;
}

.tab {
  background: none;
  border: 0;
  padding: 12px 2px;
  font: inherit;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.is-active {
  color: var(--wa-green-dark);
  border-bottom-color: var(--wa-green);
  font-weight: 600;
}

h1 {
  font-size: 22px;
  font-weight: 400;
  color: var(--ink-strong);
  margin: 0 0 18px;
}

.steps {
  text-align: left;
  margin: 0 auto 22px;
  padding-left: 22px;
  max-width: 420px;
  color: var(--ink);
  font-size: 15px;
}
.steps li { margin: 7px 0; }
.steps b { color: var(--ink-strong); font-weight: 600; }

/* ---------- QR ---------- */
.qr-frame {
  position: relative;
  width: 296px;
  height: 296px;
  margin: 0 auto 14px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  background: #f6f8f9;
  border: 1px solid var(--line);
  overflow: hidden;
}

.qr-img { width: 280px; height: 280px; display: block; }

.qr-skeleton {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.qr-overlay {
  position: absolute;
  inset: 0;
  background: rgb(255 255 255 / 92%);
  display: grid;
  place-items: center;
}

.reload {
  background: var(--wa-green-dark);
  color: #fff;
  border: 0;
  border-radius: 3px;
  padding: 14px 18px;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
}
.reload:hover { background: #017561; }

.meter {
  width: 296px;
  height: 3px;
  margin: 0 auto 14px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.meter-bar {
  height: 100%;
  width: 0%;
  background: var(--wa-green);
  transition: width 200ms linear;
}

.hint { color: var(--muted); font-size: 13px; margin: 0; }

/* ---------- pairing code ---------- */
.sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

.phone-form {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.cc, .number {
  font: inherit;
  padding: 11px 12px;
  border: 1px solid #d1d7db;
  border-radius: 3px;
  background: #fff;
  color: var(--ink-strong);
}
.cc { min-width: 190px; }
.number { flex: 1 1 180px; }

.next {
  font: inherit;
  font-size: 14px;
  padding: 11px 22px;
  border: 0;
  border-radius: 3px;
  background: var(--wa-green-dark);
  color: #fff;
  cursor: pointer;
}
.next:hover { background: #017561; }

.code-box { border-top: 1px solid var(--line); padding-top: 18px; }
.code-box p { margin: 0 0 12px; font-size: 14px; }

.code-value {
  font: 600 34px/1.2 "SF Mono", "Consolas", monospace;
  letter-spacing: 0.16em;
  color: var(--ink-strong);
  margin-bottom: 12px;
}

/* ---------- success ---------- */
.success {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 34px 0 12px;
}
.success p { margin: 0; }
.success .sub { margin-bottom: 0; }

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #d1d7db;
  border-top-color: var(--wa-green);
  border-radius: 50%;
  display: inline-block;
  animation: spin 900ms linear infinite;
}
.spinner.big { width: 38px; height: 38px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- footer ---------- */
.foot {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 16px;
  color: var(--muted);
  font-size: 12px;
}
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { text-decoration: underline; }

@media (max-width: 520px) {
  .card { padding: 22px 18px 28px; }
  .qr-frame { width: 240px; height: 240px; }
  .qr-img { width: 224px; height: 224px; }
  .meter { width: 240px; }
  h1 { font-size: 19px; }
}

/* secondary action (pairing-code recharge) */
.next.ghost {
  background: none;
  color: var(--wa-green-dark);
  border: 1px solid #d1d7db;
  font-size: 13px;
  padding: 8px 14px;
}
.next.ghost:hover { background: #f6f8f9; color: #017561; }
