/* =============================================================================
   StingyWeb — design system: THE INDEX
   -----------------------------------------------------------------------------
   The product is an archive: websites distilled into a structured catalogue.
   The interface borrows the material of archives — catalogue cards, specimen
   labels, ruled index rows — and rebuilds it as modern software.

   Voice:
     · Fraunces (display serif)  — the catalogue's public voice.
     · Inter (grotesk)           — the working voice: UI and body copy.
     · IBM Plex Mono             — the card-catalogue voice: labels, kickers,
                                   metadata, numbers, buttons. Uppercase,
                                   letterspaced, always deliberate.
   Material:
     · Warm paper ground, near-black ink, ONE vermilion accent.
     · A hairline rule beats a box. A box beats a shadow. Shadows exist
       only for true overlays (modals, toasts, menus).
     · Numbers are mono and tabular, always.
     · Corners are close to square — this is print, not bubble-gum.

   Contents:  1 tokens · 2 reset · 3 typography · 4 layout utilities
              5 buttons · 6 cards · 7 stat strip · 8 tables · 9 badges + tags
              10 forms · 11 progress + meters · 12 feedback (flash, toast,
              empty, skeleton, modal, tooltip) · 13 misc (kbd, divider)
   ========================================================================== */

/* 1 · TOKENS ---------------------------------------------------------------- */
:root {
  /* warm paper + ink */
  --bg: #f4f1ea;
  --surface: #fbf9f4;
  --surface-2: #eeeae0;
  --surface-3: #e5e0d3;
  --border: #e0dbcd;
  --border-strong: #c8c1ae;
  --overlay: rgba(28, 24, 18, 0.5);

  --text: #262119;
  --text-heading: #1a1610;
  --text-muted: #6d6555;
  --text-subtle: #948b76;
  --text-inverse: #f6f3ea;

  /* ink — primary actions */
  --ink: #1c1812;
  --ink-hover: #000000;
  --ink-active: #322c22;

  /* the accent: vermilion. Spent on ways in — links, focus, live state. */
  --brand: #c03d12;
  --brand-hover: #a4330e;
  --brand-active: #8a2b0c;
  --brand-soft: #f6e3d8;
  --brand-200: #ebc4ad;
  --brand-300: #d98a5f;

  /* semantic */
  --success: #34691f;  --success-bg: #e9efdd;  --success-border: #c8d6ae;
  --warning: #93600a;  --warning-bg: #f5ecd4;  --warning-border: #e2cf9d;
  --danger:  #a92e21;  --danger-bg:  #f6e5e0;  --danger-border:  #e5c0b5;
  --info:    #275e8d;  --info-bg:    #e3ecf1;  --info-border:    #bad0de;
  --teal:    #146d62;  --teal-bg:    #e0efeb;  --teal-border:    #b3d6cd;
  --purple:  #6d3f92;  --purple-bg:  #efe7f3;  --purple-border:  #d3bede;

  /* radii — close to square. This is print. */
  --r-xs: 2px;
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-full: 999px;

  /* shadows — overlays only; surfaces sit flat on the paper */
  --shadow-xs: none;
  --shadow-sm: 0 1px 2px rgba(28, 24, 18, 0.06);
  --shadow-md: 0 10px 30px rgba(28, 24, 18, 0.14), 0 2px 6px rgba(28, 24, 18, 0.07);
  --shadow-lg: 0 28px 70px rgba(28, 24, 18, 0.22), 0 4px 14px rgba(28, 24, 18, 0.09);

  /* spacing */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s7: 32px; --s8: 40px; --s9: 48px; --s10: 64px;

  /* type */
  --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --font-display: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont,
          Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino,
          Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", SFMono-Regular,
          Menlo, Consolas, monospace;

  --track-tight: -0.022em;
  --track-display: -0.03em;
  --track-caps: 0.1em;

  --transition: 0.14s ease;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171410;
    --surface: #1e1a15;
    --surface-2: #262119;
    --surface-3: #2f291f;
    --border: #2e281f;
    --border-strong: #463e30;
    --overlay: rgba(0, 0, 0, 0.62);

    --text: #e5dfd2;
    --text-heading: #f4efe4;
    --text-muted: #a19883;
    --text-subtle: #766d5b;
    --text-inverse: #1c1812;

    /* in the dark, ink inverts: the primary action is paper */
    --ink: #efe9db;
    --ink-hover: #fffdf6;
    --ink-active: #d6cfbf;

    --brand: #f4703b;
    --brand-hover: #ff8656;
    --brand-active: #d95c2b;
    --brand-soft: #3a1c0d;
    --brand-200: #64301a;
    --brand-300: #a04a26;

    --success: #8fbc71;  --success-bg: #1d2514;  --success-border: #34461f;
    --warning: #d8a752;  --warning-bg: #2a2211;  --warning-border: #4e3f1f;
    --danger:  #e2796a;  --danger-bg:  #2d1712;  --danger-border:  #562a20;
    --info:    #82afd4;  --info-bg:    #14202b;  --info-border:    #29455c;
    --teal:    #6dbcae;  --teal-bg:    #10231f;  --teal-border:    #204741;
    --purple:  #b48cd4;  --purple-bg:  #241729;  --purple-border:  #472f56;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6), 0 4px 14px rgba(0, 0, 0, 0.4);
  }
}

