/* BJS 面板 Z2 层 — 折叠为横条，展开从同一位置占满左下部 */
#bjs-main-panel {
  position: fixed;
  z-index: 2;
  background: rgba(20, 20, 40, 0.94);
  border: 2px solid #ffcc33;
  border-radius: 12px;
  color: #fff5cc;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: all 0.2s ease;
}

/* ---------- 折叠状态：横条，与课程面板下方对齐 ---------- */
#bjs-main-panel.collapsed {
  left: 10px;
  top: 106px;
  width: 300px;
  height: 40px;
  resize: none;
}
#bjs-main-panel.collapsed #bjs-code-wrapper,
#bjs-main-panel.collapsed #bjs-button-bar,
#bjs-main-panel.collapsed #bjs-log-output,
#bjs-main-panel.collapsed #bjs-suggestions {
  display: none !important;
}
#bjs-main-panel.collapsed #bjs-panel-header {
  border-bottom: none;
}

/* ---------- 展开状态：从折叠位置扩展，填满左侧下部空间 ---------- */
#bjs-main-panel.expanded {
  left: 10px;
  top: 106px;
  width: 50vw;
  height: calc(70vh - 106px - 20px);
  resize: both;
  min-width: 400px;
  min-height: 200px;
}

/* ---------- 标题栏 ---------- */
#bjs-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  height: 40px;
  background: rgba(0,0,0,0.5);
  border-bottom: 1px solid #ffcc33;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}
#bjs-toggle-panel-btn {
  background: none;
  border: none;
  color: #ffcc33;
  font-size: 18px;
  cursor: pointer;
}

/* ---------- 代码输入区 ---------- */
#bjs-code-wrapper {
  margin: 10px 10px 0 10px;
  flex: 0  0 auto;
  min-height: 120px;
}
#bjs-code-input {
  width: 100%;
  height: 400px;              
  background: #0a0a1a;
  border: 1px solid #ffcc33;
  color: #9eff9e;
  font-family: 'Fira Code', monospace;
  font-size: 16px;
  resize: vertical;
  box-sizing: border-box;
  padding: 8px;
}

/* ---------- 按钮栏 ---------- */
#bjs-button-bar {
  display: flex;
  gap: 12px;
  padding: 8px 10px;
  flex-shrink: 0;
}
#bjs-button-bar button {
  padding: 8px 20px;
  border: none;
  color: white;
  font-weight: bold;
  cursor: pointer;
  border-radius: 8px;
  font-size: 14px;
}
#bjs-exec-btn       { width: 160px; background: #2c8c2c; }
#bjs-clear-code-btn { width: 140px; background: #dc2626; }
#bjs-undo-btn       { width: 100px; background: #f0ad4e; }

/* ---------- 日志输出区（降低弹性，限制最大高度） ---------- */
#bjs-log-output {
  margin: 0 10px;
  flex: 0 1 120px;            /* 基准高度120px，可收缩但不扩展过多 */
  max-height: 150px;
  min-height: 40px;
  background: #0a0a1a;
  border: 1px solid #ffcc33;
  color: #ffaaaa;
  font-family: monospace;
  font-size: 14px;
  overflow-y: auto;
  padding: 8px;
  white-space: pre-wrap;
}

/* ---------- 补全列表 ---------- */
#bjs-suggestions {
  display: none;
  flex-shrink: 0;
  margin: 0 10px 10px 10px;
  max-height: 180px;
  overflow-y: auto;
  background: #2d2d2d;
  border: 1px solid #555;
  color: #eee;
  list-style: none;
  padding: 0;
  z-index: 1001;
}
#bjs-suggestions li {
  padding: 4px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #444;
}
#bjs-suggestions li .api { color: #9cdcfe; flex: 1; }
#bjs-suggestions li .desc { color: #6a9955; font-style: italic; margin-left: 10px; }
#bjs-suggestions li.cat-item { background: #3c3c3c; font-weight: bold; }
#bjs-suggestions li.cat-item .api { color: #ffcc66; }
#bjs-suggestions li.back-item { color: #ccc; font-style: italic; }
#bjs-suggestions li:hover, #bjs-suggestions li.active { background: #094771; }

/* ---------- 保存按钮 ---------- */
#bjs-save-btn {
  width: 120px;
  background: #1e88e5;
  border-radius: 8px;
  font-size: 14px;
  font-weight: bold;
  color: white;
  cursor: pointer;
  border: none;
  padding: 8px 20px;
  transition: background 0.2s;
}
#bjs-save-btn:hover { background: #1565c0; }