/* ===================================================================
   PAPERCLIP DESIGN SYSTEM
   A warm, paper-inspired design language for documentation & product UI.
   Drop-in stylesheet — import once, theme via [data-theme] on <html>.
   =================================================================== */

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

/* ===================================================================
   1. DESIGN TOKENS
   =================================================================== */
:root {
  /* ── Neutrals (warm, paper-inspired) ── */
  --ds-white:      #ffffff;  /* Surface (cards, inputs, popovers)          */
  --ds-linen:      #f5f3f0;  /* Page background — slightly warm off-white  */
  --ds-parchment:  #f0ece7;  /* Subtle tint for pills, hover states, code  */
  --ds-stone:      #e0dcd6;  /* Default borders and dividers               */
  --ds-stone-dark: #c8c3bc;  /* Stronger borders, hover borders            */
  --ds-ink:        #1a1a1a;  /* Primary text, strong contrast              */
  --ds-graphite:   #4a4a4a;  /* Body text, secondary                       */
  --ds-ash:        #888880;  /* Tertiary text, metadata, placeholders      */
  --ds-void:       #0c0c0c;  /* Code blocks, dark surfaces                 */

  /* ── Accents (semantic) ── */
  --ds-green:      #22c55e;  /* Success, primary accent                    */
  --ds-mint:       #dcfce7;  /* Success background, highlight              */
  --ds-amber:      #f59e0b;  /* Warning                                    */
  --ds-red:        #ef4444;  /* Danger / error                             */
  --ds-blue:       #1d4ed8;  /* Info                                       */

  /* ── Layout ── */
  --ds-sidebar-w:   272px;
  --ds-content-max: 760px;
  --ds-outer-px:    40px;
  --ds-layout-max:  calc(var(--ds-outer-px) * 2 + var(--ds-sidebar-w) + 64px + var(--ds-content-max));
  --ds-header-h:    56px;

  /* ── Typography ── */
  --ds-font-serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --ds-font-body:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ds-font-mono:  'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  /* Type scale (paired with line-height 1.65 for body) */
  --ds-text-xs:   11px;
  --ds-text-sm:   12.5px;
  --ds-text-base: 13.5px;
  --ds-text-md:   15.5px;
  --ds-text-lg:   17px;
  --ds-text-xl:   22px;
  --ds-text-2xl:  24px;
  --ds-text-3xl:  clamp(28px, 4vw, 38px);
  --ds-text-4xl:  clamp(40px, 6vw, 64px);

  /* ── Radii ── */
  --ds-radius-xs: 5px;
  --ds-radius-sm: 10px;
  --ds-radius:    16px;
  --ds-radius-pill: 99px;

  /* ── Motion ── */
  --ds-transition: 0.2s ease;
  --ds-transition-slow: 0.25s ease;

  /* ── Elevation ── */
  --ds-shadow-sm: 0 2px 8px rgba(26, 26, 26, 0.06);
  --ds-shadow-md: 0 8px 24px rgba(26, 26, 26, 0.04);
  --ds-shadow-lg: 0 12px 32px rgba(12, 12, 12, 0.12), 0 2px 6px rgba(12, 12, 12, 0.06);

  /* ── Focus ring ── */
  --ds-focus-ring: 0 0 0 3px rgba(26, 26, 26, 0.05);
}

/* ===================================================================
   2. DARK THEME
   Applied via <html data-theme="dark">
   =================================================================== */
[data-theme="dark"] {
  --ds-white:      #0f1117;
  --ds-linen:      #0b0d12;
  --ds-parchment:  #181c27;
  --ds-stone:      #252a3a;
  --ds-stone-dark: #353c52;
  --ds-ink:        #e4e6f0;
  --ds-graphite:   #9ba3bf;
  --ds-ash:        #6b7290;
  --ds-void:       #07080c;
  --ds-mint:       rgba(34, 197, 94, 0.12);

  --ds-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --ds-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --ds-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ===================================================================
   3. BASE ELEMENTS
   =================================================================== */
html {
  font-size: 16px;
  /* scroll-behavior: smooth causes scroll-anchoring drift when async
     content replaces skeletons — use JS scrollIntoView where needed */
  scroll-behavior: auto;
  /* Prevent scroll-anchoring from drifting the page after DOM updates */
  overflow-anchor: none;
}

body {
  background: var(--ds-linen);
  color: var(--ds-ink);
  font-family: var(--ds-font-body);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--ds-transition-slow), color var(--ds-transition-slow);
}

a { color: inherit; }

::selection { background: var(--ds-mint); color: var(--ds-ink); }

