/* ============================================================================
 * css/bx31.css —— p68：图片「边框 Border」/「阴影 Shadow」两个模块的样式
 * ----------------------------------------------------------------------------
 * 单独成文件（而不是追加进 v7.css）的原因：这两个模块是**独立模块**，
 * 样式也应当独立可摘；同时 win31/ 目录下有别的会话在并发改 v7.css，
 * 新开一个文件能彻底避免行级冲突。
 *
 * 加载顺序：css/win31.css → v6.css → v7.css → **bx31.css**（最后，可覆盖上面三个）
 *
 * 两大部分：
 *   一、画框本身（.bx31 / .sh31）—— 预览与文档里都用这一套 DOM
 *   二、对话框外壳（.bxw-*）—— 与站内 .wd-dlg / .nd31-box 同一套 Win3.1 语汇
 * ========================================================================== */

/* ============================================================
 * 一、画框 DOM
 *   分层（外→内）：.bx31 → .bx31-pd → (.bx31-sh | img | .bx31-is)
 *                              → .bx31-ir / .bx31-tx / .bx31-bg
 *   注意：.bx31-sh 是 position:absolute + z-index:0，
 *        所以 img 必须 position:relative + z-index:1，否则阴影会盖住图片
 *        （CSS 绘制顺序：有定位且 z-index:0 的元素晚于普通流内容绘制）。
 * ============================================================ */
.bx31 {
  display: inline-block;
  position: relative;
  vertical-align: middle;
  line-height: 0;
  box-sizing: content-box;
}
.bx31-pd { display: inline-block; position: relative; line-height: 0; }
.bx31-im { display: block; max-width: 100%; position: relative; z-index: 1; }
.bx31-sh {
  position: absolute; z-index: 0;
  display: none;
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: 0 0;
}
.bx31-ir, .bx31-is { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; }
.bx31-ir { z-index: 3; }
.bx31-is { z-index: 2; }
.bx31-tx {
  position: absolute; z-index: 4;
  pointer-events: none;
  overflow: hidden;
  line-height: 1.15;
  white-space: nowrap;
}
.bx31-tx[style*="vertical-rl"] { white-space: normal; }
.bx31-bg { position: absolute; z-index: 5; pointer-events: none; line-height: 1; text-align: center; }
.bx31-bg img { display: block; width: 100%; height: 100%; }

/* 只带阴影、没有边框的图片 —— 阴影模块自己造的最小外壳 */
.sh31 { display: inline-block; position: relative; vertical-align: middle; line-height: 0; }
.sh31 > img { display: block; position: relative; z-index: 1; }
.sh31-l {
  position: absolute; z-index: 0;
  display: none;
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: 0 0;
}

/* 导出时用的离屏画布不进 DOM，无需样式；这里只兜住浏览器原生拖影 */
.bx31-im, .sh31 > img { -webkit-user-drag: none; }

/* ============================================================
 * 二、对话框外壳
 * ============================================================ */
