:root {
  --mesh-bg: #080a10;
  --mesh-surface: #0e1119;
  --mesh-surface-raised: #141822;
  --mesh-border: #242a37;
  --mesh-border-soft: #1b202b;
  --mesh-text: #eef1f7;
  --mesh-muted: #8992a3;
  --mesh-accent: #7c6cff;
  --mesh-accent-strong: #967cff;
  --mesh-green: #35d49a;
  --mesh-amber: #f2ad48;
  --mesh-red: #ef6473;
}

.mesh-app,
.mesh-app * {
  box-sizing: border-box;
}

.mesh-app {
  height: calc(100dvh - var(--site-header-h, 0px));
  min-height: 600px;
  overflow: hidden;
  background: var(--mesh-bg);
  color: var(--mesh-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mesh-app button,
.mesh-app a,
.mesh-app input,
.mesh-app select {
  font: inherit;
}

.mesh-app-topbar {
  height: 48px;
  display: grid;
  grid-template-columns: 280px minmax(250px, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0 0.85rem;
  background: #0b0e15;
  border-bottom: 1px solid var(--mesh-border);
}

.mesh-app-brand,
.mesh-app-menubar,
.mesh-app-readiness,
.mesh-app-sidebar-actions,
.mesh-app-toolbar,
.mesh-app-toolbar-group,
.mesh-app-export-actions {
  display: flex;
  align-items: center;
}

.mesh-app-brand {
  gap: 0.45rem;
  white-space: nowrap;
}

.mesh-app-brand-mark {
  width: 27px;
  height: 27px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #3a4150;
  border-radius: 7px;
  background: linear-gradient(145deg, #1f2532, #10131a);
  color: #c8c6ff;
}

.mesh-app-brand strong {
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

.mesh-app-brand > span:last-child {
  color: var(--mesh-muted);
  font-size: 0.78rem;
}

.mesh-app-menubar {
  align-self: stretch;
  gap: 0.1rem;
}

.mesh-app-menubar button,
.mesh-app-menubar a,
.mesh-app-sidebar-actions button,
.mesh-app-tree-head button,
.mesh-app-toolbar button {
  border: 0;
  background: transparent;
  color: #abb3c2;
  text-decoration: none;
}

.mesh-app-menubar button,
.mesh-app-menubar a {
  height: 100%;
  padding: 0 0.7rem;
  display: inline-flex;
  align-items: center;
  font-size: 0.74rem;
}

.mesh-app-menubar button:hover,
.mesh-app-menubar a:hover,
.mesh-app-sidebar-actions button:hover,
.mesh-app-tree-head button:hover,
.mesh-app-toolbar button:hover {
  color: #fff;
  background: #1b202b;
}

.mesh-app-readiness {
  gap: 0.4rem;
}

.mesh-app-readiness-badge {
  min-width: 29px;
  height: 26px;
  padding: 0 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--mesh-border);
  border-radius: 5px;
  background: #11151e;
  color: var(--mesh-muted);
  font-size: 0.67rem;
  white-space: nowrap;
}

.mesh-app-readiness-badge i {
  font-size: 0.46rem;
}

.mesh-app-readiness-badge.is-ready { color: var(--mesh-green); border-color: color-mix(in srgb, var(--mesh-green) 42%, var(--mesh-border)); }
.mesh-app-readiness-badge.is-warning { color: var(--mesh-amber); border-color: color-mix(in srgb, var(--mesh-amber) 42%, var(--mesh-border)); }
.mesh-app-readiness-badge.is-blocked { color: var(--mesh-red); border-color: color-mix(in srgb, var(--mesh-red) 42%, var(--mesh-border)); }


.mesh-app-workspace {
  height: calc(100% - 48px);
  min-height: 552px;
  display: grid;
  grid-template-columns: 280px minmax(420px, 1fr) 320px;
  overflow: hidden;
}

.mesh-app-sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--mesh-surface);
  overflow: hidden;
}

.mesh-app-sidebar-left { border-right: 1px solid var(--mesh-border); }
.mesh-app-sidebar-right { border-left: 1px solid var(--mesh-border); }

.mesh-app-sidebar-head {
  min-height: 62px;
  padding: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--mesh-border-soft);
}

.mesh-app-sidebar-head strong,
.mesh-app-sidebar-head small {
  display: block;
}

.mesh-app-sidebar-head strong { font-size: 0.78rem; }
.mesh-app-sidebar-head small { margin-top: 0.15rem; color: var(--mesh-muted); font-size: 0.63rem; }
.mesh-app-sidebar-actions { gap: 0.2rem; }
.mesh-app-sidebar-actions button,
.mesh-app-tree-head button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 5px;
}

