/* ==========================================================================
   QR Studio Pro - Modern App CSS with Rich Animations & Mobile Experience
   ========================================================================== */

/* 1. Design Tokens & CSS Variables */
:root {
  /* Color Palette - Dark Theme (Default) */
  --bg-app: #080c16;
  --bg-surface: rgba(16, 24, 40, 0.75);
  --bg-surface-elevated: rgba(24, 34, 58, 0.85);
  --bg-card: rgba(20, 30, 50, 0.65);
  --bg-input: rgba(12, 18, 32, 0.75);
  --bg-hover: rgba(255, 255, 255, 0.08);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glass: rgba(255, 255, 255, 0.14);
  --border-focus: #6366f1;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #080c16;

  /* Brand Accents & Gradients */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  --secondary: #06b6d4;
  --accent-purple: #8b5cf6;

  --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --gradient-glow: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.25) 0%, rgba(139, 92, 246, 0.05) 50%, transparent 80%);
  --gradient-shimmer: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 35px -5px rgba(99, 102, 241, 0.45);
  --shadow-neon: 0 0 20px rgba(6, 182, 212, 0.4);

  /* Geometry */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  /* Spring Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-bounce: 0.6s cubic-bezier(0.68, -0.6, 0.32, 1.6);

  --font-family: 'Plus Jakarta Sans', 'Kantumruy Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-surface: rgba(255, 255, 255, 0.85);
  --bg-surface-elevated: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-input: #f8fafc;
  --bg-hover: rgba(0, 0, 0, 0.05);

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-glass: rgba(0, 0, 0, 0.1);
  --border-focus: #4f46e5;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: rgba(79, 70, 229, 0.1);

  --gradient-glow: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 30px -5px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px -10px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.2);
}

/* 2. Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100%;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

/* 3. Ambient Moving Aurora Glows */
.ambient-glow-wrapper {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.45;
  will-change: transform;
}

[data-theme="light"] .ambient-glow {
  opacity: 0.22;
}

.glow-1 {
  top: -10%;
  left: 20%;
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, #6366f1 0%, transparent 70%);
  animation: aurora-float-1 16s ease-in-out infinite alternate;
}

.glow-2 {
  bottom: 10%;
  right: -5%;
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
  animation: aurora-float-2 20s ease-in-out infinite alternate;
}

.glow-3 {
  top: 40%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
  animation: aurora-float-3 18s ease-in-out infinite alternate;
}

@keyframes aurora-float-1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(80px, 60px) scale(1.15); }
  100% { transform: translate(-40px, 100px) scale(0.95); }
}

@keyframes aurora-float-2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-100px, -70px) scale(1.2); }
  100% { transform: translate(50px, -40px) scale(0.9); }
}

@keyframes aurora-float-3 {
  0% { transform: translate(0, 0) scale(0.9); }
  50% { transform: translate(70px, -80px) scale(1.1); }
  100% { transform: translate(-30px, 50px) scale(1); }
}

/* Fullscreen Confetti Canvas */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* 4. Layout Architecture */
.app-container {
  max-width: 1240px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  position: relative;
  z-index: 10;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

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

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-brand);
  box-shadow: var(--shadow-sm);
  padding: 4px;
  transition: transform var(--transition-spring);
}

.brand-icon:hover {
  transform: rotate(-8deg) scale(1.08);
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge-pro {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--primary);
  color: #ffffff;
  animation: pulse-pro 2s infinite ease-in-out;
}

@keyframes pulse-pro {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); box-shadow: 0 0 12px var(--primary); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: var(--bg-surface);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.icon-btn:active {
  transform: scale(0.92);
}

.badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--bg-app);
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

/* Theme Icons Visibility */
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }

/* Main Grid */
.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
  padding: 24px 0 60px 0;
  align-items: start;
}

/* 5. Left Panel: Segmented Tabs & Input Cards */
.left-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Segmented Tabs (App Style with Sliding Indicator) */
.tabs-scroll-container {
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.segmented-tabs {
  position: relative;
  display: inline-flex;
  gap: 4px;
  background: var(--bg-surface);
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(12px);
  min-width: 100%;
}

.tab-slider {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  border-radius: var(--radius-sm);
  background: var(--gradient-brand);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  transition: all var(--transition-spring);
  pointer-events: none;
  z-index: 1;
}

.tab-btn {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: #ffffff;
}

/* Cards Base */
.card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-smooth);
  overflow: hidden;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: var(--shadow-lg);
}

