@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/instrument-sans.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('fonts/newsreader.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url('fonts/jetbrains-mono.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Beetle design language — shared tokens + primitives.
   Canonical documentation: /DESIGN.md. Keep this file framework-free. */

:root {
  /* type */
  --ds-font-sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ds-font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --ds-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ds-text-xs: 12px;
  --ds-text-sm: 13px;
  --ds-text-base: 14px;
  --ds-text-md: 16px;
  --ds-text-lg: 20px;
  --ds-text-xl: 26px;
  --ds-text-2xl: clamp(32px, 4vw, 44px);
  --ds-text-display: clamp(40px, 6vw, 72px);

  /* controls */
  --ds-control-height: 42px;
  --ds-control-radius: 10px;

  /* palette — warm paper, ink, lime signal */
  --ds-paper: #f4f3ef;
  --ds-surface: #ffffff;
  --ds-surface-alt: #ebeae5;
  --ds-ink: #121212;
  --ds-ink-2: #4b504c;
  --ds-ink-3: #6a6f6a;
  --ds-rule: #dfddd5;
  --ds-rule-strong: #c5c3b9;

  --ds-brand: #121212;
  --ds-brand-hover: #000000;
  --ds-signal: #c2e86a;
  --ds-signal-soft: #edf5d2;
  --ds-link: #2449c4;

  --ds-success: #0a7b4a;
  --ds-success-soft: #e6f4ec;
  --ds-warning: #b86a15;
  --ds-warning-soft: #fbf1e2;
  --ds-danger: #c92a2a;
  --ds-danger-soft: #fbeaec;

  /* spacing (4px base) */
  --ds-space-1: 4px;
  --ds-space-2: 8px;
  --ds-space-3: 12px;
  --ds-space-4: 16px;
  --ds-space-5: 20px;
  --ds-space-6: 24px;
  --ds-space-8: 32px;
  --ds-space-10: 40px;
  --ds-space-12: 48px;

  /* shape + motion */
  --ds-radius-sm: 6px;
  --ds-radius-md: 10px;
  --ds-radius-lg: 14px;
  --ds-radius-full: 999px;
  --ds-shadow-sm: 0 1px 2px rgba(18, 18, 18, 0.05);
  --ds-shadow-md: 0 12px 32px rgba(18, 18, 18, 0.1);
  --ds-motion-fast: 120ms ease;
  --ds-motion: 180ms ease;
  --ds-focus: 0 0 0 3px rgba(36, 73, 196, 0.2);
}

/* ---------- type helpers ---------- */
.ds-display { font-family: var(--ds-font-sans); font-size: var(--ds-text-display); font-weight: 500; line-height: 1.02; letter-spacing: -0.035em; }
.ds-serif { font-family: var(--ds-font-serif); font-weight: 500; letter-spacing: -0.015em; }
.ds-mono { font-family: var(--ds-font-mono); }
.ds-eyebrow {
  font-family: var(--ds-font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ds-ink-2);
}
.ds-muted { color: var(--ds-ink-3); }
.ds-link { color: var(--ds-link); text-underline-offset: 2px; }

/* ---------- rules and sections ---------- */
.ds-rule { height: 1px; background: var(--ds-rule); border: 0; margin: 0; }
.ds-section { border-top: 1px solid var(--ds-rule); padding-top: var(--ds-space-5); margin-top: var(--ds-space-5); }
.ds-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.ds-section-title { font-size: var(--ds-text-sm); font-weight: 600; letter-spacing: 0; margin: 0 0 var(--ds-space-3); }

/* ---------- buttons ---------- */
.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  height: 40px;
  padding: 0 var(--ds-space-4);
  border: 1px solid transparent;
  border-radius: var(--ds-radius-sm);
  background: var(--ds-brand);
  color: #fff;
  font: 500 var(--ds-text-base)/1 var(--ds-font-sans);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--ds-motion-fast), border-color var(--ds-motion-fast);
}
.ds-btn:hover { background: var(--ds-brand-hover); text-decoration: none; }
.ds-btn:focus-visible { outline: none; box-shadow: var(--ds-focus); }
.ds-btn:disabled { opacity: 0.45; cursor: default; }
.ds-btn-secondary { background: transparent; border-color: var(--ds-rule-strong); color: var(--ds-ink); }
.ds-btn-secondary:hover { background: var(--ds-surface-alt); }
.ds-btn-ghost { background: transparent; color: var(--ds-ink-2); }
.ds-btn-ghost:hover { background: var(--ds-surface-alt); color: var(--ds-ink); }
.ds-btn-danger { background: transparent; color: var(--ds-danger); border-color: transparent; }
.ds-btn-danger:hover { background: var(--ds-danger-soft); }
.ds-btn-sm { height: 32px; padding: 0 var(--ds-space-3); font-size: var(--ds-text-sm); }

