/* --- Plus Jakarta Sans & Inter font styles loaded --- */
:root {
  /* Ultra-modern professional aesthetic color palette (No gradients) */
  --bg: #090d16;
  --surface: #101622;
  --surface-2: #1e2638;
  --surface-3: #2e394e;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: #4f46e5;
  --text: #f9fafb;
  --text-muted: #9ca3af;
  
  /* Brand colors - Flat and Premium */
  --accent: #4f46e5;       /* Premium Indigo */
  --accent-hover: #3f37c9; /* Deep Indigo */
  --accent-2: #10b981;     /* Emerald Accent replacing flashy fuchsia */
  --accent-gradient: var(--accent); /* Flat fallback for gradient refs */
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 16px 36px -12px rgba(0, 0, 0, 0.5);
  --max-width: 1600px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header design */
header {
  border-bottom: 1px solid var(--border);
  background: rgba(9, 14, 26, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
}

.brand span {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.15rem;
  display: inline-block;
}

.header-actions {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Premium Buttons */
.btn {
  border: 1px solid transparent;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

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

.btn-secondary:hover {
  background: var(--surface-3);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ffffff;
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* Toggles (Mode, Lang) */
.lang-toggle, .mode-toggle {
  display: flex;
  gap: 0.15rem;
  background: var(--surface-2);
  padding: 0.25rem;
  border-radius: 100px;
  border: 1px solid var(--border);
}

.lang-toggle button, .mode-toggle button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: 100px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.lang-toggle button.active, .mode-toggle button.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Layout */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 1fr 480px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1200px) {
  main {
    grid-template-columns: 1fr;
  }
}

/* Modern Card/Panel layout */
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: border-color 0.3s ease;
}

.panel h2 {
  margin: 0 0 1.25rem;
  font-size: 1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-2);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Form Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
}

label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.required {
  color: var(--danger);
  font-size: 0.85rem;
}

/* Premium Form Elements */
input, select, textarea {
  background: rgba(9, 14, 26, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

input:hover, select:hover, textarea:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  background: rgba(9, 14, 26, 0.75);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

input.error, select.error, textarea.error {
  border-color: rgba(239, 68, 68, 0.6);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.12);
}

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

.error-msg {
  color: #fca5a5;
  font-size: 0.75rem;
  font-weight: 600;
  display: none;
  margin-top: 0.25rem;
}

.error-msg.show {
  display: block;
}

.counter {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-align: right;
  margin-top: 0.25rem;
}

.counter.over {
  color: #f87171;
  font-weight: 800;
}

.color-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

input[type="color"] {
  width: 52px;
  height: 44px;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: inline-block;
}

/* Sections */
.section-group {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  margin-top: 1.5rem;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  letter-spacing: -0.01em;
}

.badge {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  font-size: 0.65rem;
  padding: 0.25rem 0.65rem;
  border-radius: 100px;
  font-weight: 800;
  border: 1px solid rgba(99, 102, 241, 0.25);
  text-transform: uppercase;
}

.section-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.section-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  background: rgba(9, 14, 26, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: move;
  transition: all 0.2s ease;
}

.section-item:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateX(2px);
}

.section-item.dragging {
  opacity: 0.4;
  border-color: var(--accent);
}

.section-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent-2);
  cursor: pointer;
}

.section-item span {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
}

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
  font-size: 1.15rem;
  user-select: none;
}

/* Asset Selector Interface */
.asset-toolbar {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1.25rem;
}

