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

:root {
  --bg:        #0f1117;
  --surface:   #181b23;
  --surface-2: #1e222d;
  --border:    #2a2f3c;
  --text:      #e0e2e9;
  --text-mute: #8b8fa3;
  --accent:    #7c6af6;
  --accent-2:  #9b8afb;
  --green:     #34d399;
  --orange:    #f59e42;
  --blue:      #60a5fa;
  --red:       #f87171;
  --radius:    8px;
  --max-w:     1080px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; transition: color .15s; }
a:hover { color: #bfb0ff; }

/* ── Navigation ──────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,17,23,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 8px;
  overflow-x: auto;
}

.nav-logo {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  margin-right: 16px;
  letter-spacing: -.3px;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  color: var(--text-mute);
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active { background: var(--accent); color: #fff; }

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 64px 24px 48px;
}

.hero h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.2;
  margin-bottom: 12px;
}

.hero p {
  font-size: 17px;
  color: var(--text-mute);
  max-width: 640px;
  line-height: 1.6;
}

/* ── Section pages ───────────────────────────────────────── */
.page-header {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 56px 24px 24px;
}

.page-header h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.4px;
}

.page-header .subtitle {
  color: var(--text-mute);
  font-size: 16px;
  margin-top: 8px;
  max-width: 640px;
}

/* ── Card Grid ───────────────────────────────────────────── */
.card-grid {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color .2s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }

.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-mute);
}

.card-desc {
  font-size: 14px;
  color: var(--text-mute);
  line-height: 1.6;
  margin-bottom: 12px;
}

.card-when {
  font-size: 13px;
  color: var(--text-mute);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  border-left: 3px solid var(--accent);
}

.card-when strong {
  color: var(--text);
}

.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--accent); background: #252936; color: var(--text); }

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

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── Home category cards ─────────────────────────────────── */
.category-grid {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 64px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: border-color .2s, transform .15s;
  display: flex;
  flex-direction: column;
}
.category-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.category-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.category-card p {
  font-size: 14px;
  color: var(--text-mute);
  line-height: 1.6;
  flex: 1;
  margin-bottom: 16px;
}

.category-card .file-count {
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.category-accent-core     { border-top: 3px solid var(--accent); }
.category-accent-flutter  { border-top: 3px solid var(--blue); }
.category-accent-firebase { border-top: 3px solid var(--orange); }
.category-accent-supabase { border-top: 3px solid var(--green); }
.category-accent-ts       { border-top: 3px solid #3178c6; }
.category-accent-templates{ border-top: 3px solid var(--red); }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-mute);
}

/* ── Guide / How To page ─────────────────────────────────── */
.guide-content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px 64px;
}

.guide-section {
  margin-bottom: 48px;
}

.guide-section h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.guide-section > p {
  font-size: 15px;
  color: var(--text-mute);
  line-height: 1.7;
  margin-bottom: 20px;
}

.guide-section a { text-decoration: underline; text-underline-offset: 2px; }

.guide-diagram {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.diagram-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 180px;
}

.diagram-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.diagram-text { font-size: 13px; line-height: 1.5; }

.diagram-arrow {
  width: 20px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}

.step {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-body { flex: 1; min-width: 0; }
.step-body h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.step-body p { font-size: 14px; color: var(--text-mute); line-height: 1.7; margin-bottom: 10px; }
.step-body ul, .step-body ol { font-size: 14px; color: var(--text-mute); line-height: 1.7; padding-left: 20px; margin-bottom: 10px; }
.step-body li { margin-bottom: 4px; }

.step-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 12px;
}

.step-body code, .guide-section code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
}

.guide-section p code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.guide-tip {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-mute);
  line-height: 1.6;
  margin: 12px 0;
}
.guide-tip strong { color: var(--accent-2); }

.stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.stack-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stack-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.stack-card > p { font-size: 13px; color: var(--text-mute); margin-bottom: 10px; }
.stack-card ul { font-size: 13px; color: var(--text-mute); padding-left: 18px; line-height: 1.7; }

.strategy {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.strategy h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.strategy p { font-size: 14px; color: var(--text-mute); line-height: 1.7; margin-bottom: 10px; }
.strategy pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  overflow-x: auto;
  margin-bottom: 10px;
  font-size: 13px;
}

.verify-list { display: grid; gap: 14px; }

.verify-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.verify-item h3 { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.verify-item p { font-size: 13px; color: var(--text-mute); line-height: 1.6; }

.maintenance-list {
  font-size: 14px;
  color: var(--text-mute);
  line-height: 1.8;
  padding-left: 20px;
}
.maintenance-list li { margin-bottom: 6px; }
.maintenance-list strong { color: var(--text); }

/* ── FAQ-specific ────────────────────────────────────────── */
.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toc a {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-mute);
  transition: background .15s, border-color .15s, color .15s;
}
.toc a:hover { background: var(--surface-2); border-color: var(--accent); color: var(--text); }

.faq-subhead {
  font-size: 16px;
  font-weight: 700;
  margin: 24px 0 12px;
  color: var(--text);
}

.ref-table {
  overflow-x: auto;
  margin-bottom: 16px;
}

.ref-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.6;
}

.ref-table thead th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--text-mute);
  white-space: nowrap;
}

.ref-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.ref-table tbody tr:hover { background: var(--surface); }

.ref-table code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.col-yes, .col-no {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.col-yes { border-top: 3px solid var(--green); }
.col-no  { border-top: 3px solid var(--red); }

.col-yes h4, .col-no h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  margin-bottom: 8px;
}
.col-yes h4 { color: var(--green); }
.col-no  h4 { color: var(--red); }

.col-yes ul, .col-no ul {
  font-size: 13px;
  color: var(--text-mute);
  padding-left: 18px;
  line-height: 1.7;
}

.context-order {
  font-size: 14px;
  color: var(--text-mute);
  padding-left: 20px;
  line-height: 1.8;
}
.context-order li { margin-bottom: 4px; }
.context-order strong { color: var(--text); }

@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }
  .diagram-arrow { display: none; }
  .diagram-item { min-width: 100%; }
}

/* ── File viewer modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: translateY(12px);
  transition: transform .2s;
}
.modal-overlay.open .modal-box { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 14px;
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: var(--accent-2);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-mute);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  margin: 0;
  padding: 20px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  white-space: pre-wrap;
  word-wrap: break-word;
  border-radius: 0 0 10px 10px;
  tab-size: 2;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .hero h1 { font-size: 26px; }
  .page-header h1 { font-size: 24px; }
  .category-grid { grid-template-columns: 1fr; }
  .nav-inner { gap: 4px; }
  .nav-link { font-size: 12px; padding: 5px 8px; }
}
