/* SPDX-License-Identifier: LicenseRef-Cognitum-Proprietary
 *
 * Xunison operator theme. Every rule consumes only the custom properties
 * declared in brand.css, so re-branding is a single-file change.
 */
@import url("/luci-static/openwrt2020/cascade.css");

/* Xunison is a rebrand of cognitumWRT, not a replacement for it, and the
 * image ships luci-app-cognitum. Those views are built entirely from
 * `.cognitum-*` classes which live in the Cognitum theme's stylesheet, so
 * making Xunison the active theme without this import orphaned them:
 * Overview, Store, and Settings rendered as raw unstyled HTML — icons with
 * no width attribute expanded to the full column (1167px square), the
 * catalog grid collapsed to 136 stacked full-width cards, and a 22,000px
 * page. Nothing in the Xunison stylesheet could have fixed that, because
 * the selectors simply were not present.
 *
 * Structure is inherited here; the palette is re-pointed at Xunison tokens
 * immediately below, so those views adopt the brand instead of keeping
 * Cognitum's cyan. */
@import url("/luci-static/cognitum/cascade.css");

@import url("/luci-static/xunison/brand.css");

/* Re-point the inherited theme's tokens at the Xunison palette. This is the
 * whole reason the import above is safe: the Cognitum rules that consume
 * these properties become Xunison-coloured without being duplicated.
 *
 * Rules in that stylesheet which hardcode a literal instead of reading a
 * token keep their original colour — that is a known limitation of
 * inheriting it, and the reason this file forbids literals of its own. */
:root {
	--cognitum-background: var(--xunison-background);
	--cognitum-foreground: var(--xunison-foreground);
	--cognitum-card: var(--xunison-surface);
	--cognitum-card-raised: var(--xunison-surface-raised);
	--cognitum-border: var(--xunison-border);
	--cognitum-muted: var(--xunison-muted);
	--cognitum-primary: var(--xunison-primary);
	--cognitum-accent: var(--xunison-ok);
	--cognitum-danger: var(--xunison-danger);
	--cognitum-warning: var(--xunison-warn);
	--cognitum-surface-overlay: var(--xunison-surface);
	--cognitum-gradient-card: var(--xunison-gradient-surface);
	--cognitum-gradient-hero: var(--xunison-gradient-hero);
	--cognitum-shadow-card: var(--xunison-shadow);
	--regular-font: var(--xunison-font);

	/* openwrt2020's own tokens, which both themes re-point. */
	--main-bright-color: var(--xunison-primary);
	--main-dark-color: var(--xunison-background);
	--secondary-bright-color: var(--xunison-foreground);
	--secondary-dark-color: var(--xunison-background);
	--danger-color: var(--xunison-danger);
	--warning-color: var(--xunison-warn);
	--success-color: var(--xunison-ok);
}

html {
	max-width: none;
	background: var(--xunison-background);
}

body {
	background-color: var(--xunison-background);
	background-image: var(--xunison-gradient-page);
	background-attachment: fixed;
	color: var(--xunison-foreground);
	font-family: var(--xunison-font);
	font-feature-settings: var(--xunison-font-features);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

#menubar {
	min-height: 64px;
	padding-left: 20px;
	background-color: var(--xunison-surface);
	background-image: var(--xunison-gradient-surface);
	border-bottom: 1px solid var(--xunison-border);
	box-shadow: inset 0 -1px 0 var(--xunison-hairline);
}

#menubar .hostname {
	font-size: 1.25rem;
	letter-spacing: 0.02em;
	color: var(--xunison-foreground);
}

/* The base theme hardcodes this white for its own coloured menubar. Against
 * the Xunison bar it measured 1.00 contrast — white on white, occupying 350
 * x 18px of the header on every page while being completely unreadable.
 * Inherited colour is not a style; state it. */
#menubar .distversion {
	color: var(--xunison-muted);
	font-size: 0.85rem;
}

/* Suppress the inherited wordmark.
 *
 * luci-theme-cognitum injects its brand as generated content —
 * `#menubar .hostname::before { content: "COGNITUM" }` — so importing that
 * stylesheet for its layout brought the wordmark with it, and an Xunison
 * device rendered "[XUNISON] COGNITUM OpenWrt": two brands in one header,
 * which is worse for a whitelabel than showing the wrong one.
 *
 * Removing it here rather than editing the Cognitum theme keeps that theme
 * correct for its own images. Branding injected via CSS is the reason this
 * needs a rule at all; markup would have been overridable by the template. */
#menubar .hostname::before {
	content: none;
	margin-right: 0;
}

#menubar .xun-logo {
	flex: 0 0 auto;
	margin-right: 4px;
}

/* Contrast repairs on inherited surfaces.
 *
 * The base theme pairs white text with its bright accent (measured 2.41:1,
 * against a 4.5:1 requirement) on the nav toggle, primary buttons, and the
 * footer. Xunison's accent is a coral that fails the same way, so the ink
 * is set from --xunison-primary-contrast, which exists precisely to be
 * legible on the primary fill. */
