/* The Databáze section (js/catalog-browser.js, js/catalog-editor.js): the list, type filter, phone picker and the source detail with its tabs and export dialog.
   Moved out of base.css, shared-components.css and features.css in their
   original cascade order; loaded after features.css and before type.css. */

.ds-list > .library-empty.compact-loader {
  padding: 22px 18px;
}

.ds-list > .library-empty.catalog-empty {
  min-height: 48px;
  padding: 18px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

/* ── Datové zdroje ─── */
.datasources-area { flex: 1; overflow: hidden; display: none; }

.datasources-wrap { width: 100%; max-width: none; margin: 0; }

.datasources-wrap {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ds-filter {
  width: 100%;
  min-width: 0; outline: none; box-sizing: border-box;
}

.ds-filter:focus {
  box-shadow: none;
}

.ds-filter::selection {
  background: rgba(15, 23, 42, 0.14);
  color: inherit;
}

.datasources-sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

.datasources-sidebar-controls {
  display: flex;
  flex-direction: column;
  border-radius: 0;
}

.ds-type-dd-chev { width: 11px; height: 11px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.ds-type-menu {
  /* position: fixed (not absolute) + JS-computed top/left in app.js --
     .datasources-sidebar clips overflow for its rounded corners, which
     would otherwise cut this popover off. */
  position: fixed;
  z-index: 60;
  display: none;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 4px;
  min-width: 172px;
}

.ds-type-menu.open { display: block; }

.ds-type-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
}

.ds-type-menu-item svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .8;
  flex: 0 0 auto;
}

.datasources-body {
  flex: 1;
  min-height: 0;
  display: grid;
}

.ds-list {
	      display: flex;
	      flex-direction: column;
	      height: 100%;
	      overflow-y: auto;
	      min-width: 0;
	    }

.ds-item {
	      cursor: pointer;
	      transition: background .15s, color .15s, border-color .15s;
	      position: relative;
	      display: flex;
	      align-items: center;
	    }

.ds-item:last-child {
	      border-bottom: 0;
	    }

.ds-item-name {
	      min-width: 0;
	      margin: 0;
	      letter-spacing: -0.01em;
	      overflow: hidden;
	      display: -webkit-box;
	      -webkit-line-clamp: 2;
	      -webkit-box-orient: vertical;
	    }

.ds-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 0;
  background: transparent;
  opacity: .9;
}

