html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #dceff2;
}

#layout,
#stage {
  position: absolute;
  inset: 0;
}

#v3d-container {
  background: #dceff2;
}

#lesson-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.ui-hidden #lesson-overlay {
  display: none;
}

#lesson-formula-canvas {
  position: absolute;
  top: 20px;
  left: 50%;
  width: min(860px, calc(100vw - 32px));
  height: 104px;
  transform: translateX(-50%);
  display: block;
  pointer-events: none;
}

#lesson-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 3;
  touch-action: none;
}

.scene-label-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scene-label-line-back {
  stroke: rgba(255, 255, 255, 0.82);
  stroke-width: 7;
  opacity: 0.8;
}

.scene-label-line-front {
  stroke-dasharray: 10 10;
  opacity: 0.92;
}

.scene-label-pin-ring {
  fill: rgba(255, 255, 255, 0.72);
  stroke-width: 3;
}

.scene-label-pin-core {
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 2;
}

.scene-label-card {
  fill: rgba(255, 255, 255, 0.78);
  stroke: rgba(15, 23, 42, 0.1);
  stroke-width: 1;
  filter: drop-shadow(0 12px 26px rgba(15, 23, 42, 0.14));
}

.scene-label-group text {
  font-weight: 900;
  stroke: none;
}

.scene-label-title {
  font-size: clamp(20px, 2.1vw, 28px);
}

.scene-label-value {
  font-size: clamp(18px, 1.9vw, 24px);
}

.scene-label-unit {
  font-size: clamp(16px, 1.7vw, 20px);
}

.scene-label-area .scene-label-line-front {
  stroke: #ca8a04;
}

.scene-label-area .scene-label-pin-ring {
  stroke: rgba(202, 138, 4, 0.76);
}

.scene-label-area .scene-label-pin-core {
  fill: #ca8a04;
}

.scene-label-area text {
  fill: #ca8a04;
}

.scene-label-perimeter .scene-label-line-front {
  stroke: #0891b2;
}

.scene-label-perimeter .scene-label-pin-ring {
  stroke: rgba(8, 145, 178, 0.76);
}

.scene-label-perimeter .scene-label-pin-core {
  fill: #0891b2;
}

.scene-label-perimeter text {
  fill: #0891b2;
}

.op-panel {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 24px));
  display: grid;
  grid-template-columns: 134px minmax(280px, 1fr) 126px;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.mini-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metric-card {
  min-height: 76px;
  position: relative;
  display: grid;
  grid-template-rows: 20px 1fr 18px;
  place-items: center;
  padding: 8px 6px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(241, 245, 249, 0.82));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 8px 18px rgba(15, 23, 42, 0.08);
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.12;
  pointer-events: none;
}

.metric-length::before {
  background: linear-gradient(135deg, #22c7d5, transparent 62%);
}

.metric-width::before {
  background: linear-gradient(135deg, #f59e0b, transparent 62%);
}

.metric-card strong {
  position: relative;
  color: #0f172a;
  font-size: 28px;
  line-height: 1;
  font-weight: 950;
  text-align: center;
}

.metric-label,
.metric-unit {
  position: relative;
  line-height: 1;
  font-weight: 900;
  text-align: center;
}

.metric-label {
  min-width: 26px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 13px;
}

.metric-length .metric-label {
  background: #0891b2;
}

.metric-width .metric-label {
  background: #b45309;
}

.metric-unit {
  color: #64748b;
  font-size: 12px;
}

.sliders {
  display: grid;
  gap: 8px;
}

.sliders label {
  min-height: 44px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 14px;
  background: rgba(241, 245, 249, 0.92);
}

.sliders span,
.sliders strong {
  color: #0f172a;
  font-size: 18px;
  font-weight: 950;
  text-align: center;
}

.sliders input {
  width: 100%;
  accent-color: #22c7d5;
}

.actions {
  display: grid;
  grid-template-rows: repeat(3, minmax(44px, 1fr));
  gap: 8px;
}

.actions button {
  min-height: 44px;
  border: 1px solid rgba(77, 135, 255, 0.28);
  border-radius: 14px;
  background: rgba(77, 135, 255, 0.16);
  color: #0f172a;
  font-size: 16px;
  font-weight: 950;
  cursor: pointer;
}

.actions button:disabled {
  cursor: default;
  opacity: 0.56;
}

.fullscreen-button {
  z-index: 4;
}

@media (max-width: 640px), (max-height: 620px) {
  .scene-label-title {
    font-size: 18px;
  }

  .scene-label-value {
    font-size: 16px;
  }

  .scene-label-unit {
    font-size: 14px;
  }

  .op-panel {
    grid-template-columns: 1fr;
    width: calc(100vw - 16px);
    max-height: min(62vh, 430px);
    padding: 8px;
    gap: 8px;
  }

  .metric-card {
    min-height: 58px;
    grid-template-rows: 18px 1fr 14px;
    padding: 6px 4px;
  }

  .metric-card strong {
    font-size: 22px;
  }

  .metric-label {
    font-size: 12px;
    padding: 3px 6px;
  }

  .metric-unit {
    font-size: 11px;
  }

  .actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: none;
  }

  .actions button {
    min-height: 40px;
    font-size: 14px;
  }
}