/* 2 · RESET ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

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

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11"; /* single-storey a alt off; keep Inter defaults sane */
}

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

input, button, textarea, select { font: inherit; color: inherit; }

button { background: none; border: none; padding: 0; cursor: pointer; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

ul, ol { padding-left: 1.25em; }

::selection { background: var(--brand); color: #fff8f2; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--s2);
  z-index: 100;
  padding: var(--s2) var(--s4);
  background: var(--ink);
  color: var(--text-inverse);
  border-radius: var(--r-sm);
  font-weight: 600;
}
.skip-link:focus { left: var(--s2); text-decoration: none; }

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

/* 3 · TYPOGRAPHY ------------------------------------------------------------ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text-heading);
  font-weight: 650;
  letter-spacing: var(--track-tight);
  line-height: 1.22;
  text-wrap: balance;
}

h1 { font-size: 25px; }
h2 { font-size: 17px; }
h3 { font-size: 14.5px; }
h4 { font-size: 13px; }

p { text-wrap: pretty; }

/* the catalogue-card voice: every label in the product speaks mono caps */
.label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--text-subtle);
}

.lede {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-muted);
}

.mono { font-family: var(--font-mono); font-size: 0.92em; }
.tabular, .num { font-variant-numeric: tabular-nums; }

.muted  { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }

.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-brand   { color: var(--brand); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-info    { color: var(--info); }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.breakword { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.clamp-2, .clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clamp-2 { -webkit-line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; }

/* 4 · LAYOUT UTILITIES ------------------------------------------------------ */
.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--s6);
}

.stack   { display: flex; flex-direction: column; }
.stack-1 { display: flex; flex-direction: column; gap: var(--s1); }
.stack-2 { display: flex; flex-direction: column; gap: var(--s2); }
.stack-3 { display: flex; flex-direction: column; gap: var(--s3); }
.stack-4 { display: flex; flex-direction: column; gap: var(--s4); }
.stack-5 { display: flex; flex-direction: column; gap: var(--s5); }
.stack-6 { display: flex; flex-direction: column; gap: var(--s6); }
.stack-7 { display: flex; flex-direction: column; gap: var(--s7); }
.stack-8 { display: flex; flex-direction: column; gap: var(--s8); }

.row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.row-tight { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.row-loose { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: var(--s3); }
.row-baseline { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; }
.row-top { display: flex; align-items: flex-start; gap: var(--s3); }
.row-nowrap { flex-wrap: nowrap; }
.spacer { flex: 1; }

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

@media (max-width: 1024px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-md { display: none !important; }
}
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
}
.hide { display: none !important; }

/* 5 · BUTTONS ----------------------------------------------------------------
   Buttons speak the catalogue-card voice: mono, uppercase, letterspaced,
   near-square. The primary action is a solid slab of ink. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  height: 36px;
  padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--text-inverse);
}
.btn-primary:hover {
  background: var(--ink-hover);
  border-color: var(--ink-hover);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-heading);
}
.btn-secondary:hover { border-color: var(--ink); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-heading); }

.btn-danger {
  background: transparent;
  border-color: var(--danger-border);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-link {
  background: none;
  border: none;
  height: auto;
  padding: 0;
  color: var(--brand);
  font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }

.btn-sm { height: 28px; padding: 0 11px; font-size: 10px; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-group { display: inline-flex; gap: var(--s2); }

.btn[disabled], .btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  color: var(--text-subtle);
  animation: spin 0.7s linear infinite;
}
.btn-primary.is-loading::after { color: var(--text-inverse); }

@keyframes spin { to { transform: rotate(360deg); } }

/* 6 · CARDS ------------------------------------------------------------------
   A card is a sheet of lighter paper with a hairline edge. It does not float. */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head .card-title { font-size: 14.5px; letter-spacing: -0.012em; }
.card-head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-head-text p { font-size: 12.5px; color: var(--text-subtle); }

