/* Tools area bundle (FRAMEWORK.md 9): what the tools pages need beyond the
   vocabulary, loaded as their area bundle (ui/areas.py AREA_CSS). */

/* -- Tools (pages/tools.py, tools_load.py; the js/tools scripts; lane T) -- */
/* The /tools index (pages/tools.py ToolsIndex) and the workspace the tool
   scripts build inside a tool page's mount (tools_workspace.js and the tool
   registries, tools_ytdl.js). Spacing is on the --sp-* scale and a leaf
   carries no outer margin: blocks the scripts stack are spaced by their
   container's gap, borderless lines by padding. Fields are the site's own
   (.l-field, .fld, .chk-row) and buttons, notes, the panel, rows and row
   actions are WUi's (WUi.button, WUi.note, .c-panel, .l-row, WUi.acts), so
   they measure and read as every other page; this file lays them out. A
   rule that sets display on anything a script toggles with hidden carries
   :not([hidden]). Flat chrome: radius tokens, hover is a border or tint, a
   selection is a tint and an accent border. */

/* A tool page's workspace: the drop zone, files, panel and export bar a
   gap apart, like every other column of blocks. */
[data-tools-app]:not([hidden]) {
	display: flex;
	flex-direction: column;
	gap: var(--sp-3);
}

/* The file list holds no gap open before a file arrives. */
[data-tools-list]:empty { display: none; }

/* A page tile and the crop canvas clip, so their focus ring is inside. */
.tools-page:focus-visible,
.tools-crop-canvas:focus-visible { outline-offset: -2px; }

/* --- file list ---------------------------------------------------------- */

.tools-files {
	list-style: none;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	background: var(--surface-2);
}

.tools-file:not([hidden]) {
	display: flex;
	align-items: center;
	gap: var(--sp-3);
	padding: var(--sp-2);
	border-bottom: 1px solid var(--border);
}

.tools-file:last-child { border-bottom: 0; }

.tools-file--error { background: var(--danger-soft); }

.tools-file__thumb {
	flex: 0 0 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	background:
		conic-gradient(var(--border) 25%, transparent 0 50%, var(--border) 0 75%, transparent 0) 0 0 / 12px 12px,
		var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	overflow: hidden;
}

.tools-file__thumb img { max-width: 100%; max-height: 100%; }

.tools-file__thumb--plain {
	background: var(--bg);
	color: var(--text-muted);
	font-size: var(--fs-xs);
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.tools-file__info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.tools-file__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A tool page's name gives way in the middle: the stem truncates, the
   extension stays (WToolsUi.fileName draws the two spans). */
.tools-file__name:has(> span) { display: flex; min-width: 0; }
.tools-file__name > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tools-file__name > span + span { flex: none; }

.tools-file__meta,
.tools-progress-note,
.tools-page__num,
.tools-compare figcaption { color: var(--text-muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }

.tools-file__err { color: var(--danger); font-size: var(--fs-xs); }

.tools-file > .c-acts:not([hidden]) { justify-content: flex-end; }

/* The index's row: the icon controls keep one line and the name gives way
   (it ends in an ellipsis); the arrow at either end of the list keeps its
   place unseen rather than showing a disabled button. */
[data-tools-hub] .tools-file > .c-acts:not([hidden]) { flex: none; flex-wrap: nowrap; }

[data-tools-hub] .tools-file > .c-acts > [data-end] { visibility: hidden; }

/* A long name truncates; the row's glyph buttons never wrap under it. */
[data-tools-app] .tools-file > .c-acts:not([hidden]) { flex: none; flex-wrap: nowrap; }

/* --- panel -------------------------------------------------------------- */

/* Options sit two-up and stack from 900 px; .tools-full marks an item that
   spans both columns (details, sliders, plan lines). */
.tools-panel__grid:not([hidden]) {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--sp-3) var(--sp-4);
	align-items: start;
}

.tools-panel__grid > .tools-full { grid-column: 1 / -1; }

/* Fields inside a spanning details line up with the left column, but for
   one marked .tools-full. */
.tools-panel__grid > .tools-advanced > .l-field:not(.tools-full) { max-width: calc(50% - var(--sp-2)); }

/* A note in the options (a probe's status, a plan line) spans both
   columns, and holds no row open while it is empty. */
.tools-panel__grid > .c-note { grid-column: 1 / -1; }
.tools-panel__grid > .c-note:empty { display: none; }

/* A field's error line and Split's plan line keep one line from the first
   paint: a message fills in place and Export stays put. */
.l-field > .tools-file__err { display: block; min-block-size: 1lh; }
.tools-panel__grid > [data-split-plan] { min-block-size: 1lh; }
.tools-panel__grid > [data-split-plan]:empty { display: block; }

@media (max-width: 900px) {
	.tools-panel__grid:not([hidden]) { display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-3); }
	.tools-panel__grid > .tools-advanced > .l-field:not(.tools-full) { max-width: none; }
}

