/*
 * Application-wide styles.
 *
 * One file on purpose: `stylesheet_link_tag :app` includes every CSS file in
 * app/assets sorted alphabetically, which would put a `tokens.css` *after*
 * `application.css`. Keeping the token layer and the component layer in one
 * sheet removes that ordering trap. Split only if you also fix the load order.
 *
 * Layout: (1) fonts, (2) tokens, (3) base, (4) shell, (5) components,
 * (6) screen-specific bits, (7) responsive.
 *
 * Design source: doc/plan/1784879141_catalog-power-user-redesign.md
 */

/* ------------------------------------------------------------------ 1. fonts
 * Self-hosted (D5): this app may run on a host with no outbound internet, so
 * no Google Fonts link. Latin subset only. IBM Plex Sans ships as a variable
 * font, hence the single file across the 400-600 range.
 */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/assets/ibm-plex-sans-latin-bf0c3289.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/ibm-plex-mono-latin-400-d803141a.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/ibm-plex-mono-latin-500-3f7bbac1.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ----------------------------------------------------------------- 2. tokens
 * Every value below comes from the redesign prototype. Take colors, spacing,
 * and radii from these variables rather than hardcoding hexes in a component.
 */

:root {
  /* surfaces */
  --ground: #f4f4f2;
  --surface: #ffffff;
  --rail: #fbfbfa;
  --inset: #f7f7f6;
  --hover: #fafafa;

  /* ink */
  --text: #1c1c1a;
  --text-2: #3a3a36;
  --muted: #6b6b66;
  --faint: #9a9a94;
  --faintest: #b0b0aa;

  /* hairlines, lightest last */
  --line-strong: #d6d6d3;
  --line-input: #e2e2df;
  --line: #e6e6e4;
  --line-card: #efefec;
  --line-soft: #f2f2f0;
  --line-inset: #ededea;

  /* accent */
  --accent: #2563eb;
  --accent-hover: #1c4fca;
  --accent-tint: #eef3ff;

  /* status roles: text / fill / border */
  --ok: #15803d;
  --ok-bg: #e9f6ee;
  --ok-line: #cfe9d8;
  --warn: #92600a;
  --warn-bg: #fdf3e0;
  --warn-line: #f3e0bd;
  --bad: #a52222;
  --bad-bg: #fbecec;
  --bad-line: #f3d2d2;
  --off: #7a7a74;
  --off-bg: #f2f2f0;
  --off-line: #e2e2df;

  /* type */
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* geometry */
  --r-chip: 6px;
  --r-control: 8px;
  --r-card: 11px;
  --r-dialog: 13px;
  --row-pad: 10px 14px;
  --sidebar-w: 238px;
  --content-w: 1120px;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.03), 0 12px 32px -12px rgba(0, 0, 0, 0.1);
  --shadow-pop: 0 24px 60px -12px rgba(0, 0, 0, 0.28);
  --shadow-toast: 0 8px 24px -6px rgba(0, 0, 0, 0.35);
}

/* ------------------------------------------------------------------- 3. base */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
}

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

::selection {
  background: #d7e3ff;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
}
h1 {
  font-size: 22px;
}
h2 {
  font-size: 16px;
}
h3 {
  font-size: 14px;
}

p {
  margin: 0;
}

code,
.mono {
  font-family: var(--mono);
}
code {
  font-size: 0.94em;
  word-break: break-all;
}

/* Keyboard focus is themed everywhere. The prototype removes the default input
   outline; this replaces it rather than leaving keyboard users with nothing. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
input:focus {
  outline: none;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Uppercase micro-label — section headings, table headers, stat captions. */
