.mesh-editor {
  --me-bg: #f4f6f8;
  --me-panel: #ffffff;
  --me-border: #d8dee6;
  --me-accent: #1a5f8a;
  --me-text: #1f2933;
  --me-muted: #5f6b7a;
  --me-view: #1c242c;
  --me-ok: #0f7b3a;
  --me-bad: #b42318;
}

.mesh-editor__related {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.85rem;
  align-items: center;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.mesh-editor__related a {
  color: var(--me-accent);
}

.mesh-editor__form {
  margin: 0;
}

.mesh-editor__topbar,
.mesh-editor__bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  background: var(--me-panel);
  border: 1px solid var(--me-border);
  border-radius: 8px;
}

.mesh-editor__topbar {
  margin-bottom: 0.75rem;
}

.mesh-editor__bottom {
  margin-top: 0.75rem;
}

.mesh-editor__modes,
.mesh-editor__path,
.mesh-editor__history,
.mesh-editor__export,
.mesh-editor__file-row,
.mesh-editor__units,
.mesh-editor__tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.mesh-editor__path-sep {
  color: var(--me-muted);
  font-size: 0.85rem;
}

.mesh-editor__eng-toggle {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--me-text);
  margin-left: auto;
}

.mesh-editor__fs-btn.rlt-tool-fs-btn {
  margin-left: 0.5rem;
  flex: 0 0 auto;
}

.mesh-editor.is-engineering .mesh-editor__eng-toggle {
  color: var(--me-accent);
}

.mesh-editor__path .btn {
  font-size: 0.85rem;
}

.mesh-editor__topbar--file {
  margin-top: -0.35rem;
}

.mesh-editor__path .btn,
.mesh-editor__topbar--file .btn {
  text-decoration: none;
}

.mesh-editor__path .btn:hover,
.mesh-editor__path .btn:focus-visible,
.mesh-editor__topbar--file .btn:hover,
.mesh-editor__topbar--file .btn:focus-visible {
  text-decoration: underline;
}

.mesh-editor__topbar--file .mesh-editor__units label:hover {
  text-decoration: underline;
  cursor: pointer;
}

.mesh-editor:not(.is-engineering) [data-eng="1"] {
  display: none !important;
}

.mesh-editor:not(.is-paint) [data-paint-only] {
  display: none !important;
}

.mesh-editor__color {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin: 0.4rem 0;
}

.mesh-editor__color input[type="color"] {
  width: 2.4rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid var(--me-border);
  background: transparent;
}

.mesh-editor__group select {
  width: 100%;
  margin-top: 0.25rem;
}

.mesh-editor__related--stack {
  flex-direction: column;
  align-items: flex-start;
  margin-top: 0.6rem;
}

.mesh-editor__lite {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: var(--me-text);
}

.mesh-editor__missions h3 {
  margin: 0.4rem 0 0.55rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--me-muted);
}

.mesh-editor__mission {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0 0 0.4rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--me-border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.mesh-editor__mission span {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--me-text);
}

.mesh-editor__mission em {
  display: block;
  font-style: normal;
  font-size: 0.78rem;
  color: var(--me-muted);
  margin-top: 0.15rem;
}

.mesh-editor__mission.is-ok {
  border-color: #abefc6;
  background: #f0fdf4;
}

.mesh-editor__mission.is-fail {
  border-color: #fecdca;
  background: #fef3f2;
}

.mesh-editor__modes .btn.is-active,
.mesh-editor__path .btn.is-active,
.mesh-editor__tool.is-active {
  background: var(--me-accent);
  color: #fff;
  border-color: var(--me-accent);
}

.mesh-editor__file-name,
.mesh-editor__formats,
.mesh-editor__units-label,
.mesh-editor__hint,
.mesh-editor__export-hint {
  font-size: 0.85rem;
  color: var(--me-muted);
}

.mesh-editor__units label {
  font-size: 0.85rem;
  color: var(--me-text);
  margin: 0 0.15rem;
}

.mesh-editor__layout {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) minmax(
      200px,
      240px
    );
  gap: 0.75rem;
  min-height: 560px;
}

.mesh-editor__panel {
  background: var(--me-panel);
  border: 1px solid var(--me-border);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  overflow: auto;
  max-height: calc(100vh - 220px);
}

.mesh-editor__panel-head,
.mesh-editor__group h3,
.mesh-editor__stats h3 {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--me-muted);
}

.mesh-editor__group {
  margin-bottom: 1rem;
}

.mesh-editor__group[hidden] {
  display: none !important;
}

.mesh-editor__tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.mesh-editor__tool,
.mesh-editor__block-btn {
  width: 100%;
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
}

.mesh-editor__slider {
  display: block;
  margin: 0.45rem 0;
  font-size: 0.85rem;
  color: var(--me-text);
}

.mesh-editor__slider span {
  display: flex;
  justify-content: space-between;
}

.mesh-editor__slider input {
  width: 100%;
}

.mesh-editor__check {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.85rem;
  margin: 0.4rem 0;
}

.mesh-editor__viewport-wrap {
  min-height: 520px;
  height: calc(100vh - 280px);
  height: calc(100dvh - 280px);
  background: var(--me-view);
  border: 1px solid var(--me-border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.mesh-editor__viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 520px;
}

.mesh-editor__viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.mesh-editor__overlay,
.mesh-editor__loading {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.55rem 0.85rem;
  background: rgba(28, 36, 44, 0.82);
  color: #eef2f6;
  font-size: 0.85rem;
  pointer-events: none;
  z-index: 2;
}

.mesh-editor__loading {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  bottom: auto;
}

.mesh-editor__loading[hidden],
.mesh-editor__overlay[hidden] {
  display: none !important;
}

.mesh-editor__stats section {
  margin-bottom: 0.85rem;
}

.mesh-editor__stats p {
  margin: 0.2rem 0;
  font-size: 0.9rem;
  color: var(--me-text);
}

.mesh-editor__stats strong {
  float: right;
  font-weight: 600;
}

.mesh-editor__result {
  margin-top: 0.85rem;
}

.mesh-editor__notice {
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--me-border);
  background: #fff;
  font-size: 0.9rem;
}

.mesh-editor__notice--ok {
  border-color: #abefc6;
  background: #f0fdf4;
  color: var(--me-ok);
}

.mesh-editor__notice--warn {
  border-color: #fecdca;
  background: #fef3f2;
  color: var(--me-bad);
}

@media (max-width: 1100px) {
  .mesh-editor__layout {
    grid-template-columns: 1fr;
  }

  .mesh-editor__panel {
    max-height: none;
  }

  .mesh-editor__viewport-wrap {
    min-height: 380px;
    height: 55vh;
  }
}

@media (max-width: 768px) {
  .mesh-editor__topbar,
  .mesh-editor__bottom {
    align-items: stretch;
    flex-direction: column;
  }

  .mesh-editor__path-sep {
    display: none;
  }

  .mesh-editor__eng-toggle {
    margin-left: 0;
  }
}
