/* Shared design tokens for the article and the playground. */
:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --border: #e4e4df;
  --border-strong: #cfcfc8;
  --text: #17171a;
  --text-2: #4b4b52;
  --muted: #7a7a82;
  --accent: #0f766e;
  --accent-soft: #e6f4f1;
  --link: #0f6d66;
  /* Cache states */
  --shared: #10a37f;
  --shared-soft: #dcf3ec;
  --session: #3b82f6;
  --session-soft: #e1ecfe;
  --uncached: #e5484d;
  --uncached-soft: #fde6e6;
  --warn: #c27c0e;
  --warn-soft: #fbf0d9;
  --info: #6b7280;
  --info-soft: #eeeff1;
  --code-bg: #f3f3f0;
  --shadow: 0 1px 2px rgba(16, 16, 20, 0.04), 0 4px 16px rgba(16, 16, 20, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0e10;
    --surface: #15161a;
    --surface-2: #1c1d22;
    --border: #26272e;
    --border-strong: #363842;
    --text: #ececef;
    --text-2: #b4b4bd;
    --muted: #82828c;
    --accent: #34d3b4;
    --accent-soft: #10302b;
    --link: #5fe0c4;
    --shared: #14a77c;
    --shared-soft: #0f2e25;
    --session: #5b93f0;
    --session-soft: #142443;
    --uncached: #ec5a5e;
    --uncached-soft: #3a1618;
    --warn: #f0b03f;
    --warn-soft: #36290f;
    --info: #9ca3af;
    --info-soft: #23252b;
    --code-bg: #1c1d22;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0e10;
  --surface: #15161a;
  --surface-2: #1c1d22;
  --border: #26272e;
  --border-strong: #363842;
  --text: #ececef;
  --text-2: #b4b4bd;
  --muted: #82828c;
  --accent: #34d3b4;
  --accent-soft: #10302b;
  --link: #5fe0c4;
  --shared: #14a77c;
  --shared-soft: #0f2e25;
  --session: #5b93f0;
  --session-soft: #142443;
  --uncached: #ec5a5e;
  --uncached-soft: #3a1618;
  --warn: #f0b03f;
  --warn-soft: #36290f;
  --info: #9ca3af;
  --info-soft: #23252b;
  --code-bg: #1c1d22;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-underline-offset: 2px; }
code, pre, kbd { font-family: var(--mono); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--text); color: var(--bg); }
.brand-mark svg { width: 16px; height: 16px; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.topnav a, .icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500;
  background: transparent; border: 0;
  transition: background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.topnav a:hover, .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.topnav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 16px; height: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 550; white-space: nowrap;
  transition: transform 140ms var(--ease-out), background-color 150ms var(--ease-out), border-color 150ms var(--ease-out);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { background: color-mix(in srgb, var(--text) 86%, var(--bg)); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.swatch-shared { background: var(--shared); }
.swatch-session { background: var(--session); }
.swatch-uncached { background: var(--uncached); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