#menubar > button.navigation,
.cbi-button-action,
.cbi-button-apply,
.cbi-button-save,
.cbi-button-positive,
.cognitum-home-primary {
	background-color: var(--xunison-primary);
	border-color: var(--xunison-primary);
	color: var(--xunison-primary-contrast);
}

/* The "No password set!" banner measured 2.96:1 — a warning nobody can read
 * is worse than no warning, since it still consumes the space. */
.alert-message.warning,
.alert-message.warning h4,
.alert-message.warning p {
	color: var(--xunison-foreground);
}

p.luci,
p.luci a {
	color: var(--xunison-muted);
}

/* Dashboard layout ---------------------------------------------------- */

.xun-dashboard {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
	max-width: 1280px;
}

.xun-hero {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1.35rem 1.6rem;
	background-color: var(--xunison-surface);
	background-image: var(--xunison-gradient-hero);
	border: 1px solid var(--xunison-border);
	border-radius: var(--xunison-radius);
	box-shadow: var(--xunison-shadow), inset 0 1px 0 var(--xunison-hairline);
}

.xun-hero h2 {
	margin: 0;
	font-size: 1.45rem;
	font-weight: 650;
	letter-spacing: -0.014em;
	color: var(--xunison-foreground);
}

.xun-hero p {
	margin: 0.35rem 0 0;
	color: var(--xunison-muted);
	max-width: 62ch;
}

.xun-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 1rem;
}

.xun-card {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	padding: 1.15rem 1.3rem;
	background-color: var(--xunison-surface);
	background-image: var(--xunison-gradient-surface);
	border: 1px solid var(--xunison-border);
	border-radius: var(--xunison-radius);
	box-shadow: var(--xunison-shadow), inset 0 1px 0 var(--xunison-hairline);
}

.xun-card h3 {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	font-size: 0.82rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--xunison-muted);
}

/* Ownership rail: which side of the ADR 014 boundary a card belongs to */
.xun-card[data-owner="xunison"] {
	border-left: 3px solid var(--xunison-owned);
}

.xun-card[data-owner="cognitum"] {
	border-left: 3px solid var(--xunison-cognitum-owned);
}

.xun-metric {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	font-size: 1.8rem;
	font-weight: 650;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
	color: var(--xunison-foreground);
}

.xun-metric small {
	font-size: 0.85rem;
	font-weight: 400;
	color: var(--xunison-muted);
}

.xun-rows {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
	margin: 0;
}

.xun-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.4rem 0;
	border-bottom: 1px solid var(--xunison-hairline);
}

.xun-row:last-child {
	border-bottom: none;
}

.xun-row dt,
.xun-row .xun-label {
	color: var(--xunison-muted);
	font-size: 0.9rem;
}

.xun-row dd,
.xun-row .xun-value {
	margin: 0;
	color: var(--xunison-foreground);
	font-family: var(--xunison-font-mono);
	font-size: 0.88rem;
	font-variant-numeric: tabular-nums;
	text-align: right;
	overflow-wrap: anywhere;
}

/* Status pills. Shape and text carry the meaning as well as colour, so
 * the state is legible without colour perception. */
.xun-pill {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.15rem 0.6rem;
	border: 1px solid currentColor;
	border-radius: 999px;
	font-size: 0.78rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	white-space: nowrap;
}

.xun-pill::before {
	content: "";
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: currentColor;
}

.xun-pill[data-state="ok"] { color: var(--xunison-ok); }
.xun-pill[data-state="warn"] { color: var(--xunison-warn); }
.xun-pill[data-state="danger"] { color: var(--xunison-danger); }
.xun-pill[data-state="off"] { color: var(--xunison-inactive); }
.xun-pill[data-state="off"]::before { border-radius: 2px; }
.xun-pill[data-state="warn"]::before { border-radius: 2px; transform: rotate(45deg); }

/* Budget meters (integration ADR 010) */
.xun-meter {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
}

.xun-meter-head {
	display: flex;
	justify-content: space-between;
	font-size: 0.85rem;
	color: var(--xunison-muted);
}

.xun-meter-track {
	height: 7px;
	background-color: var(--xunison-surface-raised);
	border: 1px solid var(--xunison-hairline);
	border-radius: 999px;
	overflow: hidden;
}

.xun-meter-fill {
	height: 100%;
	background-image: var(--xunison-gradient-bar);
	border-radius: 999px;
}

.xun-meter-fill[data-state="warn"] { background-image: var(--xunison-gradient-bar-warn); }
.xun-meter-fill[data-state="danger"] { background-image: var(--xunison-gradient-bar-danger); }
.xun-meter-fill[data-state="unknown"] { background-image: none; background-color: var(--xunison-inactive); }

.xun-note {
	margin: 0;
	font-size: 0.85rem;
	color: var(--xunison-muted);
}

.xun-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	font-size: 0.85rem;
	color: var(--xunison-muted);
}

.xun-legend span {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
}

