/* ==========================================================================
   scim.cloud
   Flat surfaces, 1px hairline borders, one accent color. No web fonts,
   no gradients, no framework.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  --color-primary:       #0e4f5c;
  --color-primary-light: #14697a;
  --color-accent:        #0891b2;
  --color-accent-hover:  #0e7490;

  --color-text:          #12252b;
  --color-text-muted:    #55707a;

  --color-bg:            #ffffff;
  --color-surface:       #f4fafb;
  --color-surface-hover: #e6f3f6;
  --color-border:        #dbeaee;
  --color-card-bg:       #ffffff;
  --color-topbar-bg:     #0e4f5c;
  --color-topbar-text:   #ffffff;

  --color-code-bg:       #f4fafb;
  --color-code-border:   #dbeaee;
  --color-code-text:     #0e4f5c;

  /* Syntax tokens */
  --t-key:    #0e6b7d;
  --t-str:    #9a5b18;
  --t-num:    #6d28d9;
  --t-bool:   #a21caf;
  --t-null:   #a21caf;
  --t-punct:  #6b8590;
  --t-method: #0369a1;
  --t-status: #b45309;
  --t-header: #14697a;

  /* Semantic tints */
  --tint-ok-bg:     #d1fae5;
  --tint-ok-border: #a7f3d0;
  --tint-ok-text:   #065f46;
  --tint-warn-bg:     #fef3c7;
  --tint-warn-border: #fcd34d;
  --tint-warn-text:   #92400e;
  --tint-bad-bg:     #fee2e2;
  --tint-bad-border: #fca5a5;
  --tint-bad-text:   #991b1b;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  --radius-sm: 3px;
  --radius:    6px;
  --radius-lg: 8px;

  --topbar-h:   52px;
  --sidebar-w:  248px;
  --content-w:  800px;
}

/* Dark theme. Declared twice on purpose: the attribute selector handles an
   explicit user choice, the media query handles the OS default. The
   :not([data-theme="light"]) guard means an explicit choice always wins. */

[data-theme="dark"] {
  --color-primary:       #7dd3e8;
  --color-primary-light: #a5e3f2;
  --color-accent:        #22d3ee;
  --color-accent-hover:  #67e8f9;

  --color-text:          #dceef2;
  --color-text-muted:    #8ba8b2;

  --color-bg:            #08171c;
  --color-surface:       #0f2730;
  --color-surface-hover: #16333d;
  --color-border:        #1e3d47;
  --color-card-bg:       #0d222a;
  --color-topbar-bg:     #08171c;
  --color-topbar-text:   #f0fafc;

  --color-code-bg:       #0d222a;
  --color-code-border:   #1e3d47;
  --color-code-text:     #7dd3e8;

  --t-key:    #7dd3e8;
  --t-str:    #f0b775;
  --t-num:    #c4b5fd;
  --t-bool:   #f0abfc;
  --t-null:   #f0abfc;
  --t-punct:  #7d97a2;
  --t-method: #7dd3fc;
  --t-status: #fcd34d;
  --t-header: #67e8f9;

  --tint-ok-bg:     #064e3b;
  --tint-ok-border: #047857;
  --tint-ok-text:   #6ee7b7;
  --tint-warn-bg:     #78350f;
  --tint-warn-border: #b45309;
  --tint-warn-text:   #fde68a;
  --tint-bad-bg:     #7f1d1d;
  --tint-bad-border: #b91c1c;
  --tint-bad-text:   #fca5a5;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary:       #7dd3e8;
    --color-primary-light: #a5e3f2;
    --color-accent:        #22d3ee;
    --color-accent-hover:  #67e8f9;

    --color-text:          #dceef2;
    --color-text-muted:    #8ba8b2;

    --color-bg:            #08171c;
    --color-surface:       #0f2730;
    --color-surface-hover: #16333d;
    --color-border:        #1e3d47;
    --color-card-bg:       #0d222a;
    --color-topbar-bg:     #08171c;
    --color-topbar-text:   #f0fafc;

    --color-code-bg:       #0d222a;
    --color-code-border:   #1e3d47;
    --color-code-text:     #7dd3e8;

    --t-key:    #7dd3e8;
    --t-str:    #f0b775;
    --t-num:    #c4b5fd;
    --t-bool:   #f0abfc;
    --t-null:   #f0abfc;
    --t-punct:  #7d97a2;
    --t-method: #7dd3fc;
    --t-status: #fcd34d;
    --t-header: #67e8f9;

    --tint-ok-bg:     #064e3b;
    --tint-ok-border: #047857;
    --tint-ok-text:   #6ee7b7;
    --tint-warn-bg:     #78350f;
    --tint-warn-border: #b45309;
    --tint-warn-text:   #fde68a;
    --tint-bad-bg:     #7f1d1d;
    --tint-bad-border: #b91c1c;
    --tint-bad-text:   #fca5a5;
  }
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

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

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

