/*
 * Quantum Topology public site.
 *
 * One stylesheet for every page under public_base.html. Page-specific
 * stylesheets (YakDB knot.css, mosaic-drawer.css, the FL viewer) add
 * components only and use the tokens defined here.
 *
 * Manrope: headings and interface labels. Source Serif Pro: body text.
 */

@font-face {
  font-family: "Manrope";
  src: url("/yak-assets/fonts/manrope-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif Pro";
  src: url("/yak-assets/fonts/source-serif-pro-regular-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif Pro";
  src: url("/yak-assets/fonts/source-serif-pro-semibold-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
}

/* ---------------------------------------------------------------- Tokens */

:root {
  color-scheme: light;

  /* Colour */
  --paper: #f8f9fc;
  --surface: #ffffff;
  --surface-muted: #f2efe8;
  --ink: #292721;
  --muted: #6b665c;
  --border: #dedbd3;
  --border-strong: #c7c1b5;
  --deep-blue: #003b4c;
  --deep-blue-soft: #e6eef0;
  --accent: #ff6c0c;
  --accent-ring: #ff6c0c33;
  --danger: #9a3b32;

  /* Type */
  --font-heading: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Source Serif Pro", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --text-xs: 0.8125rem;   /* 13px: labels, badges */
  --text-sm: 0.9375rem;   /* 15px: tables, secondary text */
  --text-base: 1.0625rem; /* 17px: body */
  --text-lg: 1.25rem;     /* 20px: lede, h3 */
  --text-xl: 1.5rem;      /* 24px: h2 */
  --text-title: clamp(1.4rem, 1rem + 1.5vw, 1.8rem); /* YakDB breadcrumb titles */
  --text-2xl: clamp(2rem, 1.5rem + 2vw, 2.75rem); /* h1 */
  --text-display: clamp(2.5rem, 1.75rem + 3.5vw, 4rem);

  --leading-body: 1.65;
  --leading-tight: 1.2;

  /* Space: a single scale used for every margin, padding and gap */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  /* Layout */
  --page-width: 920px;
  --gutter: 28px;
  --nav-height: 4rem;

  /* Shape */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px #29272108, 0 4px 16px #29272108;
  --focus-ring: 0 0 0 3px var(--accent-ring);
  --transition: 140ms ease-out;
}

/* ------------------------------------------------------------------ Base */

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + var(--space-4));
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; }

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-4);
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: var(--leading-tight);
  color: var(--deep-blue);
  letter-spacing: -0.01em;
}
h1 { font-size: var(--text-2xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); font-weight: 600; }
h4, h5, h6 { font-size: var(--text-base); font-weight: 600; }

/* Headings after body content get room above; the first one in a block does not. */
:where(p, ul, ol, dl, pre, table, figure, details, .data-scroll, .table-scroll) + h2 { margin-top: var(--space-6); }
:where(p, ul, ol, dl, pre, table, figure, details, .data-scroll, .table-scroll) + :is(h3, h4) { margin-top: var(--space-5); }

p, ul, ol, dl, pre, figure, blockquote { margin: 0 0 var(--space-4); }
ul, ol { padding-left: var(--space-5); }
li + li { margin-top: var(--space-1); }
:where(p, ul, ol, dl, pre, figure, blockquote, table):last-child { margin-bottom: 0; }

a {
  color: var(--deep-blue);
  text-decoration: underline;
  text-decoration-color: #003b4c55;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition), color var(--transition);
}
a:hover { text-decoration-color: currentColor; }
:where(h1, h2, h3, h4) a { text-decoration: none; }
:where(h1, h2, h3, h4) a:hover { text-decoration: underline; }

strong, b { font-weight: 600; }
small { font-size: var(--text-sm); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-6) 0; }
img, svg, canvas { max-width: 100%; }

code, kbd, samp, pre, .machine-name { font-family: var(--font-mono); }
code, kbd, samp { font-size: 0.875em; }
:not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);

}
pre {
  overflow: auto;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--text-xs);
  line-height: 1.6;
}
pre code { padding: 0; background: none; font-size: inherit; }