.xun-legend i {
	width: 12px;
	height: 3px;
	border-radius: 2px;
	background: var(--xunison-owned);
}

.xun-legend i[data-owner="cognitum"] {
	background: var(--xunison-cognitum-owned);
}

/* Respect a reduced-motion preference.
 *
 * This deliberately does NOT reset `transform`. It used to, which was wrong:
 * several elements carry a *static* transform that encodes meaning rather
 * than motion — the warn pill's rotated dot marks state without relying on
 * colour, and every group in the sign-in field is positioned by a static
 * transform-origin. Blanking transforms changed the layout instead of just
 * stopping it, so a reduced-motion visitor saw a different page, not a
 * calmer one. Stop the animation; leave the geometry alone. */
@media (prefers-reduced-motion: reduce) {
	.xun-dashboard *,
	.xun-auth-page * {
		transition: none !important;
		animation: none !important;
	}
}

@media (max-width: 600px) {
	.xun-grid {
		grid-template-columns: 1fr;
	}

	.xun-row {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.15rem;
	}

	.xun-row dd,
	.xun-row .xun-value {
		text-align: left;
	}
}

/* Sign-in ------------------------------------------------------------- */

/* The sign-in page is pinned dark; see the token block in brand.css for why.
 * `color-scheme: dark` also keeps form controls and scrollbars dark, which
 * the UA would otherwise render light and break the composition. */
.xun-auth-page {
	color-scheme: dark;
	background: var(--xunison-background);
	background-image: var(--xunison-gradient-page);
	color: var(--xunison-foreground);
}

/* Fixed + own scroll container, so the blurred orbs cannot scroll away from
 * the card on a short viewport. */
.xun-auth-shell {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: grid;
	place-items: center;
	min-height: 100vh;
	padding: clamp(1rem, 4vw, 3rem);
	overflow: auto;
}

.xun-auth-glow {
	position: absolute;
	width: 24rem;
	height: 24rem;
	border-radius: 50%;
	filter: blur(100px);
	opacity: 0.78;
	pointer-events: none;
	animation: xun-auth-glow 11s ease-in-out infinite;
	will-change: transform, opacity;
}

.xun-auth-glow-primary {
	top: 10%;
	left: 12%;
	background: var(--xunison-auth-glow-a);
}

/* The negative delay starts this orb mid-cycle so the two are never in
 * phase; without it they pulse together and read as one light. */
.xun-auth-glow-accent {
	right: 10%;
	bottom: 6%;
	background: var(--xunison-auth-glow-b);
	animation-duration: 13s;
	animation-delay: -5s;
}

/* Form column has a 340px floor; the visual column has a 0 floor so it is
 * squeezed rather than forcing the layout to overflow. */
.xun-auth-layout {
	position: relative;
	z-index: 1;
	display: grid;
	grid-template-columns: minmax(340px, 0.9fr) minmax(0, 1.5fr);
	width: min(1040px, 100%);
	min-height: 620px;
	overflow: hidden;
	border: 1px solid var(--xunison-border);
	border-radius: 20px;
	background: var(--xunison-auth-surface);
	box-shadow: var(--xunison-auth-shadow);
}

.xun-auth-card {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 1.25rem;
	padding: clamp(2rem, 5vw, 3.75rem);
	border-right: 1px solid var(--xunison-border);
	background-image: var(--xunison-gradient-surface);
	backdrop-filter: blur(16px);
}

.xun-auth-kicker {
	margin: 0 0 0.4rem;
	color: var(--xunison-auth-muted);
	font-size: 0.72rem;
	font-weight: 760;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.xun-auth-brand {
	display: flex;
	align-items: center;
	gap: 0.6rem;
}

/* The supplied lockup is a 1163x182 (6.39:1) wordmark in white with the
 * coral mark, so it always sits on a dark plate regardless of scheme and
 * the plate is sized to the artwork's own ratio rather than cropping it. */
.xun-logo {
	display: block;
	box-sizing: border-box;
	width: 208px;
	height: 44px;
	padding: 9px 13px;
	border-radius: 8px;
	background-color: var(--xunison-logo-plate);
	background-image: var(--xunison-logo);
	background-repeat: no-repeat;
	background-position: left center;
	background-size: contain;
	background-origin: content-box;
}

.xun-logo-sm {
	width: 156px;
	height: 34px;
	padding: 7px 10px;
}

.xun-auth-heading h1 {
	margin: 0;
	font-size: 1.5rem;
}

.xun-auth-heading p {
	margin: 0.25rem 0 0;
	color: var(--xunison-muted);
	font-family: var(--xunison-font-mono);
	font-size: 0.9rem;
}

.xun-auth-error {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	padding: 0.7rem 0.9rem;
	border: 1px solid var(--xunison-danger);
	border-radius: 8px;
	color: var(--xunison-danger);
	font-size: 0.9rem;
}

.xun-auth-form {
	display: flex;
	flex-direction: column;
	gap: 0.9rem;
	margin: 0;
}

.xun-auth-field {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	font-size: 0.9rem;
	color: var(--xunison-muted);
}

.xun-auth-field input {
	padding: 0.62rem 0.8rem;
	background-color: var(--xunison-surface-raised);
	border: 1px solid var(--xunison-border);
	border-radius: var(--xunison-radius-sm);
	color: var(--xunison-foreground);
	font: inherit;
	transition: border-color 120ms ease;
}

.xun-auth-field input:hover {
	border-color: var(--xunison-border-strong);
}

.xun-auth-field input:focus-visible,
.xun-auth-submit:focus-visible {
	outline: 2px solid var(--xunison-primary);
	outline-offset: 2px;
}

.xun-auth-submit {
	padding: 0.7rem 1rem;
	background-color: var(--xunison-primary);
	background-image: var(--xunison-gradient-brand);
	border: 1px solid var(--xunison-primary-strong);
	border-radius: var(--xunison-radius-sm);
	color: var(--xunison-primary-contrast);
	font: inherit;
	font-weight: 650;
	cursor: pointer;
	transition: filter 120ms ease;
}

.xun-auth-submit:hover {
	filter: brightness(1.04);
}

.xun-auth-local {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.45rem;
	margin: 0;
	color: var(--xunison-muted);
	font-size: 0.82rem;
	text-align: center;
}

.xun-auth-local span {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--xunison-ok);
}

