/* Samuddhāra new look, beta release p2 (samuddhara/ui.py NEXT_RELEASE): the classic colours with the new type.
   Loaded by base.html only for people who switched to the new look, and every rule is scoped to
   html[data-ui="next"], so the classic look (output.css) never changes. Hand-written on purpose: no
   Tailwind rebuild. When the new look becomes the only one, these rules move into input.css as tokens and
   components and the attribute selectors on the apparatus give way to classes from tei_parser.py.
   Fonts are self-hosted under ../fonts/ with their OFL licences. */

@font-face { font-family: 'STIX Two Text'; src: url('../fonts/stix-two-text-vf.woff2') format('woff2');
    font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'STIX Two Text'; src: url('../fonts/stix-two-text-italic-vf.woff2') format('woff2');
    font-weight: 400 700; font-style: italic; font-display: swap; }
@font-face { font-family: 'Source Sans 3'; src: url('../fonts/source-sans-3-vf.woff2') format('woff2');
    font-weight: 200 900; font-style: normal; font-display: swap; }
/* 〈 〉 (U+2329/232A) in the apparatus fall back to a wide CJK glyph in every text face; this 3.4 KB face
   (cut from STIX Two Math) is listed first so they render as narrow brackets. A family of its own, because a
   unicode-range face inside the STIX family would be skipped for bold. It also draws ǀ ǁ (U+01C0/01C1), which
   the transcriptions use as daṇḍa and double daṇḍa, as full-height vertical lines: STIX Two Text draws them
   as click letters, a bare stem that reads as "l". */
@font-face { font-family: 'Samuddhara Brackets'; src: url('../fonts/samuddhara-brackets.woff2') format('woff2');
    font-weight: 100 900; font-style: normal; font-display: swap;
    unicode-range: U+01C0-01C1, U+2329-232A, U+27E8-27E9, U+3008-3009; }
@font-face { font-family: 'Samuddhara Brackets'; src: url('../fonts/samuddhara-brackets.woff2') format('woff2');
    font-weight: 100 900; font-style: italic; font-display: swap;
    unicode-range: U+01C0-01C1, U+2329-232A, U+27E8-27E9, U+3008-3009; }
/* tei_style.py ends every font the TEI names (#386, e.g. sigla in Gandhari Unicode) with PAGE_FONT
   "Montserrat,sans-serif". The new look loads no Montserrat, so the name points at Source Sans 3 here: readers
   without the TEI's font get the new interface face rather than a system font. */
@font-face { font-family: 'Montserrat'; src: url('../fonts/source-sans-3-vf.woff2') format('woff2');
    font-weight: 200 900; font-style: normal; font-display: swap; }
/* Devanagari: downloaded only by pages that contain it */
@font-face { font-family: 'Tiro Devanagari Sanskrit'; src: url('../fonts/tiro-devanagari-sanskrit.woff2') format('woff2');
    font-display: swap; unicode-range: U+0900-097F, U+1CD0-1CFF, U+A8E0-A8FF, U+25CC; }

/* ---------- tokens ---------- */
/* Colours are the classic ones (#403 testing: "keep colours as they were before"): output.css paints every
   background, text, border, button and apparatus chip, and this file changes type, spacing, shapes and layout.
   It adds colour only for states the classic look lacks (hover, focus, an open group siglum), from the classic
   palette. advanced_search.css reads --surface, --brand ... when a page has them: none are set here, so that page
   keeps its own colours, the same in both looks. */
html[data-ui="next"] {
    --brown: 155 115 58;             /* bblue-500 */
    --brown-dark: 132 98 49;         /* bblue-500 15% darker: brown buttons on hover */
    --maroon: 131 11 12;             /* bred-500 (Sign in, the beta switch) */
    --tint: rgb(var(--brown) / .15); /* hover: a light tint of bblue-500 */
    --font-ui: 'Source Sans 3', ui-sans-serif, system-ui, sans-serif;
    --font-read: 'Samuddhara Brackets', 'STIX Two Text', 'Tiro Devanagari Sanskrit', Georgia, serif;
    font-family: var(--font-ui);
    font-kerning: normal;
}
html[data-ui="next"] .font-samuddhara { font-family: 'STIX Two Text', Georgia, serif; }

/* Source Sans 3 has a smaller x-height than Montserrat (0.478 against 0.525): one step up keeps the size */
html[data-ui="next"] .text-sm { font-size: .9375rem; line-height: 1.375rem; }
html[data-ui="next"] .text-xs { font-size: .8125rem; line-height: 1.125rem; }
/* text-l is a typo for text-lg in 36 places; output.css has no rule for it */
html[data-ui="next"] .text-l { font-size: 1.0625rem; line-height: 1.5rem; }

/* ---------- buttons and badges ---------- */
@media (hover: hover) {
    html[data-ui="next"] button.bg-bblue-500:hover, html[data-ui="next"] a.bg-bblue-500:hover { background-color: rgb(var(--brown-dark)); }
}
/* Public / Private badges keep the classic green and beige (asked for in #403 testing), set a little bolder */
html[data-ui="next"] :is(.bg-public-500, .bg-private-500) { font-weight: 600; }

/* ---------- focus: one visible ring everywhere (beats the 55 focus:outline-none), in the classic maroon: it
   stands out on white, on the greys and on the brown header ---------- */
html[data-ui="next"] :focus-visible { outline: 2px solid rgb(var(--maroon)) !important; outline-offset: 2px; }

/* ---------- header: the classic brown band with white text, the seal top left ---------- */
html[data-ui="next"] #app-header { padding-top: 2px; padding-bottom: 2px; }
html[data-ui="next"] #app-header > .flex { align-items: center; min-height: 48px; }
html[data-ui="next"] #app-header > .flex > a:first-child { align-items: center; }
/* the seal: 96 px (2x) and 192 px files cut from samuddhara_logo_large.png, shown at 48 px */
html[data-ui="next"] #app-header .app-logo { width: 48px; height: 48px; flex: none; }
html[data-ui="next"] #app-header .font-samuddhara.text-3xl { letter-spacing: .06em;
    font-size: 1.75rem; line-height: 1; padding: 0 0 0 .75rem; }
/* "The Digital Nyāyabhāṣya Project" as in the classic look: upright STIX Two Text at 16 px, on the wordmark's baseline
   (the editors, #403: not italic) */
html[data-ui="next"] #app-header .font-samuddhara.px-4 { font-style: normal; font-size: 1rem; line-height: 1.5rem; padding-top: .3rem; }
html[data-ui="next"] #app-header > .flex > .mt-1, html[data-ui="next"] #app-header .ml-auto.mt-1 { margin-top: 0; }
html[data-ui="next"] #app-header #badge > div { white-space: nowrap; }
/* Sign in keeps the classic white button and its grey hover */
html[data-ui="next"] #app-header .bg-white.text-bred-500 { font-weight: 600; padding-top: .375rem; padding-bottom: .375rem; }
html[data-ui="next"] .ui-beta-pill { font: 600 .6875rem/1 var(--font-ui); letter-spacing: .06em; text-transform: uppercase;
    color: #fff; border: 1px solid rgb(255 255 255 / .75); border-radius: 999px; padding: .2rem .45rem; }
/* the beta badge links to the page about the new look */
@media (hover: hover) {
    html[data-ui="next"] #app-header a.ui-beta-pill:hover { background: rgb(255 255 255 / .18); text-decoration: none; }
    html[data-ui="next"] #app-header > .flex > a:first-child:hover { text-decoration: none; }
    /* #421: Sign out is a button (signing out takes a POST) that looks like the link it replaced: underlined on
       hover like a text link, without the tint of other text buttons */
    html[data-ui="next"] #badge-menu button:hover { background-color: transparent; border-radius: 0;
        text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
}
/* narrower windows: the subtitle gives way before the collection name or the user name wrap */
@media (max-width: 1279px) {
    html[data-ui="next"] #app-header .font-samuddhara.px-4 { display: none; }
    html[data-ui="next"] #app-header .ui-beta-pill { margin-left: .75rem; }
}

/* tab bar (Images and Transcriptions / Critical Text / Variant Readings): the open tab bold, with a heavier underline */
html[data-ui="next"] .bg-bgray-500.divide-x > .underline { font-weight: 600;
    text-decoration-thickness: 2px; text-underline-offset: 6px; }

/* footer: one line; the long project name gives way (ellipsis) before a link wraps */
html[data-ui="next"] #app-footer > .flex { align-items: baseline; }
html[data-ui="next"] #app-footer > .flex > * { flex: none; white-space: nowrap; }
html[data-ui="next"] #app-footer > .flex > a.text-gray-500:not(.ml-auto) { flex: 0 1 auto; min-width: 0; overflow: hidden;
    text-overflow: ellipsis; }


/* footer switch */
html[data-ui="next"] .ui-switch { display: flex; gap: 1rem; white-space: nowrap; }
html[data-ui="next"] .ui-switch button, html[data-ui="next"] .ui-switch a { margin: 0; }

/* ---------- critical text: reading face, real leading, and a column that gets wider on large screens ---------- */
/* The column (--measure) is 42.75em of the container (38em of the text, which is 1.125 x that size; about 80
   characters a line) up to a 1024 px wide window, and takes every extra pixel beyond, so that the margins stay at
   170 px, until it is 68em (1088 px at A, about 134 characters; from a 1428 px wide window), landscape and portrait
   alike (the editors, #403: on large screens, landscape and portrait, the text and the variant readings used too
   little of the width; at 1280-1536 px, the usual laptop windows, the margins took 300-430 px a side). A-/A/A+
   still write the zoom as an em font-size on the container, so the column grows with the text. */
