/* ===== 主题变量 ===== */
:root {
	--radius: 12px;
	--radius-sm: 8px;
	--gap: 12px;
	--font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
	--mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

:root,
:root[data-theme='light'] {
	color-scheme: light;
	--bg: #f5f6f8;
	--card: #ffffff;
	--card-soft: #fafbfc;
	--text: #1f2328;
	--text-dim: #667085;
	--border: #e2e5ea;
	--track: #eceff3;
	--accent: #2563eb;
	--accent-text: #ffffff;
	--accent-soft: #eff4ff;
	--ok: #067647;
	--ok-soft: #e7f6ee;
	--warn: #b54708;
	--warn-soft: #fdf3e7;
	--danger: #d92d20;
	--danger-soft: #fdecea;
	--pending: #6941c6;
	--pending-soft: #f2edfd;
	--shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 8px 24px rgba(16, 24, 40, 0.06);
	--select-arrow: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23667085'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M4%206l4%204%204-4'/%3E%3C/svg%3E");
}

:root[data-theme='dark'] {
	color-scheme: dark;
	--bg: #0e1116;
	--card: #1b1f27;
	--card-soft: #171b22;
	--text: #e7e9ee;
	--text-dim: #9aa3b2;
	--border: #2b313c;
	--track: #262c36;
	--accent: #5b8def;
	--accent-text: #ffffff;
	--accent-soft: #1d2b4a;
	--ok: #75e0a7;
	--ok-soft: #12261d;
	--warn: #f3c07b;
	--warn-soft: #2b2114;
	--danger: #f97066;
	--danger-soft: #2b1614;
	--pending: #b9a1f5;
	--pending-soft: #221d33;
	--shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
	--select-arrow: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%239aa3b2'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M4%206l4%204%204-4'/%3E%3C/svg%3E");
}

/* ===== 基础 ===== */
* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
}

body {
	font-family: var(--font);
	background: var(--bg);
	color: var(--text);
	line-height: 1.5;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	transition: background 0.2s ease, color 0.2s ease;
}

button {
	font: inherit;
	cursor: pointer;
}

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

a:hover {
	text-decoration: underline;
}

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

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

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.noscript {
	text-align: center;
	padding: 2rem;
}

.container {
	width: 100%;
	max-width: 1280px;
	margin: 0 auto;
	padding: 0 16px;
}

/* ===== 顶部栏 ===== */
.topbar {
	background: var(--card);
	border-bottom: 1px solid var(--border);
	position: sticky;
	top: 0;
	z-index: 20;
}

.topbar-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 56px;
	flex-wrap: wrap;
	padding-top: 6px;
	padding-bottom: 6px;
}

.brand {
	font-weight: 700;
	font-size: 1.1rem;
	color: var(--text);
	display: inline-flex;
	align-items: baseline;
	gap: 8px;
}

.brand:hover {
	text-decoration: none;
}

