:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --bg: #f8fafc;
  --card-bg: rgba(255, 255, 255, 0.95);
  --text: #0f172a;
  --subtext: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --accent-glow: #60a5fa;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 10px 30px -5px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Noto Sans Lao', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.05) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(96, 165, 250, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 32px 16px;
  -webkit-font-smoothing: antialiased;
}

.main-container {
  max-width: 580px;
  width: 100%;
  margin: 0 auto;
}

/* Top Navigation Bar */
.top-header-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 20px;
}

.lang-bar {
  display: flex;
  background: rgba(226, 232, 240, 0.6);
  padding: 3px;
  border-radius: 10px;
  gap: 2px;
}

.lang-btn {
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--subtext);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.lang-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* Integrated Theme Counter Badge */
.counter-badge-integrated {
  display: none !important; /* <--- ADD THIS LINE TO HIDE IT */
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.15);
  color: var(--primary);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 18px;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.6);
}

.counter-pulse-dot {
  width: 7px;
  height: 7px;
  background-color: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--primary);
  animation: pulseGlow 1.8s infinite ease-in-out;
}

.counter-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  letter-spacing: 0.05em;
}

@keyframes pulseGlow {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Header */
header {
  text-align: center;
  margin-bottom: 24px;
}

h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #0f172a 0%, #2563eb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

p.tagline {
  font-size: 15px;
  color: var(--subtext);
  line-height: 1.5;
}

/* Generator Card */
.generator-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  text-align: center;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  width: 100%;
}

.input-group {
  display: flex;
  gap: 12px;
  width: 100%;
}

.url-input {
  width: 100%;
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 72px 14px 16px;
  font-size: 15px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: all 0.2s ease;
  height: 52px;
}

.url-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.btn-paste {
  position: absolute;
  right: 10px;
  background: var(--primary-light);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.btn-paste:hover {
  background: #dbeafe;
}

/* Premium AI Live Button - Fixed Equal Height & Responsive Sizing */
.generate-btn {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 50%, #4f46e5 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0 22px;
  height: 52px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.generate-btn::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  transition: 0.5s;
}

.generate-btn:hover::before {
  left: 100%;
}

.generate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

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

.ai-sparkle-icon {
  display: inline-block;
  font-size: 18px;
  animation: aiGlowPulse 2s infinite alternate ease-in-out;
}

@keyframes aiGlowPulse {
  0% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 2px #93c5fd); }
  100% { transform: scale(1.2) rotate(12deg); filter: drop-shadow(0 0 8px #ffffff); }
}

.default-notice {
  display: none;
  font-size: 13px;
  color: var(--subtext);
  font-weight: 500;
  text-align: center;
  margin-top: 10px;
}

/* Magic Building Animation */
.magic-loader {
  display: none;
  text-align: center;
  padding: 24px 0 8px;
}

.magic-wand {
  font-size: 36px;
  display: inline-block;
  animation: magicWandAnim 1.2s infinite alternate ease-in-out;
}

.building-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  margin-top: 10px;
}

.progress-bar-container {
  width: 160px;
  height: 5px;
  background: #e2e8f0;
  border-radius: 10px;
  margin: 12px auto 0;
  overflow: hidden;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-glow));
  border-radius: 10px;
  animation: fillProgress 0.9s ease-in-out forwards;
}

@keyframes magicWandAnim {
  0% { transform: rotate(0deg) scale(1); }
  100% { transform: rotate(25deg) scale(1.15); }
}

@keyframes fillProgress {
  0% { width: 0%; }
  100% { width: 100%; }
}

/* Modal Overlay UI */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--card-bg);
  border-radius: 20px;
  max-width: 460px;
  width: 100%;
  padding: 28px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.9);
  animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalPop {
  0% { opacity: 0; transform: scale(0.92) translateY(10px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close-btn {
  position: absolute;
  top: 16px; right: 16px;
  background: #f1f5f9;
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  color: var(--subtext);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.modal-close-btn:hover { background: #e2e8f0; }

.ready-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--success);
  background: #f0fdf4;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  border: 1px solid #bbf7d0;
}

.qr-box {
  display: inline-block;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.03);
}

.qr-detected-tag {
  display: inline-block;
  margin-bottom: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.tag-lao-domain { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.tag-lao-qr { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* Advanced Collapsible Toggle */
.toggle-advanced-btn {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--subtext);
  cursor: pointer;
  margin-bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  width: 100%;
  justify-content: center;
}

.toggle-advanced-btn:hover { background: #f1f5f9; color: var(--text); }

.advanced-panel {
  display: none;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.advanced-panel.open { display: flex; }

.option-row { display: flex; flex-direction: column; gap: 8px; }
.option-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--subtext);
}

.color-swatches { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { box-shadow: 0 0 0 2px var(--primary); }

.color-picker-input {
  width: 32px; height: 32px;
  border: none; background: none;
  cursor: pointer; padding: 0;
}

.emoji-input-group { display: flex; align-items: center; gap: 10px; }
.emoji-input {
  width: 46px; height: 38px;
  text-align: center;
  font-size: 20px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none; background: #ffffff;
  transition: border-color 0.2s;
}

.emoji-input:focus { border-color: var(--primary); }

.emoji-size-btns { display: flex; gap: 4px; background: #e2e8f0; padding: 2px; border-radius: 8px; }
.size-btn {
  background: transparent;
  border: none; border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  color: var(--subtext); cursor: pointer;
  transition: all 0.2s;
}

.size-btn.active { background: #ffffff; color: var(--primary); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

.stamp-options { display: flex; flex-wrap: wrap; gap: 16px; }
.stamp-option-label {
  font-size: 13px; font-weight: 500;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
}

.stamp-option-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.action-btn-group { display: flex; justify-content: center; gap: 12px; }
.action-btn {
  flex: 1; background: #ffffff;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; transition: all 0.2s ease;
}

.action-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-share { background: var(--primary); color: #ffffff; border-color: var(--primary); box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2); }
.btn-share:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

/* History Card */
.history-card {
  display: none;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.history-header h3 { font-size: 15px; font-weight: 700; }

.clear-history-btn {
  background: none; border: none;
  color: #ef4444; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  padding: 4px 8px; border-radius: 4px;
  transition: background 0.15s;
}

.clear-history-btn:hover { background: #fef2f2; }

.history-list { list-style: none; max-height: 180px; overflow-y: auto; }
.history-item {
  font-size: 13px; padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px; background: #ffffff;
  border: 1px solid var(--border);
  cursor: pointer; display: flex;
  justify-content: space-between; align-items: center;
  transition: all 0.15s;
}

.history-item:hover { border-color: var(--primary); transform: translateX(2px); }
.history-url { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; color: var(--text); font-weight: 500; }
.history-date { font-size: 11px; color: var(--subtext); }

/* Contact */
.contact-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px; text-align: center;
  box-shadow: var(--shadow-sm);
}

.contact-card p { font-size: 13px; color: var(--subtext); margin-bottom: 4px; }
.contact-email { color: var(--primary); font-weight: 600; font-size: 14px; text-decoration: none; }
.contact-email:hover { text-decoration: underline; }

footer { margin-top: 28px; font-size: 12px; color: #94a3b8; text-align: center; line-height: 1.6; }
footer a { color: var(--primary); text-decoration: none; font-weight: 500; }
footer a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  body { padding: 20px 12px; }
  .input-group { flex-direction: column; }
  .generate-btn { width: 100%; }
  .action-btn-group { flex-direction: column; }
}