/* =========================================================================
   Pi Web Console — 设计系统 v2 (beautifului.dev 风格)
   OKLCH 色彩 / Glass Morphism / Geist Mono / 现代化组件
   ========================================================================= */
@import url("https://fonts.googleapis.com/css2?family=Geist+Mono:wght@100..900&display=swap");

:root {
	--page: oklch(98.5% 0.001 286.376);
	--canvas: oklch(96.1% 0.002 247.84);
	--surface: oklch(100% 0 0);
	--inset: oklch(97.9% 0.002 247.839);
	--hover: oklch(97% 0.002 247.839);
	--hover-2: oklch(93.3% 0.003 247.86);
	--ink: oklch(24.7% 0.006 258.361);
	--ink-2: oklch(50.6% 0.01 264.477);
	--ink-3: oklch(69.5% 0.009 264.505);
	--line: oklch(94.6% 0.003 264.542);
	--line-strong: oklch(91.2% 0.005 258.326);
	--field: oklch(96.1% 0.001 286.375);
	--accent: oklch(62.6% 0.205 254.947);
	--accent-ink: oklch(55.6% 0.187 255.617);
	--accent-tint: oklch(96% 0.019 252.878);
	--green: oklch(60.3% 0.155 150.883);
	--green-tint: oklch(95.8% 0.017 159.118);
	--orange: oklch(68.9% 0.179 49.902);
	--orange-tint: oklch(96.4% 0.021 67.581);
	--red: oklch(62.1% 0.192 23.042);
	--red-tint: oklch(95.6% 0.017 17.462);
	--tooltip-bg: oklch(27.2% 0.008 264.435);
	--tooltip-fg: oklch(97.6% 0.002 247.839);
	--tooltip-border: oklch(35.6% 0.007 264.474);
	--shadow-xs: 0 1px 2px oklch(0% 0 0 / 0.04);
	--shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.05), 0 2px 6px oklch(0% 0 0 / 0.04);
	--shadow-md: 0 2px 4px oklch(0% 0 0 / 0.06), 0 4px 12px oklch(0% 0 0 / 0.08);
	--shadow-lg: 0 4px 8px oklch(0% 0 0 / 0.08), 0 8px 24px oklch(0% 0 0 / 0.12);
	--shadow-overlay: 0 0 0 1px var(--line), var(--shadow-lg);
	--shadow-btn: 0 0 0 1px var(--line-strong), var(--shadow-xs);
	--shadow-card: 0 0 0 1px var(--line), var(--shadow-sm);
	--shadow-inset-field: inset 0 1px 2px oklch(0% 0 0 / 0.08);
	--r-xs: 4px;
	--r-sm: 6px;
	--r-md: 8px;
	--r-lg: 12px;
	--r-xl: 16px;
	--r-full: 999px;
	--sp-1: 4px;
	--sp-2: 8px;
	--sp-3: 12px;
	--sp-4: 16px;
	--sp-5: 20px;
	--sp-6: 24px;
	--sp-7: 32px;
	--sp-8: 40px;
	--font:
		"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
		sans-serif;
	--font-mono:
		"Geist Mono", "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas,
		monospace;
	--ease: cubic-bezier(0.22, 1, 0.36, 1);
	--ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
	--dur-s: 150ms;
	--dur-m: 250ms;
	--dur-l: 400ms;
	--sidebar-w: 300px;
	--inspector-w: 320px;
	--chat-max: 900px;
	--glass-blur: 20px;
	--bg: var(--page);
	--bg-elev: var(--surface);
	--bg-sidebar: var(--canvas);
	--bg-hover: var(--hover);
	--bg-active: var(--hover-2);
	--border: var(--line);
	--border-strong: var(--line-strong);
	--text: var(--ink);
	--text-2: var(--ink-2);
	--muted: var(--ink-3);
	--ok: var(--green);
	--ok-soft: var(--green-tint);
	--warn: var(--orange);
	--warn-soft: var(--orange-tint);
	--danger: var(--red);
	--danger-soft: var(--red-tint);
	--accent-soft: var(--accent-tint);
	--accent-strong: var(--accent-ink);
	--accent-fg: oklch(99% 0.001 286);
	--code-bg: oklch(15% 0.004 264.5);
	--code-text: oklch(92% 0.003 264.5);
	--tool-bg: var(--inset);
	--scrim: oklch(0% 0 0 / 0.4);
	--ring: 0 0 0 3px oklch(62.6% 0.205 254.947 / 0.2);
	color-scheme: light;
}
[data-theme="dark"] {
	--page: oklch(15% 0.004 264.477);
	--canvas: oklch(18% 0.004 264.487);
	--surface: oklch(21% 0.006 271.191);
	--inset: oklch(19% 0.004 264.492);
	--hover: oklch(24% 0.006 271.22);
	--hover-2: oklch(28% 0.007 274.747);
	--ink: oklch(96.4% 0.002 247.839);
	--ink-2: oklch(73.1% 0.008 260.731);
	--ink-3: oklch(54.1% 0.01 264.484);
	--line: oklch(28% 0.006 258.354);
	--line-strong: oklch(33% 0.007 264.474);
	--field: oklch(24% 0.006 271.223);
	--accent: oklch(68% 0.173 253.301);
	--accent-ink: oklch(78.8% 0.113 248.33);
	--accent-tint: oklch(68% 0.173 253.301 / 0.16);
	--green: oklch(70.5% 0.154 153.814);
	--green-tint: oklch(70.5% 0.154 153.814 / 0.14);
	--orange: oklch(74.6% 0.156 55.642);
	--orange-tint: oklch(74.6% 0.156 55.642 / 0.14);
	--red: oklch(66.6% 0.18 21.433);
	--red-tint: oklch(66.6% 0.18 21.433 / 0.14);
	--shadow-btn: 0 0 0 1px oklch(100% 0 0 / 0.1), 0 1px 2px oklch(0% 0 0 / 0.3);
	--shadow-card:
		0 0 0 1px oklch(100% 0 0 / 0.11), 0 1px 2px oklch(0% 0 0 / 0.2),
		0 2px 6px oklch(0% 0 0 / 0.2);
	--shadow-overlay:
		0 0 0 1px oklch(100% 0 0 / 0.15), 0 8px 28px oklch(0% 0 0 / 0.34);
	--shadow-inset-field: inset 0 1px 2px oklch(0% 0 0 / 0.4);
	--code-bg: oklch(10% 0.004 264.5);
	--code-text: oklch(88% 0.003 264.5);
	--scrim: oklch(0% 0 0 / 0.6);
	--ring: 0 0 0 3px oklch(68% 0.173 253.301 / 0.25);
	color-scheme: dark;
}
*,
*::before,
*::after {
	box-sizing: border-box;
}
html,
body {
	margin: 0;
	height: 100%;
	font-family: var(--font);
	color: var(--text);
	background: var(--bg);
	font-size: 14px;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
}
::selection {
	background: var(--accent);
	color: oklch(99% 0 0);
}
.svg-sprite {
	position: absolute;
	width: 0;
	height: 0;
	overflow: hidden;
}
.ic {
	width: 18px;
	height: 18px;
	display: inline-block;
	vertical-align: -3px;
	flex-shrink: 0;
}
a {
	color: var(--accent);
}
:focus {
	outline: none;
}
:focus-visible {
	outline: none;
	box-shadow: var(--ring);
	border-radius: var(--r-sm);
}

/* Layout */
#app {
	display: grid;
	grid-template-columns: var(--sidebar-w) 1fr 0px;
	height: 100dvh;
	overflow: hidden;
	position: relative;
	transition: grid-template-columns var(--dur-l) var(--ease);
}
body.inspector-open #app {
	grid-template-columns: var(--sidebar-w) 1fr var(--inspector-w);
}
#app::before {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 2px;
	background: linear-gradient(
		90deg,
		var(--accent) 0%,
		var(--accent) 20%,
		transparent 60%
	);
	z-index: 70;
	pointer-events: none;
}

