/* 创悟在线编辑器: 布局与样式复用旧版 CSS(layui/nav.css/fontello), 此处仅少量补充 */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ============================================================
   导航栏样式(2026-11-23 系统整理: 原散落 6 处合并于此)
   分层: 布局容器 / 按钮基类 / 图标按钮 / 上传按钮 / 触屏隐藏 / 小程序
   死规则已删: #copyright、.layui-nav-itemed、#nav-right-btn-list .layui-btn a
   ============================================================ */

/* ---- 布局容器 ---- */
#nav-wrap {
  height: 44px;
  flex: none;
}

#nav {
  height: 100%;
  max-height: none;
  position: relative;
  z-index: 1100;
  font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 400;
}

#nav-left-btn-list {
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}

/* ---- 按钮基类: 36px 高, 透明底无边框白字(绿色导航条上) ---- */
#nav-left-btn-list button,
#nav-right-btn-list button {
  height: 36px !important;
  font-size: 15px !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #fff !important;
}

#nav-left-btn-list button > a,
#nav-right-btn-list button > a {
  font-size: 14px !important;
  color: #fff;
}

#nav #mixly-path {
  color: #fff !important;
}

/* ---- 图标按钮(lab-btn, 移植自魔法瞳匠): 半透明白底圆角, 字形纯白 ---- */
.lab-btn {
  display: inline-block;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.6);
  color: #fff;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 14px;
  text-decoration: none;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lab-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

.lab-btn-group {
  display: flex;
  gap: 8px;
}

.lab-btn-group--icons {
  gap: 4px;
  flex: none;
  align-items: center;
}

.lab-btn--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.lab-btn--icon:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.94);
}

.lab-btn--icon svg {
  display: block;
}

/* 导航内图标按钮: 白底圆角不被基类透明规则压掉; fontello 字形强制纯白(layui 的 .layui-nav a 是 0.7 白) */
#nav-left-btn-list button.lab-btn--icon,
#nav-right-btn-list button.lab-btn--icon {
  background: rgba(255, 255, 255, 0.15) !important;
  border-radius: 8px !important;
}

#nav-left-btn-list button.lab-btn--icon a,
#nav-right-btn-list button.lab-btn--icon a {
  color: #fff !important;
}

/* ---- 上传按钮: 黄底黑字圆角加粗(手机/电脑/小程序一致) ---- */
#nav-left-btn-list #li_upload-btn,
#nav-right-btn-list #li_upload-btn,
.mp-env #li_upload-btn {
  background: #ffd23b !important;
  color: #000 !important;
  border-radius: 8px !important;
  padding: 0 16px !important;
  font-weight: bold !important;
  font-size: 14px !important;
}

#nav-left-btn-list #li_upload-btn a,
#nav-right-btn-list #li_upload-btn a,
.mp-env #li_upload-btn a {
  color: #000 !important;
  font-weight: bold !important;
}

/* ---- 触屏(手机浏览器): 隐藏第一组/第二组全部按钮与第三组除上传外的按钮 ---- */
.touch-env #btn-clear,
.touch-env #btn-undo,
.touch-env #btn-redo,
.touch-env #btn-save,
.touch-env #btn-load,
.touch-env #btn-h-bar,
.touch-env #btn-v-bar,
.touch-env #btn-code-area,
.touch-env #li_burn-btn,
.touch-env #li_deploy-ble-btn,
.touch-env #li_connect-btn,
.touch-env #conn-badge {
  display: none !important;
}

/* ---- 小程序(mp-env): 隐藏与触屏同规则 + 额外隐藏; 布局与字体 ---- */
.mp-env #btn-clear,
.mp-env #btn-undo,
.mp-env #btn-redo,
.mp-env #btn-save,
.mp-env #btn-load,
.mp-env #btn-h-bar,
.mp-env #btn-v-bar,
.mp-env #btn-code-area,
.mp-env #li_burn-btn,
.mp-env #li_deploy-ble-btn,
.mp-env #li_connect-btn,
.mp-env #conn-badge,
.mp-env #li_serial-btn,
.mp-env #code-editor,
.mp-env.code-mode #code-editor {
  display: none !important;
}

/* 小程序端: 状态窗口只保留「输出」标签, 去掉「串口」标签 */
.mp-env #tab-ace-serial {
  display: none !important;
}