/* ---------- form controls ---------- */
.ds-field { display: flex; flex-direction: column; gap: var(--ds-space-2); }
.ds-label { font-size: var(--ds-text-sm); font-weight: 600; color: var(--ds-ink-2); }
.ds-hint { font-size: var(--ds-text-xs); color: var(--ds-ink-3); }
.ds-input,
.ds-select,
.ds-textarea {
  width: 100%;
  min-height: var(--ds-control-height);
  padding: 10px 13px;
  border: 1px solid var(--ds-rule-strong);
  border-radius: var(--ds-control-radius);
  background: var(--ds-surface);
  color: var(--ds-ink);
  font: 400 14.5px/1.45 var(--ds-font-sans);
  box-shadow: inset 0 1px 2px rgba(17, 24, 39, 0.03);
  transition: border-color var(--ds-motion-fast), box-shadow var(--ds-motion-fast);
}
.ds-input::placeholder,
.ds-textarea::placeholder { color: var(--ds-ink-3); }
.ds-input:hover,
.ds-select:hover,
.ds-textarea:hover { border-color: var(--ds-ink-3); }
.ds-input:focus,
.ds-select:focus,
.ds-textarea:focus { outline: none; border-color: var(--ds-link); box-shadow: var(--ds-focus); }

/* ---------- cards ---------- */
.ds-card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-radius-md);
  padding: var(--ds-space-5);
  min-width: 0;
}
.ds-card-flat { background: transparent; border: 0; border-top: 1px solid var(--ds-rule); border-radius: 0; padding: var(--ds-space-5) 0; }
.ds-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ds-space-4); margin-bottom: var(--ds-space-4); }
.ds-card-title { margin: 0; font-size: var(--ds-text-md); font-weight: 600; letter-spacing: -0.01em; }
.ds-card-sub { margin: 2px 0 0; font-size: var(--ds-text-sm); color: var(--ds-ink-2); }

/* ---------- pills ---------- */
.ds-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--ds-radius-full);
  background: var(--ds-surface-alt);
  color: var(--ds-ink-2);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.ds-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.ds-pill-success { background: var(--ds-success-soft); color: var(--ds-success); }
.ds-pill-warning { background: var(--ds-warning-soft); color: var(--ds-warning); }
.ds-pill-danger { background: var(--ds-danger-soft); color: var(--ds-danger); }
.ds-pill-plain::before { display: none; }

/* ---------- stats ---------- */
.ds-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-block: 1px solid var(--ds-rule); }
.ds-stat { padding: var(--ds-space-4) var(--ds-space-5); border-left: 1px solid var(--ds-rule); min-width: 0; }
.ds-stat:first-child { border-left: 0; padding-left: 0; }
.ds-stat-label { font-size: var(--ds-text-xs); font-weight: 600; color: var(--ds-ink-2); }
.ds-stat-value { margin-top: 2px; font-size: var(--ds-text-xl); font-weight: 600; letter-spacing: -0.02em; }
.ds-stat-sub { margin-top: 2px; font-size: var(--ds-text-xs); color: var(--ds-ink-3); }
@media (max-width: 720px) { .ds-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ds-stat:nth-child(3) { border-left: 0; padding-left: 0; } }