.label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}
.faint {
  color: var(--faint);
}
.right {
  text-align: right;
}
.row {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

/* ------------------------------------------------------------------ 4. shell */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  border-right: 1px solid var(--line);
  background: var(--rail);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 15px 16px 12px;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand:hover {
  color: var(--text);
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  background: var(--text);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 15px;
}

.sidebar-palette {
  padding: 0 12px 10px;
}

.palette-trigger {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 9px;
  background: var(--surface);
  border: 1px solid var(--line-input);
  border-radius: var(--r-control);
  cursor: pointer;
  color: var(--faint);
  font-size: 12.5px;
}
.palette-trigger:hover {
  border-color: #d0d0cc;
  color: var(--muted);
}

.kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  border: 1px solid var(--line-input);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--faint);
}
.palette-trigger .kbd {
  margin-left: auto;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 31px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.nav-item:hover {
  background: var(--off-bg);
  color: var(--text);
}
.nav-item[aria-current="page"] {
  background: var(--accent-tint);
  color: var(--accent-hover);
  font-weight: 600;
}

.nav-glyph {
  font-family: var(--mono);
  font-size: 12px;
  width: 14px;
  text-align: center;
  color: var(--faintest);
}
.nav-item[aria-current="page"] .nav-glyph {
  color: var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.whoami {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
}
.whoami-avatar {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: var(--r-chip);
  background: var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}
.whoami-id {
  min-width: 0;
  flex: 1;
}
.whoami-email {
  font-size: 12.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.whoami-role {
  font-size: 10.5px;
  color: var(--faint);
  font-family: var(--mono);
}
.whoami form {
  margin: 0;
}

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 48px;
  flex: none;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 251, 250, 0.86);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  min-width: 0;
}
.crumbs a {
  color: var(--muted);
}
.crumbs a:hover {
  color: var(--text);
}
.crumb-current {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crumb-sep {
  color: #c8c8c3;
}

.jump {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--faint);
  cursor: pointer;
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
}
.jump:hover {
  border-color: var(--line-strong);
  color: var(--muted);
}
.jump .kbd {
  border: none;
  padding: 0;
}

.page {
  flex: 1;
  overflow: auto;
}
.page-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 26px 24px 60px;
  width: 100%;
}

/* Page heading block: title + subtitle on the left, actions on the right. */
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head p {
  margin-top: 5px;
  font-size: 13px;
  color: var(--muted);
}
.page-head-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

/* -------------------------------------------------------------- 5. components
 * buttons
 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 13px;
  border-radius: var(--r-control);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}
.btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
}
.btn-secondary:hover {
  background: var(--off-bg);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-ghost {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--line-strong);
  height: 30px;
  font-size: 12.5px;
}
.btn-ghost:hover {
  background: var(--hover);
  color: var(--text);
  border-color: var(--line-strong);
}

/* Irreversible actions. Outlined rather than filled: this should read as
   serious, not as the thing the page wants you to press. */
.btn-danger {
  background: var(--surface);
  color: var(--bad);
  border-color: var(--bad-line);
}
.btn-danger:hover {
  background: var(--bad-bg);
  color: var(--bad);
  border-color: var(--bad);
}

.btn-tall {
  height: 36px;
  padding: 0 15px;
}
.btn-block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* A button that reads as a link. Used for destructive inline actions and for
   `button_to` forms that must not look like buttons. */
.linkish {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
}
.linkish:hover {
  text-decoration: underline;
}
.linkish-danger {
  color: var(--bad);
}
/* The section you are already on, in a row of linkish tabs. Same signal the
   sidebar uses, so there is one way to say "you are here". */
.linkish[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

/* forms */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text);
}
textarea {
  height: auto;
  padding: 9px 11px;
  resize: vertical;
  line-height: 1.5;
}
select {
  font-family: var(--mono);
  font-size: 13px;
}
input[type="file"] {
  border: none;
  padding: 0;
  height: auto;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--muted);
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px;
  margin: 0;
}
legend {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 6px;
}

/* cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}
.card-pad {
  padding: 15px;
}
.card-flush {
  overflow: hidden;
}
.card + .card {
  margin-top: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-card);
}
.card-head-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.card-head-link {
  font-size: 12px;
}

/* An action row pinned to the bottom of a flush card, on the rail tint. */
.card-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 11px 15px;
  background: var(--rail);
  border-top: 1px solid var(--line-card);
}

/* A section title inside a padded card (no bottom rule). */
.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 9px;
}

/* stat tiles */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 16px;
  color: var(--text);
}
a.stat:hover {
  border-color: #d0d0cc;
  color: var(--text);
}
.stat-value {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 6px;
  font-family: var(--mono);
  line-height: 1.1;
}
.stat-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* The 4-up hairline meta strip on detail pages. Cells are separated by the
   grid's own background showing through a 1px gap — no per-cell borders. */
.strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
  margin-bottom: 16px;
}
.strip-cell {
  background: var(--surface);
  padding: 13px 15px;
  min-width: 0;
}
.strip-value {
  font-size: 14px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.strip-value.mono {
  font-size: 12.5px;
}

/* tables */

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: var(--row-pad);
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
  vertical-align: middle;
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table tbody tr:hover {
  background: var(--hover);
}
.table .num {
  text-align: right;
  font-family: var(--mono);
}
.table .cell-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}
.table .cell-name a {
  color: var(--text);
}
.table .cell-name a:hover {
  color: var(--accent);
}
.table .cell-meta {
  font-family: var(--mono);
  color: var(--muted);
}
.table .cell-faint {
  font-family: var(--mono);
  color: var(--faint);
}

/* Sortable header: the whole cell is a link, arrow marks the active key. */
.table th a {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.table th a:hover {
  color: var(--muted);
}
.sort-arrow {
  font-family: var(--mono);
  color: var(--accent);
}

/* Row-level click target. The navigation is the real <a> in the row; the
   row_link Stimulus controller only forwards clicks that land on dead space.
   Do NOT reintroduce a stretched-link `::after` here — on a <tr> it either
   covers the row and swallows the anchor's own clicks or, where `position:
   relative` is not honoured on table parts, covers the viewport. See
   doc/wiki/footguns/stretched-link-on-table-rows.md. */
.row-link {
  cursor: pointer;
}

/* badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-ready {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--ok-line);
}
.badge-pending {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn-line);
}
.badge-failed {
  background: var(--bad-bg);
  color: var(--bad);
  border-color: var(--bad-line);
}
.badge-empty,
.badge-neutral {
  background: var(--off-bg);
  color: var(--off);
  border-color: var(--off-line);
}
/* Curation badges (archived / pulled) sit beside a state badge, so this one is
   outlined rather than filled — two filled pills in a cell read as one blob. */
.badge-muted {
  background: transparent;
  color: var(--off);
  border-color: var(--off-line);
  border-style: dashed;
}

/* Copyable key/value rows (stable identifiers).
   The value is a real <code>, not a button label: it stays selectable, and the
   page still tells you the whole checksum when JavaScript is off. Copying is a
   separate, small affordance beside it. */

.kv {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: var(--inset);
  border: 1px solid var(--line-inset);
  border-radius: var(--r-control);
}
.kv:hover {
  border-color: var(--line-strong);
}
.kv-key {
  font-size: 11px;
  color: var(--faint);
  width: 58px;
  flex: none;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}
/* Wraps rather than truncating — a sha256 you cannot read is not an identifier. */
.kv-value {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
}

/* Small inline copy affordance, next to a value that is already legible. */
.copy-btn {
  flex: none;
  align-self: center;
  border: 1px solid var(--line-input);
  background: var(--surface);
  border-radius: var(--r-chip);
  color: var(--faint);
  font-size: 10.5px;
  padding: 2px 7px;
  cursor: pointer;
  white-space: nowrap;
}
.copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* A table cell holding a machine value plus its copy button. */
.value-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.value-cell code {
  color: var(--muted);
  font-size: 12px;
}

/* snippets */

.tabs {
  display: flex;
  gap: 4px;
}
.tab {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--r-chip);
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  color: var(--muted);
  background: var(--off-bg);
}
.tab:hover {
  color: var(--text);
}
.tab[aria-selected="true"] {
  color: #fff;
  background: var(--accent);
}

.snippet {
  position: relative;
}
.snippet pre {
  margin: 0;
  background: var(--inset);
  border: 1px solid var(--line-inset);
  border-radius: var(--r-control);
  padding: 11px 12px;
  padding-right: 62px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: #2a2a27;
  white-space: pre-wrap;
  word-break: break-all;
}
.snippet-copy {
  position: absolute;
  top: 7px;
  right: 7px;
  font-size: 11px;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-chip);
  cursor: pointer;
  color: var(--muted);
}
.snippet-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* dropzone */