.l-field > textarea.fld { max-width: 34rem; }

/* A colour field: the site's field box at its height, the swatch inside. */
body.ui input[type="color"].fld { inline-size: 4rem; cursor: pointer; }

/* A slider with its value beside it (WToolsUi.slider): the value keeps a
   width of its own, so the slider does not move as the figure grows. */
.tools-sliderline:not([hidden]) { display: flex; align-items: center; gap: var(--sp-2); min-block-size: var(--ctl-h-field); }

.tools-sliderline input[type="range"] { flex: 0 1 18rem; min-width: 0; accent-color: var(--accent); }

.tools-sliderline > output { flex: none; min-inline-size: 4ch; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }

.tools-advanced { border-top: 1px solid var(--border); padding-top: var(--sp-2); }

.tools-advanced summary {
	display: flex;
	align-items: center;
	min-block-size: var(--ctl-h-chip);
	cursor: pointer;
	font-size: var(--fs-sm);
	color: var(--text-muted);
}

/* The summary is a flex row, which drops the browser's marker: its own. */
.tools-advanced summary { gap: var(--sp-1); }

.tools-advanced summary::before {
	content: "";
	inline-size: 0;
	block-size: 0;
	border-block: 0.3em solid transparent;
	border-inline-start: 0.4em solid currentColor;
}

.tools-advanced[open] > summary::before { transform: rotate(90deg); }

.tools-advanced > :not(summary) { padding-block-start: var(--sp-2); }

/* Quality: the three steps, then the number they set. */
.l-row > .c-seg + input[type="number"] { inline-size: 5rem; }

/* --- split working layout (controls | preview) --------------------------- */

.tools-split:not([hidden]) {
	display: grid;
	grid-template-columns: minmax(0, 24rem) minmax(0, 1fr);
	gap: var(--sp-4);
	align-items: start;
}

.tools-split__controls:not([hidden]) { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }

.tools-split__preview { position: sticky; inset-block-start: calc(var(--header-h) + var(--sp-3)); min-width: 0; }

@media (max-width: 900px) {
	.tools-split:not([hidden]) { grid-template-columns: minmax(0, 1fr); }
	.tools-split__preview { position: static; }
}

/* Background removal on a phone: the preview first, above its controls. */
@media (max-width: 600px) {
	.tools-split:has(.tools-bg-canvas) > .tools-split__preview { order: -1; }
}

/* --- export bar --------------------------------------------------------- */

.tools-export__row:not([hidden]) {
	display: flex;
	gap: var(--sp-2);
	align-items: center;
	flex-wrap: wrap;
}

.tools-export__spacer { flex: 1 1 auto; }

.tools-name-input { max-width: 22rem; }

.tools-progress-wrap:not([hidden]) { display: flex; gap: var(--sp-2); align-items: center; }

.tools-progress { flex: 0 1 22rem; accent-color: var(--accent); }

/* --- page grid (organize / merge) --------------------------------------- */

.tools-gridbar:not([hidden]) { display: flex; gap: var(--sp-1); flex-wrap: wrap; align-items: center; }

.tools-gridbar > .c-note { margin-inline-start: auto; }

