* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #2b2520; color: #ddd; -webkit-tap-highlight-color: transparent; }
.layout { display: grid; grid-template-columns: 240px 1fr 320px; gap: 8px; height: 100vh; padding: 8px; }
.panel { background: #3a322c; border-radius: 8px; padding: 12px; overflow-y: auto; }

/* 左：session 列表 */
.panel-left h3 { margin: 0 0 8px; color: #f3deac; font-size: 14px; }
#session-list { list-style: none; padding: 0; margin: 0; }
.sess-item { padding: 8px; margin-bottom: 6px; background: #4a3f37; border-radius: 6px; cursor: pointer; position: relative; }
.sess-item:hover { background: #5a4d42; }
.sess-item.active { background: #6b4423; border: 1px solid #c4881a; }
.sess-name { font-weight: bold; font-size: 13px; }
.sess-meta { color: #aaa; font-size: 11px; margin-top: 4px; }
.sess-del { position: absolute; right: 8px; top: 6px; color: #888; font-size: 16px; padding: 2px 8px; }
.sess-del:hover { color: #f55; }

/* 中：棋盘 */
.panel-center { display: flex; flex-direction: column; align-items: center; padding: 16px; }
#session-head { width: 100%; margin-bottom: 12px; }
.sess-title { font-size: 16px; font-weight: bold; color: #f3deac; }
.sess-line { font-size: 12px; color: #bbb; margin-top: 4px; }
.placeholder { color: #888; padding: 30px; text-align: center; }
.toolbar { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; justify-content: center; }
.btn { background: #5a4423; border: 1px solid #7a5b30; color: #f3deac; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 13px; touch-action: manipulation; }
.btn:hover { background: #6b5028; }
.btn:active { background: #8b5a1a; }
.btn:disabled { background: #3a322c; color: #888; cursor: wait; border-color: #4a3f37; }
.btn-primary { background: #8b5a1a; }
.btn-primary:hover { background: #a36a20; }
.btn-danger { background: #7a3a3a; }
.board-wrap { width: 100%; max-width: 560px; margin: 0 auto; }
#board-svg { display: block; width: 100%; height: auto; background: #f3deac; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.3); touch-action: none; -webkit-user-select: none; user-select: none; }

#ai-status { color: #ffeb3b; font-size: 13px; margin: 8px 0; min-height: 20px; text-align: center; font-family: ui-monospace, monospace; font-weight: 500; }

#edit-panel { margin-top: 8px; padding: 8px; background: #4a3f37; border-radius: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#edit-panel select { background: #5a4d42; color: #ddd; border: 1px solid #7a5b30; padding: 4px; }

/* 右：决策树 + 走子日志 */
.panel-right h3 { margin: 0 0 6px; color: #f3deac; font-size: 14px; }
.panel-right { display: flex; flex-direction: column; gap: 10px; }
#move-log { background: #2b2520; border-radius: 4px; padding: 8px; max-height: 200px; overflow-y: auto; font-family: ui-monospace, monospace; font-size: 12px; }
.mv { padding: 1px 0; }

#decision-tree { background: #2b2520; border-radius: 4px; padding: 8px; flex: 1; overflow-y: auto; font-size: 12px; }
.tree-head { padding: 4px 0; border-bottom: 1px solid #444; margin-bottom: 6px; }
.bm { color: #ffa726; font-weight: bold; }
.spf-tag { background: #7a3a1a; color: #fff; padding: 2px 6px; border-radius: 3px; font-size: 11px; }
.tree-root { list-style: none; padding: 0; margin: 0; }
.tnode { margin-bottom: 4px; }
.tnode-hd { padding: 4px; background: #4a3f37; border-radius: 4px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.tnode-hd:hover { background: #5a4d42; }
.rank { color: #ffa726; font-weight: bold; }
.mv-iccs { font-family: monospace; }
.cp { color: #8bc34a; }
.spf-prob { color: #ff8a65; font-size: 11px; }
.btn-deep { margin-left: auto; background: #5a4423; border: 1px solid #7a5b30; color: #f3deac; padding: 2px 8px; border-radius: 3px; cursor: pointer; font-size: 11px; }
.tnode-pv { list-style: none; padding: 4px 0 4px 24px; margin: 0; color: #aaa; font-family: monospace; font-size: 11px; }
.tnode-pv li { padding: 1px 0; }
.deep-result { padding: 6px 0 6px 24px; color: #ffa; font-size: 11px; font-family: monospace; }
.deep-head { color: #f3deac; font-weight: bold; margin-bottom: 3px; }

/* 对话框 */
.dialog { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; align-items: center; justify-content: center; padding: 12px; }
.dialog-inner { background: #3a322c; padding: 20px; border-radius: 8px; min-width: 320px; max-width: 500px; width: 100%; max-height: calc(100vh - 24px); overflow-y: auto; }
.dialog h3 { margin-top: 0; color: #f3deac; }
.dlg-row { margin: 10px 0; }
.dlg-row label { display: block; margin-bottom: 4px; color: #bbb; font-size: 13px; }
.dlg-row input, .dlg-row select, .dlg-row textarea { width: 100%; padding: 8px; background: #4a3f37; border: 1px solid #5a4d42; color: #ddd; border-radius: 4px; font-family: inherit; font-size: 14px; }
.dlg-row textarea { font-family: monospace; }
.dlg-actions { text-align: right; margin-top: 12px; }
.dlg-actions .btn { margin-left: 6px; }
.flex-row { display: flex; gap: 8px; }
.flex-row > * { flex: 1; }

/* ---- 移动端布局 ---- */
.tabs { display: none; position: sticky; top: 0; z-index: 50; background: #2b2520; padding: 6px 8px 0; gap: 4px; }
.tab-btn { flex: 1; background: #3a322c; border: 1px solid #4a3f37; color: #ccc; padding: 8px 4px; border-radius: 6px 6px 0 0; cursor: pointer; font-size: 13px; border-bottom: none; }
.tab-btn.active { background: #6b4423; color: #f3deac; border-color: #c4881a; }

@media (max-width: 900px) {
  body { overflow-x: hidden; }
  .tabs { display: flex; }
  .layout {
    display: block;
    height: auto;
    min-height: 100vh;
    padding: 0;
    grid-template-columns: none;
  }
  .panel {
    border-radius: 0;
    padding: 10px;
    max-height: none;
    overflow-y: visible;
    display: none;
  }
  .panel.active { display: block; }
  /* center 始终显示，左右作为 tab 切换 */
  .panel-center { display: flex; padding: 6px 6px 10px; }
  .panel-center.tab-hidden { display: none; }
  .toolbar { gap: 4px; }
  .btn { padding: 8px 10px; font-size: 13px; }
  .btn-deep { padding: 6px 10px; font-size: 12px; }
  .board-wrap { max-width: 100%; }
  #session-head { margin-bottom: 6px; }
  .sess-title { font-size: 15px; }
  #move-log { max-height: 50vh; }
  #decision-tree { max-height: none; }
  .panel-right { gap: 14px; }
  /* 触屏点击区扩大 */
  .sess-item { padding: 12px 10px; }
  .sess-del { padding: 6px 12px; font-size: 18px; }
}