/* Sign-in visual panel ------------------------------------------------
 *
 * Decorative. The SVG is bled 8% past the panel and clipped by the
 * layout's overflow, so the outer rings run off the edge instead of
 * terminating inside it. */

.xun-auth-visual {
	position: relative;
	display: flex;
	align-items: flex-end;
	padding: clamp(2rem, 5vw, 4rem);
	overflow: hidden;
	background: var(--xunison-auth-panel);
}

.xun-auth-visual::before,
.xun-auth-visual::after {
	content: "";
	position: absolute;
	z-index: 0;
	width: 26rem;
	height: 26rem;
	border-radius: 50%;
	filter: blur(90px);
	animation: xun-auth-panel-glow 12s ease-in-out infinite;
	will-change: transform, opacity;
}

.xun-auth-visual::before {
	top: -6rem;
	right: -4rem;
	background: var(--xunison-viz-panel-a);
}

.xun-auth-visual::after {
	bottom: -8rem;
	left: -6rem;
	background: var(--xunison-viz-panel-b);
	animation-delay: -6s;
}

.xun-auth-visual svg {
	position: absolute;
	z-index: 1;
	inset: -8%;
	width: 116%;
	height: 116%;
	opacity: 0.82;
	pointer-events: none;
}

/* Load-bearing: without transform-box/transform-origin each group rotates
 * about its own bounding box and the composition tears apart. */
.xun-hyper-field,
.xun-hyper-geodesics,
.xun-hyper-ring,
.xun-hyper-particles,
.xun-hyper-core {
	transform-origin: 360px 360px;
	transform-box: view-box;
	will-change: transform, opacity;
}

/* Presentation attributes do not resolve var(), so the gradient stops and
 * the pattern fill are set here instead of in the markup. */
#xun-hyper-points circle { fill: var(--xunison-viz-a); }

#xun-hyper-field-fade stop:nth-child(1) { stop-color: var(--xunison-viz-a); stop-opacity: 0.7; }
#xun-hyper-field-fade stop:nth-child(2) { stop-color: var(--xunison-viz-a); stop-opacity: 0.3; }
#xun-hyper-field-fade stop:nth-child(3) { stop-color: var(--xunison-viz-a); stop-opacity: 0; }

.xun-hyper-field {
	opacity: 0.66;
	animation: xun-hyper-spin 72s linear infinite;
}

.xun-hyper-geodesics {
	stroke: var(--xunison-viz-geodesic);
	stroke-width: 1.5;
	animation: xun-hyper-spin 46s linear infinite reverse;
}

.xun-hyper-ring {
	stroke-width: 3;
	stroke-linecap: round;
}

/* Dash gap widens and duration lengthens outward while opacity falls —
 * together that is the depth cue. Alternating forward/reverse is what makes
 * the shells read as counter-rotating. Keep these numbers in step. */
.xun-hyper-ring-one {
	stroke: var(--xunison-viz-ring-1);
	stroke-dasharray: 2 11;
	animation: xun-hyper-breathe-forward 18s linear infinite;
}

.xun-hyper-ring-two {
	stroke: var(--xunison-viz-ring-2);
	stroke-dasharray: 2 14;
	animation: xun-hyper-breathe-reverse 26s linear infinite;
}

.xun-hyper-ring-three {
	stroke: var(--xunison-viz-ring-3);
	stroke-dasharray: 2 17;
	animation: xun-hyper-breathe-forward 34s linear infinite;
}

.xun-hyper-ring-four {
	stroke: var(--xunison-viz-ring-4);
	stroke-dasharray: 2 20;
	animation: xun-hyper-breathe-reverse 44s linear infinite;
}

