:root {
  --bg: #0a0d12;
  --panel: #10151c;
  --panel-2: #151c25;
  --panel-3: #1a2330;
  --line: #202b39;
  --line-soft: #18212c;
  --text: #e8eef6;
  --text-2: #a9b7c7;
  --muted: #6f8093;
  --accent: #37e0cf;
  --accent-dim: rgba(55, 224, 207, 0.14);
  --amber: #f5b544;
  --danger: #ff6b6b;
  --radius: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
}

button { cursor: pointer; border: none; background: none; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #26313f;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #35455a; background-clip: content-box; }

.app {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr) 272px;
  grid-template-rows: 54px minmax(0, 1fr) 30px;
  grid-template-areas:
    "top top top"
    "side stage insp"
    "side status status";
  height: 100vh;
  height: 100dvh;
}

.app.side-collapsed { grid-template-columns: 0 minmax(0, 1fr) 272px; }
.app.insp-collapsed { grid-template-columns: 296px minmax(0, 1fr) 0; }
.app.side-collapsed.insp-collapsed { grid-template-columns: 0 minmax(0, 1fr) 0; }
.app.side-collapsed .sidebar,
.app.insp-collapsed .inspector { display: none; }

/* ── 顶栏 ───────────────────────────────────────── */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px 0 16px;
  background: linear-gradient(180deg, #121922, #0e141b);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, rgba(55,224,207,.18), rgba(55,224,207,.04));
  border: 1px solid rgba(55,224,207,.35);
  box-shadow: 0 0 18px rgba(55,224,207,.12);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-cn { font-size: 14px; font-weight: 600; letter-spacing: .06em; }
.brand-en {
  font-size: 9.5px; letter-spacing: .22em; color: var(--muted);
  text-transform: uppercase; font-family: var(--mono);
}

.topbar-divider { width: 1px; height: 22px; background: var(--line); }

.search {
  flex: 1;
  max-width: 340px;
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color .15s, background .15s;
}
.search:focus-within { border-color: rgba(55,224,207,.45); background: #121a24; }
.search svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
.search input {
  flex: 1; min-width: 0;
  background: none; border: none;
  color: var(--text); font-size: 12.5px;
}
.search input::placeholder { color: var(--muted); }
.search kbd {
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px;
}

.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-2);
  font-size: 12.5px;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { color: var(--text); border-color: #2b3948; background: var(--panel-3); }
.btn svg { width: 14px; height: 14px; }
.btn.primary {
  background: linear-gradient(180deg, #2fd8c8, #1eb3a6);
  border-color: #2fd8c8;
  color: #06211f;
  font-weight: 600;
  box-shadow: 0 2px 14px rgba(55,224,207,.22);
}
.btn.primary:hover { background: linear-gradient(180deg, #43e6d6, #22c1b3); color: #06211f; }
.btn.icon { padding: 0; width: 32px; justify-content: center; }
.btn.toggled { color: var(--accent); border-color: rgba(55,224,207,.45); background: var(--accent-dim); }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 38px;
  min-width: 190px; padding: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 44px rgba(0,0,0,.55);
  display: none;
  z-index: 60;
}
.menu.open { display: block; }
.menu button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border-radius: 7px;
  color: var(--text-2); font-size: 12.5px; text-align: left;
}
.menu button:hover { background: var(--panel-3); color: var(--text); }
.menu button svg { width: 14px; height: 14px; opacity: .8; }
.menu .menu-sep { height: 1px; background: var(--line-soft); margin: 5px 4px; }

/* ── 左侧文件库 ─────────────────────────────────── */
.sidebar {
  grid-area: side;
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.side-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 9px;
}
.side-title { font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--text-2); }
.side-count {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 20px;
}

.filters { display: flex; gap: 6px; padding: 0 14px 10px; }
.chip {
  padding: 4px 10px; border-radius: 20px;
  font-size: 11.5px; color: var(--muted);
  border: 1px solid transparent; background: var(--panel-2);
}
.chip:hover { color: var(--text-2); }
.chip.active { color: var(--accent); background: var(--accent-dim); border-color: rgba(55,224,207,.3); }

.filelist { flex: 1; overflow-y: auto; padding: 0 9px 12px; }

.file-item {
  display: flex; gap: 10px; align-items: center;
  padding: 8px; margin-bottom: 4px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  transition: background .13s, border-color .13s;
}
.file-item:hover { background: rgba(255,255,255,.028); }
.file-item.active {
  background: linear-gradient(90deg, rgba(55,224,207,.13), rgba(55,224,207,.03));
  border-color: rgba(55,224,207,.32);
}
.file-item.active::before {
  content: ""; position: absolute; left: -1px; top: 9px; bottom: 9px;
  width: 2px; border-radius: 2px; background: var(--accent);
}

.thumb {
  width: 54px; height: 54px; flex: none;
  border-radius: 7px;
  background: #0b0f14;
  border: 1px solid var(--line-soft);
  overflow: hidden;
  position: relative;
}
.thumb canvas { width: 100%; height: 100%; display: block; }
.thumb .badge {
  position: absolute; left: 3px; bottom: 3px;
  font-family: var(--mono); font-size: 8px; letter-spacing: .06em;
  padding: 1px 3px; border-radius: 3px;
  background: rgba(0,0,0,.62); color: var(--text-2);
}

.file-meta { min-width: 0; flex: 1; }
.file-name {
  font-size: 12.5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  direction: ltr;
}
.file-sub {
  display: flex; align-items: center; gap: 6px;
  margin-top: 3px;
  font-size: 10.5px; color: var(--muted); font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dot-sep { width: 2px; height: 2px; border-radius: 50%; background: var(--muted); }

.file-del {
  opacity: 0; flex: none;
  width: 24px; height: 24px; border-radius: 6px;
  display: grid; place-items: center;
  color: var(--muted);
}
.file-item:hover .file-del { opacity: 1; }
.file-del:hover { color: var(--danger); background: rgba(255,107,107,.1); }
.file-del svg { width: 13px; height: 13px; }

.side-foot { padding: 10px 14px; border-top: 1px solid var(--line-soft); }
.upload-drop {
  border: 1px dashed #2a3746;
  border-radius: 9px;
  padding: 12px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
  transition: all .15s;
  background: rgba(255,255,255,.012);
}
.upload-drop strong { color: var(--text-2); font-weight: 600; display: block; font-size: 12px; margin-bottom: 1px; }
.upload-drop:hover { border-color: rgba(55,224,207,.4); color: var(--text-2); }

/* ── 画布区 ─────────────────────────────────────── */
.stage {
  grid-area: stage;
  position: relative;
  min-width: 0; min-height: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(55,224,207,.035), transparent 70%),
    var(--bg);
  overflow: hidden;
}
#view { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#view.panning { cursor: grabbing; }
#view.measuring { cursor: crosshair; }

.toolbar {
  position: absolute; top: 12px; left: 12px;
  display: flex; align-items: center; gap: 4px;
  padding: 4px;
  background: rgba(19, 26, 35, .95);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  z-index: 8;
}
.tool {
  width: 30px; height: 30px; border-radius: 7px;
  display: grid; place-items: center; color: var(--text-2);
  transition: all .13s;
}
.tool:hover { background: var(--panel-3); color: var(--text); }
.tool.active { background: var(--accent-dim); color: var(--accent); }
.tool svg { width: 15px; height: 15px; }
.tool-sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.zoom-pill {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  padding: 0 6px; min-width: 44px; text-align: center;
}

.overlay-bar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: none; align-items: center; gap: 10px;
  padding: 7px 12px;
  background: rgba(19, 26, 35, .93);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(55,224,207,.25);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  z-index: 9;
  font-size: 11.5px;
}
.overlay-bar.show { display: flex; }
.overlay-bar label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.overlay-bar select {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 6px; color: var(--text-2); font-size: 11.5px;
  max-width: 190px;
}
.overlay-bar input[type=range] { width: 84px; accent-color: var(--accent); }
.swatch-a { width: 8px; height: 8px; border-radius: 2px; background: #4ea3ff; }
.swatch-b { width: 8px; height: 8px; border-radius: 2px; background: var(--amber); }

.hint {
  position: absolute; top: 12px; right: 12px;
  display: flex; align-items: center; gap: 7px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(19,26,35,.85);
  border: 1px solid var(--line);
  color: var(--muted); font-size: 11px;
  backdrop-filter: blur(10px);
  pointer-events: none;
  z-index: 8;
}
.hint strong { color: var(--text-2); font-weight: 500; }

.zoom-dock {
  position: absolute; right: 12px; bottom: 12px;
  display: flex; flex-direction: column; gap: 2px;
  padding: 4px;
  background: rgba(19, 26, 35, .86);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 10px;
  z-index: 8;
}

.empty-state {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
  z-index: 5;
}
.empty-state.hide { display: none; }
.empty-card {
  text-align: center;
  padding: 38px 46px;
  border-radius: 16px;
  border: 1px dashed #24303f;
  background: rgba(16,21,28,.6);
  max-width: 420px;
}
.empty-card .big {
  width: 46px; height: 46px; margin: 0 auto 14px;
  border-radius: 13px;
  display: grid; place-items: center;
  background: var(--accent-dim);
  border: 1px solid rgba(55,224,207,.3);
  color: var(--accent);
}
.empty-card .big svg { width: 22px; height: 22px; }
.empty-card h2 { margin: 0 0 7px; font-size: 15px; font-weight: 600; letter-spacing: .02em; }
.empty-card p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.8; }
.empty-card .keys { margin-top: 14px; display: flex; gap: 8px; justify-content: center; }
.empty-card .keys span {
  font-size: 10.5px; color: var(--muted); font-family: var(--mono);
  border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px;
}

/* ── 右侧属性 ───────────────────────────────────── */
.inspector {
  grid-area: insp;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  min-height: 0;
}
.insp-section { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); }
.insp-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 600; letter-spacing: .1em;
  color: var(--muted); text-transform: uppercase;
  margin-bottom: 11px;
}
.insp-title .count { font-family: var(--mono); letter-spacing: 0; text-transform: none; }