/* ===================================================================
   4. TYPOGRAPHY
   Use .ds-display for hero titles, .ds-heading-* for section titles.
   =================================================================== */
.ds-display {
  font-family: var(--ds-font-serif);
  font-size: var(--ds-text-4xl);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--ds-ink);
}
.ds-display em { font-style: italic; color: var(--ds-graphite); }

.ds-heading-1 {
  font-family: var(--ds-font-serif);
  font-size: var(--ds-text-3xl);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.15;
  color: var(--ds-ink);
}
.ds-heading-2 {
  font-family: var(--ds-font-serif);
  font-size: var(--ds-text-2xl);
  font-weight: 400;
  line-height: 1.25;
  color: var(--ds-ink);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ds-stone);
}
.ds-heading-3 {
  font-size: var(--ds-text-md);
  font-weight: 600;
  color: var(--ds-ink);
}
.ds-eyebrow {
  font-size: var(--ds-text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ds-ash);
}
.ds-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ds-ash);
}
.ds-lead {
  font-size: var(--ds-text-lg);
  line-height: 1.6;
  color: var(--ds-graphite);
}
.ds-body  { font-size: var(--ds-text-md); line-height: 1.75; color: var(--ds-graphite); }
.ds-small { font-size: var(--ds-text-sm); color: var(--ds-graphite); }
.ds-muted { color: var(--ds-ash); }
.ds-mono  { font-family: var(--ds-font-mono); }

/* ===================================================================
   5. LAYOUT
   =================================================================== */
.ds-container {
  max-width: var(--ds-layout-max);
  margin: 0 auto;
  padding: 0 var(--ds-outer-px);
}

.ds-stack > * + * { margin-top: var(--ds-stack-gap, 16px); }
.ds-stack-sm > * + * { margin-top: 8px; }
.ds-stack-lg > * + * { margin-top: 24px; }

.ds-row {
  display: flex;
  align-items: center;
  gap: var(--ds-row-gap, 12px);
}

/* ===================================================================
   6. HEADER
   =================================================================== */
.ds-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 243, 240, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--ds-stone);
  padding-top: env(safe-area-inset-top);
}
[data-theme="dark"] .ds-header { background: rgba(15, 17, 23, 0.85); }

.ds-header-inner {
  max-width: var(--ds-layout-max);
  margin: 0 auto;
  padding: 0 var(--ds-outer-px);
  height: var(--ds-header-h);
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.ds-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ds-ink);
}
.ds-logo-mark {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ds-logo-mark svg { width: 26px; height: 26px; }
.ds-logo-name { font-weight: 600; font-size: 15px; }
.ds-logo-sub  { color: var(--ds-ash); font-size: 13px; margin-left: 4px; }
.ds-logo-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-parchment);
  border: 1px solid var(--ds-stone);
  font-size: 11px;
  font-weight: 500;
  color: var(--ds-graphite);
  letter-spacing: 0.01em;
  margin-left: -4px;
}

/* ===================================================================
   7. BUTTONS
   =================================================================== */
.ds-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--ds-white);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-sm);
  font-family: var(--ds-font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ds-graphite);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--ds-transition), color var(--ds-transition),
              background var(--ds-transition), transform var(--ds-transition);
}
.ds-btn:hover {
  border-color: var(--ds-stone-dark);
  color: var(--ds-ink);
  transform: translateY(-1px);
}
.ds-btn:active { transform: translateY(0); }
.ds-btn:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); border-color: var(--ds-ink); }

.ds-btn-primary {
  background: var(--ds-ink);
  border-color: var(--ds-ink);
  color: var(--ds-white);
}
.ds-btn-primary:hover { background: var(--ds-void); border-color: var(--ds-void); color: var(--ds-white); }

.ds-btn-ghost { background: transparent; border-color: transparent; }
.ds-btn-ghost:hover { background: var(--ds-parchment); border-color: var(--ds-stone); }

.ds-btn-sm { padding: 5px 10px; font-size: 11.5px; }
.ds-btn svg { width: 14px; height: 14px; }

/* Icon button (square, 34x34) */
.ds-icon-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-white);
  color: var(--ds-graphite);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--ds-transition), color var(--ds-transition);
  flex-shrink: 0;
  text-decoration: none;
}
.ds-icon-btn:hover { border-color: var(--ds-stone-dark); color: var(--ds-ink); }
.ds-icon-btn svg { width: 16px; height: 16px; }

