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: radial-gradient(circle at 30% 15%, #eef5ff 0%, #f3f0ff 55%, #f6fbff 100%);
}

.ui-loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #2b3a55;
  letter-spacing: 0.5px;
}

.ui-hidden .ui-loading {
  display: flex;
}

.ui-hidden #layout {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr;
  grid-template-areas: "stage";
}

.ui-hidden #panel {
  display: none;
}

#layout {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: 1fr;
  grid-template-areas: "stage panel";
  gap: 16px;
  padding: 16px;
  box-sizing: border-box;
}

#panel {
  grid-area: panel;
  width: 340px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 18px;
  padding: 14px 14px 12px;
  box-sizing: border-box;
  backdrop-filter: blur(10px);
  overflow: auto;
}

#stage {
  grid-area: stage;
  min-width: 0;
  position: relative;
  border-radius: 18px;
  overflow: hidden;
}

.ui-collapsed #layout {
  grid-template-columns: minmax(0, 1fr) 56px;
  grid-template-areas: "stage panel";
}

.ui-collapsed #panel {
  width: 56px;
  padding: 10px;
  overflow: hidden;
}

.v3d-container {
  position: relative;
  width: 100%;
  height: 100%;
}

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

.panel-title {
  font-weight: 700;
  font-size: 18px;
  color: #1f2a44;
}

.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-content {
  margin-top: 8px;
}

.ui-collapsed .panel-title {
  display: none;
}

.ui-collapsed .panel-content {
  display: none;
}

.panel-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: #54607a;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #39465f;
}

.inline input[type="number"] {
  width: 82px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 13px;
  outline: none;
  background: #fff;
}

.select {
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  background: #fff;
}

.hint {
  font-size: 12px;
  line-height: 1.4;
  color: #39465f;
}

.btn {
  appearance: none;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #ffffff;
  color: #1f2a44;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.btn:hover {
  background: #f7f9ff;
}

.btn.success {
  background: #eafff3;
  border-color: rgba(44, 198, 120, 0.35);
}

.btn.tiny {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.answers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.answer {
  --cat-border: rgba(255, 77, 132, 0.55);
  --cat-shadow: rgba(255, 77, 132, 0.16);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.75);
}

.answer[data-cat="3"] { --cat-border: rgba(255, 77, 132, 0.55); --cat-shadow: rgba(255, 77, 132, 0.16); }
.answer[data-cat="2"] { --cat-border: rgba(255, 200, 77, 0.55); --cat-shadow: rgba(255, 200, 77, 0.18); }
.answer[data-cat="1"] { --cat-border: rgba(70, 214, 168, 0.55); --cat-shadow: rgba(70, 214, 168, 0.18); }
.answer[data-cat="0"] { --cat-border: rgba(77, 135, 255, 0.55); --cat-shadow: rgba(77, 135, 255, 0.18); }

.answer.active {
  border-color: var(--cat-border);
  box-shadow: 0 0 0 4px var(--cat-shadow);
}

.answer-title {
  font-weight: 700;
  font-size: 13px;
  color: #1f2a44;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
  background: #fff;
}

.total {
  font-size: 13px;
  color: #54607a;
  white-space: nowrap;
}

.input[readonly] {
  background: rgba(245, 247, 255, 0.9);
}

.tag-msg {
  margin-top: 6px;
  min-height: 16px;
  font-size: 12px;
  line-height: 1.3;
  color: #d14157;
}

.mini-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.msg {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #1f2a44;
  min-height: 18px;
  white-space: pre-line;
}

.mode-exam .mode-practice {
  display: none;
}

.mode-practice #btn-check {
  display: none;
}

.mode-exam #btn-check {
  display: inline-flex;
}

.mode-exam .total {
  display: block;
  opacity: 1;
}
@media (max-width: 640px) {
  #layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas: "stage" "panel";
  }

  #panel {
    width: auto;
    max-height: 38vh;
  }

  .ui-collapsed #layout {
    grid-template-rows: 1fr auto;
  }

  .ui-collapsed #panel {
    width: auto;
    max-height: none;
  }
}