/* Buttons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	border: none;
	background: var(--surface);
	color: var(--text);
	padding: 8px 16px;
	border-radius: var(--r-md);
	cursor: pointer;
	font-size: 13px;
	font-weight: 600;
	font-family: inherit;
	line-height: 1.2;
	transition: all var(--dur-s) var(--ease);
	box-shadow: var(--shadow-btn);
	user-select: none;
	white-space: nowrap;
	position: relative;
	overflow: hidden;
}
.btn::before {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		180deg,
		oklch(100% 0 0 / 0.06) 0%,
		oklch(100% 0 0 / 0) 100%
	);
	pointer-events: none;
}
.btn:hover {
	background: var(--hover);
	box-shadow: var(--shadow-card);
	transform: translateY(-1px);
}
.btn:active {
	transform: translateY(0) scale(0.98);
	box-shadow: var(--shadow-btn);
}
.btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	transform: none;
	box-shadow: none;
}
.btn-primary {
	background: var(--accent);
	color: oklch(99% 0 0);
	box-shadow:
		0 0 0 1px var(--accent-ink),
		var(--shadow-sm);
}
.btn-primary::before {
	background: linear-gradient(
		180deg,
		oklch(100% 0 0 / 0.15) 0%,
		oklch(100% 0 0 / 0) 100%
	);
}
.btn-primary:hover {
	background: var(--accent-ink);
	box-shadow:
		0 0 0 1px var(--accent-ink),
		var(--shadow-md);
}
.btn-danger {
	background: var(--red-tint);
	color: var(--red);
	box-shadow: 0 0 0 1px oklch(62.1% 0.192 23.042 / 0.2);
}
.btn-danger:hover {
	background: var(--red);
	color: oklch(99% 0 0);
}
.btn-ghost {
	background: transparent;
	box-shadow: none;
	color: var(--ink-2);
}
.btn-ghost:hover {
	background: var(--hover);
	color: var(--text);
}
.btn-sm {
	padding: 5px 10px;
	font-size: 12px;
}
.btn-block {
	width: 100%;
}
.icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: none;
	background: transparent;
	color: var(--ink-2);
	border-radius: var(--r-sm);
	cursor: pointer;
	transition: all var(--dur-s) var(--ease);
}
.icon-btn:hover {
	background: var(--hover);
	color: var(--text);
}
.icon-btn:active {
	transform: scale(0.92);
}

/* Tooltip */
.tt {
	position: fixed;
	z-index: 9999;
	pointer-events: none;
	max-width: 280px;
	padding: 6px 10px;
	border-radius: var(--r-sm);
	background: var(--tooltip-bg);
	color: var(--tooltip-fg);
	font-size: 12px;
	line-height: 1.45;
	font-weight: 500;
	white-space: pre-line;
	box-shadow: var(--shadow-overlay);
	border: 1px solid var(--tooltip-border);
	opacity: 0;
	transform: translateY(4px) scale(0.97);
	transition:
		opacity var(--dur-s) var(--ease),
		transform var(--dur-s) var(--ease);
	will-change: opacity, transform;
}
.tt.is-show {
	opacity: 1;
	transform: translateY(0) scale(1);
}
.tt::before {
	content: "";
	position: absolute;
	width: 8px;
	height: 8px;
	background: var(--tooltip-bg);
	border-left: 1px solid var(--tooltip-border);
	border-top: 1px solid var(--tooltip-border);
	left: var(--tt-ax, 50%);
	margin-left: -4px;
	transform: rotate(45deg);
}
.tt[data-pos="bottom"]::before {
	top: -5px;
}
.tt[data-pos="top"]::before {
	bottom: -5px;
	transform: rotate(225deg);
}

/* Forms */
.select,
.search,
textarea,
.modal input[type="text"] {
	font-family: inherit;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	transition: all var(--dur-s) var(--ease);
	box-shadow: var(--shadow-inset-field);
}
.select:focus,
.search:focus,
textarea:focus,
.modal input[type="text"]:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: var(--ring);
}
.select {
	width: 100%;
	padding: 7px 30px 7px 10px;
	font-size: 12.5px;
	appearance: none;
	-webkit-appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 9px center;
	cursor: pointer;
}
.field {
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.field-label {
	font-size: 11px;
	color: var(--ink-3);
	font-weight: 500;
}
.search-wrap {
	position: relative;
	display: flex;
	align-items: center;
}
.search-wrap .ic {
	position: absolute;
	left: 9px;
	width: 14px;
	height: 14px;
	color: var(--ink-3);
	pointer-events: none;
}
.search {
	width: 100%;
	padding: 7px 10px 7px 30px;
	font-size: 12.5px;
}
.search::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

/* Sidebar */
#sidebar {
	background: var(--canvas);
	border-right: 1px solid var(--line);
	display: flex;
	flex-direction: column;
	padding: var(--sp-5) var(--sp-4) var(--sp-4);
	gap: var(--sp-4);
	overflow: hidden;
	min-height: 0;
	z-index: 60;
}
.side-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 700;
	font-size: 15px;
	letter-spacing: -0.02em;
}
.brand-mark {
	width: 28px;
	height: 28px;
	border-radius: var(--r-md);
	background: var(--accent);
	color: oklch(99% 0 0);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-family: var(--font-mono);
	font-size: 16px;
	font-weight: 700;
	box-shadow:
		0 0 0 1px var(--accent-ink),
		var(--shadow-sm);
}
.brand-name {
	font-family: var(--font-mono);
	letter-spacing: -0.02em;
}
#btn-sidebar-close {
	display: none;
}
.side-section {
	display: flex;
	flex-direction: column;
	gap: var(--sp-2);
	min-height: 0;
	flex-shrink: 0;
}
.side-history {
	flex: 1 1 0;
	min-height: 84px;
}
.side-title {
	font-family: var(--font-mono);
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--ink-3);
	display: flex;
	align-items: center;
	gap: 7px;
	justify-content: space-between;
}
.badge {
	background: var(--accent-tint);
	color: var(--accent);
	font-family: var(--font-mono);
	font-size: 10px;
	padding: 2px 7px;
	border-radius: var(--r-full);
	font-weight: 700;
	line-height: 1.4;
}
.session-list {
	list-style: none;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 2px;
	scrollbar-width: thin;
	mask-image: linear-gradient(
		to bottom,
		transparent 0,
		#000 10px,
		#000 calc(100% - 10px),
		transparent 100%
	);
	-webkit-mask-image: linear-gradient(
		to bottom,
		transparent 0,
		#000 10px,
		#000 calc(100% - 10px),
		transparent 100%
	);
}
.session-item {
	padding: 10px 12px;
	border-radius: var(--r-md);
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 13px;
	border: 1px solid transparent;
	transition: all var(--dur-s) var(--ease);
	animation: item-in var(--dur-m) var(--ease) both;
	position: relative;
}
.session-item:hover {
	background: var(--hover);
	border-color: var(--line);
}
.session-item:active {
	transform: scale(0.995);
}
.session-item.active {
	background: var(--accent-tint);
	border-color: oklch(62.6% 0.205 254.947 / 0.2);
}
.session-item .dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--line-strong);
	flex-shrink: 0;
	transition: all var(--dur-s);
}
.session-item.live .dot {
	background: var(--green);
	box-shadow: 0 0 0 3px var(--green-tint);
}
.session-item.turn-active .dot {
	background: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-tint);
	animation: pulse 1.4s ease-in-out infinite;
}
.session-item .txt {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.session-item .meta {
	font-size: 10px;
	color: var(--ink-3);
	flex-shrink: 0;
}
.session-item.disk-item {
	align-items: flex-start;
}
.session-item.disk-item .dot {
	margin-top: 5px;
}
.sess-name {
	font-size: 12px;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.sess-preview {
	font-size: 11px;
	color: var(--ink-3);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	margin-top: 1px;
}
.session-item .close {
	width: 20px;
	height: 20px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--r-sm);
	color: var(--ink-3);
	opacity: 0;
	transition: all var(--dur-s) var(--ease);
	flex-shrink: 0;
}
.session-item:hover .close,
.session-item:focus-within .close {
	opacity: 1;
}
.session-item .close:hover {
	background: var(--red-tint);
	color: var(--red);
}
.session-item .close .ic {
	width: 13px;
	height: 13px;
}
.session-item .close.del {
	font-size: 12px;
	line-height: 1;
}
.session-list-empty {
	padding: var(--sp-4) var(--sp-2);
	text-align: center;
	font-size: 12px;
	color: var(--ink-3);
}

/* Main */
#main {
	display: flex;
	flex-direction: column;
	min-width: 0;
	background: var(--page);
	position: relative;
	height: 100%;
	overflow: hidden;
}