.asset-tabs {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.asset-tab {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 0.45rem 1rem;
  border-radius: 100px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.asset-tab:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

.asset-tab.active {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.asset-search {
  flex: 1;
  min-width: 200px;
  padding: 0.6rem 0.9rem;
  font-size: 0.875rem;
}

.asset-filter {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 1rem;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 0.6rem;
}

.asset-grid.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.asset-grid.loading::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 4px solid var(--surface-2);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: asset-spin .75s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

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

/* Asset Cards */
.asset-card {
  position: relative;
  background: rgba(9, 14, 26, 0.4);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.asset-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.4);
}

.asset-card.selected {
  border-color: var(--accent);
  background: rgba(79, 70, 229, 0.08);
}

.asset-card.hero {
  border-color: var(--accent-2);
  background: rgba(16, 185, 129, 0.06);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
}

.asset-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.asset-card:hover img {
  transform: scale(1.05);
}

.asset-info {
  padding: 0.75rem;
}

.asset-name {
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #f3f4f6;
}

.asset-price {
  color: var(--accent-2);
  font-weight: 800;
  font-size: 0.75rem;
  margin-top: 0.4rem;
  letter-spacing: -0.01em;
}

.asset-check, .asset-hero-badge {
  position: absolute;
  top: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: scale(0.8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.asset-check {
  right: 8px;
  background: var(--accent);
  color: #ffffff;
}

.asset-hero-badge {
  left: 8px;
  background: var(--accent-2);
  color: #ffffff;
}

.asset-card.selected .asset-check {
  opacity: 1;
  transform: scale(1);
}

.asset-card.hero .asset-hero-badge {
  opacity: 1;
  transform: scale(1);
}

/* Hero Preview Frame */
.hero-preview {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(9, 14, 26, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: none;
  align-items: center;
  gap: 1rem;
}

.hero-preview.show {
  display: flex;
}

.hero-preview img {
  width: 100px;
  height: 70px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Output Tabbed Panel */
.output-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: var(--surface-2);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.output-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.output-tab.active {
  background: var(--surface-3);
  color: #ffffff;
}

pre {
  background: #050811;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow: auto;
  max-height: 58vh;
  font-family: "Fira Code", "Courier New", monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  color: #a5b4fc;
}

/* Validation status notification */
.validation-status {
  margin-bottom: 1.25rem;
  padding: 0.9rem 1.15rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  display: none;
  border: 1px solid transparent;
}

.validation-status.error {
  display: block;
  background: rgba(239, 68, 68, 0.08);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.25);
}

.validation-status.success {
  display: block;
  background: rgba(16, 185, 129, 0.08);
  color: #a7f3d0;
  border-color: rgba(16, 185, 129, 0.25);
}

.preset-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.preset-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 210px;
}

/* Modern Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transform: translateY(150%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toast.show {
  transform: translateY(0);
}

#outputPanel {
  position: sticky;
  top: 110px;
  align-self: start;
}

/* Custom Scrollbar design */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Added Layouts for harmony buttons, etc. --- */
#colorPalette {
  width: 100%;
}

.harmony-btn {
  margin-top: 0.5rem;
  width: 100%;
  justify-content: center;
}

.color-warning {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
}

.color-warning .hint {
  color: #fcd34d;
  margin: 0;
  font-weight: 600;
}

#assetHint {
  margin: 0.75rem 0 0.5rem;
  font-weight: 600;
}

/* Mobile Sticky Asset Bar */
.mobile-asset-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(17, 25, 39, 0.95);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.9rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  z-index: 100;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
}

.mobile-asset-bar span {
  font-size: 0.85rem;
  font-weight: 700;
}

#mobileAssetCount {
  color: var(--accent-2);
}

#mobileHeroName {
  color: var(--text);
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Responsive Adjustments --- */
@media (max-width: 1200px) {
  #outputPanel {
    position: static;
    top: auto;
  }
}

@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 1.25rem;
  }
  
  .brand {
    text-align: center;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .preset-row {
    flex-direction: column;
    align-items: stretch;
  }

  .preset-select {
    width: 100%;
    min-width: auto;
  }

  .mode-toggle, .lang-toggle {
    justify-content: center;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .mode-toggle button, .lang-toggle button {
    flex: 1;
    text-align: center;
    padding: 0.55rem;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  main {
    padding: 1rem;
    gap: 1.25rem;
  }

  .panel {
    padding: 1.25rem;
  }

  .section-title {
    font-size: 1rem;
  }

  .section-item {
    padding: 0.85rem;
  }

  .asset-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .asset-tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.4rem;
  }

  .asset-tab {
    white-space: nowrap;
  }

  .asset-search, .asset-filter {
    width: 100%;
  }

  .hero-preview {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-preview img {
    width: 100%;
    height: 120px;
  }

  /* Optimized Mobile Grid columns */
  .asset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    max-height: 520px;
  }

  .asset-card img {
    height: 110px;
  }

  .asset-info {
    padding: 0.6rem;
  }

  .asset-name {
    font-size: 0.78rem;
  }

  .asset-price {
    font-size: 0.75rem;
  }

  .output-tabs {
    flex-direction: column;
  }

  pre {
    max-height: 50vh;
    font-size: 0.78rem;
  }

  .toast {
    left: 1rem;
    right: 1rem;
    bottom: 5rem; /* Give room above mobile summary bar */
    text-align: center;
  }
}

@media (max-width: 480px) {
  .asset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
  }
  
  .asset-card img {
    height: 100px;
  }
}