/* Shared modal styles. */
datasette-modal {
    display: contents;
}

dialog.datasette-modal {
    --ink: #0f0f0f;
    --paper: #eef6ff;
    --muted: #6b6b6b;
    --rule: #d8e6f5;
    --accent: #1a56db;
    --card: #ffffff;
    border: none;
    border-radius: var(--modal-border-radius, 0.75rem);
    padding: 0;
    margin: auto;
    width: min(520px, calc(100vw - 32px));
    max-width: 95vw;
    max-height: calc(100dvh - 32px);
    box-shadow: var(--modal-shadow, 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04));
    animation: datasette-modal-slide-in var(--modal-animation-duration, 0.2s) ease-out;
    overflow: hidden;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--card);
    /* Stop iOS Safari enlarging longer runs of text in landscape */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

dialog.datasette-modal[open] {
    display: flex;
    flex-direction: column;
}

dialog.datasette-modal::backdrop {
    background: var(--modal-backdrop-bg, rgba(0, 0, 0, 0.5));
    backdrop-filter: var(--modal-backdrop-blur, blur(4px));
    -webkit-backdrop-filter: var(--modal-backdrop-blur, blur(4px));
    animation: datasette-modal-fade-in var(--modal-animation-duration, 0.2s) ease-out;
}

/* DatasetteModal.alert() and DatasetteModal.confirm() */
dialog.modal-confirm-dialog {
    width: min(420px, calc(100vw - 32px));
}

.modal-confirm-dialog .modal-confirm-message {
    margin: 0;
    padding: 22px 24px;
    color: var(--ink);
    font-size: 0.95rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
    /* Keep line breaks, and scroll a long message so the buttons stay visible */
    white-space: pre-wrap;
    min-height: 0;
    overflow-y: auto;
}

.modal-confirm-dialog .modal-btn-danger {
    background: #b91c1c;
    color: #fff;
}

.modal-confirm-dialog .modal-btn-danger:hover {
    background: #991b1b;
}

@keyframes datasette-modal-slide-in {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes datasette-modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

:where(.datasette-modal) .modal-header {
    padding: 20px 24px 12px;
    border-bottom: 1px solid var(--rule);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    min-width: 0;
}

:where(.datasette-modal) .modal-title {
    /* Keep the title whole: a long modal-meta is what gets truncated */
    flex-shrink: 0;
    max-width: 100%;
    /* A heading's margins would push it off centre from the modal-meta */
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
}

:where(.datasette-modal) .modal-meta {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, monospace;
    font-size: 0.7rem;
    color: var(--muted);
    background: var(--paper);
    padding: 3px 9px;
    border-radius: 20px;
}

:where(.datasette-modal) .modal-body {
    min-height: 0;
    overflow: auto;
    padding: 16px 24px 24px;
}

:where(.datasette-modal) .modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--rule);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
    background: var(--paper);
}

:where(.datasette-modal) .footer-info {
    flex: 1;
    font-family: ui-monospace, monospace;
    font-size: 0.68rem;
    color: var(--muted);
}

:where(.datasette-modal) .modal-btn {
    border: none;
    border-radius: 5px;
    padding: 9px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    touch-action: manipulation;
    font-family: inherit;
    transition: background 0.12s;
}

:where(.datasette-modal) .modal-btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--rule);
}

:where(.datasette-modal) .modal-btn-ghost:hover {
    background: var(--rule);
    color: var(--ink);
}

:where(.datasette-modal) .modal-btn-primary {
    background: var(--accent);
    color: #fff;
}

:where(.datasette-modal) .modal-btn-primary:hover {
    background: #1949b8;
}

:where(.datasette-modal) .modal-btn:disabled {
    opacity: 0.65;
    cursor: wait;
}

@media (prefers-reduced-motion: reduce) {
    dialog.datasette-modal,
    dialog.datasette-modal::backdrop {
        animation: none;
    }
}

/* View transitions ======================================================== */

/* Cross-document view transitions: navigating between same-origin Datasette
   pages crossfades rather than flashing blank. Pure CSS, no JavaScript -
   browsers without support navigate exactly as before. */
@media (prefers-reduced-motion: no-preference) {
    @view-transition {
        navigation: auto;
    }
}

/* The table and facets are swapped in place: each gets its own transition
   group, so the old table crossfades into the new one (after applying a
   filter, sorting, paginating) rather than being blended into the rest of
   the page. Names only apply during a transition, as view-transition-name
   creates a stacking context that would trap column and action menus. */
html:active-view-transition .content > .facet-results {
    view-transition-name: facet-results;
}
html:active-view-transition .table-wrapper:has(> table.rows-and-columns) {
    view-transition-name: rows-table;
}
/* No slide from the old position to the new one - when the old page was
   scrolled (clicking "Next page" below a long table) that would sweep the
   table in from thousands of pixels away. The group sits where the new
   element is and the old snapshot is clipped to it as it fades out.
   Only animation-name is reset: the old/new crossfade inherits its
   duration from the group, so the "animation" shorthand would kill it. */
::view-transition-group(facet-results),
::view-transition-group(rows-table) {
    animation-name: none;
    overflow: clip;
}

/* Reset and Page Setup ==================================================== */

/* Reset from http://meyerweb.com/eric/tools/css/reset/
   v2.0 | 20110126
   License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
ol,
ul {
	list-style: none;
}
blockquote,
q {
	quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
th {
    padding-right: 1em;
    white-space: nowrap;
}
strong {
    font-weight: bold;
}
em {
    font-style: italic;
}
/* end reset */

/* Shared modal CSS variables */
:root {
    --modal-backdrop-bg: rgba(0, 0, 0, 0.5);
    --modal-backdrop-blur: blur(4px);
    --modal-border-radius: 0.75rem;
    --modal-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --modal-animation-duration: 0.2s;
}

/* Many-to-many pills, and the many-to-many UI that matches them: text,
   background and border */
:root {
    --m2m-ink: #1e4f8f;
    --m2m-paper: #eef5fd;
    --m2m-rule: #c5d9f2;
}

/* Database, table and saved query names also become body classes (db-*,
   table-* and query-*). Scope component styles to their elements or containers
   so those names cannot change the page layout. */
body {
    margin: 0;
    padding: 0;
    font-family: "Helvetica Neue", sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #111A35;
    text-align: left;
    background-color: #F8FAFB;
}

/* Helper Styles  ===========================================================*/

.intro {
  font-size: 1rem;
}
.metadata-description {
  margin-bottom: 1em;
}
p {
  margin: 0 0 0.75rem 0;
  padding: 0;
}
.meta {
  color: rgba(0,0,0,0.3);
  font-size: 0.75rem
}
.intro {
	font-size: 1.5rem;
  margin-bottom: 0.75rem;
}
.context-text {
	/* for accessibility and hidden from sight */
	text-indent: -999em;
	display: block;
	width:0;
	overflow: hidden;
	margin: 0;
	padding: 0;
	line-height: 0;
}

h1,
h2,
h3,
h4,
h5,
h6,
.header1,
.header2,
.header3,
.header4,
.header5,
.header6 {
  font-weight: 700;
  font-size: 1rem;
  margin: 0;
  padding: 0;
  word-break: break-word;
}
h1,
.header1 {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  margin-top: 1rem;
}
h2,
.header2 {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  margin-top: 1rem;
}
h3,
.header3 {
  font-size: 1.25rem;
  margin: 1rem 0 0.25rem 0;
}
h4,
.header4 {
  margin: 1rem 0 0.25rem 0;
  font-weight: 400;
  text-decoration: underline;
}
h5,
.header5 {
  margin: 1rem 0 0.25rem 0;
  font-weight: 700;
  text-decoration: underline;
}
h6,
.header6 {
  margin: 1rem 0 0.25rem 0;
  font-weight: 400;
  font-style: italic;
  text-decoration: underline;
}

.page-header {
  padding-left: 10px;
  border-left: 10px solid #666;
  margin-bottom: 0.75rem;
  margin-top: 1rem;
}
.page-header h1 {
    margin: 0;
    font-size: 2rem;
    padding-right: 0.2em;
}

.page-action-menu details > summary {
    list-style: none;
    cursor: pointer;
}
.page-action-menu details > summary::-webkit-details-marker {
    display: none;
}

div,
section,
article,
header,
nav,
footer,
.wrapper {
	display: block;
	box-sizing: border-box;
}

a:link {
	color: #276890;
	text-decoration: underline;
}
a:visited {
	color: #54AC8E;
	text-decoration: underline;
}
a:hover,
a:focus,
a:active  {
	color: #67C98D;
	text-decoration: underline;
}

:where(h3).table-summary .count-all ~ .table-summary-description {
    margin-left: 0.5rem;
}

