:root {
  color-scheme: dark;
  --bg: #0e1116;
  --elev: rgba(23, 28, 36, 0.92);
  --elev-solid: #171c24;
  --line: rgba(244, 241, 234, 0.1);
  --text: #f4f1ea;
  --muted: #b1aa9e;
  --brass: #e0b15a;
  --brass-2: #f3d397;
  --ink: #1b1408;
  --teal: #8fd0c6;
  --danger: #e36a73;
  --ok: #8dcea8;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.38);
  --radius: 24px;
  --font: "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Mono", "Segoe UI Mono", Consolas, ui-monospace, monospace;
  --kb: 0px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
.hidden { display: none !important; }

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(224, 177, 90, 0.18), transparent 58%),
    radial-gradient(760px 520px at 100% 0%, rgba(143, 208, 198, 0.12), transparent 50%),
    var(--bg);
}

.shell, .gate {
  position: relative;
  z-index: 1;
}

.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.top, .brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; gap: 14px; align-items: center; }
.brand h1, .gate h1 { margin: 0; font-size: 28px; font-weight: 650; letter-spacing: -0.04em; }
.brand p, .lede { margin: 4px 0 0; color: var(--muted); }
.logo { width: 48px; height: 48px; display: block; flex: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(14, 17, 22, 0.55);
  color: var(--muted);
  font-size: 14px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(141, 206, 168, 0.6);
}
.dot.live { background: var(--ok); animation: pulse 1.8s ease-out infinite; }
.dot.wait { background: var(--brass); }
.dot.control { background: var(--danger); animation: pulse 1.4s ease-out infinite; }

@keyframes pulse {
  70% { box-shadow: 0 0 0 8px transparent; }
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 18px;
  margin-top: 22px;
}
.layout > * { min-width: 0; }
.card {
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  backdrop-filter: blur(16px);
}
.card h2 { margin: 0 0 6px; font-size: 18px; letter-spacing: -0.03em; }
.kicker {
  margin: 0 0 14px;
  color: var(--brass-2);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.45; }

.qr-card {
  width: 228px;
  margin: 8px auto 16px;
  padding: 12px;
  border-radius: 20px;
  background: white;
}
.qr-card img { width: 100%; height: auto; display: block; }
.lock-note {
  min-height: 228px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 20px;
  margin-bottom: 16px;
}

.code-well, .fp-well {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #12171f;
  border: 1px solid var(--line);
  margin-bottom: 10px;
}
.code-well strong {
  font-family: var(--mono);
  font-size: 28px;
  letter-spacing: 0.04em;
  font-weight: 620;
}
.fp-well strong { font-family: var(--mono); letter-spacing: 0.06em; font-size: 15px; }
.label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn, .text-btn, .icon-btn {
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 12px 14px;
  background: transparent;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover:not(:disabled), .text-btn:hover, .icon-btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--brass); color: var(--ink); font-weight: 680; }
.btn.primary:hover:not(:disabled) { background: var(--brass-2); }
.btn.ghost, .text-btn {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.03);
}
.btn.danger { border-color: rgba(227, 106, 115, 0.45); color: #ffc4c8; }
.btn.wide { width: 100%; }
.text-btn { padding: 8px 10px; color: var(--muted); }

.segment { display: flex; padding: 4px; gap: 4px; border-radius: 16px; background: #10151c; margin: 14px 0; }
.segment button {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: 10px;
  background: transparent;
  color: var(--muted);
}
.segment button.active { background: #2a2418; color: var(--brass-2); }

.address {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  margin: 8px 0;
}
.field { display: grid; gap: 6px; margin: 12px 0; color: var(--muted); font-size: 13px; }
.field input, .field select, .text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #10151c;
  outline: none;
  font-size: 16px;
}
.field input:focus, .field select:focus, .text-input:focus { border-color: rgba(224, 177, 90, 0.7); }
.check { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 14px; margin: 12px 0; }
.stack { display: grid; gap: 8px; }

.banner {
  border-radius: 18px;
  padding: 14px;
  background: #2a2418;
  border: 1px solid rgba(224, 177, 90, 0.28);
  margin-bottom: 14px;
}
.session-live { display: grid; gap: 10px; }
.switch {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: #10151c;
}
.switch button[aria-checked="true"] { background: #3a2428; color: #ffc4c8; border-color: transparent; }
.trust-row, .stat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.spaced { margin-top: 22px; }
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}
.footer p { flex: 1 1 280px; margin: 0; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  background: #f4f1ea;
  color: #1b1408;
  padding: 10px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 5;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 18px 32px;
}
.panel {
  width: min(440px, 100%);
  background: var(--elev);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
}
.choices { display: grid; gap: 10px; margin-top: 22px; }
.choice {
  text-align: left;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #12171f;
}
.choice strong { display: block; font-size: 17px; margin-bottom: 4px; }
.choice span { color: var(--muted); font-size: 14px; }
.choice.primary { background: var(--brass); border-color: transparent; color: var(--ink); }
.choice.primary span { color: rgba(27, 20, 8, 0.72); }
.wait-orb {
  width: 74px;
  height: 74px;
  margin: 8px auto 18px;
  border-radius: 50%;
  border: 2px solid rgba(224, 177, 90, 0.35);
  border-top-color: var(--brass);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.fail { color: #ffc4c8; }

body[data-screen="live"] { background: #05070b; overflow: hidden; }
body[data-screen="live"] .ambient { display: none; }
.stage {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}
.stage-bar, .dock {
  position: absolute;
  left: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 18px;
  background: rgba(14, 17, 22, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.stage-bar { top: max(10px, env(safe-area-inset-top)); }
.dock {
  bottom: calc(10px + var(--kb) + env(safe-area-inset-bottom));
  justify-content: space-between;
  overflow-x: auto;
  scrollbar-width: none;
}
.dock::-webkit-scrollbar { display: none; }
.grow { flex: 1; }
.canvas-wrap { position: relative; flex: 1; min-height: 0; touch-action: none; }
canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.remote-cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  margin-left: -1px;
  pointer-events: none;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'><path d='M2 1.5 L2 14.5 L6.2 10.6 L9.4 16.2 L11.6 15.1 L8.4 9.6 L14 9.2 Z' fill='white' stroke='%23111' stroke-width='1'/></svg>") center / contain no-repeat;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.45));
}
.hint {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  max-width: min(420px, calc(100% - 32px));
  text-align: center;
  color: #f4f1ea;
  background: rgba(14, 17, 22, 0.8);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
}
.icon-btn {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-color: var(--line);
  background: rgba(255,255,255,0.03);
  padding: 0;
}
.icon-btn.active { background: #2a2418; color: var(--brass-2); }
#pointer-mode, #right-click {
  width: auto;
  min-width: 52px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 650;
}
#zoom-in, #zoom-out { font-size: 26px; line-height: 1; }
.sheet {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(78px + var(--kb) + env(safe-area-inset-bottom));
  z-index: 3;
  padding: 14px;
  border-radius: 20px;
  background: rgba(18, 22, 29, 0.96);
  border: 1px solid var(--line);
  max-height: min(58dvh, 460px);
  overflow: auto;
}
.keys { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.keys button, .combos button {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #10151c;
  padding: 10px 12px;
  min-width: 46px;
}
.keys button.on { background: #2a2418; color: var(--brass-2); }
.combos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.send-row { display: flex; gap: 8px; }
.send-row .btn { flex: none; }
.range { width: 100%; }

@media (max-width: 860px) {
  .layout, .footer, .top { grid-template-columns: 1fr; display: grid; }
  .top { display: flex; }
  .footer { align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  .dot, .wait-orb { animation: none; }
}
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