.card-body { padding: var(--s5); }
.card-body-flush { padding: 0; }
.card-foot {
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s3);
}

.card-quiet { background: var(--surface-2); border-color: transparent; }

/* 7 · STAT STRIP -------------------------------------------------------------
   Not cards: one ruled ledger row. Each figure sits under a heavy ink rule,
   captioned in mono, set in mono numerals. The dashboard reads like the
   opening spread of a report. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  column-gap: var(--s6);
  row-gap: var(--s6);
}
.stat-grid + .stat-grid { margin-top: var(--s6); }

.stat {
  padding-top: var(--s3);
  border-top: 2px solid var(--ink);
  min-width: 0;
  color: inherit;
  text-decoration: none;
  transition: border-color var(--transition);
}
a.stat:hover { text-decoration: none; border-top-color: var(--brand); }
a.stat:hover .stat-label { color: var(--brand); }

.stat-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: var(--s3);
  transition: color var(--transition);
}

.stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 38px;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text-heading);
}

.stat-foot {
  display: block;
  margin-top: var(--s2);
  font-size: 12.5px;
  color: var(--text-muted);
}

.stat-delta { font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; }
.stat-delta.is-up { color: var(--success); }
.stat-delta.is-down { color: var(--danger); }
.stat-delta.is-flat { color: var(--text-subtle); }

@media (max-width: 860px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* 8 · TABLES -----------------------------------------------------------------
   A table is a ledger: mono caps column heads over hairline-ruled rows. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap-tall { max-height: 460px; overflow-y: auto; }

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--ink);
  white-space: nowrap;
}

.table td {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr[data-href] { cursor: pointer; }

.table-title {
  display: block;
  font-weight: 600;
  color: var(--text-heading);
  letter-spacing: -0.008em;
  /* In wide tables the auto layout starves the name column while a dozen
     numeric columns keep their nowrap headers; a floor keeps titles readable. */
  min-width: 16ch;
}
a.table-title:hover { color: var(--brand); text-decoration: none; }
.table-sub {
  display: block;
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 1px;
}

.cell-num { text-align: right; font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-tight { width: 1%; white-space: nowrap; }

/* numeric column heads sit over their right-aligned digits */
.table th.cell-num, .table th.cell-actions { text-align: right; }

/* wide ledgers (quality scores): tighter gutters so the row fits the page */
.table-compact th, .table-compact td { padding-inline: 8px; }
.table-compact th:first-child, .table-compact td:first-child { padding-left: var(--s4); }
.table-compact th:last-child, .table-compact td:last-child { padding-right: var(--s4); }
.table-compact .url-cell { max-width: 250px; }
.table-compact .table-title { min-width: 14ch; }

/* stacked-card tables on small screens */
@media (max-width: 720px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-bottom: var(--s3);
    background: var(--surface);
    padding: var(--s2) 0;
  }
  .table td { border: 0; padding: var(--s2) var(--s4); }
  .table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
    color: var(--text-subtle);
    margin-bottom: 2px;
  }
  .cell-num, .cell-actions { text-align: left; }
}

/* 9 · BADGES + TAGS ----------------------------------------------------------
   A badge is a specimen label: mono caps in a near-square hairline frame.
   Colour is information — only semantic states get a tint. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.8;
}

.badge-neutral { /* the default look */ }
.badge-brand   { border-color: var(--brand-200); background: var(--brand-soft); color: var(--brand); }
.badge-success { border-color: var(--success-border); background: var(--success-bg); color: var(--success); }
.badge-warning { border-color: var(--warning-border); background: var(--warning-bg); color: var(--warning); }
.badge-danger  { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.badge-info    { border-color: var(--info-border); background: var(--info-bg); color: var(--info); }
.badge-teal    { border-color: var(--teal-border); background: var(--teal-bg); color: var(--teal); }
.badge-purple  { border-color: var(--purple-border); background: var(--purple-bg); color: var(--purple); }

.badge-dot::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.tag-list { display: flex; flex-wrap: wrap; gap: var(--s2); }
.tag-remove { color: var(--text-subtle); font-size: 13px; line-height: 1; }
.tag-remove:hover { color: var(--danger); }

/* 10 · FORMS ---------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }

.field label, .field-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}
.field-required { color: var(--danger); }

.field input[type="text"],
.field input[type="url"],
.field input[type="email"],
.field input[type="password"],
.field input[type="search"],
.field input[type="number"],
.field select,
.field textarea,
.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field textarea { height: auto; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23948b76' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.field input::placeholder,
.field textarea::placeholder { color: var(--text-subtle); }

.field-hint { font-size: 12.5px; color: var(--text-subtle); }
.field-error { font-size: 12.5px; color: var(--danger); font-weight: 500; }

.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--danger); }
.field.has-error input:focus { box-shadow: 0 0 0 3px var(--danger-bg); }

.field-inline { flex-direction: row; align-items: center; gap: var(--s3); }

.checkbox, .radio {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  cursor: pointer;
  font-size: 13.5px;
}
.checkbox input, .radio input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--ink);
  flex: none;
}
.checkbox-text { font-weight: 600; color: var(--text-heading); }
.checkbox-hint { display: block; font-weight: 400; font-size: 12.5px; color: var(--text-subtle); }

.char-count { font-family: var(--font-mono); font-size: 0.92em; font-variant-numeric: tabular-nums; color: var(--text-subtle); }
.char-count.is-over { color: var(--danger); font-weight: 600; }

/* 11 · PROGRESS + METERS ---------------------------------------------------- */
.progress {
  height: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--brand);
  transition: width 0.4s ease;
}
.progress.is-indeterminate .progress-bar {
  width: 36% !important;
  animation: indeterminate 1.2s ease-in-out infinite;
}
@keyframes indeterminate {
  0% { margin-left: -36%; }
  100% { margin-left: 100%; }
}