.xun-hyper-particles {
	animation: xun-hyper-orbit 32s linear infinite;
}

.xun-hyper-particles-inner {
	opacity: 0.86;
	animation-duration: 23s;
	animation-direction: reverse;
}

.xun-hyper-particles .a { fill: var(--xunison-viz-a); filter: drop-shadow(0 0 7px var(--xunison-viz-glow-a)); }
.xun-hyper-particles .b { fill: var(--xunison-viz-b); filter: drop-shadow(0 0 7px var(--xunison-viz-glow-b)); }
.xun-hyper-particles .c { fill: var(--xunison-viz-c); filter: drop-shadow(0 0 7px var(--xunison-viz-glow-c)); }

.xun-hyper-core {
	animation: xun-hyper-core 4.8s ease-in-out infinite;
}

.xun-hyper-core circle:first-child {
	fill: var(--xunison-viz-core-fill);
	stroke: var(--xunison-viz-core-stroke);
	stroke-width: 2;
}

.xun-hyper-core circle:last-child {
	fill: var(--xunison-viz-a);
	stroke: var(--xunison-viz-core-ring);
	stroke-width: 3;
	filter: drop-shadow(0 0 16px var(--xunison-viz-core-glow));
}

.xun-auth-visual-copy {
	position: relative;
	z-index: 2;
	max-width: 30rem;
	color: var(--xunison-auth-foreground);
}

.xun-auth-visual-copy h2 {
	/* The imported Cognitum cascade sets a colour on `h1, h2, h3, h4`, i.e. on
	 * the element itself, so a colour on the ancestor never inherits down to
	 * this heading. It has to be set here, where the descendant selector also
	 * out-specifies that element rule. */
	color: var(--xunison-auth-foreground);
	margin: 0 0 0.75rem;
	font-size: clamp(1.8rem, 4vw, 2.65rem);
	line-height: 1.12;
	letter-spacing: -0.02em;
}

.xun-auth-visual-copy > p:last-of-type {
	margin: 0 0 1.25rem;
	color: var(--xunison-auth-muted);
	font-size: 0.92rem;
	line-height: 1.6;
}

.xun-auth-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.xun-auth-pills span {
	padding: 0.42rem 0.7rem;
	border: 1px solid var(--xunison-border);
	border-radius: 999px;
	background: var(--xunison-auth-well);
	font-size: 0.72rem;
	font-weight: 650;
}

/* Sign-in animations. None of these touch colour. `linear` on the breathe
 * and orbit keyframes is intentional — the ease comes from the scale and
 * opacity envelope, and an ease-in-out here makes the rotation stutter at
 * the midpoint. */

@keyframes xun-auth-glow {
	0%, 100% { transform: translate3d(0, 0, 0) scale(0.9); opacity: 0.5; }
	50% { transform: translate3d(2rem, -1.25rem, 0) scale(1.12); opacity: 0.9; }
}

@keyframes xun-auth-panel-glow {
	0%, 100% { transform: translate3d(0, 0, 0) scale(0.86); opacity: 0.28; }
	50% { transform: translate3d(-1.5rem, 1rem, 0) scale(1.16); opacity: 0.56; }
}

@keyframes xun-hyper-spin {
	to { transform: rotate(360deg); }
}

@keyframes xun-hyper-breathe-forward {
	0%, 100% { transform: rotate(0deg) scale(0.96); opacity: 0.62; }
	50% { transform: rotate(180deg) scale(1.05); opacity: 1; }
}

/* Starts at 360deg and travels to 180deg, so it counter-rotates without
 * needing animation-direction. That is why rings two and four appear to
 * turn against one and three. */
@keyframes xun-hyper-breathe-reverse {
	0%, 100% { transform: rotate(360deg) scale(1.04); opacity: 0.58; }
	50% { transform: rotate(180deg) scale(0.96); opacity: 0.94; }
}

@keyframes xun-hyper-orbit {
	0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.7; }
	50% { transform: rotate(180deg) scale(0.94); opacity: 1; }
}

@keyframes xun-hyper-core {
	0%, 100% { transform: scale(0.82); opacity: 0.72; }
	50% { transform: scale(1.14); opacity: 1; }
}

/* Below 860px the visual is removed rather than stacked: it is decorative
 * and aria-hidden, so dropping it costs nothing and spares a phone the
 * blur and twenty animated nodes. */
@media (max-width: 860px) {
	.xun-auth-glow { display: none; }

	.xun-auth-layout {
		grid-template-columns: minmax(0, 1fr);
		width: min(470px, 100%);
		min-height: 0;
	}

	.xun-auth-card {
		min-height: 620px;
		border-right: 0;
	}

	.xun-auth-visual { display: none; }
}

@media (max-width: 520px) {
	.xun-auth-shell { padding: 0; }

	.xun-auth-layout {
		min-height: 100vh;
		border: 0;
		border-radius: 0;
	}

	.xun-auth-card {
		min-height: 100vh;
		padding: 2rem 1.35rem;
	}
}

