/* THE FORM — its controls laid as the desktop's sizers lay them: a box is a flex row or column, an item takes its share
   of the free space and stretches across or keeps its own size. The form is the container a narrow screen is measured
   on: below 40rem of it, a row folds into a column, every item stretches across, and a caption stands over its field
   instead of beside it — a form drawn for a desktop still reads on a phone. */

/* A control's height, the theme's taken down to a desktop form's: the padding around its text. A finger keeps the theme's. */
@media (pointer: fine) {
	:root {
		--wa-form-control-padding-block: 0.35em;
		--wa-form-control-padding-inline: 0.5em;
	}
}

/* A form's field framed as the thin client's theme frames one: square, in the border tier, its value in the form's
   text. */
oes-clientform {
	--wa-form-control-border-color: var(--oes-border);
	--wa-form-control-border-radius: 0;
	--wa-form-control-value-color: var(--oes-form-text);
}

/* The window a form just opened is drawn in, out of sight over the one on show, until it has settled (ClientWindow): it
   is measured as it will stand, and takes nothing from what is on show. It comes in one frame, whole. */
.views > .arriving {
	position: absolute;
	inset: 0;
	visibility: hidden;
}

/* A component not yet defined takes its place but shows no raw text. */
wa-button:not(:defined),
wa-input:not(:defined),
wa-textarea:not(:defined),
wa-select:not(:defined),
wa-dropdown:not(:defined),
wa-dialog:not(:defined) {
	visibility: hidden;
}

/* The form is its view's height: its command bar on top, still, and under it the window its controls scroll in — the
   thin client's (ibVisualHostClient). The controls fill that window while they fit, what grows sharing what is left,
   and keep their own size and scroll when they do not. */
oes-clientform {
	container: form / inline-size;
	display: flex;
	flex-direction: column;
	height: 100%;
}

oes-clientform > .command-bar {
	flex: 0 0 auto;
	padding: 0.25rem 0.5rem 0.125rem;
}

oes-clientform > .content {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	box-sizing: border-box;
	padding: 0.25rem 0.5rem 0.5rem;
}

oes-clientform > .content > * {
	flex-shrink: 0;
}

oes-clientform[orient="horizontal"] > .content,
oes-layout[orient="horizontal"],
oes-page[orient="horizontal"] {
	flex-direction: row;
}

