/* ==================== 户型布局（独立页面） ====================
   结构：顶栏 / 尺寸栏 / 全宽画布（坐山·选中浮层叠上） / 脚注
   「拖入构件」改顶栏按钮弹出，不再占固定侧栏或下方整块。 */

:root {
  --bg: #eef2f8;
  --card: #ffffff;
  --panel-alt: #f7f9fd;
  --line: #e2e9f3;
  --line-soft: #eef3fa;
  --border: #e2e9f3;
  --accent: #c0392b;
  --title: #16233a;
  --text: #33435c;
  --muted: #7386a0;
  --blue: #2f6fed;
  --btn-from: #5b8def;
  --btn-to: #2f6fed;
  --gold: #2f6fed;
  --shadow-card: 0 2px 10px rgba(24, 44, 80, 0.05);
  --shadow-float: 0 8px 24px rgba(24, 44, 80, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 高度用 --app-h（JS 按 innerHeight 写死）：iOS/安卓地址栏伸缩时 100dvh 会跳，
   老系统又不认 dvh，只有显式像素最稳。没拿到底值就退回 100%。 */
html, body {
  height: 100%;
  height: var(--app-h, 100%);
  max-height: var(--app-h, 100%);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 8% -8%, #e7f0ff 0%, rgba(231, 240, 255, 0) 62%),
    linear-gradient(180deg, #f0f5fc 0%, #e8eef7 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.plan-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

/* 通用隐藏：模块自带的 .hidden 也要能压住 display:flex 之类 */
.hidden, [hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.top-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.46rem 0.72rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  flex: 0 0 auto;
  z-index: 5;
}
.link-back {
  color: var(--gold);
  text-decoration: none;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1;
  height: 1.95rem;
  padding: 0 0.62rem 0 0.42rem;
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  border-radius: 999px;
  border: 1px solid #dbe6f8;
  background: #f7fafe;
  flex: 0 0 auto;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.link-back:hover { background: #eef5ff; border-color: #bfd6f8; }
.link-back:active { background: #e3eefe; }
.link-back-arrow { font-size: 1rem; line-height: 1; }

.hx-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.36rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--title);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hx-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 7px;
  background: linear-gradient(160deg, #5b8def, #2f6fed);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow: 0 3px 8px rgba(47, 111, 237, 0.3);
  flex: 0 0 auto;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  border: 1px solid #dbe6f8;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  white-space: nowrap;
  flex: 0 0 auto;
  touch-action: manipulation;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn.primary {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(180deg, var(--btn-from), var(--btn-to));
  box-shadow: 0 3px 10px rgba(47, 111, 237, 0.28);
}
.btn.primary:hover { box-shadow: 0 5px 14px rgba(47, 111, 237, 0.34); }
.btn.ghost {
  background: #f7fafe;
  color: var(--gold);
  border-color: #d3e2fa;
}
.btn.ghost:hover { background: #eef5ff; }
.btn.ghost.is-auto-on {
  color: #15803d;
  border-color: #86efac;
  background: #f0fdf4;
}

/* 自动布局等提示：手机隐藏底栏后仍能看见 */
.plan-flash-tip {
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -8px);
  z-index: 9999;
  max-width: min(86vw, 22rem);
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.plan-flash-tip.is-on {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.btn.soft {
  background: #fff;
  color: var(--muted);
  border-color: #e3e9f3;
  font-weight: 600;
}
.btn.soft:hover { color: var(--accent); border-color: #f1d4d0; background: #fffafa; }
.btn.is-on {
  background: linear-gradient(180deg, var(--btn-from), var(--btn-to));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px rgba(47, 111, 237, 0.28);
}

/* ---------- 尺寸栏（尽量矮，把竖向空间留给画布） ---------- */
.hx-bar {
  display: flex;
  align-items: center;
  gap: 0.34rem;
  padding: 0.22rem 0.55rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  flex: 0 0 auto;
}
.hx-bar .btn.soft {
  padding: 0.22rem 0.55rem;
  font-size: 0.72rem;
  line-height: 1.2;
}
.hx-size {
  display: flex;
  align-items: center;
  gap: 0.22rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.hx-size::-webkit-scrollbar { display: none; }
.hx-size label {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.hx-size input {
  width: 3.2rem;
  padding: 0.14rem 0.2rem;
  border: 1px solid #d9e4f4;
  border-radius: 7px;
  background: #fff;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--title);
  text-align: center;
  box-shadow: inset 0 1px 2px rgba(24, 44, 80, 0.04);
  -moz-appearance: textfield;
}
.hx-size input::-webkit-outer-spin-button,
.hx-size input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.hx-size input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.13);
}
.hx-x { color: #b9c7db; font-weight: 700; font-size: 0.7rem; }

/* ---------- 主体：上画布左右拉满，下固定操作区 ---------- */
.plan-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  padding: 0;
  overflow: hidden;
}
/* flex-basis:0 + min-height：避免底部操作区把画布挤成 0 高 */
.plan-canvas-wrap {
  position: relative;
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--line);
  background: #fff;
  box-shadow: none;
}
.plan-bottom {
  flex: 0 1 auto;
  /* 先写纯 vh，再写 min()：老浏览器不认 min() 时整条会失效，画布会被整块挤没 */
  max-height: 42vh;
  max-height: min(42vh, 360px);
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.42rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: rgba(247, 250, 253, 0.96);
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
}

.hx-box {
  position: relative;
  display: block;
  flex: 0 0 auto;
  max-width: 100%;
  max-height: 100%;
}
#planCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: #fff;
  touch-action: none;
  -ms-touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  cursor: default;
  box-shadow: none;
  /* 避免被父级隐式缩放后发糊 */
  image-rendering: auto;
}

/* 罗盘层 */
.hx-luopan {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 50% 50%;
  touch-action: none;
  -ms-touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: grab;
  filter: drop-shadow(0 10px 24px rgba(20, 34, 56, 0.22));
  will-change: transform;
}
.hx-luopan.hidden { display: none; }
.hx-luopan.is-drag { cursor: grabbing; }
.hx-luopan img {
  display: block;
  width: 100%;
  height: 100%;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

.hx-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.6rem;
  box-shadow: var(--shadow-card);
  flex: 0 0 auto;
}
.hx-card-t {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.hx-card-t::before {
  content: "";
  width: 3px;
  height: 0.7rem;
  border-radius: 2px;
  background: linear-gradient(180deg, #7ba8fa, #2f6fed);
  flex: 0 0 auto;
}

.plan-sit { display: block; }
.plan-field {
  display: block;
  width: 100%;
  padding: 0.32rem 0.36rem;
  border: 1px solid #dbe6f8;
  border-radius: 9px;
  background: #fff;
  font: inherit;
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--title);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.plan-field:hover { border-color: #c3d8f7; }
.plan-field:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.13);
}
.plan-deg-row {
  display: flex;
  align-items: center;
  gap: 0.26rem;
  margin-top: 0.3rem;
}
.plan-deg-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
  flex: 0 0 auto;
  padding: 0.3rem 0.36rem;
  border: 1px solid #dbe6f8;
  border-radius: 9px;
  background: #f7fafe;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}
.plan-deg-chip input { margin: 0; accent-color: var(--blue); }
.plan-deg-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.plan-deg-input::-webkit-outer-spin-button,
.plan-deg-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.plan-deg-input:disabled {
  background: #f3f6fb;
  border-color: #e6edf7;
  color: #aab7c9;
  box-shadow: none;
}
.plan-mapbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.26rem;
  width: 100%;
  margin-top: 0.32rem;
  padding: 0.4rem 0.3rem;
  border: 1px dashed #b9d2f8;
  border-radius: 9px;
  background: #f4f9ff;
  color: var(--btn-to);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.plan-mapbtn:hover { background: #e9f2ff; border-style: solid; }
.plan-mapbtn:active { transform: translateY(1px); }
.plan-face {
  margin-top: 0.34rem;
  padding: 0.3rem 0.3rem;
  border-radius: 9px;
  background: linear-gradient(180deg, #eef4ff, #e7f0ff);
  border: 1px solid #dde9fb;
  color: #1e3f7a;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.32;
  text-align: center;
  white-space: normal;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

/* ---------- 构件（底部固定区） ---------- */
.plan-tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
}
.plan-tool {
  padding: 0.48rem 0.2rem;
  border: 1px solid #dde7f6;
  border-radius: 10px;
  background: #f8fbff;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.12s ease;
}
.plan-tool:hover {
  background: #eef5ff;
  border-color: #a9c6f7;
  color: var(--blue);
  transform: translateY(-1px);
}
.plan-tool:active { transform: translateY(0) scale(0.98); background: #e2eeff; }

@media (min-width: 721px) {
  .plan-bottom { max-height: 40vh; max-height: min(40vh, 360px); }
  .plan-tools { grid-template-columns: repeat(6, 1fr); }
  .plan-sit {
    display: grid;
    grid-template-columns: minmax(7em, 1fr) auto auto;
    gap: 0.34rem 0.4rem;
    align-items: center;
  }
  .plan-sit #planSit { width: 100%; }
  .plan-deg-row { margin-top: 0; }
  .plan-mapbtn { width: auto; margin-top: 0; padding: 0.36rem 0.55rem; }
  .plan-face { grid-column: 1 / -1; margin-top: 0; }
}

/* ---------- 选中构件 ---------- */
.plan-sel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.6rem;
  box-shadow: var(--shadow-card);
  flex: 0 0 auto;
}
.plan-sel-empty {
  font-size: 0.74rem;
  color: #9aa8bd;
  text-align: center;
  padding: 0.5rem 0;
}
.plan-sel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
  padding-bottom: 0.34rem;
  border-bottom: 1px solid var(--line-soft);
}
.plan-sel-head b {
  font-size: 0.84rem;
  color: var(--title);
  letter-spacing: 0.02em;
}
.plan-sel-head b + .plan-swap-dw { margin-right: auto; }
.plan-sel-head span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--blue);
  background: #eef4ff;
  border-radius: 999px;
  padding: 0.06rem 0.4rem;
  font-variant-numeric: tabular-nums;
}
/* 长宽输入：物件尺寸可改，别让数字被挤成省略号 */
.plan-dims {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.36rem;
}
.plan-dims label {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
}
.plan-dims input {
  width: 100%;
  min-width: 0;
  padding: 0.26rem 0.28rem;
  border: 1px solid #dde7f6;
  border-radius: 8px;
  background: #fbfdff;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--title);
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.plan-dims input::-webkit-outer-spin-button,
.plan-dims input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.plan-dims input:focus {
  outline: none;
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.13);
}

/* 九宫操作盘：上一行转向，中间一行左右与回正，下一行删除与下移 */
.plan-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.24rem;
  margin-bottom: 0.42rem;
}
.plan-nav button {
  padding: 0.3rem 0;
  border: 1px solid #dde7f6;
  border-radius: 8px;
  background: #fbfdff;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.plan-nav button:hover { background: #eef5ff; border-color: #b7d1f8; color: var(--blue); }
.plan-nav button:active { background: #dfeaff; }
.plan-nav [data-act="r-"] { grid-area: 1 / 1; }
.plan-nav [data-act="n-up"] { grid-area: 1 / 2; }
.plan-nav [data-act="r+"] { grid-area: 1 / 3; }
.plan-nav [data-act="n-left"] { grid-area: 2 / 1; }
.plan-nav [data-act="r0"] { grid-area: 2 / 2; }
.plan-nav [data-act="n-right"] { grid-area: 2 / 3; }
.plan-nav [data-act="del"] { grid-area: 3 / 1; }
.plan-nav [data-act="n-down"] { grid-area: 3 / 2; }
.plan-nav [data-act="swap-dw"] { grid-area: 3 / 3; font-size: 0.95rem; }
.plan-sel-head .plan-swap-dw {
  appearance: none;
  border: 1px solid #c7ddf8;
  background: #f3f8ff;
  color: var(--blue);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 0.25rem;
}
.plan-sel-head .plan-swap-dw:active { background: #e2eeff; }
.plan-nav .is-del {
  border-color: #f2d5d1;
  background: #fffafa;
  color: var(--accent);
}
.plan-nav .is-del:hover { background: #fdf1ef; border-color: #e9b8b1; color: var(--accent); }

.plan-dists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem 0.4rem;
  font-size: 0.71rem;
  color: var(--muted);
}
.plan-dists span { display: flex; align-items: baseline; gap: 0.2rem; }
.plan-dists i {
  font-style: normal;
  font-weight: 700;
  color: #3a5c96;
  font-variant-numeric: tabular-nums;
}
/* 山·元龙 / 洛书数 / 斜流位·吉凶（与画布胶囊同口径） */
.plan-yuan {
  margin-top: 0.24rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}
.plan-yuan .yx-line { display: block; }
.plan-yuan .yx-k { font-weight: 600; color: #475569; }
.plan-yuan .yx-dot { font-weight: 500; color: #94a3b8; }
.plan-yuan .y-shan { color: #8a5320; }
.plan-yuan .y-tian { color: #1565c0; }
.plan-yuan .y-di { color: #b45309; }
.plan-yuan .y-ren { color: #7b1fa2; }
.plan-yuan .y-shu { color: #15803d; }
.plan-yuan .y-ji { color: #15803d; }
.plan-yuan .y-xiong { color: #c62828; }
.plan-yuan .y-ping { color: #64748b; }

/* ---------- 脚注 ---------- */
.plan-foot {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.72rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  flex: 0 0 auto;
}
.plan-hint {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.7rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================== 窄屏：下方操作区压紧，画布仍全宽 ==================== */
@media (max-width: 720px) {
  .top-bar { padding: 0.42rem 0.55rem; gap: 0.34rem; }
  .hx-title { font-size: 0.94rem; }
  .hx-badge { width: 1.28rem; height: 1.28rem; font-size: 0.72rem; }
  .link-back { height: 1.85rem; font-size: 0.72rem; }
  .link-back-text { display: none; }
  .btn { padding: 0.36rem 0.62rem; font-size: 0.78rem; }

  /* 长宽栏：保持可点高度，别压成细条 */
  .hx-bar { padding: 0.22rem 0.42rem; gap: 0.28rem; }
  .hx-size { gap: 0.22rem; }
  .hx-size label { font-size: 0.72rem; }
  .hx-size input {
    width: 3.4rem;
    min-height: 2rem;
    padding: 0.28rem 0.22rem;
    font-size: 16px;
  }
  .hx-bar .btn.soft { padding: 0.28rem 0.52rem; font-size: 0.72rem; min-height: 2rem; }

  .plan-body { padding: 0; }
  /* 手机优先画布高度：底部操作区压矮，舞台拿回竖向空间 */
  .plan-canvas-wrap { border-radius: 0; min-height: 240px; }
  .plan-bottom {
    max-height: 32vh;
    max-height: min(32vh, 280px);
    padding: 0.28rem 0.4rem 0.36rem;
    gap: 0.26rem;
  }
  .hx-card, .plan-sel { padding: 0.34rem 0.4rem; border-radius: 10px; }
  .hx-card-t { margin-bottom: 0.2rem; font-size: 0.62rem; }

  .plan-sit { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem; }
  .plan-sit #planSit { flex: 1 1 100%; width: 100%; }
  .plan-deg-row { flex: 1 1 7rem; margin-top: 0; }
  .plan-mapbtn { flex: 0 0 auto; width: auto; margin-top: 0; padding: 0.32rem 0.42rem; }
  .plan-face { flex: 1 1 100%; margin-top: 0; font-size: 0.68rem; padding: 0.18rem; }

  .plan-tools {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.24rem;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .plan-tools::-webkit-scrollbar { display: none; }
  .plan-tool { flex: 0 0 auto; padding: 0.38rem 0.64rem; }

  .plan-sel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "head head"
      "dims nav"
      "dists nav"
      "yuan yuan";
    gap: 0.22rem 0.32rem;
    align-items: start;
  }
  .plan-sel-empty { text-align: left; padding: 0.1rem 0; }
  .plan-sel-head { grid-area: head; margin-bottom: 0; padding-bottom: 0.2rem; }
  .plan-dims { grid-area: dims; margin-bottom: 0; }
  .plan-nav { grid-area: nav; width: 8.6rem; margin-bottom: 0; }
  .plan-nav button { padding: 0.28rem 0; font-size: 0.76rem; }
  .plan-dists { grid-area: dists; }
  .plan-yuan { grid-area: yuan; margin-top: 0; }

  .plan-foot { display: none; }
}

/* ==================== 触屏设备：表单控件统一 16px ====================
   iOS Safari 聚焦 font-size < 16px 的 input / select 时会强制把整页放大（user-scalable=no 拦不住），
   放大后 overflow:hidden 又没法平移，右侧面板、画布边缘就「看不见」了，拖动手感也跟着错位。
   所以手机上宁可字大一点，也不能让浏览器缩放。 */
@media (max-width: 720px), (hover: none) and (pointer: coarse) {
  .hx-size input,
  .plan-field,
  .plan-dims input,
  .plan-deg-input {
    font-size: 16px;
    line-height: 1.25;
  }
  .hx-size input { width: 3.5rem; min-height: 2.05rem; padding: 0.3rem 0.2rem; }
  .plan-field { padding: 0.28rem 0.32rem; }
  .plan-dims input { padding: 0.22rem 0.24rem; }
  /* 按钮 / 构件同样按手指尺度给足高度 */
  .plan-tool { min-height: 2.1rem; }
  .plan-nav button { min-height: 2rem; }
}

/* ==================== 矮窗口：底部区压紧 ==================== */
@media (min-width: 721px) and (max-height: 740px) {
  .plan-bottom { max-height: 36vh; }
  .hx-card, .plan-sel { padding: 0.4rem 0.46rem; border-radius: 10px; }
  .hx-card-t { margin-bottom: 0.24rem; font-size: 0.63rem; }
  .plan-face { padding: 0.2rem; font-size: 0.68rem; }
  .plan-sel-head { margin-bottom: 0.28rem; padding-bottom: 0.24rem; }
  .plan-sel-head b { font-size: 0.78rem; }
  .plan-dims { margin-bottom: 0.26rem; }
  .plan-nav { gap: 0.18rem; margin-bottom: 0.3rem; }
  .plan-nav button { padding: 0.22rem 0; font-size: 0.74rem; }
  .plan-dists { font-size: 0.66rem; }
  .plan-yuan { font-size: 0.72rem; margin-top: 0.18rem; }
}