.mesh-app-current-file,
.mesh-app-saved-file {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--mesh-text);
}

.mesh-app-current-file {
  margin: 0.65rem;
  width: calc(100% - 1.3rem);
  padding: 0.6rem;
  border: 1px solid color-mix(in srgb, var(--mesh-accent) 55%, var(--mesh-border));
  border-radius: 6px;
  background: color-mix(in srgb, var(--mesh-accent) 10%, var(--mesh-surface));
}

.mesh-app-current-file > i { color: #a69cff; }
.mesh-app-current-file span,
.mesh-app-saved-file span { min-width: 0; display: block; }
.mesh-app-current-file strong,
.mesh-app-current-file small,
.mesh-app-saved-file strong,
.mesh-app-saved-file small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mesh-app-current-file strong,
.mesh-app-saved-file strong { font-size: 0.7rem; font-weight: 600; }
.mesh-app-current-file small,
.mesh-app-saved-file small { margin-top: 0.12rem; color: var(--mesh-muted); font-size: 0.59rem; }

.mesh-app-file-section {
  max-height: 180px;
  padding: 0 0.65rem 0.65rem;
  border-bottom: 1px solid var(--mesh-border-soft);
  overflow: auto;
}

.mesh-app-section-label {
  color: #697386;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mesh-app-saved-files { margin-top: 0.4rem; }
.mesh-app-saved-file {
  min-height: 54px;
  padding: 0.45rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  text-align: left;
}
.mesh-app-saved-file:hover {
  border-color: #303746;
  background: #171c26;
}
.mesh-app-file-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid !important;
  place-items: center;
  align-content: center;
  border: 1px solid #343b4a;
  border-radius: 7px;
  background: linear-gradient(145deg, #202634, #121721);
  color: #a9a2ff;
}
.mesh-app-file-icon i { font-size: 0.9rem; line-height: 1; }
.mesh-app-file-icon small {
  margin-top: 0.15rem !important;
  color: #8e96a6 !important;
  font-size: 0.43rem !important;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.mesh-app-file-empty { display: block; padding: 0.55rem; color: var(--mesh-muted); font-size: 0.66rem; }

.mesh-app-session-note {
  margin: 0.65rem;
  padding: 0.65rem;
  border: 1px solid #2d3544;
  border-radius: 6px;
  background: #131821;
  font-size: 0.67rem;
}
.mesh-app-session-note strong,
.mesh-app-session-note span { display: block; }
.mesh-app-session-note span { margin-top: 0.25rem; color: var(--mesh-muted); line-height: 1.45; }
.mesh-app-session-note a { color: #b0a8ff; }

.mesh-app-tree-section {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.mesh-app-tree-head {
  min-height: 43px;
  padding: 0 0.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--mesh-border-soft);
}
.mesh-app-tree-head small { display: block; margin-top: 0.1rem; color: var(--mesh-muted); font-size: 0.57rem; }
.mesh-app-tree { min-height: 0; flex: 1; overflow: auto; padding: 0.35rem; }
.mesh-hierarchy-row {
  margin: 0;
  padding: 0.42rem 0.48rem;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #b7bfcc;
  font-size: 0.67rem;
  cursor: pointer;
}
.mesh-hierarchy-row:hover { background: #171c26; }
.mesh-hierarchy-row.is-selected { border-color: #594dc1; background: rgba(124, 108, 255, 0.13); color: #fff; }
.mesh-hierarchy-row input { margin-top: 0.12rem; accent-color: var(--mesh-accent); }
.mesh-hierarchy-row .text-muted { color: #727c8e !important; font-size: 0.58rem !important; }

.mesh-app-main {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #090c12;
}

.mesh-app-toolbar {
  position: absolute;
  top: 0.65rem;
  left: 50%;
  z-index: 5;
  width: calc(100% - 1.3rem);
  transform: translateX(-50%);
  justify-content: center;
  gap: 0.55rem;
  padding: 0.35rem;
  border: 1px solid rgba(45, 52, 67, 0.9);
  border-radius: 6px;
  background: rgba(13, 16, 23, 0.88);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}
.mesh-app-toolbar-group {
  height: 30px;
  padding: 0.15rem;
  border: 1px solid var(--mesh-border);
  border-radius: 5px;
  background: #121620;
}
.mesh-app-toolbar button {
  height: 24px;
  min-width: 27px;
  padding: 0 0.42rem;
  border-radius: 3px;
  font-size: 0.72rem;
}
.mesh-app-toolbar button.active { color: #fff; background: #343b4a; }
.mesh-app-toolbar .mesh-app-rig-button {
  margin-left: auto;
  margin-right: 0.2rem;
  padding: 0 0.7rem;
  border: 1px solid #4f48a6;
  color: #cbc6ff;
  background: rgba(124, 108, 255, 0.12);
}

.mesh-app-canvas {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, rgba(69, 77, 98, 0.2), transparent 45%),
    linear-gradient(#0a0d14, #080a10);
}
.mesh-app-canvas canvas { width: 100% !important; height: 100% !important; display: block; }
.mesh-app-empty-state {
  box-sizing: border-box;
  min-height: 100%;
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background: radial-gradient(circle at 50% 45%, rgba(41, 47, 61, 0.35), transparent 38%);
}
.mesh-app-empty-state[hidden] { display: none; }
.mesh-app-empty-icon {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin-bottom: 1rem;
  border: 1px solid #303746;
  border-radius: 16px;
  background: linear-gradient(145deg, #171c26, #0c0f16);
  color: #a49cff;
  font-size: 2rem;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.3);
}
.mesh-app-empty-state h1 { margin: 0; font-size: 1.05rem; }
.mesh-app-empty-state p { max-width: 420px; margin: 0.5rem 0 1rem; color: var(--mesh-muted); font-size: 0.75rem; }
.mesh-app-empty-state small { margin-top: 0.7rem; color: #667084; font-size: 0.61rem; }

.mesh-editor-stats-overlay {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 3;
  padding: 0.38rem 0.55rem;
  border: 1px solid rgba(62, 70, 86, 0.8);
  border-radius: 5px;
  background: rgba(8, 11, 17, 0.78);
  color: #b5bdca;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.58rem;
  pointer-events: none;
}

.mesh-app-statusbar {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4;
  min-width: 0;
  height: 27px;
  padding: 0 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--mesh-border);
  background: rgba(12, 15, 22, 0.9);
  color: #798396;
  font-size: 0.58rem;
  backdrop-filter: blur(8px);
}
 .mesh-app-main:not(.has-model) .mesh-app-statusbar {
  top: calc(50% + 142px);
  right: 2rem;
  bottom: auto;
  left: 2rem;
  justify-content: center;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}
.mesh-app-main:not(.has-model) .mesh-app-statusbar strong { display: none; }
.mesh-app-statusbar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mesh-app-statusbar strong { color: #a5adbb; font-weight: 500; white-space: nowrap; }

.mesh-app-inspector-tabs {
  height: 43px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--mesh-border);
}
.mesh-app-inspector-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--mesh-muted);
  font-size: 0.67rem;
}
.mesh-app-inspector-tabs button:hover { color: #fff; }
.mesh-app-inspector-tabs button.active { border-bottom-color: var(--mesh-accent); color: #fff; background: rgba(124, 108, 255, 0.06); }
.mesh-app-inspector-scroll { min-height: 0; flex: 1; overflow: auto; }
.mesh-app-inspector-panel[hidden] { display: none; }

.mesh-app-selection,
.mesh-app-property-section {
  margin: 0;
  padding: 0.8rem;
  border-bottom: 1px solid var(--mesh-border-soft);
}
.mesh-app-selection { background: #0c1017; }
.mesh-app-selection.is-active { background: rgba(124, 108, 255, 0.075); }
.mesh-app-selection-heading { display: flex; align-items: center; justify-content: space-between; }
.mesh-app-selection-heading strong { font-size: 0.74rem; }
.mesh-app-selection-heading i { color: #7166cf; }
.mesh-app-selection p,
.mesh-app-muted { margin: 0.25rem 0 0; color: var(--mesh-muted); font-size: 0.63rem; line-height: 1.45; }
.mesh-app-property-section h2 { margin: 0 0 0.7rem; font-size: 0.7rem; font-weight: 700; }
.mesh-app-property-section > label:not(.mesh-app-switch) { margin-bottom: 0.35rem; color: var(--mesh-muted); font-size: 0.61rem; }
.mesh-app-vector-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
.mesh-app-vector-inputs span {
  height: 29px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding-left: 0.42rem;
  border: 1px solid var(--mesh-border);
  border-radius: 4px;
  color: #7d8799;
  font-size: 0.58rem;
}
.mesh-app-vector-inputs input {
  min-width: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: #dce1e9;
  outline: 0;
  font-size: 0.66rem;
}
.mesh-app-switch {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #c1c8d3;
  font-size: 0.66rem;
  cursor: pointer;
}
.mesh-app-switch input { accent-color: var(--mesh-accent); }
.mesh-app-range-head { display: flex; justify-content: space-between; color: var(--mesh-muted); font-size: 0.59rem; }
.mesh-app-range-head output { color: #cbc6ff; }
.mesh-app-property-section input[type="range"] { width: 100%; accent-color: var(--mesh-accent); }
.mesh-app-history-head { display: flex; align-items: center; justify-content: space-between; }
.mesh-editor-history-entry { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.45rem 0; border-bottom: 1px solid var(--mesh-border-soft); font-size: 0.61rem; }
.mesh-editor-history-current { color: #d8d4ff; }
.mesh-editor-history-time { color: var(--mesh-muted); white-space: nowrap; }

.mesh-app-export-actions {
  min-height: 56px;
  justify-content: flex-end;
  gap: 0.45rem;
  padding: 0.65rem;
  border-top: 1px solid var(--mesh-border);
  background: #0b0e15;
}
.mesh-app-export-actions .btn { font-size: 0.67rem; }

.mesh-app-modal {
  border: 1px solid #303746;
  background: #11151e;
  color: var(--mesh-text);
}
.mesh-app-modal .modal-header,
.mesh-app-modal .modal-footer { border-color: var(--mesh-border); }
.mesh-app-modal .modal-header p { margin: 0.15rem 0 0; color: var(--mesh-muted); font-size: 0.68rem; }
.mesh-app-export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.mesh-app-export-grid button {
  min-height: 72px;
  padding: 0.75rem;
  border: 1px solid var(--mesh-border);
  border-radius: 6px;
  background: #171c26;
  color: var(--mesh-text);
  text-align: left;
}
.mesh-app-export-grid button:hover { border-color: #5b50b9; background: #1d2230; }
.mesh-app-export-grid strong,
.mesh-app-export-grid span { display: block; }
.mesh-app-export-grid strong { font-size: 0.75rem; }
.mesh-app-export-grid span { margin-top: 0.2rem; color: var(--mesh-muted); font-size: 0.62rem; }
.mesh-app-rig-intro { display: flex; align-items: flex-start; gap: 0.8rem; padding: 0.8rem; margin-bottom: 0.8rem; border: 1px solid #3b356f; border-radius: 6px; background: rgba(124, 108, 255, 0.08); }
.mesh-app-rig-intro > i { color: #aaa2ff; font-size: 1.5rem; }
.mesh-app-rig-intro p { margin: 0.25rem 0 0; color: var(--mesh-muted); font-size: 0.7rem; }
.mesh-app-rig-progress { display: flex; align-items: center; gap: 0.55rem; padding: 0.65rem; color: #bcc4d2; font-size: 0.68rem; }
.mesh-app-rig-frame { height: min(68dvh, 720px); border: 1px solid var(--mesh-border); border-radius: 6px; overflow: hidden; background: #090b11; }
.mesh-app-rig-frame iframe { width: 100%; height: 100%; border: 0; }

/* Quest compatibility checks panel */
.mesh-checks-heading { margin: 0.6rem 0 0.4rem; font-size: 0.7rem; font-weight: 700; color: var(--mesh-text); }
.mesh-checks-viewpoint { color: var(--mesh-muted); }
.mesh-checks-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-bottom: 0.6rem; }
.mesh-check-metric { padding: 0.45rem; border: 1px solid var(--mesh-border-soft); border-radius: 5px; background: var(--mesh-surface); }
.mesh-check-metric-top { display: flex; align-items: center; justify-content: space-between; }
.mesh-check-metric-label { font-size: 0.62rem; color: var(--mesh-muted); }
.mesh-check-metric-status { font-size: 0.55rem; font-weight: 700; padding: 0.05rem 0.3rem; border-radius: 3px; }
.mesh-check-metric.is-pass .mesh-check-metric-status { color: var(--mesh-green); background: color-mix(in srgb, var(--mesh-green) 18%, transparent); }
.mesh-check-metric.is-warn .mesh-check-metric-status { color: var(--mesh-amber); background: color-mix(in srgb, var(--mesh-amber) 18%, transparent); }
.mesh-check-metric.is-fail .mesh-check-metric-status { color: var(--mesh-red); background: color-mix(in srgb, var(--mesh-red) 18%, transparent); }
.mesh-check-metric-value { margin-top: 0.2rem; font-size: 0.66rem; font-weight: 600; }
.mesh-check-metric-bar { height: 3px; margin-top: 0.3rem; border-radius: 2px; background: var(--mesh-border); overflow: hidden; }
.mesh-check-metric-fill { height: 100%; border-radius: 2px; }
.mesh-check-metric.is-pass .mesh-check-metric-fill { background: var(--mesh-green); }
.mesh-check-metric.is-warn .mesh-check-metric-fill { background: var(--mesh-amber); }
.mesh-check-metric.is-fail .mesh-check-metric-fill { background: var(--mesh-red); }
.mesh-check-metric-hint { margin-top: 0.25rem; font-size: 0.56rem; color: var(--mesh-muted); line-height: 1.35; }

.mesh-check-issue { padding: 0.55rem; margin-bottom: 0; border: 1px solid var(--mesh-border-soft); border-radius: 5px; background: var(--mesh-surface); }
.mesh-check-issue.is-blocker { border-left: 3px solid var(--mesh-red); }
.mesh-check-issue.is-warning { border-left: 3px solid var(--mesh-amber); }
.mesh-check-issue.is-info { border-left: 3px solid var(--mesh-muted); }
.mesh-check-issue-head { display: flex; align-items: center; gap: 0.4rem; }
.mesh-check-issue-head i { font-size: 0.7rem; }
.mesh-check-issue.is-blocker .mesh-check-issue-head i { color: var(--mesh-red); }
.mesh-check-issue.is-warning .mesh-check-issue-head i { color: var(--mesh-amber); }
.mesh-check-issue.is-info .mesh-check-issue-head i { color: var(--mesh-muted); }
.mesh-check-issue-head strong { font-size: 0.68rem; }
.mesh-check-issue-detail { margin-top: 0.25rem; color: var(--mesh-muted); font-size: 0.61rem; line-height: 1.45; }
.mesh-check-issue-affected { margin: 0.3rem 0 0; padding-left: 1rem; list-style: none; }
.mesh-check-issue-affected li { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.59rem; color: var(--mesh-text); padding: 0.1rem 0; }
.mesh-check-issue-affected-value { color: var(--mesh-muted); white-space: nowrap; }
.mesh-check-issue-remediation { margin-top: 0.4rem; padding-top: 0.4rem; border-top: 1px solid var(--mesh-border-soft); }
.mesh-check-issue-steps { margin: 0; padding-left: 1.1rem; font-size: 0.6rem; color: var(--mesh-muted); line-height: 1.5; }
.mesh-check-issue-steps li { margin-bottom: 0.15rem; }
.mesh-check-issue-fix { margin-top: 0.5rem; }
.mesh-app-texture-compress { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--mesh-border-soft); }

@media (max-width: 1100px) {
  .mesh-app-topbar { grid-template-columns: 220px 1fr auto; }
  .mesh-app-readiness { display: none; }
  .mesh-app-workspace { grid-template-columns: 230px minmax(360px, 1fr) 280px; }
}

@media (max-width: 820px) {
  .mesh-app { height: auto; min-height: 100dvh; overflow: auto; }
  .mesh-app-topbar { position: sticky; top: 0; z-index: 20; grid-template-columns: 1fr auto; }
  .mesh-app-menubar { display: none; }
  .mesh-app-workspace { height: auto; min-height: calc(100dvh - 48px); grid-template-columns: 1fr; grid-template-rows: auto 70dvh auto; overflow: visible; }
  .mesh-app-sidebar-left { max-height: 330px; border-right: 0; border-bottom: 1px solid var(--mesh-border); }
  .mesh-app-sidebar-right { max-height: none; border-left: 0; border-top: 1px solid var(--mesh-border); }
  .mesh-app-main { min-height: 70dvh; }
}
