/* zxt 桥梁控制台 · 浅色工作台。
   视觉基准：语义 token 唯一来源；机器状态色只表达真实状态，消息类型色只做左缘标识。 */
:root {
	--bg: #f3f5f9;
	--bg-panel: #f8fafc;
	--panel: #ffffff;
	--line: #e5eaf2;
	--line-strong: #d3dbe7;
	--text: #0f172a;
	--text-2: #475569;
	--text-3: #5f6b7c;
	--accent: #2563eb;
	--accent-strong: #1d4ed8;
	--accent-soft: #edf2ff;
	--accent-line: #c9d8fe;
	--ok: #166534;
	--ok-dot: #16a34a;
	--ok-bg: #e9f7ee;
	--ok-line: #bfe8cd;
	--info: #1d4ed8;
	--info-bg: #eaf0fe;
	--warn: #92400e;
	--warn-bg: #fdf4e3;
	--warn-line: #f0d9b3;
	--danger: #b42318;
	--danger-bg: #fdecea;
	--danger-line: #f3c6c1;
	--muted-bg: #eef2f7;
	--shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
	--shadow-md: 0 10px 30px rgba(15, 23, 42, .10);
	--radius: 10px;
	--radius-lg: 14px;
	--mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
}

* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
}

body {
	margin: 0;
	font: 14px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
		"Microsoft YaHei", sans-serif;
	color: var(--text);
	background: var(--bg);
	-webkit-font-smoothing: antialiased;
}

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

button {
	cursor: pointer;
}

a {
	color: var(--accent-strong);
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

::selection {
	background: #dbe7ff;
}

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.hidden {
	display: none !important;
}

.mobile-only {
	display: none !important;
}

.timeline::-webkit-scrollbar,
.thread-list::-webkit-scrollbar,
.machine-list::-webkit-scrollbar,
.modal::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

.timeline::-webkit-scrollbar-thumb,
.thread-list::-webkit-scrollbar-thumb,
.machine-list::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb {
	background: #d6deea;
	border-radius: 999px;
}

.timeline::-webkit-scrollbar-thumb:hover,
.thread-list::-webkit-scrollbar-thumb:hover,
.machine-list::-webkit-scrollbar-thumb:hover,
.modal::-webkit-scrollbar-thumb:hover {
	background: #c2ccda;
}

.timeline::-webkit-scrollbar-track,
.thread-list::-webkit-scrollbar-track,
.machine-list::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track {
	background: transparent;
}

/* ---- 品牌 / 头像 / 状态点 ---- */
.brand-mark {
	width: 30px;
	height: 30px;
	border-radius: 9px;
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	background: var(--accent);
	box-shadow: 0 2px 6px rgba(37, 99, 235, .28);
}

.brand-mark svg {
	width: 18px;
	height: 18px;
}

.brand-mark-lg {
	width: 40px;
	height: 40px;
	border-radius: 12px;
}

.brand-mark-lg svg {
	width: 24px;
	height: 24px;
}

.avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-size: 12.5px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0;
	background: #475569;
	user-select: none;
}

.avatar-sm {
	width: 30px;
	height: 30px;
	font-size: 12px;
}

.avatar-md {
	width: 36px;
	height: 36px;
	border-radius: 11px;
	font-size: 13.5px;
}

.avatar-blue {
	background: #2563eb;
}

.avatar-teal {
	background: #0f766e;
}

.avatar-violet {
	background: #6d28d9;
}

.avatar-amber {
	background: #92400e;
}

.avatar-rose {
	background: #be123c;
}

.avatar-slate {
	background: #475569;
}

.avatar-me {
	background: #1d4ed8;
}

.presence {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex: none;
	background: #cbd5e1;
}

.presence-online {
	background: var(--ok-dot);
	box-shadow: 0 0 0 3px rgba(22, 163, 74, .15);
}

.presence-offline {
	background: #cbd5e1;
}

.presence-paused {
	background: #f59e0b;
	box-shadow: 0 0 0 3px rgba(245, 158, 11, .16);
}

.machine-avatar {
	position: relative;
	display: inline-flex;
	flex: none;
}

.avatar-badge {
	position: absolute;
	top: -4px;
	right: -5px;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 15px;
	height: 15px;
	padding: 0 4px;
	border: 2px solid var(--panel);
	border-radius: 999px;
	background: var(--warn);
	color: #fff;
	font-size: 9px;
	font-weight: 600;
	line-height: 1;
}