oes-layout,
oes-page {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

oes-layout[view="wrap"] {
	flex-wrap: wrap;
}

oes-layout[view="grid"] {
	display: grid;
	grid-auto-rows: 1fr;   /* every row as tall as the tallest */
	gap: 0.25rem;
}

oes-layout[view="group"] {
	border: 1px solid var(--oes-border);
	border-radius: 6px;
	padding: 0.25rem 0.5rem 0.5rem;
}

oes-layout[view="group"] > .legend {
	font-weight: 600;
	padding: 0 0.25rem 0.25rem;
}

/* A CONTROL IN A SIZER, placed where its own node says (src/controls/control.js, applyCommon — the server's ibSizerItem):
   its share of the free space, its stretch across, its border. In a box it may go narrower and shorter than it would be;
   a grid's cell is never narrower than what it holds, over its neighbour. Of no weight: a control's own rule holds where
   it says more (a table's least height). The place is its own — not handed down to what is in it. */
@property --oes-place-grow { syntax: '*'; inherits: false; }
@property --oes-place-align { syntax: '*'; inherits: false; }
@property --oes-place-justify { syntax: '*'; inherits: false; }
@property --oes-place-margin { syntax: '*'; inherits: false; }

:where(:is(oes-layout, oes-page, oes-clientform > .content) > [data-control]) {
	flex-grow: var(--oes-place-grow, 0);
	align-self: var(--oes-place-align, flex-start);
	justify-self: var(--oes-place-justify, start);
	margin: var(--oes-place-margin, 0);
}

:where(:is(oes-layout:not([view="grid"]), oes-page, oes-clientform > .content) > [data-control]) {
	min-width: 0;
	min-height: 0;
}

[hidden] {
	display: none !important;
}

oes-clientform [disabled] {
	opacity: 0.55;
}

/* A command bar: a strip of buttons on one line, what does not fit under its » — a strip of its own, as the thin
   client's (its theme's tool bar, ibLunaRenderer::DrawToolBarBackground): the window's colour whatever it stands on —
   one bar on a form, a table, a dialog — a little lighter at the top and darker at the bottom, edged below, so it does
   not melt into the form. */
.command-bar {
	display: flex;
	flex-wrap: nowrap;
	overflow: hidden;
	align-items: center;
	gap: 2px;
	padding: 0.125rem 0.25rem;
	background-color: var(--oes-window-bg);
	background-image: linear-gradient(to bottom, var(--oes-bar-shine-top), var(--oes-bar-shine-bottom));
	border-bottom: 1px solid var(--oes-border);
}

/* A button keeps its width — squeezed, its caption ran over the next one — and one past the end is hidden, a
   component's own display notwithstanding. */
.command-bar > * {
	flex-shrink: 0;
}

.command-bar > [hidden] {
	display: none !important;
}

.command-bar wa-button img,
oes-button wa-button img,
wa-tab img {
	width: 16px;
	height: 16px;
}

/* A TILE - a button for a finger: its picture large over its caption, the note under them, the whole filling its cell. */
oes-button.tile {
	display: flex;
}

oes-button.tile wa-button {
	flex: 1 1 auto;
	width: 100%;
}

oes-button.tile wa-button::part(base) {
	height: 100%;
	min-height: calc(var(--oes-touch) * 2);
	padding: 0.5rem;
	white-space: normal;
}

oes-button.tile .tile-face {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.25rem;
	text-align: center;
}

oes-button.tile wa-button img {
	width: var(--oes-tile-picture);
	height: var(--oes-tile-picture);
}

oes-button.tile .tile-note {
	font-size: 0.85em;
	opacity: 0.75;
}

/* A HYPERLINK - the same button with no face and no frame (appearance plain), its caption underlined in a link's colour.
   Plain still fills on hover and sinks while pressed; a link does neither (the page's rule outranks the button's own). */
oes-button.hyperlink wa-button::part(base) {
	color: var(--wa-color-text-link);
	text-decoration: underline;
	background-color: transparent;
	transform: none;
}

.command-bar .separator {
	width: 1px;
	align-self: stretch;
	margin: 0.25rem 0.25rem;
	background: var(--oes-border);
}

/* THE SEARCH FIELD STANDS AT THE BAR'S END, whatever is left of the bar between it and the commands (the thin client's
   stretch spacer); it gives way before the commands do. */
.command-bar wa-input.search {
	margin-inline-start: auto;
	flex: 0 1 14rem;
	min-width: 8rem;
}

/* A tool's own padding, not the page button's: the thin client's bar is a strip of tools close together. */
.command-bar wa-button::part(base) {
	height: var(--oes-touch);
	min-height: var(--oes-touch);
	min-width: var(--oes-touch);
	padding-inline: 0.375rem;
}

/* THE BAR'S DEFAULT COMMAND (its entry's Default — a form's «… and close») stands out as the thin client draws it: a
   dialog's default button, the accent's face, the caption white. A disabled one is an ordinary disabled tool. The face
   is the page's rule, so the plain button's own hover fill does not reach it; it lightens instead. */
.command-bar wa-button.default:not([disabled])::part(base) {
	background-color: var(--oes-default-button-bg);
	color: var(--oes-default-button-text);
}

.command-bar wa-button.default:not([disabled])::part(base):hover {
	filter: brightness(1.06);
}

/* …and its caption bold, the main button (Max, 2026-11-12) — a disabled one as well, so the bar does not move as it is
   enabled; the thin client measures and writes it so (ibAuiToolBar). */
.command-bar wa-button.default::part(base) {
	font-weight: 600;
}

/* A field: its caption beside it, its buttons inside its frame. */
oes-field {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	min-width: 0;
}

/* …its caption on the right, after what it names (the field's TitleLocation). */
oes-field.title-right .caption {
	order: 1;
}

oes-field .caption {
	flex: 0 0 auto;
	/* The label column's width, given by the form's pass (src/controls/labels.js). */
	min-width: var(--oes-caption-width, 0);
	color: var(--oes-muted);
}

/* One width for every field, its buttons inside it: a field with Select and Clear is as wide as one with none, as the
   desktop's (ibTextCtrl: "button presence must not change the default size"). A stretched item still fills. */
oes-field wa-input,
oes-field wa-textarea {
	flex: 1 1 auto;
	width: var(--oes-field-width);
	/* the floor a width given to the field raises (control.js, applyCommon) */
	--oes-min-width: 6rem;
	min-width: var(--oes-min-width);
}

oes-field .side-button,
oes-table .side-button {
	min-width: 1.5em;
	height: auto;
	padding: 0;
	align-self: stretch;
	border: none;
	border-radius: 0;
	background: none;
	color: var(--oes-muted);
	cursor: pointer;
	font: inherit;
}

oes-field .side-button:hover,
oes-table .side-button:hover {
	color: var(--oes-accent);
	background: color-mix(in srgb, var(--oes-muted) 15%, transparent);
}

/* Its picture as large as the line is tall, as the desktop's (ibTextCtrl::GetButtonBitmap): it grows with the font. */
oes-field .side-button img,
oes-table .side-button img {
	display: block;
	width: 1em;
	height: 1em;
	margin: auto;
}

@media (pointer: coarse) {
	oes-field .side-button,
	oes-table .side-button {
		min-width: var(--oes-touch);
	}
}

/* A field of the view Gauge — a track filled to its share, along it or upwards; a Slider's track as long as a field. */
oes-field .gauge {
	position: relative;
	display: block;
	flex: 1 1 auto;
	width: var(--oes-field-width);
	min-width: 6rem;
	height: 0.75rem;
	border: 1px solid var(--oes-border);
	border-radius: 0.375rem;
	background: var(--oes-panel-bg);
	overflow: hidden;
}

oes-field .gauge .fill {
	position: absolute;
	left: 0;
	bottom: 0;
	width: var(--oes-gauge-share, 0);
	height: 100%;
	background: var(--oes-accent);
}

oes-field .gauge.vertical {
	flex: 0 0 auto;
	width: 0.75rem;
	min-width: 0;
	height: 6rem;
}

oes-field .gauge.vertical .fill {
	width: 100%;
	height: var(--oes-gauge-share, 0);
}

oes-field wa-slider {
	flex: 1 1 auto;
	width: var(--oes-field-width);
	min-width: 6rem;
}

oes-field wa-slider.vertical {
	flex: 0 0 auto;
	width: auto;
	min-width: 0;
	height: 6rem;
}

/* A caption breaks its lines where its text does, as the desktop's does — a label field's text too. */
oes-static[view="text"],
oes-field .text {
	white-space: pre-line;
}

oes-field .text.link {
	color: var(--oes-accent);
	text-decoration: underline;
	cursor: pointer;
}

oes-static[view="line"] {
	display: block;
	background: var(--oes-border);
	min-height: 1px;
	min-width: 1px;
}

oes-static[view="line"][orient="horizontal"] {
	height: 1px;
}

oes-static[view="line"][orient="vertical"] {
	width: 1px;
}

oes-html iframe {
	width: 100%;
	height: 100%;
	min-height: 8rem;
	border: 1px solid var(--oes-border);
}

/* A text box: the desktop's text editor — its font (ibFontColorSettings: monospace, 10pt), its ink on the theme's
   paper (a field's), the theme's highlight for a selection, whatever the control was saved with; the blank margin on
   the left is Scintilla's symbol margin (16px) and its own pixel. Lines run on: no wrap. */
oes-textarea {
	position: relative;
	display: flex;
	min-width: 0;
	min-height: 0;
}

oes-textarea textarea {
	flex: 1 1 auto;
	box-sizing: border-box;
	margin: 0;
	padding: 0 1px 0 17px;
	border: 1px solid var(--oes-border);
	border-radius: 0;
	outline: none;
	resize: none;
	background: var(--oes-table-bg);
}

oes-textarea textarea,
oes-textarea .printout {
	font: 10pt/normal "Courier New", Menlo, monospace;
	tab-size: 4;
	color: var(--oes-editor-text);
}

/* …its text on paper: none on the screen. */
oes-textarea .printout {
	display: none;
}

oes-textarea textarea::selection,
oes-textarea .find-mark mark {
	background: var(--oes-table-cell-current-bg);
	color: var(--oes-table-current-text);
}

/* What Find found, marked over the text while Find has the focus (window/find.js): a copy of the text laid over the
   field's, its ink clear but the found part's. */
oes-textarea .find-mark {
	position: absolute;
	box-sizing: border-box;
	overflow: hidden;
	color: transparent;
	white-space: pre;
	pointer-events: none;
}

/* …and a text document in a tab of its own, as a sheet: the tab's whole height. */
.views > oes-textarea {
	height: 100%;
	box-sizing: border-box;
	padding: 0.25rem 0.5rem 0.5rem;
}

oes-chart {
	display: block;
}

oes-pages.no-tabs wa-tab-group::part(nav) {
	display: none;
}

/* A table: its command bar over the grid, the grid taking the rest of its height. Its height is the form's to give, not
   its rows' (size containment): a thousand rows scroll inside it, as the thin client's do, rather than push the form. */
oes-table {
	display: flex;
	flex-direction: column;
	min-height: 15rem;
	min-width: 0;
}

oes-table .grid-frame {
	position: relative;
	flex: 1 1 auto;
	min-height: 11rem;
}

/* Laid in its frame, not flowing in it: what the grid holds never makes the frame taller. */
oes-table .grid {
	position: absolute;
	inset: 0;
}

oes-table .grid-frame.paged .grid {
	right: var(--oes-pager);
}

/* The scrollbar over the window of rows the grid holds (src/table/table.js, updatePager) — the grid's own measures
   only what is held, so it is not shown; a row too wide still scrolls sideways under its own. */
oes-table .pager {
	display: none;
	position: absolute;
	right: 0;
	width: var(--oes-pager);
	background: var(--oes-scroll-track);
	border-left: 1px solid var(--oes-table-border);
	box-sizing: border-box;
	touch-action: none;
}

oes-table .grid-frame.paged .pager {
	display: block;
}

oes-table .pager .thumb {
	position: absolute;
	left: 2px;
	right: 2px;
	border-radius: 4px;
	background: var(--oes-scroll-thumb);
	cursor: grab;
}

oes-table .pager .thumb:hover {
	background: var(--oes-scroll-thumb-hover);
}

oes-table .pager .thumb:active {
	background: var(--oes-scroll-thumb-pressed);
}

oes-table .pager[data-thumb="top"] .thumb {
	top: 0;
	height: 50%;
}

oes-table .pager[data-thumb="bottom"] .thumb {
	bottom: 0;
	height: 50%;
}

oes-table .pager[data-thumb="middle"] .thumb {
	top: 33.333%;
	height: 33.333%;
}

oes-table .tabulator .tabulator-tableholder::-webkit-scrollbar {
	width: 0;
	height: 10px;
}

oes-table .tabulator .tabulator-tableholder::-webkit-scrollbar-track {
	background: var(--oes-scroll-track);
}

oes-table .tabulator .tabulator-tableholder::-webkit-scrollbar-thumb {
	border-radius: 5px;
	background: var(--oes-scroll-thumb);
}

oes-table .tabulator .tabulator-tableholder::-webkit-scrollbar-thumb:hover {
	background: var(--oes-scroll-thumb-hover);
}

@supports not selector(::-webkit-scrollbar) {
	oes-table .tabulator .tabulator-tableholder {
		scrollbar-width: none;
	}
}

/* The grid's own stylesheet rules it in greys and sets its header in bold; the thin client's theme rules a table in its
   powder, the border round it and under its header and between the header's columns, the header's captions as the rows'
   text (ibThemeRenderer::DrawHeaderButton). */
oes-table .tabulator {
	font-size: inherit;
	background: var(--oes-table-bg);
	color: var(--oes-table-text);
	border-color: var(--oes-border);
}

oes-table .tabulator .tabulator-header,
oes-table .tabulator .tabulator-header .tabulator-col {
	background: var(--oes-table-header-bg);
	color: var(--oes-table-header-text);
	border-color: var(--oes-border);
	font-weight: normal;
}

/* The row's own line is its cells' — a taller one stood under them and drew the row a fraction higher. */
oes-table .tabulator .tabulator-row {
	background: var(--oes-table-bg);
	min-height: var(--oes-touch);
	border-bottom: 1px solid var(--oes-table-border);
	line-height: calc(1rem + 3px);
}

oes-table .tabulator .tabulator-row .tabulator-cell {
	border-right-color: var(--oes-table-border);
}

oes-table .tabulator .tabulator-row .tabulator-cell.tabulator-frozen {
	border-color: var(--oes-border);
}

oes-table .tabulator .tabulator-tableholder .tabulator-table .tabulator-row.tabulator-calcs {
	border-color: var(--oes-border);
}

/* The grid's own stylesheet paints the rows' holder, the totals under them, the footer and a column being dragged in
   its colours, black on white; the cells' text is inherited from the holder. Ours instead, in either theme. The
   totals' row is !important there, so it is here. */
oes-table .tabulator .tabulator-tableholder .tabulator-table {
	background: var(--oes-table-bg);
	color: var(--oes-table-text);
}

oes-table .tabulator .tabulator-footer,
oes-table .tabulator .tabulator-calcs-holder,
oes-table .tabulator .tabulator-calcs-holder .tabulator-row {
	background: var(--oes-table-header-bg) !important;
	color: var(--oes-table-header-text);
	border-color: var(--oes-table-border);
}

oes-table .tabulator .tabulator-col.tabulator-moving {
	background: var(--oes-table-header-bg);
	color: var(--oes-table-header-text);
	border-color: var(--oes-table-border);
}

/* A cell's text is not taken by a double click: a double click activates the row. A row 22 pixels and its rule, as the
   thin client's at the desktop's size. */
oes-table .tabulator .tabulator-cell {
	padding: 3px 0.3rem;
	line-height: calc(1rem + 3px);
	user-select: none;
}

/* The header takes the lines its table says (its HeaderHeight), a line a row's — a row's 22 pixels for one. */
oes-table .tabulator .tabulator-header .tabulator-col .tabulator-col-content {
	padding: 3px 0.3rem;
}

oes-table .tabulator .tabulator-header .tabulator-col-title {
	min-height: calc(var(--oes-header-lines, 1) * (1rem + 3px));
	line-height: calc(1rem + 3px);
}

oes-table .grid:focus,
oes-table .tabulator .tabulator-tableholder:focus {
	outline: none;
}

oes-table .tabulator .tabulator-row.tabulator-row-even {
	background: var(--oes-table-row-alt-bg);
}

/* The cursor (Table.markCursor): on a row, the row in the highlight; on a cell, the row tinted and the cell in the
   highlight — the thin client's two modes; the highlight lighter while the keys go elsewhere. No row lights up under the
   mouse: the thin client's do not. */
oes-table .tabulator .tabulator-row.current-row {
	background: var(--oes-table-row-current-bg);
	color: var(--oes-table-current-text);
}

oes-table .grid.select-cell .tabulator-row.current-row {
	background: var(--oes-table-row-selected-bg);
	color: var(--oes-table-text);
}

oes-table .tabulator .current-cell {
	background: var(--oes-table-cell-current-bg);
	color: var(--oes-table-current-text);
}

/* …and the grid's own lights a row under the mouse grey. */
oes-table .tabulator .tabulator-row.tabulator-selectable:hover:not(.current-row) {
	background: var(--oes-table-bg);
}

oes-table .tabulator .tabulator-row.tabulator-row-even.tabulator-selectable:hover:not(.current-row) {
	background: var(--oes-table-row-alt-bg);
}

oes-table .grid:not(:focus-within):not(.select-cell) .tabulator .tabulator-row.current-row,
oes-table .grid:not(:focus-within) .tabulator .current-cell {
	background: var(--oes-table-current-idle-bg);
}

/* On a row selected whole, the cell the keys put the cursor on: the row's fill left off it, as the thin client's. */
oes-table .grid:not(.select-cell) .tabulator .current-cell {
	background: var(--oes-table-bg);
	color: var(--oes-table-text);
}

/* The folders the Hierarchical view stands in, frozen over the rows of the level. */
oes-table .tabulator .tabulator-row.crumb {
	background: var(--oes-table-crumb-bg);
	font-weight: normal;
	cursor: pointer;
}

/* A row that is a group's caption: one line across the row, no cell's rule under it. */
oes-table .tabulator .tabulator-row.group-row .tabulator-cell {
	border-right-color: transparent;
	overflow: visible;
}

oes-table .tabulator .tabulator-row.group-row .first-text {
	overflow: visible;
}

/* The first column's cell: its step in, the place of the expander, the row's picture, what it shows. */
oes-table .first-cell {
	display: flex;
	align-items: center;
	gap: 0.2rem;
	min-width: 0;
}

oes-table .first-cell .first-text {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

oes-table .first-cell .expander {
	flex: 0 0 1em;
	width: 1em;
	height: auto;
	padding: 0;
	border: none;
	border-radius: 0;
	background: none;
	color: var(--oes-muted);
	font: inherit;
	text-align: center;
}

oes-table .first-cell button.expander {
	cursor: pointer;
}

@media (pointer: coarse) {
	oes-table .first-cell button.expander {
		flex-basis: var(--oes-touch);
		width: var(--oes-touch);
	}
}

oes-table .tabulator .tabulator-cell img {
	width: 16px;
	height: 16px;
	vertical-align: middle;
}

/* A table whose header is switched off (its Header). */
oes-table .grid.no-header .tabulator-header {
	display: none;
}

/* A text that loses its middle when it does not fit (src/table/table.js, cutInTheMiddle): both halves give up room,
   the first cut at its end with the mark, the second held to the right and cut at its start. */
oes-table .cut {
	display: inline-flex;
	max-width: 100%;
	vertical-align: top;
}

oes-table .cut-start,
oes-table .cut-end {
	flex: 0 1 auto;
	min-width: 0;
	overflow: hidden;
	white-space: pre;
}

oes-table .cut-start {
	text-overflow: ellipsis;
}

oes-table .cut-end {
	display: flex;
	justify-content: flex-end;
}

oes-table .cut-end > span {
	flex: none;
}

/* A column's header: its picture, its caption, the arrow of the server's sort; one that sorts takes a click. Its caption
   gives up room, the picture and the arrow keep theirs. */
oes-table .column-header {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	max-width: 100%;
}

oes-table .column-header .cut {
	min-width: 0;
}

oes-table .column-header img {
	flex: none;
	width: 16px;
	height: 16px;
}

/* The arrow at the header's right edge, in the header's text, whatever side the caption keeps — the thin client's. */
oes-table .column-header:has(.sort-arrow) {
	padding-inline-end: 1.1em;
	box-sizing: border-box;
}

oes-table .column-header .sort-arrow {
	position: absolute;
	right: 0.3rem;
	top: 50%;
	translate: 0 -50%;
	font-size: 0.7em;
	color: var(--oes-table-header-text);
}

oes-table .tabulator-col:has(.column-header.sortable) {
	cursor: pointer;
}

/* A group drawn as one column: its columns' captions and texts one under the other, or side by side in one cell. */
oes-table .column-header.joined {
	white-space: pre-line;
}

oes-table .joined.in-cell {
	display: flex;
	gap: 0.5em;
}

/* A column's footer: its picture and text, where its alignment puts them, the lines its table says (its FooterHeight). */
oes-table .column-footer {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	min-height: calc(var(--oes-footer-lines, 1) * 1.25em);
}

oes-table .column-footer img {
	width: 16px;
	height: 16px;
}

/* A cell's editor is a field's (controls/textEditor.js), filling its cell: the row's height — a cell's line and its 3
   pixels above and below (.tabulator-cell), the thin client's 22 — no taller. */
oes-table .cell-editor {
	--wa-form-control-height: calc(1rem + 9px);
	width: 100%;
}

/* A Flag's box, and a boolean's editor in an Input's column: the theme's box at its own size (not an editor's whole
   width) where the text would start — the editor's in a cell that has given up its padding to it. */
oes-table input.cell-flag {
	width: var(--wa-form-control-toggle-size);
	margin: 0;
	vertical-align: middle;
}

oes-table input.cell-editor.cell-flag {
	margin-inline-start: 0.3rem;
}

/* Its focus ring inside its frame: outside it, the cells around would cut it. */
oes-table .cell-editor:focus-within::part(base) {
	outline: 2px solid var(--oes-accent);
	outline-offset: -2px;
}

oes-table .tabulator .tabulator-cell.tabulator-editing {
	padding: 0;
	border: none;
	overflow: visible;
}

/* A spreadsheet: its command bar over the sheet, the sheet scrolling inside its own frame — sideways too, never the
   page; the rows and columns frozen stay in view. The word "composing" stands over the sheet, a third of the way down,
   and leaves the command bar free. */
oes-spreadsheet {
	position: relative;
	display: flex;
	flex-direction: column;
	min-height: 12rem;
	min-width: 0;
}

/* …and a spreadsheet document in a tab of its own (a list output, a sheet shown by code) — a sheet that is a tab's whole
   view, drawn straight into the views (FormVisualDocument): the tab's whole height. */
.views > oes-spreadsheet {
	height: 100%;
	box-sizing: border-box;
	padding: 0.25rem 0.5rem 0.5rem;
}

oes-spreadsheet .sheet-host {
	flex: 1 1 auto;
	min-height: 8rem;
	contain: size;   /* its height is the form's, as a table's is */
	overflow: auto;
	background: var(--oes-sheet-bg);
	border: 1px solid var(--oes-border);
}

/* It takes the keys; where they go is the current cell's frame, not a ring round the sheet. */
oes-spreadsheet .sheet-host:focus {
	outline: none;
}

oes-spreadsheet .compose-state {
	position: absolute;
	top: 33%;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 0.5rem;
	max-width: 90%;
	padding: 0.5rem 0.75rem;
	background: var(--oes-window-bg);
	border: 1px solid var(--oes-border);
	border-radius: 6px;
	box-shadow: 0 2px 8px var(--oes-shadow);
}

/* The figures taken, summed over the sheet's lower corner, clear of its scrollbars — as a spreadsheet program's status
   line says them. */
oes-spreadsheet .selection-summary {
	position: absolute;
	right: 1.25rem;
	bottom: 1.25rem;
	padding: 0.125rem 0.5rem;
	font-size: 0.8rem;
	white-space: pre;
	color: var(--oes-text);
	background: var(--oes-window-bg);
	border: 1px solid var(--oes-border);
	border-radius: 4px;
	pointer-events: none;
}

/* A cell with no font of its own is in the thin client's sheet font — 8pt (ibDefaultSpreadsheetFont) — and a row with
   no height of its own is its 15 pixels, its line in them (s_defaultRowHeight): one line of that font; a larger one
   grows it. Ink and paper the sheet's, in every theme. A drag takes cells, not the text in them (selection.js). */
.sheet {
	table-layout: fixed;
	border-collapse: separate;   /* collapsed, the rows scrolled under a frozen head paint over it; see linesOf */
	border-spacing: 0;
	font-size: 8pt;
	line-height: 1.2;
	color: var(--oes-sheet-text);
	background: var(--oes-sheet-bg);
	user-select: none;
}

.sheet tr {
	height: 15px;
}

/* The text 2px off the cell's sides — the grid's margin and its renderer's pixel (gridEditorDoc.cpp, chromeWrapping). */
.sheet td {
	padding: 1px 2px 0;
	overflow: hidden;
	white-space: pre;
	vertical-align: top;
	background-clip: padding-box;
}

/* A text runs on over the empty cell beside it, as the desktop's grid draws it — a report's title is one cell. */
.sheet td.spills {
	overflow: visible;
}

/* …and where it cannot, or is to, breaks onto further lines at the cell's width, a word too long for it between its
   letters (ibGrid::WrapTextLine); the row grows to them (sheet.js, placeText). */
.sheet td.wraps {
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

/* A masked text wider than its cell shows as `#` (sheet.js, maskText): the text stays in the cell for whoever reads
   it, set at no size, and the `#` stand in its place at its size, where its alignment puts them. */
.sheet td.masked {
	font-size: 0 !important;
}

.sheet td.masked::after {
	content: attr(data-mask);
	font-size: var(--oes-mask-size);
}

.sheet td.decoded {
	cursor: pointer;
}

/* The cells taken tinted over their own fill; the current one framed in the theme's highlight on its edges, a pixel
   wide — the thin client's read-only sheet (ibGrid::DrawCellHighlight; an editable one's is two). */
.sheet td.selected {
	background-image: linear-gradient(var(--oes-sheet-cell-selected), var(--oes-sheet-cell-selected));
}

.sheet td.current {
	outline: 1px solid var(--oes-table-cell-current-bg);
	outline-offset: -1px;
}

.sheet.editable td.current {
	outline-width: 2px;
	outline-offset: -2px;
}

/* A cell's text typed in place, over its cell, in its font and ink, on the sheet's paper (cellEditor.js). */
.sheet td.editing:not(.frozen) {
	position: relative;
}

.sheet .cell-editor {
	position: absolute;
	inset: 0;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 1px 2px 0;
	border: 0;
	outline: none;
	resize: none;
	overflow: hidden;
	white-space: pre;
	font: inherit;
	line-height: inherit;
	text-align: inherit;
	color: inherit;
	background: var(--oes-sheet-bg);
}

/* THE LABELS — the rows' numbers down the left, the columns' along the top, as the thin client's grid draws them: in
   the theme's header, each ruled off on its far sides in the border tier, the strips' outer edges and the first row's
   and column's near ones ruled too. The row labels and the corner stay at the left as the sheet scrolls, past the
   outline pane; the column labels lead the head, which stays at the top. */
.sheet th.label {
	padding: 0 2px;
	overflow: hidden;
	white-space: nowrap;
	font-weight: normal;
	text-align: center;
	vertical-align: middle;
	color: var(--oes-text);
	background: var(--oes-table-header-bg);
	border-right: 1px solid var(--oes-border);
	border-bottom: 1px solid var(--oes-border);
	cursor: default;
}

.sheet th.label:not([data-col]) {
	position: sticky;
	left: var(--oes-sheet-pane, 0px);
	z-index: 1;
	border-left: 1px solid var(--oes-border);
}

.sheet tr.labels th,
.sheet th.label[data-row="0"] {
	border-top: 1px solid var(--oes-border);
}

.sheet th.label[data-col="0"] {
	border-left: 1px solid var(--oes-border);
}

/* …and none round a form's sheet: nothing at its sides, a report to read (sheet.js, `bare`; the thin client's box hides
   its labels the same way). Laid out with no width, so what reads them still finds them. */
.sheet.bare tr.labels {
	display: none;
}

.sheet.bare th.label {
	visibility: hidden;
	padding: 0;
	border: 0;
}

.sheet thead {
	position: sticky;
	top: 0;
	z-index: 2;
}

/* …and covers what scrolls under it: a cell with no fill of its own — the title, the empty lines under it — would let
   the rows beneath show through. */
.sheet thead td {
	background-color: var(--oes-sheet-bg);
}

.sheet td.frozen {
	position: sticky;
	z-index: 1;
	background-color: var(--oes-sheet-bg);
}

/* THE OUTLINE PANE — the folds' chevrons and rails at the sheet's far left, the thin client's (ibGrid::DrawRowOutline):
   chrome in the labels' colours, ruled off from them, running on beside the column labels; drawn in the theme's dark
   shadow, as its tree buttons are. sheet.js places what is in it. */
.sheet td.fold {
	position: sticky;
	left: 0;
	z-index: 1;
	padding: 0;
	background: var(--oes-table-header-bg);
	border-right: 1px solid var(--oes-border);
}

.sheet tr.labels td.fold {
	border-top: 1px solid var(--oes-border);
}

.sheet :is(td.fold, td.col-fold) button {
	position: absolute;
	padding: 0;
	border: 0;
	background: none;
	color: var(--oes-table-header-text);
	cursor: pointer;
}

.sheet :is(td.fold, td.col-fold) svg {
	display: block;
	width: 100%;
	height: 100%;
	overflow: visible;
}

.sheet :is(td.fold, td.col-fold) polyline {
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5px;
	stroke-linecap: round;
	stroke-linejoin: round;
	vector-effect: non-scaling-stroke;
}

.sheet td.fold .rail {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 1px;
	background: var(--oes-table-header-text);
}

.sheet td.fold .tick {
	position: absolute;
	right: 0;
	bottom: 0;
	height: 1px;
	background: var(--oes-table-header-text);
}

/* A fold closed has no rail: its rows are away. */
.sheet td.fold button[aria-expanded="false"] + .rail {
	display: none;
}

/* …and the columns' over their labels (ibGrid::DrawColOutline): the same chrome, its marker in its level's lane, its
   rail across to the fold's last column and a tick down from there; a column folded away collapses, its cells and its
   label with it (sheet.js, drawColFolds). */
.sheet tr.col-folds > * {
	border-top: 1px solid var(--oes-border);
}

.sheet td.col-fold {
	position: relative;
	padding: 0;
	background: var(--oes-table-header-bg);
}

.sheet td.col-fold .rail-across {
	position: absolute;
	right: 0;
	height: 1px;
	background: var(--oes-table-header-text);
}

.sheet td.col-fold .tick-down {
	position: absolute;
	right: 0;
	bottom: 0;
	width: 1px;
	background: var(--oes-table-header-text);
}

.sheet col.folded {
	visibility: collapse;
}

/* A sheet on paper: its frozen rows are its head, so they come again on every page; a row is not cut across two; a
   row's print break ends its page; the cells taken, the labels, the outline and the empty cells it is filled out with
   are the screen's. */
@media print {
	.sheet td.selected {
		background-image: none;
	}

	.sheet td.current {
		outline: none;
	}

	oes-spreadsheet .selection-summary {
		display: none;
	}

	/* On paper the form is as long as what it holds, and so is its sheet. */
	oes-clientform {
		height: auto;
	}

	oes-clientform > .content {
		overflow: visible;
	}

	oes-spreadsheet .sheet-host {
		contain: none;
	}

	oes-table .grid {
		position: relative;
		inset: auto;
	}

	oes-table .pager {
		display: none !important;
	}

	/* A text box on paper is its whole text, its lines wrapped at the page's width (as the thin client's text printout
	   lays it); the box as it stands is the screen's. */
	oes-textarea,
	.views > oes-textarea {
		display: block;
		height: auto;
		padding: 0;
	}

	oes-textarea textarea {
		display: none;
	}

	oes-textarea .printout {
		display: block;
		margin: 0;
		white-space: pre-wrap;
		overflow-wrap: break-word;
	}

	.sheet thead,
	.sheet td.frozen {
		position: static;
	}

	.sheet tr.labels,
	.sheet tr.col-folds,
	.sheet tr.filler {
		display: none;
	}

	.sheet col.fold,
	.sheet col.label,
	.sheet col.filler {
		visibility: collapse;
	}

	.sheet tr {
		break-inside: avoid;
	}

	.sheet tr.page-break {
		break-before: page;
	}
}

/* THE FORM FOLDED — a narrow form: rows become columns, items stretch across, captions stand over their fields. */
@container form (max-width: 40rem) {
	oes-clientform[orient="horizontal"] > .content,
	oes-layout[orient="horizontal"],
	oes-page[orient="horizontal"] {
		flex-direction: column;
	}

	:is(oes-layout, oes-page, oes-clientform > .content) > [data-control] {
		align-self: stretch !important;
		justify-self: stretch !important;
		margin-left: 0 !important;
		margin-right: 0 !important;
	}

	oes-field {
		flex-direction: column;
		align-items: stretch;
		gap: 0.125rem;
	}

	oes-field .caption {
		min-width: 0;
	}

	oes-field wa-input,
	oes-field wa-textarea {
		width: auto;
	}

	oes-table,
	oes-spreadsheet {
		min-height: 60dvh;
	}
}
