:root {
  --bg: #0b0b14;
  --panel: rgba(22, 22, 35, 0.72);
  --panel-brd: rgba(255, 255, 255, 0.08);
  --text: #eef0f6;
  --muted: #9aa0b4;
  --accent: #6366f1;
  --accent-2: #ec4899;
  --ok: #34d399;
  --radius: 18px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Animated background */
.bg-orbs { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  animation: float 18s ease-in-out infinite;
}
.orb-1 { width: 460px; height: 460px; background: #6366f1; top: -120px; left: -80px; }
.orb-2 { width: 520px; height: 520px; background: #ec4899; bottom: -160px; right: -120px; animation-delay: -6s; }
.orb-3 { width: 380px; height: 380px; background: #22d3ee; top: 40%; left: 55%; animation-delay: -11s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 25px) scale(0.95); }
}

/* Layout */
.site-header, .wrap, .site-footer { position: relative; z-index: 1; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(18px, 5vw, 48px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 26px; filter: drop-shadow(0 0 12px rgba(99,102,241,.7)); }
.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.ghost-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--panel-brd);
  border-radius: 999px;
  transition: 0.2s;
}
.ghost-link:hover { color: var(--text); border-color: rgba(255,255,255,.25); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 10px clamp(18px, 5vw, 48px) 60px; }

.hero { text-align: center; margin: 30px 0 42px; }
.hero h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(2.1rem, 5.5vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
}
.grad-text {
  background: linear-gradient(100deg, var(--accent), var(--accent-2) 60%, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .sub { color: var(--muted); font-size: clamp(0.98rem, 2vw, 1.15rem); max-width: 620px; margin: 0 auto; }

/* Studio grid */
.studio { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 24px; align-items: start; }
@media (max-width: 860px) { .studio { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: var(--radius);
  padding: 26px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.field-group { margin-bottom: 20px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 9px; letter-spacing: 0.01em; }

/* Inputs */
.input-row { display: flex; gap: 10px; }
input[type="text"] {
  width: 100%;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-brd);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: 0.2s;
}
input[type="text"]::placeholder { color: #6b7185; }
input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.btn {
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 12px 20px;
  transition: 0.18s;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.btn.primary {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px -8px rgba(99, 102, 241, 0.7);
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -8px rgba(236, 72, 153, 0.6); }
.btn.primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.ghost { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--panel-brd); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn.ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.block { flex: 1; }
.btn.tiny { padding: 6px 12px; font-size: 12px; }
.icon-btn { padding: 12px; }
.btn.is-loading .btn-label { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
#shorten-btn { position: relative; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Advanced / alias */
.advanced { margin-top: 14px; }
.advanced summary {
  cursor: pointer; color: var(--muted); font-size: 13px;
  list-style: none; user-select: none; width: fit-content;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "\002B  "; color: var(--accent); }
.advanced[open] summary::before { content: "\2212  "; }
.alias-row {
  display: flex; align-items: center; margin-top: 10px;
  background: rgba(255,255,255,.04); border: 1px solid var(--panel-brd); border-radius: 12px; overflow: hidden;
}
.alias-prefix { padding: 0 4px 0 14px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.alias-row input { border: none; background: transparent; box-shadow: none !important; }
.alias-row input:focus { background: transparent; }

/* Result */
.result { animation: fadeUp 0.4s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.short-row {
  display: flex; gap: 10px; align-items: center;
  background: rgba(52, 211, 153, 0.08); border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 12px; padding: 6px 6px 6px 16px;
}
.short-link { flex: 1; color: var(--ok); font-weight: 600; text-decoration: none; word-break: break-all; font-size: 15px; }
.short-link:hover { text-decoration: underline; }
.meta { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }

.divider { border: none; border-top: 1px solid var(--panel-brd); margin: 22px 0; }

/* Swatches */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  border: 2px solid transparent; transition: 0.15s; position: relative;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.15); }

/* Color pickers */
.color-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.color-field { display: flex; flex-direction: column; gap: 6px; }
.color-field label { font-size: 12px; color: var(--muted); }
input[type="color"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 42px; border: 1px solid var(--panel-brd);
  border-radius: 10px; background: transparent; cursor: pointer; padding: 4px;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 6px; }

/* Toggles */
.toggle-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: rgba(255,255,255,.15); border-radius: 999px; transition: 0.2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: linear-gradient(100deg, var(--accent), var(--accent-2)); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* Chips */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 8px 14px; border-radius: 999px; font-size: 13px; cursor: pointer;
  background: rgba(255,255,255,.05); border: 1px solid var(--panel-brd); transition: 0.15s; color: var(--muted);
}
.chip:hover { color: var(--text); }
.chip.active { background: rgba(99,102,241,.18); border-color: var(--accent); color: #fff; }

/* Logo drop */
.logo-drop {
  display: flex; align-items: center; gap: 14px; padding: 14px;
  border: 1.5px dashed var(--panel-brd); border-radius: 14px; cursor: pointer; transition: 0.2s;
}
.logo-drop:hover, .logo-drop.dragover { border-color: var(--accent); background: rgba(99,102,241,.06); }
.logo-preview {
  width: 52px; height: 52px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.06); color: var(--muted); overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.logo-text strong { font-size: 14px; font-weight: 600; }
.logo-text span { font-size: 12px; color: var(--muted); }

/* Preview panel */
.preview { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 20px; }
.qr-stage {
  position: relative; aspect-ratio: 1; width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border-radius: 16px; overflow: hidden;
  background-image: linear-gradient(45deg, #e9e9ef 25%, transparent 25%), linear-gradient(-45deg, #e9e9ef 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e9e9ef 75%), linear-gradient(-45deg, transparent 75%, #e9e9ef 75%);
  background-size: 22px 22px; background-position: 0 0, 0 11px, 11px -11px, -11px 0px;
}
.qr-canvas { line-height: 0; }
.qr-canvas canvas, .qr-canvas svg { max-width: 100%; height: auto !important; }
.qr-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; color: #6b7185;
  background: #12121f; text-align: center; padding: 20px;
}
.qr-empty p { margin: 4px 0 0; font-weight: 600; color: #9aa0b4; }
.qr-empty span { font-size: 13px; }
.qr-empty-ring {
  width: 54px; height: 54px; border-radius: 14px;
  border: 3px dashed rgba(255,255,255,.15); animation: spin 8s linear infinite;
}
.qr-empty.hidden { display: none; }
.download-row { display: flex; gap: 10px; }

/* Footer */
.site-footer { text-align: center; padding: 30px; color: var(--muted); font-size: 13px; }

/* Toast */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1c1c2b; border: 1px solid var(--panel-brd); color: var(--text);
  padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: 0.28s; z-index: 100; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(248,113,113,.5); color: #fca5a5; }
.toast.ok { border-color: rgba(52,211,153,.5); color: #6ee7b7; }

.hidden { display: none !important; }