.ds-badge:focus-visible {
  outline: 2px solid rgba(15, 23, 42, 0.18);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.ds-badge svg {
  width: 21px;
  height: 21px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eurostat-mark {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-radius: 5px;
  color: currentColor;
  font-family: var(--font-sans);
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.04em;
}

.ds-type-seg-btn .eurostat-mark {
  width: 16px;
  height: 16px;
  border-radius: 4.5px;
  font-size: 7px;
}

.ds-type-menu-item .eurostat-mark {
  width: 14px;
  height: 14px;
  border-width: 1.4px;
  border-radius: 4px;
  font-size: 6px;
}

.ds-badge.sql,
.ds-badge.eurostat,
.ds-badge.cnb,
.ds-badge.csu,
.ds-badge.model {
  color: var(--ink);
}

.ds-detail-type-icon {
  flex: 0 0 auto;
  opacity: .82;
  margin-right: -2px;
}

.ds-detail {
  display: flex; flex-direction: column;
  padding: 0; min-height: 0; height: 100%; min-width: 0; overflow: visible;
}

.ds-detail-empty { text-align: center; padding: 60px 20px; font-size: var(--text-md); }

.ds-detail > .ds-detail-empty {
  margin: auto;
  padding: 0 20px;
}

.ds-detail-empty.loading {
  color: var(--faint);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  /* A detail usually arrives within a fraction of a second; the loader
     shows only when it does not. */
  opacity: 0;
  animation: chatLoadingAppear .3s ease .3s forwards;
}

/* The previous source stays while the next loads, dimmed only after a beat. */
.ds-detail.is-switching > * {
  opacity: .5;
  transition: opacity .2s ease .25s;
}

.ds-detail.is-revealing > * {
  animation: chatContentReveal .16s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .ds-detail-empty.loading { animation-duration: .01s; }

  .ds-detail.is-switching > * { transition: none; }

  .ds-detail.is-revealing > * { animation: none; }
}
.ds-detail-header {
  justify-content: space-between;
  margin-bottom: 0;
  flex: 0 0 auto;
  overflow: visible;
}

.ds-detail-heading {
  min-width: 0;
  flex: 1 1 auto;
  overflow: visible;
}

.ds-detail-heading > div:first-child { min-width: 0; }

.ds-detail-title-row {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  flex: 1 1 auto;
}

.ds-detail-name {
  margin: 0;
  min-width: 0;
}

.ds-detail-tabs {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border-radius: var(--r-md);
  border: 0;
  width: fit-content;
  white-space: nowrap;
}

.ds-detail-tab {
  border: none;
  background: transparent;
  letter-spacing: 0;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.ds-detail-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.ds-detail-panel {
  display: none;
}

.ds-detail-panel.active {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
}

.ds-detail-panel[data-detail-panel="description"].active {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.ds-detail-panel[data-detail-panel="preview"].active {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.ds-detail-desc {
  width: 100%;
  font-family: inherit; box-sizing: border-box;
}

.ds-detail-section-title {
  font-size: var(--text-md);
  font-weight: 500;
  margin: 0 0 8px 0;
  text-transform: none;
  letter-spacing: 0;
}

.ds-description-layout {
  flex: 1 1 auto;
  align-items: stretch;
  margin-top: 0;
  min-height: 0;
  width: 100%;
}

.ds-description-rules .ds-detail-desc {
  flex: 1 1 auto;
}

.ds-schema-relations,
.ds-relation-pairs {
	      display: flex;
	      flex-direction: column;
	      gap: 0;
	    }

.ds-schema-relations {
  gap: 14px;
}

.ds-schema-table-wrap {
  border: 1px solid #1f2937;
  border-radius: var(--r-md);
  overflow: hidden;
}

table.ds-schema-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}

table.ds-schema-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom: 1px solid #1f2937;
}

table.ds-schema-table td {
  padding: 7px 12px;
  border-bottom: 1px solid #1f2937;
  vertical-align: top;
}

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

.ds-schema-table col.col-name { width: 17%; }

.ds-schema-table col.col-type { width: 16%; }

.ds-schema-table col.col-unit { width: 12%; }

.ds-schema-name-cell {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.ds-schema-type-cell {
  overflow-wrap: anywhere;
}

.ds-relation-source,
.ds-relation-local,
.ds-relation-target {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  font-size: var(--text-sm);
  box-sizing: border-box;
}

.ds-relation-description {
  width: 100%;
  min-height: 64px;
  resize: none;
  box-sizing: border-box;
  font-family: inherit;
  min-height: 58px;
}

.ds-column-description {
  width: 100%;
  min-height: 34px;
  height: auto;
  max-height: none;
  padding: 6px 8px;
  font-size: var(--text-sm);
  line-height: 1.4;
  resize: none;
  overflow: visible;
  field-sizing: content;
  box-sizing: border-box;
  font-family: inherit;
}

.ds-column-description:hover {
  background: rgba(148, 163, 184, 0.08);
}

.ds-column-unit {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  font-size: var(--text-sm);
  box-sizing: border-box;
}

.ds-column-unit:hover {
  background: rgba(148, 163, 184, 0.08);
}

.ds-relation-head,
.ds-relation-pair {
  display: grid;
  grid-template-columns: minmax(140px, 1fr);
  gap: 8px;
  align-items: center;
}

.ds-relation-head {
  padding-right: 0;
}

.ds-relation-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .15s;
  overflow: hidden;
}

.ds-relation-list {
  display: grid;
  align-items: start;
}

table.ds-schema-table th {
  background: var(--surface-inset);
  color: var(--muted);
}

table.ds-schema-table tr:hover td {
  background: var(--surface-inset);
}

.ds-relation-card {
  border-color: var(--border-input);
  color: var(--ink);
}

.datasources-sidebar {
  border-color: var(--border);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.05);
}

.datasources-sidebar-controls {
  border-color: var(--border);
}

.ds-relation-source,
.ds-relation-local,
.ds-relation-target,
.ds-column-unit,
.ds-column-description,
.ds-relation-description {
  border-color: var(--border-card-hover);
}

@media (max-width: 900px) {
  .ds-description-layout,
  .ds-relation-pair {
      grid-template-columns: 1fr;
    }

  .ds-description-rules {
      grid-column: auto;
    }

  .ds-description-row-meaning {
      grid-column: auto;
    }

  .ds-detail-panel[data-detail-panel="description"].active {
      min-height: 0;
    }

  .ds-description-layout {
      grid-template-rows: none;
    }

  .ds-relation-pair span {
      display: none;
    }
}
.ds-detail-header {
  border-bottom-color: var(--border);
}

.ds-detail-tabs {
  background: transparent;
}

.ds-detail-heading {
  grid-template-columns: minmax(0, 1fr) max-content;
}

.ds-detail-title-row {
  align-self: start;
  overflow: visible;
}

.ds-detail-name {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

.ds-detail-tabs {
  align-self: start;
  justify-self: end;
  flex-wrap: wrap;
  justify-content: flex-end;
  row-gap: 4px;
  max-width: min(100%, 420px);
}

#ds-sheet-preview {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ds-sheet { border: 1px solid #1f2937; border-radius: var(--r-sm); margin-bottom: 12px; overflow: hidden; }

#ds-sheet-preview .ds-sheet {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.ds-sheet-table-wrap { overflow: auto; max-height: 460px; }

#ds-sheet-preview .ds-sheet-table-wrap {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  background: var(--surface-inset);
}

.ds-sheet-table { width: 100%; border-collapse: collapse; }

.ds-sheet-table th { text-align: left; white-space: nowrap; }

.ds-sheet-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1100px) {
  .datasources-area { padding: var(--main-pad) var(--main-pad) var(--main-pad) calc(var(--rail-width) + var(--main-pad)); }

  .datasources-wrap { height: auto; }

  .datasources-body { grid-template-columns: 1fr; }

  .ds-list { max-height: 260px; height: auto; }

  .ds-detail { height: auto; min-height: 320px; }
}
.ds-detail-name {
  color: var(--ink);
}

.ds-type-menu {
	      background: var(--surface);
	      border-color: var(--border);
	      box-shadow: var(--shadow-float);
	    }

.ds-filter,
.ds-detail-desc {
  /* The colour only: the library search draws its magnifier as a
     background image, which the shorthand would wipe. */
  background-color: var(--surface);
  border-color: var(--border-input);
  color: var(--ink);
}

.ds-item,
.ds-detail,
.ds-sheet {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

@media (max-width: 720px) {
  .datasources-area {
      padding-left: var(--main-pad);
    }

  .ds-detail-heading {
      grid-template-columns: 1fr;
      gap: 12px;
    }

  .ds-detail-title-row {
      width: 100%;
    }

  .ds-detail-tabs {
      justify-self: start;
      justify-content: flex-start;
      max-width: 100%;
      width: 100%;
    }

  .ds-detail-tab {
      padding-inline: 9px;
    }
}
.ds-item {
	      background: transparent;
	      border-bottom: 1px solid var(--border-soft);
	      box-shadow: none;
	    }

.ds-detail:has(> .ds-detail-empty) {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: none;
}

.ds-detail-empty {
  color: var(--muted) !important;
}

.ds-detail-section-title {
  color: var(--ink);
}

.ds-item-name,
.ds-sheet-table {
  color: var(--ink);
}

.ds-sheet-table {
  background: transparent;
  border: 0;
  color: var(--ink);
  box-shadow: none;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}

.ds-sheet-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: linear-gradient(180deg, var(--surface-page), var(--hover-bg));
  border-bottom: 1px solid var(--border-input);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.005em;
  padding: 10px 12px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.ds-sheet-table td {
  border-bottom: 1px solid var(--border-soft);
  color: var(--ink);
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.72);
  max-width: 360px;
}

.ds-sheet-table tbody tr:nth-child(even) td {
  background: rgba(247, 250, 252, 0.88);
}

.ds-sheet-table tbody tr:hover td {
  background: var(--card-hover-bg);
}

/* Canonical catalogue editor */
.datasources-area {
  padding: 0 0 0 var(--rail-width);
  background: var(--surface-page);
}

.datasources-wrap {
  height: 100%;
  padding: 18px 20px 20px;
  box-sizing: border-box;
}

.datasources-body {
  height: 100%;
  grid-template-columns: clamp(15.5rem, 18vw, 19rem) minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.datasources-sidebar {
  border: 0;
  border-radius: var(--r-xl) 0 0 var(--r-xl);
  background: var(--surface-inset);
}

/* Search and type strip together end on the same line as the detail
   header beside them, so the two dividers run straight across. */
.datasources-sidebar-controls {
  gap: 8px;
  box-sizing: border-box;
  padding: 1.05rem .95rem .9rem;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-inset);
}

.ds-search-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ds-search-row .ds-filter { flex: 1 1 auto; }

/* Source type as a segmented strip: one icon per type, the chosen one
   raised on the strip like a pressed key. Names come from the tooltip. */
.ds-type-seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--r-md);
  background: var(--active-bg);
}

