*{margin:0;padding:0;box-sizing:border-box}
html,body{width:100%;height:100%;overflow:hidden;background:#000}
body{color:#d4af37;font-family:"STKaiti","KaiTi",serif;user-select:none;-webkit-user-select:none;touch-action:none}
#arVideo{position:fixed;inset:0;width:100%;height:100%;object-fit:cover;z-index:0;display:none;background:#000}
#canvas{position:fixed;inset:0;display:block;cursor:grab;z-index:1;background:#000}
body.ar #canvas{background:transparent}
body.ar #arVideo{display:block}
#canvas:active{cursor:grabbing}
.toolbar{position:fixed;top:0;left:0;right:0;display:flex;gap:4px;padding:6px;
  background:linear-gradient(to bottom,rgba(0,0,0,0.85),rgba(0,0,0,0.4),transparent);
  z-index:30;flex-wrap:wrap;justify-content:center;pointer-events:none}
.toolbar button{pointer-events:auto;background:rgba(20,20,40,0.85);border:1px solid #d4af37;
  color:#d4af37;padding:5px 10px;border-radius:6px;font-size:12px;font-family:inherit;
  cursor:pointer;backdrop-filter:blur(6px);min-height:32px;display:inline-flex;align-items:center;gap:4px}
.toolbar button:hover{background:#d4af37;color:#000}
.toolbar button.active{background:#d4af37;color:#000;font-weight:bold;box-shadow:0 0 12px #d4af37}
.panel{position:fixed;top:50px;left:8px;background:rgba(15,15,30,0.92);
  border:1px solid #d4af37;padding:8px;border-radius:8px;max-width:240px;
  font-size:11px;backdrop-filter:blur(8px);max-height:calc(100vh - 60px);
  overflow-y:auto;z-index:20;line-height:1.5}
.panel.right{left:auto;right:8px;max-width:230px}
.panel.hidden{display:none}
.panel h2{font-size:13px;margin-bottom:5px;border-bottom:1px solid #d4af37;
  padding-bottom:3px;display:flex;justify-content:space-between;align-items:center}
.panel h2 .x{cursor:pointer;color:#888;font-size:14px;padding:0 4px}
.panel h2 .x:hover{color:#fff}
.panel h3{font-size:11px;margin:6px 0 3px;color:#ffd966;cursor:pointer;
  padding:2px 4px;background:rgba(212,175,55,0.08);border-radius:3px;
  display:flex;justify-content:space-between}
.panel h3::after{content:"▼";font-size:9px;opacity:0.6}
.panel h3.collapsed::after{content:"▶"}
.panel .group{margin-bottom:4px}
.panel .group.collapsed .body{display:none}
.panel label{display:block;margin:2px 0;cursor:pointer;line-height:1.4}
.panel input[type=checkbox],.panel input[type=radio]{margin-right:4px;vertical-align:middle}
.panel input[type=number],.panel input[type=datetime-local],.panel select,.panel input[type=range]{
  width:100%;background:rgba(0,0,0,0.5);color:#d4af37;border:1px solid #555;
  padding:2px 4px;border-radius:3px;font-size:11px;font-family:inherit;margin:1px 0}
.panel input[type=range]{padding:0}
.info{position:fixed;bottom:8px;left:8px;background:rgba(15,15,30,0.88);
  border:1px solid #d4af37;padding:6px 10px;border-radius:6px;font-size:11px;
  max-width:calc(100% - 16px);line-height:1.5;z-index:15;backdrop-filter:blur(6px)}
.info .x{float:right;cursor:pointer;color:#888;margin-left:8px}
.info.hidden{display:none}
.legend{font-size:10px}
.legend-row{display:flex;align-items:center;margin:1px 0}
.swatch{width:14px;height:3px;margin-right:5px}
.swatch-d{width:12px;height:12px;margin-right:5px;border-radius:2px}
button{background:transparent;border:1px solid #d4af37;color:#d4af37;
  padding:3px 7px;cursor:pointer;border-radius:3px;margin:2px 2px 0 0;
  font-family:inherit;font-size:10px}
button:hover{background:#d4af37;color:#000}
button.primary{background:rgba(212,175,55,0.2);font-weight:bold}
.row{display:flex;gap:4px;align-items:center}
.row span{font-size:10px;flex:0 0 28px}
.row input{flex:1}
.note{position:fixed;bottom:8px;right:8px;background:rgba(40,30,10,0.88);
  border:1px solid #d4af37;padding:6px 8px;border-radius:6px;font-size:10px;
  max-width:200px;line-height:1.5;color:#ffd966;z-index:15;backdrop-filter:blur(6px)}
.note.hidden{display:none}
.toast{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);
  background:rgba(40,10,10,0.95);border:1px solid #ff6b6b;color:#ffaa88;
  padding:14px 22px;border-radius:8px;z-index:100;max-width:90%;text-align:center;
  font-size:13px;line-height:1.6;display:none}
.toast.show{display:block}
.toast button{margin-top:8px}
.indicator{position:fixed;top:50px;right:8px;background:rgba(0,0,0,0.6);
  border:1px solid rgba(212,175,55,0.4);padding:3px 7px;border-radius:4px;
  font-size:10px;color:#d4af37;z-index:18;backdrop-filter:blur(4px)}
.indicator.hidden{display:none}
.calibrate-hint{position:fixed;bottom:50px;left:50%;transform:translateX(-50%);
  background:rgba(212,175,55,0.85);color:#000;padding:5px 12px;border-radius:14px;
  font-size:11px;z-index:18;font-weight:bold;display:none}
.calibrate-hint.show{display:block}
@media (max-width:600px){
  .toolbar button{padding:4px 7px;font-size:11px}
  .panel{font-size:10.5px;max-width:calc(100vw - 16px);width:auto}
  .panel.right{max-width:calc(100vw - 16px)}
  .info{font-size:10px;max-width:calc(100vw - 16px)}
  .note{max-width:160px;font-size:9px}
}
@media (max-height:500px) and (orientation:landscape){
  .panel{max-height:calc(100vh - 50px);font-size:10px}
  .info{max-width:60vw}
}