html[data-ui="next"] #text-container {
    --measure: clamp(42.75em, calc(42.75em + 100% - 1024px), 68em);
    font-family: var(--font-read);
    line-height: 1.65 !important; /* over the classic look's 1.5, the page's inline style */
    font-synthesis: none;
    /* the padding centres the column and leaves a margin for the passage labels (below): at least --gutter, which
       grows with A+ as the labels do (160 px at A, 148 px on tablets, 1rem where the labels stay in the text).
       --label-room is in the labels' own em: the longest label, the gaps and the Compare witnesses icon at its right
       and the Copy link button that opens at its left fit in the narrowest margin. Where the gutter pushes the column
       right (tablets, A+), the right margin is what is left of the window, down to --edge: the column keeps all the
       width it can have. */
    --gutter: 10em;
    --label-room: 9em;
    --edge: 2rem;
    padding-left: max(var(--gutter), calc((100% - var(--measure)) / 2));
    padding-right: max(var(--edge), calc(100% - var(--measure) - max(var(--gutter), calc((100% - var(--measure)) / 2))));
    padding-top: .75rem;
}
html[data-ui="next"] #text-container > p { font-size: 1.125em; margin: 0 0 .65em; }
/* An HTML <p> cannot hold the <div> of a passage number, so the browser ends the paragraph at the number: what
   follows the number in the same TEI paragraph stands outside any <p> (167's critical text from 3.1.63 on), and an
   empty <p> is left where the paragraph ends. That text gets the size of a paragraph (it was smaller), and the empty
   <p> stays as a paragraph end of no height: the passages no longer run on into each other (its margin collapses
   with those around it, so nowhere else gets more space) */
html[data-ui="next"] #text-container > :is(span, a, b, i, em, strong, sup, sub) { font-size: 1.125em; }
html[data-ui="next"] #text-container > p:empty { height: 0; }

/* ---------- passage numbers (the editors, #403, 4 Nov 2026) ----------
   Two numbers can start a passage:
   - the editors' own passage number (a <milestone> and its <emph> in the TEI, which tei_parser.py writes as a grey
     box, div:has(> [data-milestone]), centred above the paragraph in the classic look): the dominant number, bold,
     in the reading face and at the size of the text, at the start of the first line of its passage;
   - the passage label (<note place="left">, .left-note, with the permalink id p-...), such as Thakur's three-part
     chapter.lesson.sūtra: small, in its grey box, in the left margin beside the first line of its passage (on phones
     and on tablets held upright narrower than 860 px, where a margin for it would cost the text its width, in the
     line after the passage number, as before). A label in the middle of a paragraph
     stays where it is in the text, so that it still shows where its passage begins.
   The number stays in the text the classic look shows (copying, the navigator and permalinks see the same page). */
/* the number before a paragraph: floated into the first line of that paragraph */
html[data-ui="next"] #text-container > div:has(> [data-milestone]) {
    display: block; float: left; width: auto; margin: .225em .45em 0 0 !important; padding: 0 .3em !important;
    font: 700 1.125em/1.2 var(--font-read); /* line-height 1.2 and the .225em above it: on the baseline of the text */
}
/* the number inside a TEI paragraph, followed by the rest of that paragraph (see above): in its line. The empty end
   mark of an apparatus entry (span[data-mark]:empty) is no text: a number followed by one and a paragraph (180's
   variant readings, 101) starts that paragraph as the others do, rather than stand alone on a line above it */
html[data-ui="next"] #text-container > div:has(> [data-milestone]):has(+ :not(p, div, [data-mark]:empty)) {
    display: inline-block; float: none; margin: 0 .45em 0 0 !important; vertical-align: baseline;
}
/* passage labels: raised labels in their classic grey box, not part of copied text */
html[data-ui="next"] #text-container .left-note {
    margin-right: .35em; vertical-align: .3em; user-select: none;
    font: 600 .68em/1 var(--font-ui); font-variant-numeric: tabular-nums;
}
html[data-ui="next"] #text-container > .left-note { font-size: .765em; } /* .68 of the paragraph size, outside a <p> */
@media (min-width: 860px) {
    /* A label that starts its paragraph (nothing but the empty start marks of apparatus entries before it), or that
       follows a passage number outside a <p>, goes into the margin, its right edge .5rem from the text, with the
       Compare witnesses icon (synopsis_links.js) between them; on the baseline of the first line of the passage. It
       is as wide as its text, up to --label-room: a longer one (3 concluding verse in 140, 105 px) takes two lines,
       still within the height of a line of the text, rather than run out of the margin. It breaks only between words,
       never inside one (overflow-wrap: normal, over the text's anywhere, and min-width: min-content: at A- the
       rounding of the font made Preliminaries a hair wider than its em, and it broke as Preliminarie-s over the next
       label). It has at least 5rem whatever the zoom: at A- the margin is wide, but browsers keep small text from
       shrinking below a minimum (9 px in the headless Chrome of the checks), so a label at A- three or four times is
       larger beside the text than its em says, and on three lines it ran into the next passage's label (140).
       (width: max-content, as at
       right: 100% the label has no room of its own and would shrink to a letter.) */
    html[data-ui="next"] #text-container > p { position: relative; }
    html[data-ui="next"] #text-container :is(p > .left-note[id]:not(:not([data-mark]) ~ *), div:has(> [data-milestone]) + .left-note[id]) {
        width: max-content; max-width: max(var(--label-room), 5rem); min-width: min-content; white-space: normal;
        overflow-wrap: normal; text-align: right; line-height: 1.15; }
    html[data-ui="next"] #text-container > p > .left-note[id]:not(:not([data-mark]) ~ *) {
        position: absolute; right: 100%; margin: .705em .5rem 0 0; }
    html[data-ui="next"] #text-container > p > .left-note[id]:not(:not([data-mark]) ~ *):has(+ .syn-cmp) {
        margin-right: calc(.75rem + 1.03em); }
    html[data-ui="next"] #text-container > p > .left-note[id]:not(:not([data-mark]) ~ *) + .syn-cmp {
        position: absolute; right: 100%; margin: .57em .5rem 0 0; }
    /* outside a <p> there is no box to measure the margin from: the label is a float that takes no room in the line
       (margin-right -100%) and moves left by its own width and the gap */
    html[data-ui="next"] #text-container > div:has(> [data-milestone]) + .left-note[id] {
        float: left; margin: .705em -100% 0 0; transform: translateX(calc(-100% - .5rem)); }
    html[data-ui="next"] #text-container > div:has(> [data-milestone]) + .left-note[id]:has(+ .syn-cmp) {
        transform: translateX(calc(-100% - .75rem - 1.03em)); }
    html[data-ui="next"] #text-container > div:has(> [data-milestone]) + .left-note[id] + .syn-cmp {
        float: left; margin: .57em -100% 0 0; transform: translateX(calc(-100% - .5rem)); }
    /* the label's Copy link button (permalinks.js) opens into the empty margin at its left, not over the icon and the
       text at its right, so a chosen label needs no extra room */
    html[data-ui="next"] #text-container :is(p > .left-note[id]:not(:not([data-mark]) ~ *), div:has(> [data-milestone]) + .left-note[id]) > .permalink-copy {
        left: auto; right: 100%; margin: 0 3px 0 0; }
    /* ...and its "Link copied" opens below the button, in the margin under the label, not over the label, the icon
       and the passage number (at the button's right) nor off the window (at its left, in a narrow margin) */
    html[data-ui="next"] #text-container :is(p > .left-note[id]:not(:not([data-mark]) ~ *), div:has(> [data-milestone]) + .left-note[id]) > .permalink-copy.is-copied::after {
        left: 0; top: 100%; transform: none; margin: 4px 0 0; }
}
@media (min-width: 860px) and (pointer: coarse) {
    /* touch screens: the Compare witnesses icon is a target of 1.5em of the text (imported_cte.html; 2.21em of the
       label), its glyph half that size in the middle: the label clears the target, and the glyph is level with it */
    html[data-ui="next"] #text-container > p > .left-note[id]:not(:not([data-mark]) ~ *):has(+ .syn-cmp) {
        margin-right: calc(.5rem + 2.21em + 2px); }
    html[data-ui="next"] #text-container > div:has(> [data-milestone]) + .left-note[id]:has(+ .syn-cmp) {
        transform: translateX(calc(-100% - .5rem - 2.21em - 2px)); }
    html[data-ui="next"] #text-container :is(p > .left-note[id]:not(:not([data-mark]) ~ *), div:has(> [data-milestone]) + .left-note[id]) + .syn-cmp {
        margin-top: .17em; }
}
@media (min-width: 860px) and (max-width: 1023px) {
    /* tablets: a narrower margin, labels of up to 6em a line (Preliminaries; 3.1 Section Name takes two), and 1rem
       at the right, so that the column is as wide as before the margin numbers (684 px), and the label's Copy link
       button (26 px on a touch screen) still opens inside the window beside a label as wide as Preliminaries */
    html[data-ui="next"] #text-container { --gutter: 9.25em; --label-room: 6em; --edge: 1rem; }
}
@media (min-width: 768px) and (max-width: 859px) {
    /* tablets held upright (768 px iPad mini, 800 px, 820 px iPad and iPad Air, 834 px iPad Pro): the labels stay in
       the text, as on phones, and the column is centred in margins of 1rem or more; the margin numbers would have
       taken it from 654-684 px down to 590-623 px */
    html[data-ui="next"] #text-container { --gutter: 1rem; --edge: 1rem; }
}
/* the lemma selected in the apparatus (classic black inverse): each line of a wrapped lemma gets its own box */
html[data-ui="next"] #text-container .bg-gray-900.text-white { -webkit-box-decoration-break: clone; box-decoration-break: clone; }
html[data-ui="next"] #lemma-tooltip { font-family: var(--font-read); font-size: .9375rem; line-height: 1.5; }