.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: 9px;
  padding: 16px;
  text-align: center;
  color: var(--faint);
  font-size: 12.5px;
  background: var(--rail);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.dropzone[data-active="true"] {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-hover);
}
.dropzone-browse {
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}
.dropzone-hint {
  font-size: 11px;
  margin-top: 3px;
  color: var(--faintest);
}
.dropzone-summary {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.dropzone-summary[data-over="true"] {
  color: var(--bad);
}
/* The real inputs stay in the DOM so the form works without JavaScript; the
   Stimulus controller hides them once it takes over. */
.upload-native[hidden] {
  display: none;
}
.upload-native {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.upload-native label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

/* A single-column form page (new dataset, new collection). */
.narrow-col {
  max-width: 600px;
}

.form-error {
  background: var(--bad-bg);
  border: 1px solid var(--bad-line);
  color: var(--bad);
  border-radius: var(--r-control);
  padding: 9px 12px;
  font-size: 12.5px;
}

/* toasts */

.toasts {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--text);
  color: #fff;
  font-size: 12.5px;
  padding: 9px 15px;
  border-radius: 9px;
  box-shadow: var(--shadow-toast);
  font-family: var(--mono);
  animation: popin 0.14s ease;
  pointer-events: auto;
  max-width: 80vw;
}
.toast-alert {
  background: #7f1d1d;
}
.toast-message {
  flex: 1;
  min-width: 0;
}
/* Only persistent (alert) toasts get one — a notice is gone before you could
   aim at it, and a close button you cannot hit is just noise. */
.toast-close {
  flex: none;
  border: none;
  background: none;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 0 0 2px;
}
.toast-close:hover {
  opacity: 1;
}

@keyframes popin {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fadein {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* command palette */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 28, 26, 0.28);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
  animation: fadein 0.12s ease;
  border: none;
}
/* MUST stay. The `display` above outranks the browser's `[hidden] {display:
   none}`, so without this the palette is painted permanently — open on load,
   and impossible to dismiss, since closing only flips the attribute. Any rule
   that sets `display` on an element toggled by `hidden` needs its own pair. */
.dialog-backdrop[hidden] {
  display: none;
}
.dialog {
  width: 560px;
  max-width: 92vw;
  background: var(--surface);
  border: 1px solid var(--line-input);
  border-radius: var(--r-dialog);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: popin 0.14s ease;
}
.palette-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line-card);
}
.palette-head input {
  flex: 1;
  border: none;
  background: none;
  font-size: 14.5px;
  height: auto;
  padding: 0;
}
.palette-list {
  max-height: 52vh;
  overflow: auto;
  padding: 6px;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--r-control);
  cursor: pointer;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
}
.palette-item[aria-selected="true"] {
  background: #f4f6fb;
}
.palette-kind {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  border-radius: 4px;
  padding: 2px 6px;
  width: 74px;
  text-align: center;
  flex: none;
  color: var(--muted);
  background: var(--off-bg);
}
.palette-kind[data-kind="action"] {
  color: var(--accent-hover);
  background: var(--accent-tint);
}
.palette-kind[data-kind="dataset"] {
  color: var(--ok);
  background: var(--ok-bg);
}
.palette-kind[data-kind="collection"] {
  color: var(--warn);
  background: var(--warn-bg);
}
.palette-label {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-family: var(--mono);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-sub {
  font-size: 11.5px;
  color: var(--faint);
  flex: none;
}
.palette-empty {
  padding: 22px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
}
.palette-foot {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 9px 15px;
  border-top: 1px solid var(--line-card);
  background: var(--rail);
  font-size: 11px;
  color: var(--faint);
}
.palette-foot b {
  font-family: var(--mono);
  font-weight: 500;
}

/* ------------------------------------------------------- 6. screen specifics
 * sign in (rendered without the shell)
 */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ground);
  padding: 24px;
}
.auth-card {
  width: 392px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-card);
}
.auth-card .brand {
  padding: 0;
  margin-bottom: 22px;
}
.auth-card h1 {
  font-size: 19px;
  margin-bottom: 4px;
}
.auth-lede {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 22px;
}
.btn-google {
  width: 100%;
  height: 38px;
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
  font-size: 13.5px;
}
.btn-google:hover {
  background: var(--hover);
  color: var(--text);
  border-color: var(--line-strong);
}
.btn-google .g {
  font-family: var(--mono);
  font-weight: 500;
  color: var(--accent);
}
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: #c8c8c3;
  font-size: 11px;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.auth-note {
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--faint);
}