/* ---- 按钮 ---- */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	height: 34px;
	padding: 0 14px;
	border-radius: 9px;
	border: 1px solid var(--line-strong);
	background: var(--panel);
	color: var(--text);
	font-size: 12.5px;
	font-weight: 500;
	line-height: 1;
	white-space: nowrap;
	transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}

.btn svg {
	flex: none;
}

.btn:hover {
	background: #f6f8fb;
	border-color: #c6d1e0;
}

.btn:active {
	transform: translateY(0.5px);
}

.btn:disabled {
	opacity: .55;
	cursor: not-allowed;
	transform: none;
}

.btn-primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
	box-shadow: 0 1px 2px rgba(37, 99, 235, .30);
}

.btn-primary:hover {
	background: var(--accent-strong);
	border-color: var(--accent-strong);
}

.btn-ghost {
	border-color: transparent;
	background: transparent;
	color: var(--text-2);
}

.btn-ghost:hover {
	background: var(--muted-bg);
	border-color: transparent;
	color: var(--text);
}

.btn-small {
	height: 28px;
	padding: 0 10px;
	border-radius: 8px;
	font-size: 11.5px;
}

.btn-icon {
	width: 30px;
	height: 30px;
	padding: 0;
	border-radius: 8px;
}

.btn-danger {
	color: var(--danger);
	border-color: var(--danger-line);
	background: var(--panel);
}

.btn-danger:hover {
	background: var(--danger-bg);
	border-color: #e9b1ab;
}

.btn-block {
	width: 100%;
	height: 42px;
	border-radius: 10px;
	font-size: 13.5px;
}

/* ---- 徽标 ---- */
.chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	flex: none;
	height: 22px;
	padding: 0 9px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 500;
	line-height: 1;
	white-space: nowrap;
}

.chip-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	flex: none;
}

.chip-muted {
	background: var(--muted-bg);
	color: var(--text-2);
}

.chip-ok {
	background: var(--ok-bg);
	color: var(--ok);
}

.chip-info {
	background: var(--info-bg);
	color: var(--info);
}

.chip-warn {
	background: var(--warn-bg);
	color: var(--warn);
}

.chip-danger {
	background: var(--danger-bg);
	color: var(--danger);
}

/* ---- 登录 ---- */
.login-wrap {
	min-height: 100vh;
	display: grid;
	place-items: center;
	padding: 28px 20px;
	background:
		radial-gradient(760px 380px at 50% -12%, #e6eeff 0%, rgba(230, 238, 255, 0) 70%),
		var(--bg);
}

.login-shell {
	width: 100%;
	max-width: 400px;
}

.login-brand {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 11px;
	margin-bottom: 20px;
}

.login-brand-text {
	display: flex;
	flex-direction: column;
	line-height: 1.3;
}

.login-brand-name {
	font-size: 15px;
	font-weight: 600;
}

.login-brand-sub {
	font-size: 11px;
	color: var(--text-3);
}

.login-card {
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 18px;
	padding: 28px;
	box-shadow: 0 18px 50px rgba(15, 23, 42, .10);
}

.login-card h1 {
	margin: 0 0 5px;
	font-size: 20px;
	font-weight: 600;
	letter-spacing: -.01em;
}

.login-sub {
	margin: 0 0 22px;
	color: var(--text-2);
	font-size: 12.5px;
	line-height: 1.65;
}

.login-card .field {
	margin-bottom: 16px;
}

.login-card .field input {
	height: 42px;
	background: var(--panel);
}

.login-error {
	min-height: 18px;
	margin: 10px 0 0;
	color: var(--danger);
	font-size: 12px;
	line-height: 1.5;
}

.login-foot {
	margin: 16px 0 0;
	text-align: center;
	color: var(--text-3);
	font-size: 11px;
}

/* ---- 顶栏 ---- */
.app {
	display: flex;
	flex-direction: column;
	height: 100vh;
	height: 100dvh;
	overflow: hidden;
}

.topbar {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-height: 60px;
	padding: 0 20px;
	background: var(--panel);
	border-bottom: 1px solid var(--line);
}

.topbar-left {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	flex-wrap: wrap;
}

.brand-group {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: none;
}

.brand-block {
	display: flex;
	flex-direction: column;
	line-height: 1.3;
	min-width: 0;
}

.brand {
	font-size: 14.5px;
	font-weight: 600;
	white-space: nowrap;
}

.brand-sub {
	font-size: 10.5px;
	color: var(--text-3);
	white-space: nowrap;
}

.topbar-chips {
	display: flex;
	align-items: center;
	gap: 7px;
	flex-wrap: wrap;
}

.topbar-meta {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: none;
	color: var(--text-3);
	font-size: 11px;
}

#server-time {
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

#build-chip {
	font-family: var(--mono);
	font-size: 10.5px;
}

