/* Design foundation adapted from the supplied FrugalAI prototype. */

:root {
	--bg: oklch(98% 0.005 250);
	--surface: oklch(100% 0 0);
	--surface-2: oklch(97% 0.006 250);
	--fg: oklch(22% 0.02 240);
	--muted: oklch(50% 0.018 240);
	--border: oklch(90% 0.008 240);
	--border-strong: oklch(83% 0.01 240);
	--accent: oklch(58% 0.16 145);
	--accent-soft: color-mix(in oklch, var(--accent) 15%, transparent);
	--fg-soft: color-mix(in oklch, var(--fg) 5%, transparent);
	--ok: oklch(56% 0.14 152);
	--ok-soft: color-mix(in oklch, var(--ok) 13%, var(--surface));
	--warn: oklch(66% 0.14 72);
	--warn-soft: color-mix(in oklch, var(--warn) 18%, var(--surface));
	--danger: oklch(56% 0.2 26);
	--danger-soft: color-mix(in oklch, var(--danger) 12%, var(--surface));
	--info: oklch(56% 0.13 252);
	--info-soft: color-mix(in oklch, var(--info) 12%, var(--surface));
	--exhaust: oklch(55% 0.16 300);
	--exhaust-soft: color-mix(in oklch, var(--exhaust) 12%, var(--surface));
	--neutral: oklch(58% 0.02 240);
	--neutral-soft: color-mix(in oklch, var(--neutral) 12%, var(--surface));
	--rail: oklch(25% 0.02 250);
	--rail-fg: oklch(90% 0.01 250);
	--rail-muted: oklch(68% 0.015 250);
	--rail-border: oklch(33% 0.02 250);
	--rail-active: oklch(31% 0.03 250);
	--font-display: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
	--font-body: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
	--font-mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;
	--radius: 9px;
	--radius-lg: 14px;
	--shadow: 0 1px 2px oklch(22% 0.02 240 / 0.05), 0 6px 20px oklch(22% 0.02 240 / 0.05);
}
*,
*::before,
*::after {
	box-sizing: border-box;
}
html,
body {
	margin: 0;
}
body {
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font-body);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}
a {
	color: inherit;
	text-decoration: none;
}
button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}
button {
	background: none;
	border: none;
	cursor: pointer;
}
img,
svg {
	display: block;
}
::selection {
	background: var(--accent-soft);
}
.mono {
	font-family: var(--font-mono);
	font-variant-numeric: tabular-nums;
}
#app.hidden {
	display: none;
}
.hidden {
	display: none;
}

