:root {
  --bg0: #f8fafc;
  --bg1: #ecfeff;
  --bg2: #fffbeb;
  --ink: #0f172a;
  --ink-soft: #334155;
  --panel: rgba(255, 255, 255, 0.78);
  --line: rgba(15, 23, 42, 0.12);
  --accent: #0ea5a4;
  --accent-strong: #0f766e;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 12% 15%, var(--bg1), transparent 35%),
    radial-gradient(circle at 84% 80%, var(--bg2), transparent 38%),
    var(--bg0);
  position: relative;
}

.bg-shape {
  position: fixed;
  z-index: -1;
  filter: blur(22px);
  opacity: 0.55;
}

.bg-shape-a {
  width: 240px;
  height: 240px;
  border-radius: 40% 60% 70% 30%;
  background: #a7f3d0;
  top: 6vh;
  right: 6vw;
  animation: drift-a 10s ease-in-out infinite;
}

.bg-shape-b {
  width: 320px;
  height: 320px;
  border-radius: 58% 42% 45% 55%;
  background: #fde68a;
  left: -90px;
  bottom: -80px;
  animation: drift-b 12s ease-in-out infinite;
}

@keyframes drift-a {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(18px) rotate(6deg);
  }
}

@keyframes drift-b {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }
  50% {
    transform: translateX(22px) rotate(-8deg);
  }
}

.layout {
  width: min(1200px, calc(100vw - 2.4rem));
  margin: 1.2rem auto 2.2rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

.hero {
  background: linear-gradient(130deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.55));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow);
  animation: reveal 480ms ease-out;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3.6vw, 2.3rem);
}

.hero p {
  margin: 0.45rem 0 0;
  color: var(--ink-soft);
}

.hero .compat {
  margin-top: 0.4rem;
  font-size: 0.9rem;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
  animation: reveal 460ms ease-out;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel h2 {
  margin: 0 0 0.9rem;
}

.controls {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.control {
  display: grid;
  gap: 0.3rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

input,
select,
button,
textarea {
  border: 1px solid var(--line);
  border-radius: 11px;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  padding: 0.55rem 0.65rem;
}

textarea {
  resize: vertical;
}

.actions {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

button {
  padding: 0.56rem 0.85rem;
  background: #fff;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(15, 23, 42, 0.28);
}

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

button.primary {
  border-color: transparent;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #f8fafc;
}

.status-wrap {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.45rem;
}

.status {
  font-size: 0.96rem;
  color: var(--ink);
}

.meta {
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.mono {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
}

.qr-stage {
  margin-top: 0.9rem;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(
    45deg,
    rgba(15, 23, 42, 0.02),
    rgba(15, 23, 42, 0.02) 10px,
    rgba(15, 23, 42, 0.04) 10px,
    rgba(15, 23, 42, 0.04) 20px
  );
  border: 1px dashed rgba(15, 23, 42, 0.2);
  border-radius: 14px;
  padding: 0.9rem;
}

#qrCanvas {
  width: min(92vw, 520px);
  height: min(92vw, 520px);
  background: #fff;
  border-radius: 8px;
}

.video-wrap {
  margin-top: 0.9rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #0f172a;
}

#cameraVideo {
  width: 100%;
  display: block;
  min-height: 180px;
  max-height: 380px;
  object-fit: cover;
}

.download {
  display: inline-flex;
  width: fit-content;
  text-decoration: none;
  padding: 0.52rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
}

.manual {
  margin-top: 0.9rem;
}

.log-wrap {
  margin-top: 0.7rem;
}

#receiverLog {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.75rem;
  background: #111827;
  color: #d1fae5;
  min-height: 140px;
}

@media (min-width: 980px) {
  .layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero {
    grid-column: 1 / -1;
  }
}