/* ---- 布局 / 侧栏 ---- */
.layout {
	display: flex;
	flex: 1;
	min-height: 0;
}

.rail {
	width: 320px;
	flex: none;
	min-height: 0;
	display: flex;
	flex-direction: column;
	background: var(--bg-panel);
	border-right: 1px solid var(--line);
}

.rail-block {
	padding: 14px 14px 12px;
	border-bottom: 1px solid var(--line);
}

.rail-grow {
	flex: 1;
	min-height: 0;
	display: flex;
	flex-direction: column;
	border-bottom: none;
}

.rail-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 10px;
}

.rail-head-title {
	display: flex;
	align-items: center;
	gap: 7px;
	min-width: 0;
}

.rail-head h2 {
	margin: 0;
	color: var(--text-3);
	font-size: 11.5px;
	font-weight: 600;
	letter-spacing: .02em;
	white-space: nowrap;
}

.rail-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 999px;
	background: var(--muted-bg);
	color: var(--text-2);
	font-size: 10px;
	font-weight: 600;
}

.machine-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 44vh;
	overflow-y: auto;
	padding-right: 2px;
}

.thread-list {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 0 2px 4px 0;
}

.rail-empty {
	margin: 2px 0 0;
	padding: 10px 11px;
	border: 1px dashed var(--line-strong);
	border-radius: 10px;
	background: rgba(255, 255, 255, .5);
	color: var(--text-3);
	font-size: 11.5px;
	line-height: 1.6;
}

/* ---- 机器卡片 ---- */
.machine-card {
	flex: none;
	padding: 10px 11px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--panel);
	box-shadow: var(--shadow-sm);
	transition: border-color .15s, box-shadow .15s;
}

.machine-card:hover {
	border-color: var(--line-strong);
	box-shadow: 0 3px 10px rgba(15, 23, 42, .06);
}

.machine-card.is-paused {
	background: #fffdf8;
	border-color: #efdcbc;
}