/* Inspector */
#inspector {
	background: var(--canvas);
	border-left: 1px solid var(--line);
	display: flex;
	flex-direction: column;
	min-height: 0;
	min-width: 0;
	overflow: hidden;
	z-index: 60;
}
.insp-head {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 10px 10px 10px 14px;
	border-bottom: 1px solid var(--line);
}
.insp-tabs {
	display: flex;
	gap: 2px;
	flex: 1;
	min-width: 0;
}
.insp-tab {
	display: flex;
	align-items: center;
	gap: 6px;
	border: none;
	background: transparent;
	color: var(--ink-3);
	font-family: inherit;
	font-size: 12px;
	font-weight: 600;
	padding: 7px 11px;
	border-radius: var(--r-sm);
	cursor: pointer;
	white-space: nowrap;
	transition: all var(--dur-s) var(--ease);
}
.insp-tab .ic {
	width: 14px;
	height: 14px;
}
.insp-tab:hover {
	background: var(--hover);
	color: var(--text);
}
.insp-tab[aria-selected="true"] {
	background: var(--accent-tint);
	color: var(--accent);
}
.insp-actions {
	flex-shrink: 0;
	display: flex;
	gap: 6px;
	padding: 10px 14px;
	border-bottom: 1px solid var(--line);
}
.insp-actions .btn {
	flex: 1;
	padding: 6px 8px;
	font-size: 11px;
}
.insp-actions .ic {
	width: 13px;
	height: 13px;
}
.insp-body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 14px;
	scrollbar-width: thin;
}
.insp-pane {
	display: none;
}
.insp-pane.active {
	display: block;
	animation: fade-in var(--dur-m) var(--ease);
}
.insp-empty {
	color: var(--ink-3);
	font-size: 12px;
	text-align: center;
	padding: var(--sp-6) var(--sp-3);
}
.insp-empty .btn {
	margin-top: 10px;
}
.conn-banner {
	flex-shrink: 0;
	background: var(--orange-tint);
	color: var(--orange);
	font-size: 12px;
	font-weight: 600;
	padding: 8px var(--sp-4);
	display: flex;
	align-items: center;
	gap: 8px;
	animation: slide-down var(--dur-m) var(--ease);
}
.conn-banner[hidden] {
	display: none;
}
.conn-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--orange);
	animation: pulse 1.4s ease infinite;
}

/* Topbar */
#topbar {
	display: flex;
	align-items: center;
	gap: var(--sp-3);
	padding: 12px var(--sp-5);
	border-bottom: 1px solid var(--line);
	background: oklch(from var(--surface) l c h / 0.85);
	backdrop-filter: blur(var(--glass-blur));
	-webkit-backdrop-filter: blur(var(--glass-blur));
	flex-shrink: 0;
	position: relative;
	z-index: 5;
}
.topbar-spacer {
	flex: 1;
}
.topbar-actions {
	display: flex;
	align-items: center;
	gap: 2px;
}
.topbar-actions .divider {
	width: 1px;
	height: 20px;
	background: var(--line);
	margin: 0 6px;
}
#btn-sidebar-toggle {
	display: none;
}
.pill {
	font-family: var(--font-mono);
	font-size: 10px;
	padding: 4px 10px;
	border-radius: var(--r-full);
	border: none;
	font-weight: 700;
	white-space: nowrap;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	transition: all var(--dur-m);
}
.pill-offline {
	background: var(--red-tint);
	color: var(--red);
}
.pill-online {
	background: var(--green-tint);
	color: var(--green);
}
.pill-online::before {
	content: "";
	display: inline-block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--green);
	margin-right: 6px;
	vertical-align: 1px;
	animation: pulse 2s ease-in-out infinite;
}
.turn-indicator {
	font-family: var(--font-mono);
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--accent);
	background: var(--accent-tint);
	border: 1px solid oklch(62.6% 0.205 254.947 / 0.2);
	border-radius: var(--r-full);
	padding: 4px 10px 4px 8px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
	animation: fade-in var(--dur-m) var(--ease);
}
.turn-indicator[hidden] {
	display: none;
}
.turn-indicator::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--accent);
	animation: pulse 1.1s ease-in-out infinite;
}
.session-name {
	font-size: 13px;
	font-weight: 600;
	color: var(--ink-2);
	max-width: 260px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	padding: 4px 8px;
	border-radius: var(--r-sm);
	transition: all var(--dur-s);
	cursor: text;
}
.session-name:hover {
	background: var(--hover);
	color: var(--text);
}

/* Chat */
.chat {
	flex: 1;
	overflow-y: auto;
	padding: var(--sp-6) var(--sp-5) var(--sp-8);
	display: flex;
	flex-direction: column;
	gap: var(--sp-4);
	scroll-behavior: smooth;
	scrollbar-width: thin;
}
.chat > * {
	width: 100%;
	max-width: var(--chat-max);
	margin-inline: auto;
}
.msg {
	display: flex;
	flex-direction: column;
	animation: msg-in var(--dur-m) var(--ease) both;
}
.msg-user {
	align-items: flex-end;
	align-self: flex-end;
}
.msg-assistant {
	align-items: flex-start;
	align-self: flex-start;
}
.msg-actions {
	display: flex;
	gap: 2px;
	margin-top: 4px;
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--dur-s) var(--ease);
}
.msg-user:hover .msg-actions,
.msg-user:focus-within .msg-actions {
	opacity: 1;
	pointer-events: auto;
}
@media (hover: none) {
	.msg-actions {
		opacity: 0.7;
		pointer-events: auto;
	}
}
.msg-action-btn {
	border: none;
	background: transparent;
	color: var(--ink-3);
	font-family: inherit;
	font-size: 10px;
	padding: 3px 8px;
	border-radius: var(--r-xs);
	cursor: pointer;
	transition: all var(--dur-s);
}
.msg-action-btn:hover {
	background: var(--hover-2);
	color: var(--text);
}
.msg-empty-note {
	font-size: 11px;
	color: var(--ink-3);
	font-style: italic;
	padding: 1px 2px;
}

