:root {
  color-scheme: dark;
  --bg: #0c1016;
  --panel: rgba(22, 29, 39, 0.78);
  --panel-solid: #151d28;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4f7fb;
  --muted: #9aa8ba;
  --accent: #64d6b0;
  --accent-2: #7aa8ff;
  --warning: #ffc56f;
  --danger: #ff7d88;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 16%, rgba(100, 214, 176, 0.20), transparent 28%),
    radial-gradient(circle at 84% 18%, rgba(122, 168, 255, 0.22), transparent 30%),
    linear-gradient(135deg, #0b0f15 0%, #111827 48%, #10141c 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: var(--text);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.hero-panel,
.workspace {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-radius: 8px;
  padding: 24px;
}

.workspace {
  border-radius: 8px;
  padding: 22px;
}

.brand-row,
.top-strip,
.panel-heading,
.progress-meta,
.toolbar,
.join-row {
  display: flex;
  align-items: center;
}

.brand-row,
.panel-heading,
.top-strip {
  justify-content: space-between;
  gap: 16px;
}

.brand-row {
  justify-content: flex-start;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(100, 214, 176, 0.34);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(100, 214, 176, 0.22), rgba(122, 168, 255, 0.14));
}

.brand-mark span {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
}

.brand-mark span:nth-child(1) {
  transform: translate(-12px, 8px);
}

.brand-mark span:nth-child(2) {
  transform: translate(0, -12px);
  background: var(--accent-2);
}

.brand-mark span:nth-child(3) {
  transform: translate(13px, 8px);
  background: var(--warning);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.1rem, 4vw, 4rem);
}

h2 {
  font-size: 1.08rem;
}

.connection-map {
  display: grid;
  grid-template-columns: 58px 1fr 58px 1fr 58px;
  align-items: center;
  min-height: 118px;
  padding: 18px 4px;
}

.node {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.node svg {
  width: 24px;
  height: 24px;
}

.node-center {
  color: var(--accent);
}

.pulse-line {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 200% 100%;
  animation: pulse 2.6s linear infinite;
}

.pulse-line.reverse {
  animation-direction: reverse;
}

@keyframes pulse {
  from { background-position: 0 0; }
  to { background-position: 200% 0; }
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.mode-button,
.primary-action,
.accept-button,
.secondary-action,
.join-row button,
.toolbar button,
.code-box button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  min-height: 42px;
  background: rgba(255, 255, 255, 0.08);
}

.mode-button.is-active {
  background: var(--text);
  color: #10141c;
}

.primary-action {
  width: 100%;
  min-height: 52px;
  color: #07110e;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #a8eecf);
}

.accept-button {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  background: rgba(100, 214, 176, 0.2);
  color: var(--text);
}

.secondary-action {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.join-form {
  display: none;
}

.join-form.is-visible {
  display: block;
}

.join-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.join-row {
  gap: 8px;
}

.join-row input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  text-transform: uppercase;
}

.join-row button {
  min-width: 118px;
  padding: 0 14px;
  background: rgba(122, 168, 255, 0.24);
}

.status-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.status-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  margin-top: auto;
}

.status-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 22px var(--warning);
  flex: 0 0 auto;
}

.status-dot.is-connected {
  background: var(--accent);
  box-shadow: 0 0 22px var(--accent);
}

.status-dot.is-error {
  background: var(--danger);
  box-shadow: 0 0 22px var(--danger);
}

.top-strip {
  margin-bottom: 18px;
}

.code-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.code-box strong {
  min-width: 96px;
  text-align: center;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
}

.code-box button {
  width: 38px;
  min-height: 38px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(270px, 1.2fr) minmax(220px, 0.8fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

.info-panel {
  grid-column: 1 / -1;
}

.info-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.info-list div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
  color: var(--muted);
}

.info-list svg {
  color: var(--accent);
  flex: 0 0 auto;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #06120f;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--accent);
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 180px;
  margin-top: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.14);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-zone svg {
  width: 34px;
  height: 34px;
  color: var(--accent);
}

.drop-zone span {
  margin-top: 10px;
  font-weight: 800;
}

.drop-zone small,
#qrHelp,
.muted {
  color: var(--muted);
}

.progress-block {
  margin-top: 18px;
}

.progress-meta {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

#progressBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 160ms ease;
}

.qr-panel {
  text-align: center;
}

#qrCanvas {
  width: min(100%, 220px);
  height: auto;
  margin: 14px auto;
  border-radius: 8px;
  background: #fff;
}

.toolbar {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.toolbar button {
  min-width: 128px;
  padding: 0 14px;
}

svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    min-height: auto;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 12px;
  }

  .hero-panel,
  .workspace {
    padding: 16px;
  }

  .grid,
  .top-strip {
    grid-template-columns: 1fr;
  }

  .info-list {
    grid-template-columns: 1fr;
  }

  .top-strip {
    align-items: flex-start;
  }

  .code-box {
    width: 100%;
    justify-content: space-between;
  }

  .toolbar button,
  .join-row button {
    flex: 1 1 145px;
  }
}