.info-rows { display: grid; gap: 7px; }
.info-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.info-row .k { color: var(--muted); }
.info-row .v {
  color: var(--text-2); font-family: var(--mono); font-size: 11.5px;
  text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 62%;
}

.layer-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; border-radius: 6px; cursor: pointer;
  font-size: 12px; color: var(--text-2);
}
.layer-row:hover { background: rgba(255,255,255,.03); }
.layer-row.off { opacity: .45; }
.layer-row .sw {
  width: 10px; height: 10px; border-radius: 3px; flex: none;
  box-shadow: 0 0 0 1px rgba(255,255,255,.12) inset;
}
.layer-row .lname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row .lcount { font-family: var(--mono); font-size: 10px; color: var(--muted); }
.layer-check {
  width: 14px; height: 14px; border-radius: 4px; flex: none;
  border: 1px solid #33404f; display: grid; place-items: center;
  background: var(--panel-2);
}
.layer-row:not(.off) .layer-check { background: var(--accent); border-color: var(--accent); color: #06211f; }
.layer-check svg { width: 9px; height: 9px; }

.seg {
  display: flex; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 2px;
}
.seg button {
  flex: 1; padding: 5px 0; border-radius: 5px;
  font-size: 11.5px; color: var(--muted);
}
.seg button.active { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.3); }