/* ---------- apparatus: set like a printed apparatus, in the classic colours (pink lemma, light-blue sigla, yellow
   pos., grey om.) ---------- */
/* the classic colours are classes tei_parser.py writes (#394): lem the lemma, wit a witness, pos a pos. witness,
   rdg the list of readings; pages/imported_cte.html colours them in both looks */
html[data-ui="next"] #tab-contents { font-family: var(--font-read); }
html[data-ui="next"] #tab-contents [data-tab] { font: 600 .8125rem/1.4 var(--font-ui); }
/* window headers (apparatus, notes, Sigla; Martin chose option B, 31 Oct 2026): one line of the same height for all, a
   light parchment bar with a stripe on top in the window's classic colour (grey apparatus, yellow notes, blue
   Sigla), the title cut with an ellipsis (full text in its tooltip, next.js), quiet icon buttons (expand, or collapse
   when the window is full screen, and close) and Edit as a text button of the same height */
html[data-ui="next"] #tab-contents [data-tab] { flex: none; height: 2.25rem; margin: .25rem 0 0; padding: 0 .25rem 0 .625rem; gap: .25rem;
    flex-wrap: nowrap; white-space: nowrap; background: #fbf8f2; border-top: 4px solid #9ca3af; cursor: grab; }
html[data-ui="next"] #tab-contents [data-tab].bg-yellow-400 { border-top-color: #eab308; }
html[data-ui="next"] #tab-contents [data-tab].bg-blue-300 { border-top-color: #60a5fa; }
html[data-ui="next"] #tab-contents [data-tab] > div:first-child { margin-left: 0; flex: 1 1 auto; min-width: 0; overflow: hidden;
    text-overflow: ellipsis; }
/* the window's title ("a1: Variant Readings", "Available Witnesses", "Sigla"): in the reading font of the text and the
   page titles, a size larger than the bar's 13 px UI text, which read small and narrow (Martin, 18 Nov 2026); the
   buttons beside it keep the UI font */
html[data-ui="next"] #tab-contents [data-tab] > div:first-child { font: 600 1rem/1.4 var(--font-read); letter-spacing: .005em; }
html[data-ui="next"] #tab-contents [data-tab] > .ml-auto { flex: none; align-items: center; gap: .125rem; }
html[data-ui="next"] #tab-contents [data-tab] > .ml-auto > div { margin: 0; height: 1.75rem; border-radius: 6px; background: transparent;
    color: rgb(46 35 22 / .78); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
html[data-ui="next"] :is(#tab-contents [data-tab] > .ml-auto > div[onclick], #content-text > .header .ml-auto > div[onclick^="toggleTextFullScreen"]) {
    width: 1.75rem; padding: 0; font-size: 0; }
html[data-ui="next"] :is(#tab-contents [data-tab] > .ml-auto > div[onclick], #content-text > .header .ml-auto > div[onclick^="toggleTextFullScreen"])::before {
    content: ""; width: 1rem; height: 1rem; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat;
    mask: var(--icon) center / contain no-repeat; }
html[data-ui="next"] :is(#tab-contents [data-tab] > .ml-auto > div[onclick^="toggleFullScreen"], #content-text > .header .ml-auto > div[onclick^="toggleTextFullScreen"]) {
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6M20 4l-7 7M10 20H4v-6M4 20l7-7'/%3E%3C/svg%3E"); }
html[data-ui="next"] :is(#tab-contents .fullscreen [data-tab] > .ml-auto > div[onclick^="toggleFullScreen"], .text-fullscreen #content-text > .header .ml-auto > div[onclick^="toggleTextFullScreen"]) {
    --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 10h-6V4M14 10l7-7M4 14h6v6M10 14l-7 7'/%3E%3C/svg%3E"); }
html[data-ui="next"] #tab-contents [data-tab] > .ml-auto > div[onclick^="toggleTab"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }
html[data-ui="next"] #tab-contents [data-tab] > .ml-auto > div:has(> a) { padding: 0 .5rem; gap: .3rem; font-size: .8125rem; }
html[data-ui="next"] #tab-contents [data-tab] > .ml-auto > div > svg { width: .875rem; height: .875rem; }
html[data-ui="next"] #tab-contents [data-tab] > .ml-auto > div > a { padding-top: 0; color: inherit; text-decoration: none; }
@media (hover: hover) {
    html[data-ui="next"] :is(#tab-contents [data-tab] > .ml-auto > div, #content-text > .header .ml-auto > div[onclick^="toggleTextFullScreen"]):hover {
        background: #f2e6d3; color: #000; }
}
html[data-ui="next"] :is(#tab-contents [data-tab] > .ml-auto > div, #content-text > .header .ml-auto > div[onclick^="toggleTextFullScreen"]):focus-visible {
    outline: 2px solid rgb(var(--maroon)); outline-offset: 1px; }
html[data-ui="next"] #content-text > .header .ml-auto > div[onclick^="toggleTextFullScreen"] { height: 1.75rem; margin: 0 .25rem; border-radius: 6px;
    background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: rgb(46 35 22 / .78); }
html[data-ui="next"] #tab-contents [id^="tab-content-"] > div.overflow-y-auto { font-size: .9375rem; line-height: 1.5; }
html[data-ui="next"] #tab-contents div[data-ref] { padding: 0 .25rem; border-radius: 2px; cursor: pointer; }
@media (hover: hover) { html[data-ui="next"] #tab-contents div[data-ref]:hover { background: var(--tint); } }
html[data-ui="next"] #tab-contents span.lem { font-weight: 600; }
html[data-ui="next"] #tab-contents ul.rdg { list-style: none !important; margin: .1em 0 .5em 1.2em !important; }
html[data-ui="next"] #tab-contents :is(.wit, .pos) { white-space: nowrap; }
/* sigla: interface face in the classic chips. Specificity (0,0,1) on purpose: below the .slN classes that carry the
   sigla formatting the TEI declares (#386) */
:where(html[data-ui="next"] #tab-contents) :is(a, span, button):where(.wit, .pos) {
    font-family: var(--font-ui); font-weight: 600; font-size: .84em;
}
html[data-ui="next"] #tab-contents :is(.lem, .wit, .pos) sup { font-size: .76em; } /* preflight already raises sup */
/* #367: a group siglum is a <button class="sg"> in the plain classic light-blue chip; its arrow, full size rather than
   the classic .7em, marks it as a control. On hover and while its witnesses are listed it gets a dark edge and a shade
   darker chip (a shadow, which leaves the chip's own background as it is) */
html[data-ui="next"] #tab-contents button.sg { border-radius: 3px; padding: 0 .3em !important; }
html[data-ui="next"] #tab-contents button.sg[aria-expanded="true"] {
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / .7), inset 0 0 0 100vmax rgb(0 0 0 / .08); }
@media (hover: hover) { html[data-ui="next"] #tab-contents button.sg:hover {
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / .7), inset 0 0 0 100vmax rgb(0 0 0 / .08); } }
html[data-ui="next"] #tab-contents button.sg::after { font-size: 1em; margin-left: .15em; }
/* om. and ac/pc: italic editorial abbreviations in their classic grey boxes */
html[data-ui="next"] #tab-contents li > span.bg-gray-200.rounded { font-style: italic; }
html[data-ui="next"] #tab-contents span.bg-gray-200:not(.rounded) { font-style: italic; font-size: .8em; }

/* ---------- transcription panel (viewer): reading face; text and line numbers share one line-height ---------- */
html[data-ui="next"] #texts_view, html[data-ui="next"] #txt, html[data-ui="next"] #txtNums {
    font-family: var(--font-read); font-size: 1.0625em; line-height: 1.7; font-synthesis: none; }
html[data-ui="next"] #texts_view .line-number, html[data-ui="next"] #txtNums { font-family: var(--font-ui); }

/* ---------- hover: everything clickable shows that it is (#403 testing), in classic colours: a light tint of the
   brown, the brown for borders, red for Delete. Only where a pointer can hover: on a touch screen a :hover style
   stays on after the tap and looks like a selected state (pressing still shows, through :active) ---------- */
html[data-ui="next"] :is(a[href], button:not(:disabled), select, summary, label[for], [onclick], [hx-get], [hx-post], [hx-delete],
    [role="button"], input:is([type="checkbox"], [type="radio"], [type="submit"], [type="button"])) { cursor: pointer; }
html[data-ui="next"] :is(a, button, select, svg[onclick], div.border) {
    transition: background-color .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease; }
@media (prefers-reduced-motion: reduce) { html[data-ui="next"] :is(a, button, select, svg[onclick], div.border) { transition: none; } }

/* outlined actions are <div class="border rounded"><a>label</a></div> (home rows): the whole box lights up and is clickable
   (the link's ::after named without :has(), as the Images and Transcriptions toolbar below) */
html[data-ui="next"] div.border.rounded:has(> a[href]) { position: relative; }
html[data-ui="next"] div.border.rounded > a[href]::after { content: ""; position: absolute; inset: 0; }
@media (hover: hover) {
    html[data-ui="next"] div.border.rounded:has(> a[href]):hover { background-color: var(--tint); border-color: rgb(var(--brown));
        box-shadow: 0 1px 3px rgb(0 0 0 / .14); }
    /* Delete: a tint of its own red-500 */
    html[data-ui="next"] div.border.rounded.border-red-500:has(> a[href]):hover { background-color: rgb(239 68 68 / .1);
        border-color: rgb(239 68 68); }
}

/* the home-row actions are light buttons: dark brown text on parchment, a pale tint of the classic brown (Martin
   found filled brown too heavy for a whole row, even lightened). Hover lights them up in honey gold with a brown
   edge and lifts them; pressing deepens the gold. Delete stays white on the classic red-500, hover a deeper red.
   Keyboard focus rings the whole button. */
