/*
 * The network dialog: a workspace someone keeps open for hours. Header and tabs stay put, only
 * the body scrolls, and the live indicators sit where the eye already is.
 */

.dialog-host {
	position: fixed;
	inset: 0;
	z-index: var(--z-dialog);
	display: none;
	align-items: center;
	justify-content: center;
	padding: var(--s5);
	background: rgba(6, 9, 13, .68);
	backdrop-filter: blur(2px);
}
.dialog-host.is-open { display: flex; }

.dialog-panel {
	width: min(1480px, 95vw);
	height: min(920px, 92vh);
	display: flex;
	flex-direction: column;
	background: var(--bg);
	border: 1px solid var(--line-strong);
	border-radius: var(--r4);
	box-shadow: var(--shadow-3);
	overflow: hidden;
	min-height: 0;
}

.dialog-panel.is-narrow { width: min(1120px, 96vw); height: auto; max-height: 88vh; }

.dialog-panel.create-panel {
	width: min(1180px, 96vw);
	height: min(860px, 92vh);
}
.dialog-panel.create-panel .dialog-body {
	display: flex;
	flex-direction: column;
	min-height: 0;
}
.create-layout {
	display: grid;
	grid-template-columns: minmax(320px, 420px) minmax(420px, 1fr);
	grid-template-rows: minmax(0, 1fr) auto;
	gap: var(--s6);
	align-items: stretch;
	flex: 1;
	min-height: 480px;
}
.explorer-pane {
	min-width: 0;
	min-height: 420px;
	display: flex;
}
.explorer-tree {
	flex: 1;
	min-height: 420px;
	max-height: none;
	overflow: auto;
	padding: var(--s4);
	border: 1px solid var(--line);
	border-radius: var(--r3);
	background: var(--surface);
}
.explorer-tree h3 { margin-bottom: var(--s2); }
.explorer-tree > input { width: 100%; margin: var(--s3) 0; }
.explorer-node {
	display: flex;
	align-items: center;
	gap: var(--s2);
	min-height: 28px;
	cursor: pointer;
}
.create-foot {
	grid-column: 1 / -1;
	display: flex;
	align-items: center;
	gap: var(--s2);
	padding-top: var(--s4);
	border-top: 1px solid var(--line);
}
.create-foot-gap { flex: 1; }
.field-error { color: var(--bad); font-size: var(--t-caption); margin: 0; }
.explorer-tools { display: flex; gap: var(--s2); margin-bottom: var(--s2); }
.explorer-stat { display: flex; justify-content: space-between; gap: var(--s3); margin: 0; }
.explorer-summary { margin-top: var(--s3); border-top: 1px solid var(--line); padding-top: var(--s3); }
.explorer-node.is-filtered, .explorer-node.is-filtered + .explorer-children { display: none; }
@media (max-width: 900px) {
	.create-layout { grid-template-columns: 1fr; }
}

/* --- header ---------------------------------------------------------------------------- */

.dialog-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--s5);
	padding: var(--s5) var(--s6) var(--s4);
	background: var(--surface);
	border-bottom: 1px solid var(--line);
	flex-shrink: 0;
}

.dialog-head-text { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.dialog-head h2 { font-size: var(--t-display); font-weight: 640; letter-spacing: -.01em; }

/* identity line: #3 · local-demo · Todas */
.dialog-ident { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--t-caption); flex-wrap: wrap; }
.dialog-ident .sep { color: var(--faint); }

/* context line: round, model, snapshot, badges */
.dialog-context { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.dialog-context .ctx {
	display: inline-flex;
	align-items: baseline;
	gap: 5px;
	color: var(--text-2);
	font-size: var(--t-caption);
}
.dialog-context .ctx-k { color: var(--faint); }
.dialog-context .ctx-v { font-variant-numeric: tabular-nums; font-weight: 560; color: var(--text); }

.dialog-head-actions { display: flex; align-items: center; gap: var(--s2); flex-shrink: 0; }

/* live progress strip under the header, only while something runs */
.dialog-live {
	display: flex;
	align-items: center;
	gap: var(--s3);
	padding: var(--s2) var(--s6) var(--s3);
	background: var(--surface);
	border-bottom: 1px solid var(--line);
	flex-shrink: 0;
}
.dialog-live .bar { flex: 1; }
.dialog-live-text { color: var(--text-2); font-size: var(--t-caption); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* --- tabs ------------------------------------------------------------------------------ */

.dialog-tools {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: var(--s2) var(--s4);
	padding: 0 var(--s6);
	background: var(--surface);
	border-bottom: 1px solid var(--line);
	flex-shrink: 0;
}

.tabs {
	display: flex;
	flex: 1;
	flex-wrap: wrap;
	align-items: stretch;
	gap: var(--s1);
	min-width: 0;
	overflow: visible;
}
.tab {
	position: relative;
	height: 42px;
	padding: 0 var(--s4);
	border: 0;
	background: none;
	color: var(--muted);
	cursor: pointer;
	white-space: nowrap;
	font-size: var(--t-body);
	font-weight: 540;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); }
.tab.is-active::after {
	content: "";
	position: absolute;
	left: var(--s3); right: var(--s3); bottom: -1px;
	height: 2px;
	border-radius: 2px 2px 0 0;
	background: var(--accent);
}
.tab-dot {
	display: inline-block;
	width: 6px; height: 6px;
	border-radius: var(--r-pill);
	background: var(--accent);
	margin-left: 6px;
	vertical-align: middle;
}

.dialog-round {
	display: flex;
	align-items: center;
	align-self: center;
	gap: var(--s2);
	flex-shrink: 0;
}
.dialog-round label { color: var(--muted); font-size: var(--t-caption); line-height: 1; }
.dialog-round select {
	height: 26px;
	max-height: 26px;
	padding: 0 var(--s2);
	font-size: var(--t-caption);
	line-height: 1;
}

/* --- body ------------------------------------------------------------------------------ */

.dialog-body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	padding: var(--s5) var(--s6) var(--s7);
	display: flex;
	flex-direction: column;
	gap: var(--s4);
	background: var(--bg);
}

