:root {
  --bg: #0b0f19;
  --panel: rgba(15, 23, 42, 0.86);
  --panel-2: rgba(30, 41, 59, 0.55);
  --border: rgba(148, 163, 184, 0.18);
  --border-gold: rgba(245, 184, 65, 0.35);
  --text: #f8fafc;
  --muted: #94a3b8;
  --gold: #f5b841;
  --emerald: #10b981;
  --rose: #fb7185;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at top, #172038 0%, #0b0f19 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.hidden { display: none !important; }
.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 18px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(245, 184, 65, 0.2), rgba(217, 119, 6, 0.1));
  border: 1px solid var(--border-gold);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-name { font-size: 15.5px; font-weight: 800; letter-spacing: -0.2px; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.nav-tabs {
  display: flex;
  gap: 6px;
  background: rgba(2, 6, 23, 0.55);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.nav-tab.active {
  background: linear-gradient(135deg, rgba(245, 184, 65, 0.22), rgba(245, 184, 65, 0.08));
  color: var(--gold);
  border: 1px solid var(--border-gold);
}
.hero-strip { text-align: center; margin: 22px auto 18px; max-width: 680px; }
.hero-strip h1 { margin: 0 0 8px; font-size: clamp(21px, 3vw, 28px); font-weight: 850; letter-spacing: -0.4px; }
.hero-strip p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.55; }
.hero-strip code { background: rgba(245, 184, 65, 0.14); color: var(--gold); padding: 1px 6px; border-radius: 6px; font-weight: 700; }
.studio-grid, .scan-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
  align-items: start;
}
.scan-grid { grid-template-columns: 1fr 1fr; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.35);
}
.seg-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: rgba(2, 6, 23, 0.55);
  padding: 4px;
  border-radius: 11px;
  margin-bottom: 16px;
}
.seg-btn {
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.seg-btn.active { background: #1e293b; color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 700; color: #cbd5e1; }
.inp, select.inp, textarea.inp {
  width: 100%;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: #0f172a;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
}
.inp:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 184, 65, 0.16); }
.mono-big { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: 0.6px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 32px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.chip.active { border-color: var(--border-gold); color: var(--gold); background: rgba(245, 184, 65, 0.12); }
.palette-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s;
}
.swatch.active { border-color: #fff; transform: scale(1.08); }
.logo-upload-row { display: flex; gap: 8px; align-items: center; }
.btn-mini {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border-gold);
  background: rgba(245, 184, 65, 0.14);
  color: var(--gold);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.btn-mini.ghost { border-color: var(--border); background: transparent; color: var(--muted); }
.preview-panel { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.preview-frame {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  background: #ffffff;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.preview-frame canvas { width: 100%; height: 100%; border-radius: 10px; display: block; }
.preview-actions { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.action-subrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-fit { width: auto; white-space: nowrap; }
.btn-gold { background: linear-gradient(135deg, #f5b841, #d97706); color: #090d16; }
.btn-emerald { background: linear-gradient(135deg, #10b981, #059669); color: #041510; }
.btn-ghost { background: rgba(255, 255, 255, 0.06); color: #e2e8f0; border: 1px solid rgba(255, 255, 255, 0.12); }
.sec-title { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 15px; font-weight: 800; color: var(--gold); }
.muted { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.quick-code-row { display: flex; gap: 8px; }
.drop-zone {
  border: 1.5px dashed rgba(245, 184, 65, 0.4);
  border-radius: 16px;
  padding: 24px 16px;
  text-align: center;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--gold);
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone.dragover { border-color: var(--emerald); background: rgba(16, 185, 129, 0.1); }
.drop-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.drop-sub { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.cam-stage {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: #060911;
  border: 1px solid var(--border);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.cam-stage video { width: 100%; height: 100%; object-fit: cover; }
.cam-placeholder { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; text-align: center; padding: 16px; }
.cam-actions { display: flex; gap: 8px; }
.scan-result {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-size: 13px;
  word-break: break-all;
}
.gate-card {
  max-width: 420px;
  margin: 34px auto;
  background: var(--panel);
  border: 1px solid var(--border-gold);
  border-radius: 22px;
  padding: 30px 24px 24px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.gate-icon {
  width: 66px;
  height: 66px;
  border-radius: 20px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 184, 65, 0.12);
  border: 1px solid var(--border-gold);
  color: var(--gold);
}
.gate-icon.unlocked {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.45);
  color: var(--emerald);
  box-shadow: 0 0 28px rgba(16, 185, 129, 0.28);
}
.gate-card h1 { margin: 0 0 6px; font-size: 21px; font-weight: 850; }
.gate-sub { margin: 0 0 16px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.code-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: #e2e8f0;
  margin-bottom: 18px;
}
.pin4-grid { display: flex; justify-content: center; gap: 11px; margin: 8px 0 14px; }
.pin4-box {
  width: 56px;
  height: 62px;
  border-radius: 14px;
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  background: #0f172a;
  color: #f8fafc;
  font-size: 26px;
  font-weight: 800;
  text-align: center;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pin4-box:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 184, 65, 0.22); }
.gate-hint { font-size: 11.5px; color: #64748b; margin-bottom: 10px; }
.err-msg { min-height: 18px; font-size: 12.5px; color: var(--rose); font-weight: 600; margin: 6px 0 10px; }
.btn-link {
  margin-top: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn-link:hover { color: var(--text); }
.footer { margin-top: auto; padding-top: 28px; text-align: center; font-size: 12px; color: #64748b; }
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 12px;
  background: #1e293b;
  border: 1px solid var(--border-gold);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  z-index: 9999;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
@media (max-width: 820px) {
  .studio-grid, .scan-grid { grid-template-columns: 1fr; }
  .opt-grid { grid-template-columns: 1fr; }
  .topbar { justify-content: center; }
}

