/* 数学工具箱共享样式 */
.tbs-hero { background: linear-gradient(135deg,#4f46e5 0%,#2563eb 60%,#0ea5e9 100%); }
.tbs-hero .tbs-hero-title { color:#fff; }
.tbs-hero .tbs-hero-sub { color:rgba(255,255,255,.85); }

.tbs-tool-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:1rem; }
.tbs-tool-card {
	display:block; text-decoration:none; color:inherit;
	background:#fff; border:1px solid var(--border-color,#eee); border-radius:14px;
	padding:1.1rem; transition:.18s; height:100%;
}
.tbs-tool-card:hover { transform:translateY(-3px); box-shadow:0 .5rem 1.25rem rgba(0,0,0,.08); border-color:#c7d2fe; }
.tbs-tool-ico {
	width:46px;height:46px;border-radius:12px;display:inline-flex;align-items:center;justify-content:center;
	font-size:24px;font-weight:700;line-height:1;color:#fff;
	background:linear-gradient(135deg,#6366f1,#2563eb);margin-bottom:.6rem;
}
.tbs-tool-name { font-weight:600; }
.tbs-tool-desc { font-size:13px;color:#6b7280;margin-top:2px; }

/* 工具页通用布局 */
.tbs-wrap { display:grid; grid-template-columns:320px 1fr; gap:1.25rem; align-items:start; }
@media (max-width:991px){ .tbs-wrap{ grid-template-columns:1fr; } }
.tbs-panel { position:sticky; top:76px; }
@media (max-width:991px){ .tbs-panel{ position:static; } }
.tbs-preview {
	background:#fff;border:1px solid var(--border-color,#eee);border-radius:14px;padding:1rem;
	min-height:420px;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;
}
.tbs-toolbar { display:flex;flex-wrap:wrap;gap:.5rem;margin-bottom:.75rem; }

/* SVG 图纸通用 */
.tbs-svg-box { width:100%; overflow:auto; display:flex; justify-content:center; }
.tbs-svg-box svg { max-width:100%; height:auto; background:#fff; }

/* 水印：屏幕不显示，仅打印出现 */
.tbs-watermark { display: none; }

/* 打印：仅输出“题单/图纸”，整站导航、页脚、悬浮按钮全部不打印 */
@media print {
	/* 0) 显式隐藏站点导航、页脚、悬浮条、公告、弹层等（body 的直接子元素，位于 #body 之外） */
	body > header#header,
	body > .bbs-footer,
	body > footer,
	body > #floatingActions,
	body > .floating-actions,
	body > #mobileTabbar,
	body > .bottom-nav,
	body > #announcement-toast-container,
	body > #xnLightbox,
	body > .modal,
	body > .toast-container { display: none !important; }
	/* 兼容：任何非 main#body 的 body 直接子元素也隐藏（兜底） */
	body > :not(main#body) { display: none !important; }

	/* 1) #body 内：隐藏控制面板/面包屑/标题栏等非打印 UI（工具内容 .tbs-wrap 保留） */
	main#body .tbs-no-print { display: none !important; }
	main#body .tbs-head-row, main#body .tbs-subnav, main#body .tbs-toolbar { display: none !important; }

	/* 2) 取消双栏：让 .tbs-wrap 内仅剩 .tbs-print-area，独占页面（不隐藏 .container 包层，避免把打印区一并藏掉） */
	main#body .tbs-wrap { display: block !important; grid-template-columns: 1fr !important; gap: 0 !important; }
	/* 强清零：消除主题在打印时可能残留的容器内边距/偏移，让内容从纸张左上角起排 */
	main#body, main#body > .container, main#body .container, main#body .container.py-3 {
		margin: 0 !important; padding: 0 !important; max-width: none !important; width: 100% !important; border: none !important;
	}
	main#body .container { margin-inline: 0 !important; }

	/* 3) 打印区：纯白底，整块输出 */
	.tbs-print-area {
		display: block !important;
		width: 100% !important;
		min-width: 0 !important;
		padding: 0 !important;
		border: none !important;
		background: #fff !important;
		box-shadow: none !important;
		min-height: 0 !important;
		overflow: visible !important;
	}

	/* 4) 整页 A4 图纸(.tbs-svg-box)等比铺满；其它紧凑 svg（如 nets3d）保持原尺寸并居中 */
	.tbs-print-area .tbs-svg-box svg { width: 100% !important; height: auto !important; max-width: 100% !important; display: block !important; }
	.tbs-print-area svg { max-width: 100% !important; display: block !important; height: auto !important; margin-inline: auto; }

	/* 5) 水印：仅右下角一次 */
	.tbs-watermark {
		display: block !important;
		position: fixed;
		right: 6mm;
		bottom: 5mm;
		left: auto;
		top: auto;
		font-size: 11px;
		color: #9aa0a6;
		font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
		z-index: 9999;
		line-height: 1;
	}

	@page { size: A4; margin: 0; }
	html, body { background: #fff !important; width: 100% !important; overflow: visible !important; margin: 0 !important; }

	/* 4b) 整页 A4 图纸（方格纸/图形变换等）：锁定为恰好一页高，杜绝因舍入/空隙产生的第二张空白页 */
	.tbs-svg-box { display: block !important; height: 100vh !important; overflow: hidden !important; line-height: 0; page-break-after: avoid; }
	.tbs-svg-box svg { width: 100% !important; height: 100% !important; max-height: calc(100vh - 1px) !important; display: block !important; }
}

/* 小数/分数显示 */
.tbs-frac { display:inline-flex; flex-direction:column; text-align:center; vertical-align:middle; line-height:1.05; }
.tbs-frac > .tbs-frac-num { border-bottom:1.5px solid currentColor; padding:0 .4em .08em; }
.tbs-frac > .tbs-frac-den { padding:.08em .4em 0; }
.tbs-prob .tbs-frac, .tbs-line .tbs-frac { font-size:1.02em; }

/* 结果区 */
.tbs-result {
	width:100%; background:#f8fafc; border:1px solid #eef2f7; border-radius:12px; padding:1rem; margin-top:.5rem;
}
.tbs-steps { font-size:14px; line-height:1.9; }
.tbs-steps .tbs-step { padding:.25rem 0; border-bottom:1px dashed #e5e7eb; }
.tbs-steps .tbs-step:last-child { border-bottom:none; }

.tbs-badge { font-size:12px; padding:2px 8px; border-radius:999px; background:#eef2ff; color:#4338ca; }

/* ===== 题单 / 文本类工具：A4 纸张预览 + 打印样式 ===== */
/* 屏幕：题单呈现在一张“纸”上，排版接近真实 A4 输出 */
.tbs-sheet {
	box-sizing: border-box;
	width: min(100%, 210mm);          /* A4 宽；比预览容器窄时自适应 */
	margin: 0 auto;
	background: #fff;
	border: 1px solid #e7ecf3;        /* 屏显“纸边”，打印时会去除 */
	box-shadow: 0 3px 18px rgba(15,23,42,.08);
	padding: 9mm 11mm 14mm;
	line-height: 1.8;
}
.tbs-sheet-title {
	font-weight:700; font-size:19px; text-align:center;
	margin:0 0 1rem; letter-spacing:.04em; color:#0f172a;
}
/* 试卷顶部：标题在左，右上角 班级/姓名/日期 */
.tbs-sheet-head { display:flex; justify-content:space-between; align-items:flex-end; gap:1rem; margin:0 0 .9rem; flex-wrap:wrap; }
.tbs-sheet-head .tbs-sheet-title { margin:0; text-align:left; letter-spacing:.02em; }
.tbs-exam-meta { display:flex; flex-wrap:wrap; gap:1rem .9rem; font-size:14px; color:#334155; white-space:nowrap; }
.tbs-underline { border-bottom:1px solid #0f172a; display:inline-block; padding:0 .2rem 2px; min-width:3.6em; }
/* 试卷抬头：右上角 班级/姓名/日期 一行 */
.tbs-sheet-meta { display:flex; justify-content:flex-end; margin:0 0 .15rem; }
@media print { .tbs-sheet-head { margin-bottom:.5rem; } .tbs-sheet-meta { margin-bottom:.05rem; } }

/* 通用计算器：页签 */
.tbs-calc-tabs { gap:.3rem; flex-wrap:wrap; }
.tbs-calc-tabs .nav-link { font-size:13px; padding:.28rem .6rem; border-radius:8px; color:#475569; border:1px solid transparent; }
.tbs-calc-tabs .nav-link.active { background:var(--tbs-primary); color:#fff; }
.tbs-calc-tabs .nav-link:hover { color:var(--tbs-primary); }
.tbs-calc-fracs { display:flex; flex-direction:column; gap:.45rem; }
.tbs-calc-frac-row { display:flex; align-items:center; gap:.35rem; width:100%; min-width:0; }
.tbs-calc-frac-lbl, .tbs-calc-op-label { flex:0 0 auto; font-size:12px; color:#94a3b8; width:2em; }
.tbs-calc-frac-row input.form-control, .tbs-calc-frac-row select.form-select { flex:1 1 0; width:auto; min-width:0; }
.tbs-calc-frac-row .tbs-fr-slash { flex:0 0 auto; font-size:16px; color:#475569; }

/* 几何画板 */
.tbs-wrap--canvas { grid-template-columns: 280px 1fr; }
.tbs-geo-tools { display:grid; grid-template-columns:repeat(5,1fr); gap:.35rem; }
.tbs-geo-tool {
	aspect-ratio:1/1; display:flex; align-items:center; justify-content:center;
	border:1px solid #e2e8f0; background:#fff; border-radius:8px; cursor:pointer; color:#475569;
}
.tbs-geo-tool:hover { border-color:#c7d2fe; color:var(--tbs-primary); }
.tbs-geo-tool.is-on { background:var(--tbs-primary); border-color:var(--tbs-primary); color:#fff; }
.tbs-geo-canvas-wrap { width:100%; overflow:auto; }
.tbs-geo-canvas-wrap svg { max-width:none; }
/* 题单网格：列等分；用 minmax(0,1fr) 防止内容撑破单元格 */
.tbs-prob-grid {
	display:grid;
	grid-template-columns:repeat(var(--cols,3),minmax(0,1fr));
	gap:.95rem 1.7rem;
	align-items:stretch;
}
/* 单格：留白充足、行高舒展，题目与答案在格内垂直居中，避免“挤在一起” */
.tbs-prob {
	font-size:16px; line-height:1.7;
	padding:.55rem .4rem .6rem;
	background:#fff; border-radius:8px;
	min-height:2.3em;
	min-width:0; overflow-wrap:break-word;
}
.tbs-prob-no { color:#94a3b8; font-size:.85em; margin-right:.5rem; }
/* 答案：行内红色缩进清晰 */
.tbs-ans { color:#1d4ed8; font-weight:600; }

/* 判断题专用排版：题干居左、作答框居右、答案行独立显示 */
.tbs-prob--check { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; column-gap:1rem; }
.tbs-prob--check .tbs-prob-q { font-size:16px; line-height:1.6; }
.tbs-prob--check .tbs-mark {
	font-size:15px; padding:.25rem .6rem; border:1px solid #cbd5e1; border-radius:8px;
	background:#f8fafc; color:#475569; white-space:nowrap;
}
.tbs-prob--check .tbs-mark b { color:#0f172a; }
.tbs-prob--check .tbs-result { flex-basis:100%; font-size:14px; color:#1d4ed8; font-weight:600; margin-top:.35rem; }

@media print {
	.tbs-prob { font-size:15px; line-height:1.6; padding:.45rem .1rem; min-height:0; }
	.tbs-prob--check { min-height:0; }
}

/* 分数在题内排版：分子分母同一字号、上下留白，避免撑高错位 */
.tbs-prob .tbs-frac, .tbs-line .tbs-frac, .tbs-compare-item .tbs-frac { font-size:.98em; }
.tbs-frac-num, .tbs-frac-den { padding-inline:.28em; }

/* 打印：题单贴合纸张，A4 宽内分页，不给正文加会改变分页比例的容器边 */
@media print {
	.tbs-sheet {
		width:auto !important; max-width:100% !important;
		padding: 8mm 10mm 18mm;        /* 左右=打印页边距，底部留出水印位置 */
		border:0 !important; box-shadow:none !important; margin:0 !important;
	}
	.tbs-prob-grid { gap:.45rem .8rem; column-gap:1.2rem; }
	.tbs-prob { font-size:14px; line-height:1.95; break-inside:avoid; page-break-inside:avoid; }
	.tbs-line { break-inside:avoid; }
	.tbs-sheet-title { font-size:17px; page-break-after:avoid; }
}

/* 数独 */
.tbs-sudoku {
	border-collapse:collapse;
	margin:1rem auto;
	border:2.5px solid #1f2937;         /* 外框清晰可见 */
	background:#fff;
}
.tbs-sudoku td {
	width:40px; height:40px;
	text-align:center; vertical-align:middle;
	font-size:19px;
	border:1px solid #cbd5e1;
	box-sizing:border-box;
}
/* 九宫格粗线（每 3 行/3 列一条粗分隔） */
.tbs-sudoku td.b { border-top:2.5px solid #1f2937; }
.tbs-sudoku td.r { border-left:2.5px solid #1f2937; }
.tbs-sudoku td.given { font-weight:700; color:#0f172a; background:#f1f5f9; }
.tbs-sudoku td:empty { background:#fff; }
@media print { .tbs-sudoku td { width:38px; height:38px; } }

/* 24 点卡 */
.tbs-cards { display:flex; gap:.6rem; justify-content:center; margin:.6rem 0; flex-wrap:wrap; }
.tbs-card-chip { width:54px; height:54px; border-radius:10px; background:#eef2ff; color:#3730a3; display:flex; align-items:center; justify-content:center; font-size:24px; font-weight:700; border:1px solid #c7d2fe; }

/* 通用卡片/结果行 */
.tbs-line { font-size:15px; line-height:1.9; padding:.2rem 0; border-bottom:1px dotted #e5e7eb; }
.tbs-chip-row { display:flex; flex-wrap:wrap; gap:.5rem; }
.tbs-chip { padding:.2rem .6rem; border-radius:8px; background:#f1f5f9; border:1px solid #e2e8f0; font-size:14px; }

/* ===== v1.1 体验优化 ===== */
:root {
	--tbs-primary:#4f46e5;
	--tbs-primary-2:#2563eb;
	--tbs-accent:#e11d48;
	--tbs-bg:#f4f6fb;
	--tbs-border:#e4e9f2;
	--tbs-text:#1f2937;
	--tbs-muted:#6b7280;
}

/* 首页：搜索 + 分组筛选 */
.tbs-index-bar { max-width:560px; }
.tbs-search-wrap { border-radius:999px; overflow:hidden; box-shadow:0 1px 3px rgba(0,0,0,.04); }
.tbs-filter { display:flex; flex-wrap:wrap; gap:.4rem; align-items:center; }
.tbs-filter-chip {
	display:inline-flex; align-items:center; gap:.35rem;
	border:1px solid var(--tbs-border); background:#fff; color:#475569;
	border-radius:999px; padding:.4rem .9rem; font-size:14px; font-weight:600; cursor:pointer; transition:.16s;
	box-shadow:0 1px 2px rgba(15,23,42,.04);
}
.tbs-filter-chip i { font-size:1.05em; }
.tbs-filter-chip:hover { border-color:#a5b4fc; color:var(--tbs-primary); transform:translateY(-1px); box-shadow:0 3px 8px rgba(79,70,229,.12); }
.tbs-filter-chip.is-on {
	background:linear-gradient(135deg,var(--tbs-primary),var(--tbs-primary-2));
	border-color:transparent; color:#fff;
	box-shadow:0 3px 10px rgba(79,70,229,.28);
}
.tbs-group-block { scroll-margin-top:80px; }
.tbs-group-title { letter-spacing:.04em; display:flex; align-items:center; gap:.25rem; padding:.4rem 0 .3rem; }
.tbs-group-title i { color:var(--tbs-primary); font-size:1.05em; }
.tbs-hero-sub { color:#64748b; font-size:15px; line-height:1.7; }
.tbs-tool-card { position:relative; }
.tbs-tool-hot {
	position:absolute; top:.6rem; right:.6rem; font-size:11px; color:#fff; background:rgba(225,29,72,.85);
	padding:0 .4rem; border-radius:999px;
}
.tbs-tool-ico { background:linear-gradient(135deg,var(--tbs-primary),var(--tbs-primary-2)); }
.tbs-tool-name { padding-right:1.4rem; }

/* 工具页：面包屑 + 分组子导航 */
.tbs-subnav {
	display:flex; flex-wrap:wrap; gap:.4rem; padding:.5rem;
	background:#fff; border:1px solid var(--tbs-border); border-radius:14px;
}
.tbs-subnav-item {
	display:inline-flex; align-items:center; text-decoration:none;
	padding:.32rem .7rem; border-radius:10px; font-size:13px; color:var(--tbs-muted);
	border:1px solid transparent; transition:.15s; white-space:nowrap;
}
.tbs-subnav-item:hover { color:var(--tbs-primary); background:#f4f6fb; }
.tbs-subnav-item.is-on { background:var(--tbs-primary); color:#fff; }
.tbs-subnav-item.is-on i { color:inherit; }

/* 统一：结果/提示区字号微调、操作按钮统一样式 */
.tbs-printbar { display:flex; gap:.5rem; flex-wrap:wrap; }
.tbs-hint {
	font-size:13px; color:var(--tbs-muted); line-height:1.7;
	background:#f8fafc; border:1px dashed #dfe5ee; border-radius:10px; padding:.5rem .7rem; margin-top:.6rem;
}
.tbs-hint b { color:var(--tbs-text); }

/* 工具页标题行副标题变淡一点，避免与主标题抢视觉 */
.tbs-head-row + .tbs-wrap { margin-top:2px; }

/* 分数格式化：两分数输入行紧凑且不撑破左侧面板 */
.tbs-fr-frac { flex-wrap:nowrap; }
.tbs-fr-frac input { flex:1 1 0; min-width:0; width:auto; max-width:none; }
.tbs-fr-frac .tbs-fr-slash { flex:0 0 auto; font-size:17px; color:#475569; }
.tbs-fr-frac .tbs-fr-fracidx { flex:0 0 auto; font-size:13px; color:#94a3b8; }

/* SVG 图纸（分数条/立体展开图/函数图等）：屏幕预览时在纸张/预览区内水平居中并自适应，避免贴左/被裁 */
.tbs-print-area .tbs-svg-box,
.tbs-print-area > .w-100,
.tbs-print-area {
	text-align:center;
}
.tbs-svg-box svg,
.tbs-print-area svg {
	max-width:100%;
	height:auto;
	display:inline-block;
	vertical-align:middle;
}
.tbs-svg-box { text-align:center; }

/* ===== v1.2 新工具样式 ===== */
/* 看图列式 */
.tbs-pic-grid { display:grid; gap:1.2rem 1rem; }
.tbs-pic-item { border:1px dashed #dbe2ef; border-radius:12px; padding:.5rem; }
.tbs-pic-svg { display:flex; justify-content:center; }
.tbs-pic-svg svg { max-width:100%; height:auto; }
.tbs-pic-eq { text-align:center; font-size:18px; margin-top:.2rem; }
@media print { .tbs-pic-item { border-color:#cbd5e1; break-inside:avoid; } }

/* 补全算式填空：用下划线占位 */
.tbs-fill-blank { display:inline-block; min-width:2.2em; border-bottom:2px solid #334155; color:transparent; }
.tbs-prob.has-ans .tbs-fill-blank { color:#1d4ed8; border-bottom-color:#1d4ed8; }

/* 比大小 / 排序题 */
.tbs-compare-grid { display:grid; grid-template-columns:repeat(var(--cols,2),minmax(0,1fr)); gap:.8rem 1.6rem; align-items:stretch; }
.tbs-compare-item { font-size:18px; text-align:center; padding:.35rem; border-bottom:1px dotted #e5e7eb; }
@media print { .tbs-compare-item { break-inside:avoid; } }

/* 竖式过程（加/减/乘 展示） */
.tbs-longwrap { display:grid; gap:1rem; }
.tbs-longline { font-family:Georgia,"Times New Roman",serif; }
.tbs-longstep-row { font-family:"Times New Roman",Georgia,serif; font-size:16px; line-height:1.15; white-space:pre; margin:.15rem 0; }
.tbs-longstep-row b { color:#1d4ed8; }

/* 通用空行填写（文字题答案行） */
.tbs-wline { font-size:16px; line-height:2; margin:.35rem 0; }
.tbs-wline .ans { color:#1d4ed8; font-weight:600; }
@media print { .tbs-wline { break-inside:avoid; } }

/* ===== 图标兼容：当前 Tabler 版本缺失若干类名，映射到现有字形 ===== */
.ti-reload:before { content:"\eb13"; }
.ti-toolbox:before { content:"\ebca"; }
.ti-dots-vertical:before { content:"\efb1"; }
.ti-shape:before { content:"\eb2e"; }
.ti-calculator:before { content:"\eabc"; }
.ti-divide:before { content:"\eaf2"; }
.ti-sigma:before { content:"\eabc"; }
.ti-shape-2:before { content:"\ebca"; }
