* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #212529;
  background: #dee2e6;
}

/* Left column 70% (scene 75% / controls 25%), right column 30% (source 50% / target 50%). */
.app {
  display: grid;
  height: 100vh;
  gap: 4px;
  padding: 4px;
  grid-template-columns: 7fr 3fr;
  grid-template-rows: 2fr 1fr 1fr;
  grid-template-areas:
    "scene    source"
    "scene    target"
    "controls target";
}
.scene-panel    { grid-area: scene; }
.controls-panel { grid-area: controls; }
.source-panel   { grid-area: source; }
.target-panel   { grid-area: target; }

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}
.panel-title {
  margin: 0;
  padding: 6px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  border-bottom: 1px solid #e9ecef;
}
.hint { font-weight: 400; color: #868e96; margin-left: 6px; }

.viewport {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  display: block;
}
#scene3d canvas { display: block; }
.label-layer { position: absolute; inset: 0; }

.label3d { font-size: 13px; font-weight: 600; color: #495057; pointer-events: none; }
.label3d.axis-x, .axis-x { color: #e03131; }
.label3d.axis-y, .axis-y { color: #2f9e44; }
.label3d.axis-z, .axis-z { color: #1c7ed6; }
.label3d.source { color: #868e96; font-weight: 500; }
.label3d.target { color: #7048e8; font-weight: 500; }

/* Controls panel: left half is descriptive text, right half holds the controls in two columns. */
.controls-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 12px 16px;
  overflow: auto;
}
.info { min-width: 0; font-size: 0.9rem; line-height: 1.45; color: #495057; }
.info h3 { margin: 0 0 6px; font-size: 0.95rem; color: #212529; }
.info p { margin: 0 0 8px; }
.controls { display: grid; grid-template-columns: auto auto; justify-content: start; align-items: start; gap: 24px; min-width: 0; }
.control-column { display: flex; flex-direction: column; gap: 14px; }
.control { display: flex; flex-direction: column; gap: 6px; }
.control label, .control-label { font-size: 0.85rem; font-weight: 600; }
.control output { font-weight: 400; font-variant-numeric: tabular-nums; margin-left: 4px; }
#distance { width: 200px; }

.rot-row { display: flex; align-items: center; gap: 6px; }
.axis { width: 1.2em; font-weight: 700; }
button {
  font: inherit;
  font-size: 0.9rem;
  padding: 4px 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  background: #f8f9fa;
  cursor: pointer;
}
button:hover { background: #e9ecef; }
button:active { background: #dee2e6; }
.buttons { flex-direction: row; }

/* Phones / narrow screens: stack panels vertically. */
@media (max-width: 800px) {
  .app {
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: 60vh auto 45vh 45vh;
    grid-template-areas: "scene" "controls" "source" "target";
  }
}