/* Stat strip and catalog table (Cogs view) ---------------------------- */

.xun-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 1rem;
}

.xun-stat {
	padding: 1rem 1.15rem;
	background-color: var(--xunison-surface);
	background-image: var(--xunison-gradient-surface);
	border: 1px solid var(--xunison-border);
	border-left: 3px solid var(--xunison-primary);
	border-radius: var(--xunison-radius);
	box-shadow: var(--xunison-shadow), inset 0 1px 0 var(--xunison-hairline);
}

.xun-stat-label {
	margin-top: 0.15rem;
	font-size: 0.8rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--xunison-muted);
}

/* Wide tables scroll inside their own container so the page body never
 * scrolls horizontally on a narrow screen. */
.xun-table-scroll {
	overflow-x: auto;
}

.xun-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.92rem;
}

.xun-table th {
	padding: 0.5rem 0.75rem 0.5rem 0;
	border-bottom: 1px solid var(--xunison-border);
	color: var(--xunison-muted);
	font-size: 0.78rem;
	font-weight: 600;
	letter-spacing: 0.07em;
	text-transform: uppercase;
	text-align: left;
	white-space: nowrap;
}

.xun-table td {
	padding: 0.6rem 0.75rem 0.6rem 0;
	border-bottom: 1px solid var(--xunison-hairline);
	color: var(--xunison-foreground);
	vertical-align: middle;
}

.xun-table tr:last-child td {
	border-bottom: none;
}

/* Deployed rows carry a brand rail so the operator can separate what is
 * on this device from what merely exists in the catalog. */
.xun-table tr.xun-row-deployed td:first-child {
	box-shadow: inset 3px 0 0 var(--xunison-primary);
	padding-left: 0.75rem;
}

.xun-sub {
	color: var(--xunison-muted);
	font-size: 0.8rem;
}

.xun-mono {
	font-family: var(--xunison-font-mono);
	color: var(--xunison-muted);
}

/* Setup wizard ------------------------------------------------------- */

.xun-stepper {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.xun-step {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.4rem 0.9rem 0.4rem 0.5rem;
	border: 1px solid var(--xunison-border);
	border-radius: 999px;
	color: var(--xunison-muted);
	font-size: 0.88rem;
}

.xun-step-index {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--xunison-surface-raised);
	font-size: 0.78rem;
	font-weight: 600;
}

.xun-step[data-state="current"] {
	border-color: var(--xunison-primary);
	color: var(--xunison-foreground);
}

.xun-step[data-state="current"] .xun-step-index {
	background-image: var(--xunison-gradient-brand);
	color: var(--xunison-primary-contrast);
}

.xun-step[data-state="done"] {
	color: var(--xunison-foreground);
}

.xun-step[data-state="done"] .xun-step-index {
	background: var(--xunison-ok);
	color: var(--xunison-primary-contrast);
}

.xun-check {
	padding: 0.55rem 0;
	border-bottom: 1px solid var(--xunison-border);
}

.xun-check:last-child {
	border-bottom: none;
}

.xun-check-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
}

.xun-check .xun-note {
	margin-top: 0.25rem;
}

.xun-choices {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
	gap: 0.75rem;
}

.xun-choice {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	padding: 1rem 1.1rem;
	background-color: var(--xunison-surface-raised);
	background-image: var(--xunison-gradient-raised);
	border: 1px solid var(--xunison-border);
	border-radius: var(--xunison-radius);
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.xun-choice:hover {
	border-color: var(--xunison-border-strong);
	transform: translateY(-1px);
}

.xun-choice[data-selected="true"] {
	border-color: var(--xunison-primary);
	box-shadow: inset 3px 0 0 var(--xunison-primary), var(--xunison-shadow);
}

.xun-choice-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
}

.xun-wizard-nav {
	display: flex;
	justify-content: flex-end;
	gap: 0.6rem;
}