.ds-type-seg-btn {
  flex: 1 1 0;
  display: grid;
  place-items: center;
  height: 28px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}

.ds-type-seg-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ds-type-seg-btn:hover { color: var(--ink); }

.ds-type-seg-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

.ds-type-menu-item {
  font-size: var(--text-sm);
  color: var(--text);
}

.ds-type-menu-item:hover { background: var(--hover-bg); color: var(--ink); }

.ds-type-menu-item.active { background: var(--active-bg); color: var(--ink); font-weight: 600; }

/* Same field as the Knihovna search: magnifier first, then the text. */
.ds-filter {
  min-height: 38px;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border-input);
  border-radius: var(--r-md);
  background-color: rgba(254, 253, 251, .82);
  background-image: var(--search-icon);
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 15px 15px;
  color: var(--ink);
  font-size: var(--text-sm);
}

.ds-filter:focus { border-color: var(--border-focus); }

.ds-list {
  gap: 2px;
  padding: 7px 10px 16px;
  scrollbar-gutter: stable;
}

.ds-item {
  flex: 0 0 auto;
  min-height: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-sm);
}

.ds-item:hover,
.ds-item.keyboard-active {
  background: var(--hover-bg);
}

.ds-item.active {
  background: var(--active-bg);
  box-shadow: none;
}

.ds-item-name {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 450;
  line-height: 1.42;
}

.ds-detail {
  border: 0;
  border-left: 1px solid var(--border-soft);
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}

.ds-detail-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  min-height: 110px;
  box-sizing: border-box;
  padding: 0;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
}

.ds-detail-heading {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: auto;
  padding: 1.25rem 1.55rem .75rem;
  box-sizing: border-box;
}

.ds-detail-title-row {
  width: min(100%, var(--zpravy-measure));
  max-width: var(--zpravy-measure);
  gap: .7rem;
}

.ds-detail-name {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 550;
  line-height: 1.25;
  letter-spacing: -.015em;
}

.ds-detail-controls {
  position: static;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-width: 0;
  padding: .15rem 1.55rem .95rem;
  transform: none;
}

.ds-detail-tabs { gap: 18px; }

.ds-detail-tab {
  padding: 7px 2px 6px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 550;
}

/* Tabs are marked by a rule under the active label, not a filled shape.
   The pill this replaced was the loudest thing in a quiet UI, and it had to
   carry a tan strong enough to beat the surface, which made it louder still.
   The transparent border on the resting state reserves the 2px so switching
   tabs never shifts the row. */
.ds-detail-tab:hover {
  color: var(--ink);
  background: transparent;
}

.ds-detail-tab.active {
  color: var(--ink);
  background: transparent;
  border-bottom-color: var(--accent);
}

.ds-detail-tab:focus { outline: none; }

.ds-detail-tab:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ds-detail-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
}

.ds-detail-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 550;
  text-decoration: none;
  transition: background var(--dur) ease, border-color var(--dur) ease, transform var(--dur) ease;
}

.ds-detail-download svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ds-detail-download:hover {
  border-color: var(--border-card-hover);
  background: var(--hover-bg);
  transform: none;
}

.ds-detail-content {
  padding: 1.8rem clamp(1.55rem, 2.4vw, 2.2rem) 2.4rem;
  background: var(--surface);
}

/* The preview bleeds past the column's padding on every side. At the bottom
   it now takes all of it (2.4rem, the column's own padding-bottom) rather
   than most: the strip that was left over is exactly what the horizontal
   scrollbar needs, so the bar sits in the gap under the table instead of
   costing the table a row of height. */