.app {
	display: grid;
	grid-template-columns: 250px minmax(0, 1fr);
	min-height: 100vh;
}
.rail {
	background: var(--rail);
	color: var(--rail-fg);
	position: sticky;
	top: 0;
	height: 100vh;
	display: flex;
	flex-direction: column;
	padding: 16px 14px 14px;
	z-index: 40;
}
.rail-brand {
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 6px 8px 18px;
}
.rail-brand .mark {
	width: 32px;
	height: 32px;
	border-radius: 9px;
	background: var(--accent);
	display: grid;
	place-items: center;
	color: oklch(22% 0.03 150);
	flex: none;
}
.rail-brand .mark svg {
	width: 18px;
	height: 18px;
}
.rail-brand b {
	font-size: 16px;
	font-weight: 700;
	letter-spacing: -0.01em;
}
.rail-brand span {
	display: block;
	font-size: 10.5px;
	color: var(--rail-muted);
	font-family: var(--font-mono);
	letter-spacing: 0.04em;
}
.rail-scroll {
	flex: 1;
	overflow: auto;
	display: flex;
	flex-direction: column;
	gap: 20px;
	padding-right: 2px;
}
.rail-scroll::-webkit-scrollbar {
	width: 6px;
}
.rail-scroll::-webkit-scrollbar-thumb {
	background: var(--rail-border);
	border-radius: 999px;
}
.rail-group-title {
	font-family: var(--font-mono);
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.13em;
	color: var(--rail-muted);
	padding: 0 10px 6px;
}
.rail-item {
	display: flex;
	align-items: center;
	gap: 11px;
	padding: 8px 10px;
	border-radius: 8px;
	color: var(--rail-muted);
	font-size: 13.5px;
	font-weight: 500;
	border: 1px solid transparent;
	text-align: left;
	width: 100%;
}
.rail-item:hover {
	background: var(--rail-active);
	color: var(--rail-fg);
}
.rail-item.on {
	background: var(--rail-active);
	color: var(--rail-fg);
	border-color: var(--rail-border);
}
.rail-item .ico {
	width: 18px;
	height: 18px;
	flex: none;
	display: grid;
	place-items: center;
	color: var(--rail-muted);
}
.rail-item.on .ico {
	color: var(--accent);
}
.rail-item .badge {
	margin-left: auto;
	font-family: var(--font-mono);
	font-size: 10px;
	background: var(--accent);
	color: oklch(22% 0.03 150);
	padding: 1px 6px;
	border-radius: 999px;
	font-weight: 700;
}
.rail-foot {
	border-top: 1px solid var(--rail-border);
	padding-top: 12px;
	margin-top: 8px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.rail-identity {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 9px 10px;
	border: 1px solid var(--rail-border);
	border-radius: 10px;
	background: oklch(28% 0.025 250);
}
.rail-identity .who {
	min-width: 0;
}
.rail-identity .who b {
	display: block;
	font-size: 12.5px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.rail-identity .who .k {
	font-family: var(--font-mono);
	font-size: 10.5px;
	color: var(--rail-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.main {
	min-width: 0;
	display: flex;
	flex-direction: column;
}
.topbar {
	position: sticky;
	top: 0;
	z-index: 30;
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 11px 26px;
	background: color-mix(in oklch, var(--bg) 88%, transparent);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--border);
}
.hamburger {
	display: none;
	width: 34px;
	height: 34px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface);
	place-items: center;
}
.topbar .titles h1 {
	font-size: 17px;
	margin: 0;
	font-weight: 650;
	letter-spacing: -0.015em;
}
.topbar .titles .sub {
	color: var(--muted);
	font-size: 12px;
}
.grow {
	flex: 1;
}
.lang-switch {
	display: flex;
	align-items: center;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 2px;
}
.lang-switch button {
	padding: 6px 10px;
	border-radius: 6px;
	font-size: 12px;
	font-weight: 600;
	color: var(--muted);
}
.lang-switch button.on {
	background: var(--rail);
	color: var(--rail-fg);
}
.avatar {
	width: 34px;
	height: 34px;
	border-radius: 9px;
	background: var(--accent-soft);
	color: oklch(42% 0.12 150);
	display: grid;
	place-items: center;
	font-weight: 700;
	font-size: 13px;
}

.content {
	padding: 24px 26px 72px;
	width: 100%;
	max-width: 1440px;
	margin-inline: auto;
}
.view {
	animation: fade 0.22s ease;
}
@keyframes fade {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.page-head {
	display: flex;
	justify-content: flex-end;
	gap: 18px;
	flex-wrap: wrap;
	margin-bottom: 16px;
}
.head-actions {
	display: flex;
	gap: 9px;
	flex-wrap: wrap;
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow);
}
.card-hd {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 15px 18px;
	border-bottom: 1px solid var(--border);
	flex-wrap: wrap;
}
.card-hd h3 {
	margin: 0;
	font-size: 14.5px;
	font-weight: 650;
}
.card-hd .hint {
	color: var(--muted);
	font-size: 12px;
	font-weight: 400;
}
.card-bd {
	padding: 18px;
}
.card-bd.tight {
	padding: 0;
}

.grid {
	display: grid;
	gap: 16px;
}
.g2 {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}
.g3 {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}
.g4 {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}
.split-2-1 {
	grid-template-columns: 2fr 1fr;
}
.split-3-2 {
	grid-template-columns: 1.6fr 1fr;
}
@media (max-width: 1180px) {
	.g4 {
		grid-template-columns: repeat(2, 1fr);
	}
	.split-2-1,
	.split-3-2 {
		grid-template-columns: 1fr;
	}
	.g3 {
		grid-template-columns: repeat(2, 1fr);
	}
}
@media (max-width: 760px) {
	.g2,
	.g3,
	.g4 {
		grid-template-columns: 1fr;
	}
}
.stack {
	display: flex;
	flex-direction: column;
	gap: 16px;
}
.row {
	display: flex;
	align-items: center;
	gap: 10px;
}
.row.wrap {
	flex-wrap: wrap;
}
.spread {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-wrap: wrap;
}

.kpi {
	padding: 16px 18px;
}
.kpi .k-label {
	color: var(--muted);
	font-size: 12px;
	display: flex;
	align-items: center;
	gap: 6px;
}
.kpi .k-value {
	font-size: 27px;
	font-weight: 700;
	letter-spacing: -0.02em;
	margin-top: 8px;
	font-variant-numeric: tabular-nums;
}
.kpi .k-value small {
	font-size: 14px;
	color: var(--muted);
	font-weight: 500;
	margin-left: 3px;
}
.kpi .k-foot {
	margin-top: 6px;
	font-size: 12px;
	color: var(--muted);
	display: flex;
	align-items: center;
	gap: 6px;
}
.delta {
	font-family: var(--font-mono);
	font-size: 11px;
	font-weight: 700;
	padding: 1px 6px;
	border-radius: 999px;
}
.delta.up {
	background: var(--ok-soft);
	color: var(--ok);
}
.delta.down {
	background: var(--danger-soft);
	color: var(--danger);
}
.delta.flat {
	background: var(--neutral-soft);
	color: var(--muted);
}

.pill {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 2px 9px;
	border-radius: 999px;
	font-size: 11.5px;
	font-weight: 600;
	white-space: nowrap;
}
.pill .dot {
	width: 6px;
	height: 6px;
	border-radius: 999px;
	background: currentColor;
}
.pill.ok {
	background: var(--ok-soft);
	color: var(--ok);
}
.pill.warn {
	background: var(--warn-soft);
	color: oklch(52% 0.14 72);
}
.pill.danger {
	background: var(--danger-soft);
	color: var(--danger);
}
.pill.info {
	background: var(--info-soft);
	color: var(--info);
}
.pill.exhaust {
	background: var(--exhaust-soft);
	color: var(--exhaust);
}
.pill.neutral {
	background: var(--neutral-soft);
	color: var(--muted);
}
.tag {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 9px;
	border: 1px solid var(--border);
	border-radius: 7px;
	font-size: 12px;
	color: var(--muted);
	font-family: var(--font-mono);
}
.tag b {
	color: var(--fg);
	font-weight: 600;
}
.tag-btn {
	cursor: pointer;
	background: var(--surface);
	transition:
		border-color 0.12s,
		color 0.12s;
}
.tag-btn:hover {
	color: var(--fg);
	border-color: var(--fg);
}
.tag-btn svg {
	width: 13px;
	height: 13px;
	opacity: 0.7;
}
.tag-wrap {
	position: relative;
	display: inline-flex;
}
.popmenu {
	position: absolute;
	bottom: calc(100% + 6px);
	left: 0;
	z-index: 40;
	min-width: 136px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 11px;
	box-shadow: 0 14px 34px oklch(22% 0.02 240 / 0.18);
	padding: 5px;
	display: flex;
	flex-direction: column;
	gap: 1px;
}
.popmenu button {
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	text-align: left;
	padding: 7px 9px;
	border-radius: 7px;
	font-size: 12.5px;
	font-weight: 500;
	color: var(--fg);
	background: transparent;
	border: none;
	cursor: pointer;
	transition: background 0.1s;
}
.popmenu button:hover {
	background: var(--surface-2);
}
.popmenu button:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: -1px;
}
.popmenu button .ck {
	display: inline-block;
	width: 13px;
	height: 13px;
	flex: none;
}
.popmenu button svg {
	color: var(--accent);
	flex: none;
	opacity: 1;
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 8px 14px;
	border-radius: 9px;
	font-size: 13.5px;
	font-weight: 600;
	border: 1px solid transparent;
	transition:
		background 0.12s,
		border-color 0.12s,
		transform 0.05s;
}
.btn:active {
	transform: translateY(1px);
}
.btn svg {
	width: 16px;
	height: 16px;
}
.btn-primary {
	background: var(--accent);
	color: oklch(22% 0.03 150);
	border-color: var(--accent);
}
.btn-primary:hover {
	background: color-mix(in oklch, var(--accent) 86%, black);
}
.btn-outline {
	background: var(--surface);
	border-color: var(--border-strong);
	color: var(--fg);
}
.btn-outline:hover {
	border-color: var(--fg);
}
.btn-ghost {
	color: var(--muted);
	padding-inline: 10px;
}
.btn-ghost:hover {
	color: var(--fg);
	background: var(--fg-soft);
}
.btn-danger {
	background: var(--danger-soft);
	color: var(--danger);
	border-color: transparent;
}
.btn-danger:hover {
	background: color-mix(in oklch, var(--danger) 20%, var(--surface));
}
.btn-sm {
	padding: 5px 10px;
	font-size: 12.5px;
	border-radius: 7px;
}
.btn-sm svg {
	width: 14px;
	height: 14px;
}
.btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}
.icon-btn {
	width: 30px;
	height: 30px;
	border: 1px solid var(--border);
	border-radius: 7px;
	background: var(--surface);
	display: grid;
	place-items: center;
	color: var(--muted);
}
.icon-btn:hover {
	color: var(--fg);
	border-color: var(--fg);
}
.btn:focus-visible,
.rail-item:focus-visible,
.tab:focus-visible,
.chip:focus-visible,
.icon-btn:focus-visible,
.lang-switch button:focus-visible,
a:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.tabs {
	display: flex;
	gap: 4px;
	border-bottom: 1px solid var(--border);
	margin-bottom: 16px;
	overflow: auto;
}
.tab {
	padding: 9px 14px;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--muted);
	border-bottom: 2px solid transparent;
	white-space: nowrap;
}
.tab:hover {
	color: var(--fg);
}
.tab.on {
	color: var(--fg);
	border-bottom-color: var(--accent);
}