.machine-top {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.machine-id {
	flex: 1;
	min-width: 0;
	line-height: 1.35;
}

.machine-name {
	display: block;
	font-size: 13.5px;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.machine-sub {
	font-size: 11px;
	color: var(--text-3);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.machine-top .chip {
	height: 20px;
	padding: 0 7px;
	font-size: 10.5px;
}

.machine-phase {
	margin-top: 8px;
	padding: 6px 9px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--bg-panel);
	color: var(--text-2);
	font-size: 11px;
	line-height: 1.5;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.machine-foot {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	margin-top: 8px;
	color: var(--text-3);
	font-size: 10.5px;
	line-height: 1.4;
}

.machine-facts {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	flex: 1 1 auto;
	flex-wrap: wrap;
	min-width: 0;
}

.machine-heartbeat {
	white-space: nowrap;
}

.dot-sep {
	color: #c4ceda;
}

.machine-version {
	max-width: none;
	min-width: 0;
	flex: 0 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-family: var(--mono);
	font-size: 10px;
}

.machine-foot .chip {
	height: 19px;
	padding: 0 7px;
	font-size: 10px;
}

.machine-actions {
	display: flex;
	align-items: center;
	gap: 3px;
	flex: none;
	margin-left: auto;
}

.machine-actions .btn {
	height: 26px;
}

.machine-actions .btn-small {
	padding: 0 8px;
	font-size: 10.5px;
}

.machine-actions .btn-icon {
	width: 26px;
	padding: 0;
}

/* ---- 会话列表 ---- */
.thread-item {
	position: relative;
	width: 100%;
	padding: 8px 9px;
	display: grid;
	grid-template-columns: 36px minmax(0, 1fr);
	gap: 9px;
	align-items: start;
	text-align: left;
	background: transparent;
	border: 1px solid transparent;
	border-radius: 11px;
	transition: background .15s, border-color .15s, box-shadow .15s;
}

.thread-item:hover {
	background: #eef2f8;
}

.thread-item.active {
	background: var(--panel);
	border-color: var(--line);
	box-shadow: var(--shadow-sm);
}

.thread-item.active::before {
	content: "";
	position: absolute;
	left: -1px;
	top: 10px;
	bottom: 10px;
	width: 3px;
	border-radius: 0 3px 3px 0;
	background: var(--accent);
}

.thread-item-main {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.thread-item-top {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	min-width: 0;
}

.thread-item-title {
	font-size: 13px;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.thread-item-time {
	flex: none;
	color: var(--text-3);
	font-size: 10px;
	font-variant-numeric: tabular-nums;
}

.thread-item-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	min-width: 0;
}

.thread-item-sub {
	font-size: 10.5px;
	color: var(--text-3);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.thread-item-foot .chip {
	height: 19px;
	padding: 0 7px;
	font-size: 10px;
}

/* ---- 主区 / 空态 ---- */
.content {
	flex: 1;
	min-width: 0;
	min-height: 0;
	display: flex;
	flex-direction: column;
	background: var(--bg-panel);
}

.empty-state {
	margin: auto;
	padding: 32px 24px 48px;
	max-width: 420px;
	text-align: center;
	color: var(--text-2);
}

.empty-art {
	width: 168px;
	margin: 0 auto 18px;
}

.empty-art svg {
	display: block;
	width: 100%;
	height: auto;
}

.empty-state h2 {
	margin: 0 0 6px;
	color: var(--text);
	font-size: 18px;
	font-weight: 600;
}

.empty-state p {
	margin: 0 auto 18px;
	font-size: 12.5px;
	line-height: 1.7;
}

.empty-state .btn {
	margin-bottom: 16px;
}

.empty-state .empty-hint {
	margin: 0;
	color: var(--text-3);
	font-size: 11px;
}

.thread-panel {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

.thread-head {
	flex: none;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 14px 24px 12px;
	background: var(--panel);
	border-bottom: 1px solid var(--line);
}

.thread-title-wrap {
	flex: 1;
	min-width: 0;
}

.thread-title-line {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.thread-title-line h2 {
	margin: 0;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.35;
}

.thread-title-line .chip {
	height: 20px;
	padding: 0 7px;
	font-size: 10.5px;
}

.thread-meta {
	margin: 3px 0 0;
	color: var(--text-3);
	font-size: 11px;
	line-height: 1.55;
}

.thread-meta a {
	color: var(--accent-strong);
}

.thread-meta-sep {
	white-space: pre;
}

.thread-actions {
	flex: none;
	display: flex;
	align-items: center;
	gap: 6px;
	padding-top: 2px;
}

.thread-actions .btn {
	height: 30px;
}

.thread-expand-btn {
	display: none !important;
}

/* ---- 时间线 ---- */
.timeline {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	padding: 18px 24px 6px;
	background: var(--bg-panel);
}

.timeline>* {
	width: 100%;
	max-width: 900px;
	margin-left: auto;
	margin-right: auto;
}

.day-sep {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 20px auto 16px;
	color: var(--text-3);
	font-size: 10.5px;
	font-variant-numeric: tabular-nums;
}

.day-sep::before,
.day-sep::after {
	content: "";
	flex: 1;
	height: 1px;
	background: var(--line);
}

.timeline-note {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 40px 0;
	color: var(--text-3);
	font-size: 11.5px;
}

.spinner {
	width: 14px;
	height: 14px;
	border: 2px solid var(--line-strong);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin .8s linear infinite;
}

.msg {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	max-width: 900px;
	margin: 0 auto 18px;
}

.msg-avatar {
	margin-top: 2px;
}

.msg-main {
	min-width: 0;
	max-width: 760px;
}

.msg-meta {
	display: flex;
	align-items: center;
	gap: 7px;
	flex-wrap: wrap;
	min-height: 20px;
	margin-bottom: 4px;
	color: var(--text-3);
	font-size: 10.5px;
}

.msg-sender {
	color: var(--text);
	font-size: 12.5px;
	font-weight: 600;
}

.msg-time {
	font-variant-numeric: tabular-nums;
}

.msg-meta .chip {
	height: 19px;
	padding: 0 7px;
	font-size: 10px;
}

.msg-body {
	padding: 9px 13px;
	border: 1px solid var(--line);
	border-radius: 4px 13px 13px 13px;
	background: var(--panel);
	box-shadow: 0 1px 1px rgba(15, 23, 42, .03);
	font-size: 13.5px;
	line-height: 1.7;
	white-space: pre-wrap;
	word-break: break-word;
}

.kind-question .msg-body {
	border-left: 3px solid var(--accent);
}

.kind-fix-report .msg-body {
	border-left: 3px solid var(--ok-dot);
}

.kind-control .msg-body {
	border-left: 3px solid #dc2626;
}

.msg-self {
	flex-direction: row-reverse;
}

.msg-self .msg-main {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	max-width: 640px;
}

.msg-self .msg-meta {
	flex-direction: row-reverse;
}

.msg-self .msg-body {
	border-left-width: 1px;
	border-right: 3px solid var(--accent);
	border-color: var(--accent-line);
	border-right-color: var(--accent);
	border-radius: 13px 4px 13px 13px;
	background: var(--accent-soft);
}

.msg-self.kind-question .msg-body {
	border-left-color: var(--accent-line);
	border-right-color: var(--accent);
}

.msg-self.kind-fix-report .msg-body {
	border-left-color: var(--accent-line);
	border-right-color: var(--ok-dot);
}

.msg-self.kind-control .msg-body {
	border-left-color: var(--accent-line);
	border-right-color: #dc2626;
}

.msg-refs {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 7px;
}

.msg-self .msg-refs {
	justify-content: flex-end;
}

.ref-chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	min-width: 0;
	max-width: 100%;
	min-height: 24px;
	padding: 3px 9px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--panel);
	color: var(--text-2);
	font-size: 10.5px;
	font-weight: 500;
	line-height: 1.45;
	white-space: normal;
	overflow-wrap: anywhere;
}

.ref-chip svg {
	flex: none;
	opacity: .8;
}

a.ref-chip:hover {
	border-color: var(--accent-line);
	background: var(--accent-soft);
	color: var(--accent-strong);
	text-decoration: none;
}

.ref-chip.is-issue {
	background: var(--accent-soft);
	border-color: var(--accent-line);
	color: var(--accent-strong);
}

.ref-chip.is-evidence {
	background: var(--ok-bg);
	border-color: var(--ok-line);
	color: var(--ok);
}

.ref-chip.is-version {
	font-family: var(--mono);
	font-size: 10px;
}

.msg-deliv {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 5px;
	margin-top: 6px;
	color: var(--text-3);
	font-size: 10.5px;
}

.deliv-label {
	margin-right: 1px;
}

.deliv {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	height: 20px;
	padding: 0 8px;
	border-radius: 999px;
	background: var(--muted-bg);
	color: var(--text-2);
	font-size: 10px;
	font-weight: 500;
	white-space: nowrap;
}

.deliv i {
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: currentColor;
	flex: none;
}

.deliv.is-acked {
	background: var(--ok-bg);
	color: var(--ok);
}

.deliv.is-delivered {
	background: var(--info-bg);
	color: var(--info);
}

.deliv.is-pending {
	background: var(--warn-bg);
	color: var(--warn);
}

.deliv.is-failed {
	background: var(--danger-bg);
	color: var(--danger);
}

.deliv.is-cancelled {
	background: var(--muted-bg);
	color: var(--text-3);
}

.msg-self .msg-deliv {
	justify-content: flex-end;
}

.msg-system {
	display: flex;
	justify-content: center;
	max-width: 900px;
	margin: 2px auto 16px;
}

.msg-system .system-text {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 10px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: rgba(255, 255, 255, .72);
	color: var(--text-3);
	font-size: 10.5px;
	line-height: 1.6;
}

.msg-system .system-text time {
	font-variant-numeric: tabular-nums;
}

/* ---- 输入区 ---- */
.composer {
	flex: none;
	padding: 10px 24px 14px;
	background: var(--panel);
	border-top: 1px solid var(--line);
}

.composer-inner {
	width: 100%;
	max-width: 900px;
	margin: 0 auto;
}

.composer-toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 9px;
}

.composer-field {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--text-3);
	font-size: 10.5px;
}

.composer-field-label {
	font-weight: 500;
	white-space: nowrap;
}

.select-wrap {
	position: relative;
	display: inline-flex;
}

.select-wrap select {
	appearance: none;
	-webkit-appearance: none;
	height: 30px;
	padding: 0 26px 0 9px;
	border: 1px solid var(--line-strong);
	border-radius: 8px;
	background-color: var(--panel);
	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='%235f6b7c' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 8px center;
	background-size: 11px;
	color: var(--text-2);
	font-size: 11.5px;
	cursor: pointer;
	transition: border-color .15s, box-shadow .15s, background-color .15s;
}

.select-wrap select:hover {
	border-color: #bcc8d9;
	background-color: var(--bg-panel);
}

.select-wrap select:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.attach-btn {
	margin-left: 2px;
}

.composer-hint {
	margin-left: auto;
	color: var(--text-3);
	font-size: 10px;
	white-space: nowrap;
}

.composer-evidence {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 9px;
	padding: 7px 10px;
	border: 1px solid var(--accent-line);
	border-radius: 9px;
	background: var(--accent-soft);
	color: var(--text-2);
	font-size: 11px;
}

.composer-evidence .evidence-name {
	color: var(--text);
	font-weight: 500;
}

.composer-evidence .btn {
	margin-left: auto;
}

.composer-input-row {
	display: flex;
	align-items: stretch;
	gap: 10px;
}

.composer textarea {
	flex: 1;
	min-height: 58px;
	max-height: 200px;
	resize: vertical;
	padding: 9px 12px;
	border: 1px solid var(--line-strong);
	border-radius: 12px;
	background: var(--bg-panel);
	font-size: 13px;
	line-height: 1.6;
	transition: border-color .15s, box-shadow .15s, background .15s;
}

.composer textarea::placeholder {
	color: var(--text-3);
}

.composer textarea:focus {
	outline: none;
	border-color: var(--accent);
	background: var(--panel);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.btn-send {
	flex: none;
	min-width: 92px;
	border-radius: 12px;
}

/* ---- 模态 ---- */
.wechat-section {
	min-width: 0;
	margin: 18px 0;
}

.wechat-section summary {
	cursor: pointer;
	font-weight: 600;
	margin-bottom: 14px;
}

.wechat-break,
.wechat-list {
	overflow-wrap: anywhere;
}

.wechat-list {
	padding-left: 18px;
	font-size: 12px;
	line-height: 1.7;
}

.wechat-opt-in {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	line-height: 1.6;
}

.wechat-picker select {
	width: 100%;
	max-width: 100%;
	margin-top: 8px;
	height: 38px;
}

.modal-mask {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(15, 23, 42, .46);
	backdrop-filter: blur(2px);
	animation: fade-in .14s ease-out;
}

.modal {
	width: 480px;
	max-width: 100%;
	max-height: calc(100vh - 48px);
	overflow-y: auto;
	background: var(--panel);
	border-radius: 16px;
	box-shadow: 0 24px 60px rgba(15, 23, 42, .24);
	animation: modal-in .16s ease-out;
}

.modal-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 18px 20px 14px;
	border-bottom: 1px solid var(--line);
}

.modal-head h3 {
	margin: 0;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.4;
}

.modal-sub {
	margin: 3px 0 0;
	color: var(--text-3);
	font-size: 11px;
	line-height: 1.55;
}

.modal-body {
	padding: 16px 20px 20px;
}

.field {
	margin-bottom: 14px;
}

.field:last-child {
	margin-bottom: 0;
}

.field label {
	display: block;
	margin-bottom: 5px;
	color: var(--text-2);
	font-size: 12px;
	font-weight: 600;
}

.field input,
.field select {
	width: 100%;
	height: 38px;
	padding: 0 11px;
	border: 1px solid var(--line-strong);
	border-radius: 9px;
	background: var(--bg-panel);
	font-size: 13px;
	transition: border-color .15s, box-shadow .15s, background .15s;
}

.field input:focus,
.field select:focus {
	outline: none;
	border-color: var(--accent);
	background: var(--panel);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.field-hint {
	margin: 5px 0 0;
	color: var(--text-3);
	font-size: 10.5px;
	line-height: 1.55;
}

.modal-actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	flex-wrap: wrap;
	margin-top: 18px;
}

.modal-actions-split {
	justify-content: space-between;
}

.actions-right {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-left: auto;
}

.callout {
	display: flex;
	gap: 9px;
	margin-bottom: 14px;
	padding: 10px 12px;
	border-radius: 10px;
	font-size: 11.5px;
	line-height: 1.65;
}

.callout svg {
	flex: none;
	margin-top: 2px;
}

.callout-warn {
	background: var(--warn-bg);
	border: 1px solid var(--warn-line);
	color: var(--warn);
}

.callout strong {
	font-weight: 600;
}

.callout p {
	margin: 2px 0 0;
}

.callout code,
.token-box code {
	font-family: var(--mono);
	font-size: 11px;
}

.callout code {
	padding: 0 4px;
	border-radius: 4px;
	background: rgba(255, 255, 255, .6);
}

.token-box {
	margin-bottom: 4px;
	padding: 11px 12px;
	border: 1px solid var(--line-strong);
	border-radius: 10px;
	background: var(--bg-panel);
}

.token-box code {
	display: block;
	color: var(--text);
	line-height: 1.6;
	word-break: break-all;
	user-select: all;
}

.token-field {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin-bottom: 4px;
}

.token-field .token-box {
	flex: 1;
	min-width: 0;
	margin-bottom: 0;
}

.token-copy {
	flex: none;
	height: 32px;
	padding: 0 10px;
}

.detail-list {
	border: 1px solid var(--line);
	border-radius: 11px;
	overflow: hidden;
}

.detail-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 8px 12px;
	border-bottom: 1px solid var(--line);
	font-size: 11.5px;
}

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

.detail-row>span:first-child {
	flex: none;
	color: var(--text-3);
}

.detail-row>span:last-child {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	text-align: right;
}

/* ---- 提示 ---- */
.toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	z-index: 70;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 8px;
	max-width: min(560px, calc(100vw - 32px));
	padding: 10px 15px;
	border-radius: 12px;
	background: #0f172a;
	color: #fff;
	font-size: 12px;
	line-height: 1.5;
	box-shadow: 0 14px 34px rgba(15, 23, 42, .28);
}

.toast svg {
	flex: none;
	opacity: .9;
}

/* ---- 动效 ---- */
@keyframes fade-in {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@keyframes modal-in {
	from {
		opacity: 0;
		transform: translateY(8px) scale(.985);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

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

@media (prefers-reduced-motion: reduce) {

	*,
	*::before,
	*::after {
		animation-duration: .001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .001ms !important;
	}
}

/* ---- 窄屏：列表 / 会话 两层切换 ---- */
@media (max-width: 1100px) {
	.rail {
		width: 288px;
	}

	.msg {
		max-width: 100%;
	}

	.machine-version {
		max-width: 120px;
	}
}

@media (max-width: 860px) {
	.topbar {
		min-height: 56px;
		padding: 8px 14px;
		row-gap: 8px;
	}

	.brand-sub,
	#server-time {
		display: none;
	}

	.topbar-meta {
		margin-left: auto;
		gap: 8px;
	}

	.layout {
		flex-direction: column;
	}

	.rail {
		width: auto;
		flex: 1;
		border-right: none;
		border-bottom: none;
	}

	.rail-block {
		padding: 12px 14px 10px;
	}

	.machine-list {
		max-height: none;
	}

	.layout:not(.thread-open) .content {
		display: none;
	}

	.layout.thread-open .rail {
		display: none;
	}

	.mobile-only {
		display: inline-flex !important;
	}

	.rail-head .btn-small {
		height: 30px;
	}

	.thread-head {
		display: grid;
		grid-template-columns: 34px minmax(0, 1fr) 32px;
		grid-template-areas: "back title expand";
		align-items: center;
		padding: 8px 14px;
		gap: 8px;
	}

	#mobile-back {
		grid-area: back;
		width: 34px;
		height: 34px;
		flex: none;
	}

	.thread-title-wrap {
		grid-area: title;
		min-width: 0;
	}

	.thread-title-line {
		flex-wrap: nowrap;
		gap: 6px;
		min-width: 0;
	}

	.thread-title-line h2 {
		font-size: 15px;
		min-width: 0;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.thread-title-line .chip {
		flex: none;
	}

	.thread-meta {
		display: none;
	}

	.thread-actions {
		grid-area: actions;
		display: none;
		flex-wrap: wrap;
		justify-content: flex-start;
		gap: 6px;
		padding-top: 2px;
	}

	.thread-actions .btn {
		height: 32px;
		padding: 0 10px;
		font-size: 11.5px;
	}

	.thread-expand-btn {
		grid-area: expand;
		display: inline-flex !important;
		width: 32px;
		height: 32px;
		flex: none;
	}

	.thread-expand-btn svg {
		transition: transform .15s;
	}

	.thread-head.expanded {
		grid-template-areas: "back title expand" "actions actions actions";
		align-items: start;
		row-gap: 6px;
	}

	.thread-head.expanded .thread-title-line {
		flex-wrap: wrap;
	}

	.thread-head.expanded .thread-title-line h2 {
		white-space: normal;
		overflow: visible;
	}

	.thread-head.expanded .thread-meta {
		display: block;
	}

	.thread-head.expanded .thread-meta-created {
		display: inline;
	}

	.thread-head.expanded .thread-actions {
		display: flex;
	}

	.thread-head.expanded .thread-expand-btn {
		align-self: start;
	}

	.thread-head.expanded .thread-expand-btn svg {
		transform: rotate(180deg);
	}

	.machine-actions .btn {
		height: 30px;
	}

	.machine-actions .btn-icon {
		width: 30px;
	}

	.select-wrap select {
		height: 32px;
	}

	.timeline {
		padding: 14px 14px 4px;
	}

	.msg {
		gap: 8px;
	}

	.msg-main {
		max-width: calc(100% - 42px);
	}

	.msg-self .msg-main {
		max-width: 88%;
	}

	.composer {
		padding: 9px 14px 12px;
	}

	.composer-field-label,
	.composer-hint {
		display: none;
	}

	.modal-mask {
		padding: 16px;
	}

	.modal {
		max-height: calc(100vh - 32px);
	}
}

@media (max-width: 560px) {
	.topbar {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas: "brand meta" "chips chips";
		align-items: center;
		row-gap: 7px;
		padding: 9px 14px;
	}

	.topbar-left {
		display: contents;
	}

	.brand-group {
		grid-area: brand;
	}

	.topbar-chips {
		grid-area: chips;
		flex-basis: auto;
		order: 0;
		margin-left: 0;
	}

	.topbar-meta {
		grid-area: meta;
		margin-left: 0;
		gap: 6px;
	}

	.brand {
		font-size: 14px;
	}

	.empty-state {
		padding: 24px 18px 32px;
	}

	.thread-meta {
		font-size: 10.5px;
	}

	.thread-meta-created {
		display: none;
	}

	.thread-meta-issue {
		display: block;
	}

	.thread-meta-sep {
		display: none;
	}

	.msg-avatar {
		width: 28px;
		height: 28px;
		font-size: 11px;
	}

	.msg-main {
		max-width: calc(100% - 36px);
	}

	.msg-self .msg-main {
		max-width: calc(100% - 36px);
	}

	.msg-body {
		padding: 8px 11px;
		font-size: 13px;
	}

	.composer-toolbar {
		gap: 6px;
	}

	.attach-btn {
		margin-left: 0;
	}

	.composer-input-row {
		gap: 8px;
	}

	.btn-send {
		width: auto;
		min-width: 76px;
		height: 38px;
		align-self: flex-end;
	}

	.login-card {
		padding: 22px;
		border-radius: 16px;
	}

	.modal {
		border-radius: 14px;
	}

	.modal-actions {
		justify-content: stretch;
	}

	.modal-actions .btn {
		flex: 1;
		height: 38px;
	}

	.modal-actions-split {
		flex-direction: column-reverse;
		align-items: stretch;
	}

	.modal-actions-split>.btn {
		flex: 0 0 auto;
		width: 100%;
		height: 38px;
	}

	.actions-right {
		margin-left: 0;
	}

	.actions-right .btn {
		flex: 1;
		height: 38px;
	}

	.token-field {
		flex-direction: column;
		align-items: stretch;
	}

	.token-copy {
		width: 100%;
		height: 38px;
	}
}

@media (max-width: 860px), (max-height: 560px) {
	.thread-head.expanded {
		max-height: 40dvh;
		overflow: auto;
		overscroll-behavior: contain;
	}

	.thread-head.expanded .thread-title-line h2 {
		overflow-wrap: anywhere;
	}
}

/* 宽屏但高度不足时仍把空间留给消息与发送，不改变左右栏的导航布局。 */
@media (min-width: 861px) and (max-height: 560px) {
	.thread-head {
		padding: 8px 14px;
		gap: 8px;
	}

	.thread-title-line {
		flex-wrap: nowrap;
	}

	.thread-title-line h2 {
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.thread-meta,
	.thread-actions {
		display: none;
	}

	.thread-expand-btn {
		display: inline-flex !important;
		width: 32px;
		height: 32px;
		flex: none;
	}

	.thread-head.expanded {
		flex-wrap: wrap;
		align-items: flex-start;
	}

	.thread-head.expanded .thread-title-line {
		flex-wrap: wrap;
	}

	.thread-head.expanded .thread-title-line h2 {
		white-space: normal;
		overflow: visible;
	}

	.thread-head.expanded .thread-meta {
		display: block;
	}

	.thread-head.expanded .thread-actions {
		display: flex;
		flex-basis: 100%;
	}

	.thread-head.expanded .thread-expand-btn svg {
		transform: rotate(180deg);
	}
}

@media (max-width: 380px) {
	.logout-label {
		display: none;
	}

	#logout-btn {
		width: 32px;
		height: 32px;
		padding: 0;
	}
}