h1, h2, h3, h4, h5, h6 { margin: 0 0 var(--space-3); }

h1, h2 {
  color: var(--color-primary);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }

h3, h4, h5, h6 {
  color: var(--color-text);
  font-weight: 600;
  line-height: 1.3;
}
h3 { font-size: var(--text-xl); margin-top: var(--space-6); }
h4 { font-size: var(--text-lg); margin-top: var(--space-5); }
h5, h6 { font-size: var(--text-base); margin-top: var(--space-4); }

p { margin: 0 0 var(--space-4); }

ul, ol { margin: 0 0 var(--space-4); padding-left: 1.4rem; }
li { margin-bottom: var(--space-1); }

hr { border: 0; border-top: 1px solid var(--color-border); margin: var(--space-6) 0; }

img { max-width: 100%; height: auto; }

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Black line art (the logo, the object-model diagram) has no light-on-dark
   variant, so invert it rather than letting it disappear. */
[data-theme="dark"] .art-invert { filter: invert(1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .art-invert { filter: invert(1); }
}

/* --------------------------------------------------------------------------
   3. Layout shell
   -------------------------------------------------------------------------- */

.site-topbar {
  height: var(--topbar-h);
  background: var(--color-topbar-bg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 300;
  border-bottom: 1px solid var(--color-border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none !important;
  color: var(--color-topbar-text);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
}
.topbar-brand:hover { color: rgba(255, 255, 255, 0.85); }
.topbar-brand img { display: block; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}
.theme-toggle:active { transform: scale(0.95); }

/* Both icons stay in the DOM; the swap is pure CSS. */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.site-layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--topbar-h));
}

.site-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  padding: var(--space-4) 0 var(--space-6);
}

.site-main {
  flex: 1;
  min-width: 0;
  padding: var(--space-5) 2.5rem var(--space-8);
}

.container {
  max-width: var(--content-w);
}

.site-overlay { display: none; }

@media (max-width: 1024px) {
  .sidebar-toggle { display: flex; }

  .site-sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: calc(-1 * var(--sidebar-w) - 12px);
    height: calc(100vh - var(--topbar-h));
    transition: left 0.25s ease;
    z-index: 200;
  }
  .site-sidebar.is-open { left: 0; box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15); }

  .site-overlay {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  .site-overlay.is-open { opacity: 1; pointer-events: auto; }

  .site-main { padding: 1.25rem 1.25rem var(--space-8); }
}

/* --------------------------------------------------------------------------
   4. Sidebar navigation
   -------------------------------------------------------------------------- */

.site-sidebar-nav { font-size: var(--text-sm); }

.sidebar-divider {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  padding: 1.25rem 1.25rem 0.35rem;
}

.sidebar-link {
  display: block;
  padding: 0.28rem 1.25rem;
  color: var(--color-text);
  text-decoration: none !important;
  transition: color 0.1s, background 0.1s;
}
.sidebar-link:hover  { color: var(--color-accent); background: var(--color-surface); }
.sidebar-link.active { color: var(--color-accent); background: var(--color-surface); font-weight: 600; }

