:root {
	--ns-session: var(--accent);
	--ns-workspace: var(--ring-host);
	--ns-project: var(--ring-web);
	--ns-mcp: var(--ring-wire);
	--ns-provider: var(--mod);
	--ns-review: color-mix(in oklab, var(--del) 55%, var(--ring-web));
	--ns-todo: var(--add);
	--ns-terminal: color-mix(in oklab, var(--del) 70%, var(--text));
	--ns-other: var(--text-faint);
	--lane-web: color-mix(in oklab, var(--ring-web) 7%, transparent);
	--lane-wire: color-mix(in oklab, var(--ring-wire) 8%, transparent);
	--lane-host: color-mix(in oklab, var(--ring-host) 7%, transparent);
	--halo: var(--bg);
}

body {
	height: 100vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.cv-header kbd,
.ride-bar kbd {
	font: 11px var(--font-code);
	padding: 0 4px;
	border: 1px solid var(--line-strong);
	border-radius: 4px;
	color: var(--text-muted);
}

.view {
	flex: 1;
	min-height: 0;
	display: flex;
}

.view[hidden] {
	display: none;
}

#catalog {
	gap: 0;
}

#mapPane {
	flex: 1.55;
	min-width: 0;
	display: flex;
	flex-direction: column;
	border-right: 1px solid var(--line);
}

.pane-head {
	display: flex;
	gap: 14px;
	align-items: baseline;
	padding: 10px 16px 6px;
	color: var(--text-muted);
	font-size: 12.5px;
}

.pane-head b {
	color: var(--text);
	font-weight: 600;
	font-size: 13px;
}

.pane-head .spacer {
	flex: 1;
}

#map {
	flex: 1;
	min-height: 0;
	width: 100%;
}

#cards {
	flex: 1;
	min-width: 340px;
	max-width: 560px;
	overflow-y: auto;
	padding: 10px 14px 24px;
}

.cards-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin: 6px 2px 8px;
	color: var(--text-muted);
	font-size: 12px;
}

.cards-head b {
	color: var(--text);
	font-size: 13px;
}

.cards-head button {
	font-size: 11px;
}

.card-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}

.card {
	position: relative;
	padding: 10px 12px;
	background: var(--bg-raised);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s;
}

.card:hover,
.card.hl {
	border-color: var(--accent);
	background: color-mix(in oklab, var(--accent) 6%, var(--bg-raised));
}

.card.curated {
	grid-column: span 2;
	border-left: 3px solid var(--accent);
}

.card.start::after {
	content: attr(data-start);
	position: absolute;
	top: 8px;
	right: 10px;
	font-size: 11px;
	color: var(--accent);
}

.card h3 {
	margin: 0 0 2px;
	font-size: 13.5px;
	font-weight: 600;
}

.card.auto h3 {
	font-size: 12px;
	font-family: var(--font-code);
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.card p {
	margin: 2px 0 6px;
	color: var(--text-muted);
	font-size: 12px;
	line-height: 1.4;
}

.card .meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	align-items: center;
}

.card .tag {
	font-size: 10.5px;
	padding: 0 6px;
	border-radius: 999px;
	border: 1px solid var(--line-strong);
	color: var(--text-muted);
}

.card .tag.pr {
	border-color: var(--mod);
	color: var(--mod);
}

.card .tag.hand {
	border-color: var(--accent);
	color: var(--accent);
}

.card .tag.auto {
	border-style: dashed;
	color: var(--text-faint);
}

.lanestrip {
	display: flex;
	gap: 2px;
	margin-left: auto;
}

.lanestrip i {
	width: 9px;
	height: 9px;
	border-radius: 2px;
	background: var(--line);
}

.lanestrip i.on.web {
	background: var(--ring-web);
}

.lanestrip i.on.wire {
	background: var(--ring-wire);
}

.lanestrip i.on.host {
	background: var(--ring-host);
}

.lanestrip i.on.pi {
	background: var(--text-muted);
}

.ns-dot {
	display: inline-block;
	width: 10px;
	height: 4px;
	border-radius: 2px;
	margin-right: 4px;
	vertical-align: middle;
}

button,
.seg button {
	font: 12px var(--font-ui);
	color: var(--text);
	background: var(--bg-sunken);
	border: 1px solid var(--line-strong);
	border-radius: 6px;
	padding: 3px 10px;
	cursor: pointer;
}

button:hover {
	border-color: var(--accent);
}

button.primary {
	background: var(--accent-soft);
	border-color: var(--accent);
	color: var(--text);
}

button:disabled {
	opacity: 0.4;
	cursor: default;
}

.seg {
	display: inline-flex;
}

.seg button {
	border-radius: 0;
}

.seg button:first-child {
	border-radius: 6px 0 0 6px;
}

.seg button:last-child {
	border-radius: 0 6px 6px 0;
	border-left: none;
}

.seg button.on {
	background: var(--accent-soft);
	border-color: var(--accent);
}

/* ride */
#ride {
	flex-direction: column;
}

.ride-bar {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 16px;
	border-bottom: 1px solid var(--line);
	font-size: 12.5px;
	flex-wrap: wrap;
}