/* Bubbles */
.bubble {
	padding: 12px 16px;
	border-radius: var(--r-lg);
	max-width: 84%;
	overflow-wrap: anywhere;
	font-size: 14px;
	position: relative;
	line-height: 1.6;
}
.bubble::before {
	display: block;
	font-family: var(--font-mono);
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.1em;
	margin-bottom: 6px;
	opacity: 0.5;
}
.msg-user .bubble {
	background: var(--accent-tint);
	color: var(--text);
	border: 1px solid oklch(62.6% 0.205 254.947 / 0.15);
	border-right: 3px solid var(--accent);
}
.msg-user .bubble::before {
	content: "YOU";
	color: var(--accent);
	text-align: right;
}
.msg-assistant .bubble {
	background: var(--surface);
	border: 1px solid var(--line);
	border-left: 3px solid var(--line-strong);
	box-shadow: var(--shadow-card);
	max-width: 100%;
}
.msg-assistant .bubble::before {
	content: "PI";
	color: var(--ink-3);
}
.bubble h1,
.bubble h2,
.bubble h3,
.bubble h4 {
	margin: 0.6em 0 0.35em;
	line-height: 1.35;
	font-weight: 700;
}
.bubble h1 {
	font-size: 1.3em;
}
.bubble h2 {
	font-size: 1.18em;
}
.bubble h3 {
	font-size: 1.08em;
}
.bubble p {
	margin: 0.45em 0;
}
.bubble ul,
.bubble ol {
	margin: 0.45em 0;
	padding-left: 1.5em;
}
.bubble li {
	margin: 0.15em 0;
}
.bubble blockquote {
	margin: 0.45em 0;
	padding: 2px 12px;
	border-left: 3px solid var(--line-strong);
	color: var(--ink-2);
}
.bubble hr {
	border: none;
	border-top: 1px solid var(--line);
	margin: 0.7em 0;
}
.bubble code {
	font-family: var(--font-mono);
	font-size: 0.88em;
	background: var(--code-bg);
	color: var(--code-text);
	padding: 2px 6px;
	border-radius: var(--r-sm);
}
.bubble pre {
	background: var(--code-bg);
	color: var(--code-text);
	padding: 14px 16px;
	border-radius: var(--r-md);
	overflow-x: auto;
	margin: 0.6em 0;
	box-shadow: var(--shadow-inset-field);
}
.bubble pre code {
	background: transparent;
	padding: 0;
}
.bubble pre::-webkit-scrollbar {
	height: 8px;
}
.bubble pre::-webkit-scrollbar-thumb {
	background: oklch(100% 0 0 / 0.16);
	border-radius: 6px;
}
.bubble a {
	color: var(--accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}
.bubble img {
	max-width: 100%;
	border-radius: var(--r-md);
}
.bubble table {
	border-collapse: collapse;
	margin: 0.5em 0;
	font-size: 0.92em;
	display: block;
	overflow-x: auto;
	max-width: 100%;
}
.bubble th,
.bubble td {
	border: 1px solid var(--line-strong);
	padding: 6px 10px;
	text-align: left;
}
.bubble th {
	background: var(--inset);
	font-weight: 700;
}
.msg-user .bubble code {
	background: oklch(0% 0 0 / 0.06);
	color: var(--accent-ink);
}
.msg-user .bubble pre {
	background: var(--code-bg);
	color: var(--code-text);
}
.cursor {
	display: inline-block;
	width: 2px;
	height: 1.1em;
	background: var(--accent);
	margin-left: 2px;
	vertical-align: -2px;
	border-radius: 1px;
	animation: blink 1s steps(2, start) infinite;
}

/* Spinner - beautifului.dev 风格的像素动画 */
.spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	vertical-align: -2px;
	background: var(--accent);
	border-radius: 2px;
	animation: pixel-spin 1.2s ease-in-out infinite;
}
@keyframes pixel-spin {
	0% {
		transform: rotate(0deg);
		opacity: 1;
	}
	25% {
		transform: rotate(90deg);
		opacity: 0.7;
	}
	50% {
		transform: rotate(180deg);
		opacity: 0.5;
	}
	75% {
		transform: rotate(270deg);
		opacity: 0.7;
	}
	100% {
		transform: rotate(360deg);
		opacity: 1;
	}
}

/* Thinking - beautifului.dev 风格 */
.thinking {
	margin-top: 10px;
	max-width: 100%;
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	background: var(--surface);
	font-size: 13px;
	color: var(--ink-2);
	overflow: hidden;
	transition: all 300ms cubic-bezier(0.23, 1, 0.32, 1);
}
.thinking:hover {
	border-color: var(--accent);
	box-shadow: var(--shadow-card);
}
.thinking summary {
	cursor: pointer;
	padding: 10px 14px;
	font-weight: 500;
	user-select: none;
	display: flex;
	align-items: center;
	gap: 10px;
	list-style: none;
	transition: background 100ms ease;
}
.thinking summary:hover {
	background: var(--hover-2);
}
.thinking summary::-webkit-details-marker {
	display: none;
}
/* 星星图标替代原来的箭头 */
.thinking summary::before {
	content: "✨";
	font-size: 14px;
	transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1);
}
.thinking[open] summary::before {
	transform: rotate(72deg);
}
.thinking .thinking-body {
	padding: 0 14px 14px 38px;
	white-space: pre-wrap;
	animation: fade-in 300ms ease;
	font-size: 12.5px;
	line-height: 1.6;
	border-top: 1px solid var(--line);
	margin-top: 0;
}

/* Tool cards */
.tool {
	margin-top: 10px;
	max-width: 100%;
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	background: var(--inset);
	overflow: hidden;
	transition: all var(--dur-s) var(--ease);
	animation: msg-in var(--dur-m) var(--ease) both;
}
.tool:hover {
	border-color: var(--line-strong);
	box-shadow: var(--shadow-card);
}
.tool-head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	cursor: pointer;
	font-size: 12px;
	user-select: none;
}
.tool-head:hover {
	background: var(--hover);
}
.tool-icon {
	font-size: 14px;
}
.tool-name {
	font-weight: 700;
	font-family: var(--font-mono);
	font-size: 11px;
	color: var(--accent);
}
.tool-args {
	color: var(--ink-3);
	font-family: var(--font-mono);
	font-size: 10.5px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	flex: 1;
}
.tool-state {
	font-size: 10px;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-family: var(--font-mono);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.tool-state.running {
	color: var(--orange);
}
.tool-state.done {
	color: var(--green);
}
.tool-state.error {
	color: var(--red);
}
.tool-state.running::before {
	content: "";
	width: 8px;
	height: 8px;
	border: 2px solid var(--orange-tint);
	border-top-color: var(--orange);
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
}
.tool-chevron {
	color: var(--ink-3);
	transition: transform var(--dur-m) var(--ease);
}
.tool.open .tool-chevron {
	transform: rotate(180deg);
}
.tool-body {
	max-height: 0;
	opacity: 0;
	overflow: hidden;
	border-top: 1px solid transparent;
	transition:
		max-height var(--dur-l) var(--ease),
		opacity var(--dur-m) var(--ease),
		border-color var(--dur-m) var(--ease);
}
.tool.open .tool-body {
	max-height: 420px;
	opacity: 1;
	border-top-color: var(--line);
}
.tool-io + .tool-io {
	border-top: 1px solid var(--line);
}
.tool-io-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 6px 8px 6px 14px;
}
.tool-io-label {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.04em;
	color: var(--ink-3);
	text-transform: uppercase;
	font-family: var(--font-mono);
}
.tool-io-actions {
	display: flex;
	align-items: center;
	gap: 2px;
	flex-shrink: 0;
}
.tool-io-btn {
	border: none;
	background: transparent;
	color: var(--ink-3);
	font-family: inherit;
	font-size: 10px;
	font-weight: 600;
	padding: 2px 7px;
	border-radius: var(--r-xs);
	cursor: pointer;
	transition: all var(--dur-s) var(--ease);
}
.tool-io-btn:hover {
	background: var(--hover-2);
	color: var(--text);
}
.tool-io-input .tool-io-block {
	background: oklch(62.6% 0.205 254.947 / 0.04);
}
.tool-io-output .tool-io-block {
	background: oklch(60.3% 0.155 150.883 / 0.04);
}
.tool-io-block {
	margin: 0;
	padding: 4px 14px 10px;
	font-family: var(--font-mono);
	font-size: 11px;
	line-height: 1.5;
	white-space: pre-wrap;
	word-break: break-word;
	color: var(--text);
	max-height: 170px;
	overflow: auto;
}
.tool-io-block::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}
.tool-io-block::-webkit-scrollbar-thumb {
	background: oklch(50% 0 0 / 0.2);
	border-radius: 6px;
}
.tool-io-modal-block {
	margin: 0;
	font-family: var(--font-mono);
	font-size: 12px;
	line-height: 1.6;
	white-space: pre-wrap;
	word-break: break-word;
	color: var(--text);
	max-height: 60vh;
	overflow: auto;
}

