/* ==========================================================================
   xCode — XIO code environment
   XIO palette (black / white / grey, mono, square corners, no gradients in
   the chrome) plus ONE accent, XIO cyan, for whatever is live: the selected
   node, the focused field, the running preview. Red is for errors.
   ========================================================================== */

:root {
	--bg: #000;
	--ink: #f2f2f2;
	--dim: #8a8a8a;
	--faint: #4a4a4a;
	--rule: #1e1e1e;
	--rule-hi: #333;
	--panel: #070707;
	--panel-2: #0d0d0d;
	--hl: #29e6ff;
	--hl-dim: rgba(41, 230, 255, 0.5);
	--hl-soft: rgba(41, 230, 255, 0.12);
	--err: #ff2d2d;
	--err-soft: rgba(255, 45, 45, 0.14);

	/* syntax: greys plus a pale tint of the accent for strings */
	--s-kw: #f2f2f2;
	--s-str: #9fe6ef;
	--s-num: #d6d6d6;
	--s-com: #5c5c5c;
	--s-fn: #ffffff;
	--s-prop: #b4b4b4;
	--s-id: #c9c9c9;
	--s-punc: #7a7a7a;

	--mono: "SFMono-Regular", "SF Mono", "JetBrains Mono", "Fira Code", "IBM Plex Mono", Consolas, "Liberation Mono", Menlo, monospace;
	--sat: env(safe-area-inset-top, 0px);
	--sab: env(safe-area-inset-bottom, 0px);
	--top-h: 52px;
	--tabs-h: 56px;
	--run-w: 42vw;
	--ed-size: 14px;
	--ease: cubic-bezier(0.2, 0.8, 0.2, 1);
	color-scheme: dark;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

[hidden] {
	display: none !important;
}

html,
body {
	height: 100%;
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: var(--mono);
	font-size: 14px;
	letter-spacing: 0.01em;
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
	overflow: hidden;
	overscroll-behavior: none;
}

button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
	touch-action: manipulation;
}

input,
textarea,
select {
	font: inherit;
	color: inherit;
}

::selection {
	background: var(--ink);
	color: var(--bg);
}

svg.ic {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: square;
	stroke-linejoin: miter;
	flex: none;
}

.scan {
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 300;
	background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 3px);
	mix-blend-mode: overlay;
}

@media (prefers-reduced-motion: reduce) {
	.scan {
		display: none;
	}

	*,
	*::before,
	*::after {
		transition-duration: 0ms !important;
		animation-duration: 0ms !important;
	}
}

/* HUD corner brackets */
.brk {
	position: relative;
}

.brk::after {
	content: "";
	position: absolute;
	inset: var(--brk-inset, -5px);
	pointer-events: none;
	--c: var(--brk, var(--hl));
	--l: var(--brk-len, 9px);
	background:
		linear-gradient(var(--c), var(--c)) left top / var(--l) 1.5px no-repeat,
		linear-gradient(var(--c), var(--c)) left top / 1.5px var(--l) no-repeat,
		linear-gradient(var(--c), var(--c)) right top / var(--l) 1.5px no-repeat,
		linear-gradient(var(--c), var(--c)) right top / 1.5px var(--l) no-repeat,
		linear-gradient(var(--c), var(--c)) left bottom / var(--l) 1.5px no-repeat,
		linear-gradient(var(--c), var(--c)) left bottom / 1.5px var(--l) no-repeat,
		linear-gradient(var(--c), var(--c)) right bottom / var(--l) 1.5px no-repeat,
		linear-gradient(var(--c), var(--c)) right bottom / 1.5px var(--l) no-repeat;
}

/* small uppercase readouts */
.cap {
	font-size: 10.5px;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--dim);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 40px;
	padding: 0 14px;
	border: 1px solid var(--rule-hi);
	font-size: 11px;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--ink);
	white-space: nowrap;
	transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.btn:hover {
	border-color: var(--ink);
}

.btn:active,
.btn.on {
	background: var(--ink);
	color: var(--bg);
	border-color: var(--ink);
}

.btn.primary {
	border-color: var(--hl);
	color: var(--hl);
}

.btn.primary:hover,
.btn.primary:active {
	background: var(--hl);
	color: var(--bg);
}

.btn.danger {
	border-color: rgba(255, 45, 45, 0.5);
	color: var(--err);
}

.btn.danger:hover,
.btn.danger:active {
	background: var(--err);
	color: var(--bg);
	border-color: var(--err);
}

.btn.ghost {
	border-color: transparent;
	color: var(--dim);
}

.btn.ghost:hover {
	color: var(--ink);
	border-color: var(--rule-hi);
}

.btn.sm {
	min-height: 32px;
	padding: 0 10px;
	font-size: 10px;
}

.btn:disabled {
	opacity: 0.35;
	pointer-events: none;
}

.icb {
	display: inline-grid;
	place-items: center;
	width: 44px;
	height: 44px;
	color: var(--dim);
	transition: color 160ms ease;
}

.icb:hover {
	color: var(--ink);
}

.icb:disabled {
	opacity: 0.3;
	pointer-events: none;
}

/* ==========================================================================
   Top bar
   ========================================================================== */