/* datasets index filter bar */

.filterbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 11px;
  background: var(--surface);
  border: 1px solid var(--line-input);
  border-radius: 9px;
  max-width: 360px;
}
.search input {
  border: none;
  background: none;
  flex: 1;
  height: auto;
  padding: 0;
  font-size: 13px;
  min-width: 0;
}
.search-glyph {
  color: var(--faintest);
  font-size: 13px;
}
.result-count {
  font-size: 12px;
  color: var(--faint);
  font-family: var(--mono);
}

/* detail page title row */

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.detail-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.detail-desc {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--text-2);
  max-width: 640px;
  line-height: 1.5;
}

/* An even two-column band of cards on a detail page. */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
  align-items: start;
}
.two-col .card + .card {
  margin-top: 0;
}

/* overview */

.overview-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  align-items: start;
}
.overview-grid .card + .card {
  margin-top: 0;
}

/* A stacked list row — the design's "latest releases" panel. */
.list-row {
  display: block;
  padding: 11px 15px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
}
.list-row:last-child {
  border-bottom: none;
}
.list-row:hover {
  background: var(--hover);
  color: var(--text);
}
.list-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}
.list-row-top .cell-faint {
  font-size: 11px;
}
.list-row-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* collections card grid */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.collection-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 16px;
  color: var(--text);
}
a.collection-card:hover {
  border-color: #d0d0cc;
  color: var(--text);
}
.collection-card-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.collection-card-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  min-height: 36px;
}
.collection-card-meta {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--faint);
  font-family: var(--mono);
  padding-top: 4px;
  border-top: 1px solid var(--line-soft);
  margin-top: auto;
}

/* A table cell flush with the card's own padding — for tables that sit inside
   an already-padded card rather than spanning a flush one. */
.table .flush,
.table th.flush {
  padding-left: 0;
  padding-right: 0;
}


/* release manifest ("pinned contents") */

.manifest-body {
  padding: 14px 15px;
}
.manifest-group + .manifest-group {
  margin-top: 18px;
}
.manifest-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.manifest-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
}
.manifest-meta {
  font-size: 11.5px;
  color: var(--faint);
  font-family: var(--mono);
}
.table-inner th {
  font-size: 10.5px;
  color: var(--faintest);
  padding: 5px 0;
  border-bottom: none;
}
.table-inner th + th {
  padding: 5px 8px;
}
.table-inner td {
  padding: 5px 0;
  border-bottom: none;
  border-top: 1px solid var(--ground);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
}
.table-inner tbody tr:hover {
  background: none;
}

/* Standing notice on a detail page — an archived dataset, a pulled release.
   Unlike a toast this never dismisses: it describes the record's condition, not
   the outcome of the last click. */

.notice-block {
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--warn-line);
  border-left-width: 3px;
  border-radius: var(--r-control);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13px;
  line-height: 1.55;
}
.notice-block strong {
  font-weight: 500;
}

/* empty states */

.empty {
  padding: 26px 15px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
}

/* generic prose list used by the dataset "how to get this data" panel */

.linklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.linklist li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
}
.linklist .meta {
  font-size: 11.5px;
  color: var(--faint);
  font-family: var(--mono);
}

/* ------------------------------------------------------------ 7. responsive
 * The prototype is desktop-only. Below 900px the sidebar stops being a rail
 * and becomes a normal top block; nav items lay out in a row.
 */

@media (max-width: 900px) {
  .shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 14px;
  }
  .sidebar > * {
    padding: 0;
  }
  .brand {
    padding: 0;
  }
  .sidebar-palette {
    order: 4;
    flex: 1 1 100%;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0;
    gap: 4px;
  }
  .sidebar-foot {
    margin-top: 0;
    margin-left: auto;
    border-top: none;
    padding: 0;
  }
  .whoami-id {
    display: none;
  }
  .topbar {
    padding: 0 14px;
  }
  .page-inner {
    padding: 20px 14px 48px;
  }
  .strip {
    grid-template-columns: 1fr 1fr;
  }
  .overview-grid,
  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .table-wrap {
    overflow-x: auto;
  }
  .table {
    min-width: 560px;
  }
}