:focus-visible { outline: 2px solid var(--deep-blue); outline-offset: 3px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; top: -100px; left: var(--gutter); z-index: 50;
  padding: var(--space-3); background: var(--surface);
}
.skip-link:focus { top: var(--space-4); }

/* ---------------------------------------------------------------- Layout */

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

.site-main { flex: 1; display: block; }

/* Every content page: same width and left edge as the navigation. */
.page {
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
  padding: var(--space-7) var(--gutter) var(--space-8);
}

.page-header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.page-header h1 { margin-bottom: 0; }
.page-header > * + * { margin-top: var(--space-3); }
.lede { font-size: var(--text-lg); line-height: 1.55; color: var(--muted); }
.meta { font-size: var(--text-sm); color: var(--muted); }
.meta a { color: inherit; }

/* YakDB page titles: breadcrumb and current page on one line, at one size. */
.tool-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) 0.6rem;
  font-family: var(--font-heading);
  font-size: var(--text-title);
  font-weight: 700;
  line-height: 1.1;
  color: var(--deep-blue);
}
.tool-breadcrumb > a { color: inherit; text-decoration: none; }
.tool-breadcrumb > a:hover { text-decoration: underline; }
.tool-breadcrumb > span { color: var(--muted); font-weight: 400; }
.tool-breadcrumb h1 { margin: 0; font: inherit; letter-spacing: normal; color: inherit; }
.tool-breadcrumb h1.machine-name { font-family: var(--font-mono); font-weight: 600; }
.tool-breadcrumb h1 a { color: inherit; }
.tool-heading-rule { margin: var(--space-5) 0 var(--space-6); }
.tool-heading-rule + .meta { margin-top: calc(-1 * var(--space-4)); margin-bottom: var(--space-6); }
.dataset-intro { margin-bottom: var(--space-6); }
.dataset-intro > * + * { margin-top: var(--space-3); }

.section { padding-block: var(--space-8); }
.section + .section { border-top: 1px solid var(--border); }
.section > .shell > h2 { margin-bottom: var(--space-5); }
.section-intro { margin-bottom: var(--space-6); }
.section-intro h2 { margin-bottom: var(--space-3); }
.section-intro p { color: var(--muted); }

.stack > * + * { margin-top: var(--space-4); }

/* ------------------------------------------------------------ Navigation */

.unified-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #ffffffee;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--nav-height);
  font-family: var(--font-heading);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 36px;
  height: 36px;
  padding: 2px;
  border-radius: 50%;
  background: conic-gradient(from 140deg, var(--accent), #ffe182, var(--deep-blue), var(--accent));
}
.brand-logo-inner {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink);
}
.brand-title { display: flex; flex-direction: column; line-height: 1.25; }
.brand-title span:first-child {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.brand-title span:last-child { font-size: var(--text-base); font-weight: 600; }

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
}
.nav-links a { color: var(--ink); text-decoration: none; }
.nav-links a:hover { color: var(--deep-blue); text-decoration: underline; }

.data-nav { position: relative; }
.data-nav-heading { display: flex; align-items: center; gap: var(--space-1); }
#data-menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1);
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
#data-menu-button svg { display: block; width: 12px; height: 12px; }
.data-submenu {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: calc(-1 * var(--space-4));
  display: grid;
  gap: var(--space-1);
  min-width: 10rem;
  padding: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.data-submenu a { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); }
.data-submenu a:hover { background: var(--surface-muted); text-decoration: none; }
/* Bridge the visual gap so the menu stays open as the pointer enters it. */
.data-submenu::before {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--space-2) - 1px) 0 100%;
}

.nav-toggle {
  display: none;
  padding: var(--space-2);
  border: 0;
  background: none;
  cursor: pointer;
}
.nav-toggle-line {
  width: 20px;
  height: 2px;
  margin: 4px 0;
  border-radius: 2px;
  background: var(--ink);
}

@media (max-width: 1000px) {
  .nav-toggle { display: block; }
  .nav-links-wrapper { display: none; width: 100%; }
  .nav-links-wrapper.open { display: block; }
  .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-bottom: var(--space-3);
    font-size: var(--text-base);
  }
  .nav-links > a, .data-nav-heading { padding: var(--space-2) 0; }
  .data-submenu { position: static; margin-left: var(--space-4); padding: 0; border: 0; box-shadow: none; background: none; }
}