.brand::before {
	content: '';
	width: 26px;
	height: 26px;
	border-radius: 7px;
	background: linear-gradient(135deg, var(--accent), #7c3aed);
	display: inline-block;
	align-self: center;
}

.brand-sub {
	font-size: 0.75rem;
	font-weight: 500;
	color: var(--text-dim);
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.topbar-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.user-area {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 34px;
}

.user-chip {
	font-weight: 600;
	font-size: 0.9rem;
	color: var(--text);
	background: var(--accent-soft);
	border-radius: 999px;
	padding: 4px 12px;
	max-width: 180px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* 用户名可跳转用户中心（服务端配置了 OIDC_ACCOUNT_URL）时给出可点击的提示 */
.user-chip-link:hover {
	text-decoration: underline;
}

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

/*
 * 顶部栏操作区控件（语言切换 / 主题切换 / 登录登出按钮）的专用视觉规范。
 * 只覆盖 .topbar-actions 内的实例，表单区与结果区的 .btn / .select 不受影响；
 * 同时不覆盖 min-height，窄屏与触屏下的触控目标仍按媒体查询放大。
 */
.topbar-actions .select {
	min-width: 110px;
	padding: 6px 10px;
	/* 右侧留出箭头宽度 + 间距，避免文字与箭头重叠 */
	padding-right: 30px;
	font-size: 1rem;
	background-position: right 10px center;
	background-size: 14px 14px;
}

.topbar-actions .icon-btn {
	background: transparent;
}

.topbar-actions .icon-btn:hover {
	background: var(--accent-soft);
	border-color: var(--border);
}

.topbar-actions .btn {
	padding: 7px 14px;
	font-size: 0.9rem;
	border-color: transparent;
	white-space: nowrap;
	transition: filter 0.15s ease, background 0.15s ease;
}

.topbar-actions .btn:hover {
	border-color: transparent;
	filter: brightness(1.06);
}

.topbar-actions .btn.ghost {
	background: transparent;
	border-color: var(--border);
}

/* 描边按钮悬停只增亮，不填充底色 */
.topbar-actions .btn.ghost:hover {
	background: transparent;
}

.topbar-actions .btn.primary {
	background: var(--accent);
	border-color: transparent;
	color: var(--accent-text);
}

/* ===== 通用控件 ===== */
.input,
.select,
textarea.input {
	width: 100%;
	min-height: 38px;
	padding: 7px 10px;
	font: inherit;
	color: var(--text);
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea.input {
	line-height: 1.45;
	resize: vertical;
}

.input:focus,
.select:focus,
textarea.input:focus {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}

.select {
	appearance: none;
	padding-right: 30px;
	background-image: var(--select-arrow);
	background-repeat: no-repeat;
	background-position: right 9px center;
	background-size: 16px 16px;
}

.select-sm {
	min-height: 32px;
	width: auto;
	font-size: 0.85rem;
}

.input-target {
	font-size: 1.05rem;
	min-height: 44px;
}

/* magic 是多条件输入：允许拖拽右下角拉高，免得长串条件只能看到一行 */
.input-magic {
	min-height: 62px;
	max-height: 320px;
	/* 拖拽右下角调整高度；宽度随列宽，不需要横向拖拽 */
	resize: vertical;
	line-height: 1.5;
	font-size: 0.85rem;
}

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 38px;
	padding: 7px 16px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--card);
	color: var(--text);
	font-weight: 600;
	transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

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

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

.btn.primary:hover {
	filter: brightness(1.06);
}

.btn.ghost:hover {
	background: var(--accent-soft);
}

.btn.small {
	min-height: 30px;
	padding: 4px 10px;
	font-size: 0.8rem;
}

.btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.icon-btn {
	width: 34px;
	height: 34px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--card);
	color: var(--text);
	font-size: 1rem;
	line-height: 1;
	/* 也用于 <a>（GitHub 入口）：链接不显示下划线 */
	text-decoration: none;
}

.icon-btn:hover {
	border-color: var(--accent);
	text-decoration: none;
}

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

/* 图标按钮内的 SVG：固定尺寸并跟随按钮文字颜色 */
.icon-btn svg {
	width: 18px;
	height: 18px;
	display: block;
	fill: currentColor;
}

/* ===== 布局 ===== */
.layout {
	flex: 1;
	display: grid;
	grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
	gap: 16px;
	align-items: start;
	padding-top: 16px;
	padding-bottom: 16px;
}

.panel {
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 16px;
}

/*
 * 表单面板故意不加 sticky / max-height / overflow-y：左右两列都是自然高度，
 * 整页共用一条滚动条。
 *
 * sticky 与「内容高于视口」是矛盾的：面板会被钉在顶部，它超出视口的下半部分
 * 就再也滚不到了。所以一旦去掉内部滚动，sticky 也必须一起去掉。
 */

.result-panel {
	min-height: 240px;
}

/* ===== 结果面板标签页 ===== */
/*
 * 标签栏用换行而不是横向滚动。
 *
 * 这里不能写 overflow-x: auto：按 CSS 规范，一个轴不是 visible 时另一个轴会
 * 被计算成 auto，于是「只为横向滚动」的声明也会让 overflow-y 变成 auto——而
 * .panel-tab 的 margin-bottom: -1px（用于让激活下划线压住容器下边框）会让
 * 内容比容器高 1px，多出来的这 1px 就变成了一条多余的纵向滚动条。
 * 保持 overflow: visible + 允许换行，则任何轴上都不会出现滚动条。
 */
.panel-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-bottom: 12px;
	border-bottom: 1px solid var(--border);
}

.panel-tab {
	flex: 0 0 auto;
	min-height: 34px;
	padding: 6px 12px;
	border: 0;
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
	background: transparent;
	color: var(--text-dim);
	font-size: 0.85rem;
	font-weight: 600;
	white-space: nowrap;
}

.panel-tab:hover {
	color: var(--text);
}

.panel-tab.is-active {
	color: var(--accent);
	border-bottom-color: var(--accent);
}

.panel-tab:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: -2px;
	border-radius: 4px;
}