.ds-detail-panel[data-detail-panel="preview"].active {
  margin: -1.8rem calc(-1 * clamp(1.55rem, 2.4vw, 2.2rem)) -2.4rem;
}

.ds-detail-panel[data-detail-panel="preview"] .ds-sheet-table-wrap {
  border-radius: 0;
}

/* The detail column stays up rather than fading like the app's auto-hiding
   ones: it is the only cue that the description continues below. */
.ds-detail-content {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb-strong) transparent;
  transition: none;
}

.ds-detail-content::-webkit-scrollbar { width: 8px; height: 8px; }

.ds-detail-content::-webkit-scrollbar-track { background: transparent; }

.ds-detail-content::-webkit-scrollbar-thumb,
.ds-detail-content.is-scrolling::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb-strong);
  border-radius: var(--r-pill);
  transition: none;
}

.ds-detail-content::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.ds-detail-content::-webkit-scrollbar-corner { background: transparent; }

/* The preview table is read by dragging it sideways, so that bar is the one
   control here and it has to stay put: one size, always visible, in the
   app's own colours. Neither engine will do that with a native bar. Chrome
   ignores ::-webkit-scrollbar sizing as soon as any standard scrollbar
   property is set -- the app sets scrollbar-color on `*` -- and Firefox
   follows the Windows setting that thins and hides overlay bars whatever
   the page asks for. So both native bars go, js/sheet-scrollbar.js draws the
   horizontal one, and the rows keep the wheel and need no bar at all. */
.ds-sheet-table-wrap {
  scrollbar-width: none;
  transition: none;
}

.ds-sheet-table-wrap::-webkit-scrollbar { width: 0; height: 0; }

/* Keep the hit area comfortably tall, but paint only the thumb. A visible
   full-width rail looked like a second container under the table. */
.ds-sheet-scrollbar {
  position: relative;
  flex: 0 0 auto;
  height: 13px;
  margin: 0 12px 4px;
  background: transparent;
}

.ds-sheet-scrollbar[hidden] { display: none; }

/* The pointer gets the full 13px hit area. The thumb darkens like a native
   scrollbar on hover and again while held, without changing size. */
.ds-sheet-scrollbar-thumb {
  position: absolute;
  top: 0;
  left: 0;
  height: 7px;
  min-width: 56px;
  border-radius: var(--r-pill);
  background: var(--scrollbar-thumb-strong);
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  background-clip: padding-box;
  box-sizing: content-box;
  cursor: grab;
  touch-action: none;
  transition: background-color var(--dur) ease;
}

.ds-sheet-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

.ds-sheet-scrollbar-thumb:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.ds-sheet-scrollbar-thumb.is-held {
  background-color: var(--faint);
  cursor: grabbing;
}

.ds-detail-panel { margin-top: 0; }

.ds-detail-desc,
.ds-column-description,
.ds-column-unit,
.ds-relation-source,
.ds-relation-local,
.ds-relation-target,
.ds-relation-description {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  outline: 0;
  background: var(--surface-inset);
  color: var(--ink);
  box-shadow: none;
  transition: background var(--dur), border-color var(--dur);
}

.ds-detail-desc {
  min-height: 88px;
  padding: 10px 12px;
  font-size: var(--text-sm);
  line-height: 1.62;
  resize: none;
  field-sizing: content;
  max-height: 46vh;
}

.ds-detail textarea.ds-readonly-field { resize: none; }

.ds-description-row-meaning .ds-detail-desc { min-height: 64px; }

.ds-description-rules .ds-detail-desc { min-height: 88px; }

.ds-detail-desc {
  border-color: transparent;
}

.ds-detail-desc:focus,
.ds-column-description:focus,
.ds-column-unit:focus,
.ds-relation-source:focus,
.ds-relation-local:focus,
.ds-relation-target:focus,
.ds-relation-description:focus {
  border-color: var(--border-focus);
  background: var(--surface);
  box-shadow: none;
}

/* The public catalogue is an inspection surface. Its existing field
   structure still gives long metadata sensible wrapping, but it should
   read as content rather than as a disabled editor. */
.ds-detail.is-readonly .ds-readonly-field {
  pointer-events: none;
  cursor: default;
  opacity: 1;
}

.ds-detail.is-readonly .ds-detail-desc,
.ds-detail.is-readonly .ds-column-description,
.ds-detail.is-readonly .ds-column-unit,
.ds-detail.is-readonly .ds-relation-description {
  border-color: transparent;
  background: transparent;
}

.ds-detail.is-readonly .ds-detail-desc:hover {
  background: transparent;
}

.ds-detail.is-readonly .ds-relation-source,
.ds-detail.is-readonly .ds-relation-local,
.ds-detail.is-readonly .ds-relation-target {
  border-color: transparent;
  background-color: transparent;
  color: var(--ink);
  appearance: none;
}

.ds-relation-local,
.ds-relation-target {
  text-align: center;
  text-align-last: center;
}

.ds-detail.is-readonly .ds-column-description {
  min-height: 0;
  height: auto;
  max-height: none;
  padding: 0;
  overflow: visible;
  field-sizing: content;
  line-height: 1.45;
}

.ds-detail.is-readonly .ds-relation-description {
  max-height: none;
  overflow: visible;
  field-sizing: content;
}

.ds-schema-table-wrap { border-color: var(--border-soft); }

table.ds-schema-table th { border-color: var(--border-soft); }

table.ds-schema-table td { border-color: var(--border-soft); }

.ds-schema-name-cell {
  color: var(--ink);
  font-size: var(--text-sm);
}

.ds-schema-type-cell {
  color: var(--muted);
  font-size: var(--text-xs);
}

