:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: rgba(17, 24, 39, 0.9);
  --panel-strong: #111827;
  --panel-soft: #182235;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --border: rgba(148, 163, 184, 0.18);
  --accent: #7c3aed;
  --accent-strong: #8b5cf6;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(124, 58, 237, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.18), transparent 24%),
    linear-gradient(180deg, #09101d 0%, #0b1020 100%);
  color: var(--text);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.topbar,
.status-strip,
.future-box,
.channel-card,
.modal {
  backdrop-filter: blur(18px);
}

.topbar {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 24px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c4b5fd;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.05;
}

.subtitle {
  max-width: 680px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.token-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(10, 16, 29, 0.55);
  border: 1px solid var(--border);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text);
  outline: none;
}

.field input:focus {
  border-color: rgba(139, 92, 246, 0.8);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.16);
}

.token-actions,
.card-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.9);
}

.btn-danger {
  background: rgba(127, 29, 29, 0.92);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 28px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.72);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
}

.dot-live {
  background: var(--success);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.65);
}

.feedback {
  margin: 0;
  min-height: 20px;
  color: var(--muted);
  text-align: right;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.channel-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 260px;
  padding: 20px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.92), rgba(15, 23, 42, 0.96));
  box-shadow: var(--shadow);
}

.channel-card.placeholder {
  justify-content: center;
  border-style: dashed;
  color: var(--muted);
}

.channel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

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

.channel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(124, 58, 237, 0.14);
  font-size: 22px;
}

.channel-state {
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.state-active {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.state-connecting,
.state-need_qr {
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
}

.state-error {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.state-idle {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
}

.channel-meta,
.channel-list {
  display: grid;
  gap: 8px;
}

.channel-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.channel-list dt,
.channel-list dd,
.channel-list span:last-child {
  margin: 0;
}

.channel-list span:first-child {
  color: var(--muted);
}

.channel-footnote,
.helper {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.future-box {
  margin-top: 24px;
  padding: 22px 24px;
  border-radius: 24px;
  border: 1px dashed rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.52);
}

.modal-root.hidden {
  display: none;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.72);
}

.modal {
  position: relative;
  width: min(720px, calc(100% - 24px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.98);
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
}

.modal-grid {
  display: grid;
  gap: 18px;
}

.modal-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-card {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.88);
}

.qr-box {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 20px;
  border-radius: 20px;
  border: 1px dashed rgba(139, 92, 246, 0.35);
  background: rgba(124, 58, 237, 0.08);
}

.qr-box img {
  max-width: min(320px, 100%);
  width: 100%;
  border-radius: 18px;
  background: white;
  padding: 14px;
}

.inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: #ddd6fe;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 100%);
    padding-top: 20px;
  }

  .topbar,
  .channel-card,
  .modal {
    border-radius: 22px;
  }

  .modal-grid.two {
    grid-template-columns: 1fr;
  }

  .status-strip {
    flex-direction: column;
    align-items: start;
  }

  .feedback {
    text-align: left;
  }
}
