@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Sora:wght@400;500;600;700&display=swap');

:root {
  --bg: #07140f;
  --bg-elev: #0c1f17;
  --bg-soft: #122a20;
  --line: rgba(110, 231, 183, 0.14);
  --text: #e8f5ef;
  --muted: #8fad9d;
  --accent: #25d366;
  --accent-2: #6ee7b7;
  --warn: #f5c542;
  --danger: #ff6b6b;
  --ok: #25d366;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --font: 'Sora', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(37, 211, 102, 0.18), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(110, 231, 183, 0.08), transparent 45%),
    linear-gradient(180deg, #06110d 0%, #07140f 40%, #0a1a13 100%);
  background-attachment: fixed;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.15rem;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #25d366, #128c7e);
  display: grid;
  place-items: center;
  box-shadow: 0 0 24px rgba(37, 211, 102, 0.35);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: #04110b;
}

.nav-links {
  display: flex;
  gap: 1rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.nav-links a { color: var(--muted); }
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--accent);
  color: #04110b;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(37, 211, 102, 0.25); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost:hover { border-color: var(--accent-2); box-shadow: none; }

.btn-danger {
  background: transparent;
  border-color: rgba(255, 107, 107, 0.35);
  color: var(--danger);
}

.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.8rem; }

.panel {
  background: linear-gradient(180deg, rgba(18, 42, 32, 0.85), rgba(12, 31, 23, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: min(420px, 100%);
  padding: 2rem;
  animation: rise 0.55s ease both;
}

.auth-card h1 {
  font-size: 1.65rem;
  letter-spacing: -0.04em;
  margin: 0.75rem 0 0.35rem;
}

.auth-card .sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field input, .field textarea {
  width: 100%;
  background: rgba(7, 20, 15, 0.7);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.75rem 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.field input:focus, .field textarea:focus {
  border-color: rgba(37, 211, 102, 0.55);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.35rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-weight: 600;
  padding: 0.55rem;
  border-radius: 999px;
  cursor: pointer;
}

.tab.active {
  background: rgba(37, 211, 102, 0.18);
  color: var(--accent-2);
}

.alert {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  font-size: 0.88rem;
  margin-bottom: 1rem;
  display: none;
}

.alert.show { display: block; }
.alert.error {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ffb4b4;
}
.alert.ok {
  background: rgba(37, 211, 102, 0.12);
  border: 1px solid rgba(37, 211, 102, 0.3);
  color: #9af0bd;
}

.hero-strip {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.5rem;
  animation: rise 0.45s ease both;
}

.hero-strip h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.04em;
}

.hero-strip p {
  color: var(--muted);
  margin-top: 0.35rem;
  font-size: 0.95rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat {
  padding: 1.1rem 1.2rem;
  animation: rise 0.5s ease both;
}

.stat:nth-child(2) { animation-delay: 0.06s; }
.stat:nth-child(3) { animation-delay: 0.12s; }

.stat .label {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat .value {
  font-size: 1.7rem;
  font-weight: 700;
  margin-top: 0.35rem;
  letter-spacing: -0.03em;
}

.session-card {
  padding: 1.2rem 1.3rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  animation: rise 0.45s ease both;
}

.session-meta h3 {
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.session-meta .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-family: var(--mono);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.connected { color: var(--ok); background: rgba(37,211,102,0.1); }
.badge.qr, .badge.connecting, .badge.pending { color: var(--warn); background: rgba(245,197,66,0.1); }
.badge.disconnected, .badge.logged_out { color: var(--danger); background: rgba(255,107,107,0.1); }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: end; }

.api-box {
  padding: 1.2rem 1.3rem;
  margin-bottom: 1.5rem;
}

.api-box .key-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.75rem;
}

.api-box code {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.82rem;
  background: rgba(0,0,0,0.3);
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  overflow: auto;
  white-space: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 5, 0.72);
  display: none;
  place-items: center;
  z-index: 50;
  padding: 1rem;
}

.modal-backdrop.show { display: grid; }

.modal {
  width: min(420px, 100%);
  padding: 1.5rem;
  text-align: center;
  animation: rise 0.3s ease both;
}

.modal h2 { margin-bottom: 0.4rem; letter-spacing: -0.03em; }
.modal p { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }

.qr-frame {
  width: 280px;
  height: 280px;
  margin: 0 auto 1rem;
  border-radius: 16px;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.qr-frame img { width: 100%; height: 100%; object-fit: contain; }

.empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.docs-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  padding-bottom: 3rem;
}

.docs-nav {
  position: sticky;
  top: 1rem;
  align-self: start;
  padding: 1rem;
}

.docs-nav a {
  display: block;
  color: var(--muted);
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  font-size: 0.88rem;
  text-decoration: none;
}

.docs-nav a:hover { background: rgba(37,211,102,0.08); color: var(--text); }

.docs-content section {
  padding: 1.4rem 1.5rem;
  margin-bottom: 1rem;
  scroll-margin-top: 1rem;
}

.docs-content h2 {
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  margin-bottom: 0.6rem;
}

.docs-content p, .docs-content li {
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.94rem;
}

.docs-content ul { padding-left: 1.1rem; margin: 0.6rem 0 1rem; }

.docs-content pre {
  background: #040d09;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.55;
  color: #c8ead8;
  margin: 0.8rem 0;
}

.docs-content code {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--accent-2);
}

.method {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  margin-right: 0.4rem;
  font-weight: 600;
}

.method.get { background: rgba(110,231,183,0.15); color: var(--accent-2); }
.method.post { background: rgba(37,211,102,0.2); color: var(--accent); }
.method.put { background: rgba(245,197,66,0.15); color: var(--warn); }
.method.delete { background: rgba(255,107,107,0.15); color: var(--danger); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 800px) {
  .stats { grid-template-columns: 1fr; }
  .session-card { grid-template-columns: 1fr; }
  .actions { justify-content: start; }
  .docs-layout { grid-template-columns: 1fr; }
  .docs-nav { position: static; display: flex; flex-wrap: wrap; gap: 0.25rem; }
}