.chips {
	display: flex;
	gap: 7px;
	flex-wrap: wrap;
}
.chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 12.5px;
	color: var(--muted);
	background: var(--surface);
}
.chip:hover {
	border-color: var(--border-strong);
	color: var(--fg);
}
.chip.on {
	background: var(--accent-soft);
	border-color: transparent;
	color: oklch(42% 0.12 150);
	font-weight: 600;
}

.field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.field > label {
	font-size: 12px;
	color: var(--muted);
	font-weight: 500;
}
.input,
.select,
.textarea {
	width: 100%;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 8px 11px;
	font-size: 13px;
	outline: none;
}
.input:focus,
.select:focus,
.textarea:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea {
	min-height: 84px;
	resize: vertical;
	font-family: var(--font-mono);
	font-size: 12.5px;
	line-height: 1.55;
}
.select {
	appearance: none;
	background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
	background-repeat: no-repeat;
	background-position: right 10px center;
	padding-right: 30px;
}
.form-grid {
	display: grid;
	gap: 13px;
}
.form-grid.cols-3 {
	grid-template-columns: repeat(3, 1fr);
}
.form-grid.cols-2 {
	grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 700px) {
	.form-grid.cols-3,
	.form-grid.cols-2 {
		grid-template-columns: 1fr;
	}
}
.fieldset {
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.fieldset > .legend {
	font-size: 11.5px;
	color: var(--muted);
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}
.check-list {
	display: flex;
	flex-direction: column;
	gap: 4px;
	max-height: 210px;
	overflow: auto;
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 7px;
}
.check-row {
	display: flex;
	align-items: center;
	gap: 9px;
	font-size: 13px;
	padding: 5px 7px;
	border-radius: 6px;
	cursor: pointer;
}
.check-row:hover {
	background: var(--surface-2);
}
.check-row input {
	width: auto;
}

.switch {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 9px;
	cursor: pointer;
	font-size: 13px;
}
.switch input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}
.switch .track {
	width: 38px;
	height: 22px;
	border-radius: 999px;
	background: var(--border-strong);
	transition: background 0.15s;
	flex: none;
}
.switch .track::after {
	content: '';
	display: block;
	width: 16px;
	height: 16px;
	border-radius: 999px;
	background: var(--surface);
	margin: 3px;
	transition: transform 0.15s;
}
.switch input:checked + .track {
	background: var(--accent);
}
.switch input:checked + .track::after {
	transform: translateX(16px);
}

