:root {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-muted: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --line: #475569;
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --accent-soft: #134e4a;
  --maxw: 1120px;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

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

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

a:hover {
  text-decoration: underline;
}

p {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

h1,
h2,
h3 {
  margin: 0 0 0.75rem;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 650;
}

h2 {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 600;
  margin-top: 2rem;
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

ul,
ol {
  color: var(--text-muted);
  padding-left: 1.25rem;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.header-inner,
.main,
.site-footer-inner {
  width: min(var(--maxw), 92vw);
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 650;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: block;
  height: 1.625rem;
  width: auto;
  flex-shrink: 0;
  mix-blend-mode: screen;
}

.brand-name {
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand-open {
  color: var(--text);
}

.brand-glucose {
  color: #60a5fa;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
}

.nav a {
  color: var(--text-muted);
  font-size: 0.92rem;
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
}

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

.main {
  padding: 2.5rem 0 4rem;
}

.section {
  margin-bottom: 3rem;
}

.section-muted {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
}

.eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 0.75rem;
}

.lead {
  font-size: 1.125rem;
  text-wrap: pretty;
}

.hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero .lead {
  max-width: 42rem;
  margin: 0.75rem auto 1.5rem;
}

.section-muted .lead,
.section-muted > p {
  max-width: none;
}

.phrase-nowrap {
  white-space: nowrap;
}

@media (max-width: 480px) {
  .phrase-nowrap {
    white-space: normal;
  }
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.15rem;
  border-radius: 0.65rem;
  font-size: 0.92rem;
  font-weight: 560;
  border: 1px solid transparent;
  text-decoration: none;
  transition:
    background 150ms ease,
    border-color 150ms ease;
}

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

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

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

.btn-secondary:hover {
  background: var(--surface-muted);
  text-decoration: none;
}

.diagram-wrap {
  max-width: 720px;
  margin: 0 auto 1rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.diagram-wrap img,
.diagram-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.diagram-figure {
  display: block;
  width: 100%;
  max-width: 640px;
  margin: 0 auto 1rem;
}

.diagram-figure .diagram-wrap {
  margin-bottom: 0;
  width: 100%;
  max-width: 100%;
  padding: 1rem 1.25rem 0.375rem;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: none;
  border-bottom: none;
}

.diagram-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.diagram-caption {
  padding: 0.625rem 1.25rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}

.diagram-caption p {
  margin: 0 0 0.75rem;
  max-width: none;
  text-wrap: pretty;
}

.diagram-caption p:last-child {
  margin-bottom: 0;
}

.diagram-figure-compact {
  max-width: 640px;
}

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

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

.grid-2 > .card,
.grid-3 > .card {
  min-width: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card h3 {
  margin-bottom: 0.5rem;
}

.card p:last-child {
  margin-bottom: 0;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  margin-bottom: 0.5rem;
}

.badge-muted {
  background: var(--surface-muted);
  color: var(--text-muted);
}

.section-intro {
  font-size: 1.0625rem;
  color: var(--text-muted);
  max-width: 42rem;
  margin: -0.35rem 0 1.5rem;
  text-wrap: pretty;
}

.featured-implementations {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.featured-implementation {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1.25rem;
  align-items: center;
  min-width: 0;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.featured-implementation:hover {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 12px 28px rgba(15, 23, 42, 0.08);
}

.featured-implementation-media {
  display: flex;
  justify-content: flex-start;
  min-width: 0;
}

.featured-implementation-media .phone-shell {
  width: 200px;
  flex-shrink: 0;
  padding: 12px;
  margin: 0;
  background: #1d1d1f;
  border-radius: 40px;
  box-shadow:
    0 20px 40px rgba(15, 23, 42, 0.16),
    0 0 0 1px rgba(0, 0, 0, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.featured-implementation-media .phone-shell img {
  display: block;
  width: 100%;
  border-radius: 28px;
  aspect-ratio: 9 / 19.5;
  object-fit: cover;
  object-position: top;
}

.featured-implementation-body {
  min-width: 0;
}

.featured-implementation-label {
  margin: 0 0 0.875rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.featured-implementation-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.875rem;
}

.featured-implementation-logo {
  display: block;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.625rem;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.featured-implementation-heading h3 {
  margin: 0;
  font-size: 1.35rem;
}

.featured-implementation-summary,
.featured-implementation-relevance {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  text-wrap: pretty;
}

.featured-implementation-relevance {
  color: var(--text);
  font-size: 0.98rem;
}

.featured-implementation-uses {
  margin: 1rem 0 1.25rem;
}

.featured-implementation-uses h4 {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.featured-implementation-uses ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.featured-implementation-uses li {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.featured-implementation-uses li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--accent-strong);
  font-weight: 700;
}

.featured-implementation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.875rem;
}

.adoption-cta {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  text-align: center;
}

.adoption-cta p {
  max-width: 36rem;
  margin: 0 auto 1rem;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .featured-implementation {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 1.25rem;
  }

  .featured-implementation-media {
    order: -1;
    justify-content: center;
  }

  .featured-implementation-media .phone-shell {
    width: min(100%, 180px);
  }
}

.project-links {
  margin-top: 0.75rem;
  max-width: 100%;
}

.project-links a {
  font-weight: 560;
}

.project-links .repo-slug {
  display: block;
  margin-top: 0.35rem;
  max-width: 100%;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.roadmap-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.docs-layout {
  display: grid;
  gap: 2rem;
  grid-template-columns: 220px 1fr;
}

.docs-sidebar {
  align-self: start;
  position: sticky;
  top: 5rem;
}

.docs-sidebar h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.docs-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.docs-sidebar li {
  margin-bottom: 0.35rem;
}

.docs-sidebar a {
  display: block;
  padding: 0.4rem 0.55rem;
  border-radius: 0.45rem;
  color: var(--text-muted);
  text-decoration: none;
}

.docs-sidebar a:hover,
.docs-sidebar a.active {
  background: var(--surface-muted);
  color: var(--text);
}

.prose {
  max-width: 48rem;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: var(--surface-muted);
  padding: 0.1rem 0.35rem;
  border-radius: 0.35rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 2rem 0;
  background: var(--surface-muted);
}

.footer-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 1.5rem;
}

.footer-grid h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.footer-grid ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-grid li {
  margin-bottom: 0.4rem;
}

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

.footer-grid a:hover {
  color: var(--text);
  text-decoration: underline;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--text-muted);
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

@media (max-width: 768px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: static;
  }

  .nav {
    gap: 0.35rem 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* Code blocks & copy (WEB-082, WEB-087) */
.code-block {
  position: relative;
  margin: 1.25rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.code-block pre {
  margin: 0;
  padding: 1rem 1rem 1rem 1rem;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-muted);
}

.code-block code {
  background: none;
  padding: 0;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

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

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

/* Documentation search (WEB-081) */
.search-panel {
  margin-bottom: 1.5rem;
}

.search-input {
  width: 100%;
  max-width: 32rem;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.search-results {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.search-results li {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.search-results a {
  font-weight: 560;
}

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

.callout {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin: 1.25rem 0;
  background: var(--surface-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.callout p:last-child {
  margin-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

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

th {
  background: var(--surface-muted);
  color: var(--text);
}

td {
  color: var(--text-muted);
}

.diagram-small {
  max-width: 480px;
  margin: 1rem 0;
}
