/* The pages' stylesheet: platform-ui's chain (ui.css and its theme). Rules and token overrides that ui.css and the theme
   cannot express go after it. */
@import url("./platform-ui.css");

/* Density: an adviser's working screens are lists and records, read at 13px as the UX direction's are, not 16px. Every
   size in ui.css follows the root size, and the spacing scale follows the density. */
:root {
	--font-base: 13;
	--scaling-pad: 0.85;
	--scaling-gap: 0.85;
	--control-font-size: 1em;
	/* A compact field sits in a toolbar beside compact buttons: one text size gives them one height, where the theme's
	   smaller field size leaves the field shorter than the buttons (9.75px against 11.4px at 13px). */
	--field-font-size-compact: var(--action-font-size);
}

/* The header's breadcrumb keeps to one line, which ui.css's wraps, and fits its header: its last crumb truncates on a
   narrow screen. */
.breadcrumbs {
	display: flex;
	flex-wrap: nowrap;
}

.breadcrumbs > li:last-child {
	min-width: 0;
}

/* A popover under the button that opens it opens towards the page, not off its right edge. */
[popover][data-align="end"] {
	--popover-area: block-end span-inline-start;
}

/* A chip's remove button (the search's scope, a list's or the inbox's filter, the assistant's context) is as high as
   the chip's text, and sits in the chip's round end with as much room around it as above and below the text: the ×
   then has as much room on either side as the text has before it. ui.css's button is taller than the text, so that
   it nearly touches the chip's edges and the text, while the text has more room before it. */
.tag:has(> button:last-child) {
	gap: 0.25em;
	padding: 0.25em 0.25em 0.25em 0.625em;
}

.tag > button:last-child {
	width: 1.25em;
	height: 1.25em;
}

/* A popover's choices (filters, columns, display) follow its text, as platform-ui's embedded forms do, instead of the
   theme's 1.5rem form targets, which tower over their labels at 13px. */
[popover] {
	--radio-size: 1.125em;
	--radio-dot-size: 0.5625em;
	--checkbox-size: 1.125em;
}

/* A table cell that takes the table's remaining width, and truncates what does not fit instead of widening the table. */
td.grow {
	width: 45%;
	max-width: 0;
}

/* A list row has one height, whether or not one of its cells holds a pill: the UX direction's 34px at 13px, or roomier. */
tr.row-compact {
	height: 2.6em;
}

tr.row-roomy {
	height: 3.2em;
}

/* The list pages (components/CollectionPanel), as the UX direction's list page presents them: controls at the text size
   (13px, 32px rows, 26px in the smaller footer) with the field's rounding, not the theme's 14px pills; em sizes, so
   `.small` scales them. */
.CollectionPanel {
	--action-font-size: 1em;
	--field-font-size: 1em;
	--field-font-size-compact: 1em;
	--control-height: calc(32em / 13);
	--action-padding: 0 0.75em;
	--action-border-radius: var(--field-border-radius);
	--text-table-padding-vertical: 0;
	--text-table-padding-horizontal: 0.75em;
}

/* The table and the footer run to the page's edges, past its padding (`--pad`, which `.p-*` sets), with the outer
   cells keeping that padding, so their rules span the page. */
.CollectionPanel .bleed {
	margin-inline: calc(-1 * var(--pad, 0px));
	width: calc(100% + 2 * var(--pad, 0px));
}

.CollectionPanel table.bleed :is(th, td):first-child {
	padding-inline-start: var(--pad, 0px);
}

.CollectionPanel table.bleed :is(th, td):last-child {
	padding-inline-end: var(--pad, 0px);
}

/* The header stays above the rows as the page scrolls, and the footer under them, flush with the page's bottom. */
.CollectionPanel thead th {
	position: sticky;
	top: 0;
	z-index: 1;
	height: 2.6rem;
	background-color: var(--color-surface);
}