/* ---------- tables ---------- */
.ds-table { width: 100%; border-collapse: collapse; font-size: var(--ds-text-sm); }
.ds-table th { text-align: left; padding: var(--ds-space-2) var(--ds-space-3) var(--ds-space-2) 0; border-bottom: 1px solid var(--ds-rule); font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ds-ink-3); }
.ds-table td { padding: var(--ds-space-3) var(--ds-space-3) var(--ds-space-3) 0; border-bottom: 1px solid var(--ds-rule); vertical-align: middle; }
.ds-table tbody tr:last-child td { border-bottom: 0; }
.ds-table .ds-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- tabs ---------- */
.ds-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--ds-rule); overflow-x: auto; }
.ds-tab {
  margin-bottom: -1px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ds-ink-2);
  font: 500 var(--ds-text-sm)/1 var(--ds-font-sans);
  white-space: nowrap;
  cursor: pointer;
}
.ds-tab:hover { color: var(--ds-ink); }
.ds-tab[aria-selected="true"], .ds-tab.active { border-bottom-color: var(--ds-ink); color: var(--ds-ink); font-weight: 600; }

/* ---------- empty ---------- */
.ds-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ds-space-2);
  padding: var(--ds-space-10) var(--ds-space-6);
  border: 1px dashed var(--ds-rule-strong);
  border-radius: var(--ds-radius-md);
  color: var(--ds-ink-2);
  text-align: center;
}
.ds-empty-title { font-size: var(--ds-text-md); font-weight: 600; color: var(--ds-ink); }
.ds-empty-text { font-size: var(--ds-text-sm); }

/* ---------- code ---------- */
.ds-code {
  display: block;
  overflow-x: auto;
  padding: var(--ds-space-4);
  border: 1px solid var(--ds-rule);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-surface-alt);
  color: var(--ds-ink);
  font-family: var(--ds-font-mono);
  font-size: 12.5px;
  line-height: 1.6;
}

/* Entity preview */
.ds-has-preview { cursor: help; }
.ds-preview {
  position: fixed;
  z-index: 120;
  max-width: 300px;
  padding: 12px 14px;
  border: 1px solid var(--ds-rule-strong);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(17, 24, 39, 0.14), 0 2px 6px rgba(17, 24, 39, 0.06);
  color: var(--ds-ink);
  font: 400 13px/1.45 var(--ds-font-sans);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-2px);
  transition: opacity .12s, transform .12s, visibility .12s;
  pointer-events: none;
}
.ds-preview.is-open { opacity: 1; visibility: visible; transform: none; }
.ds-preview-title { font-weight: 600; font-size: 13.5px; overflow-wrap: anywhere; }
.ds-preview-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin: 8px 0 0;
}
.ds-preview-facts dt {
  color: var(--ds-ink-3);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ds-preview-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.ds-preview-note { margin: 8px 0 0; color: var(--ds-ink-2); font-size: 12px; }
.ds-preview-link { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 600; }

/* Signature state */
.ds-verify {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font: 500 12.5px/1.4 var(--ds-font-sans);
  color: var(--ds-ink-2);
}
.ds-verify-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--ds-rule-strong);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.ds-verify-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.ds-verify.is-signed { color: var(--ds-success, #1a7f37); }
.ds-verify.is-signed .ds-verify-pill { border-color: currentColor; background: #eef8f0; }
.ds-verify.is-failed { color: var(--ds-danger, #cf222e); }
.ds-verify.is-failed .ds-verify-pill { border-color: currentColor; background: #fdecee; }
.ds-verify.is-unsigned, .ds-verify.is-checking { color: var(--ds-ink-3); }
.ds-verify.is-checking .ds-verify-pill::before { animation: ds-pulse 1s ease-in-out infinite; }
.ds-verify-text { color: var(--ds-ink-2); font-weight: 400; }
.ds-verify-link { font-size: 12px; font-weight: 600; }
@keyframes ds-pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