/* Type Forms Animation */
.type-form {
  display: none;
}
.type-form.active {
  display: block;
  animation: slideFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Input Fields & Groups */
.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.field-header label, .input-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.field-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.field-action-btn:hover {
  background: var(--primary);
  color: #ffffff;
  transform: scale(1.04);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  font-size: 1.1rem;
  pointer-events: none;
  transition: transform var(--transition-spring);
}

.input-with-icon input:focus ~ .input-icon {
  transform: scale(1.2);
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="tel"],
textarea,
.app-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}

.input-with-icon input {
  padding-left: 44px;
  padding-right: 40px;
}

input:focus, textarea:focus, .app-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--primary-light);
  background: var(--bg-surface-elevated);
}

.clear-btn {
  position: absolute;
  right: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all var(--transition-fast);
}
.clear-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  transform: rotate(90deg) scale(1.1);
}

textarea {
  resize: vertical;
  min-height: 90px;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Quick Chips */
.quick-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.chip {
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
}

.grid-2-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.checkbox-group {
  justify-content: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem !important;
  color: var(--text-secondary) !important;
  font-weight: 500 !important;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  border-radius: 4px;
  cursor: pointer;
}

/* 6. Customization Card */
.section-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 20px;
}

.title-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.custom-row {
  margin-bottom: 16px;
}

.row-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

/* Palette Presets */
.palette-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.palette-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.palette-btn:hover {
  border-color: var(--primary);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.palette-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  transform: scale(1.03);
}

.circle-preview {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-spring);
}

.palette-btn:hover .circle-preview {
  transform: rotate(45deg);
}

/* Custom Color Inputs */
.color-picker-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.color-picker-box label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.color-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: border-color var(--transition-fast);
}

.color-input-wrapper:hover {
  border-color: var(--primary);
}

input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

.hex-text {
  font-size: 0.85rem;
  font-family: monospace;
  font-weight: 600;
  color: var(--text-primary);
}

.mt-3 {
  margin-top: 14px;
}

/* Logo Upload Row */
.logo-selector {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-input);
  border: 1px dashed var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.logo-upload-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  transform: translateY(-1px);
}

.pill-btn {
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-glass);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.remove-logo-btn {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
}
.remove-logo-btn:hover {
  background: #ef4444;
  color: #ffffff;
}

/* Margin / Padding Slider & Preset Chips */
.margin-slider-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.app-range {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--border-glass);
  outline: none;
  cursor: pointer;
  padding: 0;
  border: none;
}

.app-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gradient-brand);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.6);
  border: 2px solid #ffffff;
  transition: transform var(--transition-spring);
}

.app-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.margin-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.margin-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.margin-btn:hover {
  color: var(--text-primary);
  border-color: var(--primary);
}

.margin-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

/* 7. Right Panel: Live QR Device Card with 3D Physics */
.right-panel {
  position: sticky;
  top: 86px;
  perspective: 1000px;
}

.qr-preview-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.qr-device-card {
  position: relative;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-style: preserve-3d;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0.2, 1), box-shadow 0.3s ease;
}

.qr-card-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #10b981;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 10px #10b981;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.9; }
  50% { transform: scale(1.3); opacity: 0.4; }
  100% { transform: scale(0.95); opacity: 0.9; }
}

.qr-size-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

/* QR Code Display Canvas with Animated Laser Scanner */
.qr-canvas-box {
  width: 280px;
  height: 280px;
  background: #ffffff;
  border-radius: 20px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-spring);
}

.qr-canvas-box:hover {
  transform: scale(1.03);
}