/* "You are not on the first page" strip, shown when ?_next= is set */
.page-position {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    margin: 0 0 1rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid #c7d7f5;
    border-radius: 0.4rem;
    background: #e8effd;
    color: #1d3461;
    font-size: 0.95rem;
    line-height: 1.4;
}
.page-position-footer {
    justify-content: flex-end;
    margin: 1rem 0 1.5rem;
}
.page-position-text {
    flex: 1 1 auto;
}
.page-position-text strong {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.page-position-text code {
    font-size: 0.85em;
    background: rgba(255, 255, 255, 0.7);
    padding: 0.05em 0.3em;
    border-radius: 0.2rem;
}
.page-position-links {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.page-position a.page-position-first,
.page-position a.page-position-next {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid #1a56db;
    border-radius: 0.3rem;
    background: #fff;
    color: #1a56db;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.page-position a.page-position-first:hover,
.page-position a.page-position-first:focus {
    background: #1a56db;
    color: #fff;
}
.page-position a.page-position-next {
    background: #1a56db;
    color: #fff;
}
.page-position a.page-position-next:hover,
.page-position a.page-position-next:focus {
    background: #1646b3;
    border-color: #1646b3;
    color: #fff;
}

:where(h3).table-summary .count-error:not(:empty) {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
}

button.count-all {
    background: none;
    border: none;
    padding: 3px 0;
    margin-left: 0.25rem;
    color: #276890;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.5;
    cursor: pointer;
}

button.count-all:hover,
button.count-all:focus-visible {
    text-decoration: underline;
}

button.count-all:disabled {
    color: #596478;
    cursor: wait;
}

@media (pointer: coarse) {
    button.count-all {
        min-height: 44px;
        padding-left: 7px;
        padding-right: 7px;
    }
}

button.button-as-link {
    background: none;
    border: none;
    padding: 0;
    color: #276890;
    text-decoration: underline;
    cursor: pointer;
    font-size: 1rem;
}
button.button-as-link:hover,
button.button-as-link:focus {
	color: #67C98D;
}

code,
pre {
  font-family: monospace;
}

ul.bullets,
ul.tight-bullets,
ul.spaced,
ol.spaced {
	margin-bottom: 0.8rem;
}
ul.bullets,
ul.tight-bullets {
	padding-left: 1.25rem;
}
ul.bullets li,
ul.spaced li,
ol.spaced li {
	margin-bottom: 0.4rem;
}
ul.bullets li {
	list-style-type: circle;
}
ul.tight-bullets li {
    list-style-type: disc;
    margin-bottom: 0;
    word-break: break-all;
}
a.not-underlined {
    text-decoration: none;
}
.not-underlined .underlined {
    text-decoration: underline;
}

/* Page Furniture ========================================================= */
/* Header */
header.hd,
footer.ft {
    padding: 0.6rem 1rem 0.5rem 1rem;
    background-color: #276890;
    background: linear-gradient(180deg, rgba(96,144,173,1) 0%, rgba(39,104,144,1) 50%);
    color: rgba(255,255,244,0.9);
    overflow: hidden;
    box-sizing: border-box;
    min-height: 2.6rem;
}
footer.ft {
    margin-top: 1rem;
}
header.hd p,
footer.ft p {
    margin: 0;
    padding: 0;
}
footer.ft a:link,
footer.ft a:visited,
footer.ft a:hover,
footer.ft a:focus,
footer.ft a:active,
footer.ft button.button-as-link {
    color: rgba(255,255,244,0.8);
}
header.hd a:link,
header.hd a:visited,
header.hd a:hover,
header.hd a:focus,
header.hd a:active,
header.hd button.button-as-link {
    color: rgba(255,255,244,0.8);
    text-decoration: none;
}

footer.ft a:hover,
footer.ft a:focus,
footer.ft a:active,
footer.ft .button-as-link:hover,
footer.ft .button-as-link:focus,
header.hd a:hover,
header.hd a:focus,
header.hd a:active,
button.button-as-link:hover,
button.button-as-link:focus {
	color: rgba(255,255,244,1);
}


/* Body */
section.content {
    margin: 0 1rem;
}

/* Components ============================================================== */


h2 em {
    font-style: normal;
    font-weight: lighter;
}

/* Messages */

.message-info,
.message-warning,
.message-error {
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: rgba(103,201,141,0.3);
}
.message-warning {
    background-color: rgba(245,166,35,0.3);
}
.message-error {
    background-color: rgba(208,2,27,0.3);
}

.pattern-heading {
  padding: 1rem;
  margin-top: 2rem;
  border-top: 1px solid rgba(208,2,27,0.8);
  border-bottom: 1px solid rgba(208,2,27,0.8);
  background-color: rgba(208,2,27,0.2)
}

/* URL arguments */
.extra-wheres {
    margin-bottom: 1rem;
}
.extra-wheres ul,
.extra-wheres li {
    list-style-type: none;
    padding: 0;
    margin: 0;
}
.extra-wheres li + li {
    margin-top: 0.25rem;
}

.wrapped-sql {
    white-space: pre-wrap;
    margin: 1rem 0;
    font-family: monospace;
}

/* Collapsed CREATE TABLE / CREATE VIEW at the bottom of the table page */
:where(details).table-schema {
    margin: 1.5rem 0 1rem;
}
:where(details).table-schema > summary {
    cursor: pointer;
    width: fit-content;
    color: var(--muted, #6b6b6b);
    font-weight: 600;
}
:where(details).table-schema > summary:hover {
    color: var(--ink, #0f0f0f);
}
:where(details).table-schema .wrapped-sql {
    margin: 0.5rem 0 0;
    /* Room on the right for the copy button */
    padding: 0.75rem 2.75rem 0.75rem 1rem;
    background: var(--card, #fff);
    border: 1px solid var(--rule, #d8e6f5);
    border-radius: 0.4rem;
    font-size: 0.85rem;
}

/* <datasette-copy-button>, see copy-button.js. An icon button that copies
   text to the clipboard and shows a tick for a moment once it has. */
datasette-copy-button {
    flex: none;
    display: inline-flex;
    vertical-align: middle;
}
datasette-copy-button > button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    color: var(--muted, #6b6b6b);
    cursor: pointer;
    transition: opacity 0.12s, background-color 0.12s, color 0.12s;
}
datasette-copy-button > button:hover {
    background: #eef6ff;
    border-color: var(--rule, #d8e6f5);
    color: var(--accent, #1a56db);
}
datasette-copy-button > button:focus-visible {
    outline: 2px solid var(--accent, #1a56db);
    outline-offset: 1px;
}
datasette-copy-button .icon-copied,
datasette-copy-button[copied] .icon-copy {
    display: none;
}
datasette-copy-button[copied] .icon-copied {
    display: block;
}
datasette-copy-button[copied] > button {
    color: #1f7a4d;
}
/* Tells screen readers what was copied */
.datasette-copy-button-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* A block of SQL with a copy button in its top right corner */
.copyable-sql {
    position: relative;
}
.copyable-sql > datasette-copy-button {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
}
/* Opaque, since a long line of SQL can scroll underneath */
.copyable-sql > datasette-copy-button > button {
    background: #fff;
    border-color: var(--rule, #d8e6f5);
}
.copyable-sql > datasette-copy-button > button:hover {
    background: #eef6ff;
}

/* Tables ==================================================================
   Rows-and-columns tables (table, row and query pages) share the design
   language of the filter panel and modal dialogs:
   - Tokens: --ink, --paper, --muted, --rule and --accent from
     dialog.datasette-modal and .filters, plus Datasette's link colours and
     the column menu's slate.
   - The filter panel's 8px radius and 1px --rule border for the card.
   - The modal header band: --paper background separated by a --rule line.

   Layout:
   - The table sizes to its content (max-content) and scrolls sideways inside
     the card instead of squeezing columns, so wrappable text such as a JSON
     array does not collapse into a tall narrow strip.
   - Every cell is capped at a readable measure and long unbroken values
     (URLs, hashes) wrap inside it.
   - Numbers are right aligned with tabular figures; headers of numeric
     columns follow them, and numeric cells reserve the gear's width so the
     label still ends exactly where the digits end.
   - Soft edge shadows appear only when there is more table to scroll to.
   - table-layout.js clamps long values to a short preview and adds the
     freeze pin (see "Long values" and "Freeze" below).

   Below 577px the rows become stacked cards: see the max-width: 576px block
   under Overrides. */
:where(div).table-wrapper {
    overflow-x: auto;
}
:where(div).table-wrapper,
table.rows-and-columns {
    --ink: #0f0f0f;
    --paper: #eef6ff;
    --muted: #6b6b6b;
    --rule: #d8e6f5;
    --accent: #1a56db;
    --card: #ffffff;
    --slate: #536978;
    --link: #276890;
    --link-visited: #2d7a62;
    /* #f3f8ff over white, but translucent so the scroll-edge shadows
       still show through on the hovered row. */
    --row-hover: rgba(0, 110, 255, 0.047);
    --cell-measure: 30rem;
    --shadow: rgba(30, 64, 110, 0.12);
}
table.rows-and-columns {
    border-collapse: collapse;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
table.rows-and-columns td {
    vertical-align: top;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
/* Primary key: the row's identity. */
table.rows-and-columns td.type-pk {
    font-weight: 600;
}
/* Foreign key ids and similar asides. */
table.rows-and-columns td em {
    color: var(--muted);
    font-size: 0.8125em;
    font-style: normal;
}
/* The link for a row with an empty string primary key - a link like any
   other, in italics to show that "empty" is not the value. */
table.rows-and-columns td em.row-link-empty {
    color: inherit;
    font-size: inherit;
    font-style: italic;
}
/* Links keep Datasette's colour and its no-underline table style, with an
   underline on hover. Visited is darkened from #54AC8E to pass AA. */
table.rows-and-columns td a:link {
    color: var(--link);
    text-decoration: none;
}
table.rows-and-columns td a:visited {
    color: var(--link-visited);
    text-decoration: none;
}
.rows-and-columns td ol,
.rows-and-columns td ul {
    list-style: initial;
    list-style-position: inside;
}

@media (min-width: 577px) {
    :where(div).table-wrapper:has(> table.rows-and-columns) {
        box-sizing: border-box;
        width: fit-content;
        max-width: 100%;
        margin: 0 0 1rem;
        overscroll-behavior-inline: contain;
        border: 1px solid var(--rule);
        border-radius: 8px;
        /* Scroll shadows: the two white covers travel with the content
           (local), the two shadows stay pinned to the edges (scroll), so a
           shadow only shows on a side that has more table to reveal. */
        background:
            linear-gradient(to right, var(--card) 30%, rgba(255, 255, 255, 0)) left center / 48px 100% no-repeat local,
            linear-gradient(to left, var(--card) 30%, rgba(255, 255, 255, 0)) right center / 48px 100% no-repeat local,
            linear-gradient(to right, var(--shadow), rgba(30, 64, 110, 0)) left center / 14px 100% no-repeat scroll,
            linear-gradient(to left, var(--shadow), rgba(30, 64, 110, 0)) right center / 14px 100% no-repeat scroll,
            var(--card);
        box-shadow: 0 1px 2px rgba(15, 40, 70, 0.04);
    }

    :where(div).table-wrapper:has(> table.rows-and-columns):focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    table.rows-and-columns {
        width: max-content;
        min-width: 100%;
        font-size: 0.875rem;
        line-height: 1.45;
    }

    /* Header band */

    table.rows-and-columns th {
        padding: 0.45rem 0.5rem 0.45rem 0.75rem;
        border-bottom: 1px solid var(--rule);
        background: rgba(238, 246, 255, 0.88);
        color: var(--ink);
        font-size: 0.8125rem;
        font-weight: 600;
        line-height: 1.3;
        text-align: left;
        vertical-align: middle;
        white-space: nowrap;
    }

    /* The narrower right padding leaves room for the column menu's gear,
       which only table pages have. */
    table.rows-and-columns th:last-child,
    body:not(.table) table.rows-and-columns th {
        padding-right: 0.75rem;
    }

    table.rows-and-columns th a:is(:link, :visited) {
        color: inherit;
        text-decoration: none;
        border-radius: 3px;
    }

    table.rows-and-columns th a:hover {
        color: var(--accent);
        text-decoration: underline;
        text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
        text-underline-offset: 3px;
    }

    table.rows-and-columns th a:focus-visible {
        color: var(--accent);
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    table.rows-and-columns th button.column-menu-trigger {
        width: 22px;
        min-height: 22px;
        margin: -3px 0 -3px 3px;
        color: var(--slate);
        border-radius: 5px;
    }

    table.rows-and-columns th button.column-menu-trigger svg {
        width: 15px;
        height: 15px;
        opacity: 1;
    }

    table.rows-and-columns th button.column-menu-trigger:hover,
    table.rows-and-columns th button.column-menu-trigger[aria-expanded="true"] {
        background: var(--rule);
        color: var(--ink);
    }

    /* Body cells */

    table.rows-and-columns td {
        max-width: var(--cell-measure);
        padding: 0.5rem 0.75rem;
        border: 0;
        border-top: 1px solid var(--rule);
    }

    table.rows-and-columns tbody tr:first-child td {
        border-top: 0;
    }

    table.rows-and-columns tbody tr:hover td {
        background: var(--row-hover);
    }

    /* Numbers: right aligned on tabular figures. Foreign key cells are
       type-int too but show a label link, so they stay left aligned. */
    table.rows-and-columns td:is(.type-int, .type-float):not(:has(a)) {
        text-align: right;
    }

    /* On table pages the extra right padding reserves the header gear's
       width (header padding + the word space before the gear + gear margin
       and width), so a numeric header label ends exactly where digits end. */
    body.table table.rows-and-columns td:is(.type-int, .type-float):not(:has(a)) {
        --gear-space: calc(0.5rem + 0.28 * 0.8125rem + 25px);
        padding-right: var(--gear-space);
    }

    /* The last header cell has wider right padding; match it. */
    body.table table.rows-and-columns td:is(.type-int, .type-float):not(:has(a)):last-child {
        padding-right: calc(var(--gear-space) + 0.25rem);
    }

    /* Numeric headers follow their digits. Primary keys stay left aligned,
       as do foreign key columns showing labels: the server sets
       data-has-fks when a column's cells on this page link to other rows. */
    table.rows-and-columns th:is(
        [data-column-type*="int"],
        [data-column-type*="real"],
        [data-column-type*="floa"],
        [data-column-type*="doub"],
        [data-column-type*="dec"],
        [data-column-type="numeric"]
    ):not([data-is-pk="1"], [data-has-fks="1"]) {
        text-align: right;
    }

    table.rows-and-columns td a:hover {
        text-decoration: underline;
        text-decoration-thickness: 1px;
        text-underline-offset: 2px;
    }

    table.rows-and-columns td a:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 1px;
        border-radius: 2px;
    }
}

/* Long values (all widths)
   table-layout.js wraps any cell whose value would run past the preview in
   .long-value > .long-value-text + button.long-value-toggle. Collapsed, the
   value is a preview of --long-value-lines lines (3) with line breaks folded
   into spaces (a README's blank lines would otherwise use up the preview),
   its last line fading out under a small "expand" pill, so the row stays a
   predictable height. Values that fit the preview once folded keep their
   line breaks instead (.keeps-breaks). Expanded, the value shows in full
   with its original line breaks, and the pill floats to its top right as
   "collapse", on the line the reader clicked from. */

/* Registered so that --long-value-line: 1lh resolves on .long-value (the
   text's line height) and is inherited as that length. Unregistered, it
   would be re-resolved against the pill's own, smaller line height. */
@property --long-value-line {
    syntax: "<length>";
    inherits: true;
    initial-value: 0px;
}

table.rows-and-columns {
    --long-value-lines: 3; /* table-layout.js reads this too */
}

table.rows-and-columns .long-value {
    --long-value-line: 1lh;
    --long-value-pill-height: 1.25rem;
    --long-value-fade-clear: 5.5rem; /* the pill's width plus a gap; text fades out over the next 4rem */
    position: relative;
    display: flow-root; /* contains the floated "collapse" pill */
}

table.rows-and-columns .long-value-text {
    white-space: pre-wrap;
}

table.rows-and-columns .long-value:not(.is-expanded) > .long-value-text {
    max-height: calc(var(--long-value-lines) * 1lh);
    overflow: hidden;
    white-space: normal;
    /* Room for focus rings on links at either end of a line. */
    padding-inline: 3px;
    margin-inline: -3px;
    /* Fully visible except the end of the last line, which fades out
       behind the pill. */
    -webkit-mask:
        linear-gradient(#000 0 0) left top / 100% calc(100% - 1lh) no-repeat,
        linear-gradient(to left, transparent var(--long-value-fade-clear), #000 calc(var(--long-value-fade-clear) + 4rem)) left bottom / 100% 1lh no-repeat;
    mask:
        linear-gradient(#000 0 0) left top / 100% calc(100% - 1lh) no-repeat,
        linear-gradient(to left, transparent var(--long-value-fade-clear), #000 calc(var(--long-value-fade-clear) + 4rem)) left bottom / 100% 1lh no-repeat;
}

table.rows-and-columns .long-value.keeps-breaks:not(.is-expanded) > .long-value-text {
    white-space: pre-wrap;
}

table.rows-and-columns .long-value-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    height: var(--long-value-pill-height);
    padding: 0 0.4rem 0 0.5rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--paper);
    color: var(--accent);
    font: 600 0.75rem/1 system-ui, -apple-system, sans-serif;
    white-space: nowrap;
    cursor: pointer;
    /* Keep "expand" / "collapse" out of copied text. */
    -webkit-user-select: none;
    user-select: none;
}

/* Collapsed: centred on the preview's last line, over the fade. */
table.rows-and-columns .long-value:not(.is-expanded) > .long-value-toggle {
    position: absolute;
    right: 0;
    bottom: calc((var(--long-value-line) - var(--long-value-pill-height)) / 2);
}

/* Expanded: floated to the top right, centred on the first line. */
table.rows-and-columns .long-value.is-expanded > .long-value-toggle {
    float: right;
    margin: calc((var(--long-value-line) - var(--long-value-pill-height)) / 2) 0 0.25rem 0.75rem;
}

table.rows-and-columns .long-value-toggle svg {
    transition: transform 0.15s;
}

table.rows-and-columns .long-value.is-expanded > .long-value-toggle svg {
    transform: rotate(180deg);
}

table.rows-and-columns .long-value-toggle:hover {
    border-color: #bfccd9;
    background: var(--rule);
}

table.rows-and-columns .long-value-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
    table.rows-and-columns .long-value-toggle svg {
        transition: none;
    }
}

/* A larger touch target on the stacked mobile cards. */
@media (max-width: 576px) {
    table.rows-and-columns .long-value {
        --long-value-pill-height: 1.75rem;
        --long-value-fade-clear: 6.5rem;
    }

    table.rows-and-columns .long-value-toggle {
        padding: 0 0.6rem 0 0.75rem;
        font-size: 0.8125rem;
    }
}

/* Freeze
   table-layout.js adds button.freeze-toggle (a pin) to the primary key
   header, or to the first header when there is no key column (query
   results, views). Pressed, it sets data-freeze="N" on the table (N = how
   many leading Link and key columns to freeze, up to 4; 0 freezes only the
   header row),
   --freeze-left-2..4 on the table and --freeze-width / --freeze-top on the
   wrapper. The card then becomes a scroll box the height of the window, with
   the header row stuck to its top and the key columns stuck to its left.
   Shadows appear on the frozen edges only once content has scrolled under
   them (.is-scrolled-x/y). Not applied to the stacked mobile cards. */
@media (min-width: 577px) {
    /* The pin matches the gear. */
    table.rows-and-columns th .freeze-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 22px;
        min-height: 22px;
        margin: -3px 0 -3px 2px;
        padding: 0;
        vertical-align: middle;
        border: 0;
        border-radius: 5px;
        background: transparent;
        color: var(--slate);
        cursor: pointer;
    }

    table.rows-and-columns th .freeze-toggle svg {
        display: block;
        transform: rotate(45deg);
        transition: transform 0.15s ease;
    }

    table.rows-and-columns th .freeze-toggle:hover {
        background: var(--rule);
        color: var(--ink);
    }

    table.rows-and-columns th :is(.freeze-toggle, .column-expand-toggle):focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 1px;
    }

    /* Expand-all: the same pill as the cells' "expand", reading "expand all"
       or "collapse all", so it is clearly part of that feature rather than a
       sort control. White, to stand out on the header band. */
    table.rows-and-columns th .column-expand-toggle {
        display: inline-flex;
        align-items: center;
        gap: 0.2rem;
        height: 1.25rem;
        margin: -2px 0 -2px 6px;
        padding: 0 0.4rem 0 0.5rem;
        vertical-align: middle;
        border: 1px solid var(--rule);
        border-radius: 999px;
        background: var(--card);
        color: var(--accent);
        font: 600 0.75rem/1 system-ui, -apple-system, sans-serif;
        white-space: nowrap;
        cursor: pointer;
        -webkit-user-select: none;
        user-select: none;
    }

    table.rows-and-columns th .column-expand-toggle svg {
        display: block;
        transition: transform 0.15s;
    }

    table.rows-and-columns th .column-expand-toggle[data-state="all"] svg {
        transform: rotate(180deg);
    }

    table.rows-and-columns th .column-expand-toggle:hover {
        border-color: #bfccd9;
        background: var(--rule);
    }

    /* Pinned: upright, filled, in the accent colour on the accent tint used
       by Datasette's selected menu items. */
    table.rows-and-columns th .freeze-toggle[aria-pressed="true"] {
        background: #e8effd;
        color: var(--accent);
    }

    table.rows-and-columns th .freeze-toggle[aria-pressed="true"] svg {
        transform: none;
    }

    table.rows-and-columns th .freeze-toggle[aria-pressed="true"] .freeze-toggle-head {
        fill: currentColor;
    }

    /* The card becomes the scroll box. */
    :where(div).table-wrapper:has(> table.rows-and-columns[data-freeze]) {
        max-height: calc(100dvh - 1rem);
        overflow: auto;
        overscroll-behavior: contain;
        /* Keyboard focus scrolls cells clear of the frozen parts. */
        scroll-padding: var(--freeze-top, 0px) 0 0 var(--freeze-width, 0px);
    }

    /* Collapsed borders stay behind when cells stick; separate ones travel
       with them. The table only uses top/bottom rules, so it looks the same
       either way. */
    table.rows-and-columns[data-freeze] {
        border-collapse: separate;
        border-spacing: 0;
    }

    table.rows-and-columns[data-freeze] thead tr {
        --freeze-cell-bg: #f0f7ff; /* the header band, made opaque */
        --freeze-z: 3;
    }

    table.rows-and-columns[data-freeze] tbody tr {
        --freeze-cell-bg: var(--card);
        --freeze-z: 1;
    }

    table.rows-and-columns[data-freeze] tbody tr:hover {
        --freeze-cell-bg: #f3f8ff; /* --row-hover over white, made opaque */
    }

    table.rows-and-columns[data-freeze] thead th {
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--freeze-cell-bg);
    }

    table.rows-and-columns:is([data-freeze="1"], [data-freeze="2"], [data-freeze="3"], [data-freeze="4"]) :is(th, td):nth-child(1),
    table.rows-and-columns:is([data-freeze="2"], [data-freeze="3"], [data-freeze="4"]) :is(th, td):nth-child(2),
    table.rows-and-columns:is([data-freeze="3"], [data-freeze="4"]) :is(th, td):nth-child(3),
    table.rows-and-columns[data-freeze="4"] :is(th, td):nth-child(4) {
        position: sticky;
        left: 0;
        z-index: var(--freeze-z);
        background: var(--freeze-cell-bg);
    }

    table.rows-and-columns[data-freeze] :is(th, td):nth-child(2) {
        left: var(--freeze-left-2, 0px);
    }

    table.rows-and-columns[data-freeze] :is(th, td):nth-child(3) {
        left: var(--freeze-left-3, 0px);
    }

    table.rows-and-columns[data-freeze] :is(th, td):nth-child(4) {
        left: var(--freeze-left-4, 0px);
    }

    /* A hairline on the frozen edge. */
    table.rows-and-columns[data-freeze="1"] :is(th, td):nth-child(1),
    table.rows-and-columns[data-freeze="2"] :is(th, td):nth-child(2),
    table.rows-and-columns[data-freeze="3"] :is(th, td):nth-child(3),
    table.rows-and-columns[data-freeze="4"] :is(th, td):nth-child(4) {
        box-shadow: inset -1px 0 0 var(--rule);
    }

    /* Soft shadows once content has scrolled under a frozen edge. They are
       gradients on pseudo-elements, not box-shadows, so they run unbroken
       across cell boundaries. Sticky cells contain them. */
    :where(div).table-wrapper.is-scrolled-x > table.rows-and-columns[data-freeze="1"] :is(th, td):nth-child(1)::before,
    :where(div).table-wrapper.is-scrolled-x > table.rows-and-columns[data-freeze="2"] :is(th, td):nth-child(2)::before,
    :where(div).table-wrapper.is-scrolled-x > table.rows-and-columns[data-freeze="3"] :is(th, td):nth-child(3)::before,
    :where(div).table-wrapper.is-scrolled-x > table.rows-and-columns[data-freeze="4"] :is(th, td):nth-child(4)::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: 100%;
        width: 8px;
        background: linear-gradient(to right, rgba(30, 64, 110, 0.13), rgba(30, 64, 110, 0));
        pointer-events: none;
    }

    :where(div).table-wrapper.is-scrolled-y > table.rows-and-columns[data-freeze] thead th::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        height: 8px;
        background: linear-gradient(rgba(30, 64, 110, 0.13), rgba(30, 64, 110, 0));
        pointer-events: none;
    }
}

@media (min-width: 577px) and (prefers-reduced-motion: reduce) {
    table.rows-and-columns th :is(.freeze-toggle, .column-expand-toggle) svg {
        transition: none;
    }
}

@media (max-width: 576px) {
    table.rows-and-columns th :is(.freeze-toggle, .column-expand-toggle) {
        display: none;
    }
}
a.blob-download {
    display: inline-block;
}
:where(div).db-table p {
    margin-top: 0;
    margin-bottom: 0.3em;
}
:where(div).db-table h2 {
    margin-top: 1em;
    margin-bottom: 0;
}

/* Forms =================================================================== */

form.sql textarea {
    border: 1px solid #ccc;
    width: 70%;
    height: 3em;
    padding: 4px;
    font-family: monospace;
    font-size: 1.3em;
}
form.sql label {
    width: 15%;
}
label.sort_by_desc {
    padding-right: 1em;
}
pre#sql-query {
    margin-bottom: 1em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.core label,
label.core {
    font-weight: bold;
    display: inline-block;
}

.core input[type=text],
input.core[type=text],
.core input[type=search],
input.core[type=search] {
    border: 1px solid #ccc;
    border-radius: 3px;
    width: 60%;
    padding: 9px 4px;
    display: inline-block;
    font-size: 1em;
    font-family: Helvetica, sans-serif;
}
.core input[type=search],
input.core[type=search] {
    /* Stop Webkit from styling search boxes in an inconsistent way */
    /* https://css-tricks.com/webkit-html5-search-inputs/ comments */
    -webkit-appearance: textfield;
}
.core input[type="search"]::-webkit-search-decoration,
input.core[type="search"]::-webkit-search-decoration,
.core input[type="search"]::-webkit-search-cancel-button,
input.core[type="search"]::-webkit-search-cancel-button,
.core input[type="search"]::-webkit-search-results-button,
input.core[type="search"]::-webkit-search-results-button,
.core input[type="search"]::-webkit-search-results-decoration,
input.core[type="search"]::-webkit-search-results-decoration {
    display: none;
}

.core input[type=submit],
.core button[type=button],
input.core[type=submit],
button.core[type=button] {
    font-weight: 400;
    cursor: pointer;
    text-align: center;
    vertical-align: middle;
    border-width: 1px;
    border-style: solid;
    padding: .5em 0.8em;
    font-size: 0.9rem;
    line-height: 1;
    border-radius: .25rem;
}

.core input[type=submit],
input.core[type=submit] {
    color: #fff;
    background: linear-gradient(180deg, #007bff 0%, #4E79C7 100%);
    border-color: #007bff;
    -webkit-appearance: button;
}

.core button[type=button],
button.core[type=button] {
    color: #007bff;
    background-color: #fff;
    border-color: #007bff;
}

.search-row {
    margin-bottom: 1.8em;
}

.search-row label {
    font-size: 1.2em;
    padding-right: 0.5em;
    display: inline-block;
    width: 80px;
}

.filters .search-row {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: max-content minmax(16rem, 1fr);
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 0.45rem;
    padding-right: var(--filter-two-icon-space);
}

.filters .search-row label {
    width: auto;
    padding: 0;
    color: var(--filter-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.filters {
    --filter-ink: #0f0f0f;
    --filter-paper: #eef6ff;
    --filter-muted: #6b6b6b;
    --filter-rule: #d8e6f5;
    --filter-accent: #1a56db;
    --filter-control-border: #bfccd9;
    --filter-control-height: 2.125rem;
    --filter-control-gap: 0.4rem;
    --filter-row-icon-size: 2rem;
    --filter-two-icon-space: calc(
        (2 * var(--filter-row-icon-size)) + (2 * var(--filter-control-gap))
    );
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.55rem;
    max-width: 760px;
    margin: 0 0 1rem;
    padding: 0.75rem;
    border: 1px solid var(--filter-rule);
    border-radius: 8px;
    background: var(--filter-paper);
    color: var(--filter-ink);
    font-size: 0.875rem;
}

.filters .filter-row {
    margin-bottom: 0;
}

.filters .filter-controls-row {
    display: grid;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    grid-template-columns:
        minmax(8rem, 0.75fr)
        minmax(6.5rem, 0.5fr)
        minmax(12rem, 1.2fr)
        var(--filter-row-icon-size)
        var(--filter-row-icon-size);
    gap: var(--filter-control-gap);
    align-items: center;
}

.filters .filter-actions-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.select-wrapper {
    display: inline-block;
    width: 120px;
    min-width: 0;
}

.select-wrapper.filter-op {
    width: 80px;
}

.filters .select-wrapper {
    width: auto;
}

.select-wrapper select {
    box-sizing: border-box;
    width: 100%;
    height: var(--filter-control-height);
    border: 1px solid var(--filter-control-border, #ccc);
    border-radius: 5px;
    /* Browsers draw different arrows and text insets for a native select,
       so turn that off and draw our own chevron */
    appearance: none;
    background: #fff url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23444' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 10px center / 10px 6px;
    color: inherit;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.25;
    padding: 7px 28px 7px 9px;
}

.select-wrapper option {
    font-size: 1em;
    font-family: Helvetica, sans-serif;
}

.select-wrapper select:focus {
    border-color: var(--filter-accent, #000);
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.14);
    outline: none;
}
.filters input.filter-value {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: var(--filter-control-height);
    border: 1px solid var(--filter-control-border);
    border-radius: 5px;
    background: #fff;
    color: inherit;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.25;
    padding: 7px 9px;
}

.filters input.filter-value:focus {
    border-color: var(--filter-accent);
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.14);
    outline: none;
}

/* Many-to-many filter rows: the value searches the related table, see
   initM2MFilterRows() in table.js. Otherwise they look like other rows. */
.filters datasette-autocomplete.filter-value-autocomplete {
    min-width: 0;
    max-width: none;
}

.filters datasette-autocomplete.filter-value-autocomplete input.filter-value {
    max-width: none;
}

.filters .filter-value-error {
    grid-column: 1 / -1;
    margin: 0;
    color: #a3262a;
    font-size: 0.85rem;
}

.filters input.filter-value[aria-invalid="true"] {
    border-color: #a3262a;
}

.filters input[type=submit] {
    border-color: var(--filter-accent);
    background: var(--filter-accent);
    border-radius: 5px;
    font-weight: 500;
    padding: 0.55rem 0.85rem;
}

.filters input[type=submit]:hover,
.filters input[type=submit]:focus {
    background: #1949b8;
    border-color: #1949b8;
}

/* Secondary action: same treatment as the filter row remove buttons */
.filters a.filters-clear {
    display: inline-block;
    border: 1px solid var(--filter-rule);
    border-radius: 5px;
    background: #fff;
    color: var(--filter-muted);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1;
    padding: 0.55rem 0.85rem;
    text-decoration: none;
}

.filters a.filters-clear:hover,
.filters a.filters-clear:focus {
    border-color: #c9d5e3;
    background: #f8fbff;
    color: var(--filter-ink);
}

.filters a.filters-clear:focus-visible {
    outline: 3px solid rgba(26, 86, 219, 0.14);
    outline-offset: 2px;
}

.filters button.filter-row-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: var(--filter-row-icon-size);
    height: var(--filter-row-icon-size);
    min-width: var(--filter-row-icon-size);
    padding: 0;
    border: 1px solid var(--filter-rule);
    border-radius: 5px;
    background: #fff;
    color: var(--filter-muted);
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1;
}

.filters button.filter-row-icon[hidden] {
    display: none;
}

.filters button.filter-row-icon:focus-visible {
    outline: 3px solid rgba(26, 86, 219, 0.14);
    outline-offset: 2px;
}

.filters .filter-row-remove-icon {
    display: block;
    height: 14px;
    width: 14px;
}

.filters button.filter-row-remove:hover,
.filters button.filter-row-remove:focus {
    border-color: #c9d5e3;
    background: #f8fbff;
    color: var(--filter-ink);
}

.filters button.filter-row-add {
    border-color: var(--filter-accent);
    background: var(--filter-accent);
    color: #fff;
}

.filters .filter-row-add-icon {
    display: block;
    height: 16px;
    width: 16px;
}

.filters button.filter-row-add:hover,
.filters button.filter-row-add:focus {
    border-color: #1949b8;
    background: #1949b8;
    color: #fff;
}

.filters button.filter-row-add:focus-visible svg {
    color: #fff;
    stroke: currentColor;
}

#_search {
    font-size: 16px;
}

.filters #_search {
    box-sizing: border-box;
    width: 100%;
    height: var(--filter-control-height);
    border: 1px solid var(--filter-control-border);
    border-radius: 5px;
    background: #fff;
    color: var(--filter-ink);
    font: inherit;
    padding: 7px 9px;
}

.filters #_search:focus {
    border-color: var(--filter-accent);
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.14);
    outline: none;
}




/* Facet results: one card per facet, using the same colors, borders and
   radius as the filter box and the suggested facet chips. */
.facet-results {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem;
    margin: 0 0 1rem;
}
.facet-info {
    box-sizing: border-box;
    width: 250px;
    max-width: 100%;
    padding: 0.3rem;
    border: 1px solid #d8e6f5;
    border-radius: 8px;
    background: #fff;
    font-size: 0.875rem;
}
.facet-info p.facet-info-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 1.75rem;
    margin: 0 0 0.1rem;
    padding: 0.1rem 0.1rem 0.1rem 0.45rem;
}
.facet-info-name strong {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.facet-info-type {
    padding: 1px 5px;
    border-radius: 3px;
    background: #eef6ff;
    color: #6b6b6b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.7rem;
    font-weight: 400;
    white-space: nowrap;
}
.facet-info-total {
    margin-left: 0.15rem;
    color: #6b6b6b;
    font-size: 0.75rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.facet-info a.cross:link,
.facet-info a.cross:visited,
.facet-info a.cross:hover,
.facet-info a.cross:focus,
.facet-info a.cross:active {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border-radius: 5px;
    color: #6b6b6b;
    text-decoration: none;
}
.facet-info a.cross svg {
    display: block;
}
.facet-info-name a.cross:link,
.facet-info-name a.cross:visited {
    width: 1.5rem;
    height: 1.5rem;
    color: #8a8a8a;
}
.facet-info-name a.cross:hover,
.facet-info-name a.cross:focus-visible {
    background: #eef6ff;
    color: #0f0f0f;
}
.facet-info a.cross:focus-visible {
    outline: 2px solid #1a56db;
    outline-offset: 1px;
}
.facet-results .facet-info ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
/* Long labels wrap but the count stays on one line -
   https://github.com/simonw/datasette/issues/2754 */
.facet-results .facet-info li {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin: 0;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    list-style: none;
    line-height: 1.35;
    word-break: normal;
    /* Proportion bar: this value's share of the rows in the current result
       set, from the --facet-proportion set on the li by the template */
    background-image: linear-gradient(
        to right,
        rgba(26, 86, 219, 0.1) var(--facet-proportion, 0%),
        transparent var(--facet-proportion, 0%)
    );
}
/* The value link stretches to cover the whole row, count included */
.facet-results .facet-info li > a:first-child {
    flex: 1;
    min-width: 0;
    color: #1a56db;
    text-decoration: none;
    overflow-wrap: anywhere;
}
.facet-results .facet-info li > a:first-child::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 4px;
}
.facet-results .facet-info li > a:first-child:focus-visible {
    outline: none;
}
.facet-results .facet-info li > a:first-child:focus-visible::after {
    outline: 2px solid #1a56db;
    outline-offset: -1px;
}
.facet-results .facet-info li:has(> a:first-child):hover {
    background-color: #f3f7fe;
}
.facet-results .facet-info li:has(> a:first-child):hover > a:first-child {
    color: #1949b8;
}
.facet-count {
    flex: none;
    margin-left: auto;
    color: #6b6b6b;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.facet-results .facet-info li.facet-selected {
    align-items: center;
    background-color: #e8effd;
    color: #1949b8;
    font-weight: 600;
}
.facet-value-label {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}
.facet-selected .facet-count {
    font-weight: 400;
}
.facet-selected a.cross:link,
.facet-selected a.cross:visited {
    width: 1.25rem;
    height: 1.25rem;
    margin: -0.1rem -0.25rem -0.1rem -0.35rem;
    color: #1a56db;
}
.facet-selected a.cross:hover,
.facet-selected a.cross:focus-visible {
    background: #fff;
    color: #1949b8;
}
.facet-results .facet-info li.facet-truncated {
    color: #6b6b6b;
}
.facet-results .facet-info li.facet-truncated > a:first-child {
    color: #6b6b6b;
}
@media (pointer: coarse) {
    .facet-results .facet-info li {
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }
}
@media only screen and (max-width: 576px) {
    .facet-info {
        width: 100%;
    }
}

/* Suggested facets: a row of "add facet" chips that reuse the colors
   and radius of the filter controls above them. */
.suggested-facets {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.4rem 0.6rem;
    max-width: 760px;
    margin: 0 0 1rem;
    font-size: 0.875rem;
}

.suggested-facets-label {
    flex: none;
    color: #6b6b6b;
    font-weight: 600;
    line-height: 1.75rem;
}

.suggested-facets-list {
    display: flex;
    flex: 1 1 16rem;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.suggested-facets-list li {
    display: flex;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.suggested-facets a.suggested-facet {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    box-sizing: border-box;
    max-width: 100%;
    min-height: 1.75rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid #d8e6f5;
    border-radius: 5px;
    background: #fff;
    color: #1a56db;
    line-height: 1.2;
    text-decoration: none;
    transition: background 0.12s, border-color 0.12s;
}

.suggested-facets a.suggested-facet:hover {
    border-color: #1a56db;
    background: #e8effd;
    color: #1949b8;
}

.suggested-facets a.suggested-facet:focus-visible {
    border-color: #1a56db;
    background: #e8effd;
    color: #1949b8;
    outline: 2px solid #1a56db;
    outline-offset: 2px;
}

.suggested-facet-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggested-facet-type {
    flex-shrink: 0;
    padding: 1px 5px;
    border-radius: 3px;
    background: #eef6ff;
    color: #6b6b6b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.7rem;
}

@media (pointer: coarse) {
    .suggested-facets-label {
        line-height: 2.25rem;
    }
    .suggested-facets a.suggested-facet {
        min-height: 2.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .suggested-facets a.suggested-facet {
        transition: none;
    }
}

/* Quiet buttons: low-key secondary actions such as "Export data" and
   "View and edit SQL", in the suggested facet chips' colours. Works on
   both <button> and <a>. */
:where(div).table-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 1rem;
}

.quiet-button,
a.quiet-button:link,
a.quiet-button:visited {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    box-sizing: border-box;
    min-height: 1.75rem;
    margin: 0;
    padding: 0.2rem 0.6rem;
    border: 1px solid #d8e6f5;
    border-radius: 5px;
    background: #fff;
    color: #24465d;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.quiet-button svg {
    display: block;
    flex-shrink: 0;
    color: #6b6b6b;
    transition: color 0.12s;
}

/* "Columns": highlighted when a custom set of columns is shown */
.columns-button-count {
    font-variant-numeric: tabular-nums;
}
.columns-button-count::before {
    content: "·";
    margin-right: 0.35rem;
    color: #8a9bb0;
}
.columns-button-source {
    padding: 0 0.35rem;
    border-radius: 999px;
    background: #dbe7fb;
    color: #1949b8;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.5;
}
.quiet-button.columns-button.is-custom {
    border-color: #9cbcef;
    background: #f1f6fe;
    color: #1949b8;
}
.quiet-button.columns-button.is-custom svg {
    color: #1949b8;
}

.quiet-button:hover,
a.quiet-button:hover,
.quiet-button:focus-visible {
    border-color: #1a56db;
    background: #e8effd;
    color: #1949b8;
}

.quiet-button:hover svg,
.quiet-button:focus-visible svg {
    color: currentColor;
}

.quiet-button:focus-visible {
    outline: 2px solid #1a56db;
    outline-offset: 2px;
}

@media (pointer: coarse) {
    .quiet-button,
    a.quiet-button:link,
    a.quiet-button:visited {
        min-height: 2.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .quiet-button,
    .quiet-button svg {
        transition: none;
    }
}

/* Export dialog, opened by the "Export data" quiet button. One row per
   format: its name and description, then a group of Copy / View /
   Download / Copy URL actions that wraps below the name on narrow screens. */
dialog.export-dialog {
    width: min(660px, calc(100vw - 32px));
}

.export-dialog .modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

/* The body scrolls instead: without this the clamped scope box, which hides
   its overflow, would be squashed when the list is taller than the dialog */
.export-dialog .modal-body > * {
    flex-shrink: 0;
}

/* Which rows the export covers, e.g. "Filtered rows where state = "CA"" */
.export-dialog .export-scope {
    margin: 0;
    padding: 10px 12px;
    border-radius: 6px;
    background: var(--paper);
    color: var(--ink);
    font-size: 0.875rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
    /* Long filters or query parameters: the full text is in the title */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

/* Past the first page: the exports start from this page's rows */
.export-dialog .export-page-note {
    margin: 0;
    padding: 8px 12px;
    border-radius: 6px;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.85rem;
    line-height: 1.4;
}

.export-dialog .export-option-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.5rem;
}

/* How many rows each format returns: amber when it is not every row */
.export-dialog .export-rows {
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--paper);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.export-dialog .export-rows[data-partial="true"] {
    background: #fef3c7;
    color: #92400e;
}

/* Two boxes: TSV and CSV with the options they share, then the rest */
.export-dialog .export-options {
    margin: 0;
    padding: 0;
    border: 1px solid var(--rule);
    border-radius: 8px;
}

/* Keeps the options strip inside the rounded corners */
.export-dialog .export-option-group {
    overflow: hidden;
}

.export-dialog .export-options > li + li,
.export-dialog .export-option + .export-option {
    border-top: 1px solid var(--rule);
}

.export-dialog .export-option {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.6rem 0.75rem;
}

.export-dialog .export-option-text {
    display: flex;
    flex: 1 1 12rem;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.export-dialog .export-option-name {
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 600;
}

.export-dialog .export-option-description {
    color: var(--muted);
    font-size: 0.8rem;
}

.export-dialog .export-actions {
    display: inline-flex;
    flex-shrink: 0;
    border: 1px solid var(--rule);
    border-radius: 6px;
    background: var(--card);
    overflow: hidden;
}

.export-dialog .export-action {
    display: inline-grid;
    place-items: center;
    box-sizing: border-box;
    min-height: 1.75rem;
    margin: 0;
    padding: 0.2rem 0.6rem;
    border: 0;
    border-radius: 0;
    background: none;
    color: var(--accent);
    font: 500 0.8rem/1.2 system-ui, -apple-system, sans-serif;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.export-dialog .export-action[hidden] {
    display: none;
}

/* Dividers between the visible actions: Copy, first, can be hidden */
.export-dialog .export-action:not([hidden]) ~ .export-action:not([hidden]) {
    border-left: 1px solid var(--rule);
}

/* Too narrow for four actions in a row (a 320px phone, or large text): two
   by two instead, with the gaps showing through as the dividers */
.export-dialog .export-options {
    container: export-options / inline-size;
}

@container export-options (max-width: 18rem) {
    .export-dialog .export-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1px;
        background: var(--rule);
    }
    .export-dialog .export-action {
        background: var(--card);
        padding-inline: 0.3rem;
    }
    .export-dialog .export-action:not([hidden]) ~ .export-action:not([hidden]) {
        border-left: 0;
    }
}

.export-dialog .export-action:hover,
.export-dialog .export-action:focus-visible {
    background: var(--paper);
    color: #1949b8;
}

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

/* State labels added by export-dialog.js share one grid cell, so a
   button keeps its width as "Copy" becomes "Copying…" and "Copied". */
.export-dialog .export-action-label {
    grid-area: 1 / 1;
    visibility: hidden;
}

.export-dialog .export-action[data-state="idle"] > [data-state="idle"],
.export-dialog .export-action[data-state="busy"] > [data-state="busy"],
.export-dialog .export-action[data-state="done"] > [data-state="done"],
.export-dialog .export-action[data-state="error"] > [data-state="error"] {
    visibility: visible;
}

.export-dialog .export-action[data-state="busy"] {
    color: var(--muted);
    cursor: progress;
}

.export-dialog .export-action[data-state="done"] {
    color: #1a7f37;
}

.export-dialog .export-action[data-state="error"] {
    color: #b91c1c;
}

/* Why an action failed: stays until that action is tried again */
.export-dialog .export-option-error {
    flex: 1 0 100%;
    margin: 0;
    color: #b91c1c;
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}

/* Expand labels and Include all rows, under TSV and CSV: they apply to both */
.export-dialog .export-csv-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.1rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--rule);
    background: var(--paper);
}

.export-dialog .export-csv-options label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--ink);
    font-size: 0.85rem;
    cursor: pointer;
}

.export-dialog .export-csv-options[hidden],
.export-dialog .export-csv-options label[hidden] {
    display: none;
}

.export-dialog .export-csv-options input {
    margin: 0;
    accent-color: var(--accent);
}

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

@media (max-width: 576px) {
    .export-dialog .export-actions {
        flex: 1 0 100%;
    }
    .export-dialog .export-action {
        flex: 1 1 auto;
        padding-inline: 0.3rem;
    }
}

@media (pointer: coarse) {
    .export-dialog .export-action {
        min-height: 2.25rem;
    }
    .export-dialog .export-csv-options label {
        min-height: 2.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .export-dialog .export-action {
        transition: none;
    }
}

.download-sqlite {
    margin: 1.25rem 0 0;
}

.download-sqlite-size {
    color: #6b6b6b;
    font-size: 0.8125rem;
    transition: color 0.12s;
}

.download-sqlite .quiet-button:hover .download-sqlite-size,
.download-sqlite .quiet-button:focus-visible .download-sqlite-size {
    color: currentColor;
}



/* Below a query's results when they stopped at max_returned_rows */
.query-truncated {
    margin: 0.75rem 0 0;
    color: var(--muted);
    font-size: 0.875rem;
}

p.zero-results {
    border: 2px solid #ccc;
    background-color: #eee;
    padding: 0.5em;
    font-style: italic;
}

/* Value types */
.type-float, .type-int {
    color: #666;
}






/* Overrides ===============================================================*/

.small-screen-only,
.select-wrapper.small-screen-only {
    display: none;
}

/* navigation-search */
navigation-search {
    display: contents;
}

navigation-search dialog.datasette-modal {
    max-width: 90vw;
    width: 600px;
    max-height: 80vh;
}

navigation-search .search-container {
    display: flex;
    flex-direction: column;
}

navigation-search .search-input-wrapper {
    padding: 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

navigation-search .search-input {
    width: 100%;
    flex: 1;
    min-width: 0;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

navigation-search .search-input:focus {
    border-color: #2563eb;
}

navigation-search .close-search {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    color: #4b5563;
    cursor: pointer;
    flex: 0 0 auto;
    font: inherit;
    font-size: 1.5rem;
    height: 2.75rem;
    line-height: 1;
    width: 2.75rem;
}

navigation-search .close-search:hover,
navigation-search .close-search:focus {
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

navigation-search .results-container {
    box-sizing: content-box;
    height: calc(80vh - 180px);
    padding: 0.5rem;
}

navigation-search .results-list:empty {
    display: none;
}

navigation-search .result-item {
    padding: 0.875rem 1rem;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: background-color 0.15s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

navigation-search .result-item:hover {
    background-color: #f3f4f6;
}

navigation-search .result-item.selected {
    background-color: #dbeafe;
}

navigation-search .result-item > div {
    flex: 1;
    min-width: 0;
}

navigation-search .jump-start-content {
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.5rem 1rem;
}

navigation-search .jump-start-content:empty {
    display: none;
}

navigation-search .result-name {
    font-weight: 500;
    color: #111827;
}

navigation-search .result-label {
    font-size: 0.875rem;
    color: #4b5563;
}

navigation-search .result-type {
    color: #4b5563;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

navigation-search .result-url {
    font-size: 0.875rem;
    color: #6b7280;
}

navigation-search .result-description {
    color: #374151;
    display: -webkit-box;
    font-size: 0.8125rem;
    line-height: 1.35;
    margin-top: 0.35rem;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

navigation-search .results-heading {
    color: #4b5563;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0;
    padding: 0.5rem 1rem 0.25rem;
    text-transform: uppercase;
}

navigation-search .recent-actions {
    padding: 0.25rem 1rem 0.75rem;
}

navigation-search .clear-recent {
    background: transparent;
    border: 0;
    color: #2563eb;
    cursor: pointer;
    font: inherit;
    font-size: 0.875rem;
    padding: 0;
}

navigation-search .clear-recent:hover {
    text-decoration: underline;
}

navigation-search .no-results {
    padding: 2rem;
    text-align: center;
    color: #6b7280;
}

navigation-search .hint-text {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

navigation-search .hint-text kbd {
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    border: 1px solid #d1d5db;
    font-family: monospace;
}

navigation-search .visually-hidden,
.m2m-visually-hidden {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

@media (max-width: 640px) {
    navigation-search dialog.datasette-modal {
        width: 95vw;
        max-height: 85vh;
        border-radius: 0.5rem;
    }

    navigation-search .search-input-wrapper {
        padding: 1rem;
    }

    navigation-search .search-input {
        font-size: 16px;
    }

    navigation-search .result-item {
        padding: 1rem 0.75rem;
    }

    navigation-search .hint-text {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }
}


/* drag-reorder.js: lists reordered by dragging a handle */
.drag-reorder-handle {
    appearance: none;
    background: transparent;
    border: 0;
    border-radius: 4px;
    color: #a09c94;
    cursor: grab;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    touch-action: none;
    transition: color 0.15s;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.drag-reorder-handle:hover,
.drag-reorder-handle:focus-visible,
.drag-reorder-ghost .drag-reorder-handle {
    color: var(--accent, #1a56db);
}

.drag-reorder-handle:focus-visible {
    outline: 3px solid #b3d4ff;
    outline-offset: -3px;
}

.drag-reorder-handle:disabled {
    color: #a09c94;
    cursor: not-allowed;
    opacity: 0.45;
}

.drag-reorder-handle svg {
    display: block;
    pointer-events: none;
}

/* The item being dragged leaves a gap: a copy of it follows the pointer */
.drag-reorder-dragging {
    opacity: 0;
}

.drag-reorder-active,
.drag-reorder-active * {
    cursor: grabbing !important;
    -webkit-user-select: none;
    user-select: none;
}

.drag-reorder-ghost {
    position: fixed;
    margin: 0;
    pointer-events: none;
    z-index: 9999;
    background: white;
    border-radius: 6px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.18),
        0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 0.97;
}

.drag-reorder-ghost.drag-reorder-settling {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transition:
        left 0.15s cubic-bezier(0.22, 1, 0.36, 1),
        top 0.15s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.15s,
        opacity 0.1s 0.1s;
}

/* The line showing where the item will be dropped */
.drag-reorder-indicator {
    position: fixed;
    height: 2px;
    background: var(--accent, #1a56db);
    border-radius: 99px;
    pointer-events: none;
    z-index: 9998;
}

/* Shown at the edge the list is scrolling towards */
.drag-reorder-scroll-hint {
    position: fixed;
    width: 32px;
    height: 32px;
    margin-left: -16px;
    border-radius: 50%;
    background: var(--accent, #1a56db);
    opacity: 0.18;
    pointer-events: none;
    z-index: 9998;
    animation: drag-reorder-pulse 0.8s ease-in-out infinite;
}

.drag-reorder-indicator[hidden],
.drag-reorder-scroll-hint[hidden] {
    display: none;
}

@keyframes drag-reorder-pulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 0.18;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.07;
    }
}

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


/* column-chooser */
column-chooser {
    display: contents;
    --ink: #0f0f0f;
    --paper: #eef6ff;
    --muted: #6b6b6b;
    --rule: #d8e6f5;
    --accent: #1a56db;
    --accent-light: #e8effd;
    --card: #ffffff;
}

column-chooser * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

column-chooser dialog.datasette-modal {
    width: 100%;
    max-width: 420px;
    max-height: min(640px, calc(100vh - 32px));
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

column-chooser dialog.datasette-modal[open] {
    height: min(640px, calc(100vh - 32px));
}

column-chooser .modal-header {
    padding: 20px 24px 16px;
    justify-content: space-between;
}

column-chooser .list-toolbar {
    padding: 6px 24px;
    border-bottom: 1px solid var(--rule);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

column-chooser .list-toolbar button {
    background: var(--accent-light);
    border: 1px solid var(--rule);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.75rem;
    color: var(--accent);
    cursor: pointer;
    padding: 3px 10px;
    transition:
        background 0.12s,
        color 0.12s;
}

/* Apart from the other two, at the right */
column-chooser .list-toolbar button.reset-columns {
    margin-left: auto;
}

column-chooser .list-toolbar button:hover {
    background: var(--accent);
    color: white;
}

column-chooser .list-wrap {
    flex: 1;
    padding: 0;
    overflow-x: hidden;
    position: relative;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

column-chooser .list-wrap::before,
column-chooser .list-wrap::after {
    content: "";
    position: sticky;
    display: block;
    left: 0;
    right: 0;
    height: 20px;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.2s;
}

column-chooser .list-wrap::before {
    top: 0;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.9),
        transparent
    );
}

column-chooser .list-wrap::after {
    bottom: 0;
    background: linear-gradient(to top, rgba(255, 255, 255, 0.9), transparent);
    margin-top: -20px;
}

column-chooser .drag-list {
    list-style: none;
    padding: 4px 0;
}

column-chooser .drag-item {
    display: flex;
    align-items: center;
    background: white;
    border-bottom: 1px solid var(--rule);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    position: relative;
    transition: background 0.08s;
}

column-chooser .drag-item:last-child {
    border-bottom: none;
}

column-chooser .drag-handle {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

column-chooser .drag-item-content {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

column-chooser .drag-item-check {
    display: flex;
    align-items: center;
    width: 32px;
    height: 48px;
    flex-shrink: 0;
}

column-chooser .drag-item-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

column-chooser .drag-item-label {
    flex: 1;
    font-size: 0.9rem;
    line-height: 48px;
    padding-right: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}

/* A relationship column: "people" then a muted "via movie_actors" */
column-chooser .drag-item-label:has(+ .drag-item-via) {
    flex: 0 1 auto;
    padding-right: 0.5em;
}

column-chooser .drag-item-via {
    flex: 1;
    min-width: 0;
    color: #6b6b6b;
    font-size: 0.8125rem;
    line-height: 48px;
    padding-right: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}

column-chooser .drag-reorder-ghost .drag-item {
    border-bottom: none;
}

column-chooser .modal-btn-primary {
    color: white;
}

column-chooser .modal-btn-primary:hover {
    background: #1448c0;
}

column-chooser .list-wrap::-webkit-scrollbar {
    width: 5px;
}

column-chooser .list-wrap::-webkit-scrollbar-track {
    background: transparent;
}

column-chooser .list-wrap::-webkit-scrollbar-thumb {
    background: var(--rule);
    border-radius: 99px;
}

column-chooser input,
column-chooser textarea {
    -webkit-user-select: auto;
    user-select: auto;
}

dialog.mobile-column-actions-dialog {
    width: min(420px, calc(100vw - 32px));
    max-height: min(640px, calc(100vh - 32px));
}

.mobile-column-actions-dialog .modal-header {
    padding: 20px 24px 16px;
    justify-content: space-between;
}

.mobile-column-actions-dialog .list-wrap {
    flex: 1 1 auto;
    padding: 0;
    overflow-x: hidden;
    position: relative;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.mobile-column-actions-dialog .list-wrap::before,
.mobile-column-actions-dialog .list-wrap::after {
    content: "";
    position: sticky;
    display: block;
    left: 0;
    right: 0;
    height: 20px;
    pointer-events: none;
    z-index: 5;
}

.mobile-column-actions-dialog .list-wrap::before {
    top: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.9), transparent);
}

.mobile-column-actions-dialog .list-wrap::after {
    bottom: 0;
    background: linear-gradient(to top, rgba(255,255,255,0.9), transparent);
    margin-top: -20px;
}

.mobile-column-top-actions {
    padding: 10px 24px 0;
}

.mobile-column-top-action {
    display: inline-block;
    text-decoration: none;
}

.mobile-column-section {
    border-bottom: 1px solid var(--rule);
}

.mobile-column-actions-dialog .col-header {
    width: 100%;
    padding: 12px 24px;
    font: inherit;
    font-weight: 600;
    border: 0;
    background: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.mobile-column-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.mobile-column-name {
    color: var(--ink);
}

.mobile-column-meta {
    color: var(--muted);
    font-size: 0.78em;
    font-family: ui-monospace, monospace;
    font-weight: normal;
}

.mobile-column-chevron {
    color: var(--muted);
    transition: transform 0.2s ease-out;
}

.mobile-column-actions-dialog .col-header[aria-expanded="true"] .mobile-column-chevron {
    transform: rotate(180deg);
}

.mobile-column-actions-dialog .col-actions[hidden] {
    display: none;
}

.mobile-column-actions-dialog .col-actions ul,
.mobile-column-actions-dialog .col-actions li {
    margin: 0;
    padding: 0;
    list-style-type: none;
}

.mobile-column-actions-dialog .col-actions a,
.mobile-column-actions-dialog .col-actions button {
    display: block;
    width: 100%;
    padding: 10px 24px 10px 40px;
    color: var(--ink);
    text-align: left;
    font: inherit;
    text-decoration: none;
    background: none;
    border: 0;
    border-top: 1px solid #f5f5f5;
    cursor: pointer;
}

.mobile-column-actions-dialog .col-actions a:hover,
.mobile-column-actions-dialog .col-actions button:hover {
    background: var(--paper);
}

.mobile-column-actions-dialog .col-actions a:active,
.mobile-column-actions-dialog .col-actions button:active {
    background: #eee;
}

.mobile-column-description,
.mobile-column-no-actions {
    margin: 0;
    padding: 0 24px 12px 24px;
    color: var(--muted);
    font-size: 0.85em;
}

dialog.set-column-type-dialog {
    max-height: min(720px, calc(100vh - 32px));
}

.set-column-type-dialog .modal-header {
    justify-content: space-between;
}

.set-column-type-status,
.set-column-type-empty,
.set-column-type-error {
    margin: 0;
    padding: 12px 24px 0;
}

.set-column-type-status,
.set-column-type-empty {
    color: var(--muted);
    font-size: 0.9rem;
}

.set-column-type-error {
    color: #b91c1c;
    font-size: 0.9rem;
}

.set-column-type-options {
    display: grid;
    gap: 12px;
}

.set-column-type-option {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
    padding: 14px 16px;
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: #fbfdff;
    cursor: pointer;
}

.set-column-type-option:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

.set-column-type-option input {
    margin-top: 3px;
}

.set-column-type-option-content {
    display: grid;
    gap: 4px;
}

.set-column-type-option-name {
    font-family: ui-monospace, monospace;
    font-size: 0.95rem;
    color: var(--ink);
}

.set-column-type-option-description {
    color: var(--muted);
    font-size: 0.9rem;
}

/* Set label column dialog (set-label-column.js) */
dialog.set-label-column-dialog {
    max-height: min(720px, calc(100vh - 32px));
    width: min(560px, calc(100vw - 32px));
}

.set-label-column-intro,
.set-label-column-error {
    margin: 0;
    padding: 12px 24px 0;
    font-size: 0.9rem;
}

.set-label-column-intro {
    color: var(--muted);
}

.set-label-column-error,
.set-label-column-template-error {
    color: #b91c1c;
    font-size: 0.9rem;
}

.set-label-column-template-error {
    margin: 0;
}

.set-label-column-options {
    display: grid;
    gap: 12px;
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.set-label-column-option {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
    padding: 14px 16px;
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: #fbfdff;
    cursor: pointer;
}

.set-label-column-option:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

.set-label-column-option > input {
    margin-top: 3px;
}

.set-label-column-option-content {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.set-label-column-option-name {
    font-weight: 600;
    color: var(--ink);
}

.set-label-column-option-description {
    color: var(--muted);
    font-size: 0.9rem;
}

.set-label-column-select,
.set-label-column-template {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 6px;
    background-color: #fff;
    color: inherit;
    font-size: 0.9rem;
    line-height: 1.25;
    padding: 7px 10px;
}

/* Browsers draw different arrows and insets for a native select, so turn
   that off and draw a chevron, as the filter selects do (.select-wrapper) */
.set-label-column-select {
    appearance: none;
    background: #fff url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23444' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 12px center / 10px 6px;
    cursor: pointer;
    font-family: inherit;
    padding-right: 32px;
}

.set-label-column-template {
    font-family: ui-monospace, monospace;
}

.set-label-column-select:focus,
.set-label-column-template:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.14);
    outline: none;
}

.set-label-column-insert {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.set-label-column-insert-button {
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
    padding: 2px 8px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
}

.set-label-column-insert-button:hover,
.set-label-column-insert-button:focus-visible {
    border-color: var(--accent);
}

.set-label-column-preview-heading {
    margin: 16px 0 6px;
    font-size: 0.95rem;
}

.set-label-column-preview {
    margin: 0;
    padding-left: 20px;
    font-size: 0.9rem;
    color: var(--ink);
}

/* Column statistics dialog (column-stats.js) */
dialog.column-stats-dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: min(860px, calc(100dvh - 32px));
}

.column-stats-dialog .modal-header {
    justify-content: space-between;
}

.column-stats-dialog .modal-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* The pills and the statistics scroll together, so the pill list never
   needs a scrollbar of its own */
.column-stats-scroll {
    min-height: 0;
    overflow-y: auto;
    /* Keeps the pill rows the same width whether or not it scrolls */
    scrollbar-gutter: stable;
}

.column-stats-dialog .column-stats-body {
    overflow: visible;
}

/* A pill for each column, to switch the dialog between columns. Collapsed,
   it shows at most three rows (column-stats.js hides the rest behind a
   "+N more" pill) and stays pinned while the statistics scroll beneath it.
   Expanded, every pill shows and they scroll away with the statistics. */
.column-stats-columns {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 24px;
    border-bottom: 1px solid var(--rule);
    background: var(--card);
}

.column-stats-columns.is-expanded {
    position: static;
}

.column-stats-columns[hidden] {
    display: none;
}

/* The tablist holds only the tabs, but the pills and the "+N more" button
   share one row layout */
.column-stats-tablist {
    display: contents;
}

.column-stats-column,
.column-stats-more {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    /* Only truncate names too long to fit on a row by themselves */
    max-width: 100%;
    padding: 3px 10px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--card);
    color: var(--ink);
    font: inherit;
    font-size: 0.8rem;
    line-height: 1.4;
    cursor: pointer;
    white-space: nowrap;
}

.column-stats-column[hidden],
.column-stats-more[hidden] {
    display: none;
}

.column-stats-more {
    border-style: dashed;
    color: var(--accent);
}

.column-stats-more:hover {
    border-color: var(--accent);
    border-style: solid;
}

.column-stats-more:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.column-stats-column:hover {
    border-color: var(--accent);
}

.column-stats-column:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.column-stats-column-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.column-stats-column-type {
    font-family: ui-monospace, monospace;
    font-size: 0.68rem;
    color: var(--muted);
}

.column-stats-column[aria-selected="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    cursor: default;
}

.column-stats-column[aria-selected="true"] .column-stats-column-type {
    color: rgba(255, 255, 255, 0.85);
}

.column-stats-body {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.column-stats-section + .column-stats-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--rule);
}

.column-stats-section h3 {
    margin: 0 0 10px;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.column-stats-subtitle {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--muted);
}

.column-stats-section h4 {
    margin: 14px 0 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.column-stats-loading,
.column-stats-note {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.column-stats-error {
    margin: 8px 0 0;
    padding: 8px 10px;
    border-left: 3px solid #b91c1c;
    background: rgba(185, 28, 28, 0.06);
    color: #b91c1c;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

/* Which rows the statistics cover: filtered rows or the whole table */
.column-stats-scope {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    flex-wrap: wrap;
    margin: 0 0 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--paper);
    font-size: 0.85rem;
}

.column-stats-scope p {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.column-stats-scope[data-scope="all"] .column-stats-scope-description {
    color: var(--muted);
}

.column-stats-scope-toggle {
    flex-shrink: 0;
    border: 1px solid var(--rule);
    border-radius: 5px;
    background: var(--card);
    color: var(--accent);
    padding: 4px 10px;
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.column-stats-scope-toggle:hover {
    border-color: var(--accent);
}

/* Stat tiles */
.column-stats-tiles {
    display: grid;
    grid-template-columns: repeat(var(--column-stats-tile-columns, 4), minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}

.column-stats-tile {
    padding: 8px 10px;
    border: 1px solid var(--rule);
    border-radius: 6px;
    background: #fbfdff;
    min-width: 0;
}

.column-stats-tile dt {
    font-size: 0.72rem;
    color: var(--muted);
}

.column-stats-tile dd {
    margin: 2px 0 0;
    display: flex;
    flex-direction: column;
}

.column-stats-tile-value {
    font-size: 1rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.column-stats-tile-detail {
    font-size: 0.72rem;
    color: var(--muted);
}

/* Storage type breakdown */
.column-stats-types-bar {
    display: flex;
    height: 8px;
    margin-top: 6px;
    border-radius: 4px;
    overflow: hidden;
    gap: 2px;
}

.column-stats-types-bar span {
    flex-basis: 0;
    min-width: 3px;
}

.column-stats-types-legend {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 0.8rem;
    color: var(--muted);
}

.column-stats-swatch {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    margin-right: 5px;
}

.column-stats-type-integer { background: #1a56db; }
.column-stats-type-real { background: #0e9f6e; }
.column-stats-type-text { background: #c27803; }
.column-stats-type-blob { background: #7e3af2; }

/* Bar charts */
.column-stats-figure {
    margin: 12px 0 0;
}

.column-stats-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 96px;
    padding-bottom: 1px;
    border-bottom: 1px solid var(--rule);
}

.column-stats-bar {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: flex-end;
}

.column-stats-bar-fill {
    display: block;
    width: 100%;
    background: rgba(26, 86, 219, 0.55);
    border-radius: 2px 2px 0 0;
}

.column-stats-bar:hover .column-stats-bar-fill {
    background: var(--accent);
}

.column-stats-axis {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 3px;
    font-size: 0.72rem;
    color: var(--muted);
}

.column-stats-chart-caption {
    margin: 4px 0 0;
    min-height: 1.2em;
    font-size: 0.78rem;
    color: var(--muted);
    text-align: center;
}

/* Box plot, on the same min to max scale as the histogram axis */
.column-stats-boxplot {
    position: relative;
    height: 18px;
    margin-top: 10px;
}

.column-stats-boxplot-whisker {
    position: absolute;
    top: 8px;
    height: 2px;
    background: var(--muted);
}

.column-stats-boxplot-box {
    position: absolute;
    top: 2px;
    height: 14px;
    box-sizing: border-box;
    border: 1.5px solid var(--accent);
    background: rgba(26, 86, 219, 0.12);
    border-radius: 3px;
}

.column-stats-boxplot-median {
    position: absolute;
    top: 0;
    height: 18px;
    width: 2px;
    margin-left: -1px;
    background: var(--ink);
}

/* Percentiles */
.column-stats-percentiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 4px;
    margin: 0;
}

.column-stats-percentile {
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--paper);
    font-size: 0.8rem;
    min-width: 0;
}

.column-stats-percentile dt {
    font-size: 0.72rem;
    color: var(--muted);
}

.column-stats-percentile dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* Text patterns and range */
.column-stats-patterns {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.85rem;
}

.column-stats-patterns li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    border-bottom: 1px dashed var(--rule);
}

.column-stats-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 12px 0 0;
}

.column-stats-range dt {
    font-size: 0.72rem;
    color: var(--muted);
}

.column-stats-range dd {
    margin: 2px 0 0;
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    max-height: 4.5em;
    overflow: hidden;
}

/* Most common values */
.column-stats-top-values {
    list-style: none;
    margin: 0;
    padding: 0;
}

.column-stats-top-values li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 12px;
    padding: 5px 0;
    font-size: 0.85rem;
}

.column-stats-top-value {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.column-stats-value-special {
    color: var(--muted);
    font-style: italic;
}

.column-stats-top-count {
    color: var(--muted);
    white-space: nowrap;
}

.column-stats-top-bar {
    grid-column: 1 / -1;
    height: 4px;
    border-radius: 2px;
    background: var(--paper);
    overflow: hidden;
}

.column-stats-top-bar span {
    display: block;
    height: 100%;
    background: rgba(26, 86, 219, 0.55);
}

/* SQL used to calculate the statistics */
.column-stats-sql {
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--rule);
    font-size: 0.85rem;
}

.column-stats-sql summary {
    cursor: pointer;
    color: var(--muted);
}

.column-stats-sql-list {
    margin: 8px 0 0;
    padding-left: 1.4em;
}

.column-stats-sql-list li + li {
    margin-top: 10px;
}

.column-stats-sql-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.column-stats-sql-list pre {
    margin: 4px 0 0;
    padding: 8px 10px;
    background: var(--paper);
    border-radius: 4px;
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: pre;
}

@media (max-width: 576px) {
    .column-stats-dialog .modal-body {
        padding: 12px 16px 20px;
    }
    .column-stats-columns {
        padding: 8px 16px;
    }
    .column-stats-tiles {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .column-stats-range {
        grid-template-columns: 1fr;
    }
}

.row-mutation-status {
    margin: 0 0 0.75rem;
    padding: 8px 10px;
    border-left: 4px solid #54AC8E;
    background: rgba(103,201,141,0.12);
    color: #222;
}

.row-mutation-status[hidden] {
    display: none;
}

.row-mutation-status-error {
    border-left-color: #D0021B;
    background: rgba(208,2,27,0.12);
}

:where(div).table-row-toolbar {
    margin: 0 0 0.75rem;
}

/* Same box as .quiet-button and the actions menu trigger. Needs .core
   to outrank the button.core[type=button] defaults. */
button.core.table-insert-row {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    box-sizing: border-box;
    min-height: 1.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 5px;
    font-size: 0.875rem;
    line-height: 1.2;
}

button.table-insert-row svg {
    display: block;
    flex-shrink: 0;
}

dialog.row-delete-dialog {
    width: min(440px, calc(100vw - 32px));
}

.row-delete-dialog .modal-header {
    justify-content: flex-start;
}

/* The title is a question that wraps like a sentence */
.row-delete-dialog .modal-title {
    min-width: 0;
    max-width: 100%;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.row-delete-message,
.row-delete-error {
    margin: 0;
    padding: 16px 24px 0;
}

.row-delete-message {
    color: var(--ink);
    font-size: 0.95rem;
}

.row-delete-message p {
    margin: 0;
}

/* The row's label, above the warning. Very long labels are cut to three
   lines. */
.row-delete-message .row-delete-label {
    display: -webkit-box;
    margin-bottom: 0.4rem;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.row-delete-message .row-delete-label[hidden],
.row-delete-message .row-delete-references[hidden],
.row-delete-options-intro[hidden],
.row-delete-links-option[hidden] {
    display: none;
}

.row-delete-error {
    color: #b91c1c;
    font-size: 0.9rem;
}

.row-delete-dialog .modal-footer {
    flex-wrap: wrap;
    padding: 18px 20px 14px;
}

/* The Delete button says what will be deleted, "Delete row and 17 linked
   rows", so it can be long: it wraps, and on a phone the buttons share
   the row or stack, each the full width */
.row-delete-dialog .row-delete-confirm {
    max-width: 100%;
    white-space: normal;
}

.row-delete-dialog .modal-btn-danger {
    background: #b91c1c;
    color: #fff;
}

/* Everything between the title and the buttons scrolls as one column:
   the message, what links to the row, the warnings and the options, so
   the buttons always stay in view below it. The space under the last
   line is padding, so it scrolls into view with the content, and the
   backgrounds draw a shadow at an edge while there is more to scroll to. */
.row-delete-body {
    flex: 1 1 auto;
    min-height: 5rem;
    overflow: auto;
    overscroll-behavior: contain;
    padding-bottom: 18px;
    background:
        linear-gradient(#fff 50%, rgba(255, 255, 255, 0)) top / 100% 28px no-repeat local,
        linear-gradient(rgba(255, 255, 255, 0), #fff 50%) bottom / 100% 28px no-repeat local,
        radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.18), transparent) top / 100% 14px no-repeat scroll,
        radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.18), transparent) bottom / 100% 14px no-repeat scroll;
    background-color: var(--card, #fff);
}

/* What links to the row, loaded when the dialog opens */
.row-delete-message .row-delete-references,
.row-delete-message .row-delete-linked {
    margin: 0 0 0.6rem;
}

.row-delete-message .row-delete-checking {
    color: var(--muted);
}

/* "Linked to 19 rows via 6 tables", which opens to a line per
   relationship */
.row-delete-message .row-delete-linked-summary {
    padding: 2px 8px;
    border-left: 3px solid var(--m2m-rule);
    background: var(--m2m-paper);
    color: var(--m2m-ink);
    cursor: pointer;
    overflow-wrap: anywhere;
}

.row-delete-message .row-delete-linked-summary:hover {
    background: #e1edfb;
}

.row-delete-message .row-delete-linked[open] .row-delete-linked-summary {
    margin-bottom: 2px;
}

.row-delete-message .row-delete-linked .row-delete-list {
    margin: 0;
}

.row-delete-message .row-delete-intro {
    margin: 0 0 0.25rem;
}

.row-delete-message .row-delete-list {
    margin: 0 0 0.6rem;
    padding: 0;
    list-style: none;
}

.row-delete-message .row-delete-links li {
    margin: 0 0 2px;
    padding: 1px 8px;
    border-left: 3px solid var(--m2m-rule);
    background: var(--m2m-paper);
    color: var(--m2m-ink);
    overflow-wrap: anywhere;
}

.row-delete-message .row-delete-links-left li {
    border-left-color: #e2bcbc;
    background: #fff;
    color: var(--ink);
}

.row-delete-message .row-delete-warning,
.row-delete-message .row-delete-warnings li {
    padding-left: 8px;
    border-left: 3px solid #e2bcbc;
    overflow-wrap: anywhere;
}

.row-delete-message .row-delete-warnings li {
    margin: 0 0 0.25rem;
}

/* The options, below a rule, in the same scrolling column as the message */
.row-delete-options:has(> :not([hidden])) {
    margin-top: 16px;
    border-top: 1px solid var(--rule);
}

/* What leaving a checkbox unticked does, said once for all of them */
.row-delete-options-intro {
    margin: 0;
    padding: 12px 24px 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.row-delete-links-option {
    margin: 0;
    padding: 12px 24px 0;
    font-size: 0.95rem;
}

.row-delete-links-choice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
}

.row-delete-links-choice input {
    flex-shrink: 0;
    width: 1.1rem;
    height: 1.1rem;
    margin: 0.15rem 0 0;
}

.row-delete-links-note {
    margin: 0.3rem 0 0 calc(1.1rem + 8px);
    color: var(--muted);
    font-size: 0.9rem;
}

/* Rows of a junction table that hold data of their own, such as reviews:
   keep them and clear their foreign key, delete them, or leave them. The
   legend floats so it lays out like a block, not in the border. */
.row-delete-data-option {
    min-width: 0;
    margin: 12px 0 0;
    padding-top: 0;
    border: 0;
}

.row-delete-data-legend {
    float: left;
    width: 100%;
    margin: 0 0 0.15rem;
    padding: 0;
    overflow-wrap: anywhere;
}

.row-delete-radio-choice {
    clear: both;
    margin-top: 0.3rem;
    font-weight: normal;
}

.row-delete-options code,
.row-delete-message .row-delete-warnings code {
    padding: 0 3px;
    border: 1px solid var(--rule);
    border-radius: 3px;
    font-size: 0.85em;
    overflow-wrap: anywhere;
}

.row-delete-dialog .modal-btn-danger:hover {
    background: #991b1b;
}

.row-delete-dialog .modal-btn-danger:disabled,
.row-delete-dialog .modal-btn-danger:disabled:hover,
.row-delete-dialog .modal-btn-danger[aria-disabled="true"],
.row-delete-dialog .modal-btn-danger[aria-disabled="true"]:hover {
    background: #d98c8c;
    color: #fff;
}

/* Waiting for the references lookup: focusable, but does nothing yet */
.row-delete-dialog .modal-btn-danger[aria-disabled="true"] {
    cursor: progress;
}

dialog.row-edit-dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: min(780px, calc(100vh - 32px));
}

.row-edit-dialog .modal-title {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    max-width: 100%;
}

.row-edit-dialog .modal-title .row-dialog-action {
    flex: 0 0 auto;
    white-space: nowrap;
}

.row-edit-dialog .modal-title code,
.row-delete-dialog .modal-title code {
    display: inline;
    flex: 0 0 auto;
    padding: 2px 5px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--paper);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    overflow-wrap: anywhere;
}

.row-edit-dialog .modal-title .row-dialog-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-edit-form {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
}

.row-edit-summary,
.row-edit-loading,
.row-edit-error {
    margin: 0;
    padding: 12px 24px 0;
}

.row-edit-summary,
.row-edit-loading {
    color: var(--muted);
    font-size: 0.9rem;
}

.row-edit-error {
    border-left: 4px solid #b91c1c;
    border-radius: 4px;
    background: #fff1f1;
    color: #7f1d1d;
    font-size: 0.9rem;
    margin: 12px 24px 0;
    padding: 10px 12px;
}

.row-edit-error:focus {
    outline: 3px solid rgba(185, 28, 28, 0.18);
    outline-offset: 2px;
}

.row-edit-fields {
    display: grid;
    gap: 14px;
}

.row-edit-fields[hidden],
.row-edit-bulk[hidden] {
    display: none;
}

.row-edit-field {
    display: grid;
    grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.row-edit-label {
    padding-top: 8px;
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.row-edit-control-wrap {
    display: grid;
    gap: 5px;
}

.row-edit-input,
.m2m-editor-input,
.m2m-editor-filter-input {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    border: 1px solid var(--rule);
    border-radius: 5px;
    padding: 8px 10px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

textarea.row-edit-input {
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
}

.row-edit-input:focus,
.m2m-editor-input:focus,
.m2m-editor-filter-input:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(26, 86, 219, 0.12);
}

.row-edit-input[aria-invalid="true"] {
    border-color: #b42318;
    background: #fff8f7;
}

.row-edit-input[aria-invalid="true"]:focus {
    border-color: #b42318;
    outline-color: rgba(180, 35, 24, 0.16);
}

.row-edit-input[readonly] {
    color: var(--muted);
    background: var(--paper);
}

.row-edit-binary-control {
    display: grid;
    gap: 8px;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    border: 1px solid var(--rule);
    border-radius: 5px;
    padding: 10px;
    background: #fff;
}

.row-edit-binary-control:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(26, 86, 219, 0.12);
}

.row-edit-binary-preview[hidden] {
    display: none;
}

.row-edit-binary-preview img {
    display: block;
    max-width: min(240px, 100%);
    max-height: 180px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--paper);
}

.row-edit-binary-status {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.row-edit-binary-size {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.86rem;
}

.row-edit-binary-name {
    color: var(--muted);
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.row-edit-binary-name[hidden] {
    display: none;
}

.row-edit-binary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.row-edit-binary-file-button,
.row-edit-binary-clear {
    appearance: none;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: #fff;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-size: 0.78rem;
    line-height: 1.2;
    padding: 6px 8px;
}

.row-edit-binary-file-button:hover,
.row-edit-binary-file-button:focus-within,
.row-edit-binary-clear:hover,
.row-edit-binary-clear:focus {
    background: #f8fafc;
}

.row-edit-binary-file-button:focus-within,
.row-edit-binary-clear:focus {
    outline: 3px solid rgba(26, 86, 219, 0.12);
    outline-offset: 1px;
}

.row-edit-binary-file-button input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.row-edit-binary-clear[hidden] {
    display: none;
}

.row-edit-binary-drop-target {
    border: 1px dashed var(--rule);
    border-radius: 4px;
    padding: 7px 8px;
    color: var(--muted);
    font-size: 0.78rem;
}

.row-edit-binary-dragover .row-edit-binary-drop-target {
    border-color: var(--accent);
    background: var(--paper);
    color: var(--ink);
}

.row-edit-default {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 7.25rem;
    align-items: center;
    gap: 8px;
    min-width: 0;
    border: 1px solid var(--rule);
    border-radius: 5px;
    padding: 7px 8px 7px 10px;
    background: var(--paper);
    color: var(--ink);
}

.row-edit-default[hidden],
.row-edit-custom-value[hidden] {
    display: none;
}

.row-edit-default-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.row-edit-default-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
}

.row-edit-custom-value {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 7.25rem;
    gap: 8px;
    align-items: center;
    min-height: 45px;
    padding-right: 8px;
}

.row-edit-default-button {
    appearance: none;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: #fff;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-size: 0.78rem;
    line-height: 1.2;
    padding: 6px 8px;
    white-space: nowrap;
    width: 100%;
    align-self: center;
}

.row-edit-default-button:hover,
.row-edit-default-button:focus {
    background: #f8fafc;
}

.row-edit-default-button:focus {
    outline: 3px solid rgba(26, 86, 219, 0.12);
    outline-offset: 1px;
}

.row-edit-field-meta {
    color: var(--muted);
    font-size: 0.78rem;
}

.row-edit-field-validation-error {
    color: #b42318;
    display: block;
    margin-top: 2px;
}

.row-edit-field-validation-error[hidden] {
    display: none;
}

.row-edit-field-meta-autocomplete {
    line-height: 1.2;
    min-height: 1.2em;
}

.row-edit-fk-pk {
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.row-edit-fk-link {
    overflow-wrap: anywhere;
}

.row-edit-empty {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0;
}

.row-edit-bulk {
    display: grid;
    gap: 8px;
}

.row-edit-bulk-editor {
    display: grid;
    gap: 8px;
}

.row-edit-bulk-editor[hidden] {
    display: none;
}

.row-edit-bulk-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

.row-edit-bulk-actions .modal-btn {
    padding-left: 12px;
    padding-right: 12px;
}

.row-edit-bulk-conflict {
    display: grid;
    grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
    gap: 8px 12px;
    align-items: start;
}

.row-edit-bulk-conflict[hidden] {
    display: none;
}

.row-edit-bulk-conflict-label {
    color: var(--ink);
    font-size: 0.82rem;
    padding-top: 8px;
}

.row-edit-bulk-conflict-control {
    display: grid;
    gap: 4px;
}

.row-edit-bulk-conflict-help {
    color: var(--muted);
    font-size: 0.78rem;
    margin: 0;
}

.row-edit-copy-template-label-narrow {
    display: none;
}

.row-edit-bulk-template-note {
    color: var(--muted);
    font-size: 0.82rem;
}

.row-edit-bulk-template-note-narrow {
    display: none;
}

.row-edit-bulk-textarea {
    min-height: 16rem;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
}

.row-edit-bulk-textarea.row-edit-bulk-drop-target {
    border-color: var(--accent);
    background: #f8fbff;
    outline: 3px solid rgba(26, 86, 219, 0.12);
}

.row-edit-bulk-note {
    color: var(--muted);
    font-size: 0.82rem;
    margin: 0;
}

.row-edit-bulk-note label,
.row-edit-bulk-note .button-as-link {
    font: inherit;
}

@media (max-width: 640px) {
    .row-edit-copy-template-label-wide {
        display: none;
    }

    .row-edit-copy-template-label-narrow {
        display: inline;
    }

    .row-edit-bulk-template-note-wide {
        display: none;
    }

    .row-edit-bulk-template-note-narrow {
        display: inline;
    }
}

.row-edit-bulk-preview {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.row-edit-bulk-preview[hidden] {
    display: none;
}

.row-edit-bulk-preview-summary {
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
}

.row-edit-bulk-preview-table-wrap {
    border: 1px solid var(--rule);
    border-radius: 5px;
    max-height: 18rem;
    overflow: auto;
    background: #fff;
}

.row-edit-bulk-preview-table {
    border-collapse: collapse;
    font-size: 0.78rem;
    min-width: 100%;
    width: max-content;
}

.row-edit-bulk-preview-table th,
.row-edit-bulk-preview-table td {
    border-bottom: 1px solid var(--rule);
    border-right: 1px solid var(--rule);
    max-width: 18rem;
    overflow-wrap: anywhere;
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
    white-space: normal;
}

.row-edit-bulk-preview-table th {
    background: var(--paper);
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.row-edit-bulk-preview-table tr:last-child td {
    border-bottom: none;
}

.row-edit-bulk-preview-table th:last-child,
.row-edit-bulk-preview-table td:last-child {
    border-right: none;
}

.row-edit-bulk-preview-null,
.row-edit-bulk-preview-auto {
    color: var(--muted);
    font-style: italic;
}

.row-edit-bulk-progress {
    display: grid;
    gap: 6px;
}

.row-edit-bulk-progress[hidden] {
    display: none;
}

.row-edit-bulk-progress-bar {
    width: 100%;
}

.row-edit-bulk-progress-status {
    color: var(--ink);
    font-size: 0.9rem;
    margin: 0;
}

datasette-autocomplete {
    display: block;
    position: relative;
    max-width: 38rem;
}

datasette-autocomplete input[type="text"],
.debug-autocomplete-form input[type="text"] {
    box-sizing: border-box;
    width: 100%;
    max-width: 38rem;
}

.datasette-autocomplete-list {
    background: #fff;
    border: 1px solid var(--rule);
    border-radius: 5px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
    box-sizing: border-box;
    left: 0;
    max-height: 16rem;
    overflow-y: auto;
    /* Attached to the input: see positionListbox() in autocomplete.js */
    position: absolute;
    right: 0;
    top: calc(100% + 3px);
    z-index: 10000;
}

.datasette-autocomplete-list-above {
    top: auto;
    bottom: calc(100% + 3px);
}

.datasette-autocomplete-list[hidden] {
    display: none;
}

.datasette-autocomplete-option {
    cursor: pointer;
    padding: 7px 9px;
}

.datasette-autocomplete-option:hover,
.datasette-autocomplete-option[aria-selected="true"] {
    background: var(--paper);
}

.datasette-autocomplete-option[aria-selected="true"] {
    background: var(--paper);
    font-weight: 600;
}

/* Shown when a search finds nothing, with the empty-message attribute */
.datasette-autocomplete-empty {
    color: var(--muted);
    cursor: default;
    font-style: italic;
    padding: 7px 9px;
}

/* Actions such as "+ Create tags row", after the rows */
.datasette-autocomplete-action {
    border-top: 1px solid var(--rule);
    color: #1a3f9e;
}
.datasette-autocomplete-empty + .datasette-autocomplete-action {
    border-top: 0;
}

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

.debug-autocomplete-demo {
    margin: 1rem 0;
}

.debug-autocomplete-selected {
    max-width: 46rem;
}

.row-edit-mode-link {
    color: var(--accent);
    font-size: 0.9rem;
    margin-right: auto;
}

.row-edit-mode-link[hidden] {
    display: none;
}

.row-edit-dialog .modal-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

dialog.table-create-dialog {
    width: min(980px, calc(100vw - 32px));
    max-height: min(780px, calc(100vh - 32px));
}

:where(dialog).table-create-dialog .modal-title {
    display: flex;
    align-items: center;
    min-width: 0;
    max-width: 100%;
}

:where(dialog.table-create-dialog) .table-create-form {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
}

:where(dialog.table-create-dialog) .table-create-error {
    border-left: 4px solid #b91c1c;
    border-radius: 4px;
    background: #fff1f1;
    color: #7f1d1d;
    font-size: 0.9rem;
    margin: 12px 24px 0;
    padding: 10px 12px;
}

:where(dialog.table-create-dialog) .table-create-error:focus {
    outline: 3px solid rgba(185, 28, 28, 0.18);
    outline-offset: 2px;
}

:where(dialog.table-create-dialog) .table-create-fields {
    display: grid;
    gap: 18px;
}

:where(dialog.table-create-dialog) .table-create-field {
    display: grid;
    grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

:where(dialog.table-create-dialog) .table-create-label,
:where(dialog.table-create-dialog) .table-create-column-headings {
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
}

:where(dialog.table-create-dialog) .table-create-label {
    padding-top: 8px;
}

:where(dialog.table-create-dialog) .table-create-column-label {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

:where(dialog.table-create-dialog) .table-create-input {
    box-sizing: border-box;
    min-width: 0;
    min-height: 46px;
    border: 1px solid var(--rule);
    border-radius: 5px;
    padding: 8px 10px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    line-height: 1.35;
}

:where(dialog.table-create-dialog) select.table-create-input {
    height: 46px;
}

:where(dialog.table-create-dialog) .table-create-input-placeholder {
    color: var(--muted);
}

:where(dialog.table-create-dialog) .table-create-foreign-key-target option,
:where(dialog.table-create-dialog) .table-create-custom-column-type option,
:where(dialog.table-create-dialog) .table-create-default-expr option {
    color: var(--ink);
}

:where(dialog.table-create-dialog) .table-create-foreign-key-target option[value=""],
:where(dialog.table-create-dialog) .table-create-custom-column-type option[value=""],
:where(dialog.table-create-dialog) .table-create-default-expr option[value=""] {
    color: var(--muted);
}

:where(dialog.table-create-dialog) .table-create-table-name {
    width: 100%;
}

:where(dialog.table-create-dialog) .table-create-input:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(26, 86, 219, 0.12);
}

:where(dialog.table-create-dialog) .table-create-columns {
    display: grid;
    gap: 10px;
}

:where(dialog.table-create-dialog) .table-create-columns[hidden],
:where(dialog.table-create-dialog) .table-create-data[hidden],
:where(dialog.table-create-dialog) .table-create-data-editor[hidden],
:where(dialog.table-create-dialog) .table-create-data-preview[hidden] {
    display: none;
}

:where(dialog.table-create-dialog) .table-create-data,
:where(dialog.table-create-dialog) .table-create-data-editor {
    display: grid;
    gap: 8px;
}

:where(dialog.table-create-dialog) .table-create-data-label {
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
}

:where(dialog.table-create-dialog) .table-create-data-textarea {
    min-height: 16rem;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    line-height: 1.45;
}

:where(dialog.table-create-dialog) .table-create-data-textarea.table-create-data-drop-target {
    border-color: var(--accent);
    background: #f8fbff;
    outline: 3px solid rgba(26, 86, 219, 0.12);
}

:where(dialog.table-create-dialog) .table-create-data-note {
    color: var(--muted);
    font-size: 0.82rem;
    margin: 0;
}

:where(dialog.table-create-dialog) .table-create-data-note label,
:where(dialog.table-create-dialog) .table-create-data-note .button-as-link {
    font: inherit;
}

:where(dialog.table-create-dialog) .table-create-data-preview {
    display: grid;
    gap: 10px;
}

:where(dialog.table-create-dialog) .table-create-data-preview-summary {
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
}

:where(dialog.table-create-dialog) .table-create-data-pk-field {
    display: grid;
    grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

:where(dialog.table-create-dialog) .table-create-data-preview-table-wrap {
    border: 1px solid var(--rule);
    border-radius: 5px;
    max-height: 18rem;
    overflow: auto;
    background: #fff;
}

:where(dialog.table-create-dialog) .table-create-data-preview-table {
    border-collapse: collapse;
    font-size: 0.78rem;
    min-width: 100%;
    width: max-content;
}

:where(dialog.table-create-dialog) .table-create-data-preview-table th,
:where(dialog.table-create-dialog) .table-create-data-preview-table td {
    border-bottom: 1px solid var(--rule);
    border-right: 1px solid var(--rule);
    max-width: 18rem;
    overflow-wrap: anywhere;
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
    white-space: normal;
}

:where(dialog.table-create-dialog) .table-create-data-preview-table th {
    background: var(--paper);
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

:where(dialog.table-create-dialog) .table-create-data-preview-table tr:last-child td {
    border-bottom: none;
}

:where(dialog.table-create-dialog) .table-create-data-preview-table th:last-child,
:where(dialog.table-create-dialog) .table-create-data-preview-table td:last-child {
    border-right: none;
}

:where(dialog.table-create-dialog) .table-create-data-preview-null {
    color: var(--muted);
    font-style: italic;
}

:where(dialog.table-create-dialog) .table-create-column-list {
    display: grid;
    gap: 8px;
}

:where(dialog.table-create-dialog) .table-create-column-headings,
:where(dialog.table-create-dialog) .table-create-column-main {
    display: grid;
    grid-template-columns: 24px minmax(140px, 1.2fr) minmax(7.5rem, 0.7fr) 32px;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

:where(dialog.table-create-dialog) .table-create-column-row {
    display: grid;
    gap: 8px;
    min-width: 0;
}

:where(dialog.table-create-dialog) .table-create-column-headings {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    padding: 0 1px;
}

:where(dialog.table-create-dialog) .table-create-column-details {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    gap: 12px 16px;
    padding: 12px;
    border-left: 3px solid var(--rule);
    background: #f8fafc;
}

:where(dialog.table-create-dialog) .table-create-column-details[hidden] {
    display: none;
}

:where(dialog.table-create-dialog) .table-create-detail-field {
    display: grid;
    gap: 4px;
    min-width: 0;
}

:where(dialog.table-create-dialog) .table-create-detail-label {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
}

:where(dialog.table-create-dialog) .table-create-detail-help,
:where(dialog.table-alter-dialog) .table-alter-detail-help {
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.35;
    margin: 0;
}

:where(dialog.table-create-dialog) .table-create-detail-check {
    display: inline-flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--ink);
    font-size: 0.85rem;
    line-height: 1.35;
    min-width: 0;
    white-space: normal;
}

:where(dialog.table-create-dialog) .table-create-not-null,
:where(dialog.table-create-dialog) .table-create-primary-key,
:where(dialog.table-create-dialog) .table-create-foreign-key-field,
:where(dialog.table-create-dialog) .table-create-default-options {
    grid-column: 1 / -1;
}

:where(dialog.table-create-dialog) .table-create-default-options,
:where(dialog.table-alter-dialog) .table-alter-default-options {
    border: 1px solid var(--rule);
    border-radius: 5px;
    background: #fff;
    color: var(--ink);
    min-width: 0;
}

:where(dialog.table-create-dialog) .table-create-default-options > summary,
:where(dialog.table-alter-dialog) .table-alter-default-options > summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 0.85rem;
    padding: 8px 10px;
}

:where(dialog.table-create-dialog) .table-create-default-options > summary:focus,
:where(dialog.table-alter-dialog) .table-alter-default-options > summary:focus {
    outline: 3px solid rgba(26, 86, 219, 0.12);
    outline-offset: 1px;
}

:where(dialog.table-create-dialog) .table-create-default-grid,
:where(dialog.table-alter-dialog) .table-alter-default-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px 16px;
    padding: 0 10px 10px;
}

:where(dialog.table-create-dialog) .table-create-detail-check input {
    flex: 0 0 auto;
    margin: 0.15rem 0 0;
}

:where(dialog.table-create-dialog) .table-create-detail-check span {
    min-width: 0;
    overflow-wrap: break-word;
}

:where(dialog.table-create-dialog) .table-create-drag-handle {
    height: 32px;
    position: relative;
    width: 24px;
}

/* A larger target for fingers, reaching into the space around the handle */
:where(dialog.table-create-dialog) .table-create-drag-handle::before {
    content: "";
    position: absolute;
    inset: -6px -4px -6px -14px;
}

/* The copy of a column row that follows the pointer while it is dragged */
:where(dialog.table-create-dialog) .drag-reorder-ghost {
    box-sizing: content-box;
    margin: -6px;
    padding: 6px;
}

:where(dialog.table-create-dialog) .table-create-more-options {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
    justify-self: start;
    padding: 0;
    grid-column: 2 / -1;
    text-align: left;
}

:where(dialog.table-create-dialog) .table-create-more-options:hover,
:where(dialog.table-create-dialog) .table-create-more-options:focus {
    text-decoration: underline;
}

:where(dialog.table-create-dialog) .table-create-more-options:focus {
    outline: 3px solid rgba(26, 86, 219, 0.12);
    outline-offset: 2px;
}

:where(dialog.table-create-dialog) .table-create-more-options:disabled {
    color: var(--muted);
    cursor: default;
    text-decoration: none;
}

:where(dialog.table-create-dialog) .table-create-icon-button {
    appearance: none;
    border: 1px solid rgba(74, 85, 104, 0.24);
    background: transparent;
    color: #4a5568;
    border-radius: 4px;
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    height: 32px;
    width: 32px;
    padding: 0;
}

:where(dialog.table-create-dialog) .table-create-icon-button:hover,
:where(dialog.table-create-dialog) .table-create-icon-button:focus {
    background: rgba(74, 85, 104, 0.07);
}

:where(dialog.table-create-dialog) .table-create-icon-button:focus {
    outline: 3px solid #b3d4ff;
    outline-offset: 1px;
}

:where(dialog.table-create-dialog) .table-create-icon-button svg {
    display: block;
}

:where(dialog.table-create-dialog) .table-create-add-column {
    appearance: none;
    justify-self: start;
    border: 1px solid var(--rule);
    border-radius: 5px;
    background: #fff;
    color: var(--accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: 0.85rem;
    padding: 7px 10px;
}

:where(dialog.table-create-dialog) .table-create-add-column svg {
    display: block;
    flex: 0 0 auto;
}

:where(dialog.table-create-dialog) .table-create-add-column:hover,
:where(dialog.table-create-dialog) .table-create-add-column:focus {
    background: #f8fafc;
}

:where(dialog.table-create-dialog) .table-create-add-column:focus {
    outline: 3px solid rgba(26, 86, 219, 0.12);
    outline-offset: 1px;
}

:where(dialog.table-create-dialog) .table-create-mode-link {
    color: var(--accent);
    font-size: 0.9rem;
    margin-right: auto;
}

:where(dialog.table-create-dialog) .table-create-mode-link[hidden] {
    display: none;
}

:where(dialog).table-create-dialog .modal-btn:disabled,
:where(dialog.table-create-dialog) .table-create-add-column:disabled,
:where(dialog.table-create-dialog) .table-create-icon-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

dialog.table-alter-dialog {
    width: min(980px, calc(100vw - 32px));
    max-height: min(780px, calc(100vh - 32px));
}

:where(dialog).table-alter-dialog .modal-title {
    display: flex;
    align-items: center;
    min-width: 0;
    max-width: 100%;
}

:where(dialog.table-alter-dialog) .table-alter-form {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
}

:where(dialog.table-alter-dialog) .table-alter-error {
    border-left: 4px solid #b91c1c;
    border-radius: 4px;
    background: #fff1f1;
    color: #7f1d1d;
    font-size: 0.9rem;
    margin: 12px 24px 0;
    padding: 10px 12px;
}

:where(dialog.table-alter-dialog) .table-alter-error:focus {
    outline: 3px solid rgba(185, 28, 28, 0.18);
    outline-offset: 2px;
}

:where(dialog.table-alter-dialog) .table-alter-fields {
    display: grid;
    gap: 18px;
}

:where(dialog.table-alter-dialog) .table-alter-table-options {
    border-top: 1px solid var(--rule);
    padding-top: 12px;
}

:where(dialog.table-alter-dialog) .table-alter-table-options > summary {
    color: var(--ink);
    cursor: pointer;
    font-weight: 600;
}

:where(dialog.table-alter-dialog) .table-alter-table-options > summary:focus {
    outline: 3px solid rgba(26, 86, 219, 0.12);
    outline-offset: 3px;
}

:where(dialog.table-alter-dialog) .table-alter-table-name-field {
    display: grid;
    gap: 4px;
    margin-top: 10px;
    max-width: 24rem;
}

:where(dialog.table-alter-dialog) .table-alter-fields[hidden],
:where(dialog).table-alter-dialog .modal-footer [hidden] {
    display: none;
}

:where(dialog.table-alter-dialog) .table-alter-review {
    display: grid;
    gap: 12px;
}

:where(dialog.table-alter-dialog) .table-alter-review[hidden] {
    display: none;
}

:where(dialog.table-alter-dialog) .table-alter-review-title {
    color: var(--ink);
    font-size: 1rem;
    line-height: 1.35;
    margin: 0;
}

:where(dialog.table-alter-dialog) .table-alter-review-title:focus {
    outline: 3px solid rgba(26, 86, 219, 0.12);
    outline-offset: 2px;
}

:where(dialog.table-alter-dialog) .table-alter-review-intro {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0;
}

:where(dialog.table-alter-dialog) .table-alter-review-warning {
    border-left: 4px solid #b91c1c;
    border-radius: 4px;
    background: #fff1f1;
    color: #7f1d1d;
    font-size: 0.9rem;
    margin: 0;
    padding: 10px 12px;
}

:where(dialog.table-alter-dialog) .table-alter-review-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 1.4rem;
}

:where(dialog.table-alter-dialog) .table-alter-review-list li {
    color: var(--ink);
    line-height: 1.4;
}

:where(dialog.table-alter-dialog) .table-alter-review-damaging {
    font-weight: 600;
}

:where(dialog.table-alter-dialog) .table-alter-review-name {
    background: #eef6ff;
    border: 1px solid #c9ddf2;
    border-radius: 4px;
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
    padding: 1px 4px;
    white-space: nowrap;
}

:where(dialog.table-alter-dialog) .table-alter-columns {
    display: grid;
    gap: 10px;
}

:where(dialog.table-alter-dialog) .table-alter-column-list {
    display: grid;
    gap: 8px;
}

:where(dialog.table-alter-dialog) .table-alter-column-headings,
:where(dialog.table-alter-dialog) .table-alter-column-main {
    display: grid;
    grid-template-columns: 24px minmax(140px, 1.2fr) minmax(7.5rem, 0.7fr) 32px;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

:where(dialog.table-alter-dialog) .table-alter-column-row {
    display: grid;
    gap: 8px;
    min-width: 0;
}

:where(dialog.table-alter-dialog) .table-alter-column-headings {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    padding: 0 1px;
}

:where(dialog.table-alter-dialog) .table-alter-column-label {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

:where(dialog.table-alter-dialog) .table-alter-input {
    box-sizing: border-box;
    min-width: 0;
    min-height: 46px;
    border: 1px solid var(--rule);
    border-radius: 5px;
    padding: 8px 10px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    line-height: 1.35;
}

:where(dialog.table-alter-dialog) select.table-alter-input {
    height: 46px;
}

:where(dialog.table-alter-dialog) .table-alter-input-placeholder {
    color: var(--muted);
}

:where(dialog.table-alter-dialog) .table-alter-default-expr option,
:where(dialog.table-alter-dialog) .table-alter-custom-column-type option,
:where(dialog.table-alter-dialog) .table-alter-foreign-key-target option {
    color: var(--ink);
}

:where(dialog.table-alter-dialog) .table-alter-default-expr option[value=""],
:where(dialog.table-alter-dialog) .table-alter-custom-column-type option[value=""],
:where(dialog.table-alter-dialog) .table-alter-foreign-key-target option[value=""] {
    color: var(--muted);
}

:where(dialog.table-alter-dialog) .table-alter-input:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(26, 86, 219, 0.12);
}

:where(dialog.table-alter-dialog) .table-alter-column-details {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    gap: 12px 16px;
    padding: 12px;
    border-left: 3px solid var(--rule);
    background: #f8fafc;
}

:where(dialog.table-alter-dialog) .table-alter-column-details[hidden] {
    display: none;
}

:where(dialog.table-alter-dialog) .table-alter-detail-field {
    display: grid;
    gap: 4px;
    min-width: 0;
}

:where(dialog.table-alter-dialog) .table-alter-detail-label {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
}

:where(dialog.table-alter-dialog) .table-alter-detail-check {
    display: inline-flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--ink);
    font-size: 0.85rem;
    line-height: 1.35;
    min-width: 0;
    white-space: normal;
}

:where(dialog.table-alter-dialog) .table-alter-not-null,
:where(dialog.table-alter-dialog) .table-alter-primary-key,
:where(dialog.table-alter-dialog) .table-alter-foreign-key-field,
:where(dialog.table-alter-dialog) .table-alter-default-options {
    grid-column: 1 / -1;
}

:where(dialog.table-alter-dialog) .table-alter-detail-check input {
    flex: 0 0 auto;
    margin: 0.15rem 0 0;
}

:where(dialog.table-alter-dialog) .table-alter-detail-check span {
    min-width: 0;
    overflow-wrap: break-word;
}

:where(dialog.table-alter-dialog) .table-alter-drag-handle {
    height: 32px;
    position: relative;
    width: 24px;
}

/* A larger target for fingers, reaching into the space around the handle */
:where(dialog.table-alter-dialog) .table-alter-drag-handle::before {
    content: "";
    position: absolute;
    inset: -6px -4px -6px -14px;
}

/* The copy of a column row that follows the pointer while it is dragged */
:where(dialog.table-alter-dialog) .drag-reorder-ghost {
    box-sizing: content-box;
    margin: -6px;
    padding: 6px;
}

:where(dialog.table-alter-dialog) .table-alter-more-options {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
    justify-self: start;
    padding: 0;
    grid-column: 2 / -1;
    text-align: left;
}

:where(dialog.table-alter-dialog) .table-alter-more-options:hover,
:where(dialog.table-alter-dialog) .table-alter-more-options:focus {
    text-decoration: underline;
}

:where(dialog.table-alter-dialog) .table-alter-more-options:focus {
    outline: 3px solid rgba(26, 86, 219, 0.12);
    outline-offset: 2px;
}

:where(dialog.table-alter-dialog) .table-alter-more-options:disabled {
    color: var(--muted);
    cursor: default;
    text-decoration: none;
}

:where(dialog.table-alter-dialog) .table-alter-icon-button {
    appearance: none;
    border: 1px solid rgba(74, 85, 104, 0.24);
    background: transparent;
    color: #4a5568;
    border-radius: 4px;
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    height: 32px;
    width: 32px;
    padding: 0;
}

:where(dialog.table-alter-dialog) .table-alter-icon-button:hover,
:where(dialog.table-alter-dialog) .table-alter-icon-button:focus {
    background: rgba(74, 85, 104, 0.07);
}

:where(dialog.table-alter-dialog) .table-alter-icon-button:focus {
    outline: 3px solid #b3d4ff;
    outline-offset: 1px;
}

:where(dialog.table-alter-dialog) .table-alter-icon-button svg {
    display: block;
}

:where(dialog.table-alter-dialog) .table-alter-add-column {
    appearance: none;
    justify-self: start;
    border: 1px solid var(--rule);
    border-radius: 5px;
    background: #fff;
    color: var(--accent);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: 0.85rem;
    padding: 7px 10px;
}

:where(dialog.table-alter-dialog) .table-alter-add-column svg {
    display: block;
    flex: 0 0 auto;
}

:where(dialog.table-alter-dialog) .table-alter-add-column:hover,
:where(dialog.table-alter-dialog) .table-alter-add-column:focus {
    background: #f8fafc;
}

:where(dialog.table-alter-dialog) .table-alter-add-column:focus {
    outline: 3px solid rgba(26, 86, 219, 0.12);
    outline-offset: 1px;
}

:where(dialog).table-alter-dialog .modal-btn-danger {
    background: #b91c1c;
    color: #fff;
    margin-right: auto;
}

:where(dialog).table-alter-dialog .table-alter-drop-confirm {
    margin-right: 0;
}

:where(dialog).table-alter-dialog .modal-btn-danger:hover {
    background: #991b1b;
}

:where(dialog).table-alter-dialog .modal-btn-danger:disabled,
:where(dialog).table-alter-dialog .modal-btn-danger:disabled:hover {
    background: #d98c8c;
    color: #fff;
}

:where(dialog).table-alter-dialog .modal-btn-primary:disabled,
:where(dialog).table-alter-dialog .modal-btn-primary:disabled:hover {
    background: #a0aec0;
    color: #fff;
}

:where(dialog).table-alter-dialog .modal-btn:disabled,
:where(dialog.table-alter-dialog) .table-alter-add-column:disabled,
:where(dialog.table-alter-dialog) .table-alter-icon-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 900px) {
    dialog.table-alter-dialog {
        width: 95vw;
        max-height: 85vh;
        border-radius: 0.5rem;
    }

    :where(dialog).table-alter-dialog .modal-header,
    :where(dialog.table-alter-dialog) .table-alter-fields,
    :where(dialog.table-alter-dialog) .table-alter-review {
        padding-left: 18px;
        padding-right: 18px;
    }

    :where(dialog.table-alter-dialog) .table-alter-error {
        margin-left: 18px;
        margin-right: 18px;
    }

    :where(dialog.table-alter-dialog) .table-alter-column-headings {
        display: none;
    }

    :where(dialog.table-alter-dialog) .table-alter-column-row {
        padding-bottom: 8px;
        border-bottom: 1px solid var(--rule);
    }

    :where(dialog.table-alter-dialog) .drag-reorder-ghost .table-alter-column-row {
        padding-bottom: 0;
        border-bottom: 0;
    }

    :where(dialog.table-alter-dialog) .table-alter-column-main {
        grid-template-columns: 24px minmax(0, 1fr) minmax(7.5rem, 0.8fr) 32px;
    }

    :where(dialog.table-alter-dialog) .table-alter-column-details {
        grid-template-columns: 1fr;
    }

    :where(dialog.table-alter-dialog) .table-alter-default-grid {
        grid-template-columns: 1fr;
    }

    :where(dialog).table-alter-dialog .modal-footer {
        padding-left: 18px;
        padding-right: 18px;
    }
}

.row-link-with-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.row-inline-actions {
    display: inline-flex;
    gap: 0.2rem;
    align-items: center;
}

.row-inline-action {
    appearance: none;
    border: 1px solid rgba(74, 85, 104, 0.24);
    background: transparent;
    color: #4a5568;
    border-radius: 4px;
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    min-height: 24px;
    min-width: 24px;
    padding: 2px;
    position: relative;
}

.row-inline-action:hover,
.row-inline-action:focus {
    background: rgba(74, 85, 104, 0.07);
}

.row-inline-action:focus {
    outline: 3px solid #b3d4ff;
    outline-offset: 1px;
}

.row-inline-action-icon {
    display: block;
    height: 13px;
    width: 13px;
}

@media (max-width: 640px) {
    dialog.mobile-column-actions-dialog {
        width: 95vw;
        max-height: 85vh;
        border-radius: 0.5rem;
    }

    .mobile-column-actions-dialog .modal-header {
        padding: 16px 18px 14px;
    }

    .mobile-column-top-actions {
        padding-left: 18px;
        padding-right: 18px;
    }

    .mobile-column-actions-dialog .col-header {
        padding-left: 18px;
        padding-right: 18px;
    }

    .mobile-column-actions-dialog .col-actions a,
    .mobile-column-actions-dialog .col-actions button {
        padding-left: 34px;
        padding-right: 18px;
    }

    .mobile-column-description,
    .mobile-column-no-actions {
        padding-left: 18px;
        padding-right: 18px;
    }

    dialog.set-column-type-dialog {
        width: 95vw;
        max-height: 85vh;
        border-radius: 0.5rem;
    }

    .set-column-type-dialog .modal-header,
    .set-column-type-status,
    .set-column-type-empty,
    .set-column-type-error,
    .set-column-type-options {
        padding-left: 18px;
        padding-right: 18px;
    }

    /* Nearly the screen's full height: the body scrolls, and the more of
       it that shows, the less there is to scroll past to reach the
       options */
    dialog.row-delete-dialog {
        width: 95vw;
        max-height: calc(100dvh - 24px);
        border-radius: 0.5rem;
    }

    .row-delete-dialog .modal-header,
    .row-delete-message,
    .row-delete-options-intro,
    .row-delete-links-option,
    .row-delete-error {
        padding-left: 18px;
        padding-right: 18px;
    }

    .row-delete-dialog .modal-footer {
        padding-left: 18px;
        padding-right: 18px;
    }

    .row-delete-dialog .modal-footer .modal-btn {
        flex: 1 1 auto;
    }

    dialog.row-edit-dialog {
        width: 95vw;
        max-height: 85vh;
        border-radius: 0.5rem;
    }

    .row-edit-dialog .modal-header,
    .row-edit-summary,
    .row-edit-loading,
    .row-edit-fields,
    .row-edit-bulk {
        padding-left: 18px;
        padding-right: 18px;
    }

    .row-edit-error {
        margin-left: 18px;
        margin-right: 18px;
    }

    .row-edit-field {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .row-edit-label {
        padding-top: 0;
    }

    .row-edit-bulk-conflict {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .row-edit-bulk-conflict-label {
        padding-top: 0;
    }

    .row-edit-dialog .modal-footer {
        padding-left: 18px;
        padding-right: 18px;
    }

    dialog.table-create-dialog {
        width: 95vw;
        max-height: 85vh;
        border-radius: 0.5rem;
    }

    :where(dialog).table-create-dialog .modal-header,
    :where(dialog.table-create-dialog) .table-create-fields {
        padding-left: 18px;
        padding-right: 18px;
    }

    :where(dialog.table-create-dialog) .table-create-error {
        margin-left: 18px;
        margin-right: 18px;
    }

    :where(dialog.table-create-dialog) .table-create-field {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    :where(dialog.table-create-dialog) .table-create-label {
        padding-top: 0;
    }

    :where(dialog.table-create-dialog) .table-create-data-pk-field {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    :where(dialog.table-create-dialog) .table-create-column-headings {
        display: none;
    }

    :where(dialog.table-create-dialog) .table-create-column-row {
        padding-bottom: 8px;
        border-bottom: 1px solid var(--rule);
    }

    :where(dialog.table-create-dialog) .drag-reorder-ghost .table-create-column-row {
        padding-bottom: 0;
        border-bottom: 0;
    }

    :where(dialog.table-create-dialog) .table-create-column-main {
        grid-template-columns: 24px minmax(0, 1fr) minmax(7.5rem, 0.8fr) 32px;
    }

    :where(dialog.table-create-dialog) .table-create-column-details {
        grid-template-columns: 1fr;
    }

    :where(dialog.table-create-dialog) .table-create-default-grid {
        grid-template-columns: 1fr;
    }

    :where(dialog).table-create-dialog .modal-footer {
        padding-left: 18px;
        padding-right: 18px;
    }

    .row-inline-action {
        min-height: 30px;
        min-width: 30px;
        padding: 4px;
    }

    .row-inline-action-icon {
        height: 14px;
        width: 14px;
    }
}

@media only screen and (max-width: 576px) {

    .small-screen-only {
        display: initial;
    }
    .select-wrapper.small-screen-only {
        display: inline-block;
    }

    form.sql textarea {
        width: 95%;
    }
    /* Force table to not be like tables anymore */
    table.rows-and-columns,
    .rows-and-columns thead,
    .rows-and-columns tbody,
    .rows-and-columns th,
    .rows-and-columns td,
    .rows-and-columns tr {
        display: block;
    }

    /* Hide table headers (but not display: none;, for accessibility) */
    .rows-and-columns thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* Each row is a card in the same tokens as the desktop table. It opens
       with its first field on a --paper band, like a modal header; labels
       sit above values in the column menu's slate. */
    table.rows-and-columns {
        font-size: 0.9375rem;
        line-height: 1.4;
    }

    table.rows-and-columns tr {
        margin: 0 0 0.75rem;
        padding: 0;
        overflow: hidden;
        border: 1px solid var(--rule);
        border-radius: 8px;
        background: var(--card);
        box-shadow: 0 1px 2px rgba(15, 40, 70, 0.04);
    }

    table.rows-and-columns td {
        /* Behave like a "row" */
        padding: 0.45rem 0.75rem 0.5rem;
        border: 0;
        border-top: 1px solid var(--rule);
    }

    table.rows-and-columns td:first-child {
        border-top: 0;
        background: var(--paper);
    }

    table.rows-and-columns td:before {
        display: block;
        margin: 0 0 1px;
        color: var(--slate);
        font-size: 0.75rem;
        font-weight: 600;
        line-height: 1.4;
    }

    .row-inline-actions {
        margin-bottom: 0.35rem;
    }

    .filters {
        max-width: none;
        padding: 0.65rem;
    }
    .filters .search-row {
        grid-template-columns: max-content minmax(0, 1fr);
        padding-right: 0;
    }
    .filters .filter-controls-row {
        --filter-value-button-space: 0px;
        --filter-remove-button-offset: 0px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .filters .filter-controls-row-one-button {
        --filter-value-button-space: calc(
            var(--filter-row-icon-size) + var(--filter-control-gap)
        );
    }
    .filters .filter-controls-row-two-buttons {
        --filter-value-button-space: var(--filter-two-icon-space);
        --filter-remove-button-offset: calc(
            var(--filter-row-icon-size) + var(--filter-control-gap)
        );
    }
    .filters .filter-controls-row .select-wrapper {
        grid-row: 1;
        grid-column: 1 / 2;
    }
    .filters .filter-controls-row .select-wrapper.filter-op {
        grid-column: 2 / 3;
    }
    .filters input.filter-value {
        grid-row: 2;
        grid-column: 1 / 3;
        justify-self: start;
        width: calc(100% - var(--filter-value-button-space));
    }
    .filters datasette-autocomplete.filter-value-autocomplete {
        grid-row: 2;
        grid-column: 1 / 3;
        justify-self: start;
        width: calc(100% - var(--filter-value-button-space));
    }
    .filters datasette-autocomplete.filter-value-autocomplete input.filter-value {
        width: 100%;
    }
    .filters .filter-value-error {
        grid-row: 3;
    }
    .filters button.filter-row-icon {
        grid-row: 2;
        grid-column: 1 / 3;
        justify-self: end;
    }
    .filters .filter-controls-row-two-buttons button.filter-row-remove:not([hidden]) {
        margin-right: var(--filter-remove-button-offset);
    }
    .filters .filter-actions-row {
        justify-content: flex-start;
    }
    .filters .filter-actions-row input[type=submit] {
        flex: 0 1 auto;
    }
    button.table-insert-row,
    button.column-actions-mobile {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem 1rem;
        margin-bottom: 1em;
        font-size: 0.9rem;
        line-height: 1.2;
        font-family: inherit;
        background: white;
        border: 1px solid #ccc;
        border-radius: 5px;
        cursor: pointer;
        vertical-align: top;
        box-sizing: border-box;
        min-height: 2.5rem;
    }

    button.column-actions-mobile {
        gap: 0.55rem;
    }

    button.column-actions-mobile svg {
        display: block;
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    button.column-actions-mobile span {
        line-height: 1.2;
    }

    :where(div).table-row-toolbar {
        margin-bottom: 0.75rem;
    }

    button.table-insert-row {
        width: 100%;
        margin-bottom: 0;
    }
}

.stored-query-edit-sql {
    padding-left: 0.5em;
    position: relative;
    top: 1px;
}
.save-query {
    display: inline-block;
    margin-left: 0.45em;
}

.blob-download {
    display: block;
    white-space: nowrap;
    padding-right: 20px;
    position: relative;
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNiAxNiIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2Ij48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03LjQ3IDEwLjc4YS43NS43NSAwIDAwMS4wNiAwbDMuNzUtMy43NWEuNzUuNzUgMCAwMC0xLjA2LTEuMDZMOC43NSA4LjQ0VjEuNzVhLjc1Ljc1IDAgMDAtMS41IDB2Ni42OUw0Ljc4IDUuOTdhLjc1Ljc1IDAgMDAtMS4wNiAxLjA2bDMuNzUgMy43NXpNMy43NSAxM2EuNzUuNzUgMCAwMDAgMS41aDguNWEuNzUuNzUgMCAwMDAtMS41aC04LjV6Ij48L3BhdGg+PC9zdmc+");
    background-size: 16px 16px;
    background-position: right;
    background-repeat: no-repeat;
}

dl.column-descriptions dt {
    font-weight: bold;
}
dl.column-descriptions dd {
    padding-left: 1.5em;
    white-space: pre-wrap;
    line-height: 1.1em;
    color: #666;
}

/* Shared app, resource and column menus */
.page-action-menu {
    position: relative;
    margin-bottom: 0.5em;
}
.actions-menu-links {
    display: inline;
}
/* The "Table actions" / "Row actions" trigger shares its box with
   .quiet-button (height, border, font size, line height, radius, icon gap)
   so the two line up exactly when they sit side by side. */
.page-action-menu .icon-text {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    box-sizing: border-box;
    min-height: 1.75rem;
    padding: 0.2rem 0.6rem 0.2rem 0.5rem;
    border: 1px solid var(--accent, #1a56db);
    border-radius: 5px;
    color: #fff;
    font-weight: 400;
    font-size: 0.875rem;
    line-height: 1.2;
    background: var(--accent, #1a56db);
}
.page-action-menu .icon-text:hover {
    cursor: pointer;
}
.page-action-menu .icon {
    display: block;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

header.app-header {
    padding-top: 0;
    padding-right: 4px;
    padding-bottom: 0;
}
.app-header > nav {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 0;
    min-height: 2.6rem;
}
header.app-header .crumbs {
    flex: 1;
    min-width: 0;
    margin-right: 8px;
    overflow-wrap: anywhere;
    /* Breathing room and tighter leading when crumbs wrap to multiple lines */
    padding: 0.65rem 0;
    line-height: 1.3;
}
header.app-header .actor {
    /* Same box as a single crumbs line so it lines up with the first row */
    padding: 0.65rem 0;
    line-height: 1.3;
    order: 1;
    text-align: right;
    overflow-wrap: anywhere;
}
.app-header details.nav-menu {
    order: 2;
    flex-shrink: 0;
}
.app-header details.nav-menu > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    list-style: none;
    cursor: pointer;
    box-sizing: border-box;
    width: 44px;
    height: 2.6rem;
    border-radius: 6px;
}
.app-header details.nav-menu > summary::-webkit-details-marker {
    display: none;
}
.app-header details.nav-menu > summary:hover {
    background: #ffffff20;
}
.app-header details.nav-menu > summary[aria-expanded="true"] {
    background: transparent;
}
.page-action-menu .datasette-menu-trigger {
    display: inline-flex;
    /* Top-aligned so the inline <details> adds no space below the
       baseline, keeping the menu exactly the trigger's height */
    vertical-align: top;
    border-radius: 5px;
}
button.column-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    min-height: 24px;
    padding: 0;
    margin: 2px 0 4px 4px;
    vertical-align: middle;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #24465d;
    cursor: pointer;
}
button.column-menu-trigger:hover,
button.column-menu-trigger[aria-expanded="true"] {
    background: #e2ebf1;
}
.column-menu-trigger svg {
    display: block;
    opacity: 0.8;
    width: 16px;
    height: 16px;
}
.datasette-menu {
    --menu-ink: #203748;
    --menu-muted: #536978;
    --menu-line: #dce5eb;
    --menu-hover: #edf3f7;
    position: absolute;
    z-index: 1000;
    box-sizing: border-box;
    width: 300px;
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    margin: 0;
    padding: 6px;
    border: 1px solid var(--menu-line);
    border-radius: 12px;
    background: #fff;
    color: var(--menu-ink);
    font-size: 15px;
    line-height: 1.4;
    box-shadow: 0 8px 28px #18384d1a, 0 2px 6px #18384d0d;
    overflow: auto;
    overscroll-behavior: contain;
}
.datasette-menu.nav-menu-inner {
    --menu-ink: #fff;
    --menu-muted: #d0e4f1;
    --menu-line: #ffffff30;
    --menu-hover: #ffffff18;
    background: #276890;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}
.datasette-menu.datasette-menu-floating {
    position: fixed;
    inset: auto;
    max-width: none;
    z-index: 20000;
}
.datasette-menu[hidden] {
    display: none;
}
.datasette-menu ul,
.datasette-menu li {
    margin: 0;
    padding: 0;
    border: 0;
    list-style: none;
}
.datasette-menu .datasette-menu-heading {
    position: relative;
    padding: 10px 12px 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--menu-line);
    overflow-wrap: anywhere;
}
.datasette-menu-heading strong {
    display: block;
    font-size: 15px;
}
.datasette-menu-heading small {
    display: block;
    margin-top: 2px;
    color: var(--menu-muted);
    font-size: 12px;
}
.datasette-menu :is(a, button.button-as-link) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 8px;
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 0;
    border-radius: 6px;
    color: var(--menu-ink);
    font: inherit;
    line-height: 1.4;
    text-align: left;
    text-decoration: none;
    white-space: normal;
    overflow-wrap: anywhere;
    background: transparent;
    cursor: pointer;
}
.datasette-menu :is(a, button.button-as-link):hover,
.datasette-menu :is(a, button.button-as-link):focus-visible {
    background: var(--menu-hover);
}
.datasette-menu.nav-menu-inner :is(a, button.button-as-link) {
    color: var(--menu-ink);
    min-height: 36px;
    padding-top: 6px;
    padding-bottom: 6px;
}
:is(.datasette-menu-trigger, .column-menu-trigger, .datasette-menu a, .datasette-menu button):focus-visible {
    outline: 2px solid #598fce;
    outline-offset: -2px;
}
.app-header .nav-menu :is(summary, a, button):focus-visible {
    outline: 2px solid #c3e5ff;
    outline-offset: -2px;
}
.datasette-menu .dropdown-description {
    display: block;
    flex-basis: 100%;
    color: var(--menu-muted);
    font-size: 12px;
    line-height: 1.5;
}
.datasette-menu .keyboard-shortcut {
    box-sizing: border-box;
    min-width: 1.4em;
    margin-left: auto;
    padding: 0 0.35em;
    border: 1px solid rgba(255,255,244,0.6);
    border-radius: 3px;
    background: rgba(255,255,244,0.12);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
    line-height: 1.35;
    text-align: center;
    text-decoration: none;
}
.datasette-menu .nav-menu-logout,
.datasette-menu li.menu-separator {
    margin: 4px 0 0;
    padding: 4px 0 0;
    border-top: 1px solid var(--menu-line);
}
.datasette-menu .dropdown-column-description {
    margin: 0;
    padding: 8px 12px;
    color: var(--menu-muted);
    font-size: 14px;
    overflow-wrap: anywhere;
}
.column-actions-menu.datasette-menu .datasette-menu-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
    padding: 8px 10px;
}
.column-actions-menu.datasette-menu .datasette-menu-heading strong {
    min-width: 0;
}
.datasette-menu .dropdown-column-type {
    margin-left: auto;
    color: var(--menu-muted);
    font-size: 12px;
    white-space: nowrap;
}
.column-actions-menu.datasette-menu :is(a, button.button-as-link) {
    min-height: 38px;
    padding: 7px 10px;
}
.column-actions-menu.datasette-menu .dropdown-column-description {
    padding: 6px 10px;
}
@media (pointer: coarse), (max-width: 600px) {
    .app-header details.nav-menu > summary {
        width: 48px;
    }
    .datasette-menu :is(a, button.button-as-link) {
        min-height: 48px;
    }
    .datasette-menu.nav-menu-inner :is(a, button.button-as-link) {
        min-height: 44px;
    }
    .column-actions-menu.datasette-menu :is(a, button.button-as-link) {
        min-height: 44px;
    }
    .datasette-menu .keyboard-shortcut {
        display: none;
    }
}

@media (max-width: 600px) {
    .datasette-menu.nav-menu-inner.datasette-menu-floating {
        width: max-content;
        min-width: min(14rem, calc(100vw - 24px));
        max-width: min(18rem, calc(100vw - 24px));
    }
}

/* Mobile Safari zooms the page when a text input, select or textarea with
   a font-size smaller than 16px receives focus. Bump the controls that use
   a smaller size up to 16px on touch devices. */
@media (pointer: coarse) {
    .filters {
        /* Taller filter controls so the 16px text fits */
        --filter-control-height: 2.5rem;
    }
    .select-wrapper select,
    .filters input.filter-value,
    .filters #_search,
    textarea.row-edit-input,
    .row-edit-bulk-textarea,
    :where(dialog.table-create-dialog) .table-create-data-textarea,
    :where(dialog.table-create-dialog) .table-create-data-preview-column-name,
    :where(dialog.table-create-dialog) .table-create-data-preview-type,
    datasette-autocomplete input[type="text"],
    .set-label-column-select,
    .set-label-column-template {
        font-size: 16px;
    }
}

/* Row page: one field per line, name on the left and value on the right.
   Stacks name above value on narrow screens. See _row_fields.html. */
.row-heading-label {
    display: block;
    margin-top: 0.15rem;
    font-size: 1.05rem;
    font-weight: 500;
    color: #536978;
}

/* Row actions menu and Export data button side by side */
.row-page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
}
/* Flex all the way down so the menu trigger is never laid out on a text
   line (which browsers snap to whole pixels differently from flex items)
   and lines up exactly with the Export data button beside it */
.row-page-actions .page-action-menu,
.row-page-actions .actions-menu-links,
.row-page-actions .datasette-menu-trigger {
    display: flex;
}
.row-page-actions .page-action-menu {
    margin-bottom: 0;
}

/* After a row's many-to-many relationships: the tables that have no rows
   pointing at it */
.row-m2m-empty-references {
    margin: 0;
    padding: 0.5rem 0 0;
    border-top: 1px solid #d8e6f5;
    color: #6b6b6b;
    font-size: 0.8125rem;
    line-height: 1.7;
}

.row-fields {
    --rule: #d8e6f5;
    --muted: #6b6b6b;
    --link: #276890;
    --link-visited: #2d7a62;
    --accent: #1a56db;
    box-sizing: border-box;
    max-width: 60rem;
    margin: 0 0 1.5rem;
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 40, 70, 0.04);
    font-variant-numeric: tabular-nums;
}
.row-field {
    display: grid;
    grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr);
    gap: 0.25rem 1.25rem;
    padding: 0.55rem 0.85rem;
    border-top: 1px solid var(--rule);
}
.row-field:first-child {
    border-top: none;
}
.row-field:hover {
    background: rgba(0, 110, 255, 0.03);
}
.row-field dt {
    margin: 0;
    min-width: 0;
}
.row-field-name {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: #536978;
    overflow-wrap: break-word;
}
.row-field-description {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.75rem;
    color: var(--muted);
}
.row-field dd {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0;
    min-width: 0;
}
.row-field-value,
.row-field-long {
    flex: 1 1 auto;
    min-width: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.row-field[data-is-pk] .row-field-value {
    font-weight: 600;
}
.row-field-value em {
    color: var(--muted);
    font-size: 0.8125em;
    font-style: normal;
}
.row-field-value a:link {
    color: var(--link);
    text-decoration: none;
}
.row-field-value a:visited {
    color: var(--link-visited);
    text-decoration: none;
}
.row-field-value a:hover {
    text-decoration: underline;
}
.row-field-empty {
    flex: 1 1 auto;
    color: var(--muted);
    font-size: 0.8125rem;
    font-style: italic;
    user-select: none;
    -webkit-user-select: none;
}
/* Generated content is never included when the page is copied */
.row-field-empty::before {
    content: attr(data-label);
}

/* Long values show the first few lines, with a toggle to reveal the rest */
.row-field-long:not(.is-expanded) > .row-field-value {
    max-height: 6lh;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(#000 calc(100% - 2lh), transparent);
    mask-image: linear-gradient(#000 calc(100% - 2lh), transparent);
}
/* row-fields.js adds .fits when the whole value is visible within the clamp */
.row-field-long.fits > .row-field-value {
    -webkit-mask-image: none;
    mask-image: none;
}
.row-field-long.fits > .row-field-expand {
    display: none;
}
/* row-fields.js adds .is-rich when the value holds more than text, such as a
   map drawn by a plugin: show all of it, and drop the toggle */
.row-field-long.is-rich {
    white-space: normal;
}
.row-field-long.is-rich > .row-field-value {
    max-height: none;
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
}
.row-field-long.is-rich > .row-field-expand {
    display: none;
}
.row-field-expand {
    margin-top: 0.35rem;
    padding: 0;
    border: none;
    background: none;
    color: var(--link);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}
.row-field-expand:hover {
    text-decoration: underline;
}
/* Generated content, like the null labels, so it is never copied */
.row-field-expand {
    user-select: none;
    -webkit-user-select: none;
}
.row-field-expand::before {
    content: attr(data-label);
}

/* Copy button, plus the JSON toggle row-fields.js adds beneath it */
.row-field-actions {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin: -0.2rem -0.3rem -0.2rem 0;
}
.row-field-json {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    color: var(--muted);
    cursor: pointer;
    transition: opacity 0.12s, background-color 0.12s, color 0.12s;
}
/* Quiet until the field is hovered or the button focused */
.row-field datasette-copy-button > button,
.row-field-json {
    opacity: 0.35;
}
.row-field:hover datasette-copy-button > button,
.row-field datasette-copy-button > button:focus-visible,
.row-field datasette-copy-button[copied] > button,
.row-field:hover .row-field-json,
.row-field-json:focus-visible,
.row-field-json[aria-pressed="true"] {
    opacity: 1;
}
.row-field-json:hover,
.row-field-json[aria-pressed="true"] {
    background: #eef6ff;
    border-color: var(--rule);
    color: var(--accent);
}
.row-field-json:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.row-field-value.is-json-pretty {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
}

@media (hover: none) {
    .row-field datasette-copy-button > button,
    .row-field-json {
        opacity: 0.7;
    }
}

/* Narrow screens: match the stacked cards of the table page exactly (see
   the max-width: 576px block under Overrides), with the copy button tucked
   into the label line so values get the same width as on the table page. */
@media (max-width: 576px) {
    .row-fields {
        max-width: none;
        margin-bottom: 0.75rem;
        overflow: hidden;
        color: #0f0f0f;
        font-size: 0.9375rem;
        line-height: 1.4;
    }
    .row-field {
        display: block;
        position: relative;
        padding: 0.45rem 0.75rem 0.5rem;
    }
    .row-field:hover {
        background: none;
    }
    .row-field:first-child {
        background: #eef6ff;
    }
    .row-field dt {
        margin: 0 0 1px;
        padding-right: 1.75rem;
    }
    .row-field-name {
        font-size: 0.75rem;
        line-height: 1.4;
    }
    .row-field dd {
        display: block;
    }
    /* Side by side in the label line, rather than stacked */
    .row-field-actions {
        position: absolute;
        top: 0.2rem;
        right: 0.35rem;
        flex-direction: row;
        margin: 0;
    }
    .row-field:has(.row-field-json) dt {
        padding-right: 3.75rem;
    }
}

/* Homepage: a catalog of every table, view and query in the instance */
.homepage {
    --ink: #0f0f0f;
    --paper: #eef6ff;
    --muted: #6b6b6b;
    --rule: #d8e6f5;
    --accent: #1a56db;
    --accent-light: #e8effd;
    --card: #ffffff;
    --shadow: rgba(30, 64, 110, 0.08);
    max-width: 60rem;
    color: var(--ink);
}
.homepage .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.homepage-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-top: 1rem;
}
.homepage-header h1 {
    margin: 0;
    font-size: 2rem;
}
.homepage-header .page-action-menu {
    margin: 0;
}
.homepage .metadata-description {
    margin-top: 0.5rem;
    max-width: 44rem;
}
.homepage-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0;
    margin: 0.5rem 0 1rem;
    color: var(--muted);
    font-size: 0.9375rem;
    font-variant-numeric: tabular-nums;
}
.homepage-summary span + span::before {
    content: "·";
    margin: 0 0.5em;
}

/* Search */
.homepage-search {
    position: relative;
    display: flex;
    gap: 0.5rem;
    margin: 0 0 1rem;
}
.homepage-search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.homepage-search input[type="search"] {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    height: 2.75rem;
    padding: 0 0.85rem 0 2.6rem;
    border: 1px solid #bfccd9;
    border-radius: 0.5rem;
    background: var(--card);
    font: inherit;
    font-size: 1rem;
    box-shadow: 0 1px 2px var(--shadow);
}
.homepage-search input[type="search"]:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(26, 86, 219, 0.2);
    outline-offset: 0;
}
.homepage-search-button {
    flex: none;
    height: 2.75rem;
    padding: 0 1.1rem;
    border: 0;
    border-radius: 0.5rem;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.homepage-search-button:hover {
    background: #1949b8;
}
.homepage-sections:empty {
    display: none;
}
.homepage-sections {
    margin: 0 0 1rem;
}

/* Database filter */
.homepage-databases {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 1.25rem;
    font-size: 0.875rem;
}
.homepage-database {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 1.875rem;
    padding: 0.15rem 0.65rem;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--card);
    color: var(--ink);
    text-decoration: none;
}
.homepage-database:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.homepage-database.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}
.homepage-database-count {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.homepage-database.selected .homepage-database-count {
    color: rgba(255, 255, 255, 0.8);
}
:where(span).db-swatch {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 2px;
    background: var(--db-color, #999);
}
.homepage-database-open {
    margin-left: 0.25rem;
    font-weight: 600;
}

/* Section headings */
.homepage-queries h2,
.homepage-tables h2 {
    margin: 0 0 0.6rem;
    font-size: 1.125rem;
}
.homepage-queries {
    margin-bottom: 1.5rem;
}

/* Small tags */
:where(span).db-tag,
.type-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25rem;
    white-space: nowrap;
}
:where(span).db-tag {
    color: var(--muted);
    background: #f3f5f8;
}
:where(span).db-tag::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 2px;
    background: var(--db-color, #999);
}
.type-tag-view {
    color: #6b3fa0;
    background: #f3ecfb;
}
.type-tag-write {
    color: #9a3412;
    background: #fff1e6;
}

/* Queries */
:where(.homepage) .query-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    gap: 0.6rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
:where(.homepage) .query-card {
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--rule);
    border-radius: 0.5rem;
    background: var(--card);
}
:where(.homepage) .query-card-name {
    font-weight: 600;
}
:where(.homepage) .query-card-description,
:where(.homepage) .query-card-params {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.875rem;
}
:where(.homepage) .query-card-sql {
    display: block;
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tables and views: a column of cards, one per table, each a single link
   to its table. One column, so the order reads straight down the page.
   _catalog_cards.html, used by the homepage and database page. */
ul.catalog-list {
    display: grid;
    gap: 0.6rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.catalog-item {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0.7rem 0.85rem 0.75rem;
    border: 1px solid var(--rule);
    border-radius: 8px;
    background: var(--card);
    box-shadow: 0 1px 2px rgba(15, 40, 70, 0.04);
}
.catalog-item:hover {
    border-color: #a9c1ec;
}
.catalog-item-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.5rem;
}
.catalog-item-name {
    font-size: 1rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}
/* The whole card is the link */
.catalog-item-name::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}
.catalog-item-name:focus-visible {
    outline: none;
}
.catalog-item-name:focus-visible::after {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.type-tag-hidden {
    color: #4b5563;
    background: #eef0f3;
}
.catalog-item-count {
    margin-left: auto;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.catalog-item-description {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
}
.catalog-item-columns {
    margin: 0.4rem 0 0;
    color: #536978;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8125rem;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
.catalog-column-more {
    color: var(--muted);
    font-family: system-ui, -apple-system, sans-serif;
    white-space: nowrap;
}
/* "+N more" as a button: shows the rest of the columns in the card. It
   sits above the card's own link. */
button.catalog-column-more {
    position: relative;
    z-index: 1;
    margin: 0;
    padding: 0 0.15rem;
    border: 0;
    border-radius: 3px;
    background: none;
    color: var(--accent);
    font-size: inherit;
    line-height: inherit;
    cursor: pointer;
}
button.catalog-column-more:hover {
    text-decoration: underline;
}
button.catalog-column-more:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.catalog-item-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0.45rem 0 0;
    color: var(--muted);
    font-size: 0.8125rem;
}
.catalog-item-meta > span + span::before {
    content: "·";
    margin: 0 0.45em;
}
.catalog-item-meta .db-tag {
    padding: 0;
    background: none;
    font-size: inherit;
    font-weight: 400;
    line-height: inherit;
}
/* Above the card's own link, so the linked tables can be followed */
.catalog-item-links {
    position: relative;
    z-index: 1;
}
.homepage .catalog-item-links a,
.homepage .catalog-item-links a:visited {
    color: #1d4f7a;
    text-decoration: none;
}
.homepage .catalog-item-links a:hover,
.homepage .catalog-item-links a:focus-visible {
    color: var(--accent);
    text-decoration: underline;
}
.homepage-empty,
.homepage-more {
    color: var(--muted);
}
.homepage-more {
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
}
@media (max-width: 600px) {
    .homepage-search-button {
        display: none;
    }
}
.homepage a.homepage-database,
.homepage a.homepage-database:visited,
.homepage a.homepage-database:hover {
    color: var(--ink);
    text-decoration: none;
}
.homepage a.homepage-database.selected {
    color: #fff;
}
.homepage a.catalog-item-name,
.homepage a.catalog-item-name:visited,
.homepage a.query-card-name,
.homepage a.query-card-name:visited {
    color: #1d4f7a;
    text-decoration: none;
}
.homepage a.catalog-item-name:hover,
.homepage a.catalog-item-name:focus-visible,
.homepage a.query-card-name:hover,
.homepage a.query-card-name:focus-visible {
    color: var(--accent);
    text-decoration: underline;
}
.catalog-column-match {
    /* The negative margin keeps the highlight from pushing the comma away */
    margin: 0 -0.2rem;
    padding: 0.05rem 0.2rem;
    border-radius: 3px;
    background: #fff3b0;
    color: var(--ink);
}
.homepage a.homepage-database.empty,
.homepage span.homepage-database.empty {
    opacity: 0.5;
}

/* Homepage: recently visited, from localStorage */
.homepage-recent {
    margin: 0 0 1.25rem;
}
.homepage-recent-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin: 0 0 0.5rem;
}
.homepage-recent-header h2 {
    margin: 0;
    font-size: 1.125rem;
}
.homepage-recent-clear {
    color: var(--muted);
    font-size: 0.8125rem;
}
.recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.recent-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 100%;
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--rule);
    border-radius: 0.5rem;
    background: var(--card);
}
.homepage a.recent-item-name,
.homepage a.recent-item-name:visited {
    color: #1d4f7a;
    font-weight: 600;
    text-decoration: none;
    overflow-wrap: anywhere;
}
.homepage a.recent-item-name:hover {
    color: var(--accent);
    text-decoration: underline;
}
.type-tag-query {
    color: #0f6b4f;
    background: #e6f6ef;
}
.type-tag-database {
    color: #4b5563;
    background: #eef0f3;
}

/* Database filter: labelled row of rectangular chips */
.homepage-databases-label {
    margin-right: 0.25rem;
    color: var(--muted);
    font-weight: 600;
}
.homepage-database {
    border-radius: 0.4rem;
}
.homepage-database.selected,
.homepage a.homepage-database.selected {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.homepage-database.selected .homepage-database-count {
    color: var(--muted);
}

/* Section header with a link on the right */
.homepage-section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    margin: 0 0 0.6rem;
}
.homepage-section-header h2 {
    margin: 0;
}
.homepage-section-link {
    font-size: 0.875rem;
}

/* Queries: compact rows */
ul.query-list {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--rule);
    border-radius: 0.5rem;
    background: var(--card);
    overflow: hidden;
}
:where(.homepage) .query-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.5rem;
    padding: 0.5rem 0.9rem;
}
:where(.homepage) .query-row + .query-row {
    border-top: 1px solid var(--rule);
}
.homepage a.query-row-name,
.homepage a.query-row-name:visited {
    color: #1d4f7a;
    font-weight: 600;
    text-decoration: none;
}
.homepage a.query-row-name:hover {
    color: var(--accent);
    text-decoration: underline;
}
:where(.homepage) .query-row-detail {
    flex: 1 1 16rem;
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.875rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
:where(.homepage) .query-row-detail code {
    font-size: 0.8125rem;
}
.type-tag-mine {
    color: #1e40af;
    background: #e8effd;
}
.homepage-database.selected,
.homepage a.homepage-database.selected {
    border-color: #a9c1ec;
    background: var(--accent-light);
    box-shadow: none;
    font-weight: 600;
}
.homepage-recent-header {
    justify-content: space-between;
}
.homepage .homepage-recent-clear {
    padding: 0.1rem 0.4rem;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.8125rem;
    text-decoration: none;
    cursor: pointer;
}
.homepage .homepage-recent-clear:hover,
.homepage .homepage-recent-clear:focus-visible {
    background: #eef0f3;
    color: var(--ink);
}

/* While searching, results sit directly under the search box */
.homepage-searching .homepage-sections,
.homepage-searching .homepage-recent,
.homepage-searching .homepage-databases {
    display: none;
}
.homepage-searching .homepage-queries {
    margin-top: 1.5rem;
}

/* Plugin sections: optional heading drawn by core, styled like Recently visited */
.homepage-section + .homepage-section {
    margin-top: 1.25rem;
}
.homepage-section-heading {
    margin: 0 0 0.5rem;
}
.homepage-section-heading h2 {
    margin: 0;
    font-size: 1.125rem;
}
.homepage-tables {
    scroll-margin-top: 1rem;
}

/* Keyboard-highlighted search result */
.catalog-item.is-active,
:where(.homepage) .query-row.is-active {
    background: #eef4ff;
    box-shadow: inset 3px 0 0 var(--accent);
}
.catalog-item.is-active,
:where(.homepage) .query-row.is-active,
.catalog-item.is-active:hover {
    position: relative;
    background: #dfe9fd;
    box-shadow: none;
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    border-radius: 0.4rem;
}
.catalog-item.is-active {
    border-radius: 8px;
}
.homepage .is-active a.catalog-item-name,
.homepage .is-active a.query-row-name {
    color: var(--accent);
    text-decoration: underline;
}

/* Search results contributed by plugins through jump_items_sql */
.homepage-other {
    margin-top: 1.5rem;
}
.homepage-other h2 {
    margin: 0 0 0.6rem;
    font-size: 1.125rem;
}
.type-tag-other {
    color: #4b5563;
    background: #eef0f3;
}
/* Homepage actions sit below the title rather than beside it */
.homepage-header {
    display: block;
}
.homepage-header .page-action-menu {
    margin-top: 0.5rem;
    margin-bottom: 0.5em;
}
.homepage-recent[hidden] {
    display: none;
}

/* Query list (/-/queries): the homepage's search, chips and query rows */
:where(.homepage) .query-list-filters {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0 0 1rem;
}
:where(.homepage) .query-list-filters .homepage-databases {
    flex-wrap: wrap;
    margin: 0;
}
:where(.homepage) .query-list-facets .homepage-databases-label + .homepage-database {
    margin-left: 0;
}
:where(.homepage) .query-list-facets .homepage-database + .homepage-databases-label {
    margin-left: 0.75rem;
}
.homepage-searching.query-list-page .homepage-databases {
    display: inline-flex;
}
:where(.homepage) .query-list-heading-db {
    vertical-align: middle;
    font-size: 0.875rem;
}
.type-tag-private {
    color: #8a3b52;
    background: #f7edf0;
}
.type-tag-trusted {
    color: #1f7a4d;
    background: #e7f5ec;
}
:where(.homepage) .query-row-owner {
    font-family: ui-monospace, monospace;
    font-size: 0.8125rem;
}
:where(.homepage) .query-list-page .homepage-queries,
.homepage-searching.query-list-page .homepage-queries {
    margin-top: 0;
}

/* Above-table panels ======================================================= */

/* Tabs for the panels that JavaScript plugins add with
   makeAboveTablePanelConfigs(). datasette-manager.js builds them as a
   WAI-ARIA tablist, so the selected state is styled from aria-selected.

   The selected tab is marked by a thick underline and bolder text as well as
   by colour. Unselected tabs have no bottom border at all rather than a
   transparent one, because forced-colors mode would paint a transparent
   border and make every tab look selected. */
.above-table-panel .tab-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0 4px;
    margin: 4px 0 20px;
    border-bottom: 1px solid var(--rule, #d8e6f5);
}

.above-table-panel .tab-controls [role="tab"] {
    appearance: none;
    margin: 0;
    padding: 8px 12px 11px;
    border: 0;
    border-radius: 4px 4px 0 0;
    background: transparent;
    color: #4a4a4a;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.2;
    cursor: pointer;
}

.above-table-panel .tab-controls [role="tab"]:hover {
    background: #e8effd;
    color: #1949b8;
}

.above-table-panel .tab-controls [role="tab"][aria-selected="true"] {
    padding-bottom: 8px;
    border-bottom: 3px solid var(--accent, #1a56db);
    color: var(--ink, #0f0f0f);
    font-weight: 600;
}

.above-table-panel .tab-controls [role="tab"]:focus-visible,
.above-table-panel .tab-contents > [role="tabpanel"]:focus-visible {
    outline: 2px solid var(--accent, #1a56db);
    outline-offset: 2px;
}

.above-table-panel .tab-contents > [role="tabpanel"][hidden] {
    display: none;
}

@media (pointer: coarse) {
    .above-table-panel .tab-controls [role="tab"] {
        min-height: 44px;
    }
}

@media (forced-colors: active) {
    .above-table-panel .tab-controls [role="tab"][aria-selected="true"] {
        border-bottom-color: Highlight;
    }
}

/* Many-to-many relationships: extra columns at the end of the table, and a
   section on the row page. These are not real columns of the table. */
table.rows-and-columns th.relationship-col {
    background: #d3e3f6;
    border-left: 1px dashed var(--rule);
    font-weight: 600;
}
table.rows-and-columns th.relationship-col .m2m-via {
    /* #5c5c5c is 5.1:1 on the #d3e3f6 heading, where the --muted grey of
       the row page would be 4.1:1 */
    color: #5c5c5c;
    font-size: 0.75rem;
    font-weight: 400;
}
/* "via <junction>" links to the junction table. A quiet link, so the
   heading does not read as two competing links: the same grey in every
   state, visited too, underlined only on hover and focus. These out-rank
   the heading link and global link colours */
table.rows-and-columns th.relationship-col a.m2m-via:is(:link, :visited),
.row-m2m-relationship h3 a.row-m2m-via:is(:link, :visited) {
    text-decoration: none;
    border-radius: 2px;
}
table.rows-and-columns th.relationship-col a.m2m-via:is(:link, :visited),
table.rows-and-columns th.relationship-col a.m2m-via:is(:link, :visited):is(:hover, :focus, :active) {
    color: #5c5c5c;
}
.row-m2m-relationship h3 a.row-m2m-via:is(:link, :visited),
.row-m2m-relationship h3 a.row-m2m-via:is(:link, :visited):is(:hover, :focus, :active) {
    color: #6b6b6b;
}
table.rows-and-columns th.relationship-col a.m2m-via:is(:link, :visited):is(:hover, :focus-visible),
.row-m2m-relationship h3 a.row-m2m-via:is(:link, :visited):is(:hover, :focus-visible) {
    text-decoration: underline;
    text-underline-offset: 2px;
}
table.rows-and-columns th.relationship-col a.m2m-via:focus-visible,
.row-m2m-relationship h3 a.row-m2m-via:focus-visible {
    outline: 2px solid var(--m2m-ink);
    outline-offset: 2px;
}
@media (forced-colors: active) {
    table.rows-and-columns th.relationship-col a.m2m-via:focus-visible,
    .row-m2m-relationship h3 a.row-m2m-via:focus-visible {
        outline-color: Highlight;
    }
}
table.rows-and-columns td.relationship-col {
    border-left: 1px dashed var(--rule);
    white-space: normal;
    min-width: 8rem;
}
.m2m-items {
    /* Block level, so the "N total" link and the edit button that follow
       always start on a new line */
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
    max-width: 100%;
    min-width: 0;
}
/* No gap below the pills unless the "N total" link follows them */
.m2m-items:last-child {
    margin-bottom: 0;
}
@media (max-width: 576px) {
    /* Stacked cards: line up with the other fields of the card */
    table.rows-and-columns td.relationship-col {
        border-left: 0;
    }
    table.rows-and-columns td.relationship-col .m2m-items {
        margin-top: 0.2rem;
    }
}
a.m2m-item:is(:link, :visited),
.m2m-schema-pill {
    display: inline-block;
    padding: 0 0.45rem;
    border: 1px solid var(--m2m-rule);
    border-radius: 999px;
    background: var(--m2m-paper);
    color: var(--m2m-ink);
    font-size: 0.8125rem;
    line-height: 1.5;
    white-space: nowrap;
    /* Each name is truncated on its own, so the list is always all visible */
    max-width: min(16rem, 100%);
    overflow: hidden;
    text-overflow: ellipsis;
}
a.m2m-item:is(:link, :visited) {
    text-decoration: none;
    vertical-align: top;
}
/* Pills look the same whether or not the linked row has been visited: these
   out-rank the visited link colours for table cells and row fields */
table.rows-and-columns td a.m2m-item:is(:link, :visited),
.row-field-value a.m2m-item:is(:link, :visited),
.row-m2m a.m2m-item:is(:link, :visited),
.m2m-item-split > a.m2m-item-label:is(:link, :visited),
table.rows-and-columns td .m2m-item-split > a.m2m-item-label:is(:link, :visited),
.row-m2m .m2m-item-split > a.m2m-item-label:is(:link, :visited) {
    color: var(--m2m-ink);
    text-decoration: none;
}
a.m2m-item:hover {
    border-color: #7fa8dc;
    text-decoration: none;
}
/* A split pill, for one link that has values in the junction table's extra
   columns: "Guido Lee 175 | Lead". The left half links to the related row,
   the right half to the junction row. The values are cut first, so the
   label keeps as much room as it can */
.m2m-item-split {
    display: inline-flex;
    max-width: min(24rem, 100%);
    min-width: 0;
    border: 1px solid var(--m2m-rule);
    border-radius: 999px;
    /* Clips the two halves to the rounded outline */
    overflow: hidden;
    font-size: 0.8125rem;
    line-height: 1.5;
    white-space: nowrap;
    vertical-align: top;
}
.m2m-item-split > .m2m-item-label,
.m2m-item-split > .m2m-item-extra {
    display: block;
    padding: 0 0.45rem;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}
.m2m-item-split > .m2m-item-label {
    flex: 0 1 auto;
    min-width: 2.5em;
    max-width: 16rem;
    background: var(--m2m-paper);
}
.m2m-item-split > .m2m-item-extra {
    /* Grows into the room the label leaves, from nothing, so the label is
       only cut when it does not fit on its own. Shrinking this half from
       its full width instead, however much faster than the label, takes a
       fraction of a pixel from the label too - enough for its ellipsis to
       turn "v0.1.2" into "v0.…" */
    flex: 1 1 0;
    background: #f8fbff;
    border-left: 1px solid var(--m2m-rule);
    /* The values, then "+N" for the extra columns that are not shown. The
       values column can shrink to an ellipsis, so its minimum does not
       count towards the min-content width, but "+N" never shrinks: that
       min-content width is this half's minimum */
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: minmax(1.2em, max-content);
    grid-auto-columns: max-content;
    align-items: baseline;
    min-width: min-content;
}
.m2m-item-split > .m2m-item-extra > .m2m-item-values {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.m2m-item-split > .m2m-item-extra > .m2m-item-more {
    font-weight: 300;
}
/* Separated from the values like they are from each other. Generated, so
   copying the pill copies "Editor · Editing+1" without a stray dot */
.m2m-item-split > .m2m-item-extra > .m2m-item-values + .m2m-item-more::before {
    content: "·";
    margin: 0 0.3em;
    font-weight: 400;
}
/* Just "+N", for a link with no values to show: still a comfortable target */
.m2m-item-split > .m2m-item-extra.m2m-item-extra-more {
    grid-template-columns: max-content;
    justify-content: center;
    min-width: 2.75em;
    box-sizing: border-box;
}
/* The label is #1e4f8f, like plain pills: 7.4:1 on #eef5fd. #4a6585 is
   5.8:1 on #f8fbff, and 4.9:1 on the #dbe9fb hover background. These
   out-rank the visited link colours for table cells and row fields, as for
   plain pills */
.m2m-item-split > .m2m-item-extra,
table.rows-and-columns td .m2m-item-split > a.m2m-item-extra:is(:link, :visited),
.row-m2m .m2m-item-split > a.m2m-item-extra:is(:link, :visited) {
    color: #4a6585;
    text-decoration: none;
}
/* Each half highlights on its own */
.m2m-item-split > a.m2m-item-label:is(:link, :visited):is(:hover, :focus-visible),
.m2m-item-split > a.m2m-item-extra:is(:link, :visited):is(:hover, :focus-visible),
table.rows-and-columns td .m2m-item-split > a:is(.m2m-item-label, .m2m-item-extra):is(:link, :visited):is(:hover, :focus-visible),
.row-m2m .m2m-item-split > a:is(.m2m-item-label, .m2m-item-extra):is(:link, :visited):is(:hover, :focus-visible) {
    background: #dbe9fb;
    text-decoration: underline;
}
/* Inside the half, since the pill clips anything outside its outline */
.m2m-item-split > a:focus-visible {
    outline: 2px solid var(--m2m-ink);
    outline-offset: -2px;
}
.m2m-item-split > .m2m-item-label:focus-visible {
    border-radius: 999px 0 0 999px;
}
.m2m-item-split > .m2m-item-extra:focus-visible {
    border-radius: 0 999px 999px 0;
}
@media (max-width: 576px) {
    /* One size for every pill on a phone, plain or split, in every
       relationship: a little taller, so each half of a split pill is an
       easier tap target. A plain pill's border is its own and a split
       pill's is around both halves, so they come out the same height */
    .m2m-items a.m2m-item:is(:link, :visited),
    .m2m-items .m2m-item-split > .m2m-item-label,
    .m2m-items .m2m-item-split > .m2m-item-extra {
        padding-top: 0.2rem;
        padding-bottom: 0.2rem;
    }
}
@media (forced-colors: active) {
    .m2m-item-split > .m2m-item-extra {
        border-left-color: CanvasText;
    }
    .m2m-item-split > a:focus-visible {
        outline-color: Highlight;
    }
}
a.m2m-total:is(:link, :visited) {
    color: var(--muted, #6b6b6b);
    font-size: 0.75rem;
    white-space: nowrap;
}
.m2m-timed-out,
.m2m-none {
    color: #6b6b6b;
    font-size: 0.8125rem;
    font-style: italic;
}
.row-m2m {
    max-width: 60rem;
    margin: 0 0 1.5rem;
}
.row-m2m h2 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}
.row-m2m-relationship {
    padding: 0.4rem 0;
    border-top: 1px solid #d8e6f5;
}
.row-m2m-relationship h3 {
    margin: 0 0 0.35rem;
    font-size: 0.9375rem;
}
.row-m2m-via {
    color: #6b6b6b;
    font-size: 0.8125rem;
    font-weight: 400;
}
.row-m2m-total {
    font-size: 0.8125rem;
    font-weight: 400;
}

/* Editing many-to-many links in the row edit and insert dialogs */
.m2m-editor {
    display: grid;
    gap: 8px;
    min-width: 0;
}
/* While the row is being saved */
.m2m-editor-busy {
    opacity: 0.7;
    cursor: progress;
}
.m2m-editor datasette-autocomplete,
.m2m-editor datasette-autocomplete input[type="text"].m2m-editor-input {
    max-width: none;
}
.m2m-editor-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 12px;
    min-width: 0;
}
.m2m-editor-summary {
    color: var(--muted);
    font-size: 0.8rem;
}
.m2m-editor-filter-input {
    width: 11rem;
    max-width: 100%;
    padding: 4px 8px;
    font-size: 0.85rem;
}
.m2m-editor-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 2px;
    list-style: none;
    max-height: 15rem;
    overflow-y: auto;
}
/* An open form is not squeezed into the scrolling list */
.m2m-editor-chips:has(.m2m-chip-form) {
    max-height: none;
}
.m2m-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    padding-left: 0.6rem;
    border: 1px solid var(--m2m-rule);
    border-radius: 999px;
    background: var(--m2m-paper);
    color: var(--m2m-ink);
    font-size: 0.85rem;
    line-height: 1.4;
}
.m2m-chip:not(:has(.m2m-chip-button)) {
    padding-right: 0.6rem;
}
.m2m-chip-label {
    min-width: 0;
    padding: 2px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* The junction table's extra columns, after the label: "Ada · Lead" */
.m2m-chip-extra {
    color: var(--m2m-ink);
    opacity: 0.8;
}
.m2m-chip-removed .m2m-chip-extra {
    color: inherit;
}
.m2m-chip-label a:is(:link, :visited, :hover, :focus, :active) {
    color: inherit;
    text-decoration: none;
}
.m2m-chip-label a:hover {
    text-decoration: underline;
}
/* Clicking the values opens the form, like the edit button */
.m2m-chip-extra-editable {
    cursor: pointer;
}
.m2m-chip-extra-editable:hover {
    text-decoration: underline dotted;
}
/* Linked, with staged changes to its extra columns */
.m2m-chip-edited {
    border-style: dashed;
    border-color: var(--m2m-ink);
}
.m2m-chip-edited .m2m-chip-badge {
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--m2m-rule);
    color: var(--m2m-ink);
    opacity: 1;
}
.m2m-chip-editing {
    box-shadow: 0 0 0 2px var(--m2m-rule);
}
.m2m-chip-button.m2m-chip-edit {
    font-size: 0.85rem;
}
/* The form for one link's extra columns, directly after its chip */
.m2m-chip-form {
    flex: 1 1 100%;
    box-sizing: border-box;
    display: grid;
    gap: 8px;
    min-width: 0;
    margin: 0 0 4px;
    padding: 10px 12px;
    border: 1px solid var(--m2m-rule);
    border-radius: 8px;
    background: var(--m2m-paper);
    color: var(--ink);
}
.m2m-chip-form-invalid {
    border-color: #e2bcbc;
}
.m2m-chip-form-heading {
    margin: 0;
    color: var(--m2m-ink);
    font-size: 0.85rem;
    font-weight: 600;
}
.m2m-chip-form .row-edit-field {
    grid-template-columns: minmax(70px, 120px) minmax(0, 1fr);
    gap: 8px;
}
.m2m-chip-form .row-edit-input {
    background: #fff;
}
.m2m-chip-form-buttons {
    display: flex;
    gap: 8px;
}
.m2m-chip-form-buttons button {
    appearance: none;
    padding: 4px 14px;
    border: 1px solid var(--m2m-rule);
    border-radius: 5px;
    background: #fff;
    color: var(--m2m-ink);
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
}
.m2m-chip-form-buttons .m2m-chip-form-done {
    border-color: var(--m2m-ink);
    background: var(--m2m-ink);
    color: #fff;
}
@media (max-width: 576px) {
    .m2m-chip-form .row-edit-field {
        grid-template-columns: minmax(0, 1fr);
        gap: 2px;
    }
}
/* Staged additions: white with a dashed accent border and a filled
   "new" badge, so they stand apart from the light blue linked chips */
.m2m-chip-new {
    border-style: dashed;
    border-color: var(--accent);
    background: #fff;
    color: #1a3f9e;
}
.m2m-chip-new .m2m-chip-badge {
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    opacity: 1;
}
.m2m-chip-removed {
    border-style: dashed;
    border-color: #e2bcbc;
    background: #fff;
    color: #7a7a7a;
}
.m2m-chip-badge {
    flex: none;
    margin-left: 0.35rem;
    font-size: 0.68rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    opacity: 0.85;
}
.m2m-chip-button {
    appearance: none;
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 1.6rem;
    height: 1.6rem;
    margin: 0 0 0 0.1rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-size: 1rem;
    line-height: 1;
}
.m2m-chip-button:hover {
    background: rgba(0, 0, 0, 0.07);
}
.m2m-chip-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
.m2m-chip-flash {
    animation: m2m-chip-flash 1.2s ease-out;
}
@keyframes m2m-chip-flash {
    from { box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.5); }
    to { box-shadow: 0 0 0 3px rgba(26, 86, 219, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .m2m-chip-flash {
        animation: none;
        outline: 2px solid var(--accent);
    }
}
button.m2m-editor-more {
    justify-self: start;
    font-size: 0.85rem;
}
/* The button-as-link hover and focus colour is meant for the dark header and
   footer; on the white dialog it would be near-white */
button.m2m-editor-more.button-as-link:is(:hover, :focus, :active) {
    color: var(--m2m-ink);
    text-decoration: underline;
}
button.m2m-editor-more.button-as-link:focus-visible {
    outline: 2px solid var(--m2m-ink);
    outline-offset: 2px;
    border-radius: 2px;
}
@media (forced-colors: active) {
    button.m2m-editor-more.button-as-link:focus-visible {
        outline-color: Highlight;
    }
}
.m2m-editor-message,
.m2m-editor-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
}
.m2m-editor-note a:is(:link, :visited, :hover, :focus, :active) {
    color: var(--m2m-ink);
}
.m2m-editor-filter[hidden],
.m2m-editor-chips[hidden],
button.m2m-editor-more[hidden],
.m2m-editor-message[hidden],
.m2m-editor-note[hidden] {
    display: none;
}
.m2m-editor-input-error {
    margin: -4px 0 0;
    font-size: 0.8rem;
}
.m2m-editor-input[aria-invalid="true"] {
    border-color: #b42318;
}
.m2m-editor-message-error {
    color: #b42318;
}
.m2m-editor-message-deletes {
    padding-left: 8px;
    border-left: 3px solid #e2bcbc;
    color: var(--ink);
}
.row-edit-m2m-heading {
    margin: 4px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--rule);
    color: var(--ink);
    font-size: 0.9rem;
}
.row-edit-m2m-label {
    display: flex;
    flex-direction: column;
}
.row-edit-m2m-via {
    color: var(--muted);
    font-size: 0.72rem;
}
.datasette-autocomplete-option-disabled {
    color: var(--muted);
    cursor: default;
}
.datasette-autocomplete-option-disabled[aria-selected="true"] {
    font-weight: 400;
}
.datasette-autocomplete-note {
    color: var(--muted);
    font-size: 0.75rem;
    font-style: italic;
    font-weight: 400;
}

/* Relationships section of the create table and alter table dialogs, see
   "Many-to-many relationships in the create table and alter table dialogs"
   in edit-tools-table.js. Light blue, like the many-to-many pills. */
.m2m-schema-section {
    display: grid;
    gap: 8px;
    border-top: 1px solid var(--rule);
    padding-top: 12px;
    white-space: normal;
    min-width: 0;
}
.m2m-schema-section[hidden],
.m2m-schema-section [hidden],
.m2m-schema-form [hidden] {
    display: none !important;
}
.m2m-schema-title {
    color: var(--ink);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    margin: 0;
}
.m2m-schema-intro,
.m2m-schema-status {
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.4;
    margin: 0;
}
.m2m-schema-status:empty {
    display: none;
}
.m2m-schema-status-error {
    color: #7f1d1d;
}
.m2m-schema-note {
    border-left: 3px solid var(--m2m-rule);
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 0;
    padding: 2px 0 2px 10px;
}
.m2m-schema-list {
    display: grid;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.m2m-schema-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    border: 1px solid #c9ddf2;
    border-radius: 6px;
    background: #f5f9fe;
    margin: 0;
    padding: 8px 10px;
}
.m2m-schema-item-main {
    flex: 1 1 14rem;
    min-width: 0;
    color: var(--ink);
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.m2m-schema-item-detail {
    flex: 1 1 100%;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.4;
    margin: 0;
    order: 3;
}
/* Otherwise like a.m2m-item */
.m2m-schema-pill {
    vertical-align: bottom;
}
.m2m-schema-code {
    background: #eef6ff;
    border: 1px solid #c9ddf2;
    border-radius: 4px;
    color: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
    padding: 1px 4px;
    overflow-wrap: anywhere;
}
a.m2m-schema-junction-link {
    text-decoration: none;
}
a.m2m-schema-junction-link:hover .m2m-schema-code {
    border-color: #7fa8dc;
}
.m2m-schema-count {
    color: var(--muted);
    font-size: 0.85rem;
    margin-left: 0.25rem;
    white-space: nowrap;
}
.m2m-schema-remove,
.m2m-schema-add,
.m2m-schema-undo {
    appearance: none;
    border: 1px solid var(--rule);
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.3;
}
.m2m-schema-remove {
    color: #b91c1c;
    padding: 5px 10px;
}
.m2m-schema-add {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    padding: 7px 10px;
}
.m2m-schema-add svg {
    display: block;
    flex: 0 0 auto;
}
.m2m-schema-remove:hover,
.m2m-schema-remove:focus,
.m2m-schema-add:hover,
.m2m-schema-add:focus,
.m2m-schema-undo:hover,
.m2m-schema-undo:focus {
    background: #f8fafc;
}
.m2m-schema-remove:focus,
.m2m-schema-add:focus,
.m2m-schema-undo:focus,
.m2m-schema-input:focus,
.m2m-schema-confirm-input:focus {
    outline: 3px solid rgba(26, 86, 219, 0.12);
    outline-offset: 1px;
}
.m2m-schema-remove:disabled,
.m2m-schema-add:disabled,
.m2m-schema-undo:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.m2m-schema-inline {
    display: grid;
    gap: 12px;
    border: 1px solid #c9ddf2;
    border-radius: 6px;
    background: #f5f9fe;
    padding: 12px;
}
.m2m-schema-inline-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}
.m2m-schema-form {
    display: grid;
    gap: 14px;
    max-width: 34rem;
    white-space: normal;
}
.m2m-schema-field {
    display: grid;
    gap: 4px;
    min-width: 0;
}
.m2m-schema-choices {
    border: 0;
    margin: 0;
    padding: 0;
    gap: 6px;
}
.m2m-schema-choices legend {
    padding: 0;
    margin-bottom: 4px;
}
.m2m-schema-choice {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: 0.9rem;
    cursor: pointer;
    min-width: 0;
    overflow-wrap: anywhere;
}
.m2m-schema-choice input {
    margin: 0;
    flex: none;
}
.m2m-schema-search-wrap {
    display: grid;
    gap: 4px;
    padding-left: 24px;
    min-width: 0;
}
.m2m-schema-new {
    display: grid;
    gap: 12px;
    border-left: 3px solid var(--m2m-rule);
    background: #f8fafc;
    padding: 10px 12px;
}
.m2m-schema-inline .m2m-schema-new {
    background: #fff;
}
.m2m-schema-label {
    color: var(--ink);
    font-size: 0.875rem;
    font-weight: 600;
}
.m2m-schema-input {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 42px;
    border: 1px solid var(--rule);
    border-radius: 5px;
    padding: 8px 10px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    line-height: 1.35;
}
select.m2m-schema-input {
    height: 42px;
}
.m2m-schema-input:focus {
    border-color: var(--accent);
}
.m2m-schema-input[aria-invalid="true"] {
    border-color: #b91c1c;
}
.m2m-schema-hint {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.4;
    margin: 0;
    overflow-wrap: anywhere;
}
.m2m-schema-field-error,
.m2m-schema-other-error {
    border-left: 3px solid #b91c1c;
    color: #7f1d1d;
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 0;
    padding-left: 8px;
}
.m2m-schema-confirm {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--ink);
    font-size: 0.9rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}
.m2m-schema-confirm-input {
    flex: 0 0 auto;
    margin-top: 0.2rem;
}
/* Relationships added or removed in the alter table dialog, applied with
   the dialog's other changes */
.m2m-schema-badge {
    display: inline-block;
    margin-left: 0.25rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    line-height: 1.6;
    text-transform: uppercase;
    white-space: nowrap;
    vertical-align: 1px;
}
.m2m-schema-item-new {
    border-style: dashed;
    border-color: var(--accent);
    background: #fff;
}
.m2m-schema-item-new .m2m-schema-badge {
    background: var(--accent);
    color: #fff;
}
.m2m-schema-item-removed {
    border-style: dashed;
    border-color: #e2bcbc;
    background: #fff;
}
.m2m-schema-item-removed .m2m-schema-item-main {
    color: #6b7280;
}
.m2m-schema-item-removed .m2m-schema-item-main .m2m-schema-pill,
.m2m-schema-item-removed .m2m-schema-item-main .m2m-schema-code {
    text-decoration: line-through;
    text-decoration-color: rgba(185, 28, 28, 0.6);
}
.m2m-schema-item-removed .m2m-schema-badge {
    background: #fde8e8;
    color: #9b1c1c;
}
.m2m-schema-undo {
    color: var(--accent);
    padding: 5px 10px;
}
:where(dialog.table-alter-dialog) .table-alter-review-m2m {
    overflow-wrap: anywhere;
}
:where(dialog.table-alter-dialog) .table-alter-review-m2m .table-alter-review-name {
    white-space: normal;
}
:where(dialog.table-alter-dialog) .table-alter-review-m2m .m2m-schema-confirm {
    margin-top: 6px;
    font-weight: normal;
}
:where(dialog.table-alter-dialog) .table-alter-review-note {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: normal;
    line-height: 1.4;
    margin: 4px 0 0;
}

/* The file that a table is being created from, in place of the textarea */
:where(dialog.table-create-dialog) .table-create-data-file {
    border: 1px solid var(--rule);
    border-radius: 5px;
    background: var(--paper);
    color: var(--ink);
    font-size: 0.9rem;
    margin: 0;
    overflow-wrap: anywhere;
    padding: 12px;
}

:where(dialog.table-create-dialog) .table-create-data-file[hidden],
:where(dialog.table-create-dialog) .table-create-data-textarea[hidden],
:where(dialog.table-create-dialog) .table-create-data-import[hidden] {
    display: none;
}

:where(dialog.table-create-dialog) .table-create-data-file .button-as-link {
    font: inherit;
    margin-left: 0.5em;
}

:where(dialog.table-create-dialog) .table-create-data-preview-column-name {
    box-sizing: border-box;
    display: block;
    width: 100%;
    min-width: 8rem;
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 3px 6px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

:where(dialog.table-create-dialog) .table-create-data-preview-column-name:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(26, 86, 219, 0.12);
}

:where(dialog.table-create-dialog) .table-create-data-preview-column-name[aria-invalid="true"] {
    border-color: #b42318;
    background: #fff8f7;
}

:where(dialog.table-create-dialog) .table-create-data-preview-column-name:disabled {
    background: transparent;
    text-decoration: line-through;
}

/* A column that is skipped is still shown, so the data it holds can be
   seen, but it is greyed out */
:where(dialog.table-create-dialog) .table-create-data-preview-table th.table-create-data-preview-skipped,
:where(dialog.table-create-dialog) .table-create-data-preview-table td.table-create-data-preview-skipped {
    color: var(--muted);
    background: #f6f7f9;
}

:where(dialog.table-create-dialog) .table-create-data-preview-renamed {
    color: var(--ink);
    font-size: 0.85rem;
    margin: 0;
}

:where(dialog.table-create-dialog) .table-create-data-preview-type {
    display: block;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: normal;
    margin-top: 4px;
}

:where(dialog.table-create-dialog) .table-create-data-import {
    display: grid;
    gap: 12px;
}

:where(dialog.table-create-dialog) .table-create-data-import-summary {
    color: var(--ink);
    font-size: 0.9rem;
}

:where(dialog.table-create-dialog) .table-create-data-import-summary p {
    margin: 0 0 8px;
}

:where(dialog.table-create-dialog) .table-create-data-import-result {
    font-weight: 600;
}

:where(dialog.table-create-dialog) .table-create-data-import-mismatches {
    margin: 0 0 8px;
    padding-left: 1.2em;
}

/* The progress of an import of CSV or TSV, see edit-tools-import.js */
.import-progress {
    display: grid;
    gap: 6px;
}

.import-progress[hidden],
.import-progress-question[hidden],
.import-progress-detail[hidden] {
    display: none;
}

.import-progress-bar {
    width: 100%;
}

.import-progress-status {
    color: var(--ink);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    margin: 0;
}

.import-progress-question {
    border: 1px solid var(--rule);
    border-left: 4px solid #b45309;
    border-radius: 5px;
    display: grid;
    gap: 8px;
    margin-top: 6px;
    padding: 10px 12px;
}

.import-progress-message,
.import-progress-detail {
    color: var(--ink);
    font-size: 0.9rem;
    margin: 0;
    overflow-wrap: anywhere;
}

.import-progress-detail {
    color: var(--muted);
}

.import-progress-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* The file that rows are being inserted from, in place of the textarea */
.row-edit-bulk-file {
    border: 1px solid var(--rule);
    border-radius: 5px;
    background: var(--paper);
    color: var(--ink);
    font-size: 0.9rem;
    margin: 0;
    overflow-wrap: anywhere;
    padding: 12px;
}

.row-edit-bulk-file[hidden],
.row-edit-bulk-textarea[hidden] {
    display: none;
}

.row-edit-bulk-file .button-as-link {
    font: inherit;
    margin-left: 0.5em;
}

/* Dragging a table heading by its handle moves the whole column,
   see column-drag.js */
table.rows-and-columns th .column-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* At the right end of the heading, whatever else is added to it */
    float: right;
    width: 16px;
    height: 20px;
    margin: 0 -4px 0 6px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: none;
    color: #9aa7b8;
    cursor: grab;
    vertical-align: middle;
    touch-action: none;
}
table.rows-and-columns th .column-drag-handle:hover,
table.rows-and-columns th .column-drag-handle:focus-visible {
    color: #1a56db;
    background: rgba(26, 86, 219, 0.1);
}
@media (max-width: 576px) {
    /* Stacked cards have no columns to drag */
    table.rows-and-columns th .column-drag-handle {
        display: none;
    }
}
body.column-drag-active,
body.column-drag-active * {
    cursor: grabbing !important;
    user-select: none;
    -webkit-user-select: none;
}
/* The other columns slide aside as the dragged one passes them */
table.rows-and-columns.is-column-dragging > * > tr > * {
    transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1);
}
/* The dragged column follows the pointer, above the rest */
table.rows-and-columns.is-column-dragging > * > tr > .column-drag-cell {
    position: relative;
    z-index: 5;
    transition: opacity 0.12s;
    box-shadow:
        -1px 0 0 #7fa8dc,
        1px 0 0 #7fa8dc,
        0 0 18px rgba(20, 40, 80, 0.22);
}
table.rows-and-columns.is-column-dragging > tbody > tr > td.column-drag-cell {
    background: #fff;
}
table.rows-and-columns.is-column-dragging > thead > tr > th.column-drag-cell {
    background: #c9dcf5;
}
/* Let go: it slides into its new place, or back */
table.rows-and-columns.is-column-settling > * > tr > .column-drag-cell {
    transition:
        transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1),
        opacity 0.12s;
}
/* Over the remove strip */
table.rows-and-columns.is-column-removing > * > tr > .column-drag-cell {
    opacity: 0.35;
    box-shadow:
        -1px 0 0 #d92d20,
        1px 0 0 #d92d20;
}
table.rows-and-columns.is-column-removing > tbody > tr > td.column-drag-cell,
table.rows-and-columns.is-column-removing > thead > tr > th.column-drag-cell {
    background: #fde7e5;
}
.column-remove-zone {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    width: 96px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    border-right: 2px dashed #d92d20;
    background: rgba(217, 45, 32, 0.14);
    /* Blur what is behind it, so the label reads clearly over the page */
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: #b42318;
    font-size: 0.8125rem;
    font-weight: 600;
    text-align: center;
    pointer-events: none;
    transform: translateX(-100%);
    transition:
        transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1),
        background 0.12s;
}
.column-remove-zone.is-shown {
    transform: translateX(0);
}
.column-remove-zone.is-active {
    border-right-style: solid;
    background: #d92d20;
    color: #fff;
}
.column-remove-zone-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 400;
    opacity: 0;
}
.column-remove-zone.is-active .column-remove-zone-name {
    opacity: 1;
}
/* Under the label: the key that does the same */
.column-remove-zone-hint {
    margin-top: 10px;
    color: rgba(180, 35, 24, 0.75);
    font-size: 0.6875rem;
    font-weight: 400;
    line-height: 1.6;
}
.column-remove-zone-hint kbd {
    display: inline-block;
    padding: 0 4px;
    border: 1px solid rgba(180, 35, 24, 0.45);
    border-bottom-width: 2px;
    border-radius: 3px;
    font-family: inherit;
    font-size: 0.625rem;
    line-height: 1.4;
}
.column-remove-zone.is-active .column-remove-zone-hint {
    color: rgba(255, 255, 255, 0.9);
}
.column-remove-zone.is-active .column-remove-zone-hint kbd {
    border-color: rgba(255, 255, 255, 0.7);
}
@media (prefers-reduced-motion: reduce) {
    table.rows-and-columns.is-column-dragging > * > tr > *,
    table.rows-and-columns.is-column-settling > * > tr > .column-drag-cell,
    .column-remove-zone {
        transition: none;
    }
}

/* "Saved for this table", shown after columns change, which flies
   into the "Columns" button, see announceColumnsSaved() in table.js */
.columns-saved-note {
    position: fixed;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 8px 14px;
    border: 1px solid #9cbcef;
    border-radius: 10px;
    background: #f1f6fe;
    box-shadow: 0 6px 24px rgba(20, 40, 80, 0.18);
    color: #1949b8;
    font-size: 0.875rem;
    line-height: 1.3;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transform-origin: center;
    transition:
        opacity 0.2s,
        transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.columns-saved-note span {
    color: #4a6585;
    font-size: 0.75rem;
}
.columns-saved-note.is-shown {
    opacity: 1;
    transform: none;
}
.columns-saved-note.is-flying {
    transition:
        transform 0.42s cubic-bezier(0.5, 0, 0.75, 0.2),
        opacity 0.42s cubic-bezier(0.7, 0, 1, 0.5);
}
.columns-saved-note.is-leaving {
    opacity: 0;
}
/* The button the note flew into */
@keyframes columns-button-saved {
    0% {
        box-shadow: 0 0 0 0 rgba(26, 86, 219, 0.45);
        transform: scale(1);
    }
    35% {
        transform: scale(1.06);
    }
    100% {
        box-shadow: 0 0 0 10px rgba(26, 86, 219, 0);
        transform: scale(1);
    }
}
.columns-button.is-just-saved {
    animation: columns-button-saved 0.9s ease-out;
}
@media (prefers-reduced-motion: reduce) {
    .columns-saved-note,
    .columns-saved-note.is-flying {
        transition: opacity 0.2s;
        transform: none;
    }
    .columns-button.is-just-saved {
        animation: none;
        outline: 2px solid #1a56db;
        outline-offset: 2px;
    }
}
