:root {
  --bg: #ffffff;
  --bg-alt: #f7faf7;
  --text: #1a1a1a;
  --text-muted: #666666;
  --accent: #5aaa5a;
  --accent-hover: #4a9a4a;
  --border: #e0e0e0;
  --code-bg: #f5f5f5;
  --code-text: #1a1a1a;
  --shadow: rgba(0, 0, 0, 0.05);
  --nav-bg: rgba(255, 255, 255, 0.92);
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-alt: #222222;
  --text: #e8e8e8;
  --text-muted: #888888;
  --accent: #6aba6a;
  --accent-hover: #7aca7a;
  --border: #333333;
  --code-bg: #2a2a2a;
  --code-text: #e0e0e0;
  --shadow: rgba(0, 0, 0, 0.3);
  --nav-bg: rgba(26, 26, 26, 0.92);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  transition: background 0.2s, color 0.2s;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Nav */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

nav {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--accent);
  text-decoration: none;
}
.logo:visited {
  color: #5aaa5a;
  text-decoration: none;
}
[data-theme="dark"] .logo:visited {
  color: #6aba6a;
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-links a {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.nav-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1;
}

#theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Layout */

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 36px 0;
}

.section-alt {
  background: var(--bg-alt);
}

h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.section-desc {
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* Hero */

.hero {
  text-align: center;
  padding: 44px 24px 36px;
  max-width: 960px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: -2px;
  color: var(--text);
  margin-bottom: 12px;
}

.tagline {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.hero-pills {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pill {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hero-badges {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.badge {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

a.badge:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #ffffff;
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.15s;
  text-decoration: none;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #ffffff;
  text-decoration: none;
}

/* Demo section */

.demo-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.demo-controls input,
.demo-controls select {
  font-size: 0.95rem;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.demo-controls input {
  flex: 1;
  min-width: 200px;
}

.demo-controls input:focus,
.demo-controls select:focus {
  border-color: var(--accent);
}

.demo-controls select {
  cursor: pointer;
}

.demo-output {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 640px) {
  .demo-output {
    grid-template-columns: 1fr;
  }
}

.demo-diagram-wrap {
  min-width: 120px;
}

#demo-diagram svg {
  display: block;
}

.demo-error {
  color: #cc4444;
  font-size: 0.9rem;
  margin-top: 8px;
}

.demo-code-wrap {
  min-width: 0;
}

.code-header-sm {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.code-block-sm {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  font-size: 0.82rem;
  overflow-x: auto;
  white-space: pre;
  color: var(--code-text);
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  line-height: 1.5;
  min-height: 60px;
}

/* Showcase */

.showcase-group {
  margin-bottom: 28px;
}

.showcase-group:last-child {
  margin-bottom: 0;
}

.showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 24px;
  align-items: start;
}

.showcase-grid--piano {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.showcase-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.diagram-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: auto;
  max-width: 100%;
}

.diagram-cell svg {
  display: block;
}

.showcase-item figcaption {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

/* Install */

.install-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  max-width: 720px;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--code-bg);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.code-block {
  background: var(--code-bg);
  padding: 20px;
  overflow-x: auto;
  white-space: pre;
  font-size: 0.88rem;
  color: var(--code-text);
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  line-height: 1.6;
  margin: 0;
}

.btn-copy {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
}

.btn-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* API */

.api-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.api-table th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.api-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.api-table tr:last-child td {
  border-bottom: none;
}

code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
}

.api-note {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Footer */

footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

.footer-copy {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Responsive */

@media (max-width: 600px) {
  .hero h1 {
    font-size: 2.8rem;
  }

  .nav-links a:not(:last-of-type) {
    display: none;
  }

  .showcase-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
  }

  .demo-controls {
    flex-direction: column;
  }

  .demo-controls input,
  .demo-controls select {
    width: 100%;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}