.field { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; font-size: 12px; }
.field:last-child { margin-bottom: 0; }
.field > span { color: var(--muted); }
.field select {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 6px; color: var(--text-2); font-size: 11.5px;
}

.switch {
  width: 34px; height: 19px; border-radius: 20px;
  background: #222d3b; border: 1px solid var(--line);
  position: relative; transition: all .18s; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #64758a; transition: all .18s;
}
.switch.on { background: rgba(55,224,207,.22); border-color: rgba(55,224,207,.5); }
.switch.on::after { left: 17px; background: var(--accent); }

.measure-list { display: grid; gap: 5px; }
.measure-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px;
  background: var(--panel-2); font-family: var(--mono); font-size: 11px;
  color: var(--text-2);
}
.measure-item .idx { color: var(--accent); }
.measure-item .val { flex: 1; text-align: right; }
.measure-item .rm { color: var(--muted); width: 16px; height: 16px; display: grid; place-items: center; border-radius: 4px; }
.measure-item .rm:hover { color: var(--danger); background: rgba(255,107,107,.1); }

.empty-note { font-size: 11.5px; color: var(--muted); line-height: 1.7; }

/* ── 状态栏 ─────────────────────────────────────── */
.statusbar {
  grid-area: status;
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: #0d1219;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
}
.statusbar .grow { flex: 1; }
.statusbar .st { display: flex; align-items: center; gap: 5px; }
.statusbar .st b { color: var(--text-2); font-weight: 500; }
.statusbar .pill {
  color: var(--accent); background: var(--accent-dim);
  padding: 1px 6px; border-radius: 4px;
}

/* ── 拖拽遮罩 / 提示 ────────────────────────────── */
.drop-mask {
  position: fixed; inset: 0; z-index: 200;
  display: none; place-items: center;
  background: rgba(6, 10, 14, .82);
  backdrop-filter: blur(4px);
}
.drop-mask.show { display: grid; }
.drop-mask .inner {
  border: 2px dashed rgba(55,224,207,.55);
  border-radius: 18px;
  padding: 60px 90px;
  text-align: center;
  color: var(--accent);
  font-size: 16px;
  background: rgba(55,224,207,.05);
}
.drop-mask .inner small { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }

.toast-wrap {
  position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%);
  display: grid; gap: 8px; z-index: 300; pointer-events: none;
}
.toast {
  padding: 9px 16px; border-radius: 8px;
  background: #1a2431; border: 1px solid var(--line);
  color: var(--text); font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  animation: toastIn .22s ease;
}
.toast.err { border-color: rgba(255,107,107,.45); color: #ffb3b3; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.loading-bar {
  position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform .25s;
  z-index: 30;
}
.loading-bar.active { animation: loading 1.1s ease-in-out infinite; }
@keyframes loading {
  0% { transform: scaleX(0); opacity: 1; }
  70% { transform: scaleX(.85); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}

@media (max-width: 1100px) {
  .app { grid-template-columns: 250px minmax(0, 1fr) 0; }
  .inspector { display: none; }
  .search kbd { display: none; }
}
