*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* 由 js/mp-viewport.js 写入 */
  --app-height: 100%;
  /* 底部占位高度：有小程序 tab 时拉开，无 tab 时为 0 */
  --mp-tabbar-spacer: 0px;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #0a1020;
  color: #eef3ff;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  position: relative;
  /* 控件改浮窗后，下方留给提示文本 */
  grid-template-rows: 0.4fr 6.4fr 3.2fr var(--mp-tabbar-spacer, 0px);
  height: var(--app-height, 100%);
  max-height: var(--app-height, 100%);
  overflow: hidden;
}

@supports (height: 100dvh) {
  #app {
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
  }
}

.user-header {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0);
  text-align: center;
  background: linear-gradient(180deg, rgba(8, 12, 28, 0.98) 0%, rgba(8, 12, 28, 0.85) 100%);
  border-bottom: 1px solid rgba(120, 154, 255, 0.12);
}

.user-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #f5f0ea;
  line-height: 1.2;
}

.user-viewer-wrap {
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, rgba(40, 56, 96, 0.35) 0%, rgba(8, 12, 28, 0.2) 70%);
}

.user-viewer {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.user-viewer canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.btn-reset-view {
  position: absolute;
  left: 12px;
  right: auto;
  bottom: 12px;
  z-index: 6;
  min-width: 52px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(120, 154, 255, 0.35);
  border-radius: 999px;
  background: rgba(12, 18, 36, 0.88);
  color: #e8eeff;
  font-size: 13px;
  letter-spacing: 0.04em;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  -webkit-tap-highlight-color: transparent;
}

.btn-reset-view:active {
  background: rgba(124, 156, 255, 0.28);
  border-color: rgba(124, 156, 255, 0.55);
}

#loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: rgba(8, 12, 28, 0.75);
  font-size: 14px;
  color: #93a4c7;
}

#loading.done {
  display: none;
}

.user-footer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 8px 12px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  background: rgba(10, 16, 32, 0.96);
  border-top: 1px solid rgba(120, 154, 255, 0.15);
  position: relative;
  z-index: 5;
}

html.mp-tabbar .user-footer {
  padding-bottom: 6px;
}

.mp-tabbar-spacer {
  min-height: 0;
  height: 100%;
  background: #0a1020;
  pointer-events: none;
}

.btn-picker-float {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 8;
  width: 30px;
  min-height: 132px;
  height: auto;
  padding: 16px 0;
  border: 1px solid rgba(120, 154, 255, 0.45);
  border-right: none;
  border-radius: 14px 0 0 14px;
  background: rgba(18, 28, 56, 0.94);
  color: #e8eeff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.22em;
  writing-mode: vertical-rl;
  text-orientation: upright;
  box-shadow: -4px 4px 16px rgba(0, 0, 0, 0.32);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-picker-float:active,
.btn-picker-float[aria-expanded="true"] {
  background: rgba(124, 156, 255, 0.32);
  border-color: rgba(124, 156, 255, 0.7);
}

.picker-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(4, 8, 18, 0.48);
  /* 抬高避开小程序底部 tab（由 mp-viewport 写入 --mp-tabbar-spacer） */
  padding-bottom: calc(var(--mp-tabbar-spacer, 0px) + 12px);
  box-sizing: border-box;
}

.picker-overlay[hidden] {
  display: none !important;
}

.picker-sheet {
  width: 100%;
  max-width: 480px;
  max-height: min(62vh, 480px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: rgba(12, 18, 36, 0.98);
  border: 1px solid rgba(120, 154, 255, 0.22);
  box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  margin: 0 8px;
}

.picker-sheet-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(120, 154, 255, 0.14);
  color: #f5f0ea;
  font-size: 15px;
  font-weight: 600;
}

.picker-close {
  height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(120, 154, 255, 0.28);
  border-radius: 999px;
  background: transparent;
  color: #c5d4ff;
  font-size: 13px;
  cursor: pointer;
}

.picker-sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.picker-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.picker-field label {
  flex: 0 0 40px;
  color: #9db4ff;
  font-size: 13px;
}