.top {
	position: fixed;
	z-index: 60;
	top: 0;
	left: 0;
	right: 0;
	height: calc(var(--top-h) + var(--sat));
	padding: var(--sat) max(4px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
	display: flex;
	align-items: center;
	gap: 2px;
	background: rgba(0, 0, 0, 0.92);
	border-bottom: 1px solid var(--rule);
}

.logo {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	height: 44px;
	padding: 0 8px 0 2px;
	font-weight: 700;
	letter-spacing: 0.3em;
	font-size: 12px;
}

.logo svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: var(--ink);
	stroke-width: 12;
	transition: transform 600ms var(--ease);
}

.logo:hover svg {
	transform: rotate(180deg);
}

.logo b span {
	color: var(--hl);
}

.proj {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	height: 44px;
	padding: 0 10px;
	border-left: 1px solid var(--rule);
	color: var(--dim);
	font-size: 12px;
	letter-spacing: 0.04em;
}

.proj span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 28vw;
}

.proj:hover {
	color: var(--ink);
}

.proj i {
	width: 5px;
	height: 5px;
	flex: none;
	background: var(--faint);
	transition: background 300ms ease;
}

.proj i.dirty {
	background: var(--hl);
}

.views {
	display: none;
	margin-left: 8px;
	border: 1px solid var(--rule-hi);
}

.views button {
	height: 32px;
	padding: 0 14px;
	font-size: 10.5px;
	letter-spacing: 0.22em;
	color: var(--dim);
}

.views button + button {
	border-left: 1px solid var(--rule-hi);
}

.views button[aria-selected="true"] {
	color: var(--bg);
	background: var(--ink);
}

.sp {
	flex: 1;
}

.run-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 34px;
	margin: 0 4px;
	padding: 0 12px;
	border: 1px solid var(--hl);
	color: var(--hl);
	font-size: 11px;
	letter-spacing: 0.2em;
}

.run-btn svg {
	width: 14px;
	height: 14px;
	fill: currentColor;
	stroke: none;
}

.run-btn:hover,
.run-btn.on {
	background: var(--hl);
	color: var(--bg);
}

.run-btn .lbl {
	display: none;
}

/* ==========================================================================
   Stage and views
   ========================================================================== */

.stage {
	position: fixed;
	left: 0;
	right: 0;
	top: calc(var(--top-h) + var(--sat));
	bottom: calc(var(--tabs-h) + var(--sab));
	display: grid;
	grid-template-columns: 1fr;
	grid-template-rows: 1fr;
}

body.typing .stage {
	bottom: var(--kb-h, 0px);
}

.view {
	grid-area: 1 / 1;
	position: relative;
	min-width: 0;
	min-height: 0;
	overflow: hidden;
	display: none;
}

.view.on {
	display: block;
}

.split {
	display: none;
}

/* bottom tabs (phone) */
.tabs {
	position: fixed;
	z-index: 60;
	left: 0;
	right: 0;
	bottom: 0;
	height: calc(var(--tabs-h) + var(--sab));
	padding-bottom: var(--sab);
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	background: #000;
	border-top: 1px solid var(--rule);
}

body.typing .tabs {
	display: none;
}

.tabs button {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	font-size: 9.5px;
	letter-spacing: 0.24em;
	color: var(--dim);
}

.tabs button[aria-selected="true"] {
	color: var(--ink);
}

.tabs button[aria-selected="true"]::before {
	content: "";
	position: absolute;
	top: -1px;
	left: 28%;
	right: 28%;
	height: 2px;
	background: var(--hl);
}

.tabs button.err-dot::after {
	content: "";
	position: absolute;
	top: 10px;
	right: calc(50% - 18px);
	width: 6px;
	height: 6px;
	background: var(--err);
}

/* ---------- desktop ---------- */
@media (min-width: 900px) {
	:root {
		--tabs-h: 0px;
	}

	.tabs {
		display: none;
	}

	.views {
		display: flex;
	}

	.run-btn .lbl {
		display: inline;
	}

	.proj span {
		max-width: 22vw;
	}

	body.run-open .stage {
		grid-template-columns: minmax(0, 1fr) 6px var(--run-w);
	}

	body.run-open .split {
		display: block;
		grid-area: 1 / 2;
		cursor: col-resize;
		background: var(--rule);
		touch-action: none;
	}

	body.run-open .split:hover,
	body.run-open .split.drag {
		background: var(--hl-dim);
	}

	body.run-open .view.run {
		display: flex;
		grid-area: 1 / 3;
	}
}

/* ==========================================================================
   Map
   ========================================================================== */

.map-vp {
	position: absolute;
	inset: 0;
	overflow: hidden;
	touch-action: none;
	cursor: grab;
	background-color: #000;
	background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1.2px);
	background-size: 24px 24px;
}

.map-vp.panning {
	cursor: grabbing;
}

.map-world {
	position: absolute;
	left: 0;
	top: 0;
	transform-origin: 0 0;
	will-change: transform;
}

.map-edges {
	position: absolute;
	left: 0;
	top: 0;
	overflow: visible;
	pointer-events: none;
}

.map-edges .tree {
	fill: none;
	stroke: var(--rule-hi);
	stroke-width: 1.5;
}

.map-edges .tree.hot {
	stroke: var(--dim);
}

.map-edges .dep {
	fill: none;
	stroke: var(--hl);
	stroke-width: 1.2;
	stroke-dasharray: 4 4;
	opacity: 0.35;
}

.map-edges .dep.hot {
	opacity: 0.95;
	stroke-width: 1.5;
}

.map-edges .dep.used {
	stroke: var(--ink);
}

.map-edges text {
	fill: var(--hl);
	font: 10px var(--mono);
	letter-spacing: 0.06em;
}