html[data-ui="next"] div.border.rounded.border-bblue-500:has(> a[href]) { background-color: rgb(242 230 211);
    border-color: rgb(217 195 160); color: rgb(74 53 25); font-weight: 600; }
@media (hover: hover) {
    html[data-ui="next"] div.border.rounded.border-bblue-500:has(> a[href]):hover { background-color: rgb(232 201 138);
        border-color: rgb(184 137 63); box-shadow: 0 2px 4px rgb(0 0 0 / .15); }
}
html[data-ui="next"] div.border.rounded.border-bblue-500:has(> a[href]):active { background-color: rgb(221 183 107);
    border-color: rgb(var(--brown)); box-shadow: none; }
html[data-ui="next"] div.border.rounded.border-red-500:has(> a[href]) { background-color: rgb(239 68 68);
    border-color: rgb(239 68 68); color: #fff; font-weight: 600; }
@media (hover: hover) {
    html[data-ui="next"] div.border.rounded.border-red-500:has(> a[href]):hover { background-color: rgb(220 38 38);
        border-color: rgb(220 38 38); box-shadow: 0 2px 4px rgb(0 0 0 / .2); }
}
html[data-ui="next"] div.border.rounded.border-red-500:has(> a[href]):active { background-color: rgb(185 28 28);
    border-color: rgb(185 28 28); box-shadow: none; }
html[data-ui="next"] div.border.rounded:has(> a[href]:focus-visible) { outline: 2px solid rgb(var(--maroon)); outline-offset: 2px; }
html[data-ui="next"] div.border.rounded > a[href]:focus-visible { outline: none !important; }

/* plain text links: underlined, in their own colour */
@media (hover: hover) {
    html[data-ui="next"] a[href]:not([class*="bg-"]):not([class*="border"]):not(div.border > a):hover {
        text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
}

/* buttons without a fill (text and icon buttons), icon controls and the viewer's arrows. Not the advanced search
   pill buttons: advanced_search.css gives them their own hover, the same in both looks */
@media (hover: hover) {
    html[data-ui="next"] button:not(:disabled):not([class*="bg-"]):not(.sg):not(.as-button):hover,
    html[data-ui="next"] svg[onclick]:hover { background-color: var(--tint); border-radius: 4px; }
}

/* drop-downs, search fields and bordered toggles such as Hyphenate */
@media (hover: hover) {
    html[data-ui="next"] select:hover,
    html[data-ui="next"] :is(label, div, span)[class*="border"][class*="rounded"]:has(> input[type="checkbox"]):hover {
        border-color: rgb(var(--brown)); background-color: var(--tint); }
    html[data-ui="next"] input:is([type="text"], [type="search"]):hover { border-color: rgb(var(--brown)); }
}

/* tabs (Images and Transcriptions / Critical Text / Variant Readings) */
@media (hover: hover) {
    html[data-ui="next"] .divide-x > :is(div, a):has(a[href]):hover,
    html[data-ui="next"] .divide-x > a[href]:hover { background-color: var(--tint); }
}

/* ======================================================================================================== */
/* ---------- responsive (#403: "new theme can we make it responsive?"). Breakpoints are Tailwind's: phones
   below 768 px (md), tablets below 1024 (lg), small laptops below 1280 (xl); 1280 and up is the desktop look
   above, which these rules leave alone apart from bugs that show at every width. Touch screens
   ((pointer: coarse)) get tap targets of about 44 px. Layout only: every colour stays the classic one. ---------- */

/* ---------- the frame: header, content, footer fill the screen ---------- */
/* 100dvh: the visible screen, without the mobile browser's address bar and toolbar (100vh is the fallback) */
html[data-ui="next"] body > .h-screen { height: 100vh; height: 100dvh; }
/* the content box clips without being a scroll container (clip, not hidden): scrollIntoView() of an apparatus
   entry used to scroll the whole reading area up under the header, toolbar and all, until the next reload.
   min-height 0, because a box that only clips would otherwise grow to its content */
html[data-ui="next"] body > .h-screen > .w-full.flex-1 { overflow: hidden; overflow: clip; min-height: 0; }

/* ---------- header ---------- */
@media (max-width: 1279px) {
    /* the collection name gives way (ellipsis) before the user name or the beta badge are pushed out; the page
       itself and its ⓘ show the full name */
    html[data-ui="next"] #app-header > .flex > .flex-1 { min-width: 0; margin-left: .75rem; margin-right: .75rem; }
    html[data-ui="next"] #app-header > .flex > .flex-1 > :not(.about-link) { min-width: 0; overflow: hidden;
        text-overflow: ellipsis; white-space: nowrap; }
    html[data-ui="next"] #app-header > .flex > .ml-auto { flex: none; }
    html[data-ui="next"] #app-header #badge > div { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
    /* the title link's focus ring is drawn inside the room the clipping box keeps around it */
    html[data-ui="next"] #app-header > .flex > .flex-1 > :not(.about-link) { padding: 4px; margin: -4px; }
}
@media (max-width: 1023px) {
    /* tablets: a shorter user name and a smaller wordmark leave the collection name more than a few letters */
    html[data-ui="next"] #app-header #badge > div { max-width: 8rem; }
    html[data-ui="next"] #app-header .font-samuddhara.text-3xl { font-size: 1.5rem; }
    html[data-ui="next"] #app-header > .flex > .flex-1 .text-2xl { font-size: 1.25rem; }
}
@media (max-width: 767px) {
    /* phones: a smaller seal and wordmark; the collection name moves to a second line of its own */
    html[data-ui="next"] #app-header { padding-left: .75rem; padding-right: .75rem; }
    html[data-ui="next"] #app-header > .flex { flex-wrap: wrap; column-gap: .375rem; }
    html[data-ui="next"] #app-header .app-logo { width: 40px; height: 40px; }
    html[data-ui="next"] #app-header .font-samuddhara.text-3xl { font-size: 1.125rem; letter-spacing: .03em; padding-left: .5rem; }
    html[data-ui="next"] #app-header .ui-beta-pill { margin-left: .125rem; }
    html[data-ui="next"] #app-header > .flex > .ml-auto { margin-right: 0; min-width: 0; }
    html[data-ui="next"] #app-header .bg-white.text-bred-500 { padding-left: .75rem; padding-right: .75rem; }
    html[data-ui="next"] #app-header #badge > div { max-width: 8rem; }
    html[data-ui="next"] #app-header > .flex > .flex-1 { order: 3; flex: 1 0 100%; justify-content: flex-start;
        margin: 0 0 .25rem; font-size: 1rem; line-height: 1.375rem; }
    html[data-ui="next"] #app-header > .flex > .flex-1 .text-2xl { font-size: 1.125rem; }
    html[data-ui="next"] #app-header > .flex > .flex-1 .about-link { margin-bottom: 0; }
    /* the account menu opens to the left, under the badge at the right edge */
    html[data-ui="next"] #badge-menu { left: auto; right: 0; }
}
@media (max-width: 479px) {
    /* small phones: a person icon stands for the user name (kept for screen readers), next to the menu arrow */
    html[data-ui="next"] #app-header #badge { cursor: pointer; }
    html[data-ui="next"] #app-header #badge > div { position: absolute; width: 1px; height: 1px; overflow: hidden;
        clip-path: inset(50%); white-space: nowrap; }
    html[data-ui="next"] #app-header #badge::before { content: ""; width: 1.75rem; height: 1.75rem; background: currentColor;
        -webkit-mask: var(--person) center / contain no-repeat; mask: var(--person) center / contain no-repeat; }
    html[data-ui="next"] #app-header { --person: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='%23000'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z'/%3E%3C/svg%3E"); }
}

/* ---------- the tab and quick-search bar under the header (Images and Transcriptions / Critical Text / Variant
   Readings, the search box) ---------- */
