/* 모달 열렸을 때 배경 스크롤 막기 */
body.modal-open {
  overflow: hidden;
  touch-action: none;
}

/* 계산기 모달 스타일 */
.calculator-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.calculator-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.calculator-content {
  background: var(--surface);
  border-radius: 16px;
  width: 90%;
  max-width: 320px;
  padding: 24px;
  padding-top: 54px; /* 닫기 버튼 공간 확보 */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transform: translateY(20px);
  transition: transform 0.2s;
  position: relative;
}

/* ... (생략) ... */

.btn-close-calc {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 36px;
  height: 36px;
  background: #f3f4f6;
  border-radius: 50%;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.calculator-modal.open .calculator-content {
  transform: translateY(0);
}

.calc-display {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: right;
  margin-bottom: 20px;
  height: auto;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden; /* 넘치는 내용 숨김 */
}

.calc-formula {
  font-size: 1rem;
  color: var(--text-secondary);
  min-height: 1.5em;
  margin-bottom: 8px;
  word-break: break-all;
}

.calc-result {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  overflow-x: auto; /* 가로 스크롤 허용 */
  white-space: nowrap;
  scrollbar-width: none; /* 스크롤바 숨김 (Firefox) */
}
.calc-result::-webkit-scrollbar {
  display: none; /* 스크롤바 숨김 (Chrome/Safari) */
}

.btn-backspace {
  font-size: 1.4rem;
  color: var(--text);
  background: var(--surface);
}

.calc-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.calc-btn {
  padding: 16px 0;
  border-radius: 12px;
  border: none;
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 0.1s,
    transform 0.05s; /* transform 애니메이션 가속화 */
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.05);

  /* 🔥 모바일 반응 속도 개선 🔥 */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.calc-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.btn-number {
  background: var(--surface);
}

.btn-operator {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-light);
  font-size: 1.2rem;
}

.btn-equals {
  grid-column: span 1;
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-clear {
  color: var(--danger);
  font-size: 1rem;
  background: hsl(0, 100%, 98%);
  border-color: hsl(0, 100%, 95%);
}

.btn-backspace {
  font-size: 1rem;
}

.btn-submit {
  grid-column: span 4;
  margin-top: 16px;
  padding: 14px;
  background: var(--success);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
  transition: transform 0.1s;
}

.btn-submit:active {
  transform: scale(0.98);
}

/* 수량 입력 박스 수정 */
.quantity-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.btn-calc-open {
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  width: 50px;
  height: 48px; /* input 높이와 맞춤 */
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
}

.btn-calc-open:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* JS로 제어하는 즉각적인 눌림 효과 */
.calc-btn.active-press {
  transform: scale(0.95);
  background-color: #e5e7eb; /* 약간 진한 회색 */
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: none; /* 애니메이션 없이 즉시 변경 */
}