/* Glowing Neon Laser Scanner Line */
.scanner-laser {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #06b6d4, #6366f1, #06b6d4, transparent);
  box-shadow: 0 0 12px #06b6d4, 0 0 24px #6366f1;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

.scanner-laser.scanning {
  opacity: 1;
  animation: laserSweep 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes laserSweep {
  0% { top: 0%; opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.qr-canvas-box canvas, .qr-canvas-box svg {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 8px;
  display: block;
  animation: qrPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes qrPop {
  0% { transform: scale(0.92); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #64748b;
  font-size: 0.85rem;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.qr-scan-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

/* Resolution Chips */
.resolution-selector {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.res-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.res-chips {
  display: flex;
  gap: 6px;
}

.res-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.res-btn:hover {
  color: var(--text-primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.res-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

/* Action Buttons Grid */
.qr-actions-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.app-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  white-space: nowrap;
  overflow: hidden;
}

.app-btn:active {
  transform: scale(0.95);
}

.btn-primary {
  grid-column: span 2;
  background: var(--gradient-brand);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.6);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
}

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

.btn-outline {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
}

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.w-full {
  width: 100%;
}

/* Tactile Ripple Effect on Buttons */
.ripple-btn {
  position: relative;
  overflow: hidden;
}

.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transform: scale(0);
  animation: rippleAnimation 0.55s ease-out;
  pointer-events: none;
}

@keyframes rippleAnimation {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

.input-icon {
  position: absolute;
  left: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  pointer-events: none;
  transition: transform var(--transition-spring), color var(--transition-fast);
}

.input-with-icon input:focus ~ .input-icon {
  color: var(--primary);
  transform: scale(1.15);
}

/* 8. Mobile Native App Bottom Navigation Dock */
.mobile-app-dock {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(14, 20, 36, 0.94);
  border-top: 1px solid var(--border-glass);
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 50;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .mobile-app-dock {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.08);
}

.dock-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dock-item svg {
  stroke: var(--text-muted);
  transition: all var(--transition-fast);
}

.dock-item span {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.dock-item.active {
  color: var(--primary);
}

.dock-item.active svg {
  stroke: var(--primary);
  transform: translateY(-2px);
}

.dock-item:active {
  transform: scale(0.92);
}

.dock-primary {
  background: var(--gradient-brand) !important;
  color: #ffffff !important;
  border-radius: var(--radius-md) !important;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4) !important;
  padding: 6px 8px !important;
}

.dock-primary svg {
  stroke: #ffffff !important;
}

.dock-primary span {
  color: #ffffff !important;
}

/* 9. History Drawer / Sheet */
.history-drawer {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.history-drawer.open {
  pointer-events: auto;
  opacity: 1;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

.drawer-content {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100%;
  background: var(--bg-surface-elevated);
  border-left: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  padding: 24px;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}

.history-drawer.open .drawer-content {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
}

.clear-history-link {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.history-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.history-item:hover {
  border-color: var(--primary);
  background: var(--bg-hover);
  transform: translateX(-3px);
}

.history-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.history-type-badge {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
}

.history-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

.history-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.empty-history {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.drawer-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

/* 10. Toast Notification Pill */
.toast-pill {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  opacity: 0;
  background: rgba(15, 23, 42, 0.94);
  color: #ffffff;
  border: 1px solid var(--border-glass);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
  z-index: 100;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 0.9rem;
  font-weight: 700;
}

[data-theme="light"] .toast-pill {
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.toast-pill.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #10b981;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 900;
  animation: checkPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkPop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* Save Image Modal (Mobile Reliable Save) */
.save-image-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.save-image-modal.open {
  pointer-events: auto;
  opacity: 1;
}

.save-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.save-modal-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.save-image-modal.open .save-modal-card {
  transform: scale(1);
}

.save-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.save-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title-icon {
  stroke: var(--primary);
}

.save-modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.save-image-preview-box {
  position: relative;
  background: #ffffff;
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  border: 2px dashed rgba(99, 102, 241, 0.4);
}

.save-image-preview-box img {
  width: 210px;
  height: 210px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 8px;
  -webkit-touch-callout: default !important; /* Enable iOS long-press save */
  user-select: auto !important;
  pointer-events: auto !important;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.save-image-preview-box img:active {
  transform: scale(0.97);
}

.save-image-badge {
  position: absolute;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  pointer-events: none;
}

.save-modal-instructions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--primary-light);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-md);
  padding: 12px;
}

.instruction-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text-primary);
  font-size: 0.8rem;
  line-height: 1.45;
}

.inst-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.save-modal-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.save-modal-sub-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

/* 11. Footer */
.app-footer {
  text-align: center;
  padding: 24px 0 40px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-subtle);
}

/* 12. Responsive Mobile-First Enhancements (Like a Native App) */
@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
    gap: 20px;
    padding-bottom: 96px; /* Space for mobile app dock */
  }

  .mobile-app-dock {
    display: flex;
  }

  .right-panel {
    position: static;
    order: -1;
  }

  .qr-device-card {
    padding: 20px;
  }

  .qr-canvas-box {
    width: 250px;
    height: 250px;
  }

  .drawer-content {
    max-width: 100%;
    height: 75vh;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
    border-left: none;
    border-top: 1px solid var(--border-glass);
    top: auto;
    bottom: 0;
  }

  .history-drawer.open .drawer-content {
    transform: translateY(0);
  }

  .drawer-handle {
    width: 40px;
    height: 5px;
    background: var(--text-muted);
    border-radius: var(--radius-full);
    margin: -8px auto 16px auto;
  }
}

@media (max-width: 480px) {
  .app-container {
    padding: 0 12px;
  }

  .card {
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .grid-2-cols {
    grid-template-columns: 1fr;
  }

  .qr-actions-grid {
    grid-template-columns: 1fr;
  }

  .btn-primary {
    grid-column: span 1;
  }

  .tab-btn {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .palette-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  .qr-canvas-box {
    width: 220px;
    height: 220px;
  }
}

.hidden {
  display: none !important;
}