.CollectionPanel footer.bleed {
	z-index: 1;
	margin-bottom: calc(-1 * var(--pad, 0px));
	padding: var(--pad-3) var(--pad, 0px);
	background-color: var(--color-surface);
}

/* The views are the filled presentation without its track: the selected view takes a light neutral fill, the others
   stay muted text. They keep to the title's row, and scroll sideways when there are more than it holds. */
.CollectionPanel .tabs.group {
	flex-wrap: nowrap;
	bottom: 0;
	padding: 0;
	gap: 0.25em;
	overflow-x: auto;
	scrollbar-width: none;
	--background-color-opacity: 0;
}

.CollectionPanel .tabs.group .tab {
	color: color-mix(in oklch, var(--color-surface-text), var(--color-surface) var(--text-muted-mix));
	font-weight: 500;
}

.CollectionPanel .tabs.group .tab[aria-selected="true"] {
	--background-color-base: var(--color-neutral);
	--background-color-opacity: 0.15;
	color: var(--color-surface-text);
	box-shadow: none;
}

/* The current page is filled, as a selected tab is; the others stay quiet. */
.CollectionPanel footer button[aria-current="page"] {
	background-color: color-mix(in srgb, var(--color-text) 8%, transparent);
	color: var(--color-text);
}

/* A popover's options are menu rows: no frame, a wash on hover that runs near its edges, and the control alone marks
   the choice. Its compact controls (fields, toggles, buttons) are a row high, and their frames run as near its edges as
   the washes do. What starts a row (its icon, control or words), a legend, a field's icon or words, and a ghost action's
   words, start one inset (`--inset`) further in: in rem, so that a smaller legend lines up too. A row's icon is as
   wide as its controls (`--checkbox-size`), so that the words after them line up as well. */
.CollectionPanel [popover] {
	--inset: 0.5rem;
	--control-height-compact: 2em;
	--field-padding-compact: 0 calc(var(--inset) - 1px);
	--field-gap: 0.5em;
	width: 18em;
	padding: var(--pad-1);
	gap: var(--gap-1);
}

.CollectionPanel [popover] .choice {
	border-width: 0;
	background-color: transparent;
	min-height: 2em;
	padding: 0 var(--inset);
	gap: 0.5em;
}

.CollectionPanel [popover] .ghost.compact:not(.grip) {
	padding-inline: var(--inset);
}

.CollectionPanel [popover] .menu {
	padding: 0;
}

.CollectionPanel [popover] .menu > button {
	min-height: 2em;
	padding-block: 0;
	padding-inline: var(--inset);
}

.CollectionPanel [popover] legend {
	padding: 0.25em var(--inset) 0;
}

/* A section, or the footer, follows a rule, with as much room under it as over it; the footer's actions are rows too. */
.CollectionPanel [popover] .bd-t {
	margin: 0;
	padding-top: var(--pad-1);
}

.CollectionPanel [popover] .choice:hover {
	background-color: color-mix(in srgb, var(--color-text) 5%, transparent);
}

/* A collection's layouts (components/CollectionPanel, in its header) are a framed group without its track, as high and
   framed as the outline buttons beside it (ui.css's control border, which stays as it is under the pointer, as theirs
   does): the chosen layout is filled as a selected view is, the others stay muted. Each shows its icon and its name,
   and its icon alone once the panel is too narrow for its header to hold the names beside its views. */
.CollectionPanel {
	container-type: inline-size;
}

.CollectionPanel .selector.toggle {
	--control-background-opacity: 0;
	--control-border-opacity: inherit;
	gap: 2px;
	padding: 2px;
	border: var(--control-border-width, 1px) solid color-mix(in srgb, color-mix(in oklab, var(--control-border-base),
		var(--control-border-tint) calc(100% - 100% * var(--control-border-blend))), transparent calc(100% - 100% * var(--control-border-opacity)));
	border-radius: var(--field-border-radius);
}

.CollectionPanel .selector.toggle > button {
	border-radius: calc(var(--field-border-radius) - 2px);
	color: color-mix(in oklch, var(--color-surface-text), var(--color-surface) var(--text-muted-mix));
}

