/* =========================================================================
 * 手机 / 平板适配样式 — mobile.css
 *   横屏优先；刘海屏安全区；触屏加大点按目标
 * ========================================================================= */

/* 全屏、无回弹、禁止误选 */
html, body {
  height: 100%;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body { touch-action: manipulation; }

/* 刘海屏安全区（iOS Safari 横屏时左右有黑边） */
@supports (padding: max(0px)) {
  .topbar {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .body {
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(6px, env(safe-area-inset-right));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
}

/* 独立运行（添加到主屏幕）时隐藏一切浏览器痕迹 */
@media (display-mode: standalone), (display-mode: fullscreen) {
  html, body { overflow: hidden; }
}

/* 触屏设备：加大点按区域、去掉 hover 效果 */
.touch .rail .tool:active { background: #e8f0fe; }
.touch .btn:active { transform: translateY(1px); }
.touch .menu .tb:active { background: #eef4ff; }
.touch .sup-step:active, .touch .fb-item:active { background: #eef4ff; }

/* 小屏横屏（手机横放）：进一步压缩，把画布让出来 */
@media (max-width: 1000px) and (orientation: landscape) {
  .topbar { height: 44px; padding-top: 0; padding-bottom: 0; }
  .brand svg, .brand .logo { width: 26px; height: 26px; }
  .rail { width: 56px !important; flex: 0 0 56px !important; }
  .rail .tool { width: 52px; padding: 5px 2px 3px; }
  .rail .tool span { font-size: 9px; }
  .inspector { flex: 0 0 240px !important; font-size: 12px; }
  .statusbar { display: none; }
  .stage-top { height: 34px; flex: 0 0 34px; }
  .credit { display: none; }

  /* 浮层面板：横屏时改为左右两栏、铺满 */
  .sup-panel { width: 97vw !important; height: 94vh !important; }
  .sup-side { width: 258px !important; padding: 8px; }
  .sup-head { padding: 8px 12px; }
  .ah-side { width: 258px !important; }
  .ah-body { padding: 6px; gap: 6px; }
}

/* 横屏提示浮层（竖屏时出现） */
#rotateTip {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef4ff, #dbe7fb);
}
#rotateTip.show { display: flex; }
#rotateTip .rt-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 30px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .18);
  text-align: center;
}
#rotateTip b { font-size: 17px; color: #0f172a; }
#rotateTip span { font-size: 12.5px; color: #64748b; }

/* iOS「添加到主屏幕」引导条 */
#a2hsBar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translate(-50%, 24px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, .92);
  color: #fff;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: .25s;
  z-index: 9998;
  max-width: 92vw;
}
#a2hsBar.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#a2hsBar button {
  border: 0;
  border-radius: 9px;
  padding: 6px 12px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  font-size: 12.5px;
}

/* ===== 手机横屏（高度很小）：单行顶栏 + 紧凑布局 ===== */
@media (orientation: landscape) and (max-height: 520px) {
  .app { height: 100vh; height: 100dvh; overflow: hidden; }
  .topbar {
    height: 40px !important;
    flex: 0 0 40px !important;
    flex-wrap: nowrap !important;
    overflow: hidden;
    gap: 4px;
    padding: 0 6px !important;
  }
  .brand { display: none; }
  .menu {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0;
    -webkit-overflow-scrolling: touch;
  }
  .menu::-webkit-scrollbar { display: none; }
  .menu .tb, .menu .dropdown > .tb {
    height: 30px;
    padding: 0 7px;
    font-size: 11.5px;
    white-space: nowrap;
  }
  /* 模块跳转链接在手机上收起来（可用底部/菜单切换），保留核心操作 */
  .menu > a.tb[href$=".html"] { display: none; }
  /* 但「← 平面杆系」要留：手机上这是回主页面唯一的入口 */
  .menu > a.tb[href="index.html"] { display: inline-flex; }
  /* 顶栏是横向滚动容器，普通下拉会被裁掉：改成挂在顶栏下方的整条面板 */
  .menu-pop {
    position: fixed !important;
    left: 6px;
    right: 6px;
    top: 44px;
    min-width: 0;
    max-height: 62vh;
    box-shadow: 0 18px 44px rgba(15, 23, 42, .3);
    z-index: 400;
  }
  .menu-pop a, .menu-pop button { padding: 7px 12px; font-size: 12.8px; }
  .menu-pop a small, .menu-pop button small { display: inline; margin: 0 0 0 8px; font-size: 11px; }
  .model-name, .credit, .brand-text { display: none !important; }
  .btn.primary { height: 30px; padding: 0 10px; font-size: 12px; }
  .btn.primary kbd { display: none; }

  .body { padding: 4px !important; gap: 4px !important; flex-direction: row !important; }

  .rail {
    width: 50px !important;
    flex: 0 0 50px !important;
    flex-direction: column !important;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 0 !important;
    gap: 0 !important;
  }
  .rail .tool { width: 48px !important; padding: 3px 0 2px !important; gap: 1px; }
  .rail .tool svg { width: 16px; height: 16px; }
  .rail .tool span { font-size: 8.5px; line-height: 1.1; }
  .rail-sep { width: auto !important; height: 1px !important; margin: 2px 6px !important; }

  .stage-top {
    height: 30px !important;
    flex: 0 0 30px !important;
    padding: 0 6px !important;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .stage-top::-webkit-scrollbar { display: none; }
  .stage-top .tab { font-size: 11.5px; padding: 0 8px; }
  .stage-top label, .stage-top .chk { font-size: 11px; white-space: nowrap; }

  .inspector { flex: 0 0 208px !important; font-size: 11.5px; }
  .inspector .card-h { font-size: 11.5px; padding: 7px 9px; }
  .inspector .card-b { padding: 8px 9px; }
  .statusbar { display: none !important; }

  /* 各浮层（叠加法 / 截面法 / 多跨梁 / 受力分析）在手机横屏铺满 */
  .sup-overlay { padding: 6px !important; }
  .sup-panel { width: 98vw !important; height: 96vh !important; height: 96dvh !important; }
  .sup-side { width: 236px !important; padding: 8px !important; }
  .sup-head { padding: 7px 10px !important; }
  .sup-canvas { padding: 6px !important; }

  /* 三铰拱页 */
  .ah-body { padding: 4px !important; gap: 4px !important; }
  .ah-side { width: 232px !important; }
  .ah-left > canvas, .ah-diag-wrap { border-radius: 8px; }
}

/* 手机横屏：视图条矮，三角形折叠键跟着收小 */
@media (orientation: landscape) and (max-height: 520px) {
  .panel-toggle { width: 26px; height: 24px; border-radius: 7px; }
  .ah-left > .panel-toggle { top: 5px; right: 5px; }
}

/* 三铰拱：手机横屏保持左右两栏（覆盖 980px 断点的竖排） */
@media (orientation: landscape) and (max-height: 520px) {
  .ah-body { flex-direction: row !important; min-height: 0; overflow: hidden; }
  .ah-left { min-height: 0 !important; flex: 1 1 auto; min-width: 0; }
  .ah-side { width: 226px !important; flex: 0 0 226px !important; max-height: none !important; overflow-y: auto; }
  .ah-side .card-h { padding: 6px 9px; font-size: 11.5px; }
  .ah-side .card-b { padding: 7px 9px; gap: 6px; }
  .ah-side input[type="number"], .ah-side select { height: 27px; font-size: 12px; }
  .ah-side .field label { font-size: 10.5px; }
  .formula { font-size: 11.5px; padding: 4px 7px; }
}

/* 触摸设备的悬浮缩放按钮 */
#zoomPad {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 900;
}
.touch #zoomPad { display: flex; }
#zoomPad button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid #dbe3ee;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 6px 16px rgba(15, 23, 42, .14);
  color: #1d4ed8;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
#zoomPad button:active { background: #eef4ff; transform: scale(.96); }

/* 手机横屏：顶栏空间有限，字号控件收起（可用双指缩放整图代替） */
@media (orientation: landscape) and (max-height: 520px) {
  .fontctl { display: none !important; }
}
