/* === Tokens === */
:root {
  --bg: #0c0e14;
  --bg-subtle: #12151e;
  --surface: #181b27;
  --surface-hover: #1e2235;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #475569;
  --accent: #818cf8;
  --accent-bright: #a5b4fc;
  --accent-glow: rgba(129, 140, 248, 0.15);
  --accent-glow-strong: rgba(129, 140, 248, 0.25);
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
}

/* === Reset === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* === Base === */
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Grain overlay for depth */
.noise {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
}

/* Ambient glow behind content */
body::before {
  content: '';
  position: fixed;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 80vw;
  height: 60vh;
  background: radial-gradient(ellipse, rgba(129, 140, 248, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Everything above noise */
header, .type-panel, .main {
  position: relative;
  z-index: 1;
}

/* === Header === */
header {
  padding: 52px 16px 12px;
  text-align: center;
  animation: fadeUp 0.6s ease both;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(129, 140, 248, 0.2);
  border-radius: 100px;
  margin-bottom: 16px;
}

header h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: #fff;
}

header p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 8px;
  line-height: 1.5;
}

/* === Type Selector === */
.type-panel {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 24px 16px 28px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  animation: fadeUp 0.6s 0.08s ease both;
}

.type-panel::-webkit-scrollbar { display: none; }

.type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--text-muted);
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.type-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--text);
  transform: translateY(-1px);
}

.type-btn.active {
  background: rgba(129, 140, 248, 0.1);
  color: var(--accent-bright);
  border-color: rgba(129, 140, 248, 0.3);
  box-shadow: 0 0 20px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.05);
}

.type-btn .icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* === Main Layout === */
.main {
  display: flex;
  gap: 28px;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px 64px;
  animation: fadeUp 0.6s 0.16s ease both;
}

/* === Form Panel === */
.form-panel {
  flex: 1 1 55%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.form-panel h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 22px;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

/* === Form Fields === */
.field-group {
  margin-bottom: 16px;
}

.field-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-family: var(--font-body);
  background: var(--bg-subtle);
  color: var(--text);
  transition: all 0.2s ease;
}

.field-group input:hover,
.field-group select:hover,
.field-group textarea:hover {
  border-color: var(--border-hover);
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--surface);
}

.field-group input::placeholder,
.field-group textarea::placeholder {
  color: var(--text-dim);
}

.field-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.field-group select option {
  background: var(--surface);
  color: var(--text);
}

.field-group textarea {
  resize: vertical;
  min-height: 80px;
}

.field-group.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-group.checkbox-group input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.field-group.checkbox-group label {
  margin-bottom: 0;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.88rem;
  color: var(--text);
}

/* === Preview Panel === */
.preview-panel {
  flex: 1 1 40%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-card {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#qr-output {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  min-height: 220px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 8px 40px rgba(0, 0, 0, 0.4),
    0 0 80px var(--accent-glow);
  transition: box-shadow 0.4s ease;
}

#qr-output:has(canvas) {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 8px 40px rgba(0, 0, 0, 0.4),
    0 0 80px var(--accent-glow-strong);
}

.qr-placeholder {
  color: #b0b0b8;
  font-size: 0.82rem;
  text-align: center;
  padding: 40px 20px;
  line-height: 1.5;
}

/* === Buttons === */
.preview-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:not(.btn-secondary) {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(129, 140, 248, 0.3);
}

.btn:not(.btn-secondary):hover {
  background: var(--accent-bright);
  box-shadow: 0 4px 20px rgba(129, 140, 248, 0.4);
  transform: translateY(-1px);
}

.btn:not(.btn-secondary):active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(129, 140, 248, 0.2);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

/* === Animations === */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === Responsive === */
@media (max-width: 640px) {
  header {
    padding: 36px 16px 8px;
  }

  header h1 {
    font-size: 1.6rem;
  }

  .main {
    flex-direction: column;
    padding: 0 16px 40px;
    gap: 20px;
  }

  .preview-panel {
    order: -1;
  }

  .preview-card {
    position: static;
    width: 100%;
    align-items: center;
  }

  .form-panel {
    padding: 20px;
  }

  .type-panel {
    justify-content: flex-start;
    padding: 16px;
  }
}
