:root {
  --bg: #04060d;
  --panel: rgba(13, 20, 36, 0.72);
  --panel-border: rgba(120, 160, 255, 0.14);
  --text: #e6edf7;
  --muted: #8b98ad;
  --accent: #22d3ee;
  --accent-2: #8b5cf6;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Top bar ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  z-index: 10;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 12px currentColor;
  transition: background .4s;
}
.brand-dot.ok { background: var(--ok); }
.brand-dot.down { background: var(--err); }
.brand-name { font-weight: 600; letter-spacing: .3px; font-size: 15px; }
.accent {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.icon-btn {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: 11px;
  font-size: 17px;
  cursor: pointer;
  backdrop-filter: blur(10px);
}
.icon-btn:active { transform: scale(.95); }

/* ---------- Panels ---------- */
.panel {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 16px;
  z-index: 9;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  background: rgba(34, 211, 238, .16);
  color: var(--accent);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 12px;
  letter-spacing: 0;
}

/* Left: accounts */
.panel-accounts {
  top: 66px; left: 18px;
  width: 300px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}

/* Right: wizard */
.panel-wizard {
  top: 66px; right: 18px;
  width: 360px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}

.account-list { display: flex; flex-direction: column; gap: 9px; }

.account-card {
  border: 1px solid rgba(120, 160, 255, .12);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, .025);
}
.account-card .row1 {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 3px;
}
.account-card .aid { font-weight: 600; font-size: 13.5px; color: var(--accent); }
.account-card .email { font-size: 12.5px; word-break: break-all; color: var(--text); }
.account-card .meta { font-size: 11px; color: var(--muted); margin-top: 5px; }

.status-pill {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .8px;
}
.status-pill.authorized { background: rgba(52, 211, 153, .16); color: var(--ok); }
.status-pill.pending { background: rgba(251, 191, 36, .16); color: var(--warn); }
.status-pill.other { background: rgba(248, 113, 113, .16); color: var(--err); }

/* ---------- Wizard ---------- */
.wizard-step { display: flex; flex-direction: column; gap: 11px; }
.hidden { display: none !important; }

.muted { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 0; }
.steps { padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }
.steps code, .muted code {
  background: rgba(139, 92, 246, .14);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12px;
}

.link-box { display: flex; gap: 8px; }
.link-box input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, .35);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 12px;
}

.field-label { font-size: 12px; color: var(--muted); }

textarea, .gate-card input {
  width: 100%;
  background: rgba(0, 0, 0, .35);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 9px;
  padding: 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
textarea:focus, .gate-card input:focus, .link-box input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #041018;
}
.btn.ghost {
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  border: 1px solid var(--panel-border);
}
.btn.small { padding: 8px 12px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: wait; }

.row { display: flex; gap: 9px; }
.row .btn { flex: 1; }

.error { color: var(--err); font-size: 12.5px; margin: 0; }
.success { color: var(--ok); font-size: 14.5px; font-weight: 600; margin: 0; }

/* ---------- Gate ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 13, .82);
  backdrop-filter: blur(6px);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.gate-card h2 { margin: 0; font-size: 17px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 20, 36, .95);
  border: 1px solid var(--panel-border);
  border-radius: 11px;
  padding: 12px 18px;
  font-size: 13.5px;
  z-index: 30;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  max-width: 90vw;
}
.toast.ok { border-color: rgba(52, 211, 153, .45); }
.toast.err { border-color: rgba(248, 113, 113, .45); }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  body { overflow-y: auto; }
  .panel {
    position: relative;
    inset: auto;
    width: auto;
    margin: 0 14px 14px;
    max-height: none;
  }
  .panel-accounts { margin-top: 56px; }
  .topbar { position: sticky; background: linear-gradient(180deg, rgba(4,6,13,.9), transparent); }
  #scene { position: fixed; opacity: .5; }
  .app-flow { position: relative; z-index: 5; }
}