.dialog-foot {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: var(--s2);
	padding: var(--s4) var(--s6);
	border-top: 1px solid var(--line);
	background: var(--surface);
	flex-shrink: 0;
}

.menu-note { color: var(--muted); font-size: var(--t-caption); }

/* --- historical banner ----------------------------------------------------------------- */

.history-banner {
	display: flex;
	align-items: center;
	gap: var(--s3);
	padding: var(--s3) var(--s4);
	border: 1px solid rgba(232, 180, 87, .32);
	border-radius: var(--r2);
	background: var(--warn-weak);
	color: var(--warn);
	font-size: var(--t-caption);
}
.history-banner .btn { margin-left: auto; }

/* --- secondary menu -------------------------------------------------------------------- */

.menu-pop {
	position: absolute;
	right: var(--s6);
	top: 58px;
	z-index: 2;
	min-width: 190px;
	background: var(--surface-2);
	border: 1px solid var(--line-strong);
	border-radius: var(--r2);
	box-shadow: var(--shadow-2);
	padding: var(--s1);
	display: flex;
	flex-direction: column;
}
.menu-pop button {
	height: 32px;
	padding: 0 var(--s3);
	border: 0;
	background: none;
	color: var(--text-2);
	text-align: left;
	border-radius: var(--r1);
	cursor: pointer;
}
.menu-pop button:hover { background: var(--surface-3); color: var(--text); }

@media (max-width: 900px) {
	.dialog-host { padding: 0; }
	.dialog-panel { width: 100vw; height: 100vh; border-radius: 0; border: 0; }
	.dialog-head, .dialog-tools, .dialog-body, .dialog-live { padding-left: var(--s4); padding-right: var(--s4); }
}

/* --- images ----------------------------------------------------------------------------- */

.image-stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 360px;
	border-radius: var(--r2);
	background:
		repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface-3) 0% 50%) 50% / 18px 18px;
	overflow: hidden;
}

.image-frame { position: relative; transform-origin: center; line-height: 0; }
.image-frame img { display: block; max-width: 100%; max-height: 520px; }
.image-boxes { position: absolute; inset: 0; width: 100%; height: 100%; }
.box-gt { fill: none; stroke: var(--good); stroke-width: .004; }
.box-pred { fill: none; stroke: var(--warn); stroke-width: .004; stroke-dasharray: .012 .008; }
.image-missing { color: var(--muted); padding: var(--s5); }

/*
 * The contact strip. Two things matter here and both were wrong.
 *
 * The cell must not be sized by the image. A grid item is stretched by default and the row is
 * sized by its content, so an <img> that has not decoded yet contributes nothing and the row
 * collapses, while free space is then handed back to the rows and blows them up again. The strip
 * resized itself under the reader's cursor every time a page of thumbnails arrived. Pinning the
 * item to its own 4:3 box, and reserving that box on the image before it decodes, keeps every cell
 * the same size from the first paint.
 *
 * And it has to be tall enough to work in: a snapshot here holds around twenty thousand samples,
 * which is not something anyone browses through two rows.
 */
.image-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
	grid-auto-rows: max-content;
	align-items: start;
	align-content: start;
	gap: var(--s2);
	max-height: min(56vh, 620px);
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: var(--s1);
}

.thumb {
	position: relative;
	padding: 0;
	border: 2px solid transparent;
	border-radius: var(--r2);
	background: var(--surface-2);
	cursor: pointer;
	overflow: hidden;
	aspect-ratio: 4 / 3;
}
.thumb img { width: 100%; height: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.thumb:hover { border-color: var(--line-strong); }
.thumb.is-selected { border-color: var(--accent); }
.thumb-split {
	position: absolute;
	left: 4px; bottom: 4px;
	padding: 1px 5px;
	border-radius: var(--r1);
	background: rgba(8, 11, 16, .74);
	color: var(--text-2);
	font-size: 9px;
	letter-spacing: .04em;
}