.xun-btn {
	padding: 0.58rem 1.15rem;
	background-color: var(--xunison-surface-raised);
	background-image: var(--xunison-gradient-raised);
	border: 1px solid var(--xunison-border);
	border-radius: var(--xunison-radius-sm);
	color: var(--xunison-foreground);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: border-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.xun-btn:not([disabled]):hover {
	border-color: var(--xunison-border-strong);
	box-shadow: var(--xunison-shadow);
}

.xun-btn[disabled] {
	opacity: 0.45;
	cursor: not-allowed;
}

.xun-btn-primary {
	background-color: var(--xunison-primary);
	background-image: var(--xunison-gradient-brand);
	border-color: var(--xunison-primary-strong);
	color: var(--xunison-primary-contrast);
	box-shadow: var(--xunison-shadow), inset 0 1px 0 var(--xunison-hairline);
}

.xun-btn-primary:not([disabled]):hover {
	filter: brightness(1.04);
}

.xun-btn:focus-visible,
.xun-choice:focus-visible,
.xun-link:focus-visible {
	outline: 2px solid var(--xunison-primary);
	outline-offset: 2px;
}

.xun-link {
	color: var(--xunison-primary);
	font-weight: 600;
	text-decoration: none;
}

.xun-link:hover {
	text-decoration: underline;
}

/* Live-demo link in the Cog estate table. Only rendered where a demo
 * exists; cogs without one show a dash, so the column never implies a
 * destination that would 404. */
.xun-demo-link {
	color: var(--xunison-primary);
	font-weight: 650;
	text-decoration: none;
}

.xun-demo-link:hover,
.xun-demo-link:focus-visible {
	text-decoration: underline;
}

/* --- Per-cog detail modal (Cognitum Store) --------------------------------
 *
 * The store rendered 136 catalog entries as one card each with no way to see
 * further, so fields the registry already transports — configuration option
 * counts, difficulty, CSI packet types, hardware requirements — were carried
 * to the browser and then dropped. These rules dress the detail surface that
 * finally shows them.
 *
 * Base modal chrome (#modal_overlay, .modal, .button-row) is inherited from
 * the Cognitum stylesheet imported at the top of this file; only the
 * detail-specific layout lives here. */

.cognitum-catalog-card-openable {
	cursor: pointer;
	transition: border-color 120ms ease, box-shadow 120ms ease;
}

.cognitum-catalog-card-openable:hover {
	border-color: var(--xunison-border-strong);
	box-shadow: var(--xunison-shadow-raised);
}

/* The card title is a real button so the surface is keyboard reachable and
 * announced as actionable, but it has to keep looking like the heading it
 * sits inside. */
.cognitum-catalog-open {
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.cognitum-catalog-open:hover {
	color: var(--xunison-primary);
}

.cognitum-catalog-open:focus-visible,
.cognitum-catalog-card-openable:focus-within {
	outline: 2px solid var(--xunison-primary);
	outline-offset: 2px;
}

.cognitum-detail-description {
	margin: 0 0 1rem;
	color: var(--xunison-foreground);
}

/* A description list, not a table: every row is one label and one value, and
 * the pairing has to survive the single-column reflow below. */
.cognitum-detail-grid {
	display: grid;
	gap: 0.1rem;
	margin: 0;
	border-top: 1px solid var(--xunison-hairline);
}

.cognitum-detail-row {
	display: grid;
	grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr);
	gap: 0.75rem;
	padding: 0.55rem 0;
	border-bottom: 1px solid var(--xunison-hairline);
}

.cognitum-detail-row > dt {
	margin: 0;
	color: var(--xunison-muted);
	font-size: 0.78rem;
	font-weight: 650;
	letter-spacing: 0.01em;
}

.cognitum-detail-row > dd {
	margin: 0;
	min-width: 0;
	color: var(--xunison-foreground);
	font-size: 0.85rem;
	overflow-wrap: anywhere;
}

.cognitum-detail-inline {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
}

.cognitum-detail-row .cognitum-target-fit {
	display: inline-block;
	color: var(--xunison-muted);
}

/* The pill list in the card carries a 1.5rem top margin that would push each
 * value off its own row here. */
.cognitum-detail-row .cognitum-auth-pills {
	margin-top: 0;
	gap: 0.4rem;
}

/* An absent field reads differently from an empty one, so it is stated
 * rather than left blank. */
.cognitum-detail-absent {
	color: var(--xunison-muted);
	font-style: italic;
}

.cognitum-detail-demo {
	margin-top: 1rem;
	padding: 0.8rem 0.9rem;
	border: 1px solid var(--xunison-border);
	border-left: 3px solid var(--xunison-warn);
	border-radius: var(--xunison-radius-sm);
	background: var(--xunison-surface-raised);
}

.cognitum-detail-demo > h5 {
	margin: 0 0 0.35rem;
	font-size: 0.82rem;
}

.cognitum-detail-demo > p {
	margin: 0 0 0.6rem;
}

.cognitum-detail-demo-link {
	color: var(--xunison-primary);
	font-size: 0.78rem;
	overflow-wrap: anywhere;
	text-decoration: none;
}

.cognitum-detail-demo-link:hover,
.cognitum-detail-demo-link:focus-visible {
	text-decoration: underline;
}

.cognitum-detail-modal .button-row {
	display: flex;
	justify-content: flex-end;
}

@media (max-width: 620px) {
	.cognitum-detail-row {
		grid-template-columns: minmax(0, 1fr);
		gap: 0.25rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cognitum-catalog-card-openable {
		transition: none !important;
	}
}

/* Cog estate table: header contrast, controls, and the stacked layout ---
 *
 * Everything below was appended to fix three measured defects on the Cog
 * estate view. It reads only brand.css tokens, like the rest of this file.
 */

/* 1. The header row was illegible on a light desktop.
 *
 * The inherited Cognitum stylesheet styles every `th` with a hardcoded
 * dark plate rather than a token, and re-pointing --cognitum-* cannot
 * reach it — that is the known limitation noted at the top of this file.
 * In the dark scheme the accident is harmless; in the light scheme the
 * plate stayed dark while --xunison-muted became dark text on it, which
 * measured 1.12:1. Owning both halves of the pair here fixes it in one
 * place and raises the dark scheme too: 14.6:1 light, 12.6:1 dark. */
.xun-table thead th {
	background-color: var(--xunison-surface-raised);
	background-image: var(--xunison-gradient-raised);
	color: var(--xunison-foreground);
	border-bottom: 1px solid var(--xunison-border-strong);
}

/* The header cannot be a sort control — the dashboard contract forbids a
 * click handler in a read-only status view — so it reports the sort the
 * select applied. The arrow hangs off the same `aria-sort` a screen reader
 * announces, so the two cannot drift apart. */
.xun-table thead th[aria-sort="ascending"],
.xun-table thead th[aria-sort="descending"] {
	color: var(--xunison-primary);
}

.xun-table thead th[aria-sort="ascending"]::after {
	content: " \2191";
}

.xun-table thead th[aria-sort="descending"]::after {
	content: " \2193";
}

/* 2. Filter, sort, and paging controls, so 111 rows are reachable without
 * scrolling all of them. */
.xun-table-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem 0.9rem;
	align-items: flex-end;
}

.xun-control {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	min-width: 0;
}

.xun-control-wide {
	flex: 1 1 18rem;
}

.xun-control-label {
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.07em;
	text-transform: uppercase;
	color: var(--xunison-muted);
}

.xun-table-controls input,
.xun-table-controls select {
	min-width: 0;
	padding: 0.45rem 0.6rem;
	background-color: var(--xunison-surface-raised);
	background-image: var(--xunison-gradient-raised);
	border: 1px solid var(--xunison-border);
	border-radius: var(--xunison-radius-sm);
	color: var(--xunison-foreground);
	font: inherit;
	font-size: 0.9rem;
}

.xun-table-controls input:hover,
.xun-table-controls select:hover {
	border-color: var(--xunison-border-strong);
}

.xun-table-controls input:focus-visible,
.xun-table-controls select:focus-visible {
	outline: 2px solid var(--xunison-primary);
	outline-offset: 1px;
}

.xun-table-status {
	margin: 0;
	color: var(--xunison-muted);
	font-size: 0.82rem;
}

.xun-table-empty {
	padding: 0.9rem 0;
	color: var(--xunison-muted);
}

/* 3. The stacked layout below 800px.
 *
 * The inherited theme turns every table into a column of blocks at that
 * width and hides the header row with it, which left each cell showing a
 * bare value — a lone "1.0.0", a lone dash — with nothing naming the
 * column. The view puts the column name on each cell as `data-label`; this
 * prints it. No script is involved, so it cannot fall out of step with a
 * re-sort or a filter.
 *
 * `data-label` rather than the base theme's `data-title` on purpose:
 * `data-title` already carries that theme's own ::before/::after treatment
 * and a percentage indent, and overriding it would fight rules this file
 * does not own. */
@media only screen and (max-width: 800px) {
	.xun-table-scroll {
		overflow-x: visible;
	}

	.xun-table,
	.xun-table tbody,
	.xun-table tr,
	.xun-table td {
		display: block;
	}

	.xun-table thead {
		display: none;
	}

	/* Each row becomes a card, so the eye can tell where one Cog ends. */
	.xun-table tr {
		margin: 0 0 0.6rem;
		padding: 0.5rem 0.7rem;
		background-color: var(--xunison-surface-raised);
		background-image: var(--xunison-gradient-raised);
		border: 1px solid var(--xunison-border);
		border-radius: var(--xunison-radius-sm);
	}

	.xun-table td {
		padding: 0.3rem 0;
	}

	.xun-table td[data-label] {
		display: flex;
		flex-wrap: wrap;
		align-items: baseline;
		gap: 0.25rem 0.6rem;
	}

	.xun-table td[data-label]::before {
		content: attr(data-label);
		flex: 0 0 7.5em;
		color: var(--xunison-muted);
		font-size: 0.7rem;
		font-weight: 600;
		letter-spacing: 0.07em;
		text-transform: uppercase;
	}

	/* Separators between the stacked cells. Specific enough to beat the
	 * `.xun-table tr:last-child td` rule above, which would otherwise strip
	 * them from the last card. */
	.xun-table tr td:not(:last-child) {
		border-bottom: 1px solid var(--xunison-hairline);
	}

	.xun-table tr td:last-child {
		border-bottom: none;
	}

	/* The deployed rail moves from the first cell to the whole card, since
	 * the cells no longer sit side by side. */
	.xun-table tr.xun-row-deployed {
		box-shadow: inset 3px 0 0 var(--xunison-primary);
	}

	.xun-table tr.xun-row-deployed td:first-child {
		box-shadow: none;
		padding-left: 0;
	}

	.xun-control,
	.xun-control-wide {
		flex: 1 1 100%;
	}
}
