/* ========== 编辑按钮（统一样式） ========== */
.edit-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.15s ease;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-family: inherit;
  white-space: nowrap;
}
.edit-mode .edit-btn {
  opacity: 1;
  pointer-events: auto;
}
.edit-btn:active {
  transform: scale(0.95);
  opacity: 0.8;
}

/* 底部栏编辑按钮（fixed独立定位） */
.tabbar-edit-btn {
  position: fixed;
  top: auto;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 75px);
  right: 24px;
}

/* ========== 拖拽状态 ========== */
.draggable {
  touch-action: none;
  position: relative;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.edit-mode .draggable {
  cursor: move;
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

.edit-mode .draggable * {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

.draggable.dragging {
  opacity: 0.92;
  z-index: 100;
  transition: none !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
}

/* ========== 编辑模式左上角工具按钮组 ========== */
.edit-toolbar-group {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 15;
  pointer-events: none;
}

.reset-layout-btn,
.edit-tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-family: inherit;
  width: auto;
  max-width: fit-content;
}

.reset-layout-btn svg,
.edit-tool-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.app-shell.edit-mode .reset-layout-btn,
.app-shell.edit-mode .edit-tool-btn {
  opacity: 1;
  pointer-events: auto;
}

.reset-layout-btn:active,
.edit-tool-btn:active {
  opacity: 0.7;
  transform: scale(0.95);
}

/* ========== 通用编辑气泡卡片 (Popup Card) ========== */
.popup-mask {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 999;
  display: none;
}
.popup-mask.show {
  display: block;
}

.popup-card {
  position: fixed;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  width: 240px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: none;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
}
.popup-card.show {
  display: flex;
}

.popup-card-title {
  font-size: 14px;
  font-weight: 600;
  color: #1c1c1e;
  text-align: center;
  padding-bottom: 4px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
}

.popup-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: #3c3c43;
  font-weight: 500;
}

.popup-card-row input[type="color"] {
  width: 32px;
  height: 26px;
  border: 1px solid #e5e5ea;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  padding: 1px;
}

.popup-card-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #e5e5ea;
  border-radius: 99px;
  outline: none;
}

.popup-card-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  border: 0.5px solid rgba(0, 0, 0, 0.04);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.popup-card-value {
  font-size: 12px;
  color: #8e8e93;
  min-width: 36px;
  text-align: right;
}

/* 开关组件 */
.toggle-switch { 
  position: relative; 
  width: 44px; 
  height: 24px; 
}

.toggle-switch input { 
  opacity: 0; 
  width: 0; 
  height: 0; 
}

.toggle-switch label { 
  position: absolute; 
  cursor: pointer; 
  top: 0; 
  left: 0; 
  right: 0; 
  bottom: 0; 
  background-color: #e5e5ea; 
  transition: .3s; 
  border-radius: 24px; 
}

.toggle-switch label:before { 
  position: absolute; 
  content: ""; 
  height: 20px; 
  width: 20px; 
  left: 2px; 
  bottom: 2px; 
  background-color: white; 
  transition: .3s; 
  border-radius: 50%; 
  box-shadow: 0 1px 3px rgba(0,0,0,.15); 
}

input:checked + label { 
  background-color: #1c1c1e;
}

input:checked + label:before { 
  transform: translateX(20px);
}