@media (max-width: 1023px) {
    /* the tabs stay one swipeable line; the search form gets a line of its own below them */
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap { flex-wrap: wrap; overflow: visible; white-space: normal; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap > .ml-auto { flex: 1 1 100%; margin-left: 0;
        padding: .375rem 0; justify-content: flex-start; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form { flex: 1 1 auto; min-width: 0; flex-wrap: wrap;
        justify-content: flex-start; gap: .375rem .5rem; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form > * { margin: 0; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form > .rounded-lg { flex: 1 1 10rem; min-width: 0;
        align-items: center; min-height: 2.5rem; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form input[name="q"] { flex: 1 1 auto; min-width: 0; width: 100%; padding-left: .25rem; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form #search-kb { height: 2.5rem; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form a[aria-label="Advanced search"] {
        display: inline-flex; align-items: center; justify-content: center; width: 2.5rem; height: 2.5rem; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap :is(form, form > div.h-full) { height: auto; }
    /* "in <collection>": the name shortened */
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form > div.h-full { max-width: 14rem; }
}
@media (max-width: 1279px) {
    /* "in <collection>" ends in an ellipsis instead of being cut off at the right edge of the bar (1024 px with
       touch: the larger check box no longer left room for the whole name) */
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap > .ml-auto:has(form),
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap :is(form, form > div.h-full) { min-width: 0; }
    /* the tab strip beside it (full width, mostly empty) gives up its room first */
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap > .bg-bgray-500 { flex: 1 1 0; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form > div.h-full > b { min-width: 0; overflow: hidden;
        text-overflow: ellipsis; white-space: nowrap; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
    /* a name that fitted before still does: the space added after "in" is taken from the keyboard choice's margin,
       and the name may run into the bar's right padding as it always did */
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form > #search-kb { margin-right: .25rem; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap:has(form) { padding-right: .25rem; }
    /* the keyboard symbol (#372) gives way beside the tabs, where it would push out the name (at 1024 px, "in" and the
       check box too): no width, but still there to name the keyboard choice for screen readers */
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap:has(> .bg-bgray-500) form > #search-kb-label {
        width: 0; margin: 0; overflow: hidden; }
}

@media (max-width: 639px) {
    /* phones: the Velthuis keyboard choice, and its keyboard symbol (#372), give their room to the search box (a phone
       has its own keyboards) */
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form :is(#search-kb, #search-kb-label) { display: none; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form > .rounded-lg { flex-basis: 7rem; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form > div.h-full { max-width: 8rem; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form > input[type="checkbox"] { margin-left: -.25rem; }
}

/* ---------- tab strips (the bar above, the critical text toolbar, the collection pages' Manage / Edit /
   Share ... bars): each label on one line instead of wrapping inside its tab. On a touch screen the strip is one
   line that swipes sideways (next.js brings the open tab into view); with a mouse, where a sideways strip
   can be neither seen nor wheeled, whole tabs wrap onto a second line ---------- */
@media (max-width: 1023px), (max-width: 1279px) and (pointer: coarse) {
    html[data-ui="next"] :is(.bg-bgray-500.divide-x, .flex.w-full.bg-bgray-500:has(> .ml-10:first-child)) {
        flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; }
    /* a scroll box's automatic minimum size is 0: at the top of a full page column the strip was squashed out of
       sight (Edit collection on phones) */
    html[data-ui="next"] .flex-col > :is(.bg-bgray-500.divide-x, .flex.w-full.bg-bgray-500:has(> .ml-10:first-child)) { flex-shrink: 0; }
    /* a strip's tabs: the same elements as "strip > *", but named without :has() (the ml-10 strip's are its first
       child and the ones after it). With :has() before "> *" every element added anywhere on the page restyled the
       whole page in Chrome (60-85 ms on the critical text page, at each group of a long apparatus window made, #394,
       #403 "Back to"); the same specificity as before */
    html[data-ui="next"] :is(.bg-bgray-500.divide-x > *, .flex.w-full.bg-bgray-500 > .ml-10:first-child, .flex.w-full.bg-bgray-500 > .ml-10:first-child ~ *) {
        flex: none; white-space: nowrap; }
    html[data-ui="next"] .flex.w-full.bg-bgray-500 > .ml-10:first-child { margin-left: 0; }
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap > .bg-bgray-500 { min-width: 0; }
    /* keyboard focus: the ring goes round the whole tab, inside the strip that would clip it */
    html[data-ui="next"] :is(.bg-bgray-500.divide-x > *, .flex.w-full.bg-bgray-500 > .ml-10:first-child, .flex.w-full.bg-bgray-500 > .ml-10:first-child ~ *):has(> a:focus-visible) {
        outline: 2px solid rgb(var(--maroon)); outline-offset: -2px; }
    html[data-ui="next"] :is(.bg-bgray-500.divide-x > *, .flex.w-full.bg-bgray-500 > .ml-10:first-child, .flex.w-full.bg-bgray-500 > .ml-10:first-child ~ *) > a:focus-visible {
        outline: none !important; }
}
@media (max-width: 1023px) {
    html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap > .bg-bgray-500 { flex: 1 1 100%; }
}
@media (max-width: 1023px) and (pointer: fine) {
    html[data-ui="next"] :is(.bg-bgray-500.divide-x, .flex.w-full.bg-bgray-500:has(> .ml-10:first-child)) {
        flex-wrap: wrap; overflow-x: visible; }
}
@media (max-width: 1279px) and (pointer: coarse) {
    html[data-ui="next"] :is(.bg-bgray-500.divide-x, .flex.w-full.bg-bgray-500:has(> .ml-10:first-child)) { scrollbar-width: none; }
    html[data-ui="next"] :is(.bg-bgray-500.divide-x, .flex.w-full.bg-bgray-500:has(> .ml-10:first-child))::-webkit-scrollbar { display: none; }
    /* the strips' tabs, named without :has() as above */
    html[data-ui="next"] :is(.bg-bgray-500.divide-x > :is(div, a), .flex.w-full.bg-bgray-500 > .ml-10:first-child:is(div, a), .flex.w-full.bg-bgray-500 > .ml-10:first-child ~ :is(div, a)) {
        padding-top: .5rem; padding-bottom: .5rem; align-items: center; }
}

/* ---------- footer ---------- */
@media (max-width: 767px) {
    /* phones: the links wrap onto a second line instead of running off the screen (staff have four more); the
       look switch stays in the footer, at the right */
    html[data-ui="next"] #app-footer { padding-left: 1rem; padding-right: 1rem; }
    html[data-ui="next"] #app-footer > .flex { flex-wrap: wrap; column-gap: 1rem; align-items: center; }
    html[data-ui="next"] #app-footer > .flex > * { margin: 0; }
    html[data-ui="next"] #app-footer > .flex > a.text-gray-500:not(.ml-auto) { display: none; }
    /* the padding is on the link and the switch's button themselves, so a tap on it counts */
    html[data-ui="next"] #app-footer > .flex > a, html[data-ui="next"] #app-footer > .flex > form.ui-switch > :is(button, a) {
        padding-top: .5rem; padding-bottom: .5rem; }
    html[data-ui="next"] #app-footer > .flex > form.ui-switch { margin-left: auto; }
}
@media (min-width: 768px) and (pointer: coarse) {
    html[data-ui="next"] #app-footer > .flex > a, html[data-ui="next"] #app-footer > .flex > form.ui-switch > :is(button, a) {
        padding-top: .5rem; padding-bottom: .5rem; }
}

/* ---------- touch: tap targets of about 44 px, the look unchanged ---------- */
@media (pointer: coarse) {
    /* the beta badge and Sign in: a larger invisible hit area around the same shape */
    html[data-ui="next"] #app-header :is(.ui-beta-pill, .bg-white.text-bred-500) { position: relative; }
    html[data-ui="next"] #app-header .ui-beta-pill::after { content: ""; position: absolute; inset: -12px -6px; }
    html[data-ui="next"] #app-header .bg-white.text-bred-500::after { content: ""; position: absolute; inset: -4px; }
    html[data-ui="next"] #app-header #badge { min-height: 44px; min-width: 44px; padding-top: 0; }
    html[data-ui="next"] #badge-menu :is(a, button) { padding-top: .75rem; padding-bottom: .75rem; }
    /* pill buttons (Create, Import, Submit, Save, Approve ...) */
    html[data-ui="next"] :is(a, button).bg-bblue-500.rounded-full:not(.hidden) { min-height: 44px; display: inline-flex;
        align-items: center; justify-content: center; }
    html[data-ui="next"] .ui-beta-page button, html[data-ui="next"] .ui-beta-page .rounded-full { min-height: 44px; }
    /* small check boxes: 24 px, the WCAG 2.5.8 minimum */
    html[data-ui="next"] input[type="checkbox"]:not(.sr-only) { width: 1.5rem; height: 1.5rem; }
}

/* ---------- home: the collection list ---------- */
/* .row is only the home row (widgets/home_row.html). Its actions wrap onto a second line rather than squeezing:
   at 1280 px and below the eight actions of an editable row no longer fit in one, and a squeezed label wrapped
   inside its 32 px button and spilled out below it, white on the white page */
html[data-ui="next"] .row > .w-32.h-32 { flex: none; }
html[data-ui="next"] .row .flex.flex-row.ml-auto.h-8 { height: auto; flex-wrap: wrap; justify-content: flex-end;
    row-gap: .5rem; min-width: 0; align-self: flex-start; align-items: flex-start; }
html[data-ui="next"] .row .flex.flex-row.ml-auto.h-8 > div.border.rounded { flex: none; white-space: nowrap; }
@media (pointer: coarse) {
    /* the title and owner links: a taller hit area, the same layout */
    html[data-ui="next"] .row .w-64 a { display: inline-block; padding-top: .375rem; padding-bottom: .375rem;
        margin-top: -.375rem; margin-bottom: -.375rem; }
    html[data-ui="next"] .row .flex.flex-row.ml-auto.h-8 > div.border.rounded { padding: .5rem .625rem; }
}
@media (max-width: 767px) {
    /* phones: a smaller picture beside the title; the actions go below the title, from the left */
    html[data-ui="next"] .row > .w-32.h-32 { width: 5.5rem; height: auto; padding: .75rem 0 .75rem 1rem; }
    html[data-ui="next"] .row > .grow { padding: .5rem 1rem .75rem .75rem; min-width: 0; }
    html[data-ui="next"] .row > .grow > .flex.w-full { flex-direction: column; gap: .5rem; }
    html[data-ui="next"] .row .flex.flex-col.w-64 { width: auto; min-width: 0; }
    html[data-ui="next"] .row .flex.flex-col.w-64 .text-2xl { font-size: 1.375rem; line-height: 1.2; }
    html[data-ui="next"] .row .flex.flex-row.ml-auto.h-8 { margin-left: 0; justify-content: flex-start; align-self: stretch; }
    html[data-ui="next"] .row .flex.flex-row.ml-auto.h-8 > div.border.rounded { margin: 0 .5rem 0 0; }
    /* the Collections / New Collection: Create Import bar */
    html[data-ui="next"] .flex.w-full.my-2.h-8.text-l { height: auto; flex-wrap: wrap; align-items: center; row-gap: .5rem;
        padding: 0 1rem; }
    html[data-ui="next"] .flex.w-full.my-2.h-8.text-l > .ml-6 { margin-left: 0; }
    html[data-ui="next"] .flex.w-full.my-2.h-8.text-l > .mr-10 { margin-right: 0; }
}
@media (max-width: 479px) {
    html[data-ui="next"] .flex.w-full.my-2.h-8.text-l > .ml-auto.text-black { display: none; }
    html[data-ui="next"] .flex.w-full.my-2.h-8.text-l > .ml-auto.text-black + a { margin-left: auto; }
}

/* ---------- sign in, sign up, forgotten password: the 700 px card becomes one column on phones ---------- */
@media (max-width: 767px) {
    html[data-ui="next"] .bg-gray-100.w-full.flex-1.px-6:has(> .min-w-700) { padding: 1rem; overflow-y: auto; align-items: flex-start; }
    html[data-ui="next"] .min-w-700 { min-width: 0; width: 100%; max-width: 28rem; flex-direction: column; margin: auto 0; flex: none; }
    html[data-ui="next"] .min-w-700 > .w-1\/2 { width: 100%; }
    html[data-ui="next"] .min-w-700 > .bg-bblue-500 img { width: 6rem; padding: 1rem 0 0; }
    html[data-ui="next"] .min-w-700 > .bg-bblue-500 .text-\[2\.8em\] { font-size: 1.75rem; padding: .25rem 0 .75rem; }
    html[data-ui="next"] .min-w-700 > .min-h-500 { min-height: 0; padding-bottom: 1rem; }
}

/* ---------- About, Help, Contact (Wagtail pages): their own scroll bar at every width (before, a page taller
   than the window was cut off: at 1280 x 800 the Contact form's Submit). Below 1280 px also a gutter and a
   ~70-character measure, where the text ran from edge to edge; 1280 and up keep the desktop layout ---------- */
html[data-ui="next"] .form-page-thanks, html[data-ui="next"] .flex.flex-col.w-full:has(> .max-w-screen-lg) { overflow-y: auto; }
@media (max-width: 1279px) {
    html[data-ui="next"] .form-page-thanks { max-width: none; margin: 0; padding: 1.25rem max(1rem, calc((100% - 44rem) / 2)) 2rem;
        overflow-wrap: anywhere; }
    html[data-ui="next"] .flex.flex-col.w-full > .max-w-screen-lg { width: 100%; max-width: 46rem; padding-left: 1rem; padding-right: 1rem; }
    html[data-ui="next"] .flex.flex-col.w-full > .max-w-screen-lg:last-child { padding-bottom: 2rem; }
    html[data-ui="next"] form.form-page :is(input:not([type="checkbox"]):not([type="radio"]), textarea, select) { max-width: 100%; }
    /* /ui/beta: about 75 characters a line (its inline 46rem gave over 100) */
    html[data-ui="next"] .ui-beta-page { max-width: 40rem !important; }
}
/* /ui/beta: its visually hidden legend is placed inside the page's own scroller, not against the window, where
   it made the whole frame scroll by a few pixels */
html[data-ui="next"] .ui-beta-page { position: relative; }

/* ---------- Images and Transcriptions (the manuscript viewer) ---------- */
/* "in <collection>" beside the search box: a space between the two words */
html[data-ui="next"] body > .h-screen > .bg-gray-100.whitespace-nowrap form > div.h-full { gap: .25rem; }
/* the Witness / Passage / Folio / All Folios row and the image toolbar wrap instead of being cut off at the right.
   The row is named by its id (pages/overview.html), with the specificity ":has(#witness)" gave it: a :has() before a
   combinator to a plain element ("> div", "> a", "[hidden]") made Chrome restyle far more than an element added
   anywhere on a page, some 15 ms each time on phones on the critical text page (#403 "Back to", tests/test_ui_beta.py) */
html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b { flex-wrap: wrap; }
html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > .divide-x { white-space: nowrap; }
html[data-ui="next"] .bg-bgray-500.h-8:has(#osd_buttons) { height: auto; min-height: 2rem; flex-wrap: wrap; }
html[data-ui="next"] :is(#showrl, #hiderl, #highlight_lemma, #transcription_edit, label[for="hyphenate"]) { white-space: nowrap; }
html[data-ui="next"] #rlRange { max-width: 40vw; }
/* the transcription toolbar (A buttons, keyboard, History, Highlight Lemma, Hyphenate, Edit) */
html[data-ui="next"] #tab-transcription form > div.bg-bgray-500.flex-row { flex-wrap: wrap; }
/* the splitter between image and transcription can be dragged with a finger (next.js) */
html[data-ui="next"] #move { touch-action: none; }
@media (pointer: coarse) {
    html[data-ui="next"] #move { padding-top: .5rem; padding-bottom: .5rem; }
    /* the arrows beside the passage and folio pickers */
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b svg[onclick] { box-sizing: content-box; padding: .5rem .25rem; }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b button { min-width: 2.75rem; min-height: 2.75rem;
        display: inline-flex; align-items: center; justify-content: center; }
    html[data-ui="next"] :is(#witness, #passage, #folio, #all_folios, #keyboard) { min-height: 2.25rem; }
    html[data-ui="next"] :is(#showrl, #hiderl, #toggle-annotations-btn) { min-height: 2.25rem; padding-left: .5rem; padding-right: .5rem; }
}
@media (max-width: 1279px) {
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > .divide-x { flex-wrap: wrap; }
}
@media (max-width: 767px) {
    /* phones: two pickers a line (Witness and Passage, then Folio and All Folios), each label above its picker;
       the jump-to-first / last arrows give way to the pickers */
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b { padding: .125rem .25rem .25rem; }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > div { flex: 0 0 50%; min-width: 0; margin: 0;
        border-left-width: 0; border-right-width: 0; padding: 0 .25rem; }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > div:has(> label) { display: grid; align-items: center;
        grid-template-columns: auto minmax(0, 1fr) auto; }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > div:first-child { flex: 1 1 0; grid-template-columns: minmax(0, 1fr); }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > div:nth-child(2) { flex: none; align-self: flex-end; padding: 0; }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > div > label { grid-column: 1 / -1; margin: 0; padding-top: .125rem;
        line-height: 1rem; }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b svg[onclick*="_SAFE_INTEGER"] { display: none; }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b :is(select, #distinct_folio) { min-width: 0; max-width: none;
        width: 100%; padding-left: .375rem; padding-right: .125rem; }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > .divide-x { flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto;
        padding: 0; order: 2; }
    /* roadmap idea 5: Compare witnesses on a line of its own after the pickers, so they stay two a line; idea 6: Back to
       critical text beside it on that line */
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > :is(.synopsis-link, .cte-back-link) { order: 1; flex: 1 1 auto; padding: 0 .25rem; }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > .synopsis-link + .cte-back-link { justify-content: flex-end; }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > :is(.synopsis-link, .cte-back-link) > a { display: inline-flex; align-items: center;
        min-height: 2.25rem; }
    /* there it has room for its whole label, which the desktop toolbar shortens (an editor's to the icon alone) */
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > :is(.synopsis-link, .cte-back-link) [hidden] { display: inline; }
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > .cte-back-link .cte-back-short { display: none; }
    /* the image above the transcription, never side by side (next.js keeps portrait folios stacked too) */
    html[data-ui="next"] div:has(> #portrait_icon), html[data-ui="next"] div:has(> #landscape_icon) { display: none; }
    /* editors: the Transcription / Watermark tabs name the pane, so the toolbar drops its own title (#text has
       data-tabs where it has the tabs, without :has(), as above) */
    html[data-ui="next"] #text[data-tabs] #tab-transcription form > div.bg-bgray-500 > div.font-bold:first-child { display: none; }
    html[data-ui="next"] #tab-transcription form > div.bg-bgray-500 { padding: .125rem .25rem; row-gap: .25rem; align-items: center; }
    html[data-ui="next"] #tab-transcription form > div.bg-bgray-500 > :is(.ml-auto, .mr-5, .mr-2) { margin-right: .25rem; }
    html[data-ui="next"] #tab-transcription form > div.bg-bgray-500 > :is(.mb-1, .mt-1) { margin-top: 0; margin-bottom: 0; }
    /* the page scrolls like a document, and the image and transcription get a screen of their own below the
       pickers and toolbars: in the fixed frame an editor's transcription was left no room at all (0 px at
       360 x 740). svh, the screen with the browser's toolbars shown, does not change while the page scrolls */
    html[data-ui="next"] body > .h-screen:has(#ImageAndText) { height: auto; min-height: 100vh; min-height: 100dvh; }
    html[data-ui="next"] body > .h-screen:has(#ImageAndText) > .w-full.flex-1 { flex: 1 0 auto; overflow: visible; overflow-x: clip; }
    html[data-ui="next"] .flex-grow.overflow-hidden:has(> #ImageAndText) { flex: none; height: 100vh; height: 100svh; }
}

@media (max-width: 767px) and (pointer: coarse) {
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > .divide-x { scrollbar-width: none; }
}
@media (max-width: 767px) and (pointer: fine) {
    /* a narrow window with a mouse: the editor links wrap rather than hide past an edge that cannot be scrolled */
    html[data-ui="next"] #witness-toolbar.bg-bgray-500.border-b > .divide-x { flex-wrap: wrap; overflow-x: visible; }
}

/* the witness metadata and collection About windows: above the image toolbar (z-index 30), which showed through
   them and caught taps once they moved up on tablets and phones; inside the screen there */
html[data-ui="next"] :is(#metadata-modal, #about-modal) { z-index: 50; }
@media (max-width: 1023px) {
    html[data-ui="next"] :is(#metadata-modal, #about-modal) > .fixed.h-fit { left: 1rem; right: 1rem; top: 4rem; width: auto;
        max-width: 40rem; margin: 0 auto; }
    html[data-ui="next"] #htmxModal { width: calc(100vw - 2rem); max-width: 40rem; }
    html[data-ui="next"] #htmxModal > .overflow-y-scroll[style], html[data-ui="next"] #about-modal .px-8.py-4[style] {
        height: auto !important; max-height: calc(100vh - 9rem); max-height: calc(100dvh - 9rem); overflow-y: auto; }
    html[data-ui="next"] #about-modal .px-8.py-4[style] { padding-left: 1.25rem; padding-right: 1.25rem; }
}
/* metadata category tabs (the window above and the Manage metadata page) wrap instead of running off */
html[data-ui="next"] ul.flex.border-b-4.border-gray-100 { flex-wrap: wrap; }
@media (pointer: coarse) {
    html[data-ui="next"] :is(#metadata-modal, #about-modal) .bg-bblue-500 > div[onclick] { padding: .5rem; margin: -.5rem; }
}

/* transcription history: a narrower gutter on phones; long changed words break */
html[data-ui="next"] [id^="diff_"] { overflow-wrap: anywhere; }
@media (max-width: 639px) {
    html[data-ui="next"] .overflow-y-scroll:has(> .text-xl.text-center.p-4) > .px-10 { padding-left: 1rem; padding-right: 1rem; }
    html[data-ui="next"] .overflow-y-scroll > .text-xl.text-center.p-4 { font-size: 1.125rem; padding: .75rem 1rem; }
}

/* ---------- critical text and variant readings ---------- */
/* the page fills the content box: its 94vh ran 20-50 px under the footer, which hid the bottom of the apparatus
   and let a lemma's scrollIntoView() push the toolbar up under the header */
html[data-ui="next"] #full { height: auto; min-height: 0; }
html[data-ui="next"] #content-main.text-fullscreen #content-text { height: 100% !important; }
/* a long compound (members joined by ZWNJ, which is no break opportunity) breaks where it must instead of
   widening the text into a pane that scrolls sideways */
html[data-ui="next"] #text-container { overflow-x: hidden; overflow-wrap: anywhere; }
html[data-ui="next"] #tab-contents [id^="tab-content-"] > div.overflow-y-auto { overflow-wrap: anywhere; }
/* the toolbar: labels on one line, tools centred on it */
html[data-ui="next"] #content-text > .header a { white-space: nowrap; }
html[data-ui="next"] #content-text > .header > .ml-auto { align-items: center; }
/* the burger menu opens below the toolbar, above it in the stacking order (next.js places it under the button) */
html[data-ui="next"] #apparatus-dropdown { z-index: 30; overflow-y: auto; }
@media (max-width: 1023px) {
    html[data-ui="next"] #content-text > .header > .flex.bg-bgray-500 > div { padding-left: .625rem; padding-right: .625rem; }
}
@media (max-width: 767px) {
    /* phones: the tabs on the first line (they swipe), the tools on the second (the Apparatuses button, which was the
       burger beside the tabs, is in the navigator's toolbar below, cte_nav.css) */
    html[data-ui="next"] #content-text > .header { flex-wrap: wrap; row-gap: .25rem; padding-top: .25rem; padding-bottom: .25rem; }
    html[data-ui="next"] #content-text > .header > .flex.bg-bgray-500 { flex: 1 1 100%; min-width: 0; }
    html[data-ui="next"] #content-text > .header > .ml-auto { flex: 1 1 100%; margin-left: 0; justify-content: flex-end;
        flex-wrap: wrap; row-gap: .25rem; }
    html[data-ui="next"] #content-text > .header > .ml-auto > :first-child { margin-left: 0; }
    /* the text uses the width of the screen: the passage labels stay in the text, after the passage number (see
       "passage numbers" above; in a narrow margin a long one such as 3.1.61_62 lost its first characters at the
       screen edge) */
    html[data-ui="next"] #text-container { padding-left: 1rem; padding-right: 1rem; }
}
@media (max-width: 1023px) {
    /* phones and tablets: several apparatus windows one under the other in a scrolling column, not side by side
       (three side by side at 768 px were about 245 px each) */
    html[data-ui="next"] #tab-contents { flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
    html[data-ui="next"] #tab-contents > [id^="tab-content-"] { width: auto !important; flex: 0 0 auto; height: auto;
        max-height: 100%; min-height: 0; }
    html[data-ui="next"] #tab-contents > [id^="tab-content-"] > div.overflow-y-auto { flex: 1 1 auto; height: auto; min-height: 0;
        padding-bottom: 1rem; }
    html[data-ui="next"] #tab-contents > .gutter.gutter-horizontal { display: none; }
}
@media (max-width: 767px) {
    /* phones: the sigla chips a little larger (same low specificity as the rule above, below the TEI's .slN) */
    :where(html[data-ui="next"] #tab-contents) :is(a, span, button):where(.wit, .pos) {
        font-size: .9em; }
    html[data-ui="next"] #tab-contents :is(.lem, .wit, .pos) sup { font-size: .8em; }
}
/* the selected lemma keeps its classic black under the pointer: the amber hover fill behind its white text
   (contrast about 1.3:1) showed right after every click, once a click no longer scrolled the text away */
html[data-ui="next"] #text-container .bg-gray-900.lemma-hover { background-color: rgb(17 24 39) !important; }
/* touch: a tap shows the lemma in black and opens its apparatus entry; the hover highlight and tooltip of a
   mouse (which a tap would leave behind) are not shown */
@media (hover: none) {
    html[data-ui="next"] #lemma-tooltip { display: none !important; }
    html[data-ui="next"] #text-container .lemma-hover:not(.bg-gray-900) { background-color: transparent !important; }
    html[data-ui="next"] #text-container .lemma-hover { outline: none; }
}
@media (pointer: coarse) {
    html[data-ui="next"] :is(#tab-contents [data-tab] .ml-auto > div, #content-text > .header .ml-auto > div[onclick], #apparatus-dropdown-btn) {
        min-width: 2.75rem; min-height: 2.5rem; display: inline-flex; align-items: center; justify-content: center; }
    html[data-ui="next"] #tab-contents [data-tab] { height: 2.75rem; }
    html[data-ui="next"] #content-text > .header .ml-auto > button { width: 2.5rem; height: 2.5rem; }
    html[data-ui="next"] #content-text > .header .ml-auto > label { min-height: 2.5rem; }
    html[data-ui="next"] #apparatus-dropdown div[data-id] { min-height: 2.75rem; }
    /* the resize bars between text and apparatus (inline 10 px from Split.js) and between apparatus windows */
    html[data-ui="next"] .gutter.gutter-vertical { height: 20px !important; }
    html[data-ui="next"] .gutter.gutter-horizontal { width: 14px !important; }
    html[data-ui="next"] #tab-contents [id^="tab-content-"] > div.overflow-y-auto li { line-height: 1.9; }
}

/* ---------- editors' pages ---------- */
/* Manage collection (and Manage sigla): each column's list starts below its title and Delete Selected, however
   many lines the title takes (the list sat at a fixed 5.5rem and covered the button when the title wrapped) */
html[data-ui="next"] :is(#witness_manage, #passage_manage, #folio_manage, #sigla_manage, #sigla_witness_manage) > .relative {
    display: flex; flex-direction: column; }
html[data-ui="next"] :is(#witness_manage, #passage_manage, #folio_manage, #sigla_manage, #sigla_witness_manage) > .relative > .absolute.inset-x-0 {
    position: static; flex: 1 1 auto; min-height: 0; }
html[data-ui="next"] :is(#witness_manage, #passage_manage, #folio_manage) .bg-bblue-500.break-words { overflow-wrap: normal; word-break: normal; }
html[data-ui="next"] div.flex-col.flex-1:has(> :is(#witness_manage, #folio_manage, #sigla_manage)) { min-height: 0; }
/* the three columns end at the footer (h-full plus the tab bar above them ran ~40 px under it, which hid the end
   of each list); Manage sigla the same */
html[data-ui="next"] :is(#alldata, .flex.flex-row.h-full.w-full:has(#sigla_witness_manage)) { flex: 1 1 0; min-height: 0; height: auto; }
/* the folio list keeps a usable height above the transcription (it was 2 px at 1024 x 768, one row at 1280 x 800;
   at 1440 x 900 it stays as it was), and the transcription's text box gives way so its Save stays in view */
html[data-ui="next"] #folio_col > .flex-col.flex-1 { flex: 0 0 auto; height: clamp(15rem, 26vh, 20rem); }
html[data-ui="next"] #folio_col > .flex-1.p-2 { flex: 1 1 0; height: auto; min-height: 0; display: flex; flex-direction: column; }
html[data-ui="next"] #text_manage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
html[data-ui="next"] #text_manage > form { flex: 1 1 auto; min-height: 0; height: auto; }
html[data-ui="next"] #text_manage > form > .h-full.overflow-y-auto { flex: 1 1 0; height: auto; min-height: 0; }
@media (max-width: 1023px) {
    /* tablets and phones: the three columns one under the other, the page scrolls */
    html[data-ui="next"] #alldata { flex-direction: column; overflow-y: auto; }
    html[data-ui="next"] :is(#witness_col, #passage_col, #folio_col) { flex: none !important; width: 100%; min-width: 0 !important; }
    html[data-ui="next"] :is(#witness_col, #passage_col) { height: 26rem; max-height: 60vh; }
    html[data-ui="next"] #folio_col > .flex-col.flex-1 { height: 20rem; }
    html[data-ui="next"] #folio_col > .flex-1.p-2, html[data-ui="next"] #text_manage > form > .h-full.overflow-y-auto { flex: none; }
    html[data-ui="next"] .col-resize-handle { display: none; }
    /* Manage sigla: the same */
    html[data-ui="next"] .flex.flex-row.h-full.w-full:has(#sigla_witness_manage) { flex-direction: column; overflow-y: auto; }
    html[data-ui="next"] .flex.flex-row.h-full.w-full:has(#sigla_witness_manage) > .w-1\/3 { width: 100%; flex: none; height: 24rem; max-height: 60vh; }
    html[data-ui="next"] :is(#sigla_manage, #sigla_witness_manage, #witness_manage) .overflow-x-hidden { overflow-x: auto; }
}
@media (pointer: coarse) {
    html[data-ui="next"] :is(#witness_manage, #passage_manage, #folio_manage) td { padding-top: .25rem; padding-bottom: .25rem; }
    html[data-ui="next"] :is(#witness_manage, #passage_manage, #folio_manage) td :is(svg, button, a) { margin: 0 .125rem; }
}
@media (min-width: 1024px) and (max-width: 1279px) and (pointer: coarse) {
    /* the three columns side by side on a landscape tablet are too narrow for larger controls: the passage
       column's edit pencil was pushed past the edge of its list */
    html[data-ui="next"] :is(#witness_manage, #passage_manage, #folio_manage) input[type="checkbox"] { width: auto; height: auto; }
    html[data-ui="next"] :is(#witness_manage, #passage_manage, #folio_manage) td :is(svg, button, a) { margin: 0; }
}

/* Manage metadata of a witness: the page scrolls (the Add row of a long category was out of reach) */
html[data-ui="next"] body > .h-screen > .w-full.flex-1 > .p-5.w-full:has(> ul.border-b-4) { overflow-y: auto; }

/* Edit collection (Title and Information) and Share: the page scrolls, so Save and Delete can be reached */
html[data-ui="next"] .flex.flex-col.w-full:has(> .flex-row.ml-10.h-full) { overflow-y: auto;
    overflow-x: hidden; /* its w-full + ml-10 row is 40 px wider than the page; that empty strip stays out of reach */ }
html[data-ui="next"] .overflow-y-auto > form.h-full.w-4\/5 { height: auto; }
@media (max-width: 1279px) {
    /* Share: the user's email gets the room, Can edit and Action stay narrow */
    html[data-ui="next"] .w-1\/2.m-5.h-fit .grid.grid-cols-3 { grid-template-columns: minmax(0, 1fr) 6rem 6rem; }
    html[data-ui="next"] .w-1\/2.m-5.h-fit .grid.grid-cols-3 > :first-child { overflow-wrap: anywhere; text-align: left;
        padding-left: .5rem; padding-right: .5rem; }
}
@media (max-width: 1023px) {
    html[data-ui="next"] .w-1\/2.m-5.h-fit { width: auto; margin: 1rem; }
}
@media (max-width: 767px) {
    html[data-ui="next"] .flex.flex-row.w-full.ml-10.h-full { margin-left: 0; height: auto; }
    html[data-ui="next"] :is(form.ml-10.w-4\/5, form#create_form.ml-10, form.ml-10.w-1\/2) { margin-left: 1rem; margin-right: 1rem;
        width: auto; flex: 1 1 auto; min-width: 0; height: auto; }
    html[data-ui="next"] .flex.flex-col.w-full.ml-2.overflow-y-auto { margin-left: 0; }
    html[data-ui="next"] input[type="range"]:is(.w-1\/3, .w-1\/5) { width: calc(100% - 2rem); }
}

/* Moderate a user: the page was 80 px wider than the window (w-full plus m-10), which cut off the Action column */
html[data-ui="next"] form > .overflow-y-auto.m-10 { width: auto; }
@media (max-width: 767px) {
    html[data-ui="next"] form > .overflow-y-auto.m-10 { margin: 0; padding: 1rem; }
    html[data-ui="next"] form > .overflow-y-auto.m-10 .grid.grid-cols-3:not(.text-2xl) { grid-template-columns: minmax(0, 1fr) 5rem 6rem; }
    html[data-ui="next"] form > .overflow-y-auto.m-10 .grid.grid-cols-3 > * { min-width: 0; overflow-wrap: anywhere; }
    html[data-ui="next"] form > .overflow-y-auto.m-10 button { white-space: nowrap; }
    html[data-ui="next"] form > .overflow-y-auto.m-10 :is(.px-10, .px-6) { padding-left: 1.25rem; padding-right: 1.25rem; }
    html[data-ui="next"] form > .overflow-y-auto.m-10 .mx-5 { margin-left: .5rem; margin-right: .5rem; }
}

/* Users: on phones each user is a card (name, email, role ... with Manage at the right) instead of a table
   twice the width of the screen */
@media (max-width: 767px) {
    html[data-ui="next"] .users-page { padding-left: 1rem; padding-right: 1rem; }
    html[data-ui="next"] .users-page thead { display: none; }
    html[data-ui="next"] .users-page tr.user-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: .75rem;
        padding: .6rem 0; border-bottom: 1px solid #e5e7eb; }
    html[data-ui="next"] .users-page tr.user-row > td { display: block; padding: 0; border: 0; grid-column: 1; }
    html[data-ui="next"] .users-page tr.user-row > td:last-child { grid-column: 2; grid-row: 1 / span 6; align-self: center; }
    html[data-ui="next"] .users-page tr.user-row > td:nth-child(2) { overflow-wrap: anywhere; }
    html[data-ui="next"] .users-page .pending-table tr.user-row { background: #fefce8; }
    html[data-ui="next"] .users-page .manage { min-height: 44px; display: inline-flex; align-items: center; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    html[data-ui="next"] .users-page { padding-left: 1.5rem; padding-right: 1.5rem; }
    html[data-ui="next"] .users-page td:nth-child(2) { overflow-wrap: anywhere; }
}

/* Collection wizard (bulk replace of folio names): the page scrolls; on narrow screens the list and inputs use the width */
html[data-ui="next"] body > .h-screen > .w-full.flex-1 > .w-full:has(> form .pl-10) { overflow-y: auto; }
@media (max-width: 1023px) {
    html[data-ui="next"] .flex.flex-col.mx-10.w-1\/3.overflow-y-auto { width: auto; margin-left: 1rem; margin-right: 1rem;
        height: auto !important; max-height: 50vh; }
    html[data-ui="next"] form .pl-10 input.w-1\/3 { width: auto; flex: 1 1 auto; min-width: 0; }
    html[data-ui="next"] form:has(.pl-10) > .text-xl.mx-10 { margin-left: 1rem; margin-right: 1rem; }
}
@media (max-width: 767px) {
    html[data-ui="next"] form .pl-10 { padding-left: 1rem; padding-right: 1rem; }
}

/* Manuscript images (DZI Manager): the edit and delete icons keep their size beside a long name; on phones each
   folder level is a column of its own that the page swipes through */
html[data-ui="next"] [id^="level_"] .view > svg.icon { flex: none; }
html[data-ui="next"] [id^="level_"] .view > .px-2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 767px) {
    html[data-ui="next"] .flex.flex-row.w-full.h-full:has(> [id^="level_"]) { overflow-x: auto; scroll-snap-type: x mandatory; }
    html[data-ui="next"] [id^="level_"] { flex: 0 0 85vw; width: auto; margin: .75rem .5rem; scroll-snap-align: start; }
}

/* Advanced search: on phones the results come before the form once there are any; on wider screens the sticky
   form panel scrolls on its own when it is taller than the window (Options open), so Search stays reachable */
@media (max-width: 767px) {
    html[data-ui="next"] .as-layout:has(> .as-results > :is(.as-summary, .as-alert)) > .as-results { order: -1; }
}
/* the visually hidden scope radios (position absolute, no offsets) are placed inside the page's own scroller:
   against the window they sat ~3600 px down once the form came after the results, and made the whole frame
   scroll away into blank space */
html[data-ui="next"] .as-page { position: relative; }
@media (min-width: 768px) {
    html[data-ui="next"] .as-panel { max-height: calc(100vh - 8rem); max-height: calc(100dvh - 8rem); overflow-y: auto; }
}
/* find & replace tables: headings and short cells (passage, witness) do not break inside a word; on phones a
   table too wide for the screen scrolls sideways inside itself */
@media (max-width: 767px) {
    html[data-ui="next"] .as-table { display: block; overflow-x: auto; }
}
html[data-ui="next"] .as-table th { overflow-wrap: normal; white-space: nowrap; }
html[data-ui="next"] .as-table td:not(:has(.as-kwic)) { overflow-wrap: normal; word-break: keep-all; }
@media (pointer: coarse) {
    html[data-ui="next"] .as-small { min-height: 2.25rem; padding-left: .8rem; padding-right: .8rem; }
    html[data-ui="next"] .as-table a { display: inline-block; padding-top: .5rem; padding-bottom: .5rem; }
}

/* ---------- phones: form fields at 16 px, so iOS Safari does not zoom the page in on focus ---------- */
@media (max-width: 767px) {
    html[data-ui="next"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
        select, textarea) { font-size: max(16px, 1em); }
}

/* ---------- landscape phones (last: these override the page rules above) ---------- */
/* a landscape phone (360-430 px high): the page scrolls like a document, and the image and transcription, or
   the critical text and its apparatus, get a whole screen of their own below the pickers and toolbars */
@media (max-height: 500px) and (orientation: landscape) {
    html[data-ui="next"] body > .h-screen { height: auto; min-height: 100vh; min-height: 100dvh; }
    html[data-ui="next"] body > .h-screen > .w-full.flex-1 { flex: 1 0 auto; overflow: visible; overflow-x: clip; }
    /* svh: the screen with the browser's toolbars shown, which does not change while the page scrolls */
    html[data-ui="next"] .flex-grow.overflow-hidden:has(> #ImageAndText) { flex: none; height: 100vh; height: 100svh; }
    html[data-ui="next"] #full { height: 100vh; height: 100svh; }
    /* Manage collection and Manage sigla: the columns take the height of their lists (flex-basis 0 in a column
       of automatic height left them 0 px tall, a blank page) */
    html[data-ui="next"] :is(#alldata, .flex.flex-row.h-full.w-full:has(#sigla_witness_manage)) { flex: none; }
}
