/* ==========================================================================
   Tolstoy — design system
   --------------------------------------------------------------------------
   "Print bay": dark-first, hairline borders, one signal accent (teal),
   mono micro-labels, display type for headings. Framework-agnostic: no build
   step, no Tailwind, no JS. Link this file and use the classes in DESIGN.md.

   Theme: light by default; html[data-theme="dark"] flips it. Without an
   explicit value it follows the OS. Always set data-theme from an inline
   script in <head> to avoid a flash (see DESIGN.md § Themes).

   Version: 1.1.0
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Fonts (self-hosted, OFL — see css/fonts/LICENSE-*.txt)
   -------------------------------------------------------------------------- */

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("./fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("./fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: "Space Grotesk Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 300 700;
  src: url("./fonts/space-grotesk-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Grotesk Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 300 700;
  src: url("./fonts/space-grotesk-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url("./fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url("./fonts/jetbrains-mono-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

/* --------------------------------------------------------------------------
   2. Tokens
   -------------------------------------------------------------------------- */

:root {
  --radius: 0.75rem;
  --font-sans: "Inter Variable", Inter, system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk Variable", "Space Grotesk", "Inter Variable",
    system-ui, sans-serif;
  --font-mono: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace,
    SFMono-Regular, monospace;

  --container: 1320px;
  --gutter: 1rem;
  --gutter-lg: 2rem;

  --background: #f4f6f9;
  --foreground: #0e1217;
  --card: #ffffff;
  --card-foreground: #0e1217;
  --popover: #ffffff;
  --popover-foreground: #0e1217;
  --muted: #ebeff4;
  --muted-foreground: #4f5a6b;
  --border: #dfe4eb;
  --input: #c9d1dc;
  --ring: #0e9f83;

  --primary: #0e9f83;
  --primary-foreground: #ffffff;
  --signal: #0e9f83;
  --signal-soft: rgb(14 159 131 / 0.12);
  --warn: #a86500;
  --info: #0369a1;
  --destructive: #c62828;
  --destructive-foreground: #ffffff;

  /* Compatibility aliases for shadcn/Tailwind projects (LiMa). They resolve
     against the active theme, so secondary/accent follow muted and success
     follows the signal accent. */
  --secondary: var(--muted);
  --secondary-foreground: var(--foreground);
  --accent: var(--muted);
  --accent-foreground: var(--foreground);
  --success: var(--signal);

  --line-strong: #c9d1dc;
  --dim: #5e6878;
  --thumb: #e4eaf1;
  --dot: rgb(0 0 0 / 0.1);
  --terminal: #0b0e12;

  /* The one elevation exception: floating layers only. */
  --shadow-overlay: 0 18px 48px -20px rgb(0 0 0 / 0.35);

  color-scheme: light;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Dark tokens are applied when the theme is explicit, and when the OS asks for
   dark and the user has not pinned light. Keep these two blocks identical. */
[data-theme="dark"] {
  --background: #07090c;
  --foreground: #e7ecf3;
  --card: #0e1217;
  --card-foreground: #e7ecf3;
  --popover: #0e1217;
  --popover-foreground: #e7ecf3;
  --muted: #141922;
  --muted-foreground: #9aa4b5;
  --border: #1c232d;
  --input: #2a3340;
  --ring: #4fe3c1;

  --primary: #4fe3c1;
  --primary-foreground: #04110d;
  --signal: #4fe3c1;
  --signal-soft: rgb(79 227 193 / 0.12);
  --warn: #f5b544;
  --info: #7dd3fc;
  --destructive: #ff7a7a;
  --destructive-foreground: #1a0b0b;

  --secondary: var(--muted);
  --secondary-foreground: var(--foreground);
  --accent: var(--muted);
  --accent-foreground: var(--foreground);
  --success: var(--signal);

  --line-strong: #2a3340;
  --dim: #7a8597;
  --thumb: #10161d;
  --dot: rgb(255 255 255 / 0.09);
  --terminal: #05070a;
  --shadow-overlay: 0 18px 48px -20px rgb(0 0 0 / 0.8);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #07090c;
    --foreground: #e7ecf3;
    --card: #0e1217;
    --card-foreground: #e7ecf3;
    --popover: #0e1217;
    --popover-foreground: #e7ecf3;
    --muted: #141922;
    --muted-foreground: #9aa4b5;
    --border: #1c232d;
    --input: #2a3340;
    --ring: #4fe3c1;

    --primary: #4fe3c1;
    --primary-foreground: #04110d;
    --signal: #4fe3c1;
    --signal-soft: rgb(79 227 193 / 0.12);
    --warn: #f5b544;
    --info: #7dd3fc;
    --destructive: #ff7a7a;
    --destructive-foreground: #1a0b0b;

    --secondary: var(--muted);
    --secondary-foreground: var(--foreground);
    --accent: var(--muted);
    --accent-foreground: var(--foreground);
    --success: var(--signal);

    --line-strong: #2a3340;
    --dim: #7a8597;
    --thumb: #10161d;
    --dot: rgb(255 255 255 / 0.09);
    --terminal: #05070a;
    --shadow-overlay: 0 18px 48px -20px rgb(0 0 0 / 0.8);

    color-scheme: dark;
  }
}

/* --------------------------------------------------------------------------
   3. Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  border-color: var(--border);
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

::selection {
  background: var(--signal-soft);
  color: var(--foreground);
}

/* --------------------------------------------------------------------------
   4. Layout
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

@media (min-width: 640px) {
  .container {
    padding-inline: var(--gutter-lg);
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, 1rem);
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--row-gap, 0.75rem);
}

.spread {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

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

/* --------------------------------------------------------------------------
   5. Type utilities
   -------------------------------------------------------------------------- */

.mono {
  font-family: var(--font-mono);
  font-variant-ligatures: none;
}

.display {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.dim {
  color: var(--dim);
}

.muted {
  color: var(--muted-foreground);
}

.signal {
  color: var(--signal);
}

/* Mono micro-label: "// 01 — LIBRARY" */
.label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.label--signal {
  color: var(--signal);
}

.hairline {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 0;
}

.measure {
  max-width: 68ch;
}

/* --------------------------------------------------------------------------
   6. Backgrounds & decorations
   -------------------------------------------------------------------------- */

/* Hairline grid, used behind page heroes. */
.bg-grid {
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
}

/* Dot matrix, used behind empty states and thumbnails. */
.bg-dots {
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 14px 14px;
}

/* Accent corner brackets (top-left + bottom-right). */
.corners {
  position: relative;
}
.corners::before,
.corners::after {
  content: "";
  position: absolute;
  z-index: 2;
  width: var(--corner-size, 14px);
  height: var(--corner-size, 14px);
  border-color: var(--signal);
  border-style: solid;
  pointer-events: none;
}
.corners::before {
  top: var(--corner-inset, 10px);
  left: var(--corner-inset, 10px);
  border-width: 1.5px 0 0 1.5px;
}
.corners::after {
  bottom: var(--corner-inset, 10px);
  right: var(--corner-inset, 10px);
  border-width: 0 1.5px 1.5px 0;
}

/* Segmented progress fill. */
.bg-scan {
  background: repeating-linear-gradient(
    90deg,
    var(--signal) 0 6px,
    transparent 6px 9px
  );
}

/* --------------------------------------------------------------------------
   7. Chrome: top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 85%, transparent);
  backdrop-filter: blur(12px);
}

.topbar__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding-block: 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--foreground);
}

.brand__mark {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  background: var(--primary);
  color: var(--primary-foreground);
}

.brand__name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.nav {
  display: flex;
  gap: 0.25rem;
}

.nav a {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav a:hover {
  color: var(--foreground);
}

.nav a[aria-current="page"] {
  background: var(--muted);
  color: var(--foreground);
  font-weight: 500;
}

.grow {
  flex: 1 1 auto;
}

/* --------------------------------------------------------------------------
   8. Hero
   -------------------------------------------------------------------------- */

.hero {
  border-bottom: 1px solid var(--border);
}

.hero__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 164px;
  padding-block: 2.5rem 2rem;
}

@media (min-width: 640px) {
  .hero__inner {
    min-height: 188px;
    padding-block: 3rem 2rem;
  }
}

.hero__eyebrow {
  display: block;
  margin-bottom: 0.625rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--signal);
}

.hero__title {
  font-size: clamp(2.5rem, 6vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.035em;
}

.hero__sub {
  margin-top: 0.625rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

/* --------------------------------------------------------------------------
   9. Buttons, inputs, kbd
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.5rem;
  padding: 0 1rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: var(--primary);
  color: var(--primary-foreground);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  background: color-mix(in srgb, var(--primary) 88%, var(--foreground));
}

.btn:active {
  transform: translateY(1px);
}

.btn--outline {
  border-color: var(--input);
  background: var(--card);
  color: var(--foreground);
  font-weight: 500;
}

.btn--outline:hover {
  background: var(--muted);
  border-color: var(--line-strong);
}

.btn--ghost {
  background: transparent;
  color: var(--muted-foreground);
  font-weight: 500;
}

.btn--ghost:hover {
  background: var(--muted);
  color: var(--foreground);
}

.btn--destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.btn--destructive:hover {
  background: color-mix(in srgb, var(--destructive) 86%, var(--foreground));
}

.btn--sm {
  height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
}

.btn--lg {
  height: 2.75rem;
  padding: 0 1.25rem;
  font-size: 0.9375rem;
}

.btn--icon {
  width: 2.5rem;
  padding: 0;
}

.btn--sm.btn--icon {
  width: 2rem;
}

.btn--lg.btn--icon {
  width: 2.75rem;
}

.btn svg {
  width: 1rem;
  height: 1rem;
}

.input {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem;
  border: 1px solid var(--input);
  border-radius: 0.5rem;
  background: var(--card);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 0.875rem;
}

.input::placeholder {
  color: var(--dim);
}

.input:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent);
}

.kbd {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0.125rem 0.375rem;
  border: 1px solid var(--input);
  border-radius: 0.25rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-align: center;
}

/* Textarea and select share the input surface. */
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: 0.5rem;
  background: var(--card);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea {
  min-height: 5.5rem;
  padding: 0.625rem 0.75rem;
  resize: vertical;
}

.select {
  height: 2.5rem;
  padding: 0 2rem 0 0.75rem;
  appearance: none;
  cursor: pointer;
}

.select-wrap {
  position: relative;
  display: block;
}

.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0.9rem;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid var(--dim);
  border-bottom: 1.5px solid var(--dim);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.textarea::placeholder {
  color: var(--dim);
}

.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Form field: label, control, hint/error. */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field__label {
  font-size: 0.8125rem;
  font-weight: 500;
}

.field__hint {
  font-size: 0.75rem;
  color: var(--dim);
}

.field__error {
  font-size: 0.75rem;
  color: var(--destructive);
}

.field--row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--signal);
}

/* --------------------------------------------------------------------------
   10. Cards
   -------------------------------------------------------------------------- */

.card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--card-foreground);
  transition: border-color 0.15s ease, transform 0.15s ease,
    background-color 0.15s ease;
}

a.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.card__kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: var(--dim);
}