.CollectionPanel .selector.toggle > button[aria-pressed="true"] {
	background-color: color-mix(in srgb, var(--color-text) 8%, transparent);
	color: var(--color-surface-text);
	box-shadow: none;
}

@container (width < 60em) {
	.CollectionPanel .selector.toggle > button {
		aspect-ratio: 1;
		padding: 0;
	}

	.CollectionPanel .selector.toggle > button > span {
		display: none;
	}
}

/* The collection's records run from edge to edge of the page (`.bleed`). The table's header stays out of its rows'
   scrolling, so that their scrollbar starts under it: both keep the same scrollbar gutter, so that their columns line
   up, and the header follows the rows sideways (components/CollectionPanel.js). Its gutter takes the width of the
   rows' scrollbar, which `.overflow` makes thin. The list and the board keep the page's padding within their
   scrolling. */
.CollectionPanel .records > :is(.head, .rows) {
	scrollbar-gutter: stable;
	scrollbar-width: thin;
}

.CollectionPanel .records > .pane {
	padding-inline: var(--pad, 0px);
}

/* The table's columns (its `colgroup`) set their widths, whatever the rows hold, and a cell clips what does not fit
   it, its text ending in an ellipsis. Its outer cells keep the page's padding. A row's checkbox follows the text, as a
   popover's choices do. */
.CollectionPanel table {
	--checkbox-size: 1.125em;
	table-layout: fixed;
}

.CollectionPanel table :is(th, td):first-child {
	padding-inline-start: var(--pad, 0px);
}

.CollectionPanel table :is(th, td):last-child {
	padding-inline-end: var(--pad, 0px);
}

.CollectionPanel :is(th, td) {
	overflow: hidden;
}

.CollectionPanel thead th > button {
	max-width: 100%;
}

/* A column's header moves when dragged, and resizes from its edge (components/CollectionPanel.js): the edge shows as
   the header is hovered, and marks the column while it is resized or focused. A header moved fades while a copy of it
   follows the pointer, and a marker shows where it would go. */
.CollectionPanel th .resizer {
	position: absolute;
	inset-block: 0;
	inset-inline-end: 0;
	width: 0.5em;
	cursor: col-resize;
}

.CollectionPanel th .resizer::after {
	content: "";
	position: absolute;
	inset-block: 0.75em;
	inset-inline-end: 0;
	width: 2px;
	border-radius: 1px;
	background-color: var(--border-color);
	opacity: 0;
}

.CollectionPanel th:hover .resizer::after {
	opacity: 1;
}

.CollectionPanel th:is(.resizing, :has(> .resizer:is(:hover, :focus-visible))) .resizer::after {
	inset-block: 0;
	background-color: var(--color-primary);
	opacity: 1;
}

.CollectionPanel th .resizer:focus-visible {
	outline: none;
}

.CollectionPanel th.lifted {
	opacity: 0.4;
}

.CollectionPanel .column-ghost {
	position: absolute;
	z-index: 3;
	box-shadow: 0 8px 24px rgb(9 9 11 / 0.12);
	pointer-events: none;
}

.CollectionPanel table.column-ghost :is(th, td):is(:first-child, :last-child) {
	padding-inline: var(--text-table-padding-horizontal);
	border: 1px solid var(--border-color);
	border-radius: var(--field-border-radius);
}

.CollectionPanel .column-marker {
	position: absolute;
	z-index: 3;
	inset-block: 0;
	width: 2px;
	margin-inline-start: -1px;
	background-color: var(--color-primary);
	pointer-events: none;
}

/* While a column moves or resizes, its cursor shows wherever the pointer goes; a resize's gesture overlay (Select's
   `drag`) takes the pointer, so that nothing under it reacts. */
:root.column-moving,
:root.column-moving * {
	cursor: grabbing !important;
}

.column-resizing {
	pointer-events: auto !important;
	cursor: col-resize;
}