.meter {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.meter-value {
  width: 64px;
  height: 3px;
  background: var(--surface-3);
  overflow: hidden;
  position: relative;
}
.meter-value > span, .meter-value i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--ink);
}
.meter.is-warning .meter-value > span, .meter.is-warning .meter-value i { background: var(--warning); }
.meter.is-danger  .meter-value > span, .meter.is-danger  .meter-value i { background: var(--danger); }
.meter.is-success .meter-value > span, .meter.is-success .meter-value i { background: var(--success); }

/* 12 · FEEDBACK ------------------------------------------------------------- */
.flash {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 13.5px;
}
.flash-title { font-weight: 650; color: var(--text-heading); }
.flash-body { flex: 1; min-width: 0; }
.flash-message { color: var(--text); }
.flash-close {
  color: var(--text-subtle);
  font-size: 16px;
  line-height: 1;
  padding: 2px;
}
.flash-close:hover { color: var(--text-heading); }
.flash.is-dismissed { display: none; }

.flash-success { border-left-color: var(--success); }
.flash-warning { border-left-color: var(--warning); }
.flash-error, .flash-danger { border-left-color: var(--danger); }
.flash-info { border-left-color: var(--brand); }

.toast-stack {
  position: fixed;
  top: var(--s4);
  right: var(--s4);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  animation: toast-in 0.18s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.toast-title { font-weight: 650; color: var(--text-heading); }
.toast-body { flex: 1; min-width: 0; }
.toast-message { color: var(--text); }
.toast-close { color: var(--text-subtle); font-size: 16px; line-height: 1; }
.toast-close:hover { color: var(--text-heading); }
.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-error, .toast-danger { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--brand); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  text-align: center;
  padding: var(--s9) var(--s6);
  color: var(--text-muted);
}
.empty-state-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 550;
  letter-spacing: -0.01em;
  color: var(--text-heading);
}
.empty-state p { max-width: 46ch; font-size: 13.5px; }

.skeleton, .skeleton-line, .skeleton-title, .skeleton-block {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  border-radius: var(--r-xs);
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-line { height: 12px; }
.skeleton-title { height: 18px; width: 40%; }
.skeleton-block { height: 96px; border-radius: var(--r-md); }

.modal, dialog.modal {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  max-width: min(440px, calc(100vw - 32px));
  width: 100%;
}
dialog.modal::backdrop { background: var(--overlay); }
.modal-body { padding: var(--s6); }
.modal-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 550;
  letter-spacing: -0.01em;
  color: var(--text-heading);
  margin-bottom: var(--s2);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s3);
  padding: var(--s4) var(--s6);
  border-top: 1px solid var(--border);
}

.tooltip { position: relative; }
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--text-inverse);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 4px 9px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 50;
}
.tooltip:hover::after, .tooltip:focus-visible::after { opacity: 1; }

/* 13 · MISC ----------------------------------------------------------------- */
.kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  color: var(--text-muted);
}

.divider { border: 0; border-top: 1px solid var(--border); margin: var(--s5) 0; }
.divider-vertical {
  display: inline-block;
  width: 1px;
  align-self: stretch;
  background: var(--border);
}
.divider-labelled {
  display: flex;
  align-items: center;
  gap: var(--s3);
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
}
.divider-labelled::before, .divider-labelled::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}