.ds-relation-description {
  padding: 9px 11px;
  font-size: var(--text-sm);
  line-height: 1.45;
}

.ds-relation-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ds-relation-pair,
.ds-detail.is-readonly .ds-relation-pair {
  grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr);
}

.ds-relation-card {
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: none;
}

.ds-relation-head {
  min-height: 20px;
}

.ds-relation-pair {
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--surface-inset);
}

.ds-relation-pair .ds-relation-equals {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  align-self: center;
  justify-self: center;
  color: var(--muted);
  font-size: var(--text-2xs);
  line-height: 1;
}

.ds-detail.is-readonly .ds-relation-source {
  padding: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.4;
  text-overflow: ellipsis;
}

.ds-detail.is-readonly .ds-relation-local,
.ds-detail.is-readonly .ds-relation-target {
  padding: 0;
  font-size: var(--text-xs);
  line-height: 1.35;
  text-overflow: ellipsis;
}

.ds-detail.is-readonly .ds-relation-description {
  min-height: 0;
  margin: 0;
  padding: 10px 0 0;
  border: 0;
  border-top: 1px solid var(--border-soft);
  border-radius: 0;
  background: transparent;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.ds-relation-card:hover,
.ds-relation-card:focus-within {
  border-color: var(--border-card-hover);
  box-shadow: none;
}

@media (max-width: 1180px) {
  .ds-detail-heading {
      padding: .9rem 1rem .65rem;
    }

  .ds-detail-title-row { max-width: none; }

  .ds-detail-controls {
      padding: .1rem 1rem .75rem;
    }
}
@media (max-width: 760px) {
  .datasources-body {
      grid-template-columns: minmax(0, 1fr);
    }

  .datasources-sidebar {
      max-height: 17rem;
      border-bottom: 1px solid var(--border);
    }

  .ds-list { height: auto; }

  .ds-detail {
      min-height: 26rem;
      border-top: 0;
      border-left: 0;
    }

  .ds-detail-controls {
      overflow-x: auto;
    }

  .ds-detail-tabs { width: max-content; }

  .ds-relation-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .ds-relation-list { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .datasources-area { padding: 0; }

  .datasources-wrap { padding: 0; }

  .datasources-body {
      border: 0;
      border-radius: 0;
      box-shadow: none;
    }

  .datasources-sidebar { border-radius: 0; }
}
/* Editor panels use the full pane width; description fields sit in
   a balanced two-column grid, technical row spans below. */
.ds-description-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: none;
  align-content: start;
  gap: 20px 26px;
}

/* Public descriptions form one card that grows with its content: every
   row is as tall as its text and the detail pane scrolls once, as a whole.
   It used to be pinned to the pane's height with each row scrolling on its
   own, which cut long rules off mid-sentence behind a second scrollbar. */
.ds-description-layout-readonly {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  align-self: flex-start;
  width: min(100%, 1080px);
  height: auto;
  box-sizing: border-box;
  margin-inline: auto;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  background: var(--surface-inset);
}

.ds-dataset-facts {
  display: grid;
  grid-template-columns: minmax(8rem, .65fr) minmax(10rem, .85fr) minmax(10rem, .85fr) minmax(13rem, 1.65fr);
  gap: 1.5rem;
  margin: 0;
  padding: 1.15rem 1.75rem 1.2rem;
}

.ds-dataset-footer {
  flex: 0 0 auto;
  margin-top: 0;
  border-top: 1px solid var(--border-soft);
  background: transparent;
}

.ds-dataset-fact { min-width: 0; }

.ds-dataset-fact dt {
  margin: 0 0 .38rem;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.35;
}

.ds-dataset-fact dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.ds-description-layout-readonly .ds-description-block {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(9.5rem, 11.5rem) minmax(0, 1fr);
  gap: 1.6rem;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  padding: 1.35rem 1.75rem 1.45rem;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
}

.ds-description-layout-readonly .ds-description-summary .ds-description-copy {
  max-width: 84ch;
  font-size: var(--text-lg);
  line-height: 1.64;
}

.ds-description-layout-readonly .ds-description-summary {
  padding-block: 1.7rem 1.8rem;
  background: transparent;
}

.ds-description-layout-readonly .ds-description-summary .ds-detail-section-title {
  color: var(--green-deep);
  font-size: var(--text-sm);
}

.ds-description-layout-readonly .ds-description-examples {
  border-bottom: 0;
}

.ds-description-layout-readonly .ds-detail-section-title {
  margin: .15rem 0 0;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: 0;
}

.ds-description-copy {
  max-width: 84ch;
  margin: 0;
  color: var(--ink);
  font-size: var(--text-md);
  line-height: 1.68;
  white-space: pre-line;
}

.ds-description-body {
  min-width: 0;
}

.ds-example-questions {
  display: grid;
  gap: .42rem;
  max-width: 84ch;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ink);
  font-size: var(--text-md);
  line-height: 1.58;
}

.ds-example-questions li {
  position: relative;
  padding-left: 1rem;
}