.bxw-ov {
  position: fixed; inset: 0; z-index: 100030;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .30);
}
.bxw {
  position: relative;
  display: flex; flex-direction: column;
  box-sizing: border-box;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  background: var(--face, #c0c0c0);
  border: 1px solid #000;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .45);
  font-family: 'SimSun31', 'Win31System', 'F31Latin', 'ZpixCJK', 'F31Hans', 'F31Hant', monospace;
  color: var(--text-main, #000);
}

/* ---------- 标题栏（沿用窗口那一套语汇：系统菜单盒 19×19、无独立关闭键） ---------- */
.bxw-tb {
  flex: 0 0 auto; height: 20px;
  display: flex; align-items: flex-start;
  background: var(--title-active, #0000a8);
  color: #fff;
}
.bxw-sys {
  flex: 0 0 19px; width: 19px; height: 19px;
  box-sizing: border-box;
  background: var(--face, #c0c0c0);
  border-left: 1px solid #000; border-right: 1px solid #000;
  box-shadow: inset 1px 1px 0 var(--face-light, #dfdfdf), inset -1px -1px 0 var(--face-shadow, #808080);
  position: relative;
}
.bxw-sys::after {
  content: ''; position: absolute; left: 2px; top: 7px; width: 13px; height: 3px;
  background: #fff; box-shadow: 0 0 0 1px #000, 1px 1px 0 1px #808080;
}
.bxw-tt {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center;
  padding-left: 4px;
  font-size: 13px; letter-spacing: .65px; font-weight: normal;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- 标签页 ---------- */
.bxw-tabs {
  flex: 0 0 auto;
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 4px 5px 0;
  background: var(--face, #c0c0c0);
  border-bottom: 1px solid #808080;
}
.bxw-tabs .bxw-tab {
  min-height: 0 !important; min-width: 0 !important; max-height: none !important;
  height: 22px; padding: 0 9px; font-size: 12px;
  box-shadow: inset 1px 1px 0 var(--face-light, #dfdfdf), inset -1px -1px 0 var(--face-shadow, #808080) !important;
}
.bxw-tabs .bxw-tab.on {
  background: var(--win-bg, #ffffff) !important;
  box-shadow: inset 1px 1px 0 var(--face-light, #dfdfdf), inset -1px 0 0 var(--face-shadow, #808080) !important;
  margin-bottom: -1px;
  padding-bottom: 1px;
}

/* ---------- 主体：左预览 / 右控件 ---------- */
.bxw-body {
  flex: 1 1 auto; min-height: 0;
  display: flex; gap: 6px; padding: 6px;
}
.bxw-left {
  flex: 0 0 306px; min-width: 0;
  display: flex; flex-direction: column; gap: 5px;
}
.bxw-stage {
  flex: 1 1 auto; min-height: 120px;
  display: flex; align-items: center; justify-content: center;
  background: var(--win-bg, #ffffff);
  border: 1px solid #808080;
  box-shadow: inset 1px 1px 0 #000;
  overflow: auto;
  padding: 6px;
  box-sizing: border-box;
}
.bxw-cv { display: block; max-width: 100%; max-height: 100%; }
.bxw-bbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-main, #000);
}
.bxw-cbon { display: flex; align-items: center; gap: 3px; white-space: nowrap; cursor: var(--cur-hand, pointer); }
.bxw-bsp { flex: 1 1 auto; min-width: 40px; }
.bxw-right {
  flex: 1 1 auto; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--win-bg, #ffffff);
  border: 1px solid #808080;
  box-shadow: inset 1px 1px 0 #000;
  overflow-y: auto;
  overflow-x: hidden;
}
.bxw-page { padding: 8px 10px 12px; }

/* ---------- 分组 / 行 / 标签 ---------- */
.bxw-grp { margin: 0 0 12px; }
.bxw-gt {
  font-size: 12px; font-weight: bold;
  padding: 2px 0 3px;
  border-bottom: 1px solid #b0b4b8;
  margin-bottom: 4px;
}
.bxw-gc { padding: 2px 0 0; }
.bxw-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; min-height: 21px; }
.bxw-lb {
  flex: 0 0 112px; font-size: 12px; text-align: right;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bxw-cl { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.bxw-tip { font-size: 11px; opacity: .82; padding: 3px 0 0; line-height: 1.5; }
.bxw-note { font-size: 11px; opacity: .78; padding: 3px 0; }
.bxw-msg {
  font-size: 12px; line-height: 1.6; padding: 5px 7px; margin: 3px 0;
  background: var(--white, #fff); border: 1px solid #808080;
  box-shadow: inset 1px 1px 0 #000;
}
.bxw-drow { font-size: 12px; line-height: 1.6; padding: 1px 0; }
.bxw-sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 10px; }
.bxw-sides .bxw-lb { flex: 0 0 44px; }
.bxw-btns { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- 控件 ---------- */
.bxw-rng { flex: 1 1 80px; min-width: 56px; height: 16px; }
.bxw-rv { width: 52px; font-size: 12px; text-align: right; }
.bxw-un { font-size: 11px; opacity: .85; white-space: nowrap; }
.bxw-sel { flex: 0 1 auto; min-width: 96px; max-width: 220px; }
.bxw-spin { display: inline-flex; }
.bxw-cb { display: flex; align-items: center; gap: 4px; font-size: 12px; cursor: var(--cur-hand, pointer); }

/* Win3.1 滑杆：内凹槽 + 凸起滑块 */
.bxw-rng, .bxw-bsp { -webkit-appearance: none; appearance: none; background: transparent; height: 16px; }
.bxw-rng::-webkit-slider-runnable-track, .bxw-bsp::-webkit-slider-runnable-track {
  height: 6px; background: var(--face, #c0c0c0);
  box-shadow: inset 1px 1px 0 var(--face-shadow, #808080), inset -1px -1px 0 var(--face-light, #dfdfdf);
}
.bxw-rng::-webkit-slider-thumb, .bxw-bsp::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 11px; height: 16px; margin-top: -5px;
  background: var(--face, #c0c0c0);
  box-shadow: inset 1px 1px 0 var(--face-light, #dfdfdf), inset -1px -1px 0 var(--face-shadow, #808080), 0 0 0 1px #000;
}
.bxw-rng::-moz-range-track, .bxw-bsp::-moz-range-track {
  height: 6px; background: var(--face, #c0c0c0);
  box-shadow: inset 1px 1px 0 var(--face-shadow, #808080), inset -1px -1px 0 var(--face-light, #dfdfdf);
}
.bxw-rng::-moz-range-thumb, .bxw-bsp::-moz-range-thumb {
  border-radius: 0; border: 1px solid #000;
  width: 11px; height: 16px;
  background: var(--face, #c0c0c0);
  box-shadow: inset 1px 1px 0 var(--face-light, #dfdfdf), inset -1px -1px 0 var(--face-shadow, #808080);
}

/* 色块 + HEX/RGB/HSL */
.bxw-cbox {
  flex: 0 0 34px; width: 34px; height: 22px;
  position: relative;
  border: 1px solid #000;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .8), inset -1px -1px 0 #808080;
}
.bxw-cbox > .bxw-sw {
  position: absolute; inset: 0; width: 100%; height: 100%;
  padding: 0; border: 0; background: transparent;
  cursor: var(--cur-hand, pointer);
}
.bxw-hex { width: 104px; font-size: 12px; }
.bxw-cfmt { flex: 0 0 64px; min-width: 64px; }
.bxw-recents { display: flex; flex-wrap: wrap; gap: 3px; }
.bxw-rsw {
  width: 17px; height: 17px;
  border: 1px solid #000;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .55);
  cursor: var(--cur-hand, pointer);
}

/* 颜色节点编辑器 */
.bxw-stops { display: flex; flex-direction: column; gap: 3px; padding: 2px 0; }
.bxw-stop { display: flex; align-items: center; gap: 5px; }
.bxw-stop > .bxw-sw {
  position: static; flex: 0 0 28px; width: 28px; height: 20px;
  padding: 0; border: 1px solid #000; background: transparent;
  cursor: var(--cur-hand, pointer);
}
.bxw-stop > .bxw-rv { width: 44px; }
.bxw-stop > .bxw-del { margin-left: auto; }

/* 类型瓦片 / 小按钮 —— ⚠️ 全站 button{min-height:19px} 与 button{box-shadow:…!important}
   会顶高并盖掉自绘按钮，所以这里必须显式清零并自带 !important 的阴影。 */
.bxw-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.bxw-tile {
  min-height: 0 !important; min-width: 0 !important; max-height: none !important;
  height: 24px; padding: 0 5px; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: inset 1px 1px 0 var(--face-light, #dfdfdf), inset -1px -1px 0 var(--face-shadow, #808080) !important;
}
.bxw-mini, .bxw-del {
  min-height: 0 !important; min-width: 0 !important; max-height: none !important;
  height: 19px; padding: 0 6px; font-size: 11px;
  box-shadow: inset 1px 1px 0 var(--face-light, #dfdfdf), inset -1px -1px 0 var(--face-shadow, #808080) !important;
}
.bxw-del { padding: 0; width: 19px; font-size: 12px; line-height: 17px; }

/* 预设列表 */
.bxw-plist {
  max-height: 236px; overflow-y: auto;
  background: var(--win-bg, #ffffff);
  border: 1px solid #808080;
  box-shadow: inset 1px 1px 0 #000;
}
.bxw-prow { display: flex; align-items: center; gap: 6px; padding: 2px 4px; font-size: 12px; }
.bxw-prow:nth-child(even) { background: rgba(0, 0, 0, .04); }
.bxw-pname { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bxw-ptag { flex: 0 0 auto; font-size: 10px; opacity: .68; }
.bxw-pacts { flex: 0 0 auto; display: flex; gap: 3px; }

/* 光照控制盘 */
.bxw-dial { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 2px 0 4px; }
.bxw-dialcv {
  width: 200px; height: 200px;
  border: 1px solid #000;
  box-shadow: inset 1px 1px 0 #808080;
  cursor: crosshair;
  touch-action: none;
}
.bxw-dialinfo { font-size: 11px; text-align: center; line-height: 1.5; }

/* ---------- 底部按钮条 ---------- */
.bxw-ft {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 5px;
  padding: 7px 8px 8px;
  border-top: 1px solid var(--face-light, #dfdfdf);
  box-shadow: inset 0 1px 0 var(--face-shadow, #808080);
}
.bxw-stt { flex: 1 1 auto; min-width: 0; font-size: 11px; opacity: .85; padding-right: 8px; }
.bxw-ft > .btn31 {
  min-height: 0 !important; min-width: 74px !important; max-height: none !important;
  height: 23px; padding: 0 10px; font-size: 12px;
  box-shadow: inset 1px 1px 0 var(--face-light, #dfdfdf), inset -1px -1px 0 var(--face-shadow, #808080) !important;
}

/* ============================================================
 * p68 补丁：把「边框模块的圆角」从全局直角开关里救回来
 * ------------------------------------------------------------
 * 站内有个**默认打开**的外观设置项：prefs.js 的
 *   B('btnSquare', '按钮保持直角', '外观与窗口', 'pf-square',
 *     'body.pf-square *{border-radius:0 !important}', '开启', true)
 * 注意它是 `body.pf-square *` —— 命中的是**所有元素**，且带 !important。
 * 于是只要这个开关开着（默认就开着），js/border.js 写在 inline style 上的
 * `border-radius:6px 8px 10px 12px` 会被它无条件压掉 ⇒ 圆角边框 / 圆角卡片
 * 全部静默变直角（inline 赢不了 !important，这是最容易被漏掉的一类回归）。
 *
 * 救法：模块自己用 CSS 变量承接「四角半径」，再由下面这条**特异性更高、
 * 同样带 !important** 的规则读出来。变量由 applyDom 逐元素写在 inline 上，
 * 所以四角独立设置依然生效。
 *   --bxr-out → 外框 .bx31（= 模型 radius）
 *   --bxr-in  → 内衬 / 图片 / 内嵌线 / 内阴影（= 同心内层半径）
 * ⚠️ 以后新增「挂在 .bx31 里的元素」也要一并加进这两条规则，否则一样会被压平。
 * ============================================================ */
body.pf-square .bx31 { border-radius: var(--bxr-out, 0) !important; }
body.pf-square .bx31-pd,
body.pf-square .bx31-im,
body.pf-square .bx31-ir,
body.pf-square .bx31-is { border-radius: var(--bxr-in, 0) !important; }

/* ============================================================
 * p80 —— 修「边框对话框里的汉字被截断」
 * ------------------------------------------------------------
 * 现象：10 个标签页里的汉字（「统一宽度」「边框颜色」「线型」「X 偏移」…）
 *       上沿缺笔画，像是字没写完。
 *
 * 真因（三步实测，不是推测）：
 *   ① css/win31.css 里 `html, body { line-height: 1 }` ⇒ 没自己声明行高的元素，
 *      行盒高度 = font-size = 12px。
 *   ② SimSun31 带 `size-adjust:116.6667%`（点阵原生档 14ppem 映射到 12px 字号）
 *      ⇒ 12px 字号的**字面 metric 盒 = 15px**，比 12px 的行盒高。
 *   ③ 凡是同时带 `overflow:hidden` 的元素，裁的就是自己的行盒 —— 汉字上沿被削。
 *
 * 取证（同一构建、同一窗口、同一 clip，只把 overflow 换成 visible 再逐像素比）：
 *   _dev/p80clip2.js（几何仪器：用 Range.getClientRects 取字面盒，和最近裁剪祖先的
 *       padding 盒比）：改前 .bxw-lb 上削 2 / 下削 1（字面盒 15 vs 行盒 12）、
 *       .bxw-tt 上削 2 / 下削 1。仪器自证：把修复还原后它**必报**这两个元素。
 *   _dev/p80clip4.js（逐行定位）：差分是**纯绘制差异**（before/after 几何一模一样），
 *       差分带落在元素**顶边之上 ≈1.1 CSS px** ⇒ 墨迹是从行盒顶边再往上探出去的。
 *   _dev/p80clip3.js（实测定档）：行高取 14/15/16px，差异**完全相同**
 *       ⇒ **抬行高没用**！元素在行里 align-items:center，盒子长高 Δ、顶边就上移 Δ/2，
 *         墨迹的绝对位置和裁剪边界一起动，正好抵消。
 *   _dev/p80clip5.js（定档 + 可证伪预言）：N=0 与原版逐像素相同（自检）✔；
 *       N=1 仍 ≠ 参考版（预言残余 0.125px）✔；**N=2 == 参考版，逐像素完全相同** ⇒ 取 N=2。
 *
 * 修法（两条，都不改排版）：
 *   ㈠ .bxw-tt（标题「边框」）抬行盒到 19px —— 与窗口标题栏
 *      `v7.css: .win > .titlebar > .tb-title{ line-height:var(--tb-h,19px) }` 同值，
 *      既彻底不裁字，又与系统菜单盒（19px）在同一条垂直带上。
 *   ㈡ .bxw-lb / .bxw-pname 用**对称 padding + 等量负 margin** 把裁剪盒上下各外扩 2px。
 *      外边距盒尺寸不变 ⇒ 居中行里的位置不变 ⇒ **文字绝对位置一个像素都不动**
 *      （p80clip5 的 `==参考版` 同时证明「没被裁」+「没挪位」两件事）；
 *      而 padding 盒（= 裁剪边界）上下各多 2px ⇒ 整条墨迹都进得来。
 *
 * ⚠️ 不能改成 overflow:visible —— 它们靠 `overflow:hidden + text-overflow:ellipsis`
 *    做长标签省略号（preset 页的「保存当前参数为预设」就会溢出），换 visible 会压到控件上。
 * ⚠️ 别只用「抬行高」（p80clip3 已证无效）；也别只加 padding 不配负 margin
 *    （那会把汉字整体往下推 2px）。
 * ⚠️ .bxw-lb 仍保留 line-height:14px：定档实验就是在这个组合下验到 `==参考版` 的，
 *    去掉它会改变几何、必须重跑 p80clip5 才能再声明「没被裁」。
 * ============================================================ */
.bxw-lb, .bxw-pname {
  padding: 2px 0;
  margin: -2px 0;
  line-height: 14px;
}
.bxw-tt { line-height: 19px; }