.site-sidebar-nav details { border: none; }

.sidebar-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.28rem 1.25rem;
  cursor: pointer;
  list-style: none;
  color: var(--color-text);
  font-size: var(--text-sm);
  user-select: none;
}
.sidebar-summary::-webkit-details-marker { display: none; }
.sidebar-summary::after {
  content: '›';
  font-size: 1.1em;
  color: var(--color-text-muted);
  transition: transform 0.15s;
  flex-shrink: 0;
}
details[open] > .sidebar-summary::after { transform: rotate(90deg); }
.sidebar-summary:hover { color: var(--color-accent); background: var(--color-surface); }
details[open] > .sidebar-summary { color: var(--color-primary); font-weight: 600; }

.sidebar-sub { list-style: none; padding: 0.15rem 0 var(--space-2); margin: 0; }
.sidebar-sub li { margin: 0; }

.sidebar-sublink {
  display: block;
  padding: 0.22rem 1.25rem 0.22rem 2rem;
  color: var(--color-text-muted);
  text-decoration: none !important;
  font-size: 0.8125rem;
  transition: color 0.1s, background 0.1s;
}
.sidebar-sublink:hover  { color: var(--color-accent); background: var(--color-surface); }
.sidebar-sublink.active { color: var(--color-accent); background: var(--color-surface); font-weight: 600; }

.sidebar-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-left: 0.4rem;
}

/* --------------------------------------------------------------------------
   5. Breadcrumbs
   -------------------------------------------------------------------------- */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
}
.breadcrumb li { margin: 0; color: var(--color-text-muted); }
.breadcrumb li + li::before {
  content: '/';
  margin-right: 0.4rem;
  color: var(--color-border);
}

/* --------------------------------------------------------------------------
   6. Prose components
   -------------------------------------------------------------------------- */

/* The recurring uppercase micro-eyebrow. */
.eyebrow {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.lede {
  font-size: var(--text-lg);
  line-height: 1.55;
  color: var(--color-text-muted);
  margin-bottom: var(--space-5);
}

.callout {
  background: var(--color-surface);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-3) var(--space-4);
  margin: var(--space-5) 0;
}
.callout > :last-child { margin-bottom: 0; }
.callout strong.callout-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.callout--muted { border-left-color: var(--color-border); }

.page-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

/* Inline code and the monospace identifier pill share one treatment, so RFC
   numbers read as code tokens in running prose. */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  color: var(--color-code-text);
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
}

.rfc-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-code-text);
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.45em;
  vertical-align: middle;
  white-space: nowrap;
  text-decoration: none !important;
}
.rfc-badge:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.mono-url {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  word-break: break-all;
}

.status {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.1em 0.5em;
  border-radius: var(--radius-sm);
  vertical-align: middle;
  white-space: nowrap;
}
/* Neutral variant for metadata that isn't a status — e.g. "Updates 7643, 7644". */
.status--neutral    { background: var(--color-surface); color: var(--color-text-muted); border: 1px solid var(--color-border); }
/* An in-progress draft. Accent rather than a tint, so it reads as "current"
   and stays clearly distinct from the amber used for expired. */
.status--active     { background: var(--color-surface-hover); color: var(--color-accent); border: 1px solid var(--color-accent); }
.status--published  { background: var(--tint-ok-bg);   color: var(--tint-ok-text);   border: 1px solid var(--tint-ok-border); }
.status--draft      { background: var(--tint-warn-bg); color: var(--tint-warn-text); border: 1px solid var(--tint-warn-border); }
.status--expired    { background: var(--tint-warn-bg); color: var(--tint-warn-text); border: 1px solid var(--tint-warn-border); }
.status--deprecated { background: var(--tint-bad-bg);  color: var(--tint-bad-text);  border: 1px solid var(--tint-bad-border); }