.card__title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.card__desc {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

/* --------------------------------------------------------------------------
   11. Badges & chips
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.125rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  line-height: 1.5;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge--outline {
  border-color: var(--border);
  background: transparent;
}

.badge--signal {
  border-color: color-mix(in srgb, var(--signal) 35%, transparent);
  background: var(--signal-soft);
  color: var(--signal);
}

.badge--warn {
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  color: var(--warn);
}

.badge--success {
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  color: var(--success);
}

.badge--info {
  border-color: color-mix(in srgb, var(--info) 35%, transparent);
  background: color-mix(in srgb, var(--info) 10%, transparent);
  color: var(--info);
}

.badge--destructive {
  border-color: color-mix(in srgb, var(--destructive) 35%, transparent);
  background: color-mix(in srgb, var(--destructive) 10%, transparent);
  color: var(--destructive);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--line-strong);
  color: var(--foreground);
}

.chip[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--signal) 45%, transparent);
  background: var(--signal-soft);
  color: var(--signal);
}

/* Small dot used to mark status. */
.dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 999px;
  background: var(--signal);
}

.dot--warn {
  background: var(--warn);
}

.dot--info {
  background: var(--info);
}

.dot--error {
  background: var(--destructive);
}

/* --------------------------------------------------------------------------
   12. Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

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

.table th {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--muted);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--muted) 45%, transparent);
}

.table tr[data-state="warn"] td {
  background: color-mix(in srgb, var(--warn) 8%, transparent);
}

.table tr[data-state="error"] td {
  background: color-mix(in srgb, var(--destructive) 8%, transparent);
}

.table--compact th,
.table--compact td {
  padding-block: 0.375rem;
}

.table--log td {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   13. Tabs
   -------------------------------------------------------------------------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.tabs a,
.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tabs a:hover,
.tabs button:hover {
  color: var(--foreground);
}

.tabs [aria-current="page"],
.tabs [aria-selected="true"] {
  border-bottom-color: var(--signal);
  color: var(--foreground);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   14. Alerts & stats
   -------------------------------------------------------------------------- */

