:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev-2: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #3b82f6;
  --green: #10b981;
  --red: #ef4444;
  --mono: ui-monospace, "SF Mono", Consolas, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.mono { font-family: var(--mono); }
.muted { color: var(--text-dim); }
.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.topbar h1 { margin: 0; font-size: 18px; }
.topbar h1 span { color: var(--accent); }
.tagline { color: var(--text-dim); font-size: 12px; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: 0;
}

.left {
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.right {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px;
  gap: 12px;
  overflow-y: auto;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.drag {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.08);
}
.dropzone p { margin: 4px 0; }

.btn {
  display: inline-block;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover { border-color: var(--text-dim); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-green { background: var(--green); border-color: var(--green); color: #04150e; font-weight: 600; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.pkg-info { margin-top: 14px; padding: 12px; background: var(--bg-elev); border-radius: var(--radius); }
.pkg-name { font-size: 13px; word-break: break-all; }
.pkg-stats { font-size: 12px; margin: 6px 0 10px; }

.block { margin-top: 16px; }
.block h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); }

.model-list { list-style: none; margin: 0; padding: 0; }
.model-list li {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
}
.model-list li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-list input[type="checkbox"] { flex: none; accent-color: var(--accent); cursor: pointer; margin: 0; }
.sel-controls { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.btn, .tree .row { user-select: none; -webkit-user-select: none; }
.model-list li:hover { border-color: var(--accent); }
.model-list li.active { border-color: var(--accent); background: rgba(59, 130, 246, 0.1); }
.model-list .size { color: var(--text-dim); font-size: 12px; white-space: nowrap; }

.tree { font-size: 12px; line-height: 1.7; }
.tree ul { list-style: none; margin: 0; padding-left: 16px; }
.tree .dir > .row { color: var(--text-dim); }
.tree .row { display: flex; gap: 6px; align-items: center; cursor: pointer; border-radius: 4px; padding: 0 4px; }
.tree .row:hover { background: var(--bg-elev-2); }
.tree .dl { color: var(--accent); text-decoration: none; margin-left: auto; opacity: 0; }
.tree .row:hover .dl { opacity: 1; }
.tree .kind { font-size: 10px; padding: 0 5px; border-radius: 4px; background: var(--bg-elev-2); color: var(--text-dim); }
.tree .kind.model { color: #7ee2bd; }
.tree .kind.image { color: #f3c26b; }
.tree .kind.material { color: #a5b4fc; }

.viewer-wrap {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 55vh;
  min-height: 320px;
  overflow: hidden;
}
#viewer { width: 100%; height: 100%; display: block; }
.viewer-empty, .viewer-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  background: rgba(13, 17, 23, 0.75);
}

.view-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 8px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  user-select: none;
}
.view-toggles .toggle { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }
.view-toggles input { accent-color: var(--accent, #58a6ff); cursor: pointer; }

.warn-box {
  padding: 10px 12px;
  background: rgba(210, 153, 34, 0.08);
  border: 1px solid rgba(210, 153, 34, 0.45);
  border-radius: var(--radius);
}
.warn-box h3 { margin: 0 0 6px; font-size: 12px; color: #d29922; text-transform: uppercase; }
.warn-box ul { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.55; }
.warn-box li { margin-bottom: 4px; }
.warn-box .badge {
  display: inline-block;
  font-size: 10px;
  padding: 0 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: 1px;
  white-space: nowrap;
}
.warn-box .badge.ok { background: rgba(63, 185, 80, 0.15); color: #3fb950; border: 1px solid rgba(63, 185, 80, 0.4); }
.warn-box .badge.lost { background: rgba(248, 81, 73, 0.12); color: #f85149; border: 1px solid rgba(248, 81, 73, 0.4); }

.export-panel {
  padding: 14px 16px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: var(--radius);
}
.export-panel h3 {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--green);
  text-transform: none;
  letter-spacing: 0;
}
.export-hint { margin: 0 0 12px; font-size: 12px; }
.export-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.export-actions .btn-green { flex: 1 1 220px; text-align: center; }
.export-actions .btn-green:disabled { opacity: 0.45; cursor: not-allowed; }
.mat-report { font-size: 12px; margin-top: 10px; min-height: 1.2em; }

.tree-advanced {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.tree-advanced-hint { display: block; font-size: 11px; margin-top: 6px; line-height: 1.4; }

.export-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.log-block h3 { margin: 0 0 6px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; }
.log {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .left { border-right: none; border-bottom: 1px solid var(--border); }
}
