:root {
  --green: #1fa055;
  --green-light: #e8f7ee;
  --green-dark: #167a40;
  --text: #1a1a1a;
  --text-muted: #555;
  --border: #d0d0d0;
  --bg: #ffffff;
  --bg-alt: #f7f8f6;
  --radius: 8px;
  font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

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

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--green);
  text-decoration: none;
}
.site-header nav a {
  margin-left: 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.site-header nav a:hover { color: var(--green); }

/* Main layout */
.page-main {
  max-width: 780px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* Chips */
.meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1.5rem;
}
.chip {
  background: var(--green-light);
  color: var(--green-dark);
  border-radius: 100px;
  padding: 0.2rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Prose */
.prose {
  color: var(--text);
}
.prose p { margin: 0 0 1rem; }
.prose ul { padding-left: 1.5rem; margin: 0 0 1rem; }
.prose li { margin-bottom: 0.3rem; }
.prose strong { color: var(--text); }

/* Section spacing */
.prose-section,
.drill-section,
.faq-section,
.related-section {
  margin-top: 2.5rem;
}
.prose-section h2,
.drill-section h2,
.faq-section h2,
.related-section h2 {
  font-size: 1.35rem;
  margin: 0 0 1rem;
  color: var(--green-dark);
  border-bottom: 2px solid var(--green-light);
  padding-bottom: 0.35rem;
}

/* Drill mount */
#chessy-drill {
  background: var(--bg-alt);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
#chessy-drill::before { content: "Interactive drill loads here"; }

.cta-text {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.btn-cta {
  display: inline-block;
  background: var(--green);
  color: #fff;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.15s;
}
.btn-cta:hover { background: var(--green-dark); }

/* Win rate bar */
.win-rate-block {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-alt);
  border-radius: var(--radius);
}
.win-rate-block h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}
.wr-bar {
  display: flex;
  height: 2rem;
  border-radius: 4px;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 600;
}
.wr-white {
  background: #f0ede8;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
}
.wr-draw {
  background: #b8b8b8;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
}
.wr-black {
  background: #2a2a2a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  flex: 1;
}
.wr-legend {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.leg-white { color: #555; }
.leg-draw { color: #888; }
.leg-black { color: #333; }

/* Top moves table */
.top-moves-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.9rem;
}
.top-moves-table th {
  text-align: left;
  border-bottom: 2px solid var(--border);
  padding: 0.4rem 0.5rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.top-moves-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.move-san {
  font-family: monospace;
  font-weight: 700;
  color: var(--green-dark);
}

/* FAQ */
.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}
.faq-q {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-q::after { content: "+"; color: var(--green); font-size: 1.1rem; }
details[open] .faq-q::after { content: "−"; }
.faq-a {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Related */
.related-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.related-list li {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
}
.related-list a { color: var(--green-dark); text-decoration: none; font-weight: 600; }
.related-list a:hover { text-decoration: underline; }
.related-type { color: var(--text-muted); font-size: 0.8rem; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.site-footer a { color: var(--green-dark); }

/* Index page */
.index-intro { margin-bottom: 2rem; color: var(--text-muted); }
.opening-type-group { margin-bottom: 2rem; }
.opening-type-group h2 {
  font-size: 1.1rem;
  color: var(--green-dark);
  text-transform: capitalize;
  border-bottom: 2px solid var(--green-light);
  padding-bottom: 0.3rem;
  margin-bottom: 0.75rem;
}
.opening-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}
.opening-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.opening-card:hover {
  border-color: var(--green);
  box-shadow: 0 2px 8px rgba(31,160,85,0.12);
}
.opening-card .card-name { font-weight: 600; font-size: 0.95rem; }
.opening-card .card-eco { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }

@media (max-width: 600px) {
  .wr-bar { font-size: 0.7rem; }
  .wr-white, .wr-draw, .wr-black { min-width: 0; }
  .page-main { padding: 1.25rem 1rem 3rem; }
}
