/* แล็บ AI เบื้องต้น — เวทีบน / แผงล่าง (จอกว้าง: ซ้าย-ขวา) */
:root{
  --sans:'IBM Plex Sans Thai','Noto Sans Thai',system-ui,-apple-system,'Segoe UI',sans-serif;
  --ink:#191a24; --muted:#6b6c7e; --line:#e6e3dc; --surface:#fff; --bg:#f5f4ef;
  --brand:#2e7d88; --brand-ink:#1f5f68; --brand-soft:#dcecee;
  --ok:#129a72; --warn:#d68a17; --danger:#e2564a;
  --grpA:#3a86e0; --grpB:#f08a3c;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden}
body{font-family:var(--sans);color:var(--ink);background:var(--bg);display:flex;flex-direction:column;
  -webkit-font-smoothing:antialiased;user-select:none;-webkit-user-select:none}
input,textarea,select,[contenteditable]{-webkit-user-select:text;user-select:text}

#stage{position:relative;flex:1;min-height:0;background:#f2f0ea}
#webgl-canvas{width:100%;height:100%;display:block;touch-action:none}

.status{
  position:absolute;left:12px;top:12px;
  background:rgba(255,255,255,.95);border:1px solid var(--line);border-radius:12px;
  padding:8px 13px;font-size:.82rem;box-shadow:0 4px 14px rgba(25,26,36,.12);
  pointer-events:none;max-width:min(560px,calc(100% - 120px));line-height:1.5;
}
.status.ok{border-color:#bfe9da;color:#0a6b50;background:#f0fbf7}
.status.bad{border-color:#f6cdc9;color:#8f2018;background:#fdf3f2}
.status.warn{border-color:#f7e2bd;color:#7d5209;background:#fffaf0}

#panel{
  flex:none;background:var(--surface);border-top:1px solid var(--line);
  padding:12px 14px 14px;display:flex;flex-direction:column;gap:11px;max-height:54vh;overflow-y:auto;
}
.panel-head{display:flex;align-items:baseline;gap:10px}
.panel-title{font-weight:700;font-size:.92rem}
.goal{font-size:.78rem;color:var(--muted);margin-left:auto;text-align:right}
.hint{font-size:.76rem;color:var(--muted);line-height:1.55;margin:0}

.stat-row{display:flex;gap:8px}
.stat{flex:1;background:var(--bg);border-radius:12px;padding:8px 11px;display:flex;flex-direction:column;gap:2px}
.stat-k{font-size:.7rem;font-weight:700;color:var(--muted)}
.stat-v{font-size:1.15rem;font-weight:700;font-variant-numeric:tabular-nums}

.ctl-row{display:flex;gap:8px}
.ctl-row .btn{flex:1}

.lr-row{display:flex;gap:6px;align-items:center}
.lr-label{font-size:.76rem;font-weight:600;color:var(--muted);flex:none}
.lr-btn{flex:1;padding:7px 4px;border-radius:9px;border:1.5px solid var(--line);background:#fff;
  font-family:inherit;font-size:.8rem;font-weight:700;cursor:pointer;color:var(--ink);font-variant-numeric:tabular-nums}
.lr-btn.is-active{border-color:var(--brand);background:var(--brand-soft);color:var(--brand-ink)}

.add-row{display:flex;gap:6px}
.add-btn{flex:1;padding:8px 4px;border-radius:9px;border:1.5px solid var(--line);background:#fff;
  font-family:inherit;font-size:.78rem;font-weight:600;cursor:pointer;color:var(--ink)}
.add-btn.a.is-active{border-color:var(--grpA);background:#e7f1fc;color:#1d5da8}
.add-btn.b.is-active{border-color:var(--grpB);background:#fdf0e4;color:#a85618}

.tasks{display:flex;flex-direction:column;gap:5px}
.tk-head{font-size:.78rem;font-weight:600;color:var(--muted)}
.tk-head span:last-child{background:var(--brand-soft);color:var(--brand-ink);padding:1px 8px;border-radius:999px;font-size:.72rem}
.task-list{display:flex;flex-direction:column;gap:4px}
.task-item{display:flex;align-items:center;gap:7px;font-size:.78rem;padding:6px 9px;border-radius:8px;background:var(--bg)}
.task-item.is-done{background:#e9f8f2;color:#0a6b50}
.task-check{width:16px;height:16px;border-radius:50%;border:2px solid var(--line);flex:none;display:grid;place-items:center;font-size:.6rem;color:#fff}
.task-item.is-done .task-check{background:var(--ok);border-color:var(--ok)}

.actions{display:flex;gap:8px}
.btn{padding:10px 14px;border-radius:999px;border:1px solid transparent;font-family:inherit;
  font-size:.84rem;font-weight:600;cursor:pointer;box-shadow:0 2px 6px rgba(25,26,36,.12)}
.btn:active{transform:translateY(1px)}
.btn[disabled]{opacity:.45;pointer-events:none}
.btn-ghost{background:var(--surface);border-color:var(--line);color:var(--ink)}
.btn-run{background:var(--brand);color:#fff}
.btn-run.is-on{background:var(--danger)}
.btn-submit{background:var(--ok);color:#fff;width:100%}

@media (min-width:900px){
  body{flex-direction:row}
  #panel{width:348px;max-height:none;height:100%;border-top:none;border-left:1px solid var(--line);padding:16px}
}
@media (max-width:560px){
  .status{position:static;margin:8px 12px;max-width:none}
  #stage{display:flex;flex-direction:column;min-height:46vh}
  #webgl-canvas{flex:1;min-height:180px}
}

/* ---------- เลือกวิธีเรียนรู้ ---------- */
.mode-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.mode-btn {
  flex: 1 1 46%; padding: 8px 6px; border-radius: 10px; cursor: pointer; font: inherit; font-size: .84rem;
  border: 1px solid var(--pg-line, #d5dbe3); background: var(--pg-card, #fff); color: var(--pg-ink, #222);
}
.mode-btn.is-active { border-color: #2f6fa8; background: #e5eefb; color: #17456e; font-weight: 600; }

/* ---------- กล่อง "เครื่องคิดยังไง" ---------- */
.works {
  border: 1px solid var(--pg-line, #d9dee5); border-radius: 12px;
  padding: 10px 12px; margin: 8px 0; background: var(--pg-card, #fff);
}
.w-title { font-weight: 700; font-size: .82rem; opacity: .65; margin-bottom: 6px; letter-spacing: .03em; }
.w-hint { font-size: .82rem; opacity: .6; margin: 4px 0; }
.w-eq {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem;
  background: #f2f5f8; border-radius: 8px; padding: 7px 9px; margin-bottom: 7px; overflow-x: auto; white-space: nowrap;
}
.w-row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; font-size: .85rem; }
.w-k { opacity: .7; }
.w-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.w-v.blue { color: #2f6fa8; } .w-v.orange { color: #c56d21; }
.w-v.good { color: #2e7d4f; } .w-v.bad { color: #c0392b; }
.w-upd {
  margin-top: 6px; font-size: .76rem; line-height: 1.5; color: #8a5300;
  background: #fdf3e2; border-radius: 8px; padding: 6px 8px;
}
.w-bars { display: flex; gap: 6px; align-items: flex-end; height: 62px; margin: 4px 0 8px; }
.w-bar {
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  height: 100%; background: #f2f5f8; border-radius: 6px; overflow: hidden; position: relative;
}
.w-bar span { width: 100%; border-radius: 6px 6px 0 0; }
.w-bar small { position: absolute; bottom: 2px; font-size: .62rem; opacity: .75; }

/* ---------- ชิปตัวเลือก ---------- */
.opt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.opt-lab { font-size: .78rem; opacity: .65; margin-right: 2px; }
.chip {
  padding: 5px 11px; border-radius: 999px; cursor: pointer; font: inherit; font-size: .8rem;
  border: 1px solid var(--pg-line, #d5dbe3); background: var(--pg-card, #fff); color: var(--pg-ink, #222);
}
.chip.is-active { border-color: #2f6fa8; background: #e5eefb; color: #17456e; font-weight: 600; }

/* ---------- ลูกบิดตั้งค่าการเรียนรู้ ---------- */
.knob-box{display:flex;flex-direction:column;gap:8px;border:1px solid var(--line);
  border-radius:12px;padding:9px 11px;background:var(--bg)}
.knob-row{display:flex;flex-direction:column;gap:7px}
.knob-say{display:grid;grid-template-columns:1fr auto;gap:2px 10px;font-size:.73rem;align-items:baseline}
.ks-k{color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ks-v{font-variant-numeric:tabular-nums;font-weight:700;text-align:right}
.ks-v.warn{color:#c0392b}