/* ---------------------------------------------------------------- Footer */

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.site-footer .shell {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  padding-block: var(--space-5);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--muted);
}
.site-footer a { color: inherit; }
.site-footer a:hover { color: var(--deep-blue); }

/* ---------------------------------------------------------------- Forms */

label { font-family: var(--font-heading); font-size: var(--text-sm); font-weight: 500; }

input:where(:not([type=checkbox], [type=radio], [type=hidden])),
select,
textarea {
  height: 2.5rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
textarea { display: block; width: 100%; height: auto; min-height: 6rem; font-family: var(--font-mono); line-height: 1.6; resize: vertical; }
:where(input, select, textarea):focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
input::placeholder, textarea::placeholder { color: #8a847a; opacity: 1; }

.field { display: grid; gap: var(--space-2); }
.field > span { color: var(--muted); }
.form-row { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-4); }
.form-row .field--grow { flex: 1 1 18rem; }
.form-row .field--grow input { width: 100%; }
.query-form { margin-block: var(--space-6); }
.query-form > .field input { width: 100%; }

/* Buttons. Unclassed <button>s in content get the default style. */
.btn,
.page button:not([class]),
.table-pagination button:not(.table-expand) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.5rem;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--deep-blue);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.btn:hover,
.page button:not([class]):hover,
.table-pagination button:not(.table-expand):hover { background: var(--deep-blue-soft); border-color: var(--deep-blue); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #e85f06; border-color: #e85f06; color: #fff; }

/* ------------------------------------------------------------ Components */

.card {
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.card > :last-child { margin-bottom: 0; }
.card h2, .card h3 { margin-bottom: var(--space-2); font-size: var(--text-lg); }
.card p { color: var(--muted); }
.card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
}
.card-footer .card-link { margin-left: auto; font-weight: 600; }

.card-list { display: grid; gap: var(--space-4); }
.card-grid { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }

/* Toolbar above a table: record count, then groups of buttons. */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-3);
}
.toolbar-count { margin-right: auto; font-family: var(--font-heading); font-size: var(--text-sm); color: var(--muted); }
.toolbar-count strong { color: var(--ink); }
.btn-group { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.btn-icon { width: 1.1em; height: 1.1em; }

/* Modal dialogs */
.dialog {
  width: min(44rem, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100vh - 4rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px #29272133;
}
.dialog::backdrop { background: #29272166; }
.dialog-header,
.dialog-footer { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-4) var(--space-5); }
.dialog-header { justify-content: space-between; border-bottom: 1px solid var(--border); }
.dialog-header h2 { margin: 0; font-size: var(--text-lg); }
.dialog-footer { justify-content: flex-end; border-top: 1px solid var(--border); }
.dialog-body { padding: var(--space-5); overflow: auto; max-height: 60vh; }
.dialog-body p { font-size: var(--text-sm); }
.dialog-body pre { margin: 0; overflow: auto; background: var(--surface-muted); border: 0; }
.dialog-body pre.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog-close { border: 0; background: none; color: var(--muted); font-size: var(--text-xl); line-height: 1; cursor: pointer; }
.dialog-close:hover { color: var(--ink); }

/* Plain list of linked entries separated by rules (projects index). */
.entry-list { list-style: none; padding: 0; max-width: none !important; }
.entry-list > li { margin: 0; padding-block: var(--space-5); border-bottom: 1px solid var(--border); }
.entry-list > li:first-child { padding-top: 0; }
.entry-list h2 { margin-bottom: var(--space-2); font-size: var(--text-lg); }
.entry-list p { margin-bottom: var(--space-2); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem var(--space-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.5;
  color: var(--muted);
  white-space: nowrap;
}
.badge-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
details > summary {
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
details[open] > summary { border-bottom: 1px solid var(--border); }
details > :not(summary) { margin: var(--space-4); max-width: none; }

.definition-list { display: grid; grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr); gap: var(--space-2) var(--space-5); }
.definition-list dt { font-family: var(--font-heading); font-size: var(--text-sm); font-weight: 600; color: var(--muted); }
.definition-list dd { margin: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- Tables */

/* Horizontal scroll wrapper for any wide table. */
.data-scroll, .table-scroll, .data-table-scroll, .catalogue-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin-bottom: var(--space-4);
}
.data-scroll, .table-scroll, .catalogue-scroll {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

/* Grid tables: header row plus records. */
.data-scroll table,
.table-scroll table,
.catalogue-table,
.tools-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  line-height: 1.5;
}
.data-scroll :where(th, td),
.table-scroll :where(th, td),
.catalogue-table :where(th, td) {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.data-scroll thead th,
.table-scroll thead th,
.catalogue-table thead th {
  background: var(--surface-muted);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.data-scroll tbody tr:last-child > *,
.table-scroll tbody tr:last-child > *,
.catalogue-table tbody tr:last-child > * { border-bottom: 0; }
.data-scroll td { max-width: 24rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:where(.data-scroll, .table-scroll, .catalogue-table, .entity-fields-table, .knot-data, .tools-table) td > code {
  padding: 0;
  background: none;
}

/* List tables without a frame (tools index, results). */
.tools-table { margin-bottom: var(--space-4); }
.tools-table :where(th, td) {
  padding: var(--space-3) var(--space-5) var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.tools-table thead th {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
}
.tools-table tbody th { font-weight: 400; color: var(--muted); }

/* Key/value tables: label column plus value column. */
.entity-fields-table,
.knot-data {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--text-sm);
  line-height: 1.6;
}
.entity-fields-table :where(th, td),
.knot-data :where(th, td) {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}
.entity-fields-table th,
.knot-data th {
  width: 30%;
  padding-right: var(--space-5);
  font-weight: 400;
  color: var(--muted);
}
:where(.entity-fields-table, .knot-data, .tools-table) th label { font: inherit; color: inherit; }
.entity-fields-table th code { color: var(--ink); background: none; padding: 0; }
.entity-field-type { display: block; margin-top: var(--space-1); color: var(--muted); font-size: var(--text-xs); }
.entity-fields-table pre {
  max-height: 20rem;
  margin: 0;
  padding: var(--space-3);
  white-space: pre;
  font-size: var(--text-xs);
}

/* ------------------------------------------------------------ Home page */

.home-hero {
  padding-block: var(--space-9) var(--space-8);
  text-align: center;
}
.home-hero .shell { max-width: 52rem; }
.home-hero h1 {
  margin-bottom: var(--space-5);
  font-size: var(--text-display);
  line-height: 1.08;
  color: var(--ink);
}
.home-hero h1 .highlight {
  background: linear-gradient(120deg, var(--accent), var(--deep-blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.home-hero .lede { margin: 0 auto var(--space-7); }
/* The drawing canvas grows upward into the description and search heading:
   hide them while drawing and keep the title in place above the canvas. */
.home-hero :is(.lede, h2) { transition: opacity 180ms ease, visibility 180ms; }
.home-hero.is-drawing :is(.lede, h2) { opacity: 0; visibility: hidden; }
.hero.home-hero.is-drawing #title { transform: none; }
.home-hero .shell > h2 { font-weight: 400; margin-bottom: var(--space-4); font-size: var(--text-lg); color: var(--ink); }
.learn-more {
  display: inline-flex;
  gap: var(--space-2);
  margin-top: var(--space-7);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  color: var(--muted);
  text-decoration: none;
}

/* ---------------------------------------------------------- Search widget */

.search-form { margin: 0; }
.search-box {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.search-box input,
.search-box input:focus {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  box-shadow: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.search-icon { flex: 0 0 20px; width: 20px; height: 20px; color: var(--muted); }
.search-submit,
.draw-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 2.75rem;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.search-submit { background: var(--accent); color: #fff; }
.search-submit:hover { background: #e85f06; }
.search-submit svg { width: 18px; height: 18px; }
.compute-submit, .compute-submit:hover { background: var(--deep-blue); }
.draw-toggle { background: var(--surface); border-color: var(--border); color: var(--deep-blue); }
.draw-toggle:hover { background: var(--deep-blue-soft); border-color: var(--deep-blue); }

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.example-label { margin-right: var(--space-1); font-family: var(--font-heading); font-size: var(--text-xs); color: var(--muted); }
.example {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 1.75rem;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  cursor: pointer;
}
.example span { color: var(--muted); }
.example:hover { border-color: var(--border-strong); background: var(--surface-muted); }

.search-feedback,
.query-record {
  margin-top: var(--space-5);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  text-align: left;
}
.search-feedback h2,
.query-record h2 { margin-bottom: var(--space-2); font-size: var(--text-sm); color: var(--ink); }
.search-feedback p,
.query-record p { margin: 0; font-size: var(--text-sm); color: var(--muted); }

.search-link { overflow-wrap: anywhere; }
.search-link-icon { display: inline-block; width: 1em; height: 1em; vertical-align: -0.15em; }

@media (max-width: 600px) {
  .search-box { gap: var(--space-2); padding-left: var(--space-4); }
  .search-icon { display: none; }
  .search-submit { padding: 0 var(--space-3); }
  .search-submit span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .example-label { flex-basis: 100%; margin: 0; }
}

/* --------------------------------------------------------- People page */

.people-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
}
.person-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-6) var(--space-5);
  text-align: center;
}
.person-photo {
  display: grid;
  place-items: center;
  width: 6rem;
  height: 6rem;
  margin-bottom: var(--space-4);
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 2.5rem;
}
.person-info { display: flex; flex: 1; flex-direction: column; width: 100%; }
.person-card p:empty { display: none; }
.person-photo img { width: 100%; height: 100%; object-fit: cover; }
.person-card h2 { margin-bottom: var(--space-1); font-size: var(--text-lg); color: var(--ink); }
.person-role {
  margin-bottom: var(--space-3);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--deep-blue);
}
.person-card p { margin-bottom: var(--space-2); font-size: var(--text-sm); color: var(--muted); }
.person-card p.person-affiliation { color: var(--ink); }
.person-links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: auto; padding-top: var(--space-3); }
.person-links .btn { min-height: 2rem; padding: 0 var(--space-3); font-size: var(--text-xs); }

/* ------------------------------------------------------ Entity pages */

.entity-record { margin-top: var(--space-7); }
.entity-record h2 { margin-bottom: var(--space-2); }
.entity-record > .meta { margin-bottom: var(--space-4); }
.entity-diagram {
  display: grid;
  place-items: center;
  width: min(100%, 28rem);
  aspect-ratio: 1;
  margin: 0 auto var(--space-6);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.entity-diagram img { width: 100%; height: 100%; object-fit: contain; }

/* ------------------------------------------------- Research articles */

.page.research-article {
  padding-block: 2rem 3rem;
  line-height: 1.55;
}
.research-article .project-header { margin-bottom: 1.5rem; }
.research-article .tool-heading-rule { margin: 1rem 0; }
.research-article .project-header > .meta { margin: 0; }
.research-article .project-body p { margin: .7rem 0; }
.research-article .project-body h2 {
  font-size: 1.35rem;
  margin: 1.8rem 0 .7rem;
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--border);
}
.research-article .project-body > h2:first-child { margin-top: 0; }
.research-article .project-body h3 { font-size: 1.05rem; margin: 1.4rem 0 .4rem; }

.katex-display { overflow-x: auto; overflow-y: hidden; padding-block: var(--space-1); }

/* ---------------------------------------------------------- Responsive */

@media (max-width: 640px) {
  :root { --text-base: 1rem; --gutter: 20px; }
  .page { padding-top: var(--space-6); }
  .home-hero { padding-block: var(--space-7) var(--space-6); }
  .section { padding-block: var(--space-7); }
  .entity-fields-table th, .knot-data th { width: 40%; padding-right: var(--space-3); }
  .definition-list { grid-template-columns: 1fr; gap: var(--space-1); }
  .definition-list dd { margin-bottom: var(--space-3); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.badge-verified { color: #17643b; background: #edf8f0; border-color: #bedcc7; }
.tool-breadcrumb > .schema-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 1.4rem;
  height: 1.4rem;
  flex: 0 0 auto;
  border: 1px solid #bedcc7;
  border-radius: 50%;
  background: #edf8f0;
  color: #17643b;
  font: 600 0.85rem/1 var(--font-heading);
}

/* Keep dataset actions together; use a deliberate second row on small screens. */
.dataset-toolbar {flex-wrap:nowrap;justify-content:space-between;gap:var(--space-3)}
.toolbar-summary,.toolbar-actions {display:flex;align-items:center;gap:var(--space-3);white-space:nowrap}
.toolbar-actions {margin-left:auto}
.dataset-toolbar .toolbar-count {margin-right:0}
.toolbar-text-button {border:0;background:none;padding:0;color:var(--deep-blue);font:inherit;font-size:var(--text-sm);cursor:pointer;white-space:nowrap}
.toolbar-text-button:hover {text-decoration:underline}
.btn-group-joined {flex-wrap:nowrap;gap:0}
.btn-group-joined > .btn {border-radius:0;white-space:nowrap}
.btn-group-joined > .btn + .btn {margin-left:-1px}
.btn-group-joined > .btn:first-child {border-radius:var(--radius) 0 0 var(--radius)}
.btn-group-joined > .btn:last-child {border-radius:0 var(--radius) var(--radius) 0}
.btn-group-joined > .btn:hover,.btn-group-joined > .btn:focus-visible {position:relative;z-index:1}
@media(max-width:700px) {
  .dataset-toolbar {flex-direction:column;align-items:stretch}
  .toolbar-actions {gap:var(--space-2)}
  .dataset-toolbar .btn {padding-inline:.5rem;font-size:.75rem}
}

.dataset-schema-check {display:inline-flex;align-items:center;justify-content:center;width:1.1rem;height:1.1rem;margin-left:.25rem;border:1px solid #23834b;border-radius:50%;color:#17643b;background:#edf8f0;font:600 .75rem/1 var(--font-heading);vertical-align:middle;cursor:help}

.btn:disabled,.btn:disabled:hover {opacity:.45;cursor:not-allowed;background:var(--surface);border-color:var(--border-strong);color:var(--muted)}

/* YakDB type hints, shared by catalogue tables and verified dataset previews. */
.type-info {position:relative;display:inline-flex;align-items:center;margin-left:var(--space-1);vertical-align:middle;color:var(--muted);text-decoration:none}
.type-info:focus-visible {outline:2px solid currentColor;outline-offset:3px;border-radius:50%}
.type-tooltip {display:none;position:fixed;z-index:100;padding:var(--space-2) var(--space-3);border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface);box-shadow:var(--shadow);color:var(--ink);font-size:var(--text-xs);font-weight:400;white-space:normal;overflow-wrap:anywhere;max-width:min(28rem,calc(100vw - 16px))}
.type-info:hover .type-tooltip,.type-info:focus .type-tooltip {display:block}
.typed-value,.typed-set {font-family:var(--font-mono)}
.data-scroll td:has(.typed-set) {white-space:normal;overflow:visible;min-width:12rem}

/* Compact YakDB search precedes the navigation links. */
.nav-links-wrapper {display:flex;align-items:center;gap:var(--space-5);margin-left:auto}
.nav-search {position:relative;width:13rem;min-width:0;margin:0}
.nav-search input {display:block;width:100%;height:36px;padding:0 0 0 26px;border:0;border-bottom:1px solid var(--border);border-radius:0;background:transparent;color:var(--ink);font-family:var(--font-mono);font-size:.8125rem;box-shadow:none}
.nav-search input:focus {border-color:var(--deep-blue);box-shadow:none}
.nav-search:focus-within {outline:2px solid var(--deep-blue);outline-offset:4px;border-radius:2px}
.nav-search-submit {position:absolute;left:0;top:0;display:grid;place-items:center;width:22px;height:36px;padding:0;border:0;background:transparent;color:var(--muted);cursor:pointer}
.nav-search-submit svg {width:18px;height:18px}
@media(max-width:1000px) {
  .nav-links-wrapper {display:none;margin-left:0}
  .nav-search {width:100%;margin:0 0 var(--space-3)}
  .nav-search input {font-size:1rem}
}