/*
 * 面板切换只用 hidden 属性；显式声明 display:none，避免被 .results 的
 * display:flex 之类的规则覆盖掉。
 *
 * 面板本身不限制高度：探针列表最多 160 行，一旦给 max-height 就会出现
 * 「整页一条滚动条 + 面板内部一条滚动条」的双层滚动，很难操作。
 */
.panel-pane[hidden] {
	display: none;
}

.probe-summary {
	margin: 0 0 8px;
	font-size: 0.78rem;
	color: var(--text-dim);
}

/* 列表末尾重复同一句汇总：长列表滚到底时不必再滚回顶部确认总量 */
.probe-summary-bottom {
	margin: 8px 0 0;
}

.probe-state {
	padding: 24px 12px;
	text-align: center;
	font-size: 0.85rem;
	color: var(--text-dim);
}

.probe-table .probe-loc {
	white-space: nowrap;
}

.probe-loc-text {
	margin-left: 6px;
}

.probe-table .probe-network,
.probe-table .probe-region {
	overflow-wrap: anywhere;
}

/* 「Northern Europe · EU」折成三行很难读：保持单行，由 .table-wrap 横向滚动兜底 */
.probe-table .probe-region {
	white-space: nowrap;
}

.probe-tag-list {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

.probe-tag {
	font-size: 0.7rem;
	color: var(--text-dim);
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 1px 7px;
	white-space: nowrap;
}

.probe-table .probe-action {
	width: 1%;
	white-space: nowrap;
	text-align: right;
}

.probe-add,
.probe-remove {
	width: 28px;
	height: 28px;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1;
}

.probe-add {
	color: var(--accent);
	border-color: var(--accent);
}

.probe-remove {
	color: var(--danger);
	border-color: var(--border);
}

.probe-broad {
	font-size: 0.7rem;
	white-space: nowrap;
}

/* ===== 表单 ===== */
.field {
	display: flex;
	flex-direction: column;
	gap: 5px;
	margin-bottom: var(--gap);
}

.field > label {
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--text-dim);
}

.field-check {
	justify-content: flex-end;
}

.grid-2,
.grid-3 {
	display: grid;
	gap: 0 var(--gap);
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-wide {
	grid-column: 1 / -1;
}

.input-row {
	display: flex;
	gap: 8px;
}

.input-row .select {
	width: auto;
	min-width: 84px;
}

.hint {
	margin: 2px 0 0;
	font-size: 0.75rem;
	color: var(--text-dim);
}

/* ===== 位置筛选自动补全面板 ===== */
/*
 * 自动补全面板是挂在 body 上的浮层，用 fixed + 视口坐标定位，不参与文档流，
 * 因此与页内面板不同：它必须自己限高，否则 5000 条候选会伸展到视口之外。
 */
.suggest-panel {
	position: fixed;
	z-index: 90;
	max-height: 280px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow);
}

.suggest-panel[hidden] {
	display: none;
}

.suggest-list {
	margin: 0;
	padding: 4px;
	list-style: none;
}

.suggest-item {
	display: flex;
	align-items: baseline;
	gap: 8px;
	padding: 7px 10px;
	border-radius: 6px;
	cursor: pointer;
	line-height: 1.35;
}

.suggest-item.is-active {
	background: var(--accent-soft);
}

.suggest-label {
	font-size: 0.88rem;
	font-weight: 600;
	color: var(--text);
	overflow-wrap: anywhere;
}

.suggest-meta {
	flex: 0 1 auto;
	min-width: 0;
	font-size: 0.76rem;
	color: var(--text-dim);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.suggest-badge {
	flex: none;
	font-size: 0.72rem;
	color: var(--text-dim);
	border: 1px solid var(--border);
	border-radius: 999px;
	padding: 1px 7px;
	white-space: nowrap;
}

.suggest-count {
	/* 数字靠右对齐，方便竖排时一眼横着比较 */
	margin-left: auto;
	flex: none;
	font-size: 0.72rem;
	font-variant-numeric: tabular-nums;
	color: var(--text-dim);
	white-space: nowrap;
}

.suggest-empty {
	padding: 10px;
	font-size: 0.82rem;
	color: var(--text-dim);
	text-align: center;
}

.check {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 38px;
	font-size: 0.85rem;
	cursor: pointer;
}

.check input {
	width: 16px;
	height: 16px;
	accent-color: var(--accent);
}

/* 测量类型标签页 */
.type-tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	border: 0;
	padding: 0;
	margin: 0 0 var(--gap);
}

.type-tab {
	position: relative;
	display: inline-flex;
}

.type-tab input {
	position: absolute;
	opacity: 0;
	inset: 0;
	margin: 0;
	cursor: pointer;
}