/* 小程序端: 积木分类字体 13px(工具箱为 HTML, 不受工作区缩放影响) */
.mp-env .blocklyToolboxCategoryLabel {
  font-size: 13px !important;
}

/* 小程序端: 字体整体缩小 2 号(积木区文字除外) */
.mp-env #nav-left-btn-list button { font-size: 13px !important; }
.mp-env #nav-left-btn-list button > a { font-size: 12px !important; }
.mp-env #nav-right-btn-list .layui-btn a { font-size: 12px !important; }
.mp-env #mixly-footer { font-size: 10px !important; }
.mp-env .footer-btn { font-size: 13px; }
.mp-env .overlay-head { font-size: 14px; }
.mp-env .overlay-btn { font-size: 12px; }
.mp-env .m-field-title { font-size: 13px; }
.mp-env .m-field-value { font-size: 38px; }
.mp-env .m-field-input { font-size: 22px; }
.mp-env .m-field-grid button { font-size: 16px; }
.mp-env .m-field-actions button { font-size: 14px; }
.mp-env .m-toast { font-size: 12px; }

/* 小程序端: 分类面板收窄 */
.mp-env .blocklyToolbox { width: 110px !important; }

/* 小程序端菜单条布局: 返回按钮显示 + 上传按钮绝对定位右侧 */
#mp-back-btn { display: none; }

.mp-env #nav-left-btn-list {
  position: relative;
}

.mp-env #mp-back-btn {
  display: inline-block;
  padding: 0 6px !important;
}

.mp-env #li_upload-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.mp-env #li_upload-btn:active {
  transform: translateY(-50%) scale(0.96);
}

/* ===== 工具箱 ===== */
.blocklyToolbox {
  width: 140px !important;
}

.blocklyToolboxCategoryLabel {
  font-size: 16px !important;
}

.blocklyText {
  font-size: 16px !important;
}

.blocklyFlyoutLabelText {
  font-size: 16px !important;
}

/* 缩放控件与背包(与旧版一致: 显示) */

/* ===== 代码列(侧边栏/模式切换控制宽度; 并排布局, 永不遮挡积木区) ===== */
#code-editor {
  transition: width 0.15s ease;
}

/* 侧边栏(v-bar): 隐藏代码列 → 积木区放大; 再点恢复 */
body.code-panel-hidden #code-editor {
  width: 0 !important;
  border-left: none;
}

/* 模式切换(code-area): 代码列占满, 积木列收起 */
body.code-mode #code-editor {
  width: 100% !important;
  display: flex !important;
}

body.code-mode #block-editor {
  display: none;
}

/* ===== 手机端(<768px): 同样并排(窄屏代码列 38%), 不用覆盖层 ===== */
@media (max-width: 768px) {
  #code-editor {
    display: flex;
    width: 38% !important;
    position: static;
  }

  body.code-panel-hidden #code-editor {
    display: none !important;
  }

  body.code-mode #code-editor {
    display: flex !important;
    width: 100% !important;
  }

  #app-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 0 10px;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    z-index: 80;
  }

  #td_middle {
    height: 160px !important;
  }
}

/* 桌面端: 隐藏手机底栏 */
@media (min-width: 768px) {
  #app-footer { display: none; }
}

.footer-btn {
  flex: 1;
  height: 44px;
  border: 1px solid #ddd;
  border-radius: 22px;
  background: #fff;
  color: #333;
  font-size: 15px;
}

.footer-btn--primary {
  background: #FB5607;
  border-color: #FB5607;
  color: #fff;
  font-weight: bold;
}

.footer-btn:active { opacity: 0.75; }

/* ===== 代码弹窗(文件>导出代码) ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 99998;
  display: flex;
  flex-direction: column;
}

.overlay-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.overlay.hidden { display: none; }

.overlay-head {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: bold;
  color: #333;
  border-bottom: 1px solid #eee;
}

.overlay-head span { flex: 1; }

.overlay-btn {
  border: 1px solid #ddd;
  background: #fff;
  color: #333;
  border-radius: 16px;
  padding: 7px 14px;
  font-size: 14px;
}

.overlay-btn--primary {
  background: #FB5607;
  border-color: #FB5607;
  color: #fff;
}

/* ===== 串口工具(旧版 串口 按钮移植) ===== */
#serial-tool {
  background: rgba(0, 0, 0, 0.45);
}