.tbl-wrap {
	overflow: auto;
	border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
table {
	width: 100%;
	border-collapse: collapse;
	font-size: 13px;
}
thead th {
	position: sticky;
	top: 0;
	background: var(--surface-2);
	text-align: left;
	font-family: var(--font-mono);
	font-size: 10.5px;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	color: var(--muted);
	font-weight: 600;
	padding: 10px 14px;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
tbody td {
	padding: 11px 14px;
	border-bottom: 1px solid var(--border);
	vertical-align: middle;
}
tbody tr:last-child td {
	border-bottom: none;
}
tbody tr:hover {
	background: var(--surface-2);
}
td.num,
th.num {
	text-align: right;
	font-family: var(--font-mono);
	font-variant-numeric: tabular-nums;
}
.tbl-check {
	width: 16px;
	height: 16px;
	accent-color: var(--accent);
}
.cell-main {
	font-weight: 600;
}
.cell-sub {
	color: var(--muted);
	font-size: 11.5px;
	margin-top: 1px;
}

.bars {
	display: flex;
	flex-direction: column;
	gap: 9px;
}
.bar-row {
	display: grid;
	grid-template-columns: 150px 1fr 74px;
	gap: 12px;
	align-items: center;
}
.bar-row .lbl {
	font-size: 12.5px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.bar-track {
	height: 18px;
	background: var(--surface-2);
	border-radius: 999px;
	overflow: hidden;
	display: flex;
}
.bar-fill {
	height: 100%;
	min-width: 2px;
}
.bar-val {
	text-align: right;
	font-family: var(--font-mono);
	font-size: 12px;
	color: var(--muted);
}

.list {
	display: flex;
	flex-direction: column;
}
.list-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 18px;
	border-bottom: 1px solid var(--border);
}
.list-row:last-child {
	border-bottom: none;
}
.list-row .grow {
	min-width: 0;
}
.list-row .t {
	font-weight: 600;
	font-size: 13px;
}
.list-row .s {
	color: var(--muted);
	font-size: 11.5px;
	margin-top: 1px;
}

.meter {
	height: 7px;
	border-radius: 999px;
	background: var(--surface-2);
	overflow: hidden;
	margin-top: 7px;
}
.meter > i {
	display: block;
	height: 100%;
	border-radius: 999px;
}

.empty {
	text-align: center;
	padding: 42px 20px;
	color: var(--muted);
}

.modal {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 22px;
	background: oklch(22% 0.02 240 / 0.42);
	backdrop-filter: blur(2px);
}
.modal.on {
	display: flex;
}
.modal-card {
	background: var(--surface);
	border-radius: var(--radius-lg);
	width: 100%;
	max-width: 560px;
	max-height: 88vh;
	display: flex;
	flex-direction: column;
	box-shadow: 0 24px 60px oklch(22% 0.02 240 / 0.28);
}
.modal-card.wide {
	max-width: 760px;
}
.modal-hd {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid var(--border);
}
.modal-hd h3 {
	margin: 0;
	font-size: 15px;
	font-weight: 650;
}
.modal-bd {
	padding: 20px;
	overflow: auto;
}
.modal-ft {
	display: flex;
	justify-content: flex-end;
	gap: 9px;
	padding: 14px 20px;
	border-top: 1px solid var(--border);
}

#toasts,
.toasts {
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 200;
	display: flex;
	flex-direction: column;
	gap: 9px;
}
.toast {
	background: var(--rail);
	color: var(--rail-fg);
	padding: 11px 15px;
	border-radius: 10px;
	font-size: 13px;
	box-shadow: var(--shadow);
	display: flex;
	align-items: center;
	gap: 9px;
	animation: pop 0.2s ease;
}
.toast .dot {
	width: 8px;
	height: 8px;
	border-radius: 999px;
	background: var(--accent);
}
.toast.danger .dot {
	background: var(--danger);
}
@keyframes pop {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.banner {
	border-radius: 10px;
	padding: 11px 14px;
	font-size: 12.5px;
	display: flex;
	gap: 9px;
	align-items: flex-start;
}
.banner.info {
	background: var(--info-soft);
	color: oklch(42% 0.12 252);
}
.banner.ok {
	background: var(--ok-soft);
	color: var(--ok);
}
.banner.warn {
	background: var(--warn-soft);
	color: oklch(46% 0.13 72);
}
.banner.danger {
	background: var(--danger-soft);
	color: var(--danger);
}
.banner[hidden] {
	display: none;
}
.banner svg {
	width: 16px;
	height: 16px;
	flex: none;
	margin-top: 1px;
}

.code {
	font-family: var(--font-mono);
	font-size: 12px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 10px 12px;
	overflow: auto;
	white-space: pre;
}
.kv {
	display: flex;
	justify-content: space-between;
	gap: 14px;
	padding: 8px 0;
	border-bottom: 1px dashed var(--border);
	font-size: 13px;
}
.kv:last-child {
	border-bottom: none;
}
.kv .k {
	color: var(--muted);
}
.kv .v {
	font-family: var(--font-mono);
	text-align: right;
}

.msg {
	padding: 13px 15px;
	border-radius: 12px;
	max-width: 78%;
	font-size: 13.5px;
	line-height: 1.6;
}
.msg.user {
	background: var(--accent-soft);
	align-self: flex-end;
	border-bottom-right-radius: 4px;
}
.msg.assistant {
	background: var(--surface-2);
	align-self: flex-start;
	border-bottom-left-radius: 4px;
}
.thread {
	display: flex;
	flex-direction: column;
	gap: 14px;
}
.msg {
	position: relative;
}
.msg-actions {
	position: absolute;
	top: 6px;
	right: 6px;
	display: flex;
	gap: 3px;
	opacity: 0;
	transition: opacity 0.15s;
	z-index: 2;
}
.msg:hover .msg-actions,
.msg:focus-within .msg-actions {
	opacity: 1;
}
.msg-actions .mbtn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 25px;
	height: 25px;
	padding: 0;
	border: 1px solid var(--border);
	border-radius: 7px;
	background: var(--surface);
	color: var(--muted);
	cursor: pointer;
	transition:
		color 0.12s,
		border-color 0.12s,
		background 0.12s;
}
.msg-actions .mbtn:hover {
	color: var(--fg);
	border-color: var(--border-strong);
	background: var(--surface-2);
}
.msg-actions .mbtn.danger:hover {
	color: var(--danger);
	border-color: var(--danger);
}
.msg-actions .mbtn.ok {
	color: var(--accent);
	border-color: var(--accent);
}
.msg.editing {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
.msg-edit {
	width: 100%;
	min-height: 96px;
	border: 1px solid var(--border-strong);
	border-radius: 8px;
	background: var(--surface);
	color: var(--fg);
	font: inherit;
	font-size: 13px;
	line-height: 1.55;
	padding: 9px 11px;
	resize: vertical;
	outline: none;
}
.msg-edit:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}
.msg-edit-actions {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	margin-top: 8px;
}
.msg-raw {
	margin: 0;
	font-family: var(--font-mono);
	font-size: 12px;
	line-height: 1.6;
	white-space: pre-wrap;
	word-break: break-word;
	background: oklch(24% 0.02 250);
	color: oklch(90% 0.01 250);
	border-radius: 8px;
	padding: 10px 12px;
	overflow: auto;
	max-height: 320px;
}
.msg-foot {
	margin-top: 9px;
	padding-top: 7px;
	border-top: 1px dashed var(--border);
	font-size: 11px;
	line-height: 1.4;
	color: var(--muted);
	font-family: var(--font-mono);
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}
.msg-foot .mf-time {
	color: var(--fg);
	opacity: 0.72;
}
.msg-foot .mf-model {
	color: var(--fg);
	opacity: 0.72;
}
.msg-foot .mf-tok {
	color: var(--fg);
	opacity: 0.72;
	cursor: help;
	text-decoration: underline dotted;
	text-underline-offset: 2px;
}
.msg-foot .mf-sep {
	opacity: 0.45;
}
.msg-think {
	margin: 0 0 9px;
	border-left: 3px solid var(--accent);
	background: var(--accent-soft);
	border-radius: 8px;
	overflow: hidden;
	font-size: 12px;
}
.msg-think > summary {
	display: flex;
	align-items: center;
	gap: 7px;
	padding: 6px 10px;
	cursor: pointer;
	color: oklch(42% 0.12 150);
	font-weight: 600;
	font-size: 11.5px;
	user-select: none;
	list-style: none;
}
.msg-think > summary::-webkit-details-marker {
	display: none;
}
.msg-think > summary svg {
	display: inline-flex;
	flex: none;
}
.msg-think .mt-meta {
	margin-left: auto;
	display: inline-flex;
	align-items: center;
	gap: 7px;
}
.msg-think .mt-time {
	font-family: var(--font-mono);
	font-size: 10px;
	font-weight: 600;
	color: var(--muted);
}
.msg-think .mt-level {
	font-family: var(--font-mono);
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--muted);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 1px 7px;
}
.msg-think[open] > summary {
	border-bottom: 1px solid color-mix(in oklch, var(--accent) 30%, transparent);
}
.msg-think .mt-body {
	padding: 7px 11px 9px;
	color: var(--muted);
	font-family: var(--font-mono);
	font-size: 11.5px;
	line-height: 1.7;
}
.composer {
	border: 1px solid var(--border-strong);
	border-radius: 12px;
	background: var(--surface);
	padding: 10px 10px 9px;
	transition:
		border-color 0.12s,
		box-shadow 0.12s;
}
.composer:focus-within {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}
.composer textarea {
	width: 100%;
	border: none;
	outline: none;
	resize: none;
	min-height: 44px;
	font-size: 13.5px;
	line-height: 1.5;
	background: transparent;
}
.composer .row {
	padding: 0 2px;
	gap: 8px;
}
.composer .icon-btn {
	width: 26px;
	height: 26px;
	border-radius: 7px;
}

.chat-shell {
	display: grid;
	grid-template-columns: 232px minmax(0, 1fr);
	flex: 1;
	min-height: 0;
}
.chat-sessions {
	display: flex;
	flex-direction: column;
	min-width: 0;
	background: var(--surface-2);
	border-right: 1px solid var(--border);
	border-bottom-left-radius: var(--radius-lg);
}
.chat-sessions-hd {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 13px 20px 10px;
	border-bottom: 1px solid var(--border);
}
.chat-sessions-hd .lbl {
	font-family: var(--font-mono);
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: 0.13em;
	color: var(--muted);
}
.chat-sessions-list {
	flex: 1;
	overflow: auto;
	padding: 8px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.chat-sessions-list::-webkit-scrollbar {
	width: 6px;
}
.chat-sessions-list::-webkit-scrollbar-thumb {
	background: var(--border-strong);
	border-radius: 999px;
}
.cs-item {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 3px;
	padding: 9px 12px;
	border-radius: var(--radius);
	border: 1px solid transparent;
	text-align: left;
	width: 100%;
	cursor: pointer;
	background: transparent;
	transition:
		background 0.12s,
		border-color 0.12s,
		box-shadow 0.12s;
}
.cs-item:hover {
	background: var(--fg-soft);
}
.cs-item.on {
	background: var(--surface);
	border-color: var(--border);
	box-shadow: var(--shadow);
}
.cs-item.on::before {
	content: '';
	position: absolute;
	left: 0;
	top: 10px;
	bottom: 10px;
	width: 3px;
	border-radius: 0 3px 3px 0;
	background: var(--accent);
}
.cs-item:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}
.cs-item .cs-t {
	font-size: 13px;
	font-weight: 600;
	line-height: 1.35;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	padding-right: 28px;
}
.cs-item.on .cs-t {
	color: var(--fg);
}
.cs-item .cs-m {
	font-family: var(--font-mono);
	font-size: 10.5px;
	color: var(--muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.cs-del {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	width: 22px;
	height: 22px;
	border-radius: 6px;
	display: grid;
	place-items: center;
	color: var(--muted);
	opacity: 0;
	transition:
		opacity 0.12s,
		background 0.12s,
		color 0.12s;
}
.cs-item.on .cs-del {
	opacity: 0.45;
}
.cs-item:hover .cs-del,
.cs-item:focus-within .cs-del {
	opacity: 0.8;
}
.cs-del:hover,
.cs-del:focus-visible {
	opacity: 1;
	background: var(--danger-soft);
	color: var(--danger);
}
.cs-del svg {
	width: 12px;
	height: 12px;
}
.cs-new {
	width: 26px;
	height: 26px;
	border-radius: 7px;
	display: grid;
	place-items: center;
	color: var(--muted);
	border: 1px solid var(--border);
	background: var(--surface);
	transition:
		background 0.12s,
		color 0.12s,
		border-color 0.12s;
}
.cs-new:hover {
	color: oklch(22% 0.03 150);
	background: var(--accent);
	border-color: var(--accent);
}
.cs-new svg {
	width: 14px;
	height: 14px;
}
.cs-rename {
	width: 100%;
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	border: 1px solid var(--accent);
	border-radius: 7px;
	padding: 4px 8px;
	background: var(--surface);
	outline: none;
	box-shadow: 0 0 0 3px var(--accent-soft);
}
.chat-pane {
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 0;
}
@media (max-width: 760px) {
	.chat-shell {
		grid-template-columns: 1fr;
	}
	.chat-sessions {
		border-right: none;
		border-bottom: 1px solid var(--border);
		border-radius: 0;
		max-height: 200px;
	}
}

.step {
	display: flex;
	gap: 12px;
}
.step .n {
	width: 24px;
	height: 24px;
	border-radius: 999px;
	border: 1px solid var(--border-strong);
	display: grid;
	place-items: center;
	font-family: var(--font-mono);
	font-size: 12px;
	flex: none;
	color: var(--muted);
}
.step.done .n {
	background: var(--accent);
	color: oklch(22% 0.03 150);
	border-color: var(--accent);
}
.step.on .n {
	border-color: var(--accent);
	color: var(--accent);
	font-weight: 700;
}
.step .body {
	padding-bottom: 16px;
}
.switch-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 11px 0;
	border-bottom: 1px solid var(--border);
}
.switch-row:last-child {
	border-bottom: none;
}
.switch-row .t {
	font-size: 13px;
	font-weight: 500;
}
.switch-row .s {
	font-size: 11.5px;
	color: var(--muted);
	margin-top: 2px;
	max-width: 52ch;
}
.mock-block {
	border: 1px solid var(--border);
	border-radius: 10px;
	overflow: hidden;
}
.mock-hd {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 11px 13px;
	background: var(--surface-2);
	border: 0;
	cursor: pointer;
	font: inherit;
	color: inherit;
	text-align: left;
}
.mock-hd .mock-title {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}
.mock-hd .mock-title svg {
	width: 14px;
	height: 14px;
	color: var(--accent);
	flex: none;
}
.mock-hd .t {
	font-size: 13px;
	font-weight: 600;
}
.mock-hd .mock-chev {
	display: inline-flex;
}
.mock-hd .mock-chev svg {
	width: 14px;
	height: 14px;
	transition: transform 0.15s;
	color: var(--muted);
	flex: none;
}
.mock-hd[aria-expanded='true'] .mock-chev svg {
	transform: rotate(180deg);
}
.mock-bd {
	padding: 2px 13px 13px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.mock-preview {
	margin-top: 6px;
	font-size: 11.5px;
	color: var(--muted);
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 8px 10px;
	max-height: 96px;
	overflow: auto;
	white-space: pre-wrap;
	word-break: break-word;
}
.seg {
	display: inline-flex;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 2px;
}
.seg button {
	padding: 5px 12px;
	border-radius: 6px;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--muted);
}
.seg button.on {
	background: var(--surface);
	color: var(--fg);
	box-shadow: 0 1px 2px oklch(22% 0.02 240 / 0.08);
}
.seg button:focus {
	outline: none;
}
.seg button:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}
.chat-settings-trigger {
	display: none;
}
.raw-toolbar {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}
.raw-badge {
	color: var(--accent);
	border-color: var(--accent);
}
.raw-endpoint {
	font-family: var(--font-mono);
	font-size: 11.5px;
	color: var(--muted);
}
.raw-sec-hd {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 2px 0 0;
}
.raw-sec-hd h4 {
	margin: 0;
	font-size: 12.5px;
	font-weight: 600;
}
.raw-editor {
	width: 100%;
	min-height: 190px;
	flex: 1 1 auto;
	border: 1px solid var(--border);
	border-radius: 10px;
	background: oklch(24% 0.02 250);
	color: oklch(91% 0.01 250);
	font-family: var(--font-mono);
	font-size: 12px;
	line-height: 1.65;
	padding: 14px 16px;
	resize: vertical;
	white-space: pre;
	overflow: auto;
	tab-size: 2;
}
.raw-editor:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}
.raw-resp {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
	align-items: stretch;
}
.raw-pane {
	display: flex;
	flex-direction: column;
	min-width: 0;
}
.raw-pane h4 {
	margin: 0 0 8px;
	font-size: 11px;
	font-weight: 600;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}