.picker-field select,
#disease-select,
#meridian-select,
#acupoint-select {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 10px;
  border: 1px solid rgba(120, 154, 255, 0.28);
  border-radius: 12px;
  background: rgba(8, 14, 28, 0.96);
  color: #eef3ff;
  font-size: 14px;
  outline: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #93a4c7 50%), linear-gradient(135deg, #93a4c7 50%, transparent 50%);
  background-position: calc(100% - 14px) 17px, calc(100% - 9px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 24px;
}

#disease-select:focus,
#meridian-select:focus,
#acupoint-select:focus {
  border-color: rgba(124, 156, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 156, 255, 0.12);
}

.search-input-wrap {
  position: relative;
  min-width: 0;
  z-index: 40;
  overflow: visible;
}

.search-suggest {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 4px);
  top: auto;
  max-height: min(220px, 32vh);
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  border: 1px solid rgba(120, 154, 255, 0.35);
  border-radius: 12px;
  background: rgba(10, 16, 32, 0.98);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
  z-index: 50;
}

.search-suggest[hidden] {
  display: none !important;
}

.search-suggest li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  color: #eef3ff;
  font-size: 14px;
}

.search-suggest li:hover,
.search-suggest li.active {
  background: rgba(124, 156, 255, 0.18);
}

.search-suggest .suggest-kind {
  flex-shrink: 0;
  min-width: 36px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(124, 156, 255, 0.16);
  color: #9db4ff;
  font-size: 11px;
  text-align: center;
}

.search-suggest .suggest-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#search {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(120, 154, 255, 0.28);
  border-radius: 12px;
  background: rgba(12, 18, 36, 0.92);
  color: #eef3ff;
  font-size: 15px;
  outline: none;
}

#search::placeholder {
  color: #7f8fb8;
}

#search:focus {
  border-color: rgba(124, 156, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 156, 255, 0.12);
}

.result-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 12px 14px;
  margin-bottom: 4px;
  border-radius: 12px;
  background: rgba(12, 18, 36, 0.72);
  border: 1px solid rgba(120, 154, 255, 0.14);
  position: relative;
  z-index: 1;
}

.result-placeholder {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  color: #c5d4ff;
  text-align: center;
  padding: 18px 8px;
  letter-spacing: 0.06em;
}

.result-placeholder.hidden {
  display: none;
}

.result-body.hidden {
  display: none;
}

.result-body h2 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: #f5f0ea;
}

.result-body p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #b8c5e0;
}

.result-tips {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(124, 156, 255, 0.1);
  border: 1px solid rgba(124, 156, 255, 0.28);
}

.result-tips.hidden {
  display: none;
}

.result-tips-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #9eb8ff;
}

.result-tips-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.result-tips-list li {
  font-size: 14px;
  line-height: 1.6;
  color: #d8e4ff;
}

.result-tips-list li + li {
  margin-top: 4px;
}

.result-desc {
  margin-top: 10px !important;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 102, 34, 0.1);
  border: 1px solid rgba(255, 102, 34, 0.3);
  color: #ffd8c4 !important;
}

.result-desc.hidden {
  display: none;
}

.result-desc::before {
  content: '调理说明';
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #ff9966;
}

.point-labels {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

.point-label-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.point-label-line {
  stroke: #ff6644;
  stroke-width: 3;
  fill: none;
}

.point-label {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(12, 18, 36, 0.96);
  border: 2px solid rgba(255, 120, 80, 0.85);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  color: #ffe2d2;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
  max-width: 200px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.point-label-name {
  display: block;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.point-label-desc {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 400;
  color: #ffc9a8;
  line-height: 1.4;
}

.point-label.visible {
  opacity: 1;
}

/* 经络密集模式（多标签时）仍可读 */
.point-label.compact {
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-width: 1.5px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.32);
}

.point-labels.compact-mode .point-label-line {
  stroke-width: 2;
  stroke: rgba(255, 140, 90, 0.85);
}

@media (min-width: 768px) {
  #app {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid rgba(120, 154, 255, 0.1);
    border-right: 1px solid rgba(120, 154, 255, 0.1);
  }
}
