:root {
  --accent: #22D3EE;
  --accent2: #8B5CF6;
  --card: #121A2C;
  --card-soft: #0E1526;
  --stroke: #22304B;
  --stroke-2: #2A3A5C;
  --text: #E5E7EB;
  --muted: #8EA3BF;
  --faint: #5B6B86;
  --green: #22FF7E;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, #0B0F19 0%, #0F182B 55%, #14102B 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  z-index: 0;
}
.glow-1 {
  width: 520px; height: 520px;
  top: -220px; right: -160px;
  background: radial-gradient(circle, rgba(139,92,246,.35), transparent 65%);
}
.glow-2 {
  width: 460px; height: 460px;
  bottom: -220px; left: -160px;
  background: radial-gradient(circle, rgba(34,211,238,.18), transparent 65%);
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 26px 18px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 22px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 16px; }

.logo {
  position: relative;
  width: 58px; height: 58px;
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  box-shadow: 0 0 22px rgba(34,211,238,.38);
  display: grid;
  place-items: center;
  flex: none;
}
.logo img { width: 46px; height: 46px; object-fit: contain; border-radius: 8px; }

.live-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 9px; height: 9px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 1.6s ease-in-out infinite;
}

.brand-text h1 { font-size: 21px; font-weight: 700; letter-spacing: .3px; }
.brand-text h1 .accent { color: var(--accent); }
.brand-text p {
  font-size: 10px; color: var(--muted);
  font-weight: 600; letter-spacing: 2.4px;
  margin-top: 3px;
}

.chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.chip {
  font-size: 10px; font-weight: 600; letter-spacing: .5px;
  color: #C7D2E4;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 6px 12px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip-green { color: #A7F3C9; background: #0E1B14; border-color: #1F6E3F; }
.chip-accent { color: #7DE8FB; background: #0E1D26; border-color: var(--accent); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }
.dot.green { background: var(--green); }
.pulse { animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

/* ---------- Layout ---------- */

.content {
  display: grid;
  grid-template-columns: 364px 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 22px;
}

.editor { display: flex; }
.editor .scroll { overflow-y: auto; width: 100%; padding-right: 2px; }

.sect-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.6px;
  color: var(--muted);
  margin: 20px 0 8px;
}
.sect-label.inline { margin-top: 20px; }
.sect-label.no-margin { margin: 0; }

/* ---------- Input ---------- */

.input-wrap { position: relative; }

#content {
  width: 100%;
  color: var(--text);
  background: var(--card-soft);
  border: 1px solid var(--stroke-2);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
#content:focus { border-color: var(--accent); }
#content::placeholder { color: transparent; }

.placeholder {
  position: absolute;
  left: 14px; top: 12px;
  color: var(--faint);
  font-size: 14px;
  pointer-events: none;
}

.template-row { display: flex; gap: 8px; margin-top: 10px; }

.pill {
  font-size: 12px; font-weight: 600;
  color: #C7D2E4;
  background: #17223A;
  border: 1px solid var(--stroke-2);
  border-radius: 14px;
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.pill:hover { border-color: var(--accent); background: #1B2A4E; }
.pill:active { transform: scale(.96); }

/* ---------- Select ---------- */

select#ecc {
  width: 100%;
  color: var(--text);
  background: var(--card-soft);
  border: 1px solid var(--stroke-2);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% - 2px),
    calc(100% - 15px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select#ecc:focus { border-color: var(--accent); }
select#ecc option { background: #10182B; color: var(--text); }

/* ---------- Slider ---------- */

.row-between { display: flex; align-items: center; justify-content: space-between; }
.chip-ish {
  font-size: 13px; font-weight: 600; color: #7DE8FB;
  background: var(--card-soft);
  border: 1px solid var(--stroke-2);
  border-radius: 10px;
  padding: 3px 10px;
  min-width: 40px; text-align: center;
}

#scale {
  width: 100%;
  height: 6px;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 3px;
  background: #1E2A44;
  outline: none;
  cursor: pointer;
  accent-color: var(--accent);
}
#scale::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: 3px solid #0E1526;
  box-shadow: 0 0 10px rgba(34,211,238,.6);
  cursor: grab;
}
#scale::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: 3px solid #0E1526;
  box-shadow: 0 0 10px rgba(34,211,238,.6);
  cursor: grab;
}

/* ---------- Swatches ---------- */

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }

.swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--stroke-2);
  background: var(--card-soft);
  cursor: pointer;
  padding: 0;
  transition: transform .12s;
  position: relative;
}
.swatch i {
  display: block;
  width: 22px; height: 22px;
  margin: 4px auto;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.25);
  background: var(--sw);
}
.swatch:hover { border-color: var(--muted); transform: scale(1.08); }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 8px rgba(34,211,238,.5); }

/* ---------- Status & Save ---------- */

.status-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-soft);
  border: 1px solid #1E3A5C;
  border-radius: 12px;
  padding: 10px 14px;
}
.status-text { font-size: 12px; font-weight: 600; color: #B9E6F5; letter-spacing: .4px; }

.save-btn {
  width: 100%;
  margin-top: 16px;
  height: 46px;
  border: none;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 18px rgba(34,211,238,.28);
  transition: opacity .15s, transform .1s;
  letter-spacing: 1px;
}
.save-btn:hover { opacity: .9; }
.save-btn:active { transform: scale(.98); }
.save-btn:disabled { opacity: .35; cursor: default; }

.hint { text-align: center; font-size: 11px; color: var(--faint); margin-top: 10px; }

/* ---------- Preview ---------- */

.preview { display: flex; flex-direction: column; min-height: 0; }

.preview-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; flex-wrap: wrap; gap: 8px;
}

.stage {
  flex: 1;
  display: grid;
  place-items: center;
  position: relative;
  min-height: 320px;
}

.qr-frame {
  background: #fff;
  border-radius: 26px;
  padding: 20px;
  box-shadow: 0 0 40px rgba(34,211,238,.45);
  display: grid;
  place-items: center;
}
.qr-frame.hidden { display: none; }
#qr {
  max-width: 252px;
  max-height: 252px;
  width: auto;
  height: auto;
  image-rendering: pixelated;
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  background: var(--card-soft);
  border: 1px dashed #1E2A44;
  border-radius: 20px;
  margin: 0 34px;
  padding: 30px;
}
.empty.hidden { display: none; }
.empty-title {
  font-size: 12px; font-weight: 700; letter-spacing: 2px; color: var(--accent);
}
.empty-sub { font-size: 12px; color: var(--muted); margin-top: 8px; max-width: 260px; }

.preview-foot { text-align: center; margin-top: 14px; }
.preview-foot p { font-size: 11px; color: var(--faint); }
.preview-foot p + p { margin-top: 4px; }

/* ---------- Footer ---------- */

.footer { text-align: center; padding-top: 20px; }
.credit-tr { font-size: 12px; color: var(--muted); }
.credit-site { margin-top: 4px; }
.credit-site a {
  color: #7DE8FB;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
}
.credit-site a:hover { filter: brightness(1.15); }
.credit-en { font-size: 10px; color: var(--faint); margin-top: 4px; }

/* ---------- Scrollbar ---------- */

.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: var(--stroke-2); border-radius: 4px; }
.scroll::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .content { grid-template-columns: 1fr; }
  .page { padding: 16px; }
  .stage { min-height: 280px; }
}