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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222633;
  --border: #2e3345;
  --text: #e8eaed;
  --text-muted: #9aa0b0;
  --accent: #6c63ff;
  --accent-hover: #7b73ff;
  --accent-dim: rgba(108, 99, 255, 0.15);
  --success: #4caf50;
  --warning: #ff9800;
  --warning-bg: rgba(255, 152, 0, 0.1);
  --warning-border: rgba(255, 152, 0, 0.3);
  --radius: 8px;
  --radius-sm: 4px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  --mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", Consolas, monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== Header ===== */
.site-header {
  padding: 32px 0 24px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.site-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.accent {
  color: var(--accent);
}

.subtitle {
  color: var(--text-muted);
  margin-top: 4px;
  font-size: 1.05rem;
}

/* ===== Sections ===== */
.section {
  margin-top: 28px;
}

.section h2 {
  font-size: 1.15rem;
  margin-bottom: 6px;
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

/* ===== Warnings ===== */
.warnings {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 20px;
}

.warning-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--warning);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.warning-content strong {
  color: var(--warning);
}

.warning-content ul {
  margin-top: 4px;
  padding-left: 18px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.warning-content li {
  margin-top: 2px;
}

/* ===== Stacks Grid ===== */
.stacks-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stack-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.stack-btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.stack-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* ===== Search ===== */
.search-wrap {
  position: relative;
  margin-top: 24px;
}

.search-wrap input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px 10px 40px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-wrap input:focus {
  border-color: var(--accent);
}

.search-wrap input::placeholder {
  color: var(--text-muted);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* ===== Main Layout ===== */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

/* ===== Picker Panel ===== */
.picker-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.category {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.category-header:hover {
  background: var(--surface-hover);
}

.category-toggle {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.category.collapsed .category-toggle {
  transform: rotate(-90deg);
}

.category.collapsed .category-items {
  display: none;
}

.category-items {
  padding: 4px 14px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.item-check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 0.88rem;
  cursor: pointer;
  min-width: 140px;
}

.item-check.hidden {
  display: none;
}

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

.item-check span {
  color: var(--text-muted);
  transition: color 0.1s ease;
}

.item-check:hover span {
  color: var(--text);
}

.item-check input:checked + span {
  color: var(--text);
}

.category-empty {
  display: none;
  padding: 8px 14px 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.category.all-hidden .category-items {
  display: none;
}

.category.all-hidden .category-empty {
  display: block;
}

/* ===== Preview Panel ===== */
.preview-panel {
  position: sticky;
  top: 16px;
  align-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.preview-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-secondary.copied {
  color: var(--success);
  border-color: var(--success);
}

.preview-info {
  padding: 40px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.preview-code {
  margin: 0;
  padding: 14px;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-muted);
  overflow-x: auto;
  max-height: 70vh;
  overflow-y: auto;
  white-space: pre;
  tab-size: 2;
}

.preview-code::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.preview-code::-webkit-scrollbar-track {
  background: transparent;
}

.preview-code::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ===== SEO Content ===== */
.seo-content {
  margin-top: 40px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.seo-content h2 {
  font-size: 1.3rem;
  margin-bottom: 12px;
}

.seo-content h3 {
  font-size: 1.05rem;
  margin-top: 20px;
  margin-bottom: 8px;
}

.seo-content p,
.seo-content li {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

.seo-content ul,
.seo-content ol {
  padding-left: 22px;
  margin-top: 6px;
}

.seo-content li {
  margin-top: 4px;
}

.seo-content code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--accent);
}

/* ===== Ad Slots ===== */
.ad-slot {
  margin: 24px 0;
  min-height: 50px;
}

/* ===== Footer ===== */
.site-footer {
  margin-top: 48px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }

  .site-header h1 {
    font-size: 1.5rem;
  }

  .seo-content {
    padding: 20px 16px;
  }

  .category-items {
    gap: 4px 12px;
  }

  .item-check {
    min-width: 120px;
  }
}

@media (max-width: 480px) {
  .stacks-grid {
    gap: 6px;
  }

  .stack-btn {
    font-size: 0.8rem;
    padding: 5px 10px;
  }

  .item-check {
    min-width: 100%;
  }
}
