﻿html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #eef3f8;
}

#layout,
#stage,
.v3d-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.v3d-container canvas {
  touch-action: none;
}

.lesson-ui {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  color: #172036;
}

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

.op-panel {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(780px, calc(100% - 28px));
  border: 1px solid rgba(20, 32, 54, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  padding: 14px 14px 12px;
  box-sizing: border-box;
  pointer-events: auto;
}

.panel-handle {
  position: absolute;
  top: -17px;
  left: 50%;
  transform: translateX(-50%);
  width: 58px;
  height: 28px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: rgba(255, 255, 255, 0.9);
  color: #2e3a52;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(185px, 1fr) minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 14px;
  align-items: center;
}

.control-row {
  display: grid;
  grid-template-columns: auto minmax(88px, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  font-size: 16px;
  font-weight: 900;
  color: #2f3d56;
}

.control-row > span:first-child {
  min-width: 4em;
  white-space: nowrap;
  text-align: left;
  line-height: 1.15;
}

.control-row input[type="range"] {
  width: 100%;
  accent-color: #4d87ff;
}

.control-row output {
  width: 42px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #4b5c79;
}

.degree-input {
  width: 78px;
  display: grid;
  grid-template-columns: 58px auto;
  align-items: center;
  gap: 4px;
}

.degree-input input {
  width: 58px;
  height: 36px;
  box-sizing: border-box;
  border: 1px solid rgba(20, 32, 54, 0.14);
  border-radius: 10px;
  background: #fff;
  color: #263550;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  text-align: center;
}

.degree-input em {
  font-style: normal;
  color: #4b5c79;
}

.action-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.model-picker {
  min-height: 44px;
  display: inline-grid;
  grid-template-columns: auto 118px;
  align-items: center;
  gap: 8px;
  color: #2f3d56;
  font-size: 16px;
  font-weight: 900;
}

.model-picker select {
  height: 44px;
  min-width: 118px;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  background: #fff;
  color: #1f2a44;
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  padding: 0 10px;
}

.btn {
  min-width: 116px;
  min-height: 44px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  background: #fff;
  color: #1f2a44;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
}

.btn.primary {
  border-color: rgba(77, 135, 255, 0.34);
  background: rgba(77, 135, 255, 0.14);
  color: #1e4f9f;
}

.feedback {
  min-height: 24px;
  margin-top: 8px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
  color: #31506f;
}

.feedback.ok {
  color: #197a4f;
}

.feedback.warn {
  color: #a75518;
}

.ui-panel-collapsed .op-panel {
  width: auto;
  min-width: 360px;
  padding: 10px 12px;
}

.ui-panel-collapsed .panel-handle {
  top: -17px;
  transform: translateX(-50%) rotate(180deg);
}

.ui-panel-collapsed .control-grid,
.ui-panel-collapsed .feedback {
  display: none;
}

.ui-panel-collapsed .action-row {
  margin-top: 0;
}

@media (max-width: 640px), (max-height: 620px) {
  .op-panel {
    bottom: 10px;
    width: calc(100% - 20px);
    max-height: min(62vh, 430px);
    padding: 10px;
  }

  .control-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .control-row {
    grid-template-columns: 70px minmax(0, 1fr) 78px;
    min-height: 38px;
    font-size: 14px;
  }

  .model-picker {
    grid-template-columns: auto 104px;
    min-height: 40px;
    font-size: 14px;
  }

  .model-picker select {
    min-width: 104px;
    height: 40px;
    font-size: 14px;
  }

  .btn {
    min-height: 40px;
    min-width: 96px;
    font-size: 15px;
  }

  .feedback {
    font-size: 14px;
  }
}

@media (max-width: 420px) {
  .action-row {
    justify-content: stretch;
  }

  .model-picker,
  .btn {
    flex: 1 1 auto;
  }

  .btn {
    min-width: 0;
  }
}

