/* app.css —— 深色移动优先的界面样式（扫码端 & 显示端共用） */
:root {
  --bg: #0b0f14;
  --bg-2: #131a22;
  --bg-3: #1b242e;
  --line: #26313d;
  --fg: #e8eef5;
  --fg-dim: #93a3b4;
  --accent: #2fd4a7;
  --accent-2: #3b9dff;
  --warn: #ffb454;
  --err: #ff6b6b;
  --ok: #2fd4a7;
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  overscroll-behavior: none;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--fg-dim); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(11, 15, 20, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.spacer { flex: 1 1 auto; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  font-size: 12px;
  color: var(--fg-dim);
  white-space: nowrap;
}
.pill b { color: var(--fg); font-weight: 600; }
.pill.on { border-color: rgba(47, 212, 167, .5); color: var(--accent); }
.pill.off { border-color: rgba(255, 107, 107, .5); color: var(--err); }
.pill .led { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------------- 按钮 ---------------- */
button, .btn {
  font: inherit;
  color: var(--fg);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
button:hover, .btn:hover { border-color: #3a4a5c; background: #202b36; }
button:active { transform: scale(.97); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary { background: linear-gradient(180deg, #2fd4a7, #22b78f); color: #04211a; border-color: transparent; font-weight: 700; }
button.danger { border-color: rgba(255, 107, 107, .5); color: var(--err); }
button.mini { padding: 3px 9px; font-size: 12px; border-radius: 8px; }
button.active { background: rgba(47, 212, 167, .18); border-color: var(--accent); color: var(--accent); }

select, input[type=text], textarea {
  font: inherit;
  color: var(--fg);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  max-width: 100%;
}
input[type=range] { accent-color: var(--accent); width: 100%; }
input[type=checkbox] { accent-color: var(--accent); width: 17px; height: 17px; }

/* ---------------- 布局 ---------------- */
.wrap { padding: 14px; max-width: 1500px; margin: 0 auto; }
.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 980px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 14px; letter-spacing: .4px; color: var(--fg-dim); text-transform: uppercase; }
.card h3 { font-size: 13px; }

/* ---------------- 视频舞台 ---------------- */
.stage {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
}
@media (min-aspect-ratio: 1/1) { .stage { aspect-ratio: 16 / 9; } }
.stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage .reticle {
  position: absolute;
  inset: 14%;
  border-radius: 14px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .28);
  outline: 2px solid rgba(47, 212, 167, .85);
  outline-offset: -2px;
}
.stage .reticle::before, .stage .reticle::after {
  content: '';
  position: absolute;
  width: 26px; height: 26px;
  border: 3px solid var(--accent);
}
.stage .reticle::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.stage .reticle::after { bottom: -3px; right: -3px; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; }
.stage .flash {
  position: absolute; inset: 0; background: var(--accent); opacity: 0; pointer-events: none;
}
.stage .flash.go { animation: flash .42s ease-out; }
@keyframes flash { 0% { opacity: .55; } 100% { opacity: 0; } }

.hud {
  position: absolute; left: 10px; bottom: 10px;
  display: flex; gap: 6px; flex-wrap: wrap;
  font-size: 11px;
}
.hud span {
  background: rgba(0, 0, 0, .6);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  padding: 3px 8px;
  backdrop-filter: blur(4px);
}
.hud span b { color: var(--accent); font-weight: 700; }
.stage .hint {
  position: absolute; top: 10px; left: 10px; right: 10px;
  font-size: 12px;
  background: rgba(0, 0, 0, .6);
  border-radius: 10px;
  padding: 6px 10px;
  backdrop-filter: blur(4px);
}
.stage .hint.warn { color: var(--warn); }
.stage .scanstate {
  position: absolute; right: 10px; bottom: 10px;
  font-size: 12px; background: rgba(0, 0, 0, .6); padding: 4px 10px; border-radius: 999px;
}

/* 暂停遮罩：完全盖住二维码，避免扫码端继续识别到上一张旧码 */
.stage.paused::after {
  content: '已暂停 · 按空格继续';
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--fg-dim);
  font-size: 18px;
  letter-spacing: 2px;
}

/* ---------------- 控件行 ---------------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-dim); }
.field > * { flex: 0 0 auto; }
.zoomline { display: flex; align-items: center; gap: 10px; }
.zoomline input[type=range] { flex: 1 1 auto; }
.zoomval { min-width: 74px; text-align: right; font-weight: 700; color: var(--accent); }

/* ---------------- 列表 ---------------- */
.list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.list li {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px;
  background: var(--bg-3); font-size: 13px;
}
.code-text { word-break: break-all; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.row-tools { display: flex; align-items: center; gap: 6px; color: var(--fg-dim); font-size: 11px; flex: 0 0 auto; }

.log {
  height: 190px; overflow: auto; background: #070a0e; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px; color: #9fb3c6; white-space: pre-wrap; word-break: break-all;
}
.log div { padding: 1px 0; border-bottom: 1px solid rgba(255, 255, 255, .03); }

/* ---------------- 结果卡片 ---------------- */
.result {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px;
  word-break: break-all; min-height: 46px; max-height: 160px; overflow: auto;
}

/* ---------------- 二维码显示区 ---------------- */
.qrbox {
  display: flex; align-items: center; justify-content: center;
  background: #fff; border-radius: 14px; padding: 16px; min-height: 280px;
  border: 1px solid var(--line);
}
.qrbox.dark { background: #000; }
.qrbox canvas { max-width: 100%; max-height: 70vh; height: auto; image-rendering: pixelated; display: block; }
.qrbox.empty { color: #6b7b8c; background: var(--bg-3); font-size: 14px; }

/* ---------------- 提示 ---------------- */
.toast-box { position: fixed; z-index: 99; left: 50%; bottom: 26px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(20, 28, 36, .96); border: 1px solid var(--line); color: var(--fg);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  animation: pop .2s ease-out;
}
.toast.warn { border-color: var(--warn); color: var(--warn); }
.toast.err { border-color: var(--err); color: var(--err); }
.toast.out { opacity: 0; transition: opacity .35s; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- 首页 ---------------- */
.hero { text-align: center; padding: 34px 14px 10px; }
.hero h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: .5px; }
.hero p { margin: 0 auto; max-width: 720px; color: var(--fg-dim); }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin: 22px 0; }
.role {
  display: block; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; transition: .18s; color: inherit;
}
.role:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.role h3 { margin: 0 0 6px; font-size: 17px; color: var(--fg); text-transform: none; }
.role .tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--fg-dim); }
.role .tag.exclusive { border-color: rgba(255, 180, 84, .6); color: var(--warn); }
.role .tag.multi { border-color: rgba(59, 157, 255, .6); color: var(--accent-2); }

table.info { width: 100%; border-collapse: collapse; font-size: 13px; }
table.info td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.info td:first-child { color: var(--fg-dim); width: 34%; }

.gate {
  max-width: 560px; margin: 24px auto; text-align: center;
}
.gate .big { font-size: 34px; margin-bottom: 6px; }

/* 全屏显示端 */
body.fullscreen-mode .topbar, body.fullscreen-mode .side { display: none; }
body.fullscreen-mode .grid { grid-template-columns: 1fr; }