.alert {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--signal);
  border-radius: 0.5rem;
  background: var(--card);
  font-size: 0.875rem;
}

.alert__title {
  font-weight: 600;
}

.alert__body {
  color: var(--muted-foreground);
}

.alert--success {
  border-left-color: var(--success);
  background: color-mix(in srgb, var(--success) 7%, var(--card));
}

.alert--warn {
  border-left-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 7%, var(--card));
}

.alert--info {
  border-left-color: var(--info);
  background: color-mix(in srgb, var(--info) 7%, var(--card));
}

.alert--error {
  border-left-color: var(--destructive);
  background: color-mix(in srgb, var(--destructive) 7%, var(--card));
}

.stats {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: inherit;
}

a.stat {
  transition: border-color 0.15s ease, transform 0.15s ease;
}

a.stat:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.stat__value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat__label {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.stat--success .stat__value {
  color: var(--success);
}

.stat--info .stat__value {
  color: var(--info);
}

.stat--warn .stat__value {
  color: var(--warn);
}

.stat--error .stat__value {
  color: var(--destructive);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-block: 1rem;
}

.pager__status {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--dim);
}

/* --------------------------------------------------------------------------
   15. Overlays: dialog, menu, command
   --------------------------------------------------------------------------
   CSS shells only. Open/close, focus trapping and keyboard navigation belong
   to the consuming project; native <dialog> gives the backdrop for free. */