.ds-example-questions li::before {
  content: '';
  position: absolute;
  top: .7em;
  left: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.ds-description-empty {
  color: var(--muted);
  font-style: italic;
}

.ds-description-row-meaning,
.ds-description-rules {
  grid-column: auto;
}

@media (max-width: 1100px) {
  .ds-description-layout {
      grid-template-columns: 1fr;
    }

  .ds-description-layout-readonly {
      padding: 0;
    }

  .ds-dataset-facts {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

  .ds-description-layout-readonly .ds-description-block {
      grid-template-columns: 1fr;
      gap: .65rem;
    }
}
@media (max-width: 620px) {
  .ds-dataset-facts { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  /* Two columns do not fit, and squeezing them gave a five-row list above
     a screenful of "choose from the list on the left" -- with no left to
     choose from. They are two screens instead: the catalogue, then the
     source, with a way back. */
  .datasources-body {
    display: block;
    position: relative;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .datasources-sidebar,
  .ds-detail {
    width: 100%;
    max-width: none;
    border: 0;
  }

  /* The 1100px breakpoint caps the list at 260px so it can sit above the
     detail. Here they are separate screens, so the catalogue gets the
     whole of one. */
  .ds-list {
    max-height: none;
    height: auto;
    overflow-y: visible;
  }

  /* A narrower breakpoint caps the sidebar so it can sit above the detail
     in one scroller. Here it is the whole screen, so the cap has to go or
     the catalogue shows five of its 133 rows. */
  .datasources-wrap,
  .datasources-sidebar {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .datasources-area {
    overflow-y: auto;
  }

  body:not(.ds-detail-open) .ds-detail,
  body:not(.ds-detail-open) .ds-detail-back {
    display: none;
  }

  body.ds-detail-open .datasources-sidebar {
    display: none;
  }

  .ds-detail-back {
    display: none;
    align-items: center;
    gap: 6px;
    margin: 0 0 4px;
    padding: 8px 12px 8px 4px;
    border: 0;
    background: transparent;
    color: var(--accent);
    font: inherit;
    font-size: var(--text-md);
    font-weight: 550;
    cursor: pointer;
  }

  body.ds-detail-open .ds-detail-back {
    display: inline-flex;
  }

  .ds-detail-back svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}
/* The catalogue and a source are one screen with two columns everywhere
   but a phone, so there is nothing to go back to and no button for it. */
.ds-detail-back {
  display: none;
}

@media (max-width: 720px) {
  body[data-mode="datasources"] .datasources-sidebar-controls {
      padding-left: var(--rail-toggle-slot);
    }

  /* Databáze is one phone workspace. The selected source fills the screen
       and the bottom field opens the catalogue upward like a compact picker. */
  .datasources-area,
    .datasources-wrap,
    .datasources-body {
      height: 100%;
      min-height: 0;
    }

  .datasources-area {
      overflow: hidden;
    }

  /* Phone users swipe the table itself. The separate desktop drag control
       costs a full row of scarce preview height and adds no touch value. */
  .ds-sheet-scrollbar {
      display: none;
    }

  .datasources-body {
      --ds-mobile-control-height: calc(59px + env(safe-area-inset-bottom, 0px));
      --ds-mobile-detail-controls-height: 50px;
      display: grid;
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: minmax(0, 1fr) auto;
      position: relative;
      overflow: hidden;
    }

  .datasources-sidebar,
    body.ds-detail-open .datasources-sidebar {
      display: contents;
    }

  .ds-detail,
    body:not(.ds-detail-open) .ds-detail {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      grid-template-rows: auto minmax(0, 1fr) auto;
      grid-column: 1;
      grid-row: 1;
      width: 100%;
      height: auto;
      min-height: 0;
      overflow: hidden;
    }

  .ds-detail-header {
      display: contents;
    }

  .ds-detail-heading {
      grid-column: 1 / -1;
      grid-row: 1;
      padding: 14px 16px 12px;
      border-bottom: 1px solid var(--border-soft);
    }

  .ds-detail-content {
      grid-column: 1 / -1;
      grid-row: 2;
    }

  /* On a phone the detail pane is the page. Its description therefore
       owns one continuous scroll instead of presenting four small nested
       scrollports followed by an oversized facts footer. */
  .ds-detail-content:has(.ds-detail-panel[data-detail-panel="description"].active) {
      padding: 0 0 18px;
    }

  .ds-detail-content:has(.ds-detail-panel[data-detail-panel="schema"].active) {
      padding-top: 0;
    }

  .ds-detail-panel[data-detail-panel="description"].active {
      display: block;
      min-height: 0;
    }

  .ds-description-layout-readonly {
      width: 100%;
      height: auto;
      min-height: 0;
      max-height: none;
      margin: 0;
      overflow: visible;
      border-right: 0;
      border-left: 0;
      border-radius: 0;
    }

  .ds-description-layout-readonly .ds-description-block,
    .ds-description-layout-readonly .ds-description-summary,
    .ds-description-layout-readonly .ds-description-row-meaning,
    .ds-description-layout-readonly .ds-description-rules,
    .ds-description-layout-readonly .ds-description-examples {
      flex: none;
      min-height: 0;
      overflow: visible;
    }

  .ds-description-layout-readonly .ds-description-row-meaning,
    .ds-description-layout-readonly .ds-description-examples {
      flex-basis: auto;
    }

  /* Four table columns become too narrow on a phone. The schema keeps its
       table semantics, but each data row uses the full viewport: identity
       and type stay compact above a full-width description. */
  .ds-detail-panel[data-detail-panel="schema"].active .ds-schema-table-wrap {
      margin-inline: calc(-1 * clamp(1.55rem, 2.4vw, 2.2rem));
      border-right: 0;
      border-left: 0;
      border-radius: 0;
    }

  .ds-detail-panel[data-detail-panel="schema"] table.ds-schema-table {
      display: block;
      table-layout: auto;
    }

  .ds-detail-panel[data-detail-panel="schema"] .ds-schema-table colgroup {
      display: none;
    }

  .ds-detail-panel[data-detail-panel="schema"] .ds-schema-table thead {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip: rect(0 0 0 0);
      clip-path: inset(50%);
      white-space: nowrap;
    }

  .ds-detail-panel[data-detail-panel="schema"] .ds-schema-table tbody {
      display: block;
    }

  .ds-detail-panel[data-detail-panel="schema"] .ds-schema-table tbody tr {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto auto;
      gap: .25rem .75rem;
      padding: .75rem var(--main-pad);
      border-bottom: 1px solid var(--border-soft);
    }

  .ds-detail-panel[data-detail-panel="schema"] .ds-schema-table tbody tr:last-child {
      border-bottom: 0;
    }

  .ds-detail-panel[data-detail-panel="schema"] .ds-schema-table tbody td {
      display: block;
      padding: 0;
      border-bottom: 0;
    }

  .ds-detail-panel[data-detail-panel="schema"] .ds-schema-table tbody td:nth-child(2),
    .ds-detail-panel[data-detail-panel="schema"] .ds-schema-table tbody td:nth-child(3) {
      color: var(--muted);
      font-size: .7rem;
      text-align: right;
    }

  .ds-detail-panel[data-detail-panel="schema"] .ds-schema-table tbody td:nth-child(3):empty {
      display: none;
    }

  .ds-detail-panel[data-detail-panel="schema"] .ds-schema-table tbody td:nth-child(4) {
      grid-column: 1 / -1;
      padding-top: .2rem;
    }

  .ds-detail-panel[data-detail-panel="schema"] .ds-column-unit {
      width: min(6rem, 22vw);
    }

  .ds-detail-controls {
      display: contents;
    }

  .ds-detail-tabs {
      grid-column: 1 / -1;
      grid-row: 3;
      width: 100%;
      min-height: var(--ds-mobile-detail-controls-height);
      box-sizing: border-box;
      padding: 7px 112px 8px 16px;
      border-top: 1px solid var(--border-soft);
      background: rgb(var(--surface-page-rgb) / .96);
      -webkit-backdrop-filter: blur(10px);
      backdrop-filter: blur(10px);
    }

  .ds-detail-actions {
      grid-column: 2;
      grid-row: 3;
      align-self: center;
      justify-self: end;
      margin-left: 0;
      margin-right: 62px;
      padding: 0;
      z-index: 2;
    }

  .ds-detail-actions .ds-detail-download {
      width: 38px;
      min-height: 38px;
      padding: 0;
      border-radius: var(--r-md);
    }

  .ds-detail-actions .ds-detail-download span {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }

  .ds-detail-actions:empty {
      display: none;
    }

  .ds-detail-back,
    body.ds-detail-open .ds-detail-back {
      display: none;
    }

  .datasources-sidebar-controls {
      position: static;
      grid-column: 1;
      grid-row: 2;
      flex: 0 0 auto;
      z-index: 50;
      flex-direction: column;
      align-items: stretch;
      gap: 8px;
      min-height: 0;
      padding: 10px var(--main-pad) calc(10px + env(safe-area-inset-bottom, 0px));
      border-top: 1px solid var(--border-soft);
      border-bottom: 0;
      background: rgb(var(--surface-page-rgb) / .96);
      -webkit-backdrop-filter: blur(10px);
      backdrop-filter: blur(10px);
    }

  .datasources-sidebar-controls .ds-search-row {
      width: 100%;
      flex: 1 1 auto;
      max-width: none;
      min-width: 0;
      margin-left: auto;
    }

  .ds-list,
    body:not(.ds-detail-open) .ds-list {
      position: absolute;
      z-index: 55;
      left: var(--main-pad);
      right: var(--main-pad);
      bottom: calc(var(--ds-mobile-control-height) + var(--ds-mobile-detail-controls-height) + 6px);
      display: none;
      max-height: min(52vh, 420px);
      height: auto;
      overflow-y: auto;
      padding: 6px;
      border: 1px solid var(--border);
      border-radius: var(--r-lg);
      background: var(--surface);
      box-shadow: var(--shadow-pop);
    }

  body.ds-mobile-picker-open .ds-list {
      display: flex;
    }

  /* The type strip is for choosing a source, so on a phone it appears only
       while the picker is open, above the search, starting where the rail
       toggle does. The resting bar stays one row under the detail. */
  .ds-type-seg {
      display: none;
      order: -1;
      margin-left: calc(12px + env(safe-area-inset-left, 0px) - var(--rail-toggle-slot));
    }

  body.ds-mobile-picker-open .ds-type-seg {
      display: flex;
    }

  body.ds-mobile-picker-open .datasources-body {
      --ds-mobile-control-height: calc(99px + env(safe-area-inset-bottom, 0px));
    }

  body.ds-mobile-picker-open .ds-filter {
      border-color: var(--border-focus);
    }

  .ds-list .catalog-empty {
      padding: 18px 12px;
    }

  .ds-detail-back {
      margin-left: 0;
    }
}
/* Catalogue exports stay out of the page until asked for. The sheet uses
   the same warm surface and restrained controls as the rest of Databáze. */
.ds-detail-download { font-family: var(--font-sans); cursor: pointer; }

.ds-export-overlay {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgb(var(--muted-rgb) / .24);
  backdrop-filter: blur(5px);
}

.ds-export-overlay.open { display: flex; }

.ds-export-dialog {
  width: min(960px, 100%);
  height: min(560px, calc(100dvh - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  color: var(--text);
  font-family: var(--font-sans);
}

/* Title, how many rows the file holds, and the dialog's two controls --
   one row, with no footer and no close cross. */
.ds-export-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px 13px;
}

.ds-export-rows {
  color: var(--faint);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ds-export-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex: none;
}

.ds-export-dismiss {
  min-height: 38px;
  padding: 9px 16px;
  border: 1px solid var(--border-input);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
  font: 500 13px var(--font-sans);
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur);
}

.ds-export-dismiss:hover { background: var(--hover-bg); border-color: var(--border-strong, var(--border-input)); }

.ds-export-dialog:has(.ds-export-progress, .ds-export-complete) {
  width: min(520px, 100%);
  height: auto;
  max-height: calc(100dvh - 40px);
  align-self: center;
}

.ds-export-head h4 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: var(--text-base);
  font-weight: 620;
  letter-spacing: -.01em;
}

.ds-export-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 5px 20px 18px;
}

.ds-export-new,
.ds-export-cancel {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--muted);
  padding: 7px 10px;
  font: 12px var(--font-sans);
  cursor: pointer;
}

.ds-export-new:hover,
.ds-export-cancel:hover { background: var(--hover-bg); color: var(--ink); }

/* The sample fills the dialog down to its bottom edge: the table is the
   whole form now, and a last row cut off at the frame says there is more
   below, where a whole number of rows left a strip of empty dialog. */
.ds-export-body:has(> .ds-export-preview) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ds-export-preview { display: flex; flex: 1 1 auto; flex-direction: column; width: 100%; min-width: 0; min-height: 0; margin: 0; }

/* Framed like the preview table in the detail pane, so the sample reads as
   a table sitting in the dialog rather than rows floating in it. */
.ds-export-preview .ds-sheet { display: flex; flex: 1 1 auto; flex-direction: column; width: 100%; min-width: 0; min-height: 0; margin: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--r-lg); }

.ds-export-preview .ds-sheet-table-wrap { flex: 1 1 auto; min-height: 0; max-height: none; overflow-x: auto; overflow-y: hidden; }

.ds-export-preview .ds-sheet-scrollbar:not([hidden]) { display: block; margin: 0; }

/* Each header is the switch for its column: a check that fills with the
   accent while the column is in the file. Dropped columns stay in place,
   greyed and hatched, so they are one click from coming back. */
.ds-export-preview th { padding: 0; }

.ds-export-col {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur), color var(--dur);
}

