/* ── 編輯模式控制按鈕 ── */
#edit-btn,
#restore-btn,
#finish-edit-btn {
  background: var(--inner);
  border: 1px solid var(--accent-bg);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
@media (hover: hover) and (pointer: fine) {
    #edit-btn:hover,
    #restore-btn:hover,
    #finish-edit-btn:hover {
        background: var(--accent-bg);
        border-color: var(--ink);
        color: var(--ink);
    }
}
#edit-btn:disabled,
#restore-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 編輯模式啟用時 ── 顯示「還原」「完成」、隱藏「編輯」 */
.edit-mode-btn { display: none; }
.editing-active #edit-btn { display: none; }
.editing-active .edit-mode-btn { display: inline-block; }
.editing-active #result-section-label::after {
  content: "（編輯中）";
  margin-left: 6px;
  color: var(--ink);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

/* ── 編輯模式卡片：放大、露出控制項 ── */
.acu-card-editing {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px 14px 14px;
  border-radius: var(--radius-sm);
  min-width: 200px;
  position: relative;
}
.acu-card-editing .acu-card-name {
  font-size: 1.0rem;
  font-weight: 500;
  padding-right: 40px;
}

/* ── ✕ 刪除按鈕：右上角，44×44 hit area ── */
.acu-card-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: var(--inner);
  border: 1px solid var(--accent-bg);
  border-radius: 50%;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.acu-card-delete:active {
  background: rgba(181, 72, 47, 0.08);
  border-color: var(--rec);
  color: var(--rec);
}

/* ── Stepper：[−] [數字] [+] ── */
.acu-card-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.stepper-btn {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--inner);
  border: 1px solid var(--accent-bg);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s;
}
.stepper-btn:active {
  background: var(--accent-bg);
  border-color: var(--ink);
}
.stepper-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.stepper-value {
  min-width: 60px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text);
}
.stepper-unit {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: -2px;
}

/* ── 「＋ 新增穴位到 X」按鈕（每個部位區塊底部） ── */
.add-acupoint-btn {
  display: none;
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  border: 1.5px dashed var(--accent-bg);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 48px;
  transition: background 0.15s, border-color 0.15s;
}
.add-acupoint-btn:active {
  background: var(--accent-bg);
  border-color: var(--ink);
}
.editing-active .add-acupoint-btn { display: block; }

/* ── 「＋ 新增其他部位的穴位」最底部按鈕 ── */
.add-new-section-btn {
  display: none;
  width: 100%;
  margin-top: 6px;
  padding: 16px;
  border: 1.5px dashed var(--ink);
  border-radius: var(--radius-sm);
  background: var(--accent-bg);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 48px;
  transition: opacity 0.15s;
}
@media (hover: hover) and (pointer: fine) {
    .add-new-section-btn:hover {
        opacity: 0.8;
    }
}
.editing-active .add-new-section-btn { display: block; }

/* ── Bottom Sheet Overlay ── */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 42, 36, 0.45);
  z-index: 9998;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.bottom-sheet-overlay.hidden { display: none; }

.bottom-sheet {
  background: var(--surface);
  border-top: 1px solid var(--accent-bg);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 8px 20px 20px;
  box-shadow: 0 -4px 24px rgba(47,74,61,.12);
  animation: sheet-slide-up 0.22s ease-out;
  position: relative;
  bottom: 0;
  transition: bottom 0.18s ease;
}
@keyframes sheet-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--accent-bg);
  border-radius: 2px;
  margin: 6px auto 14px;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.sheet-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 500;
}
#add-sheet-close,
#treatment-sheet-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--inner);
  border: 1px solid var(--accent-bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s;
}
@media (hover: hover) and (pointer: fine) {
    #add-sheet-close:hover,
    #treatment-sheet-close:hover {
        background: var(--accent-bg);
        border-color: var(--ink);
        color: var(--text);
    }
}

.sheet-step.hidden { display: none; }
#add-sheet-search {
  margin-bottom: 10px;
  font-size: 1rem;
  min-height: 44px;
}

/* 部位選單 / 穴位選單共用 row 樣式 */
.sheet-loc-list,
.sheet-acu-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--accent-bg);
  border-radius: var(--radius-sm);
  background: var(--inner);
  max-height: 40vh;
  -webkit-overflow-scrolling: touch;
}
.sheet-row {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--accent-bg);
  cursor: pointer;
  min-height: 48px;
  user-select: none;
  transition: background 0.12s;
}
.sheet-row:last-child { border-bottom: none; }
.sheet-row:active {
  background: var(--accent-bg);
}
.sheet-row.selected {
  background: var(--accent-bg);
  border-left: 3px solid var(--ink);
}
.sheet-row.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.sheet-row-name {
  flex: 1;
  color: var(--text);
  font-size: 0.95rem;
}
.sheet-row-code {
  color: var(--muted);
  font-size: 0.78rem;
  font-family: "Consolas", monospace;
  margin-right: 12px;
  min-width: 56px;
}
.sheet-row-hint {
  color: var(--ink);
  font-size: 0.75rem;
  margin-left: 8px;
}

.sheet-qty-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--accent-bg);
  margin-top: 12px;
}
.sheet-qty-row.hidden { display: none; }

.sheet-footer {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--accent-bg);
}
.sheet-btn-primary,
.sheet-btn-secondary {
  flex: 1;
  min-height: 48px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.sheet-btn-primary {
  background: var(--ink);
  border: none;
  color: var(--surface);
}
@media (hover: hover) and (pointer: fine) {
    .sheet-btn-primary:hover {
        opacity: 0.88;
    }
}
.sheet-btn-primary:active {
    transform: scale(0.98);
}
.sheet-btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.sheet-btn-secondary {
  background: var(--inner);
  border: 1px solid var(--accent-bg);
  color: var(--text);
}
@media (hover: hover) and (pointer: fine) {
    .sheet-btn-secondary:hover {
        background: var(--accent-bg);
        border-color: var(--ink);
    }
}

/* ── 編輯模式下的療法卡片：填色膠囊加寬，留 ✕ 空間 ── */
.treatment-card-editing {
  padding: 5px 40px 5px 6px;
  min-height: 44px;
}
.treatment-card-editing .acu-card-delete {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, .9);
  border-color: transparent;
}

/* ── treatment sheet 「點選即新增」提示 ── */
.sheet-hint {
  margin: -4px 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
}