/* In the Display popover, a column's grip moves it, its icon where the section's words start, and the title column,
   which stays first, keeps the grip's room. A column dragged shows where it would go. */
.CollectionPanel .grip {
	display: flex;
	flex: none;
	width: calc(var(--inset) + 1em);
	min-width: 0;
	padding: 0 0 0 var(--inset);
	justify-content: flex-start;
}

.CollectionPanel button.grip {
	cursor: grab;
}

.CollectionPanel .column-slot {
	border-radius: var(--field-border-radius);
	background-color: color-mix(in srgb, var(--color-text) 5%, transparent);
	outline: 1px dashed var(--border-color);
}

/* A filter set opens its own: its words are the chip's, not one of its round buttons. The chips keep to one line,
   short of room, each value ends in an ellipsis, after its label. */
.CollectionPanel .tag > .chip {
	display: flex;
	gap: 0.25em;
	min-width: 0;
}

.CollectionPanel .tag > button.chip {
	flex: 0 1 auto;
	aspect-ratio: auto;
	width: auto;
	height: auto;
	padding: 0;
	border-radius: 0;
	line-height: inherit;
	opacity: 1;
}

.CollectionPanel .tag > button.chip:hover {
	background: none;
	text-decoration: underline;
}

.CollectionPanel .tag .ellipsis {
	min-width: 1.5em;
}

/* A record's name says what the record is and its number (ui.css's tooltip), under the pointer or the keyboard's focus
   on its link: in the list, the link is the record's whole row, which shows its name's too. */
.CollectionPanel a.item:focus-visible [data-tooltip]::before,
.CollectionPanel a.item:focus-visible [data-tooltip]::after {
	opacity: 1;
}

/* The main navigation (components/Navigation), as the UX direction's sidebar: 240px at 13px, folding to its icons. Its
   entries are ghost buttons at the text size, left-aligned, with the field's rounding. */
.Navigation {
	width: calc(240em / 13);
	transition: width 120ms ease;
	--action-font-size: 1em;
	--control-height: calc(32em / 13);
	--action-padding: 0 0.75em;
	--action-border-radius: var(--field-border-radius);
}

.Navigation.folded {
	width: calc(2.5em + 2 * var(--pad-3));
}

.Navigation :is(a.button, footer > button) {
	justify-content: flex-start;
	gap: 0.75em;
	width: 100%;
	font-weight: 400;
}

/* A section's pages line up with its label, past its icon. */
.Navigation li li > a.button {
	padding-inline-start: 2.75em;
}

/* The current page is marked at the navigation's edge, past the list's padding (`.pw-3`), as well as filled. */
.Navigation a.button[aria-current="page"] {
	position: relative;
}

.Navigation a.button[aria-current="page"]::before {
	content: "";
	position: absolute;
	inset-block: 0.375em;
	inset-inline-start: calc(-1 * var(--pad-3));
	width: 2px;
	border-radius: 1px;
	background-color: var(--color-primary-900, var(--color-primary));
}

/* The assistant's toggle is filled while the assistant is open, as the current page's entry is (ui.css fills a ghost
   button that is `aria-current`), without the current page's mark. */
.Navigation footer > button[aria-pressed="true"] {
	background-color: var(--control-background-base, var(--control-color-base, var(--color-neutral)));
}

.Navigation.folded :is(header, a.button, footer > button) {
	justify-content: center;
}

.Navigation.folded :is(a.button, footer > button) {
	padding: 0;
}

/* The global search (components/SearchBar): its results open over the page, under the field and wider than it. */
.SearchBar .results {
	position: absolute;
	z-index: 30;
	inset-block-start: calc(100% + 0.25em);
	inset-inline-start: 0;
	width: max(100%, 36em);
	max-height: min(70vh, 34em);
	padding: 0;
	overflow: hidden;
}

/* A result's title line holds its tags, which lose their padding, so results with and without tags line up. */
.SearchBar [role="option"] .fill > .row {
	min-height: 1.5em;
}