.ds-export-col:hover { background: var(--hover-bg); }

.ds-export-col:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.ds-export-col-check {
  position: relative;
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
}

.ds-export-col-check::after {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 1px;
  width: 3px;
  height: 6px;
  border: solid var(--on-accent);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.ds-export-col[aria-pressed="false"] { color: var(--faint); }

.ds-export-col[aria-pressed="false"] .ds-export-col-check {
  border-color: var(--border-focus);
  background: transparent;
}

.ds-export-col[aria-pressed="false"] .ds-export-col-check::after { display: none; }

.ds-export-preview .is-excluded {
  color: var(--faint);
  background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgb(var(--muted-rgb) / .05) 6px 12px);
}

.ds-export-error { padding: 12px 2px 0; color: var(--red); font-size: var(--text-sm); }

.ds-export-footer {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  min-height: 68px;
  padding: 12px 20px 18px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}

.ds-export-footer[hidden] { display: none; }

.ds-export-create {
  min-height: 38px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--on-accent);
  padding: 9px 17px;
  font: 600 13px var(--font-sans);
  cursor: pointer;
}

.ds-export-create:hover:not(:disabled) { background: var(--accent-hover); }

.ds-export-create:disabled { opacity: .35; cursor: default; }

.ds-export-progress { padding: 13px 2px 20px; }

