* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: #1e1f22;
  color: #e6e6e6;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ---- Hierarchy panel ------------------------------------------------ */
#panel {
  width: 320px;
  min-width: 220px;
  max-width: 50vw;
  display: flex;
  flex-direction: column;
  background: #26282c;
  border-right: 1px solid #3a3d42;
}

#panel-header {
  padding: 12px 14px;
  border-bottom: 1px solid #3a3d42;
}

#panel-header h1 {
  font-size: 14px;
  margin: 0 0 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

#modes, #gizmo-modes, #gizmo-space {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

#modes button, #gizmo-modes button, #gizmo-space button {
  flex: 1;
  padding: 6px 4px;
  font-size: 12px;
  border: 1px solid #45484e;
  border-radius: 5px;
  background: #303338;
  color: #d6d6d6;
  cursor: pointer;
}
#modes button:hover, #gizmo-modes button:hover, #gizmo-space button:hover { background: #3a3e44; }
#modes button.active, #gizmo-modes button.active, #gizmo-space button.active {
  background: #3d6fe0;
  border-color: #3d6fe0;
  color: #fff;
}

#search {
  width: 100%;
  margin-top: 8px;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid #45484e;
  border-radius: 5px;
  background: #1c1d20;
  color: #e6e6e6;
}

#gizmo-size-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 11px;
  color: #9aa0a6;
}
#gizmo-size-row span { flex: 0 0 auto; }
#gizmo-size { flex: 1; min-width: 0; }

#frame-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

#frame-row button {
  flex: 0 0 auto;
  padding: 5px 10px;
  font-size: 12px;
  border: 1px solid #45484e;
  border-radius: 5px;
  background: #303338;
  color: #d6d6d6;
  cursor: pointer;
}
#frame-row button:hover { background: #3a3e44; }
#frame-row button:active { background: #3d6fe0; border-color: #3d6fe0; color: #fff; }
/* Sticky highlight while isolation is active. */
#frame-row button.active { background: #3d6fe0; border-color: #3d6fe0; color: #fff; }

#frame-toggle-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #9aa0a6;
  cursor: pointer;
}
#frame-toggle { margin: 0; cursor: pointer; }

#tree {
  flex: 1;
  overflow: auto;
  padding: 6px 4px 20px;
  font-size: 13px;
  line-height: 1.5;
  user-select: none;
}

.node-children { margin-left: 14px; }
.node-children.collapsed { display: none; }

.node-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 1px 4px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.node-row:hover { background: #33363c; }
.node-row.selected { background: #3d6fe0; color: #fff; }

.caret {
  width: 14px;
  text-align: center;
  color: #9aa0a6;
  flex: 0 0 auto;
}
.caret.leaf { visibility: hidden; }
.node-row.selected .caret { color: #dfe7ff; }

.node-label { overflow: hidden; text-overflow: ellipsis; }
.node-id { color: #7f868d; font-size: 11px; margin-left: 6px; }
.node-row.selected .node-id { color: #cfe0ff; }

.object-title {
  font-weight: 600;
  color: #cfd3d8;
  padding: 6px 4px 2px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ---- Viewport ------------------------------------------------------- */
#viewport {
  flex: 1;
  position: relative;
  background: #111214;
}

#unity-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #b7bdc4;
  pointer-events: none;
}
#loading.hidden { display: none; }

#bar {
  width: 220px;
  height: 6px;
  background: #33363c;
  border-radius: 3px;
  overflow: hidden;
}
#bar-fill {
  height: 100%;
  width: 0%;
  background: #3d6fe0;
  transition: width 0.2s;
}

#status {
  position: absolute;
  bottom: 8px;
  left: 10px;
  font-size: 11px;
  color: #6f767d;
}

/* Always-visible controls legend, pinned bottom-right of the viewport. pointer-events:none so
   it never intercepts a camera drag. */
#controls-help {
  position: absolute;
  right: 10px;
  bottom: 8px;
  padding: 8px 10px;
  background: rgba(20, 21, 23, 0.6);
  border: 1px solid #3a3d42;
  border-radius: 6px;
  color: #b7bdc4;
  pointer-events: none;
  max-width: 260px;
}
.ch-title {
  font-weight: 600;
  color: #cfd3d8;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 10px;
}
.ch-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  line-height: 1.7;
  font-size: 11px;
}
.ch-row kbd {
  flex: 0 0 auto;
  min-width: 66px;
  font-family: inherit;
  font-size: 10px;
  color: #e6e6e6;
  background: #303338;
  border: 1px solid #45484e;
  border-radius: 4px;
  padding: 1px 5px;
  text-align: center;
}
.ch-row span { color: #9aa0a6; }

/* ---- Metadata panel (right side) ------------------------------------ */
#meta-panel {
  /* Pinned width: property values can be huge, so the content must never size the panel. */
  flex: 0 0 340px;
  width: 340px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  background: #26282c;
  border-left: 1px solid #3a3d42;
  overflow: hidden;
}

#meta-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #3a3d42;
}

#meta-header h1 {
  font-size: 14px;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.3px;
}

#meta-status {
  font-size: 11px;
  color: #7f868d;
}

#meta-body {
  flex: 1;
  overflow: auto;
  padding: 10px 12px 20px;
  font-size: 12px;
}

.meta-empty {
  color: #7f868d;
  padding: 4px 2px;
}

/* Selected-node summary block above the property table. */
.meta-node-name {
  font-weight: 600;
  color: #e6e6e6;
  word-break: break-all;
  line-height: 1.4;
}

.meta-node-sub {
  color: #9aa0a6;
  font-size: 11px;
  margin: 2px 0 10px;
}

.meta-section-title {
  font-weight: 600;
  color: #cfd3d8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 12px 0 4px;
}

#meta-body table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

#meta-body tr { border-bottom: 1px solid #2e3136; }
#meta-body tr:last-child { border-bottom: none; }

#meta-body th {
  width: 42%;
  text-align: left;
  vertical-align: top;
  font-weight: 500;
  color: #9aa0a6;
  padding: 4px 8px 4px 2px;
  word-break: break-all;
  line-height: 1.4;
}

#meta-body td {
  vertical-align: top;
  color: #e6e6e6;
  padding: 4px 2px;
  word-break: break-word;
  line-height: 1.4;
}

/* Long values are clamped; click to expand/collapse. The clamp lives on an inner div so the
   td keeps its table-cell display (a non-cell td falls out of the fixed table layout). */
#meta-body .meta-val.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
#meta-body .meta-val.clamp.expanded {
  display: block;
  -webkit-line-clamp: unset;
}
