:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c232d;
  --line: #2a3340;
  --text: #dbe2ea;
  --text-dim: #8b98a8;
  --accent: #4a9eff;
  --accent2: #7c5cff;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --log-bg: rgba(13, 17, 23, 0.95);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ---------- toolbar ---------- */
#toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.tb-group { display: flex; align-items: center; gap: 6px; }
.tb-btn {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
}
.tb-btn:hover { border-color: var(--accent); }
.tb-btn.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; }
.tb-btn.view-btn.active { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.tb-select {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 6px;
}
.tb-check { display: flex; align-items: center; gap: 4px; color: var(--text-dim); cursor: pointer; }
.tb-info { color: var(--text-dim); font-variant-numeric: tabular-nums; }
#tbRight { margin-left: auto; }

/* ---------- main ---------- */
#main {
  flex: 1;
  display: flex;
  min-height: 0;
}
#left {
  width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel-title { color: var(--text-dim); font-weight: 600; font-size: 12px; letter-spacing: 1px; }
.shape-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.shape-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
}
.shape-item:hover { border-color: var(--accent); }
.shape-item.selected { border-color: var(--accent); background: rgba(74, 158, 255, 0.12); }
.shape-item .sname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.shape-item .sdel { color: var(--text-dim); cursor: pointer; padding: 0 4px; }
.shape-item .sdel:hover { color: var(--err); }
.flat-btn {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
}
.flat-btn:hover { border-color: var(--accent); }
.flat-btn.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; }
.flat-btn.danger:hover { border-color: var(--err); color: var(--err); }
.params { display: flex; flex-direction: column; gap: 6px; }
.param-row { display: flex; align-items: center; gap: 6px; }
.param-row label { width: 66px; color: var(--text-dim); flex-shrink: 0; }
.param-row input[type="number"], .param-row input[type="text"], .param-row input[type="color"], .param-row select {
  flex: 1;
  min-width: 0;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 4px 6px;
}
.param-row input[type="color"] { padding: 2px; height: 26px; }
.param-row .u { color: var(--text-dim); font-size: 11px; }
.param-section { color: var(--text-dim); font-weight: 600; font-size: 11px; letter-spacing: 1px; margin-top: 4px; border-top: 1px dashed var(--line); padding-top: 6px; }
.param-section:first-child { border-top: none; margin-top: 0; padding-top: 0; }

/* ---------- center ---------- */
#center { flex: 1; position: relative; min-width: 0; background: var(--bg); }
#preview { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#hint {
  position: absolute;
  left: 10px;
  bottom: 8px;
  color: var(--text-dim);
  font-size: 11px;
  pointer-events: none;
  background: rgba(13, 17, 23, 0.6);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ---------- right ---------- */
#right {
  width: 300px;
  background: var(--bg2);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#right .panel-title { padding: 8px 8px 4px; }
#jsonWrap { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 8px; }
#jsonArea {
  flex: 1;
  resize: none;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  font: 12px/1.5 ui-monospace, Consolas, monospace;
  white-space: pre;
}
#jsonArea.error { border-color: var(--err); }
.json-status { font-size: 11px; padding: 4px 2px; min-height: 16px; }
.json-status.ok { color: var(--ok); }
.json-status.err { color: var(--err); }
.json-btns { display: flex; gap: 6px; padding: 4px 8px 8px; }

/* ---------- timeline ---------- */
#timeline {
  height: 168px;
  background: var(--bg2);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  gap: 4px;
}
#tlHead { display: flex; align-items: center; gap: 10px; }
.tl-label { color: var(--text-dim); font-weight: 600; font-size: 12px; letter-spacing: 1px; }
.tl-info { color: var(--text-dim); font-size: 11px; }
.tl-spacer { flex: 1; }
.tl-opt { display: flex; align-items: center; gap: 4px; color: var(--text-dim); font-size: 12px; cursor: pointer; }
#tlTrackWrap { flex: 1; min-height: 0; position: relative; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); overflow: hidden; }
#tlCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#tlFrames { position: absolute; inset: 0; pointer-events: none; }
#tlFooter { display: flex; align-items: center; gap: 8px; }
#tlSelInfo { min-width: 140px; }

/* ---------- log panel ---------- */
#logPanel {
  position: fixed;
  right: 12px;
  bottom: 182px;
  width: 420px;
  max-height: 320px;
  background: var(--log-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  z-index: 100;
  backdrop-filter: blur(4px);
}
#logPanel.hidden { display: none; }
#logHead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 12px;
}
.spacer { flex: 1; }
.mini-btn {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 11px;
}
.mini-btn:hover { border-color: var(--accent); }
#logBody {
  overflow-y: auto;
  padding: 4px 8px;
  font: 11px/1.5 ui-monospace, Consolas, monospace;
  max-height: 260px;
}
.log-line { display: flex; gap: 6px; padding: 1px 0; word-break: break-all; }
.log-line .lt { color: var(--text-dim); flex-shrink: 0; }
.log-line .lv { flex-shrink: 0; font-weight: 700; width: 44px; }
.log-line.debug .lv { color: var(--text-dim); }
.log-line.info .lv { color: var(--accent); }
.log-line.warn .lv { color: var(--warn); }
.log-line.error .lv { color: var(--err); }
.log-line .lm { color: var(--text); }

.hidden { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  #main { flex-direction: column; }
  #left { width: 100%; max-height: 26vh; border-right: none; border-bottom: 1px solid var(--line); }
  #right { width: 100%; max-height: 22vh; border-left: none; border-top: 1px solid var(--line); }
  #timeline { height: 140px; }
  #logPanel { width: calc(100vw - 24px); bottom: 156px; }
  #hint { display: none; }
}