.dialog {
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  overflow: auto;
  box-shadow: var(--shadow-overlay);
}

.dialog::backdrop {
  background: color-mix(in srgb, var(--background) 72%, transparent);
  backdrop-filter: blur(4px);
}

.dialog__header {
  position: relative;
  padding: 1.25rem 1.25rem 0;
}

.dialog__title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.dialog__desc {
  margin-top: 0.375rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.dialog__body {
  padding: 1rem 1.25rem;
}

.dialog__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0 1.25rem 1.25rem;
}

.dialog__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}

.dialog__close:hover {
  background: var(--muted);
  color: var(--foreground);
}

.menu {
  min-width: 10rem;
  padding: 0.25rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.5rem;
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-overlay);
}

.menu__item,
.command__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.375rem 0.5rem;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
}

.menu__item:hover,
.menu__item:focus-visible,
.menu__item[data-highlighted],
.command__item:hover,
.command__item:focus-visible,
.command__item[data-selected="true"] {
  background: var(--muted);
  color: var(--foreground);
}

.menu__item--destructive {
  color: var(--destructive);
}

.menu__separator {
  height: 1px;
  margin: 0.25rem -0.25rem;
  background: var(--border);
}

.menu__label {
  padding: 0.375rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.menu__shortcut {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
  color: var(--dim);
}

.command {
  display: flex;
  flex-direction: column;
  max-height: min(28rem, 70vh);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-overlay);
}

.command__input {
  height: 2.75rem;
  padding: 0 0.75rem;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 0.875rem;
}

.command__input:focus {
  outline: none;
}

.command__list {
  overflow-y: auto;
  padding: 0.375rem;
}

.command__group-label {
  padding: 0.375rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.command__empty {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--dim);
}

/* --------------------------------------------------------------------------
   16. Section headers
   -------------------------------------------------------------------------- */

.section {
  padding-block: 1.75rem 0.25rem;
}

.section__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.section__rule {
  flex: 1 1 auto;
  height: 1px;
  background: var(--border);
}

.section__count {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--dim);
}

/* --------------------------------------------------------------------------
   17. Empty state
   -------------------------------------------------------------------------- */

.empty {
  padding: 2.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.empty__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.empty__body {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

/* --------------------------------------------------------------------------
   18. Footer
   -------------------------------------------------------------------------- */

.footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-block: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--dim);
}

.footer a {
  color: var(--muted-foreground);
}

.footer a:hover {
  color: var(--signal);
}

/* --------------------------------------------------------------------------
   19. Motion
   -------------------------------------------------------------------------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.rise {
  animation: rise 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 25ms);
}

@keyframes signal-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--signal) 55%, transparent);
  }
  70% {
    box-shadow: 0 0 0 8px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.pulse-signal {
  animation: signal-pulse 2s infinite;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .rise,
  .pulse-signal {
    animation: none;
  }
  .card,
  .btn,
  a.stat {
    transition: none;
  }
  a.card:hover,
  a.stat:hover {
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   20. Print
   -------------------------------------------------------------------------- */

@media print {
  .topbar,
  .footer {
    display: none;
  }
  .bg-grid {
    background-image: none;
  }
  body {
    background: #fff;
    color: #000;
  }
}
