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: #a8bed9;
}

#stage,
.v3d-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #a8bed9;
}

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

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

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

#net-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  touch-action: none;
}

.net-mode #net-svg {
  display: none;
}

.lesson-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(760px, calc(100vw - 32px));
  min-height: 24px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(252, 254, 255, 0.86));
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 28px rgba(24, 46, 84, 0.14);
  color: #1f2a44;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  box-sizing: border-box;
  backdrop-filter: blur(14px) saturate(1.1);
  pointer-events: none;
}

.lesson-toast:empty {
  display: none;
}

.lesson-panel {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 32px));
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(252, 254, 255, 0.86));
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 42px rgba(24, 46, 84, 0.16), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  backdrop-filter: blur(16px) saturate(1.12);
  pointer-events: auto;
  box-sizing: border-box;
}

.panel-toggle {
  position: absolute;
  left: 50%;
  top: -22px;
  transform: translateX(-50%);
  width: 54px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #eef3fb);
  color: #46557a;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(24, 46, 84, 0.14);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

body:not(.panel-collapsed) .panel-toggle:hover {
  transform: translateX(-50%) translateY(-1px);
  box-shadow: 0 14px 28px rgba(24, 46, 84, 0.18);
}

.panel-main {
  display: grid;
  grid-template-columns: minmax(250px, 1.2fr) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  box-sizing: border-box;
}

.case-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.case-btn,
.plain-btn,
.primary-btn {
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(31, 42, 68, 0.08);
  padding: 8px 12px;
  color: #1f2a44;
  background: linear-gradient(180deg, #ffffff, #f5f8fd);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 6px rgba(24, 46, 84, 0.07);
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.case-btn.is-active {
  background: linear-gradient(180deg, #eaf2ff, #dbe9ff);
  border-color: rgba(77, 135, 255, 0.42);
  color: #103f8f;
  box-shadow: 0 8px 18px rgba(77, 135, 255, 0.22), 0 0 0 3px rgba(77, 135, 255, 0.12);
}

.case-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: none;
}

.case-btn.is-done {
  box-shadow: inset 0 -3px 0 rgba(55, 190, 120, 0.4), 0 2px 6px rgba(24, 46, 84, 0.07);
}

.case-btn.is-best {
  background: rgba(55, 190, 120, 0.18);
  border-color: rgba(55, 190, 120, 0.38);
  color: #0d7a45;
}

.readout {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(244, 248, 255, 0.96), rgba(236, 243, 254, 0.92));
  border: 1px solid rgba(77, 135, 255, 0.14);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.85) inset;
  color: #2c3650;
  box-sizing: border-box;
}

#case-name {
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
}

#case-formula {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
}

#case-length {
  color: #103f8f;
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.primary-btn {
  background: linear-gradient(180deg, #e9f9f1, #d6f0e2);
  border-color: rgba(55, 190, 120, 0.36);
  color: #0b6f3f;
  box-shadow: 0 6px 16px rgba(55, 190, 120, 0.2);
}

.plain-btn:hover,
.primary-btn:hover,
.case-btn:hover {
  filter: brightness(0.985);
}

.plain-btn:not(:disabled):hover,
.primary-btn:not(:disabled):hover,
.case-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(24, 46, 84, 0.12);
}

.plain-btn:not(:disabled):active,
.primary-btn:not(:disabled):active,
.case-btn:not(:disabled):active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(24, 46, 84, 0.1) inset;
}

body.panel-collapsed .lesson-panel {
  width: 86px;
  min-height: 40px;
  border-radius: 999px;
}

body.panel-collapsed .panel-main {
  display: none;
}

body.panel-collapsed .panel-toggle {
  position: static;
  transform: none;
  display: block;
  margin: 6px auto;
  box-shadow: none;
}

.net-face {
  stroke: rgba(31, 42, 68, 0.34);
  stroke-width: 2;
}

.net-path {
  fill: none;
  stroke: #f05a4f;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.net-path.is-preview {
  opacity: 0.55;
  stroke-dasharray: 10 8;
}

.net-path.is-best {
  stroke: #13a15f;
  stroke-width: 7;
}

.guess-path {
  fill: none;
  stroke: #f0a240;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 12 8;
}

.kink-dot {
  fill: #f0a240;
  stroke: #ffffff;
  stroke-width: 4;
  cursor: grab;
}

.optimal-dot {
  fill: rgba(255, 255, 255, 0.88);
  stroke: #f05a4f;
  stroke-width: 4;
}

.guide-line {
  stroke: rgba(31, 42, 68, 0.2);
  stroke-width: 2;
  stroke-dasharray: 8 8;
}

.point-dot {
  fill: #1f2a44;
  stroke: #ffffff;
  stroke-width: 4;
}

.point-dot.is-target {
  fill: #f05a4f;
}

.point-label,
.face-label,
.dim-label {
  fill: #1f2a44;
  font-weight: 900;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.82);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.point-label {
  font-size: 25px;
}

.face-label {
  font-size: 17px;
}

.dim-label {
  font-size: 16px;
  fill: #4a5874;
}

@media (max-width: 760px), (max-height: 620px) {
  .lesson-toast {
    top: 10px;
    font-size: 14px;
    padding: 6px 10px;
  }

  .lesson-panel {
    bottom: 10px;
    width: min(680px, calc(100vw - 20px));
  }

  .panel-main {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px;
  }

  .readout {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media (max-width: 520px) {
  .lesson-panel {
    width: calc(100vw - 12px);
  }

  .panel-main {
    grid-template-columns: 1fr;
    max-height: 42vh;
    overflow: auto;
    padding: 8px;
  }

  .case-tabs {
    gap: 6px;
  }

  .case-btn,
  .plain-btn,
  .primary-btn {
    min-height: 38px;
    padding: 6px 8px;
    border-radius: 12px;
    font-size: 14px;
  }

  .readout {
    grid-template-columns: 1fr auto;
    min-height: 38px;
    padding: 6px 8px;
  }

  #case-name {
    display: none;
  }

  #case-formula {
    font-size: 13px;
  }

  #case-length {
    font-size: 15px;
  }

  .panel-actions {
    justify-content: center;
  }
}