.raw-out {
	margin: 0;
	flex: 1;
	min-height: 210px;
	max-height: 340px;
	overflow: auto;
	background: oklch(24% 0.02 250);
	color: oklch(88% 0.01 250);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 12px 14px;
	font-family: var(--font-mono);
	font-size: 11.5px;
	line-height: 1.6;
	white-space: pre-wrap;
	word-break: break-word;
}
.raw-rendered {
	flex: 1;
	min-height: 210px;
	max-height: 340px;
	overflow: auto;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 14px 16px;
	font-size: 13.5px;
	line-height: 1.7;
}
.raw-rendered p {
	margin: 0 0 10px;
}
.raw-rendered p:last-child {
	margin-bottom: 0;
}
.raw-rendered ul {
	margin: 0 0 10px;
	padding-left: 20px;
}
.raw-rendered li {
	margin: 3px 0;
}
.raw-rendered code {
	font-family: var(--font-mono);
	font-size: 12px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 5px;
	padding: 1px 5px;
}
.raw-rendered pre {
	margin: 0 0 10px;
	background: oklch(24% 0.02 250);
	color: oklch(90% 0.01 250);
	border-radius: 8px;
	padding: 12px 14px;
	overflow: auto;
	font-family: var(--font-mono);
	font-size: 12px;
	line-height: 1.6;
}
.raw-cursor::after {
	content: '▋';
	color: var(--accent);
	margin-left: 1px;
}
@media (max-width: 1180px) {
	.chat-settings-card {
		display: none;
	}
	.chat-settings-trigger {
		display: inline-flex;
	}
}
@media (max-width: 820px) {
	.raw-resp {
		grid-template-columns: 1fr;
	}
	.raw-out,
	.raw-rendered {
		max-height: 260px;
	}
}
.model-row {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 12px;
	border: 1px solid var(--border);
	border-radius: 9px;
	background: var(--surface);
}
.model-row .grow {
	min-width: 0;
}
.model-row .id {
	font-family: var(--font-mono);
	font-size: 12.5px;
	font-weight: 600;
}
.pool-card {
	padding: 16px 18px;
	cursor: pointer;
	transition:
		border-color 0.12s,
		transform 0.08s;
}
.pool-card:hover {
	border-color: var(--border-strong);
	transform: translateY(-1px);
}
.pool-card.on {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}