.ds-export-progress-copy { display: flex; justify-content: space-between; gap: 12px; font-size: var(--text-sm); }

.ds-export-progress-copy strong { color: var(--ink); font-weight: 600; }

.ds-export-progress-copy span { color: var(--faint); }

.ds-export-progress-track { height: 3px; margin-top: 12px; overflow: hidden; border-radius: var(--r-pill); background: var(--border-soft); }

.ds-export-progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s ease; }

.ds-export-complete { padding: 13px 2px 18px; }

.ds-export-complete > strong { color: var(--ink); font-size: var(--text-md); }

.ds-export-complete p { margin: 7px 0; color: var(--red); font-size: var(--text-sm); }

.ds-export-complete div { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }

.ds-export-complete a { color: var(--accent); font-size: var(--text-sm); text-decoration: none; }

.ds-export-complete a:hover { text-decoration: underline; }

@media (max-width: 700px) {
  .ds-export-overlay { align-items: stretch; padding: 10px; }

  .ds-export-dialog { width: 100%; height: min(560px, calc(100dvh - 20px)); border-radius: var(--r-lg); }

  .ds-export-head { padding: 14px 17px 12px; flex-wrap: wrap; }

  .ds-export-rows { order: 3; flex-basis: 100%; }

  .ds-export-body { padding: 4px 17px 16px; }

  .ds-export-footer { position: sticky; bottom: 0; padding: 11px 17px 15px; }
}

/* A model's page: the status sits by the title, the method is prose from
   Markdown, the inputs are a plain table. Everything else reuses the
   description blocks a dataset has. */
.ds-model-status {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--active-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.ds-model-list { margin: 0; padding-left: 18px; }
.ds-model-list li { margin: 4px 0; }

.ds-model-methodology { max-width: 72ch; }
.ds-model-methodology h1,
.ds-model-methodology h2,
.ds-model-methodology h3 { margin: 1.4em 0 0.5em; font-size: 15px; }
.ds-model-methodology h1 { font-size: 17px; margin-top: 0.4em; }
.ds-model-methodology p,
.ds-model-methodology li { line-height: 1.55; }
.ds-model-methodology code { font-size: 12.5px; }

.ds-model-inputs {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ds-model-inputs th,
.ds-model-inputs td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: top;
}
.ds-model-inputs th { color: var(--muted); font-weight: 500; }
.ds-model-inputs td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ds-model-inputs code { font-size: 12px; }
