:root {
  --bg: #e9edf1;
  --panel: #ffffff;
  --ink: #1d2730;
  --muted: #66737f;
  --line: #dde3e8;
  --accent: #0f8b8d;
  --accent-soft: #dff1f1;
  --sel: #ff7a1a;
  --measure: #e8590c;
  --shadow: 0 6px 24px rgba(20, 35, 50, .14);
  --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 14px/1.35 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.small { padding: 3px 8px; font-size: 13px; white-space: nowrap; }
input[type=search] { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

#app { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; overflow: hidden; }
#canvas { width: 100%; height: 100%; display: block; touch-action: none; }
#labels { position: absolute; inset: 0; pointer-events: none; }
.mlabel { position: absolute; transform: translate(-50%, -130%); background: var(--measure); color: #fff;
  padding: 2px 6px; border-radius: 4px; font-size: 13px; font-weight: 600; white-space: nowrap; }
#snapMark { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid var(--measure);
  border-radius: 2px; pointer-events: none; display: none; }
#snapMark.face { border-radius: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; }
#selRect { position: absolute; display: none; pointer-events: none; border: 1.5px solid var(--accent);
  background: rgba(15, 139, 141, .08); }
#selRect.crossing { border-style: dashed; background: rgba(255, 122, 26, .08); border-color: var(--sel); }

#loadBar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 20; }
#loadBarFill { height: 100%; width: 0; background: var(--accent); transition: width .2s, opacity .6s; }
#titleChip { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px;
  box-shadow: var(--shadow); display: flex; gap: 10px; align-items: baseline; max-width: calc(100% - 24px);
  white-space: nowrap; overflow: hidden; }
#title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
#statusText { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
#toast { position: fixed; top: 52px; left: 50%; transform: translateX(-50%); z-index: 30; background: #24323d; color: #fff;
  padding: 7px 14px; border-radius: 8px; display: none; max-width: calc(100% - 32px); text-align: center; }

/* floating panels */
.panel { position: fixed; top: 56px; bottom: 92px; width: 300px; z-index: 10; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-height: 0; }
.panel.left { left: 12px; }
.panel.right { right: 12px; width: 330px; }
.panel.closed { display: none; }
.panel header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px; }
.panel h2 { margin: 0; font-size: 15px; }
.panel .x { border: 0; background: transparent; font-size: 20px; line-height: 1; padding: 2px 6px; color: var(--muted); }
.pbody { padding: 4px 12px 12px; overflow: auto; flex: 1; min-height: 0; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; justify-content: flex-start; }
.hint { color: var(--muted); font-size: 13px; }
.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.seg { display: inline-flex; background: #f1f4f6; border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 7px; font-size: 13px; }
.seg button.active { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }

#layerTree, #layerTree ul { list-style: none; margin: 0; padding: 0; }
#layerTree ul { padding-left: 16px; }
#layerTree li > .lrow { display: flex; align-items: center; gap: 6px; padding: 3px 2px; border-radius: 4px; }
#layerTree li > .lrow:hover { background: #f2f6f8; }
.lrow .tw { width: 16px; text-align: center; color: var(--muted); cursor: pointer; user-select: none; }
.lrow .sw { position: relative; width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.25); flex: none; cursor: pointer; }
.lrow .sw input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.lrow .sw.custom { box-shadow: 0 0 0 2px var(--accent); }
.lrow .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.lrow .ct { color: var(--muted); font-size: 12px; }
.lrow input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--accent); }
li.collapsed > ul { display: none; }
li.hiddenByFilter { display: none; }

/* properties */
#propsBody { margin-top: 10px; }
#propsBody h3 { margin: 4px 0 8px; font-size: 16px; word-break: break-all; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 10px; font-size: 12px; }
.crumbs button { padding: 2px 7px; font-size: 12px; border-radius: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs button.cur { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.crumbs .sep { color: var(--muted); }
.ptable { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 10px; }
.ptable td { border-bottom: 1px solid var(--line); padding: 5px 2px; vertical-align: top; word-break: break-word; }
.ptable td:first-child { color: var(--muted); width: 40%; word-break: normal; }
.ptitle { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 12px 0 4px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.glist { list-style: none; padding: 0; margin: 0 0 10px; }
.glist li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.glist li:hover { background: #f2f6f8; }
.glist .c { color: var(--muted); flex: none; }
.glist .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#measSection h3 { display: flex; justify-content: space-between; align-items: center; font-size: 13px;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 4px; }
#measList { padding-left: 20px; margin: 4px 0; }
#measList li { padding: 6px 0; border-bottom: 1px solid var(--line); }
#measList .big { font-weight: 600; font-size: 16px; }
#measList .d { color: var(--muted); font-size: 12px; }
#measList button { float: right; }

/* dock */
#dock { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 12;
  display: flex; gap: 14px; align-items: center; padding: 7px 12px; background: rgba(255,255,255,.96);
  border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
  max-width: calc(100% - 16px); overflow-x: auto; scrollbar-width: none; }
#dock::-webkit-scrollbar { display: none; }
.dgroup { display: flex; gap: 2px; flex: none; }
#dock button { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; color: #34424d; flex: none; }
#dock button:hover { background: #eef2f4; }
#dock button.active { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1.5px rgba(15,139,141,.45); }
#dock svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.pop { position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%); z-index: 13; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 10px;
  width: min(520px, calc(100% - 24px)); }
#sectionPop { display: flex; gap: 10px; align-items: center; }
#sectionPop input[type=range] { flex: 1; accent-color: var(--accent); }
#secVal { font-variant-numeric: tabular-nums; min-width: 92px; text-align: right; color: var(--muted); }
#searchResults { list-style: none; padding: 0; margin: 8px 0 0; max-height: 40vh; overflow: auto; }
#searchResults li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 6px; border-radius: 6px; cursor: pointer; }
#searchResults li:hover, #searchResults li.all { background: #f2f6f8; }
#searchResults li.all { font-weight: 600; color: var(--accent); }
#searchResults .c { color: var(--muted); flex: none; }

#picker { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40; }
#picker .card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; width: min(520px, 100%); }
#picker h1 { font-size: 18px; margin: 0 0 10px; }
#modelList { list-style: none; padding: 0; margin: 0; }
#modelList a { display: block; padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px;
  color: var(--ink); text-decoration: none; }
#modelList a:hover { border-color: var(--accent); }
#modelList small { color: var(--muted); display: block; }

@media (max-width: 760px) {
  .panel { top: 50px; bottom: 74px; }
  .panel.left { left: 8px; right: auto; width: min(86vw, 320px); }
  .panel.right { left: 8px; right: 8px; width: auto; top: auto; bottom: 74px; max-height: 48vh; }
  #dock { bottom: 10px; gap: 8px; padding: 5px 8px; justify-content: flex-start; }
  #dock button { width: 36px; height: 36px; }
  .pop { bottom: 64px; }
  #titleChip { top: 8px; }
  #statusText { display: none; }
}
