:root {
  --bg: #f7f8fa;
  --bg-elevated: #ffffff;
  --text: #1b2230;
  --text-muted: #565f70;
  --border: #e0e3e9;
  --accent: #0d7d7d;
  --accent-strong: #095e5e;
  --accent-contrast: #ffffff;
  --code-bg: #eef1f5;
  --shadow: 0 1px 2px rgba(20, 25, 35, 0.06), 0 4px 16px rgba(20, 25, 35, 0.05);
  --radius: 10px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10141c;
    --bg-elevated: #171d29;
    --text: #e7ebf3;
    --text-muted: #99a3b6;
    --border: #2a3242;
    --accent: #35c2c1;
    --accent-strong: #6fe0df;
    --accent-contrast: #08221f;
    --code-bg: #1c2331;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg: #10141c;
  --bg-elevated: #171d29;
  --text: #e7ebf3;
  --text-muted: #99a3b6;
  --border: #2a3242;
  --accent: #35c2c1;
  --accent-strong: #6fe0df;
  --accent-contrast: #08221f;
  --code-bg: #1c2331;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

code,
pre,
.mono {
  font-family: var(--mono);
}

code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.88em;
}

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

/* ---- Nav ---- */

header.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

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

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

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

.nav-links {
  display: flex;
  gap: 1.6rem;
  align-items: center;
}

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

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

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  width: 38px;
  height: 38px;
  font-size: 1.1rem;
  cursor: pointer;
}

.nav-utils {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: 0.6rem;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.lang-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  background-color: var(--bg-elevated);
  background-image: linear-gradient(
      145deg,
      color-mix(in srgb, var(--accent) 14%, transparent),
      transparent 65%
    ),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%238a94a6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-position:
    0 0,
    right 0.6rem center;
  background-size:
    100% 100%,
    11px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.32rem 1.7rem 0.32rem 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.lang-select:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.lang-select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent);
}

.lang-select:active {
  transform: scale(0.96);
}

.lang-select::-ms-expand {
  display: none;
}

.lang-select option {
  color: var(--text);
  background: var(--bg-elevated);
  font-weight: 500;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

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

@media (max-width: 640px) {
  .nav-utils {
    margin: 0.4rem 0 0.6rem;
    padding: 0.6rem 20px 0;
    border-left: none;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    width: 100%;
  }

  .nav-links {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 0.5rem 0;
    display: none;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 0.7rem 20px;
    width: 100%;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* ---- Hero ---- */

.hero {
  padding: 4.5rem 0 3rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  margin: 0 0 0.6rem;
  letter-spacing: -0.02em;
}

.hero .tagline {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto 1.8rem;
}

.hero .pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  margin-bottom: 1.4rem;
}

.cta-row {
  display: flex;
  gap: 0.9rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.3rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
}

.btn:hover {
  text-decoration: none;
}

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

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

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

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

/* ---- Sections ---- */

section {
  padding: 3rem 0;
}

section.alt {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* Bands nested inside a padded container need their own inset. */
.container > section.alt {
  padding-left: 1.6rem;
  padding-right: 1.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

@media (max-width: 640px) {
  .container > section.alt {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

h2 {
  font-size: 1.7rem;
  margin-bottom: 0.3rem;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.15rem;
  margin-bottom: 0.4rem;
}

.section-intro {
  color: var(--text-muted);
  max-width: 640px;
  margin-bottom: 2rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.2rem;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow);
}

.card .index {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.card p {
  color: var(--text-muted);
  margin: 0.4rem 0 0;
  font-size: 0.95rem;
}

/* ---- Diagram ---- */

.diagram-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.diagram-wrap svg {
  display: block;
  margin: 0 auto;
  min-width: 640px;
}

.diagram-wrap text {
  fill: var(--text);
  font-family: var(--sans);
}

.diagram-wrap .muted-text {
  fill: var(--text-muted);
}

.diagram-wrap .box {
  fill: var(--bg);
  stroke: var(--border);
}

.diagram-wrap .box-accent {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 1.6;
}

.diagram-wrap .arrow {
  stroke: var(--text-muted);
  stroke-width: 1.4;
  fill: none;
}

.diagram-wrap .arrow-accent {
  stroke: var(--accent);
  stroke-width: 1.6;
  fill: none;
}

.diagram-wrap marker path {
  fill: var(--text-muted);
}

.diagram-wrap marker.accent path {
  fill: var(--accent);
}

/* ---- Tables ---- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.6rem;
  font-size: 0.92rem;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td code {
  white-space: nowrap;
}

/* ---- Steps ---- */

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding: 0.2rem 0 1.6rem 3rem;
  border-left: 2px solid var(--border);
  margin-left: 1rem;
}

.steps li:last-child {
  border-color: transparent;
  padding-bottom: 0;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: -1.05rem;
  top: 0;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.steps h3 {
  margin-top: 0.15rem;
}

.steps p {
  color: var(--text-muted);
  margin: 0.3rem 0 0;
}

/* ---- Footer ---- */

footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0 3rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

footer .foot-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  justify-content: space-between;
  align-items: center;
}

footer a {
  color: var(--text-muted);
}

footer a:hover {
  color: var(--accent);
}

/* ---- Spec page (rendered markdown) ---- */

.spec-doc {
  max-width: 780px;
}

.spec-doc h1 {
  font-size: 2.1rem;
}

.spec-doc h2 {
  margin-top: 2.4rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.spec-doc h3,
.spec-doc h4 {
  margin-top: 1.6rem;
}

.spec-doc ul,
.spec-doc ol {
  color: var(--text);
}

.spec-doc blockquote {
  margin: 0;
  padding: 0.2rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

.spec-loading {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.9rem;
}

.badge-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.badge {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.55rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.85em;
}