/* Pill action button (e.g. page actions) */
.ds-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--ds-white);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-pill);
  font-family: var(--ds-font-body);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ds-graphite);
  cursor: pointer;
  transition: border-color var(--ds-transition), color var(--ds-transition), background var(--ds-transition);
}
.ds-pill-btn:hover { border-color: var(--ds-stone-dark); color: var(--ds-ink); }
.ds-pill-btn[aria-expanded="true"] {
  color: var(--ds-ink);
  background: var(--ds-parchment);
  border-color: var(--ds-stone-dark);
}

/* ===================================================================
   8. INPUTS
   =================================================================== */
.ds-input {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-white);
  font-family: var(--ds-font-body);
  font-size: 13px;
  color: var(--ds-ink);
  outline: none;
  -webkit-appearance: none;
  transition: border-color var(--ds-transition), box-shadow var(--ds-transition);
}
.ds-input:focus { border-color: var(--ds-ink); box-shadow: var(--ds-focus-ring); }
.ds-input::placeholder { color: var(--ds-ash); }

.ds-search-wrap { position: relative; width: min(420px, 90vw); }
.header-search-wrap {
  flex: 1 1 240px;
  width: auto;
  min-width: 180px;
  max-width: 420px;
}
.ds-search-wrap .ds-input { padding: 0 44px 0 32px; }
.ds-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--ds-ash); pointer-events: none;
}
.ds-kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 10.5px;
  color: var(--ds-ash);
  background: var(--ds-linen);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-xs);
  padding: 1px 5px;
  font-family: var(--ds-font-body);
  pointer-events: none;
}

/* ── Nav search dropdown ──────────────────────────────────────────── */
.nav-search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--ds-white);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-sm);
  box-shadow: var(--ds-shadow-lg);
  z-index: 500;
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
}
.nav-search-dropdown.is-open { display: block; }

.nav-search-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--ds-linen);
  transition: background var(--ds-transition);
}
.nav-search-item:last-of-type { border-bottom: none; }
.nav-search-item:hover, .nav-search-item.is-focused { background: var(--ds-linen); }

.nav-search-item-tag {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: var(--ds-radius-xs);
  flex-shrink: 0;
}
.nav-search-item-tag--guide    { background: var(--ds-mint); color: var(--ds-ink); }
.nav-search-item-tag--doc      { background: color-mix(in srgb, var(--ds-blue) 14%, transparent); color: var(--ds-blue); }
.nav-search-item-tag--qa,
.nav-search-item-tag--thread   { background: var(--ds-amber); color: var(--ds-void); }
.nav-search-item-tag--resource { background: #e0e7ff; color: #3730a3; }

.nav-search-item-title {
  font-size: var(--ds-text-sm);
  font-weight: 500;
  color: var(--ds-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-search-item-meta {
  font-size: 11px;
  color: var(--ds-ash);
  white-space: nowrap;
}

.nav-search-footer {
  display: block;
  padding: 10px 14px;
  font-size: var(--ds-text-sm);
  color: var(--ds-blue);
  text-decoration: none;
  background: var(--ds-linen);
  border-top: 1px solid var(--ds-stone);
  transition: background var(--ds-transition);
}
.nav-search-footer:hover, .nav-search-footer.is-focused { background: var(--ds-stone); }
.nav-search-footer strong { font-weight: 600; }

.nav-search-loading, .nav-search-empty {
  padding: 14px;
  font-size: var(--ds-text-sm);
  color: var(--ds-ash);
}

/* ===================================================================
   9. CARDS
   =================================================================== */
.ds-card {
  background: var(--ds-white);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--ds-transition), transform var(--ds-transition), box-shadow var(--ds-transition);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.ds-card::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--ds-green);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform var(--ds-transition);
}
.ds-card:hover {
  border-color: var(--ds-stone-dark);
  transform: translateY(-2px);
  box-shadow: var(--ds-shadow-md);
}
.ds-card:hover::after { transform: scaleY(1); }

.ds-card-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--ds-parchment);
  border: 1px solid var(--ds-stone);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ds-graphite);
  margin-bottom: 4px;
}
.ds-card-icon svg { width: 18px; height: 18px; }

.ds-card-title {
  font-family: var(--ds-font-serif);
  font-size: var(--ds-text-xl);
  font-weight: 400;
  color: var(--ds-ink);
  line-height: 1.2;
}
.ds-card-desc { font-size: var(--ds-text-base); color: var(--ds-graphite); line-height: 1.55; }
.ds-card-meta {
  font-size: 11.5px;
  color: var(--ds-ash);
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ds-card-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ds-stone-dark); }

.ds-card-grid {
  display: grid;
  grid-template-columns: repeat(var(--ds-card-cols, 3), 1fr);
  gap: 16px;
}

/* ===================================================================
   10. CHIPS / PILLS
   =================================================================== */