/* System notes */
.sysnote {
	align-self: center;
	font-size: 11px;
	color: var(--ink-3);
	background: var(--surface);
	border: 1px solid var(--line);
	padding: 4px 14px;
	border-radius: var(--r-full);
	animation: msg-in var(--dur-m) var(--ease) both;
	max-width: 100%;
}
.sysnote.warn {
	color: var(--orange);
	background: var(--orange-tint);
	border-color: transparent;
}
.sysnote.err {
	color: var(--red);
	background: var(--red-tint);
	border-color: transparent;
}

/* Empty state */
.chat-empty {
	margin: auto;
	text-align: center;
	color: var(--ink-3);
	padding: var(--sp-6);
}
.chat-empty .empty-ic {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	margin-bottom: 16px;
	border-radius: var(--r-lg);
	background: var(--surface);
	border: 1px solid var(--line);
	font-family: var(--font-mono);
	font-size: 28px;
	font-weight: 700;
	color: var(--accent);
	box-shadow: var(--shadow-card);
}
.chat-empty h2 {
	font-size: 20px;
	margin: 0 0 8px;
	color: var(--text);
	font-weight: 700;
	letter-spacing: -0.02em;
}
.chat-empty p {
	margin: 0 auto;
	font-size: 13px;
	max-width: 420px;
	line-height: 1.7;
	color: var(--ink-2);
}
.chat-empty code {
	font-family: var(--font-mono);
	background: var(--inset);
	padding: 2px 6px;
	border-radius: var(--r-sm);
	font-size: 12px;
}

/* Status bar */
.status-bar {
	flex-shrink: 0;
	border-top: 1px solid var(--line);
	background: var(--surface);
	padding: 6px var(--sp-4);
	font-size: 11px;
	color: var(--ink-3);
	min-height: 28px;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	font-family: var(--font-mono);
}
.status-bar .status-item {
	margin-right: 16px;
}
.status-bar .status-key {
	color: var(--accent);
	font-weight: 600;
}

/* Composer */
#composer {
	flex-shrink: 0;
	border-top: 1px solid var(--line);
	background: var(--surface);
	padding: var(--sp-3) var(--sp-5)
		calc(var(--sp-3) + env(safe-area-inset-bottom));
	position: relative;
	z-index: 4;
}
.composer-inner {
	max-width: var(--chat-max);
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
#input {
	width: 100%;
	resize: none;
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	padding: 10px 14px;
	font-family: inherit;
	font-size: 14px;
	color: var(--text);
	background: var(--page);
	min-height: 42px;
	max-height: 200px;
	line-height: 1.5;
	transition: all var(--dur-s);
	box-shadow: var(--shadow-inset-field);
}
#input:hover {
	border-color: var(--line-strong);
}
#input:focus,
#input:focus-visible {
	border-color: var(--accent);
	box-shadow: var(--ring);
	background: var(--surface);
}
.composer-actions {
	display: flex;
	align-items: center;
	gap: var(--sp-3);
}
.composer-hint {
	font-size: 10px;
	color: var(--ink-3);
	flex: 1;
	font-family: var(--font-mono);
}
.composer-btns {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	justify-content: flex-end;
}
.composer-btns .btn {
	padding: 6px 12px;
	font-size: 12px;
}
.composer-btns .ic {
	width: 14px;
	height: 14px;
}
.composer-config {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
}
.cfg-item {
	display: flex;
	align-items: center;
	gap: 5px;
	border: 1px solid var(--line);
	background: var(--page);
	border-radius: var(--r-md);
	padding: 3px 8px 3px 10px;
	transition: border-color var(--dur-s);
}
.cfg-item:hover,
.cfg-item:focus-within {
	border-color: var(--line-strong);
}
.cfg-label {
	font-family: var(--font-mono);
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--ink-3);
	white-space: nowrap;
	flex-shrink: 0;
}
.select-compact {
	width: auto;
	max-width: 168px;
	border: none;
	background-color: transparent;
	box-shadow: none;
	padding: 3px 18px 3px 0;
	font-size: 11px;
	background-position: right 1px center;
	background-size: 10px;
}
.select-compact:focus,
.select-compact:focus-visible {
	box-shadow: none;
	border-color: transparent;
}
#thinking-select.select-compact {
	max-width: 92px;
}