.SearchBar [role="option"] .pill {
	padding-block: 0;
	line-height: 1.5;
}

/* The kind the search searches in is filled among the others it offers, as a current page is. */
.SearchBar .results button[aria-pressed="true"] {
	background-color: color-mix(in srgb, var(--color-text) 8%, transparent);
}

/* The field clears with its own button: the browser's, on a search input, would be a second one. */
.SearchBar input[type="search"]::-webkit-search-cancel-button {
	display: none;
}

/* What matched is marked with a light wash; the text keeps its colour. */
.SearchBar mark {
	border-radius: 0.125em;
	background-color: color-mix(in srgb, var(--color-warning) 35%, transparent);
	color: inherit;
}

/* The assistant (components/AgentPanel), the changes it proposes (components/ChangeSet), the task inbox
   (components/TaskInbox), the task beside it (components/TaskPanel) and the search's panel (components/SearchBar)
   take the list pages' controls: at the text size, with the field's rounding. */
:is(.AgentPanel, .ChangeSet, .TaskInbox, .TaskPanel, .SearchBar) {
	--action-font-size: 1em;
	--field-font-size: 1em;
	--field-font-size-compact: 1em;
	--action-padding: 0 0.75em;
	--action-border-radius: var(--field-border-radius);
}

/* Its conversation and its composer keep to a readable column, which a docked panel is narrower than, and which a page
   centres. Its menus are as wide as their entries need. */
.AgentPanel .column {
	width: 100%;
	max-width: 46em;
	margin-inline: auto;
}

.AgentPanel [popover] {
	min-width: 16em;
	max-width: 24em;
	padding: var(--pad-1);
}

/* The conversation shown is filled among the others, as a current page is. */
.AgentPanel .menu > [aria-current="true"] {
	background-color: color-mix(in srgb, var(--color-text) 8%, transparent);
}

/* A citation is a small numbered mark in the answer's text, as is the fact it leads to; the fact shows when reached. */
.AgentPanel .cite {
	min-width: 1.6em;
	padding: 0.15em 0.45em;
	border-radius: 1em;
	font-size: 0.75em;
	font-weight: 600;
	line-height: 1;
	text-align: center;
	vertical-align: 0.15em;
	background-color: color-mix(in srgb, var(--color-primary) 14%, transparent);
	color: var(--color-primary-text);
}

.AgentPanel a.cite {
	margin-inline-start: 0.15em;
	text-decoration: none;
}

.AgentPanel a.cite:hover {
	background-color: color-mix(in srgb, var(--color-primary) 28%, transparent);
}

.AgentPanel li > .cite {
	padding-block: 0.3em;
}

/* Its forms are embedded in the conversation: their labels are smaller than their title, and close to their field. */
.AgentPanel form {
	--field-label-size: 0.875em;
	--field-label-gap: 0.25em;
}

.AgentPanel li[tabindex] {
	padding: 0.25em;
}

.AgentPanel li[tabindex]:focus {
	outline: none;
	background-color: color-mix(in srgb, var(--color-primary) 18%, transparent);
}

/* The changes proposed (components/ChangeSet): what a change removes is struck through, and what it adds is marked,
   each in its tone, so that both read without their colour. */
.ChangeSet :is(del, ins) {
	padding: 0 0.2em;
	border-radius: 0.2em;
}

.ChangeSet del {
	background-color: color-mix(in srgb, var(--color-danger) 10%, transparent);
	color: var(--color-danger-text);
	text-decoration: line-through;
}

.ChangeSet ins {
	background-color: color-mix(in srgb, var(--color-success) 14%, transparent);
	color: var(--color-success-text);
	text-decoration: none;
}

/* The task open beside the inbox (components/TaskInbox) is filled, as a current page is. */
.TaskInbox a.item[aria-current="true"] {
	background-color: color-mix(in srgb, var(--color-text) 8%, transparent);
}
