:root {
  color-scheme: dark;
  --bg: #070b14;
  --surface: #111827;
  --surface-alt: #182235;
  --border: #26344d;
  --text: #f3f6fc;
  --muted: #98a6c0;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top, #0f172a 0%, var(--bg) 65%);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.muted { color: var(--muted); }

.web-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(17, 24, 39, 0.9);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #03101d;
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.brand-title { font-weight: 700; font-size: 1rem; }
.brand-sub { font-size: 0.78rem; color: var(--muted); }

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.host-locale-group {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
}

.locale-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.locale-btn.active {
  background: var(--accent-strong);
  color: #ffffff;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 0.84rem;
}

.session-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}

.restricted-tag {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 15px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--accent-strong);
  color: #ffffff;
}

.btn-primary:hover { background: #0369a1; }

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover { border-color: var(--accent); }

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.auth-stage {
  flex: 1;
  display: grid;
  place-items: center;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  text-align: center;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}

.pill-badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
  margin-bottom: 10px;
}

.auth-card h1 {
  margin: 4px 0 8px;
  font-size: 1.4rem;
}

.qr-frame {
  margin: 18px auto 12px;
  width: 244px;
  height: 244px;
  padding: 12px;
  background: #ffffff;
  border-radius: 14px;
  display: grid;
  place-items: center;
}

.qr-frame svg {
  width: 100%;
  height: 100%;
  display: block;
}

.qr-status {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}

.qr-status.status-warn { color: var(--warn); }
.qr-status.status-error { color: var(--danger); }
.qr-status.status-ok { color: var(--ok); }

.qr-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 14px;
}

.restriction-note {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
  text-align: start;
}

.launcher-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.launcher-head h2 { margin: 0 0 4px; font-size: 1.25rem; }
.launcher-head p { margin: 0; font-size: 0.88rem; }

.traffic-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-chip {
  font-size: 0.78rem;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.capsule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.capsule-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.capsule-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.capsule-name { font-weight: 700; font-size: 1.05rem; margin: 0 0 4px; }
.capsule-desc { margin: 0; font-size: 0.84rem; color: var(--muted); line-height: 1.4; }

.mode-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.14);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
  white-space: nowrap;
}

.mode-badge.partial {
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.35);
}

.parts-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.part-chip {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--border);
}

.empty-state {
  padding: 36px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}

.runner-stage {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 10px;
}

.runner-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
}

.runner-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.parts-note { font-size: 0.78rem; color: var(--muted); }

.sandbox-frame-wrap {
  flex: 1;
  min-height: 68vh;
  background: #000000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
}

.capsule-iframe {
  width: 100%;
  min-height: 68vh;
  border: 0;
  background: #0b0f19;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-alt);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 50;
  font-size: 0.88rem;
}