/* Slash menu */
#slash-menu {
	position: absolute;
	bottom: calc(100% - 4px);
	left: 50%;
	transform: translateX(-50%);
	width: min(640px, calc(100% - 24px));
	max-height: min(430px, 46vh);
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--r-xl);
	box-shadow: var(--shadow-overlay);
	padding: 8px;
	z-index: 20;
	display: flex;
	flex-direction: column;
	gap: 2px;
	animation: slash-in var(--dur-m) var(--ease);
}
#slash-menu[hidden] {
	display: none;
}
@keyframes slash-in {
	from {
		opacity: 0;
		transform: translate(-50%, 10px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: translate(-50%, 0) scale(1);
	}
}
.slash-group {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 7px 10px 4px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.05em;
	color: var(--ink-3);
	text-transform: uppercase;
	flex-shrink: 0;
	font-family: var(--font-mono);
}
.slash-group::after {
	content: "";
	flex: 1;
	height: 1px;
	background: var(--line);
}
.slash-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border-radius: var(--r-md);
	border: 1px solid transparent;
	background: transparent;
	cursor: pointer;
	font-family: inherit;
	font-size: 13px;
	color: var(--text);
	text-align: left;
	transition: all var(--dur-s) var(--ease);
	flex-shrink: 0;
}
.slash-item:hover {
	background: var(--hover);
}
.slash-item.active {
	background: var(--accent-tint);
	border-color: oklch(62.6% 0.205 254.947 / 0.3);
}
.slash-item .slash-cmd {
	font-family: var(--font-mono);
	font-weight: 700;
	color: var(--accent);
	font-size: 12px;
	white-space: nowrap;
}
.slash-item .slash-desc {
	flex: 1;
	font-size: 12px;
	color: var(--ink-2);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.slash-item .slash-src {
	font-size: 10px;
	line-height: 1;
	padding: 3px 7px;
	border-radius: var(--r-full);
	border: 1px solid var(--line);
	color: var(--ink-3);
	background: var(--page);
	white-space: nowrap;
	flex-shrink: 0;
}
.slash-item .slash-src-builtin,
.slash-item .slash-src-extension {
	color: var(--accent);
	background: var(--accent-tint);
	border-color: transparent;
}
.slash-item .slash-src-skill {
	color: var(--green);
	background: var(--green-tint);
	border-color: transparent;
}
.slash-item .slash-src-prompt {
	color: var(--orange);
	background: var(--orange-tint);
	border-color: transparent;
}
.slash-empty {
	padding: 14px 12px;
	font-size: 12px;
	color: var(--ink-3);
	text-align: center;
}
.slash-empty code {
	font-family: var(--font-mono);
	color: var(--accent);
}

/* Modal */
.modal-backdrop {
	position: fixed;
	inset: 0;
	background: var(--scrim);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
	padding: var(--sp-4);
	animation: fade-in var(--dur-m) var(--ease);
	backdrop-filter: blur(4px);
}
.modal {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--r-xl);
	box-shadow: var(--shadow-overlay);
	width: min(560px, 100%);
	max-height: 84dvh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: pop-in var(--dur-m) var(--ease-bounce);
}
.modal-head {
	padding: 16px 20px;
	border-bottom: 1px solid var(--line);
	display: flex;
	align-items: center;
	gap: 10px;
}
.modal-head .title {
	font-weight: 700;
	font-size: 15px;
	letter-spacing: -0.01em;
}
.modal-head .sub {
	font-size: 11px;
	color: var(--ink-3);
	margin-left: auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.modal-body {
	padding: var(--sp-4) 20px;
	overflow: auto;
}
.modal-body .confirm-text {
	margin: 0 0 4px;
	font-size: 14px;
	font-weight: 600;
	word-break: break-all;
}
.modal-body .confirm-sub {
	margin: 0;
	font-size: 12px;
	color: var(--ink-2);
}
.modal-foot {
	padding: 14px 20px;
	border-top: 1px solid var(--line);
	display: flex;
	gap: 8px;
	justify-content: flex-end;
}
.modal textarea,
.modal input[type="text"] {
	width: 100%;
	padding: 10px 12px;
	font-size: 13px;
}
.modal textarea {
	min-height: 130px;
	resize: vertical;
}

/* Options */
.option-list {
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.option-item {
	text-align: left;
	padding: 10px 13px;
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	background: var(--page);
	cursor: pointer;
	font-size: 13px;
	font-family: inherit;
	color: var(--text);
	transition: all var(--dur-s) var(--ease);
}
.option-item:hover {
	border-color: var(--accent);
	background: var(--accent-tint);
	transform: translateX(2px);
}
.option-item:active {
	transform: scale(0.99);
}

/* Stats */
.stats-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}
.stat-box {
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	padding: 12px 14px;
	background: var(--page);
	transition: all var(--dur-s);
}
.stat-box:hover {
	border-color: var(--line-strong);
	transform: translateY(-1px);
	box-shadow: var(--shadow-card);
}
.stat-box .k {
	font-size: 10px;
	color: var(--ink-3);
	font-family: var(--font-mono);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.stat-box .v {
	font-size: 20px;
	font-weight: 700;
	margin-top: 4px;
	font-variant-numeric: tabular-nums;
	overflow-wrap: break-word;
}
.stat-box .v small {
	display: block;
	font-size: 11px;
	font-weight: 400;
	color: var(--ink-3);
	margin-left: 0;
}
#insp-pane-stats .stats-grid {
	grid-template-columns: 1fr;
}

/* Tree */
.tree {
	font-family: var(--font-mono);
	font-size: 11px;
}
.tree-stats {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
	margin-bottom: 10px;
	padding-bottom: 10px;
	border-bottom: 1px solid var(--line);
}
.tree-stats .stat {
	font-size: 10px;
	color: var(--ink-3);
	background: var(--page);
	padding: 3px 10px;
	border-radius: var(--r-full);
	border: 1px solid var(--line);
	font-family: var(--font-mono);
}
.tree-stats .stat-active {
	color: var(--green);
	background: var(--green-tint);
	border-color: transparent;
}
.tree-search {
	margin-bottom: 10px;
}
.tree ul {
	list-style: none;
	margin: 0;
	padding-left: 20px;
	border-left: 1px dotted var(--line-strong);
}
.tree > ul {
	padding-left: 0;
	border-left: none;
}
.tree li {
	padding: 2px 0;
}
.entry-label {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 8px;
	border-radius: var(--r-sm);
	transition: background var(--dur-s);
}
.entry-label:hover {
	background: var(--hover);
}
.entry-label.active {
	background: var(--accent-tint);
}
.entry-label.leaf {
	box-shadow: inset 2px 0 0 var(--green);
}
.node-arrow {
	width: 12px;
	flex-shrink: 0;
	color: var(--ink-3);
	cursor: pointer;
	user-select: none;
	text-align: center;
	transition: transform var(--dur-m) var(--ease);
}
.node-arrow.is-empty {
	visibility: hidden;
}
li:not(.open) > .entry-label .node-arrow {
	transform: rotate(-90deg);
}
.node-children {
	animation: fade-in var(--dur-m) var(--ease);
}
li:not(.open) > .node-children {
	display: none;
}
.node-icon {
	font-size: 13px;
	flex-shrink: 0;
}
.node-icon.user {
	color: var(--accent);
}
.node-icon.assistant {
	color: var(--green);
}
.node-icon.tool {
	color: var(--orange);
}
.node-text {
	flex: 1;
	color: var(--ink-3);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.entry-label.active .node-text {
	color: var(--text);
}
.node-id {
	color: var(--line-strong);
	font-size: 10px;
	flex-shrink: 0;
}
.node-fork {
	opacity: 0;
	border: none;
	background: var(--accent-tint);
	color: var(--accent);
	font-size: 10px;
	font-weight: 700;
	padding: 2px 8px;
	border-radius: var(--r-full);
	cursor: pointer;
	transition: opacity var(--dur-s);
	flex-shrink: 0;
}
.entry-label:hover .node-fork,
.entry-label:focus-within .node-fork {
	opacity: 1;
}
.tree-empty {
	color: var(--ink-3);
	padding: var(--sp-4);
	text-align: center;
}

/* Commands */
.cmd-list {
	gap: 6px;
}
.cmd-item {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}
.cmd-item .cmd-name {
	font-family: var(--font-mono);
	font-weight: 700;
	color: var(--accent);
	font-size: 12px;
}
.cmd-item .cmd-desc {
	flex: 1;
	color: var(--ink-2);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	min-width: 120px;
}
.cmd-item .cmd-src {
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 2px 8px;
	border-radius: var(--r-full);
	background: var(--surface);
	color: var(--ink-3);
	border: 1px solid var(--line);
	flex-shrink: 0;
}
.cmd-item .cmd-src-extension {
	color: var(--accent);
	background: var(--accent-tint);
	border-color: transparent;
}
.cmd-item .cmd-src-skill {
	color: var(--green);
	background: var(--green-tint);
	border-color: transparent;
}
.cmd-item .cmd-src-prompt {
	color: var(--orange);
	background: var(--orange-tint);
	border-color: transparent;
}
.cmd-item.cmd-quick {
	border-color: oklch(62.6% 0.205 254.947 / 0.25);
	background: var(--accent-tint);
}
.cmd-item.cmd-quick:hover {
	transform: none;
}
.cmd-src-once {
	color: var(--accent);
	background: var(--accent-tint);
	border-color: transparent;
}
.cmd-sep {
	font-size: 10px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	color: var(--ink-3);
	padding: 8px 4px 2px;
	font-family: var(--font-mono);
}

/* Settings */
.settings-panel {
	display: flex;
	flex-direction: column;
}
.settings-row {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 10px 8px;
	margin: 0 -8px;
	border-bottom: 1px solid var(--line);
	border-radius: var(--r-sm);
	transition: background var(--dur-s);
}
.settings-row:hover {
	background: var(--hover);
}
.settings-row:last-of-type {
	border-bottom: none;
}
.s-label-wrap {
	min-width: 128px;
	flex-shrink: 0;
}
.s-label {
	font-size: 13px;
	font-weight: 600;
}
.s-hint {
	font-size: 11px;
	color: var(--ink-3);
	margin-top: 2px;
	line-height: 1.4;
}
.s-control {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 8px;
}
.settings-select {
	min-width: 230px;
	font-size: 12.5px;
}
.settings-info {
	margin-top: 14px;
	padding: 4px 12px;
	background: var(--page);
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	font-size: 12px;
	color: var(--ink-2);
	display: flex;
	flex-direction: column;
}
.settings-info-title {
	font-weight: 700;
	color: var(--text);
	font-size: 10px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	padding: 10px 0 8px;
	border-bottom: 1px solid var(--line);
	margin-bottom: 2px;
	font-family: var(--font-mono);
}
.settings-info-row {
	display: flex;
	align-items: baseline;
	gap: 10px;
	padding: 6px 0;
	border-bottom: 1px dashed var(--line);
}
.settings-info-row:last-child {
	border-bottom: none;
}
.settings-info-row .k {
	flex-shrink: 0;
	min-width: 56px;
	color: var(--ink-3);
	font-size: 11px;
}
.settings-info-row .v {
	font-family: var(--font-mono);
	font-size: 11px;
	color: var(--ink-2);
	word-break: break-all;
	text-align: right;
	margin-left: auto;
}
.switch {
	position: relative;
	display: inline-flex;
	cursor: pointer;
	flex-shrink: 0;
}
.switch input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}
.switch-track {
	width: 36px;
	height: 20px;
	border-radius: var(--r-full);
	background: var(--line-strong);
	transition: background var(--dur-s);
}
.switch input:checked + .switch-track {
	background: var(--accent);
}
.switch-thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: oklch(99% 0 0);
	box-shadow: var(--shadow-xs);
	transition: transform var(--dur-s) var(--ease);
}
.switch input:checked ~ .switch-thumb {
	transform: translateX(16px);
}
.switch:focus-within .switch-track {
	box-shadow: var(--ring);
}