#serial-tool .overlay-panel {
  position: relative;
  flex: none;
  width: 640px;
  max-width: 96%;
  height: 480px;
  margin: 40px auto 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#serial-tool-recv {
  flex: 1;
  margin: 10px 14px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-family: monospace;
  font-size: 13px;
  padding: 8px;
  resize: none;
  background: #f7f7f2;
}

.serial-tool-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 14px 12px;
}

.serial-tool-row--center {
  justify-content: center;
}

#serial-tool-send {
  flex: 1;
  height: 34px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 14px;
}

.serial-tool-row select {
  height: 34px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.serial-tool-row label {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* nav.css 全局禁用了文字选择, 输出区/串口监视/串口工具接收区恢复可选中复制 */
#sb-output,
#sb-monitor-output,
#serial-tool-recv {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* ===== 大号字段编辑弹窗(参考极速配送) ===== */
.m-field-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.m-field-card {
  position: relative;
  background: #fff;
  border-radius: 18px;
  padding: 22px 24px;
  width: 100%;
  max-width: 300px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.m-field-title {
  font-size: 15px;
  color: #666;
  margin-bottom: 10px;
}

.m-field-value {
  font-size: 40px;
  font-weight: bold;
  color: #FB5607;
  line-height: 1.2;
  margin-bottom: 14px;
  word-break: break-all;
}

.m-field-input {
  width: 100%;
  font-size: 24px;
  text-align: center;
  border: 2px solid #FB5607;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 14px;
  outline: none;
}

.m-field-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.m-field-grid button {
  height: 44px;
  border: 1px solid #eee;
  border-radius: 10px;
  background: #fafafa;
  font-size: 18px;
  color: #333;
}

.m-field-grid button:active { background: #FB5607; color: #fff; }

.m-field-actions {
  display: flex;
  gap: 10px;
}

.m-field-actions button {
  flex: 1;
  height: 44px;
  border: none;
  border-radius: 22px;
  font-size: 16px;
}

.m-field-ok { background: #FB5607; color: #fff; }
.m-field-cancel { background: #f0f0ea; color: #666; }

.m-toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 18px;
  border-radius: 22px;
  font-size: 14px;
  z-index: 99999;
  pointer-events: none;
}

@media (min-width: 768px) {
  .m-toast { bottom: 40px; }
}

.hidden { display: none !important; }

/* 取色字段(桌面版行为): 白色描边仅鼠标悬停时显示 */
.evalley-colour-field {
  stroke-opacity: 0;
  transition: stroke-opacity 0.15s;
}
.evalley-colour-field:hover {
  stroke-opacity: 1;
}

/* ===== 嵌入模式(思源致远关卡 iframe, ?embed=1) ===== */
/* 隐藏导航装饰与代码区, 保留 清空/撤销/重做/保存/加载 + 连接/上传 */
.embed-env #mp-back-btn,
.embed-env #mixly-path,
.embed-env #btn-h-bar,
.embed-env #btn-v-bar,
.embed-env #btn-code-area,
.embed-env #li_burn-btn,
.embed-env #li_deploy-ble-btn,
.embed-env #code-editor,
.embed-env #code-mode-hint {
  display: none !important;
}
.embed-env #block-editor {
  flex: 1 1 auto;
}

/* 嵌入模式预留面板: 默认隐藏; embed 时桌面占右侧(max 50%), 触屏占上方 300px
   (布局参照 cv.lanshenggu.com 关卡页: 桌面左工作区右结果, 手机上方结果下方工作区) */
.embed-panel { display: none; }
.embed-env .embed-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  max-width: 50%;
  min-width: 0;
  background: #f5f6f7;
  border-left: 1px solid #e5e5e5;
  overflow: auto;
}
.embed-env.touch-env #v-container {
  flex-direction: column !important;
}
.embed-env.touch-env #block-editor { order: 1; }
.embed-env.touch-env .embed-panel {
  order: 0;
  flex: none;
  width: 100%;
  max-width: none;
  height: 300px;
  border-left: none;
  border-bottom: 1px solid #e5e5e5;
}
