:root {
  --bg-dark: #080b11;
  --card-dark: #0f1623;
  --border-dark: #1e293b;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
}

/* Custom Slick Dark Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: #090d16;
}
::-webkit-scrollbar-thumb {
  background: #223249;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}
* {
  scrollbar-width: thin;
  scrollbar-color: #223249 #090d16;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body.dark-theme {
  font-family: system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.ambient-glow {
  position: absolute;
  top: -150px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 450px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.15) 0%, rgba(16, 185, 129, 0.08) 40%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Header */
.studio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border-dark);
  background: rgba(8, 11, 17, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 1.35rem; font-weight: 800; display: flex; align-items: center; gap: 8px; color: #fff; }
.spark-icon { width: 22px; height: 22px; color: var(--accent-cyan); }
.logo .highlight { color: var(--accent-cyan); }
.studio-badge { font-size: 0.72rem; background: rgba(6, 182, 212, 0.12); color: var(--accent-cyan); border: 1px solid rgba(6, 182, 212, 0.3); padding: 2px 8px; border-radius: 12px; font-weight: 700; }

.header-center { display: flex; align-items: center; gap: 12px; }
.pill-badge { font-size: 0.8rem; background: #131d2e; color: #cbd5e1; padding: 5px 12px; border-radius: 20px; border: 1px solid #1e293b; }
.pricing-tag { color: var(--accent-green); border-color: rgba(16, 185, 129, 0.3); }

.header-right { display: flex; align-items: center; gap: 16px; }
.nav-link { color: var(--text-muted); text-decoration: none; font-size: 0.88rem; font-weight: 600; }
.nav-link:hover { color: #fff; }
.btn-account { background: #1e293b; color: #fff; text-decoration: none; padding: 6px 16px; border-radius: 8px; font-size: 0.86rem; font-weight: 600; border: 1px solid #334155; }

/* Container & Hero */
.studio-container { max-width: 1300px; margin: 0 auto; padding: 36px 20px 60px; position: relative; z-index: 1; }
.hero-title-area { text-align: center; margin-bottom: 28px; }
.main-tagline { font-size: 2.3rem; font-weight: 800; letter-spacing: -0.5px; background: linear-gradient(135deg, #fff 40%, var(--accent-cyan) 100%); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sub-tagline { font-size: 1rem; color: var(--text-muted); margin-top: 6px; }

/* Central KlingAI Console */
.ai-console-card {
  background: var(--card-dark);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  padding: 16px;
  margin-bottom: 44px;
}
.console-body { display: flex; gap: 14px; align-items: flex-start; }
.upload-trigger-btn {
  background: #162033;
  border: 1px dashed rgba(6, 182, 212, 0.4);
  border-radius: 12px;
  width: 90px;
  height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  color: var(--accent-cyan);
  transition: 0.2s;
  flex-shrink: 0;
}
.upload-trigger-btn:hover { background: #1e2b45; border-color: var(--accent-cyan); }
.upload-trigger-btn svg { width: 22px; height: 22px; margin-bottom: 4px; }
.upload-trigger-btn span { font-size: 0.72rem; font-weight: 600; text-align: center; padding: 0 4px; }

textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 0.98rem;
  line-height: 1.5;
  resize: none;
  font-family: inherit;
  min-height: 130px;
}
textarea::placeholder { color: #64748b; }

.console-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  margin-top: 10px;
  border-top: 1px solid var(--border-dark);
}
.controls-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.custom-select-wrap { display: flex; align-items: center; gap: 6px; background: #141c2c; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border-dark); }
.custom-select-wrap label { font-size: 0.75rem; color: #64748b; font-weight: 700; }
.custom-select-wrap select { background: transparent; border: none; outline: none; color: #cbd5e1; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.custom-select-wrap select option { background: #0f172a; color: #fff; }

.active-tpl-pill { font-size: 0.8rem; color: var(--text-muted); background: #141c2c; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-dark); }
.active-tpl-pill strong { color: var(--accent-cyan); }

.btn-generate-glow {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 0.94rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.35);
  transition: 0.2s;
}
.btn-generate-glow:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(16, 185, 129, 0.5); }
.btn-icon { width: 18px; height: 18px; }

/* Tabs & 25 Themes Grid */
.gallery-section { margin-top: 10px; }
.gallery-header { margin-bottom: 22px; }
.gallery-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.tab-btn {
  background: #111827;
  color: var(--text-muted);
  border: 1px solid var(--border-dark);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.2s;
}
.tab-btn:hover { color: #fff; border-color: #334155; }
.tab-btn.active { background: #1e293b; color: #fff; border-color: var(--accent-cyan); }

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.tpl-card {
  background: var(--card-dark);
  border: 1px solid var(--border-dark);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: 0.25s;
  position: relative;
  display: flex;
  flex-direction: column;
}
.tpl-card:hover { transform: translateY(-3px); border-color: rgba(6, 182, 212, 0.4); box-shadow: 0 8px 24px rgba(0,0,0,0.5); }
.tpl-card.selected { border-color: var(--accent-cyan); box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.4); }

.tpl-thumbnail-wrapper {
  background: #ffffff;
  border-radius: 8px;
  height: 270px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
.tpl-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.3s ease;
}
.tpl-card:hover .tpl-thumb-img {
  transform: scale(1.04);
}
.tpl-accent-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.tpl-card-info { margin-top: 10px; display: flex; justify-content: space-between; align-items: center; }
.tpl-name { font-size: 0.86rem; font-weight: 700; color: #f1f5f9; }
.tpl-tag { font-size: 0.7rem; color: #64748b; font-weight: 600; text-transform: uppercase; }

/* Modal Live Preview Canvas */
.preview-modal { position: fixed; inset: 0; z-index: 999; display: flex; justify-content: center; align-items: center; padding: 20px; }
.preview-modal.hidden { display: none !important; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 7, 12, 0.88); backdrop-filter: blur(10px); }
.modal-content {
  position: relative;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px;
  width: 900px;
  max-width: 95vw;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
}

.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid #1e293b; background: #0b111e; }
.modal-title-wrap { display: flex; align-items: center; gap: 12px; }
.modal-title-wrap h2 { font-size: 1.15rem; color: #fff; }
.badge-locked { font-size: 0.74rem; background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); padding: 3px 8px; border-radius: 10px; font-weight: 700; }
.badge-unlocked { font-size: 0.74rem; background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); padding: 3px 8px; border-radius: 10px; font-weight: 700; }

.modal-actions-top { display: flex; align-items: center; gap: 10px; }
.modal-tpl-select { background: #1e293b; color: #fff; border: 1px solid #475569; padding: 5px 10px; border-radius: 6px; font-size: 0.82rem; font-weight: 600; }
.modal-close-btn { background: transparent; border: none; color: #94a3b8; font-size: 1.6rem; cursor: pointer; line-height: 1; }
.modal-close-btn:hover { color: #fff; }

.suggestions-bar { background: #111a2e; border-bottom: 1px solid #1e293b; padding: 12px 20px; font-size: 0.84rem; color: #cbd5e1; }
.sugg-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sugg-sub { font-size: 0.74rem; color: #64748b; }
.chips-container { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; max-height: 85px; overflow-y: auto; }
.chip-btn {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}
.chip-btn:hover { background: rgba(6, 182, 212, 0.25); border-color: var(--accent-cyan); }
.refine-flex { display: flex; gap: 12px; align-items: stretch; }
.refine-flex textarea {
  flex: 1;
  background: #090e1a;
  border: 1px solid #334155;
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.5;
  min-height: 85px;
  resize: vertical;
}
.refine-flex textarea:focus { border-color: var(--accent-cyan); outline: none; }
.btn-refine {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
  min-height: 85px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body-scroll { flex: 1; overflow-y: auto; padding: 24px 20px; background: #080d17; display: flex; justify-content: center; }

/* A4 Paper */
.a4-paper {
  background: #ffffff;
  color: #1f2937;
  width: 100%;
  max-width: 780px;
  min-height: 800px;
  padding: 36px 40px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  font-size: 9.2pt;
  line-height: 1.42;
  user-select: none;
}
.a4-paper h3 { font-size: 18pt; font-weight: 700; margin: 0; }
.a4-paper .doc-head { font-size: 11pt; font-weight: 600; margin: 3px 0; }
.a4-paper .doc-contact { font-size: 8.8pt; color: #4b5563; }
.a4-paper .doc-sec { font-size: 10.5pt; font-weight: 700; text-transform: uppercase; margin-top: 14px; border-bottom: 1px solid; padding-bottom: 2px; }
.a4-paper table { width: 100%; border-collapse: collapse; margin-top: 6px; margin-bottom: 8px; }
.a4-paper th { padding: 5px 7px; color: #fff; font-size: 8.5pt; text-align: left; border: 1px solid #cbd5e1; }
.a4-paper td { padding: 5px 7px; font-size: 8.5pt; border: 1px solid #cbd5e1; }
.a4-paper ul { margin: 3px 0 0 16px; padding: 0; }
.a4-paper li { margin-bottom: 2.5px; }

.modal-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: #0b111e;
  border-top: 1px solid #1e293b;
}
.pricing-info { display: flex; flex-direction: column; }
.price-val { font-size: 1.05rem; font-weight: 800; color: #10b981; }
.price-sub { font-size: 0.76rem; color: #94a3b8; }

.btn-unlock-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
.download-flex { display: flex; gap: 10px; }
.btn-dl { padding: 9px 18px; border-radius: 8px; text-decoration: none; font-size: 0.88rem; font-weight: 700; color: #fff; }
.btn-dl.pdf { background: #dc2626; }
.btn-dl.docx { background: #2563eb; }

.error-banner { background: rgba(220, 38, 38, 0.15); border: 1px solid #dc2626; color: #f87171; padding: 8px 12px; border-radius: 8px; margin-top: 10px; font-size: 0.85rem; }
.hidden { display: none !important; }

.btn-secondary { background: var(--primary); color: #fff; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-weight: 600; }

.a4-paper { border: 1px solid #e5e7eb; padding: 22px; border-radius: 6px; background: #fff; min-height: 360px; user-select: none; }
.a4-paper h3 { color: var(--primary); font-size: 1.35rem; }
.a4-paper .doc-head { font-weight: 600; color: #4b5563; font-size: 0.92rem; margin-bottom: 4px; }
.a4-paper .doc-sec { margin-top: 14px; border-bottom: 1px solid #e5e7eb; font-weight: 700; font-size: 0.9rem; color: var(--primary); text-transform: uppercase; }
.a4-paper ul { margin: 6px 0 0 18px; font-size: 0.9rem; }

.download-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.btn-download { text-align: center; padding: 12px; border-radius: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 0.92rem; }
.btn-download.pdf { background: #dc2626; }
.btn-download.docx { background: #1d4ed8; }
.error-box { background: #fee2e2; color: #991b1b; padding: 10px; border-radius: 6px; margin-top: 10px; font-size: 0.88rem; }
.hidden { display: none !important; }

.template-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; background: #f8fafc; padding: 8px; border-radius: 8px; border: 1px solid #e2e8f0; }
.tpl-btn { border: 1px solid #cbd5e1; background: #fff; padding: 5px 10px; border-radius: 6px; font-size: 0.8rem; font-weight: 600; cursor: pointer; }
.tpl-btn.active { background: #1e3a8a; color: #fff; border-color: #1e3a8a; }

/* Live Preview Theme Variations */
.a4-paper.modern_slate .doc-header-box { background: #f0fdfa; border-left: 4px solid #0f766e; padding: 10px; }
.a4-paper.modern_slate h3, .a4-paper.modern_slate .doc-sec { color: #0f766e; border-bottom-color: #99f6e4; }
.a4-paper.ats_minimal { font-family: Georgia, serif; }
.a4-paper.ats_minimal h3, .a4-paper.ats_minimal .doc-sec { color: #111827; border-bottom-color: #111827; }
.a4-paper.royal_marriage .doc-header-box { border: 2px solid #d97706; background: #fffbeb; padding: 10px; text-align: center; }
.a4-paper.royal_marriage h3, .a4-paper.royal_marriage .doc-sec { color: #881337; border-bottom-color: #d97706; }