.tools-pagegrid:not([hidden]) {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: var(--sp-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	background: var(--surface-2);
	padding: var(--sp-2);
}

.tools-page:not([hidden]) {
	position: relative;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
	background: var(--bg);
	padding: var(--sp-1);
	cursor: grab;
	user-select: none;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: var(--sp-1);
}

.tools-page:hover { border-color: var(--text-muted); }

/* Selected: the whole tile tinted with an accent border and number. */
.tools-page--selected,
.tools-page--selected:hover {
	border-color: var(--accent);
	background: var(--accent-soft);
}

.tools-page--selected .tools-page__num { color: var(--accent); font-weight: 600; }

.tools-page--droptarget { border-style: dashed; border-color: var(--accent); }

/* Under the thumbnail, one line: the page number, then rotate and delete
   (tools_organize.js), clear of the page's top where its heading is. */
.tools-page > .c-acts:not([hidden]) { justify-self: end; }

.tools-page__num { padding-inline-start: var(--sp-1); }

.tools-page__frame {
	grid-column: 1 / -1;
	width: 100%;
	aspect-ratio: 3 / 4;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
}

.tools-page__frame img { max-width: 100%; max-height: 100%; }

.tools-page__blank { color: var(--text-muted); font-size: var(--fs-xs); }

.tools-page__frame--loading {
	background: color-mix(in srgb, var(--text-muted) 7%, var(--surface-2));
	animation: tools-thumb-pulse 1.6s ease-in-out infinite;
}

@keyframes tools-thumb-pulse {
	50% { opacity: 0.55; }
}

/* --- compress compare --------------------------------------------------- */

.tools-compare:not([hidden]) { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-start; }

.tools-compare figure { margin: 0; flex: 1 1 220px; max-width: 340px; }

.tools-compare img,
.tools-compare canvas {
	max-height: 300px;
	width: auto;
	height: auto;
}

.tools-compare img {
	max-width: 100%;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background:
		conic-gradient(var(--border) 25%, transparent 0 50%, var(--border) 0 75%, transparent 0) 0 0 / 14px 14px,
		var(--surface-2);
}

/* --- crop dialog (appended to body, outside the page frame) --------------- */

.tools-crop-overlay:not([hidden]) {
	position: fixed;
	inset: 0;
	background: var(--modal-backdrop);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: var(--z-modal);
}

.tools-crop-box:not([hidden]) {
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: var(--sp-4);
	max-width: calc(100vw - 40px);
	max-height: calc(100dvh - 40px);
	overflow: auto;
	display: flex;
	flex-direction: column;
	gap: var(--sp-2);
}

.tools-crop-canvas {
	touch-action: none;
	background:
		conic-gradient(var(--border) 25%, transparent 0 50%, var(--border) 0 75%, transparent 0) 0 0 / 14px 14px,
		var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	cursor: crosshair;
	max-width: 100%;
}

.tools-crop-actions { justify-content: flex-end; }

/* X, Y, Width and Height share one line, two to a line on a phone. */
.tools-crop-box .l-row > .l-field { flex: 1 1 5rem; min-width: 0; }
.tools-crop-box .l-row > .l-field > .fld { inline-size: 100%; }

/* --- tools index ---------------------------------------------------------- */

/* The index (pages/tools.py ToolsIndex + tools_hub.js): the drop zone; with
   files loaded, the hub - the files, a row of operations per kind of file
   (.tools-op: a format or a one-word name beside its glyph) and the last
   run with its results and folded options; with none, an optional Recent
   row and one column per group of .tools-tool tiles - glyph and short
   name, "input -> output" as the title. */
.tools-menu__title {
	display: block;
	font-size: var(--fs-xs);
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--text-muted);
}

.tools-glyph { flex: none; inline-size: 1rem; block-size: 1rem; }

.tools-glyph svg { display: block; width: 100%; height: 100%; }

/* A tool page's head strip: each tool's glyph before its name. */
.c-subnav__current:has(> .tools-glyph) { column-gap: var(--sp-1); }

/* An output's Save: the glyph, then the word. */
[data-tools-save] { gap: var(--sp-1); }

.tools-hub__head:not([hidden]) { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }

.tools-hub__count { color: var(--text-muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }

/* Show all N under a folded list; nothing while the list is short. */
.tools-hub__more:has(> [hidden]) { display: none; }

.tools-ops:not([hidden]) { display: flex; flex-direction: column; gap: var(--sp-3); }

.tools-ops:empty { display: none; }

.tools-ops__row:not([hidden]) { display: flex; flex-direction: column; gap: var(--sp-2); }

.tools-ops__tiles:not([hidden]) { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.tools-op:not([hidden]) {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	gap: var(--sp-2);
	block-size: var(--ctl-h-primary);
	padding: 0 var(--sp-3);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-md);
	background: var(--surface-2);
	color: var(--text);
	font: inherit;
	font-size: var(--fs-sm);
	text-decoration: none;
	cursor: pointer;
	user-select: none;
}

.tools-op:hover,
.tools-op:focus-visible {
	text-decoration: none;
	border-color: var(--accent);
	background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
}

.tools-op[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* Off while a run is busy: the site's disabled look (a dashed border, a
   flat fill, muted text at full opacity); the script ignores the click. */
.tools-op[aria-disabled="true"],
.tools-op[aria-disabled="true"]:hover {
	background: var(--surface-2);
	border-color: var(--border);
	border-style: dashed;
	color: var(--text-muted);
	cursor: not-allowed;
}

.tools-op > .tools-glyph { color: var(--text-muted); }

.tools-op[aria-pressed="true"] > .tools-glyph { color: inherit; }

.tools-op__fmt { font-weight: 600; letter-spacing: 0.02em; }

.tools-run__head:not([hidden]) { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }

.tools-run__title { flex: 1 1 auto; min-inline-size: 0; font-size: var(--fs-base); font-weight: 600; }

/* The progress bar while a run is busy, its outcome after: one line of the
   same height either way. */
.tools-run__status:not([hidden]) { display: flex; align-items: center; min-block-size: var(--ctl-h-btn); }

.tools-run__status > .tools-progress-wrap { flex: 1 1 auto; min-inline-size: 0; }

/* A run's outputs (and a pick list) are dense rows: a small thumbnail, the
   name and its meta on one line. */
.tools-run .tools-file:not([hidden]) { box-sizing: border-box; min-block-size: var(--row-h); padding-block: 0; }

.tools-run .tools-file__thumb { flex-basis: 24px; height: 24px; }

.tools-run .tools-file__info { flex-direction: row; align-items: baseline; gap: var(--sp-2); }

.tools-run .tools-file__name { min-inline-size: 0; }

.tools-run .tools-file__meta { flex: none; }

.tools-run__fields:not([hidden]) { display: flex; flex-direction: column; gap: var(--sp-3); }

.l-grid.tools-index__cols {
	--l-cols: repeat(3, minmax(0, 1fr));
	gap: var(--sp-5);
	align-items: start;
}

.tools-index__list:not([hidden]) {
	display: flex;
	flex-direction: column;
	gap: var(--sp-2);
}

.tools-index__list--row:not([hidden]) {
	flex-direction: row;
	flex-wrap: wrap;
}

.tools-index__list--row .tools-tool { flex: 1 1 16rem; max-width: 22rem; }

/* Recent is one compact row of the same tiles. */
[data-tools-recent-list] .tools-tool:not([hidden]) { flex: none; }

/* A tile is its glyph and name on one line; the input -> output line is
   its title. */
.tools-tool:not([hidden]) {
	display: grid;
	grid-template-columns: 1.4rem minmax(0, 1fr);
	column-gap: var(--sp-2);
	align-items: center;
	/* One line of text: with the padding and border it is the control's
	   height, 44 px on touch. */
	min-block-size: calc(var(--ctl-h-primary) - 2 * var(--sp-2) - 2px);
	padding: var(--sp-2) var(--sp-3);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	background: var(--surface-2);
	color: var(--text);
	text-decoration: none;
}

.tools-tool:hover,
.tools-tool:focus-visible {
	text-decoration: none;
	border-color: var(--accent);
	background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
}

.tools-tool__icon {
	width: 1.3rem;
	height: 1.3rem;
}

.tools-tool__icon svg { display: block; width: 100%; height: 100%; }

[data-tools-group] .tools-tool__icon { color: var(--accent); }

.tools-tool__name { font-size: var(--fs-sm); }

@media (max-width: 900px) {
	.l-grid.tools-index__cols { --l-cols: minmax(0, 1fr); }
}

/* --- responsive / preferences ------------------------------------------- */

@media (max-width: 600px) {
	/* A tool page's head strip is one line that scrolls sideways, not a
	   ragged wrap of links. */
	[data-area="tools"] .l-page__nav > .c-links { display: flex; flex: 1 1 100%; min-inline-size: 0; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; white-space: nowrap; }
	[data-area="tools"] .l-page__nav > .c-links > * { flex: none; }
	/* Its links keep the 44 px touch height but are as wide as their
	   words, so the gaps between them are even. */
	body.ui [data-area="tools"] .l-page__nav > .c-links > .c-link:not([hidden]) { min-inline-size: 0; }
	.tools-pagegrid:not([hidden]) { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
	.tools-file:not([hidden]) { flex-wrap: wrap; }
	.tools-file > .c-acts:not([hidden]) { width: 100%; justify-content: flex-start; }
	/* A phone shows a file's whole name, wrapping onto more lines, since
	   names that differ at the end would truncate alike (no middle cut). */
	.tools-file__name:has(> span) { display: block; }
	.tools-file__name,
	.tools-file__name > span:first-child { white-space: normal; overflow-wrap: anywhere; }
	/* The index keeps a row to one line: its controls are icons. */
	[data-tools-hub] .tools-file:not([hidden]) { flex-wrap: nowrap; }
	[data-tools-hub] .tools-file > .c-acts:not([hidden]) { flex: none; width: auto; }
	/* So does a tool page: its row actions are icons too. */
	[data-tools-app] .tools-file:not([hidden]) { flex-wrap: nowrap; }
	[data-tools-app] .tools-file > .c-acts:not([hidden]) { flex: none; width: auto; }
	/* Undo / Redo on one line, Start over ... Export on the next; with no
	   Undo there is no first line. */
	.tools-export__spacer { flex-basis: 100%; }
	.tools-export__spacer:first-child { flex-basis: auto; }
	[data-tools-export] { margin-left: auto; }
	/* The head strip names the page in the h1 above it: on a phone the
	   current item is left out, so it does not wrap into a second title. */
	body.ui .l-page__nav .c-links > .c-subnav__current,
	body.ui .l-page__nav .c-links > .c-subnav__current + .c-links__sep,
	body.ui .l-page__nav .c-links > .c-links__sep:has(+ .c-subnav__current:last-child) { display: none; }
	/* The trim labels line up their fields. */
	.tools-wave .tools-bg-sliderlabel > span:first-child { min-width: 3em; }
	.tools-wave select { min-width: 4.5rem; }
}

@media (prefers-reduced-motion: reduce) {
	.tools-progress { transition: none; }
	.tools-page__frame--loading { animation: none; }
}

/* --- overlay tools (add-text / page-numbers / watermark) ----------------- */

.tools-ovpreview { padding-block-start: var(--sp-2); }

.tools-ovnav { align-items: center; padding-block-end: var(--sp-2); }

.tools-ovstage {
	position: relative;
	display: inline-block;
	max-width: 100%;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--bg);
	line-height: 0;
}

.tools-ovcanvas { display: block; max-width: 100%; }

.tools-ovlayer {
	position: absolute;
	inset: 0 auto auto 0;
	line-height: normal;
}

.tools-ovlayer--drawing { cursor: crosshair; }

.tools-ovsvg { position: absolute; inset: 0; pointer-events: none; }

.tools-ovsvg .tools-ovshape { pointer-events: stroke; cursor: pointer; }

.tools-ovsvg .tools-ovshape--selected { outline: none; }

.tools-ovtext {
	position: absolute;
	border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
	background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.tools-ovtext--selected {
	border-style: solid;
	border-color: var(--accent);
	background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.tools-ovtext__edit {
	min-height: 1em;
	outline: none;
	padding: var(--sp-1);
	overflow-wrap: break-word;
	line-height: 1.25;
}

.tools-ovtext__grip {
	position: absolute;
	top: -1.15rem;
	left: -1px;
	font: inherit;
	font-size: var(--fs-xs);
	line-height: 1;
	padding: 0 var(--sp-1);
	background: var(--accent);
	color: var(--on-accent);
	border: 0;
	border-radius: var(--radius-sm) var(--radius-sm) 0 0;
	cursor: grab;
}

.tools-ovtext__resize {
	position: absolute;
	right: -5px;
	bottom: -5px;
	width: 10px;
	height: 10px;
	background: var(--accent);
	border-radius: 50%;
	cursor: nwse-resize;
}

.tools-inspector__title { font-size: var(--fs-sm); }

.tools-scope:not([hidden]) { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* --- background removal --------------------------------------------------- */

.tools-bg-canvas:not([hidden]) {
	max-width: 100%;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	display: block;
}

.tools-bg-canvas--checker {
	background:
		conic-gradient(var(--border) 25%, transparent 0 50%, var(--border) 0 75%, transparent 0) 0 0 / 14px 14px,
		var(--surface-2);
}

.tools-bg-swatch:not([hidden]) {
	display: inline-block;
	width: 1.6rem;
	height: 1.6rem;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
	vertical-align: middle;
}

.tools-bg-refine-scroll {
	overflow: auto;
	max-width: calc(100vw - 80px);
	max-height: calc(100dvh - 280px);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
}

.tools-bg-refine-scroll canvas { cursor: crosshair; touch-action: none; display: block; }

.tools-bg-sliderlabel:not([hidden]) {
	display: inline-flex;
	align-items: center;
	gap: var(--sp-2);
	min-block-size: var(--ctl-h-chip);
	font-size: var(--fs-sm);
	color: var(--text-muted);
}

/* --- media tools ---------------------------------------------------------- */

.tools-wave__scroll {
	overflow-x: auto;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface-2);
}

.tools-wave__canvas { display: block; touch-action: none; cursor: crosshair; }

.tools-wave > .l-row:not([hidden]) { padding-block-start: var(--sp-2); }

.tools-wave input[type="text"] { width: 7.5rem; }

/* --- download video (owner-only) ----------------------------------------- */

/* The preview's thumbnail beside its title and Note (the panel is a Panel). */
.tools-ytdl-meta:not([hidden]) {
	display: flex;
	gap: var(--sp-3);
	align-items: flex-start;
}

.tools-ytdl-thumb {
	width: 180px;
	max-width: 40%;
	aspect-ratio: 16 / 9;
	object-fit: cover;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	flex: none;
}

.tools-ytdl-title {
	padding-block-end: var(--sp-1);
	font-size: var(--fs-sm);
}

/* The Saved bar (a Toolbar): the search keeps its width, a line above the list. */
.tools-ytdl-libbar { padding-block-end: var(--sp-2); }

.tools-ytdl-libbar input[type="search"] { inline-size: 20rem; max-inline-size: 100%; }

/* A saved or subscription row (a RowList line) keeps its actions on one
   line, as a table's RowActions do. */
.tools-ytdl-lib .c-acts { flex-wrap: nowrap; }

/* Its title takes a line and its details and actions the next, at every
   width (the RowList's own phone layout): a long title is never squeezed
   beside them. */
.tools-ytdl-lib .c-list__item { flex-wrap: wrap; row-gap: 0; padding-block: var(--sp-1); }
.tools-ytdl-lib .c-list__main { flex-basis: 100%; }
.tools-ytdl-lib .c-list__meta { flex: 1 1 0; min-inline-size: 0; }

/* Phone: the search takes a line and the sort and paging sit under it. */
@media (max-width: 600px) {
	.tools-ytdl-libbar > :is(.l-toolbar__lead, .l-toolbar__trail) { flex: 1 1 100%; }
	.tools-ytdl-libbar input[type="search"] { flex: 1 1 100%; inline-size: auto; }
}
/* -- end Tools -- */