/* Definition-style spec list: title row + description. */
.spec-list { list-style: none; padding: 0; margin: 0 0 var(--space-5); }
.spec-list > li {
  padding: var(--space-3) 0;
  margin: 0;
  border-bottom: 1px solid var(--color-border);
}
.spec-list > li:last-child { border-bottom: 0; }
.spec-list .spec-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
  font-weight: 600;
}
.spec-list .spec-title a:not(.rfc-badge) { color: var(--color-primary); }
.spec-list p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.55;
}

/* Collapsible block for content that is kept for the record but shouldn't
   compete with current material. Native <details>, no JS. */
.disclosure {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin: 0 0 var(--space-5);
}
.disclosure > summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  list-style: none;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  user-select: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after {
  content: '›';
  margin-left: auto;
  font-size: 1.2em;
  line-height: 1;
  transition: transform 0.15s;
}
.disclosure[open] > summary::after { transform: rotate(90deg); }
.disclosure > summary:hover { color: var(--color-accent); }
.disclosure[open] > summary {
  color: var(--color-primary);
  border-bottom: 1px solid var(--color-border);
}
.disclosure-body { padding: var(--space-4) var(--space-4) var(--space-2); }
.disclosure-body > :last-child { margin-bottom: 0; }

.terminology { margin: 0 0 var(--space-5); }
.terminology dt {
  font-weight: 700;
  color: var(--color-primary);
  margin-top: var(--space-5);
  font-size: var(--text-base);
}
.terminology dt:first-child { margin-top: 0; }
.terminology dt .term-abbr {
  font-weight: 400;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin-left: 0.4rem;
}
.terminology dd {
  margin: var(--space-1) 0 0 0;
  padding-left: var(--space-4);
  border-left: 3px solid var(--color-border);
  line-height: 1.6;
}
.terminology dd > :last-child { margin-bottom: 0; }

.figure {
  margin: var(--space-5) 0;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.figure img { display: block; margin: 0 auto; border-radius: var(--radius); }
.figure figcaption {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}

/* --------------------------------------------------------------------------
   7. Cards and grids
   -------------------------------------------------------------------------- */

.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 700px) {
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.card > :last-child { margin-bottom: 0; }
.card h3, .card h4 { margin-top: 0; }

/* Interactive nav card: border goes accent, soft shadow on hover. No lift. */
.entry-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 1.25rem var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none !important;
  color: var(--color-text);
  height: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.entry-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  color: var(--color-text);
}
.entry-card .entry-text { flex: 1; min-width: 0; }
.entry-card .entry-title {
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-primary);
  margin-bottom: 0.2rem;
}
.entry-card .entry-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.45;
}
.entry-card .entry-arrow {
  flex-shrink: 0;
  font-size: 1.1rem;
  color: var(--color-text-muted);
  transition: color 0.15s, transform 0.15s;
}
.entry-card:hover .entry-arrow { color: var(--color-accent); transform: translateX(3px); }

/* Compact link chips. */
.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.link-chip {
  display: block;
  padding: 0.6rem 0.9rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none !important;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.link-chip:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-accent);
  color: var(--color-accent);
}
.link-chip .chip-note {
  display: block;
  font-weight: 400;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}
.link-chip:hover .chip-note { color: var(--color-accent); }

/* --------------------------------------------------------------------------
   8. Code blocks
   -------------------------------------------------------------------------- */

.code-block {
  position: relative;
  background: var(--color-code-bg);
  border: 1px solid var(--color-code-border);
  border-radius: var(--radius);
  margin: 0 0 var(--space-5);
  overflow: hidden;
}

.code-block-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  background: var(--color-surface-hover);
  border-bottom: 1px solid var(--color-code-border);
  padding: 0.4rem 0.75rem;
}

.code-block pre {
  margin: 0;
  padding: var(--space-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--color-text);
  tab-size: 2;
}
.code-block pre code {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
}