/* Popover */
.popover-menu {
	position: fixed;
	z-index: 150;
	min-width: 220px;
	max-width: 300px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--r-lg);
	box-shadow: var(--shadow-overlay);
	padding: 6px;
	display: flex;
	flex-direction: column;
	gap: 1px;
	opacity: 0;
	transform: translateY(-4px) scale(0.98);
	transition:
		opacity var(--dur-s) var(--ease),
		transform var(--dur-s) var(--ease);
}
.popover-menu.is-show {
	opacity: 1;
	transform: none;
}
.popover-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	border: none;
	background: transparent;
	padding: 7px 9px;
	border-radius: var(--r-md);
	cursor: pointer;
	font-family: inherit;
	text-align: left;
	color: var(--text);
	transition: background var(--dur-s);
}
.popover-item:hover {
	background: var(--hover);
}
.popover-item.active {
	background: var(--accent-tint);
}
.popover-txt {
	flex: 1;
	min-width: 0;
}
.popover-label {
	font-size: 13px;
	font-weight: 600;
}
.popover-hint {
	font-size: 11px;
	color: var(--ink-3);
	margin-top: 1px;
}
.popover-item.active .popover-label {
	color: var(--accent);
}
.popover-check {
	color: var(--accent);
	font-size: 12px;
	font-weight: 700;
	flex-shrink: 0;
}
.popover-sep {
	height: 1px;
	background: var(--line);
	margin: 5px 2px;
}
#btn-view.view-active {
	color: var(--accent);
	background: var(--accent-tint);
}

/* View modes */
.chat.view-summary .thinking {
	display: none;
}
.chat.view-summary .tool-args {
	display: none;
}
.chat.view-verbose .tool.open .tool-body {
	max-height: 560px;
}

/* Hotkeys */
.hotkeys {
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.hotkey-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 10px;
	border-radius: var(--r-sm);
	font-size: 13px;
}
.hotkey-row:nth-child(odd) {
	background: var(--page);
}
.hotkey-key {
	font-family: var(--font-mono);
	font-size: 11px;
	font-weight: 700;
	color: var(--accent);
	background: var(--accent-tint);
	border: 1px solid oklch(62.6% 0.205 254.947 / 0.2);
	border-radius: var(--r-xs);
	padding: 3px 8px;
	white-space: nowrap;
	min-width: 96px;
	text-align: center;
}
.hotkey-desc {
	color: var(--ink-2);
}

