:root {
  --bg: #edf2f7;
  --panel: rgba(255, 255, 255, 0.94);
  --ink: #152232;
  --muted: #5e6d7d;
  --line: #d8e1eb;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --danger: #b53e52;
  --shadow: 0 18px 42px rgba(21, 34, 50, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
}

body {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 24%),
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.12), transparent 20%),
    linear-gradient(180deg, #f7fbfd 0%, #ebf1f7 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1500px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 14px 0 24px;
}

.topbar,
.panel {
  background: var(--panel);
  border: 1px solid rgba(216, 225, 235, 0.96);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 20px 24px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.8rem, 3vw, 2.9rem);
}

h2 {
  margin-bottom: 12px;
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 0.98rem;
}

.subtitle,
.hint,
.selection-label,
.field span,
.object-meta,
.shortcut-list {
  color: var(--muted);
  line-height: 1.5;
}

.workspace {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 320px;
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.panel-block + .panel-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.topbar-actions,
.stack-buttons,
.mesh-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mesh-grid {
  display: grid;
  grid-template-columns: 1fr;
}

button {
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fbfdff;
  color: var(--ink);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.35);
}

button.active {
  background: rgba(15, 118, 110, 0.12);
  border-color: rgba(15, 118, 110, 0.4);
  color: var(--accent-strong);
}

button.danger {
  color: var(--danger);
}

.mesh-button {
  display: grid;
  gap: 2px;
  text-align: left;
  min-height: 64px;
}

.mesh-button span {
  color: var(--muted);
  font-size: 0.9rem;
}

.viewport-panel {
  min-width: 0;
}

.viewport-wrap {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.viewport-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.compact button {
  min-width: 46px;
}

.viewport {
  padding: 0;
  overflow: hidden;
}

.tool-rail {
  display: grid;
  gap: 10px;
  justify-items: center;
  align-content: start;
}

.tool-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#viewport {
  position: relative;
  min-height: 760px;
  background:
    linear-gradient(180deg, #dfeaf3 0%, #b7cfdd 52%, #d9e6ef 52%, #eff4f8 100%);
}

#scene-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: grab;
}

#scene-canvas.is-panning {
  cursor: grabbing;
}

.nav-gizmo {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 132px;
  height: 132px;
  z-index: 4;
  cursor: grab;
}

.nav-gizmo.is-dragging {
  cursor: grabbing;
}

.delete-popup {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%);
  width: min(320px, calc(100% - 32px));
  padding: 12px;
  border-radius: 16px;
  background: rgba(25, 28, 33, 0.96);
  color: #f7fafc;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.35);
  z-index: 5;
}

.delete-popup.hidden {
  display: none;
}

.delete-popup__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  color: rgba(247, 250, 252, 0.92);
}

.delete-popup__icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.26);
  font-weight: 800;
  font-size: 1.2rem;
}

.delete-popup__action {
  width: 100%;
  justify-content: space-between;
  display: flex;
  align-items: center;
  min-height: 46px;
  border: 1px solid rgba(147, 197, 253, 0.45);
  background: linear-gradient(180deg, #5592e8 0%, #3d74c8 100%);
  color: #f8fbff;
}

.delete-popup__action span {
  opacity: 0.72;
  font-weight: 700;
}

.delete-popup__hint {
  margin: 10px 2px 2px;
  font-size: 0.9rem;
  color: rgba(241, 245, 249, 0.76);
}

.object-list {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
}

.object-row {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
  text-align: left;
}

.object-row.active {
  border-color: rgba(15, 118, 110, 0.4);
  background: rgba(15, 118, 110, 0.09);
}

.object-row strong,
.object-row span {
  display: block;
}

.field-group + .field-group {
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field input[type="text"],
.field input[type="color"] {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

.field input[type="color"] {
  padding: 4px;
}

.field strong {
  color: var(--accent-strong);
  font-size: 0.92rem;
}

.shortcut-list {
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .inspector-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .topbar,
  .workspace,
  .viewport-toolbar,
  .viewport-wrap {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar {
    justify-content: stretch;
  }

  #viewport {
    min-height: 520px;
  }
}