.ride-bar h2 {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
}

.ride-bar .muted {
	color: var(--text-muted);
}

.ride-bar .spacer {
	flex: 1;
}

.toggle {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	user-select: none;
	color: var(--text-muted);
}

.toggle input {
	accent-color: var(--mod);
}

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

.pr-strip {
	display: none;
	gap: 14px;
	align-items: center;
	padding: 6px 16px;
	border-bottom: 1px solid var(--line);
	background: var(--mod-soft);
	font-size: 12px;
	color: var(--text-muted);
}

.pr-strip.on {
	display: flex;
}

.pr-strip b {
	color: var(--text);
}

.legend {
	display: inline-flex;
	gap: 10px;
	align-items: center;
}

.legend span::before {
	content: "";
	display: inline-block;
	width: 12px;
	height: 8px;
	border-radius: 2px;
	margin-right: 4px;
	vertical-align: middle;
	border: 1.5px solid;
}

.legend .lg-add::before {
	border-color: var(--add);
	background: var(--add-soft);
}

.legend .lg-del::before {
	border-color: var(--text-faint);
	border-style: dashed;
}

.legend .lg-mod::before {
	border-color: var(--mod);
	background: var(--mod-soft);
}

.legend .lg-err::before {
	border-color: var(--del);
	background: var(--del-soft);
}

.ride-body {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

#diagramWrap {
	flex: 1;
	min-height: 0;
	overflow: auto;
	position: relative;
}

#dia {
	display: block;
}

#stepPanel {
	border-top: 1px solid var(--line);
	background: var(--bg-raised);
	padding: 10px 18px 12px;
	min-height: 96px;
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 4px 20px;
}

#stepPanel .where {
	font: 12px var(--font-code);
	color: var(--text-muted);
}

#stepPanel .where b {
	color: var(--text);
	font-family: var(--font-ui);
}

#stepPanel .narr {
	font-size: 15px;
	line-height: 1.45;
	grid-column: 1;
}

#stepPanel .narr code {
	font-size: 13px;
	color: var(--accent);
}

#stepPanel .note {
	grid-column: 1;
	font-size: 11px;
	color: var(--text-faint);
}

#stepPanel .ctrl {
	grid-column: 2;
	grid-row: 1 / span 3;
	display: flex;
	gap: 6px;
	align-items: center;
}

/* svg */
svg text {
	font-family: var(--font-ui);
	fill: var(--text);
}

.mono {
	font-family: var(--font-code);
}

.halo {
	paint-order: stroke;
	stroke: var(--halo);
	stroke-width: 3.5px;
	stroke-linejoin: round;
}

.flow {
	animation: flow 1.6s linear infinite;
}

@keyframes flow {
	to {
		stroke-dashoffset: -20;
	}
}

#map .ln {
	transition: opacity 0.15s;
	cursor: pointer;
}

#map.dim .ln:not(.hl),
#map.dim text[data-ns]:not(.hl) {
	opacity: 0.08;
}

#map.dim .st:not(.hl) {
	opacity: 0.35;
}

#dia .node,
#dia .side {
	cursor: pointer;
}

#dia .node.cur rect.box {
	stroke-width: 2.5px;
	filter: drop-shadow(0 0 6px var(--accent));
}

.tip {
	position: fixed;
	z-index: 20;
	max-width: 440px;
	padding: 10px 12px;
	background: var(--bg-raised);
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
	font-size: 12px;
	line-height: 1.45;
	pointer-events: none;
}

.tip.pinned {
	pointer-events: auto;
}

.tip h4 {
	margin: 0 0 4px;
	font-size: 13px;
}

.tip .loc {
	font: 11.5px var(--font-code);
	color: var(--accent);
}

.tip .dim {
	color: var(--text-muted);
}

.tip .faint {
	color: var(--text-faint);
	font-size: 11px;
}

.tip .chips {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-top: 4px;
}

.tip .chip {
	font: 10.5px var(--font-code);
	padding: 0 6px;
	border: 1px solid var(--line-strong);
	border-radius: 999px;
	color: var(--text-muted);
}

.tip .chip.test {
	border-color: var(--add);
	color: var(--add);
}

.tip .chip.none {
	border-style: dashed;
}

.tip table {
	border-collapse: collapse;
	width: 100%;
	margin-top: 4px;
}

.tip td {
	padding: 1px 6px 1px 0;
	font-size: 11.5px;
	vertical-align: top;
}

.tip td.n {
	text-align: right;
	color: var(--text-muted);
	font-family: var(--font-code);
}

.tip pre {
	margin: 6px 0 0;
	padding: 6px 8px;
	background: var(--bg-sunken);
	border-radius: 6px;
	font-size: 11px;
	line-height: 1.35;
	overflow: hidden;
	white-space: pre;
}

.tip pre .a {
	color: var(--add);
}

.tip pre .d {
	color: var(--del);
}

.tip pre .c {
	color: var(--text-faint);
}

.tip .graph-edge {
	color: var(--add);
}

.tip .graph-symbol {
	color: var(--text-muted);
}

.tip .graph-none {
	color: var(--mod);
}

.tip .graph-pr {
	color: var(--mod);
}