.type-tab span {
	display: inline-flex;
	align-items: center;
	min-height: 32px;
	padding: 4px 14px;
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--text-dim);
	background: var(--card-soft);
	border: 1px solid var(--border);
	border-radius: 999px;
	transition: all 0.15s ease;
}

.type-tab input:checked + span {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-text);
}

.type-tab input:focus-visible + span {
	box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 高级选项 */
.advanced {
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	margin-bottom: var(--gap);
	background: var(--card-soft);
}

.advanced > summary {
	padding: 10px 12px;
	font-size: 0.85rem;
	font-weight: 600;
	cursor: pointer;
	list-style: none;
	display: flex;
	align-items: center;
	gap: 8px;
}

.advanced > summary::-webkit-details-marker {
	display: none;
}

.advanced > summary::before {
	content: '▸';
	font-size: 0.9em;
	color: var(--text-dim);
	transition: transform 0.15s ease;
}

.advanced[open] > summary::before {
	transform: rotate(90deg);
}

.advanced > :not(summary) {
	margin: 0 12px 12px;
}

.option-group[hidden] {
	display: none;
}

.form-actions {
	display: flex;
	gap: 8px;
	padding-top: 4px;
}

.form-actions .btn.primary {
	flex: 1;
}

/* ===== 结果区 ===== */
.results {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.placeholder {
	display: flex;
	flex-direction: column;
	gap: 8px;
	justify-content: center;
	min-height: 190px;
	padding: 16px;
	color: var(--text-dim);
	text-align: center;
	border: 1px dashed var(--border);
	border-radius: var(--radius-sm);
}

.placeholder > p {
	margin: 0;
}

.placeholder.error {
	border-color: var(--danger);
	color: var(--danger);
	text-align: left;
}

.placeholder .measure-head-row {
	justify-content: center;
}

.spinner-line::before {
	content: '';
	display: inline-block;
	width: 12px;
	height: 12px;
	margin-right: 8px;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: pa-spin 0.8s linear infinite;
	vertical-align: -2px;
}

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

.measure-head {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--border);
}

.measure-head-row {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.measure-target {
	margin: 0;
	font-size: 1.15rem;
	word-break: break-all;
}

.measure-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 16px;
	font-size: 0.78rem;
	color: var(--text-dim);
}

.measure-actions {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.badge {
	display: inline-flex;
	align-items: center;
	padding: 2px 9px;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	background: var(--card-soft);
	border: 1px solid var(--border);
	color: var(--text-dim);
	white-space: nowrap;
}

.badge.type-badge {
	background: var(--accent-soft);
	border-color: transparent;
	color: var(--accent);
	text-transform: uppercase;
}

.badge.status-ok {
	background: var(--ok-soft);
	border-color: transparent;
	color: var(--ok);
}

.badge.status-pending {
	background: var(--pending-soft);
	border-color: transparent;
	color: var(--pending);
}

.badge.status-warn {
	background: var(--warn-soft);
	border-color: transparent;
	color: var(--warn);
}

.badge.status-bad {
	background: var(--danger-soft);
	border-color: transparent;
	color: var(--danger);
}

/* 探测点列表 */
.probe-section {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.section-heading {
	margin: 0;
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--text-dim);
}

.probe-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	overflow: hidden;
}

.probe-list-item + .probe-list-item {
	border-top: 1px solid var(--border);
}

.probe-list-link {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	font-size: 0.85rem;
	color: var(--text);
	text-decoration: none;
	transition: background 0.15s ease;
}

.probe-list-link:hover {
	background: var(--accent-soft);
	text-decoration: none;
}

.probe-list-name {
	flex: 0 0 auto;
	font-weight: 600;
}

.probe-list-network {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--text-dim);
	font-size: 0.78rem;
}

.probe-list-metric {
	color: var(--text-dim);
	font-size: 0.8rem;
	white-space: nowrap;
}

.probe-flag {
	font-size: 1rem;
	line-height: 1;
}

/* 结果卡片 */
.result-card {
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--card-soft);
	padding: 12px;
	scroll-margin-top: 80px;
}

.result-card:target {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}