/* ── @mention chip (inline in rendered content) ─────────────────────── */
a.mention-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-mint);
  color: var(--ds-ink);
  font-size: 0.9em;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid rgba(34, 197, 94, 0.25);
  transition: background var(--ds-transition), border-color var(--ds-transition);
  line-height: 1.6;
  vertical-align: middle;
}
a.mention-chip:hover {
  background: rgba(34, 197, 94, 0.25);
  border-color: rgba(34, 197, 94, 0.5);
}

/* ── @mention autocomplete dropdown ─────────────────────────────────── */
.mention-dropdown {
  display: none;
  background: var(--ds-white);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-sm);
  box-shadow: var(--ds-shadow-lg);
  z-index: 9999;
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}

.mention-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--ds-linen);
  cursor: pointer;
  font-family: var(--ds-font-body);
  font-size: var(--ds-text-sm);
  color: var(--ds-ink);
  transition: background var(--ds-transition);
}
.mention-dropdown-item:last-of-type { border-bottom: none; }
.mention-dropdown-item:hover,
.mention-dropdown-item.is-focused { background: var(--ds-linen); }

.mention-dropdown-item-handle {
  font-weight: 600;
  color: var(--ds-ink);
  flex-shrink: 0;
}
.mention-dropdown-item-name {
  color: var(--ds-ash);
  font-size: var(--ds-text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-dropdown-hint {
  padding: 10px 14px;
  font-size: var(--ds-text-sm);
  color: var(--ds-ash);
  font-style: italic;
}

.ds-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-parchment);
  border: 1px solid var(--ds-stone);
  font-size: var(--ds-text-xs);
  color: var(--ds-graphite);
}
.ds-chip--free { color: #15803d; background: var(--ds-mint); border-color: rgba(34,197,94,.3); }
.ds-chip--paid { color: var(--ds-ink); background: var(--ds-white); border-color: var(--ds-stone-dark); font-weight: 500; }
[data-theme="dark"] .ds-chip--free { color: var(--ds-green); }
.ds-select { height: 32px; padding: 0 30px 0 10px; border: 1px solid var(--ds-stone); border-radius: var(--ds-radius-sm); background: var(--ds-white); font-family: var(--ds-font-body); font-size: 12.5px; color: var(--ds-ink); cursor: pointer; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888880' stroke-width='1.5' stroke-linecap='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 8px center; }

/* ===================================================================
   11. CALLOUTS
   =================================================================== */
.ds-callout {
  border-radius: var(--ds-radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.65;
  display: flex;
  gap: 11px;
  align-items: flex-start;
}
.ds-callout-icon { flex-shrink: 0; margin-top: 3px; display: inline-flex; }
.ds-callout-icon svg { width: 16px; height: 16px; }
.ds-callout-body { flex: 1; min-width: 0; }
.ds-callout-label { font-weight: 600; margin-right: 6px; }

.ds-callout--note    { background: var(--ds-parchment);      border: 1px solid var(--ds-stone-dark); }
.ds-callout--info    { background: rgba(59,130,246,0.08);    border: 1px solid rgba(59,130,246,0.28); }
.ds-callout--tip     { background: var(--ds-mint);           border: 1px solid rgba(34,197,94,0.30); }
.ds-callout--warning { background: rgba(245,158,11,0.10);    border: 1px solid rgba(245,158,11,0.30); }
.ds-callout--danger  { background: rgba(239,68,68,0.08);     border: 1px solid rgba(239,68,68,0.28); }

.ds-callout--note    .ds-callout-icon,
.ds-callout--note    .ds-callout-label { color: var(--ds-graphite); }
.ds-callout--info    .ds-callout-icon,
.ds-callout--info    .ds-callout-label { color: var(--ds-blue); }
.ds-callout--tip     .ds-callout-icon,
.ds-callout--tip     .ds-callout-label { color: #15803d; }
.ds-callout--warning .ds-callout-icon,
.ds-callout--warning .ds-callout-label { color: #92400e; }
.ds-callout--danger  .ds-callout-icon,
.ds-callout--danger  .ds-callout-label { color: #b91c1c; }

/* ===================================================================
   12. CODE
   =================================================================== */
code, .ds-code-inline {
  font-family: var(--ds-font-mono);
  font-size: 0.87em;
  background: var(--ds-parchment);
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-xs);
  padding: 1px 6px;
  color: var(--ds-ink);
  white-space: nowrap;
}

.ds-code-block {
  background: var(--ds-void);
  color: #d4d4d4;
  border-radius: var(--ds-radius-sm);
  padding: 18px 20px;
  overflow-x: auto;
  font-family: var(--ds-font-mono);
  font-size: 0.87rem;
  line-height: 1.6;
}
.ds-code-block code { background: none; border: none; padding: 0; color: inherit; font-size: inherit; }

.ds-code-wrap { position: relative; }
.ds-code-copy {
  position: absolute;
  top: 8px; right: 8px;
  width: 30px; height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #d4d4d4;
  border-radius: 7px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--ds-transition), background var(--ds-transition), color var(--ds-transition);
}
.ds-code-copy svg { width: 14px; height: 14px; }
.ds-code-wrap:hover .ds-code-copy,
.ds-code-copy:focus-visible { opacity: 1; }
.ds-code-copy:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.ds-code-copy.is-copied {
  opacity: 1;
  color: var(--ds-green);
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.12);
}
@media (hover: none) { .ds-code-copy { opacity: 0.75; } }

/* ===================================================================
   13. TABLES
   =================================================================== */
.ds-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--ds-stone);
  border-radius: var(--ds-radius-sm);
}