.overlay-scrim {
	display: none;
}
@media (max-width: 980px) {
	.app {
		grid-template-columns: 1fr;
	}
	.rail {
		position: fixed;
		left: 0;
		top: 0;
		width: 250px;
		transform: translateX(-100%);
		transition: transform 0.22s ease;
	}
	.app.nav-open .rail {
		transform: none;
	}
	.app.nav-open .overlay-scrim {
		display: block;
		position: fixed;
		inset: 0;
		background: oklch(22% 0.02 240 / 0.4);
		z-index: 35;
	}
	.hamburger {
		display: grid;
	}
	.content {
		padding: 18px 16px 60px;
	}
	.topbar {
		padding: 10px 16px;
	}
}
@media (max-width: 560px) {
	.topbar .sub {
		display: none;
	}
}

.gate {
	position: fixed;
	inset: 0;
	z-index: 120;
	display: grid;
	place-items: center;
	padding: 24px;
	background: var(--rail);
}
.gate::after {
	content: '';
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: radial-gradient(760px 460px at 80% 4%, color-mix(in oklch, var(--accent) 22%, transparent), transparent 62%);
}
.gate.hidden {
	display: none;
}
.gate-card {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 460px;
	background: var(--surface);
	border-radius: var(--radius-lg);
	box-shadow: 0 24px 70px oklch(0% 0 0 / 0.45);
	padding: 30px 28px;
}
.gate-brand {
	display: flex;
	align-items: center;
	gap: 11px;
	margin-bottom: 22px;
}
.gate-brand .mark {
	width: 34px;
	height: 34px;
	border-radius: 9px;
	background: var(--accent);
	display: grid;
	place-items: center;
	color: oklch(22% 0.03 150);
}
.gate-brand .mark svg {
	width: 19px;
	height: 19px;
}
.gate-brand b {
	font-size: 16px;
	font-weight: 700;
}
.gate-brand span {
	display: block;
	font-family: var(--font-mono);
	font-size: 10.5px;
	letter-spacing: 0.08em;
	color: var(--muted);
}
.gate h2 {
	margin: 0 0 6px;
	font-size: 20px;
	font-weight: 700;
	letter-spacing: -0.015em;
}
.gate p {
	margin: 0 0 20px;
	color: var(--muted);
	font-size: 13px;
	line-height: 1.6;
}
.gate .input {
	font-family: var(--font-mono);
}
.gate-err {
	color: var(--danger);
	font-size: 12px;
	margin-top: 8px;
	display: none;
}
.gate-types {
	display: grid;
	gap: 8px;
	margin: 18px 0 0;
	font-size: 12px;
	color: var(--muted);
}
.gate-types .row {
	gap: 8px;
}
.gate-types code {
	font-family: var(--font-mono);
	color: var(--fg);
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 1px 6px;
}