.map-edges text.used {
	fill: var(--ink);
}

.mn {
	position: absolute;
	left: 0;
	top: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 3px;
	padding: 8px 12px 8px 12px;
	background: var(--panel);
	border: 1px solid var(--rule-hi);
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
	transition: border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.mn:hover {
	border-color: var(--dim);
}

.mn.k-step {
	background: #000;
	border-color: var(--dim);
	border-width: 1px 1px 1px 3px;
}

.mn.scope {
	border-color: var(--ink);
	border-width: 2px;
	background: var(--panel-2);
}

.mn.sel {
	border-color: var(--hl);
	background: #001114;
	--brk-inset: -6px;
}

.mn.drop {
	border-color: var(--hl);
	background: var(--hl-soft);
	border-style: dashed;
}

.mn.dragging {
	opacity: 0.35;
}

.mn.has-err {
	border-color: var(--err);
}

.mn.has-err .mn-k::after {
	content: " ✕";
	color: var(--err);
}

.mn-k {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 9.5px;
	letter-spacing: 0.22em;
	color: var(--dim);
	white-space: nowrap;
}

.mn-k b {
	color: var(--faint);
	font-weight: 400;
	margin-left: auto;
	letter-spacing: 0.05em;
}

.mn-t {
	font-size: 13px;
	font-weight: 700;
	line-height: 1.25;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mn.scope .mn-t {
	font-size: 15px;
}

.mn-n {
	font-size: 11px;
	line-height: 1.3;
	color: var(--dim);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mn-n.code {
	color: var(--faint);
}

.mn-fold {
	position: absolute;
	top: 50%;
	width: 22px;
	height: 22px;
	margin-top: -11px;
	display: grid;
	place-items: center;
	background: #000;
	border: 1px solid var(--rule-hi);
	font-size: 10px;
	color: var(--dim);
}

.mn-fold:hover {
	color: var(--ink);
	border-color: var(--ink);
}

.mn-fold.r {
	right: -12px;
}

.mn-fold.l {
	left: -12px;
}

.drag-ghost {
	position: fixed;
	z-index: 120;
	pointer-events: none;
	padding: 8px 12px;
	background: #000;
	border: 1px solid var(--hl);
	font-size: 12px;
	font-weight: 700;
	transform: translate(-50%, -130%);
}

.crumbs {
	position: absolute;
	z-index: 5;
	left: 10px;
	top: 10px;
	right: 64px;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 2px;
	pointer-events: none;
}

.crumbs > * {
	pointer-events: auto;
}

.crumbs button {
	height: 30px;
	padding: 0 8px;
	font-size: 10.5px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--dim);
	background: rgba(0, 0, 0, 0.85);
	border: 1px solid var(--rule);
	max-width: 40vw;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.crumbs button:hover {
	color: var(--ink);
}

.crumbs button.cur {
	color: var(--ink);
	border-color: var(--rule-hi);
}

.crumbs i {
	color: var(--faint);
	font-style: normal;
	padding: 0 2px;
}

.map-tools {
	position: absolute;
	z-index: 5;
	right: 10px;
	top: 10px;
	display: flex;
	flex-direction: column;
	background: rgba(0, 0, 0, 0.85);
	border: 1px solid var(--rule);
}

.map-tools button {
	width: 42px;
	height: 40px;
	display: grid;
	place-items: center;
	color: var(--dim);
	font-size: 15px;
}

.map-tools button + button {
	border-top: 1px solid var(--rule);
}

.map-tools button:hover {
	color: var(--ink);
}

.map-tools button.on {
	color: var(--hl);
}

.map-empty {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, 90px);
	text-align: center;
	color: var(--faint);
	font-size: 12px;
	line-height: 1.7;
	pointer-events: none;
	width: min(90vw, 360px);
}

/* the selected node's action card (thumb zone) */
.card {
	position: absolute;
	z-index: 8;
	left: 10px;
	right: 10px;
	bottom: 10px;
	max-width: 560px;
	margin: 0 auto;
	background: rgba(0, 0, 0, 0.95);
	border: 1px solid var(--rule-hi);
	animation: card-in 200ms var(--ease);
}

@keyframes card-in {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
}

.card-top {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 4px 4px 12px;
	border-bottom: 1px solid var(--rule);
}

.card-top .glyph {
	color: var(--hl);
	font-size: 13px;
	width: 22px;
	text-align: center;
	flex: none;
}

.card-title {
	flex: 1;
	min-width: 0;
	text-align: left;
	padding: 6px 0;
}

.card-title b {
	display: block;
	font-size: 13px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.card-title span {
	display: block;
	font-size: 10px;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--dim);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.card-adds {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
}

.card-adds button {
	height: 46px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	font-size: 9.5px;
	letter-spacing: 0.16em;
	color: var(--dim);
}

.card-adds button b {
	font-size: 13px;
	color: var(--ink);
	font-weight: 400;
	letter-spacing: 0;
}

.card-adds button + button {
	border-left: 1px solid var(--rule);
}

.card-adds button:hover {
	color: var(--ink);
	background: var(--panel-2);
}

/* ==========================================================================
   List
   ========================================================================== */

.list-wrap {
	position: absolute;
	inset: 0;
	overflow: auto;
	-webkit-overflow-scrolling: touch;
	padding: 0 0 120px;
}

.list-bar {
	position: sticky;
	top: 0;
	z-index: 4;
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	padding: 8px 12px;
	background: rgba(0, 0, 0, 0.94);
	border-bottom: 1px solid var(--rule);
}

.list-bar .cap {
	margin-right: auto;
}

.tree,
.tree ol {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tree ol {
	margin-left: 22px;
	border-left: 1px solid var(--rule);
}

.row-line {
	display: flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	padding: 0 8px 0 4px;
	border-bottom: 1px solid var(--rule);
	cursor: pointer;
}

.row-line:hover {
	background: var(--panel);
}

.row.sel > .row-line {
	background: #001114;
	box-shadow: inset 2px 0 0 var(--hl);
}

.row.has-err > .row-line .row-ttl {
	color: var(--err);
}

.tw {
	width: 28px;
	height: 36px;
	flex: none;
	color: var(--faint);
	font-size: 10px;
	transition: transform 160ms ease;
}

.tw.open {
	transform: rotate(90deg);
}

.tw.none {
	visibility: hidden;
}

.row-g {
	width: 26px;
	flex: none;
	text-align: center;
	color: var(--dim);
	font-size: 12px;
}

.row.k-step > .row-line .row-g {
	color: var(--ink);
}

.row-num {
	color: var(--faint);
	font-size: 10.5px;
	flex: none;
}

.row-ttl {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 13px;
}

.row.k-step > .row-line .row-ttl {
	font-weight: 700;
}

.row-meta {
	margin-left: auto;
	flex: none;
	font-size: 10px;
	letter-spacing: 0.1em;
	color: var(--faint);
	white-space: nowrap;
}

.row-acts {
	display: none;
	flex: none;
	margin-left: auto;
}

.row.sel > .row-line .row-acts {
	display: flex;
}

.row.sel > .row-line .row-meta {
	display: none;
}

.row-acts button {
	width: 36px;
	height: 36px;
	display: grid;
	place-items: center;
	color: var(--dim);
	font-size: 13px;
}

.row-acts button:hover {
	color: var(--ink);
}

.row-note {
	padding: 6px 12px 8px 64px;
	font-size: 11.5px;
	color: var(--dim);
	border-bottom: 1px solid var(--rule);
	white-space: pre-wrap;
}

.row-code {
	margin: 0;
	padding: 10px 12px 12px 64px;
	font-size: 12px;
	line-height: 1.55;
	white-space: pre;
	overflow-x: auto;
	border-bottom: 1px solid var(--rule);
	background: var(--panel);
	color: var(--s-id);
	tab-size: 2;
}

.row-code.empty {
	color: var(--faint);
	font-style: italic;
}

.list-foot {
	padding: 24px 16px;
	color: var(--faint);
	font-size: 11px;
	line-height: 1.8;
}

.list-foot b {
	color: var(--dim);
	font-weight: 400;
}

/* ==========================================================================
   Node view
   ========================================================================== */

.nv {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
}

.nv-head {
	display: flex;
	align-items: center;
	gap: 2px;
	border-bottom: 1px solid var(--rule);
	flex: none;
}

.nv-path {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 2px;
	overflow-x: auto;
	scrollbar-width: none;
	white-space: nowrap;
}

.nv-path::-webkit-scrollbar {
	display: none;
}

.nv-path button {
	padding: 0 4px;
	height: 40px;
	font-size: 10.5px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--dim);
}

.nv-path button:last-child {
	color: var(--ink);
}

.nv-path i {
	color: var(--faint);
	font-style: normal;
}

.nv-meta {
	flex: none;
	display: grid;
	grid-template-columns: auto 1fr;
	align-items: center;
	gap: 6px 10px;
	padding: 10px 12px 8px;
	border-bottom: 1px solid var(--rule);
}

.kind-seg {
	display: flex;
	border: 1px solid var(--rule-hi);
}

.kind-seg button {
	height: 32px;
	min-width: 40px;
	padding: 0 8px;
	font-size: 10px;
	letter-spacing: 0.16em;
	color: var(--dim);
}

.kind-seg button + button {
	border-left: 1px solid var(--rule-hi);
}

.kind-seg button.on {
	background: var(--ink);
	color: var(--bg);
}

.kind-seg.step button {
	pointer-events: none;
}

.fld {
	width: 100%;
	min-width: 0;
	background: transparent;
	border: 1px solid transparent;
	border-bottom-color: var(--rule-hi);
	padding: 6px 2px;
	outline: none;
	transition: border-color 160ms ease;
}

.fld:focus {
	border-bottom-color: var(--hl);
}

.nv-title {
	font-size: 16px;
	font-weight: 700;
}

.nv-note {
	grid-column: 1 / -1;
	font-size: 12px;
	color: var(--dim);
	resize: none;
	line-height: 1.5;
	min-height: 30px;
	max-height: 90px;
}

.nv-tools {
	flex: none;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border-bottom: 1px solid var(--rule);
	overflow-x: auto;
	scrollbar-width: none;
}

.nv-tools::-webkit-scrollbar {
	display: none;
}

.chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 28px;
	padding: 0 9px;
	border: 1px solid var(--rule-hi);
	font-size: 11px;
	color: var(--dim);
	white-space: nowrap;
	flex: none;
}

.chip:hover {
	color: var(--ink);
	border-color: var(--dim);
}

.chip b {
	color: var(--ink);
	font-weight: 400;
}

.chip.dep {
	border-color: color-mix(in srgb, var(--hl) 35%, transparent);
	color: var(--hl);
}

.chip.warn {
	border-color: rgba(255, 45, 45, 0.5);
	color: var(--err);
}

.nv-ed {
	flex: 1;
	min-height: 0;
	position: relative;
}

.nv-step {
	flex: 1;
	min-height: 0;
	overflow: auto;
	padding: 12px 12px 120px;
}

.kids {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
	gap: 8px;
	margin: 10px 0 18px;
}

.kid {
	text-align: left;
	padding: 10px 12px;
	border: 1px solid var(--rule-hi);
	background: var(--panel);
	min-width: 0;
}

.kid:hover {
	border-color: var(--dim);
}

.kid .mn-k {
	margin-bottom: 4px;
}

.kid b {
	display: block;
	font-size: 13px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.kid span {
	display: block;
	font-size: 11px;
	color: var(--dim);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.adds {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.empty-note {
	color: var(--faint);
	font-size: 12px;
	line-height: 1.7;
	margin: 6px 0 14px;
}

.nv-deps {
	flex: none;
	max-height: 30%;
	overflow: auto;
	border-top: 1px solid var(--rule);
	padding: 8px 12px;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	align-items: center;
}

.nv-deps .cap {
	margin-right: 4px;
}

/* ==========================================================================
   Code editor
   ========================================================================== */

.ed {
	position: absolute;
	inset: 0;
	background: #000;
}

.ed-scroll {
	position: absolute;
	inset: 0;
	overflow: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
}

.ed-grid {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	min-height: 100%;
	min-width: max-content;
	width: 100%;
	position: relative;
}

.ed-gutter,
.ed-hl,
.ed-ta {
	margin: 0;
	font-family: var(--mono);
	font-size: var(--ed-size);
	line-height: 1.6;
	tab-size: 2;
	letter-spacing: 0;
}

.ed-gutter {
	grid-column: 1;
	grid-row: 1;
	position: sticky;
	left: 0;
	z-index: 2;
	padding: 12px 10px 40vh 10px;
	min-width: 42px;
	text-align: right;
	color: var(--faint);
	background: #000;
	border-right: 1px solid var(--rule);
	user-select: none;
	-webkit-user-select: none;
}

.ed-gutter .err {
	color: var(--err);
	font-weight: 400;
}

.ed-hl,
.ed-ta {
	grid-column: 2;
	grid-row: 1;
	padding: 12px 24px 40vh 14px;
	white-space: pre;
	overflow-wrap: normal;
	word-break: normal;
}

.ed-hl {
	pointer-events: none;
	color: var(--s-id);
}

.ed-ta {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	outline: none;
	resize: none;
	overflow: hidden;
	background: transparent;
	color: transparent;
	caret-color: var(--hl);
	-webkit-text-fill-color: transparent;
	user-select: text;
	-webkit-user-select: text;
}

.ed-ta::selection {
	background: color-mix(in srgb, var(--hl) 28%, transparent);
	color: transparent;
}

.ed-mark {
	grid-column: 1 / -1;
	grid-row: 1;
	align-self: start;
	height: calc(var(--ed-size) * 1.6);
	margin-top: calc(12px + var(--line, 0) * var(--ed-size) * 1.6);
	background: var(--err-soft);
	box-shadow: inset 2px 0 0 var(--err);
	pointer-events: none;
}

.h-kw {
	color: var(--s-kw);
	font-weight: 700;
}

.h-str,
.h-re {
	color: var(--s-str);
}

.h-num {
	color: var(--s-num);
}

.h-com {
	color: var(--s-com);
	font-style: italic;
}

.h-fn {
	color: var(--s-fn);
}

.h-type {
	color: var(--ink);
	text-decoration: underline;
	text-decoration-color: var(--faint);
	text-underline-offset: 3px;
}

.h-prop {
	color: var(--s-prop);
}

.h-id {
	color: var(--s-id);
}

.h-punc {
	color: var(--s-punc);
}

.h-tag {
	color: var(--ink);
	font-weight: 700;
}

.h-attr {
	color: var(--s-prop);
}

.h-sel {
	color: var(--ink);
	font-weight: 700;
}

.h-val {
	color: var(--s-id);
}

/* phone key bar, sits on top of the on-screen keyboard */
.keybar {
	position: fixed;
	z-index: 90;
	left: 0;
	right: 0;
	bottom: var(--kb-off, 0px);
	height: 44px;
	display: flex;
	background: #050505;
	border-top: 1px solid var(--rule-hi);
	overflow-x: auto;
	scrollbar-width: none;
}

.keybar::-webkit-scrollbar {
	display: none;
}

.keybar button {
	flex: 1 0 40px;
	height: 44px;
	font-size: 15px;
	color: var(--ink);
	border-right: 1px solid var(--rule);
}

.keybar button.w {
	flex-basis: 52px;
	font-size: 10px;
	letter-spacing: 0.14em;
	color: var(--dim);
}

.keybar button:active {
	background: var(--ink);
	color: var(--bg);
}

body.typing .stage {
	bottom: calc(var(--kb-h, 0px) + 44px);
}

/* ==========================================================================
   Run
   ========================================================================== */

.view.run {
	flex-direction: column;
	background: #000;
}

.view.run.on {
	display: flex;
}

.run-bar {
	flex: none;
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 0 4px 0 10px;
	min-height: 44px;
	border-bottom: 1px solid var(--rule);
}

.run-scope {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.run-scope b {
	color: var(--hl);
	font-weight: 400;
}

.live {
	width: 6px;
	height: 6px;
	background: var(--faint);
	flex: none;
	margin-right: 4px;
}

.live.on {
	background: var(--hl);
	animation: blink 1.4s steps(1, end) infinite;
}

@keyframes blink {
	50% {
		opacity: 0.2;
	}
}

.run-frame {
	flex: 1 1 60%;
	min-height: 80px;
	position: relative;
	background: #fff;
	margin: 0;
}

.run-frame iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: #fff;
}

.run-frame.dark,
.run-frame.dark iframe {
	background: #000;
}

.con-split {
	flex: none;
	height: 10px;
	cursor: row-resize;
	border-top: 1px solid var(--rule-hi);
	touch-action: none;
	position: relative;
}

.con-split::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 3px;
	width: 34px;
	height: 2px;
	margin-left: -17px;
	background: var(--faint);
}

.console {
	flex: 0 0 var(--con-h, 34%);
	min-height: 70px;
	display: flex;
	flex-direction: column;
	background: #000;
}

.con-head {
	flex: none;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 0 4px 0 10px;
	height: 32px;
}

.con-head .cap {
	margin-right: auto;
}

.con-count {
	color: var(--err);
}

.con-out {
	flex: 1;
	min-height: 0;
	overflow: auto;
	font-size: 12px;
	line-height: 1.5;
	padding: 0 0 6px;
}

.cl {
	display: flex;
	gap: 8px;
	padding: 3px 10px;
	border-bottom: 1px solid #0f0f0f;
	white-space: pre-wrap;
	word-break: break-word;
	color: var(--s-id);
}

.cl::before {
	content: "›";
	color: var(--faint);
	flex: none;
}

.cl.warn {
	color: #e8d28a;
}

.cl.warn::before {
	content: "!";
	color: #e8d28a;
}

.cl.error {
	color: var(--err);
	background: rgba(255, 45, 45, 0.06);
}

.cl.error::before {
	content: "✕";
	color: var(--err);
}

.cl.in {
	color: var(--dim);
}

.cl.in::before {
	content: ">";
	color: var(--hl);
}

.cl.res::before {
	content: "←";
}

.cl.sys {
	color: var(--faint);
	font-size: 11px;
}

.cl.sys::before {
	content: "//";
}

.cl a {
	color: var(--ink);
	border-bottom: 1px solid var(--faint);
	cursor: pointer;
	white-space: nowrap;
}

.cl .n {
	margin-left: auto;
	flex: none;
	color: var(--faint);
	font-size: 10px;
}

.con-in {
	flex: none;
	display: flex;
	align-items: center;
	border-top: 1px solid var(--rule);
}

.con-in span {
	padding: 0 4px 0 10px;
	color: var(--hl);
}

.con-in input {
	flex: 1;
	min-width: 0;
	height: 38px;
	background: transparent;
	border: 0;
	outline: none;
	font-size: 12.5px;
}

/* ==========================================================================
   Sheets
   ========================================================================== */

.sheet-back {
	position: fixed;
	inset: 0;
	z-index: 150;
	background: rgba(0, 0, 0, 0.6);
	opacity: 0;
	pointer-events: none;
	transition: opacity 200ms ease;
}

.sheet-back.on {
	opacity: 1;
	pointer-events: auto;
}

.sheet {
	position: fixed;
	z-index: 160;
	left: 0;
	right: 0;
	bottom: 0;
	max-height: min(86vh, calc(100% - var(--sat) - 40px));
	display: flex;
	flex-direction: column;
	background: #000;
	border-top: 1px solid var(--rule-hi);
	padding-bottom: var(--sab);
	transform: translateY(105%);
	transition: transform 260ms var(--ease);
}

.sheet.on {
	transform: none;
}

.sheet::before {
	content: "";
	position: absolute;
	left: 0;
	top: -1px;
	height: 1px;
	width: 100%;
	background: var(--hl);
	transform: scaleX(0);
	transition: transform 420ms var(--ease) 80ms;
}

.sheet.on::before {
	transform: scaleX(1);
}

.sh-head {
	flex: none;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 4px 4px 16px;
	border-bottom: 1px solid var(--rule);
}

.sh-head h2 {
	flex: 1;
	margin: 0;
	font-size: 11px;
	letter-spacing: 0.28em;
	text-transform: uppercase;
	font-weight: 700;
}

.sh-body {
	flex: 1;
	min-height: 0;
	overflow: auto;
	padding: 14px 16px 20px;
	-webkit-overflow-scrolling: touch;
}

@media (min-width: 900px) {
	.sheet {
		left: 50%;
		right: auto;
		top: 50%;
		bottom: auto;
		width: min(620px, 92vw);
		max-height: 80vh;
		border: 1px solid var(--rule-hi);
		padding-bottom: 0;
		opacity: 0;
		transform: translate(-50%, -48%);
		pointer-events: none;
		transition: opacity 180ms ease, transform 220ms var(--ease);
	}

	.sheet.on {
		opacity: 1;
		transform: translate(-50%, -50%);
		pointer-events: auto;
	}
}

.sh-sec {
	margin: 18px 0 8px;
}

.sh-sec:first-child {
	margin-top: 0;
}

.opt {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	width: 100%;
	text-align: left;
	padding: 14px 14px;
	border: 1px solid var(--rule-hi);
	margin-bottom: 8px;
	transition: border-color 160ms ease, background 160ms ease;
}

.opt:hover {
	border-color: var(--dim);
	background: var(--panel);
}

.opt .g {
	width: 30px;
	flex: none;
	color: var(--hl);
	font-size: 15px;
	text-align: center;
	padding-top: 1px;
}

.opt b {
	display: block;
	font-size: 13px;
	margin-bottom: 3px;
}

.opt span {
	display: block;
	font-size: 11.5px;
	line-height: 1.55;
	color: var(--dim);
}

.opt .r {
	margin-left: auto;
	flex: none;
	align-self: center;
	color: var(--faint);
	font-size: 11px;
}

.opt.sel {
	border-color: var(--hl);
}

.menu-list {
	display: flex;
	flex-direction: column;
}

.mi {
	display: flex;
	align-items: center;
	gap: 14px;
	min-height: 48px;
	padding: 0 6px;
	text-align: left;
	border-bottom: 1px solid var(--rule);
	font-size: 13px;
}

.mi:hover {
	background: var(--panel);
}

.mi .g {
	width: 24px;
	text-align: center;
	color: var(--dim);
}

.mi .k {
	margin-left: auto;
	color: var(--faint);
	font-size: 10.5px;
	letter-spacing: 0.1em;
}

.mi.danger {
	color: var(--err);
}

.mi.danger .g {
	color: var(--err);
}

.toggle {
	margin-left: auto;
	width: 34px;
	height: 18px;
	border: 1px solid var(--rule-hi);
	position: relative;
	flex: none;
}

.toggle::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 10px;
	height: 10px;
	background: var(--faint);
	transition: transform 160ms ease, background 160ms ease;
}

.toggle.on {
	border-color: var(--hl);
}

.toggle.on::after {
	transform: translateX(16px);
	background: var(--hl);
}

.form-row {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 14px;
}

.form-row label {
	font-size: 10.5px;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--dim);
}

.inp {
	width: 100%;
	min-height: 42px;
	padding: 8px 10px;
	background: #000;
	border: 1px solid var(--rule-hi);
	outline: none;
	font-size: 14px;
}

.inp:focus {
	border-color: var(--hl);
}

textarea.inp {
	resize: vertical;
	min-height: 64px;
	line-height: 1.5;
}

.row-btns {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	margin-top: 6px;
}

.row-btns .btn {
	flex: 1;
}

.grid-tags {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
	gap: 6px;
}

.grid-tags button {
	height: 52px;
	border: 1px solid var(--rule-hi);
	font-size: 12px;
	color: var(--ink);
}

.grid-tags button:hover {
	border-color: var(--hl);
	color: var(--hl);
}

.grid-tags button span {
	color: var(--faint);
}

.pset {
	padding: 12px 0;
	border-bottom: 1px solid var(--rule);
	display: flex;
	gap: 12px;
	align-items: flex-start;
}

.pset .g {
	width: 26px;
	flex: none;
	text-align: center;
	color: var(--hl);
	padding-top: 2px;
}

.pset .tx {
	flex: 1;
	min-width: 0;
}

.pset b {
	font-size: 13px;
}

.pset .tag {
	font-size: 9.5px;
	letter-spacing: 0.2em;
	color: var(--faint);
	margin-left: 8px;
}

.pset p {
	margin: 3px 0 0;
	font-size: 11.5px;
	line-height: 1.5;
	color: var(--dim);
}

.pset .acts {
	display: flex;
	flex-direction: column;
	gap: 4px;
	flex: none;
}

.note-box {
	border-left: 2px solid var(--rule-hi);
	padding: 4px 0 4px 12px;
	margin: 10px 0;
	font-size: 11.5px;
	line-height: 1.6;
	color: var(--dim);
}

.note-box.warn {
	border-color: var(--err);
	color: #ff8b8b;
}

.files {
	margin: 8px 0 0;
	padding: 10px 12px;
	background: var(--panel);
	border: 1px solid var(--rule);
	font-size: 11px;
	line-height: 1.6;
	color: var(--dim);
	max-height: 200px;
	overflow: auto;
	white-space: pre;
}

.help h3 {
	margin: 18px 0 6px;
	font-size: 11px;
	letter-spacing: 0.24em;
	text-transform: uppercase;
}

.help h3:first-child {
	margin-top: 0;
}

.help p,
.help li {
	font-size: 12px;
	line-height: 1.7;
	color: var(--dim);
}

.help ul {
	padding-left: 18px;
	margin: 0;
}

.help kbd {
	font: inherit;
	color: var(--ink);
	border: 1px solid var(--rule-hi);
	padding: 0 5px;
	font-size: 11px;
}

.proj-row {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 0;
	border-bottom: 1px solid var(--rule);
}

.proj-row .tx {
	flex: 1;
	min-width: 0;
	text-align: left;
	padding: 4px 0;
}

.proj-row b {
	display: block;
	font-size: 13px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.proj-row span {
	font-size: 10.5px;
	letter-spacing: 0.1em;
	color: var(--faint);
}

.proj-row.cur b {
	color: var(--hl);
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
	position: fixed;
	z-index: 400;
	left: 50%;
	top: calc(var(--top-h) + var(--sat) + 12px);
	transform: translate(-50%, -12px);
	max-width: calc(100vw - 32px);
	padding: 10px 16px;
	background: #000;
	border: 1px solid var(--rule-hi);
	font-size: 12px;
	opacity: 0;
	pointer-events: none;
	transition: opacity 200ms ease, transform 200ms var(--ease);
}

.toast.on {
	opacity: 1;
	transform: translate(-50%, 0);
}

.toast.err {
	border-color: var(--err);
	color: var(--err);
}

/* ==========================================================================
   Smart editor: autocomplete and live checks
   ========================================================================== */

.ed-marks {
	grid-column: 2;
	grid-row: 1;
	position: relative;
	pointer-events: none;
}

.ed-marks i {
	position: absolute;
	height: 3px;
	background-repeat: repeat-x;
	background-size: 6px 3px;
}

.ed-marks i.err {
	background-image: linear-gradient(45deg, transparent 35%, var(--err) 35% 65%, transparent 65%), linear-gradient(-45deg, transparent 35%, var(--err) 35% 65%, transparent 65%);
}

.ed-marks i.warn {
	background-image: radial-gradient(circle, #e8d28a 1px, transparent 1.4px);
	background-size: 4px 3px;
}

.ed-gutter .warn {
	color: #e8d28a;
	font-weight: 400;
}

.ac {
	position: absolute;
	z-index: 20;
	max-height: calc(7 * 34px + 2px);
	overflow-y: auto;
	background: #000;
	border: 1px solid var(--hl);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
	overscroll-behavior: contain;
}

.ac button {
	display: flex;
	align-items: baseline;
	gap: 10px;
	width: 100%;
	height: 34px;
	padding: 0 10px;
	text-align: left;
	font-size: 12.5px;
	border-bottom: 1px solid #111;
}

.ac button b {
	font-weight: 400;
	color: var(--ink);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	flex: none;
	max-width: 62%;
}

.ac button span {
	margin-left: auto;
	color: var(--faint);
	font-size: 10.5px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
}

.ac button.on {
	background: var(--hl-soft);
	box-shadow: inset 2px 0 0 var(--hl);
}

.ac button.on b {
	color: var(--hl);
}

.nv-probs {
	flex: none;
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	min-height: 32px;
	padding: 4px 12px;
	text-align: left;
	font-size: 11.5px;
	border-top: 1px solid var(--rule);
	background: rgba(255, 45, 45, 0.07);
	color: #ff8b8b;
}

.nv-probs.warn {
	background: rgba(232, 210, 138, 0.06);
	color: #e8d28a;
}

.nv-probs .cnt {
	flex: none;
	letter-spacing: 0.1em;
}

.nv-probs .msg {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.nv-probs .nx {
	flex: none;
	color: var(--dim);
}

/* ==========================================================================
   XIO account chip, sync conflicts
   ========================================================================== */

.acct {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 34px;
	padding: 0 8px;
	margin-right: 2px;
	color: var(--dim);
	font-size: 10.5px;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	border: 1px solid transparent;
}

.acct:hover {
	color: var(--ink);
	border-color: var(--rule-hi);
}

.acct i {
	width: 5px;
	height: 5px;
	background: var(--faint);
	flex: none;
}

.acct.ok i {
	background: var(--hl);
}

.acct.busy i {
	background: var(--hl);
	animation: blink 0.8s steps(1, end) infinite;
}

.acct.bad i {
	background: var(--err);
}

.acct span {
	max-width: 12ch;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

@media (max-width: 899px) {
	.acct span {
		display: none;
	}

	.acct {
		padding: 0 6px;
	}
}

.mn.has-conflict {
	border-color: #e8d28a;
}

.mn.has-conflict .mn-k::before {
	content: "⇄";
	color: #e8d28a;
	margin-right: 2px;
}

.cf-mark {
	color: #e8d28a;
	font-weight: 400;
}

.nv-conflict {
	flex: none;
	padding: 8px 12px;
	border-bottom: 1px solid var(--rule);
	background: rgba(232, 210, 138, 0.06);
	max-height: 40%;
	overflow: auto;
}

.cf-msg {
	font-size: 11.5px;
	line-height: 1.55;
	color: #e8d28a;
	margin-bottom: 8px;
}

.cf-btns {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.nv-conflict .row-code {
	margin-top: 8px;
	padding-left: 12px;
	border: 1px solid var(--rule);
}

.nv-probs .pr-go {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	gap: 10px;
	text-align: left;
	min-height: 28px;
}

.nv-probs .pr-fix {
	flex: none;
	height: 26px;
	padding: 0 9px;
	border: 1px solid currentColor;
	font-size: 10.5px;
	letter-spacing: 0.1em;
}

.nv-probs .pr-fix:hover {
	background: var(--ink);
	color: var(--bg);
	border-color: var(--ink);
}

.kind-seg button[data-m],
.kind-seg button[data-pv] {
	min-width: 64px;
}

/* XIO colour + motion layer: <html data-xio="xcode"> + /xio/motion/ set
   --accent; the bridge turns --hl/--ink/--rule into the xCode orange.
   Strings keep a pale tint of the accent, as they did of cyan. */
html[data-xio] {
	--hl-dim: color-mix(in srgb, var(--accent) 50%, transparent);
	--s-kw: var(--x-text);
	--s-str: color-mix(in oklab, var(--accent) 45%, #e8e8e8);
	--s-fn: color-mix(in oklab, var(--accent) 18%, #ffffff);
	--s-num: color-mix(in oklab, var(--accent-2) 22%, #d6d6d6);
}
.xc-opt { position: relative; flex: none; width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; border: 1px solid var(--rule-hi); background: none; color: var(--dim); cursor: pointer; transition: color 200ms var(--ease), border-color 200ms var(--ease); }
.xc-opt:hover, .xc-opt[aria-expanded="true"] { color: var(--hl); border-color: var(--hl); }
.xc-opt svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; }
html[data-xio] .logo svg { stroke: var(--accent); }