.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 520px;
}
.ds-table th {
  background: var(--ds-parchment);
  border-bottom: 1px solid var(--ds-stone);
  border-right: 1px solid var(--ds-stone);
  padding: 8px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ds-graphite);
}
.ds-table td {
  background: var(--ds-linen);
  border-bottom: 1px solid var(--ds-stone);
  border-right: 1px solid var(--ds-stone);
  padding: 8px 14px;
  color: var(--ds-graphite);
  vertical-align: top;
}
.ds-table tr:last-child td { border-bottom: none; }
.ds-table th:last-child,
.ds-table td:last-child { border-right: none; }
.ds-table tbody tr:hover td { background: var(--ds-white); }

/* ===================================================================
   14. TABS
   =================================================================== */
.ds-tabs { margin-bottom: 24px; }
.ds-tabs-bar {
  display: flex;
  border-bottom: 1px solid var(--ds-stone);
}
.ds-tab-btn {
  padding: 7px 18px;
  font-family: var(--ds-font-body);
  font-size: 13px;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ds-ash);
  cursor: pointer;
  transition: color var(--ds-transition), border-color var(--ds-transition);
  margin-bottom: -1px;
}
.ds-tab-btn:hover { color: var(--ds-graphite); }
.ds-tab-btn.is-active {
  color: var(--ds-ink);
  border-bottom-color: var(--ds-green);
}
.ds-tab-panel { display: none; }
.ds-tab-panel.is-active { display: block; }

/* ===================================================================
   15. SIDEBAR
   =================================================================== */
.ds-sidebar {
  width: var(--ds-sidebar-w);
  min-width: var(--ds-sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--ds-header-h) + env(safe-area-inset-top));
  max-height: calc(100vh - var(--ds-header-h));
  overflow-y: auto;
  padding: 32px 0 40px;
  scrollbar-width: thin;
}
.ds-sidebar-group-label {
  display: flex;
  padding: 18px 10px 6px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ds-ash);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ds-sidebar-group-label:first-child { padding-top: 6px; }

.ds-sidebar-link {
  display: block;
  padding: 5px 10px;
  margin-bottom: 2px;
  font-size: var(--ds-text-sm);
  color: var(--ds-graphite);
  text-decoration: none;
  border-radius: 6px;
  line-height: 1.45;
  cursor: pointer;
  transition: background var(--ds-transition), color var(--ds-transition);
}
.ds-sidebar-link:hover,
.ds-sidebar-link.is-active {
  color: var(--ds-ink);
  font-weight: 500;
  background: var(--ds-parchment);
}

/* ===================================================================
   16. UTILITIES
   =================================================================== */
.ds-divider {
  height: 1px;
  background: var(--ds-stone);
  border: none;
  margin: 36px 0;
}

.ds-hidden { display: none !important; }

/* Spinner */
.ds-spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--ds-stone);
  border-top-color: var(--ds-green);
  border-radius: 50%;
  animation: ds-spin 0.7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* Heading flash (for search jumps) */
@keyframes ds-heading-flash {
  0%   { background-color: var(--ds-mint); }
  40%  { background-color: var(--ds-mint); }
  100% { background-color: transparent; }
}
.ds-heading-highlight {
  animation: ds-heading-flash 2s ease-out forwards;
  border-radius: 4px;
  padding-left: 6px;
  margin-left: -6px;
}

/* ===================================================================
   18. RESPONSIVE
   =================================================================== */
@media (max-width: 820px) {
  .ds-card-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .ds-card-grid { grid-template-columns: 1fr; }
  :root { --ds-outer-px: 16px; }
}