.code-copy {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.45rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}
.code-block:hover .code-copy,
.code-copy:focus-visible { opacity: 1; }
.code-copy:hover { color: var(--color-accent); border-color: var(--color-accent); }
.code-block:has(.code-block-label) .code-copy { top: 2rem; }

.t-key    { color: var(--t-key); }
.t-str    { color: var(--t-str); }
.t-num    { color: var(--t-num); }
.t-bool   { color: var(--t-bool); font-weight: 600; }
.t-null   { color: var(--t-null); font-weight: 600; }
.t-punct  { color: var(--t-punct); }
.t-method { color: var(--t-method); font-weight: 700; }
.t-path   { color: var(--color-text); font-weight: 600; }
.t-proto  { color: var(--t-header); font-weight: 600; }
.t-status { color: var(--t-status); font-weight: 700; }
.t-header { color: var(--t-header); }

/* --------------------------------------------------------------------------
   9. Tables
   -------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin-bottom: var(--space-5); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
table.data thead th {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}
table.data tbody tr:hover { background: var(--color-surface); }
table.data tbody tr:last-child td { border-bottom: 0; }

table.data th.sortable {
  cursor: pointer;
  user-select: none;
}
table.data th.sortable:hover { color: var(--color-accent); }
table.data th.sortable::after {
  content: '';
  display: inline-block;
  min-width: 0.9em;
  margin-left: 0.3em;
  font-size: 0.85em;
  color: var(--color-accent);
}
table.data th.sortable[aria-sort="ascending"]::after  { content: '▲'; }
table.data th.sortable[aria-sort="descending"]::after { content: '▼'; }

.yes { color: var(--tint-ok-text); font-weight: 700; }
.no  { color: var(--color-text-muted); }

.license-pill,
.rev-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.05em 0.4em;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   10. Implementation search + filters
   -------------------------------------------------------------------------- */

.impl-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.impl-search {
  flex: 1 1 240px;
  min-width: 200px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.45rem 0.7rem;
}
.impl-search::placeholder { color: var(--color-text-muted); }
.impl-search:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 18%, transparent);
}

.impl-filter {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.impl-filter:hover { border-color: var(--color-accent); color: var(--color-accent); }
.impl-filter[aria-pressed="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
[data-theme="dark"] .impl-filter[aria-pressed="true"] { color: var(--color-bg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .impl-filter[aria-pressed="true"] { color: var(--color-bg); }
}

.impl-count {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.impl-empty {
  padding: var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
}

/* --------------------------------------------------------------------------
   11. Footer
   -------------------------------------------------------------------------- */

.site-footer {
  max-width: var(--content-w);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-8);
  padding-top: var(--space-5);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.contribution-prompt {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  margin: 0 0 var(--space-4);
}
.contribution-prompt a { font-weight: 600; margin-left: var(--space-1); }
.contribution-prompt .divider { margin: 0 var(--space-2); opacity: 0.4; }

.footer-meta { text-align: center; }
.footer-meta p { margin-bottom: var(--space-2); }

/* --------------------------------------------------------------------------
   12. Home
   -------------------------------------------------------------------------- */

.home-hero {
  margin-bottom: var(--space-6);
}
.home-hero img {
  display: block;
  width: 200px;
  max-width: 55%;
  margin-bottom: var(--space-4);
}
/* The topbar is dark in both themes, so the brand mark always needs inverting. */
.topbar-brand img { filter: invert(1); }

.home-hero h1 { margin-bottom: var(--space-3); }

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stat {
  flex: 1 1 140px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.stat .stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.1;
}
.stat .stat-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   13. Print
   -------------------------------------------------------------------------- */

@media print {
  .site-topbar, .site-sidebar, .site-overlay,
  .contribution-prompt, .code-copy, .impl-controls { display: none !important; }
  .site-main { padding: 0; }
  .container { max-width: none; }
  a[href^="http"]:not(.noprintexpand)::after { content: " (" attr(href) ")"; font-size: 0.8em; }
}