.result-card-head {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.result-card-title {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1 1 auto;
}

.probe-name {
	font-weight: 600;
}

.probe-meta {
	font-size: 0.75rem;
	color: var(--text-dim);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.result-card-metric {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.result-card-sub {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 12px;
	margin: 4px 0 0;
	font-size: 0.75rem;
	color: var(--text-dim);
}

.probe-tags,
.probe-resolvers {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.result-body {
	margin-top: 10px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.result-section-title {
	margin: 0;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: var(--text-dim);
}

.result-note {
	margin: 0;
	font-size: 0.8rem;
	color: var(--text-dim);
}

.result-note.error {
	color: var(--danger);
}

/* 键值列表 */
.kv {
	display: grid;
	grid-template-columns: max-content minmax(0, 1fr);
	gap: 3px 12px;
	margin: 0;
	font-size: 0.82rem;
}

/*
 * 每个键值对包在 .kv-pair 里。
 *
 * 默认 display: contents 让 dt/dd 直接参与外层两列网格（标签 | 值）；
 * .kv-inline 则把每个 pair 当作一个网格单元、标签与值纵向排列，
 * 否则方括号里的 4 个元素会并排成「标签 值 标签 值」，读起来是错的。
 */
.kv-pair {
	display: contents;
}

.kv dt {
	color: var(--text-dim);
}

.kv dd {
	margin: 0;
	word-break: break-word;
}

.kv.kv-inline {
	grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
	gap: 10px 16px;
}

.kv.kv-inline > .kv-pair {
	display: flex;
	flex-direction: column;
	gap: 1px;
}

.kv.kv-inline dt {
	font-size: 0.72rem;
}

/* 表格 */
.data-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.8rem;
}

.data-table th,
.data-table td {
	padding: 5px 8px;
	text-align: left;
	border-bottom: 1px solid var(--border);
	vertical-align: top;
	word-break: break-word;
}

.data-table th {
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--text-dim);
	background: var(--card);
	position: sticky;
	top: 0;
}

.data-table td.mono,
.data-table td.num {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.data-table td.mono.break {
	white-space: normal;
	word-break: break-all;
}

/* 主机名可能很长：宽度不足时换行，而不是把表格撑到横向滚动 */
.data-table.hops td.hop-host {
	white-space: normal;
	overflow-wrap: anywhere;
}

.mono.break,
.break {
	white-space: normal;
	word-break: break-all;
}

.data-table tr:last-child td {
	border-bottom: 0;
}

.table-wrap {
	overflow-x: auto;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	-webkit-overflow-scrolling: touch;
}

.dns-hop-title {
	margin: 0 0 6px;
	font-size: 0.78rem;
	color: var(--text-dim);
}

.dns-hop + .dns-hop {
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px dashed var(--border);
}

/* 逐包时序条形图 */
.timing-bars {
	display: flex;
	align-items: flex-end;
	gap: 3px;
	height: 56px;
	padding: 6px 8px;
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
}

.timing-bar {
	flex: 1 1 0;
	min-width: 2px;
	max-width: 16px;
	background: linear-gradient(180deg, var(--accent), #7c3aed);
	border-radius: 2px 2px 0 0;
	transition: height 0.2s ease;
}

.timing-bar-more {
	align-self: center;
	font-size: 0.7rem;
	color: var(--text-dim);
}

/* 原始输出 */
.raw-output {
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	margin-top: 10px;
	background: var(--card);
}

.raw-output > summary {
	padding: 6px 10px;
	font-size: 0.75rem;
	cursor: pointer;
	color: var(--text-dim);
	list-style: none;
	display: flex;
	align-items: center;
	gap: 6px;
}

.raw-output > summary::-webkit-details-marker {
	display: none;
}

.raw-output > summary::before {
	content: '▸';
	transition: transform 0.15s ease;
}

.raw-output[open] > summary::before {
	transform: rotate(90deg);
}

/*
 * 原始输出：高度由内容决定，不设上限。长行仍需横向滚动（相当于代码块），
 * 只保留 overflow-x 即可——高度不受限时不会出现纵向滚动条。
 */
.raw-text {
	margin: 0;
	padding: 10px;
	overflow-x: auto;
	font-size: 0.76rem;
	line-height: 1.5;
	white-space: pre;
	tab-size: 4;
	color: var(--text);
	background: var(--bg);
	border-top: 1px solid var(--border);
	border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* ===== 页脚 + 额度条 ===== */
.footer {
	position: sticky;
	bottom: 0;
	z-index: 15;
	background: var(--card);
	border-top: 1px solid var(--border);
}

.footer-inner {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	padding-top: 10px;
	padding-bottom: 10px;
}

.quota-meters {
	display: flex;
	align-items: stretch;
	gap: 10px;
	flex-wrap: wrap;
}

.quota-meter {
	display: flex;
	flex-direction: column;
	gap: 0;
	width: 214px;
	max-width: 100%;
	padding: 8px 10px;
	text-align: left;
	background: var(--card-soft);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	color: var(--text);
	transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.quota-meter:hover:not([disabled]) {
	border-color: var(--accent);
}

.quota-meter[data-active='true'] {
	background: var(--accent-soft);
	border-color: var(--accent);
}

.quota-meter[data-actor='user'][data-active='true'] {
	background: var(--pending-soft);
	border-color: var(--pending);
}

.quota-meter[disabled] {
	opacity: 0.55;
	cursor: not-allowed;
}

.quota-meter-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	font-size: 0.78rem;
}

.quota-meter-label {
	font-weight: 600;
	color: var(--text-dim);
}

.quota-meter[data-active='true'] .quota-meter-label {
	color: var(--text);
}

.quota-meter-value {
	font-variant-numeric: tabular-nums;
	font-weight: 700;
}

.quota-meter-track {
	height: 6px;
	margin: 6px 0 4px;
	border-radius: 999px;
	background: var(--track);
	overflow: hidden;
}

.quota-meter-fill {
	display: block;
	width: 0;
	height: 100%;
	border-radius: 999px;
	background: var(--accent);
	transition: width 0.3s ease, background 0.3s ease;
}

.quota-meter[data-actor='user'] .quota-meter-fill {
	background: var(--pending);
}

.quota-meter-fill[data-level='low'] {
	background: var(--warn);
}

.quota-meter-fill[data-level='empty'] {
	background: var(--danger);
}

.quota-meter-note {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 3px 10px;
	margin: 0;
	font-size: 0.68rem;
	line-height: 1.35;
	color: var(--text-dim);
}

.quota-meter-active-tag {
	color: var(--accent);
	font-weight: 700;
}

.quota-meter[data-actor='user'] .quota-meter-active-tag {
	color: var(--pending);
}

.quota-meter-reset,
.quota-meter-credits {
	font-variant-numeric: tabular-nums;
}

.footer-meta {
	flex: 1 1 260px;
	min-width: 0;
	text-align: right;
	font-size: 0.72rem;
	color: var(--text-dim);
}

.footer-note {
	margin: 0;
	line-height: 1.5;
}

.footer-version {
	margin: 3px 0 0;
	opacity: 0.75;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.footer-credit {
	margin: 3px 0 0;
	line-height: 1.5;
	opacity: 0.9;
	overflow-wrap: anywhere;
}

.footer-credit a {
	color: inherit;
	text-decoration: underline;
	text-decoration-style: dotted;
	text-underline-offset: 2px;
}

.footer-credit a:hover {
	color: var(--accent);
}

/* ===== 弹窗 / 提示 ===== */
/*
 * 登录 / 登出弹窗：半透明遮罩 + 居中提示框。遮罩、尺寸、动效与按钮排版按
 * 同一套规范统一，改动时请整体保持一致。
 */
.modal-overlay {
	position: fixed;
	inset: 0;
	/* 保持低于 toast（80）/ 补全面板（90），避免弹窗打开时把提示与补全面板盖住 */
	z-index: 60;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(16, 24, 40, 0.45);
	animation: modal-fade-in 0.15s ease;
}

.modal-dialog {
	display: flex;
	flex-direction: column;
	gap: 10px;
	/*
	 * 宽度跟随内容：默认 360px 会把较长的 SSO 提供商名挤成两行。
	 * 用 max-content 让弹框随按钮文字伸展，再由 max-width 兜住视口宽度
	 * （遮罩左右各有 16px 内边距）。
	 */
	width: max-content;
	min-width: min(92vw, 280px);
	max-width: calc(100vw - 32px);
	padding: 28px 24px;
	background: var(--card);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	animation: modal-pop-in 0.18s ease;
}

.modal-text {
	margin: 0 0 4px;
	text-align: center;
	font-size: 0.95rem;
	color: var(--text);
}

.modal-action {
	/* 由父级 flex 拉伸到弹框宽度，配合 max-content 弹框不会形成循环依赖 */
	align-self: stretch;
	padding: 11px 18px;
	font-size: 0.95rem;
	/*
	 * 弹框宽度是 max-content（受 max-width 限制），因此按钮文案只有在
	 * 超过视口上限时才会换行；正常情况下始终单行。
	 * overflow-wrap: anywhere 让没有空格的超长串也能在视口内断开。
	 */
	white-space: normal;
	overflow-wrap: anywhere;
	text-align: center;
}

/* 弹窗内按钮：与顶部栏按钮同一套规范（透明描边 + 悬停增亮） */
.modal-dialog .btn {
	border-color: transparent;
	transition: filter 0.15s ease, background 0.15s ease;
}

.modal-dialog .btn:hover {
	border-color: transparent;
	filter: brightness(1.06);
}

.modal-dialog .btn.ghost {
	background: transparent;
	border-color: var(--border);
}

.modal-dialog .btn.ghost:hover {
	background: transparent;
}

.modal-dialog .btn.primary {
	background: var(--accent);
	border-color: transparent;
	color: var(--accent-text);
}

body.modal-open {
	overflow: hidden;
}

@keyframes modal-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes modal-pop-in {
	from {
		opacity: 0;
		transform: translateY(8px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.toast-box {
	position: fixed;
	left: 50%;
	bottom: 96px;
	transform: translateX(-50%);
	z-index: 80;
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: center;
	pointer-events: none;
	width: min(90vw, 460px);
}

.toast {
	width: 100%;
	padding: 9px 14px;
	border-radius: var(--radius-sm);
	font-size: 0.85rem;
	background: var(--card);
	border: 1px solid var(--border);
	box-shadow: var(--shadow);
	animation: pa-toast-in 0.18s ease;
	word-break: break-word;
}

.toast-info {
	border-color: var(--accent);
	color: var(--text);
}

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

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

@keyframes pa-toast-in {
	from { opacity: 0; transform: translateY(6px); }
	to { opacity: 1; transform: none; }
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
	.layout {
		grid-template-columns: minmax(0, 1fr);
	}

	.footer-meta {
		text-align: left;
	}
}

@media (max-width: 620px) {
	/*
	 * 只收窄横向间距。
	 *
	 * 这里不能用简写 padding：.topbar-inner 与 .footer-inner 同时带有 container 类，
	 * 而本规则在样式表末尾、特异性又与之相同（都是单个类），简写会把它们的
	 * padding-top / padding-bottom 一并清零，于是顶栏与页脚的文字直接贴到边沿。
	 * 用 padding-inline 只改横向，纵向留给各自的规则。
	 */
	.container {
		padding-inline: 12px;
	}

	.layout {
		gap: 12px;
		padding-top: 12px;
		padding-bottom: 12px;
	}

	.panel {
		padding: 13px;
	}

	.result-card {
		padding: 10px;
	}

	.grid-2,
	.grid-3 {
		grid-template-columns: minmax(0, 1fr);
	}

	/* 触控目标放大，便于手指点按 */
	.btn {
		min-height: 42px;
	}

	.btn.small {
		min-height: 42px;
	}

	.icon-btn {
		width: 42px;
		height: 42px;
	}

	.panel-tab {
		min-height: 42px;
	}

	.probe-add,
	.probe-remove {
		width: 38px;
		height: 38px;
	}

	.select-sm {
		min-height: 42px;
	}

	.type-tabs {
		gap: 8px;
	}

	.type-tab span {
		min-height: 42px;
		padding: 6px 16px;
	}

	.check {
		min-height: 42px;
	}

	.probe-list-link {
		min-height: 44px;
	}

	.advanced > summary,
	.raw-output > summary {
		min-height: 42px;
	}

	.topbar-inner {
		gap: 8px;
		/*
		 * 窄屏下按钮会放大到 42px（见下方触控目标相关的规则），
		 * 桌面端的 6px 上下留白此时会让内容显得贴边，这里放宽到 10px。
		 */
		padding-block: 10px;
	}

	/*
	 * 语言选择框 + 主题按钮 + 用户名 + 登录/登出按钮在窄屏会超出可用宽度：
	 * 允许换行并右对齐。
	 */
	.topbar-actions {
		flex-wrap: wrap;
		justify-content: flex-end;
	}

	.user-chip {
		max-width: 10ch;
	}

	.measure-actions,
	.form-actions {
		gap: 6px;
	}

	.form-actions .btn {
		flex: 1 1 auto;
	}

	/* 键值列表：值可换行，长内容不会撑破卡片 */
	.kv.kv-inline {
		grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
		gap: 6px 10px;
	}

	.kv dd {
		overflow-wrap: anywhere;
	}

	/*
	 * 两条额度条在小屏并排（一左一右），各占一半宽度。
	 *
	 * 容器保持整行宽度，两条各自 flex: 1 1 0 平分；min-width: 0 是必需的，
	 * 否则 flex 项的最小尺寸默认是 min-content，长文案（如英文的
	 * Shared account quota）会把宽度顶开，两条就折成两行。
	 */
	.quota-meters {
		width: 100%;
		gap: 8px;
	}

	.quota-meter {
		flex: 1 1 0;
		min-width: 0;
		width: auto;
		/* 列变窄后收紧内边距，把宽度让给文案与进度条 */
		padding: 7px 8px;
	}

	/* 窄列里标签与数值可能同行放不下：允许换行，避免把标签从词中间挤断 */
	.quota-meter-head {
		flex-wrap: wrap;
		gap: 2px 6px;
	}

	/* 页脚的 10px 上下留白由基础规则提供，这里只收窄列间距 */
	.footer-inner {
		gap: 10px;
	}

	.footer-meta {
		overflow-wrap: anywhere;
	}

	.probe-list-network {
		display: none;
	}

	/* ===== 窄屏表格：隐藏表头，单元格堆叠为卡片 ===== */
	.data-table {
		display: block;
		font-size: 0.78rem;
	}

	.data-table thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.data-table tbody,
	.data-table tr,
	.data-table td {
		display: block;
	}

	.data-table tr {
		padding: 7px 9px;
		border-bottom: 1px solid var(--border);
	}

	.data-table tr:last-child {
		border-bottom: 0;
	}

	.data-table td {
		padding: 0;
		border-bottom: 0;
		white-space: normal;
	}

	.data-table td[data-label]::before {
		content: attr(data-label);
		flex: 0 0 auto;
		margin-right: 6px;
		font-size: 0.7rem;
		color: var(--text-dim);
	}

	/* MTR / traceroute：序号 + 地址一行，主机名独占一行，统计值一行四列 */
	.data-table.hops tr {
		display: flex;
		flex-wrap: wrap;
		align-items: baseline;
		gap: 2px 8px;
	}

	.data-table.hops td {
		flex: 0 0 auto;
	}

	.data-table.hops td.hop-idx {
		min-width: 1.1em;
		color: var(--text-dim);
	}

	.data-table.hops td.hop-addr {
		flex: 1 1 auto;
		min-width: 0;
		overflow-wrap: anywhere;
	}

	.data-table.hops td.hop-host {
		flex: 1 1 100%;
		min-width: 0;
		overflow-wrap: anywhere;
	}

	.data-table.hops td.hop-addr,
	.data-table.hops td.hop-host,
	.data-table.hops td.hop-stat,
	.data-table.hops td.hop-rtt {
		white-space: normal;
	}

	.data-table.hops td.hop-stat {
		display: flex;
		flex: 1 1 18%;
		flex-direction: column;
		min-width: 0;
	}

	.data-table.hops td.hop-rtt {
		display: flex;
		flex: 1 1 100%;
		flex-wrap: wrap;
		gap: 2px 6px;
	}

	/* DNS 应答 / HTTP 响应头：属性与值各占一行，记录值可换行 */
	.data-table.dns-answers td.dns-name,
	.data-table.dns-answers td.dns-value,
	.data-table.http-headers td.hdr-name,
	.data-table.http-headers td.hdr-value {
		display: block;
		white-space: normal;
		overflow-wrap: anywhere;
	}

	.data-table.dns-answers td.dns-value,
	.data-table.http-headers td.hdr-value {
		margin-top: 2px;
	}

	.data-table.dns-answers td.dns-meta {
		display: inline-block;
		margin-right: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	* {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}
}

/*
 * 小屏滚动时收起顶栏与页脚
 *
 * 由 `src/frontend/scroll-chrome.ts` 给对应区域加 `.chrome-hidden`；断点必须与该模块
 * 导出的 MOBILE_QUERY 一致。
 *
 * 用 transform 而不是高度或 display：两个区域都是 sticky，仍然占据布局中自身的空间，
 * 页面不会重排，正文也不会跳动。
 */
@media (max-width: 620px) {
	.topbar,
	.footer {
		transition: transform 0.25s ease;
	}

	.topbar.chrome-hidden {
		transform: translateY(-100%);
	}

	.footer.chrome-hidden {
		transform: translateY(100%);
	}
}

/* 触屏设备（含平板 / 横屏手机）：无论宽度都放大可点按区域 */
@media (hover: none) and (pointer: coarse) {
	.type-tab span,
	.btn.small,
	.select-sm,
	.raw-output > summary,
	.advanced > summary,
	.probe-list-link {
		min-height: 42px;
	}

	.icon-btn {
		width: 42px;
		height: 42px;
	}

	/* 标签页与探针列表的增删按钮同样要够大 */
	.panel-tab {
		min-height: 42px;
	}

	.probe-add,
	.probe-remove {
		width: 38px;
		height: 38px;
	}

	.suggest-item {
		min-height: 44px;
		align-items: center;
	}
}