/* Model picker */
.model-picker {
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.model-search {
	width: 100%;
}
.model-list {
	display: flex;
	flex-direction: column;
	gap: 3px;
	max-height: 42vh;
	overflow-y: auto;
	overscroll-behavior: contain;
}
.model-group {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.05em;
	color: var(--ink-3);
	text-transform: uppercase;
	padding: 8px 8px 2px;
	position: sticky;
	top: 0;
	background: var(--surface);
	z-index: 1;
	font-family: var(--font-mono);
}
.model-item {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 8px 10px;
	border-radius: var(--r-md);
	border: 1px solid transparent;
	background: transparent;
	cursor: pointer;
	font-family: inherit;
	font-size: 13px;
	color: var(--text);
	text-align: left;
	transition: all var(--dur-s) var(--ease);
}
.model-item:hover {
	background: var(--hover);
}
.model-item.active {
	background: var(--accent-tint);
	border-color: oklch(62.6% 0.205 254.947 / 0.3);
}
.model-id {
	font-family: var(--font-mono);
	font-weight: 600;
	font-size: 12px;
	color: var(--accent);
	white-space: nowrap;
}
.model-name {
	font-size: 12px;
	color: var(--ink-2);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.model-check {
	margin-left: auto;
	font-size: 11px;
	font-weight: 700;
	color: var(--green);
	flex-shrink: 0;
}
.model-empty {
	padding: 14px;
	font-size: 12px;
	color: var(--ink-3);
	text-align: center;
}

/* Resume picker */
.resume-picker {
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.resume-list {
	display: flex;
	flex-direction: column;
	gap: 3px;
	max-height: 46vh;
	overflow-y: auto;
	overscroll-behavior: contain;
}
.resume-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 11px;
	border-radius: var(--r-md);
	border: 1px solid transparent;
	background: transparent;
	cursor: pointer;
	font-family: inherit;
	text-align: left;
	color: var(--text);
	transition: all var(--dur-s) var(--ease);
}
.resume-item:hover {
	background: var(--hover);
	border-color: var(--line);
}
.resume-txt {
	flex: 1;
	min-width: 0;
}
.resume-name {
	font-size: 13px;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.resume-preview {
	font-size: 11px;
	color: var(--ink-3);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.resume-meta {
	font-size: 11px;
	color: var(--ink-3);
	flex-shrink: 0;
}

/* About */
.about {
	display: flex;
	flex-direction: column;
	gap: 7px;
	font-size: 13px;
}
.about-row {
	padding: 8px 10px;
	background: var(--page);
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	word-break: break-all;
}
.about-note {
	font-size: 11px;
	color: var(--ink-3);
	padding: 2px 2px 0;
}

/* Quick prompt */
.quick-prompt {
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.quick-files {
	margin-top: -4px;
}

/* Button loading */
.btn.is-loading {
	pointer-events: none;
	opacity: 0.75;
}
.btn.is-loading .ic {
	visibility: hidden;
}
.btn.is-loading::after {
	content: "";
	width: 12px;
	height: 12px;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
}

/* Attach bar */
.attach-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.attach-bar[hidden] {
	display: none;
}
.attach-item {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--page);
	border: 1px solid var(--line);
	border-radius: var(--r-md);
	padding: 5px 8px 5px 5px;
	max-width: 230px;
	animation: msg-in var(--dur-m) var(--ease) both;
}
.attach-item img {
	width: 34px;
	height: 34px;
	object-fit: cover;
	border-radius: var(--r-sm);
	flex-shrink: 0;
}
.attach-info {
	display: flex;
	flex-direction: column;
	min-width: 0;
}
.attach-name {
	font-size: 11px;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 120px;
}
.attach-size {
	font-size: 10px;
	color: var(--ink-3);
}
.attach-rm {
	border: none;
	background: transparent;
	color: var(--ink-3);
	cursor: pointer;
	font-size: 12px;
	padding: 2px 5px;
	border-radius: var(--r-sm);
	transition:
		background var(--dur-s),
		color var(--dur-s);
	flex-shrink: 0;
}
.attach-rm:hover {
	background: var(--red-tint);
	color: var(--red);
}
.bubble-imgs {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 8px;
}
.bubble-imgs img {
	max-width: 180px;
	max-height: 180px;
	border-radius: var(--r-sm);
	object-fit: cover;
}

/* Shell panel */
.bash-panel {
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.bash-row {
	display: flex;
	gap: 8px;
}
.bash-row input {
	flex: 1;
	padding: 8px 12px;
	border: 1px solid var(--line);
	border-radius: var(--r-sm);
	background: var(--page);
	color: var(--text);
	font-family: var(--font-mono);
	font-size: 13px;
}
.bash-row input:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: var(--ring);
}
.bash-out {
	margin: 0;
	min-height: 120px;
	max-height: 320px;
	overflow: auto;
	background: var(--code-bg);
	color: var(--code-text);
	border-radius: var(--r-md);
	padding: 12px 14px;
	font-family: var(--font-mono);
	font-size: 12px;
	line-height: 1.55;
	white-space: pre-wrap;
	word-break: break-word;
}

/* Toast */
#toast-root {
	position: fixed;
	right: var(--sp-4);
	bottom: var(--sp-4);
	display: flex;
	flex-direction: column;
	gap: 8px;
	z-index: 200;
	max-width: min(380px, 90vw);
}
.toast {
	background: var(--surface);
	border: 1px solid var(--line);
	border-left: 4px solid var(--accent);
	border-radius: var(--r-md);
	box-shadow: var(--shadow-md);
	padding: 11px 15px;
	font-size: 13px;
	animation: toast-in var(--dur-m) var(--ease);
	transition:
		opacity var(--dur-m) var(--ease),
		transform var(--dur-m) var(--ease);
}
.toast.info {
	border-left-color: var(--accent);
}
.toast.ok {
	border-left-color: var(--green);
}
.toast.warning {
	border-left-color: var(--orange);
}
.toast.error {
	border-left-color: var(--red);
}
.toast.leaving {
	opacity: 0;
	transform: translateY(8px);
}

/* Scrollbar */
::-webkit-scrollbar {
	width: 10px;
	height: 10px;
}
::-webkit-scrollbar-track {
	background: transparent;
}
::-webkit-scrollbar-thumb {
	background: color-mix(in srgb, var(--ink-3) 28%, transparent);
	border-radius: 6px;
	border: 2px solid transparent;
	background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
	background-color: color-mix(in srgb, var(--ink-3) 45%, transparent);
}

/* Animations */
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}
@keyframes blink {
	50% {
		opacity: 0;
	}
}
@keyframes fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}
@keyframes msg-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}
@keyframes item-in {
	from {
		opacity: 0;
		transform: translateX(-6px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}
@keyframes pop-in {
	from {
		opacity: 0;
		transform: scale(0.94) translateY(8px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}
@keyframes toast-in {
	from {
		opacity: 0;
		transform: translateX(24px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}
@keyframes slide-down {
	from {
		opacity: 0;
		transform: translateY(-100%);
	}
	to {
		opacity: 1;
		transform: none;
	}
}
@keyframes pulse {
	0%,
	100% {
		opacity: 1;
	}
	50% {
		opacity: 0.35;
	}
}

/* Responsive */
@media (max-width: 1100px) {
	:root {
		--sidebar-w: 260px;
		--inspector-w: 300px;
	}
}
@media (max-width: 1100px) and (min-width: 901px) {
	#app,
	body.inspector-open #app {
		grid-template-columns: var(--sidebar-w) 1fr;
	}
	#inspector {
		position: fixed;
		inset: 0 0 0 auto;
		width: min(340px, 40vw);
		transform: translateX(104%);
		transition: transform var(--dur-l) var(--ease);
		box-shadow: var(--shadow-overlay);
	}
	body.inspector-open #inspector {
		transform: none;
	}
	#inspector-scrim {
		position: fixed;
		inset: 0;
		background: var(--scrim);
		opacity: 0;
		pointer-events: none;
		transition: opacity var(--dur-m) var(--ease);
		z-index: 58;
	}
	body.inspector-open #inspector-scrim {
		opacity: 1;
		pointer-events: auto;
	}
}
@media (max-width: 900px) {
	#app,
	body.inspector-open #app {
		grid-template-columns: 1fr;
	}
	#inspector {
		position: fixed;
		inset: 0 0 0 auto;
		width: min(340px, 88vw);
		transform: translateX(104%);
		transition: transform var(--dur-l) var(--ease);
		box-shadow: var(--shadow-overlay);
		z-index: 60;
	}
	body.inspector-open #inspector {
		transform: none;
	}
	#inspector-scrim {
		position: fixed;
		inset: 0;
		background: var(--scrim);
		opacity: 0;
		pointer-events: none;
		transition: opacity var(--dur-m) var(--ease);
		z-index: 58;
	}
	body.inspector-open #inspector-scrim {
		opacity: 1;
		pointer-events: auto;
	}
	#sidebar {
		position: fixed;
		inset: 0 auto 0 0;
		width: min(304px, 86vw);
		transform: translateX(-104%);
		transition: transform var(--dur-l) var(--ease);
		box-shadow: var(--shadow-overlay);
	}
	body.sidebar-open #sidebar {
		transform: none;
	}
	#btn-sidebar-close {
		display: inline-flex;
	}
	#btn-sidebar-toggle {
		display: inline-flex;
	}
	#sidebar-scrim {
		position: fixed;
		inset: 0;
		background: var(--scrim);
		opacity: 0;
		pointer-events: none;
		transition: opacity var(--dur-m) var(--ease);
		z-index: 55;
	}
	body.sidebar-open #sidebar-scrim {
		opacity: 1;
		pointer-events: auto;
	}
	#topbar {
		padding: 9px 12px;
		gap: var(--sp-2);
	}
	.topbar-actions {
		gap: 0;
	}
	.topbar-actions .divider {
		margin: 0 5px;
	}
	.chat {
		padding: var(--sp-4) var(--sp-3) var(--sp-6);
		gap: var(--sp-3);
	}
	.bubble {
		max-width: 92%;
	}
	#composer {
		padding: var(--sp-2) var(--sp-3)
			calc(var(--sp-2) + env(safe-area-inset-bottom));
	}
	.composer-hint {
		display: none;
	}
}
@media (max-width: 520px) {
	.session-name {
		max-width: 120px;
	}
	#btn-bash,
	#btn-compact {
		display: none;
	}
	.insp-tab span {
		display: none;
	}
	.insp-actions .btn span {
		display: none;
	}
	.composer-btns .btn {
		padding: 8px 12px;
	}
	#btn-steer,
	#btn-followup {
		font-size: 12px;
		padding: 8px 10px;
	}
	.chat-empty h2 {
		font-size: 17px;
	}
	.composer-actions {
		flex-wrap: wrap;
		row-gap: 6px;
	}
	.composer-config {
		order: -1;
		flex-basis: 100%;
	}
	.composer-btns {
		flex: 1;
		justify-content: flex-end;
	}
	.cfg-label {
		display: none;
	}
	.cfg-item {
		flex: 1;
		padding: 3px 8px;
	}
	.select-compact,
	#thinking-select.select-compact {
		max-width: none;
		width: 100%;
	}
}
@media (hover: none) {
	.session-item .close {
		opacity: 1;
	}
}
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
	html {
		scroll-behavior: auto;
	}
}
