:root {
  --card-bg: #ececff;
  --card-border: #e5e7eb;
  --muted: #6b7280;

  --modal-backdrop: rgba(0, 0, 0, 0.45);
  --modal-bg: #ffffff;
  --modal-border: #e5e7eb;
}

/* 공통 */
* {
  box-sizing: border-box;
}
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}
body {
  font-family: Arial, sans-serif;
  padding: 20px;
  line-height: 1.5;
}

/* 전체 가운데 정렬 컨테이너 */
.page {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}

h1 {
  margin: 0 0 10px;
  text-align: center;
}
.lead {
  font-size: 1.05rem;
  margin: 0 0 12px;
}

label,
input,
button,
select {
  font-size: 16px;
}

/* 컨트롤 영역 */
.controls {
  display: grid;
  grid-template-columns: minmax(90px, 140px) minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
  max-width: 720px;
  margin: 0 auto;
}
.controls .full {
  grid-column: 1 / -1;
}

input[type="number"],
select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

/* 버튼 공통 */
button {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #cfd2ff;
  border-radius: 10px;
  background: #f1f3ff;
  font-weight: 700;
  cursor: pointer;
  transition:
    box-shadow 0.12s ease-in-out,
    transform 0.02s ease-in-out;
}
button:hover {
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}
button:active {
  transform: translateY(1px);
}

/* 버튼 변형 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: #fafafa;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.btn:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: #2f5bff;
  color: #fff;
  border-color: #2f5bff;
}
.btn-full {
  width: 100%;
}

/* 결과 카드 영역 */
.result {
  margin: 20px auto 0;
  width: 100%;
  max-width: 720px;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(12, 12, 12, 0.337);
  width: 100%;
  max-width: 100%;
  text-align: left;
}
.card.totals {
  background: #fff4e5;
  border-color: #f3b673;
}
.rank-title {
  font-weight: 700;
  margin-bottom: 6px;
}
.muted {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}
.total-line {
  margin-top: 6px;
  font-size: 1.05rem;
}

/* ==================== 체크박스 그룹 ==================== */
fieldset.checkbox-group {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #f9f9ff;

  display: flex;
  flex-direction: column;
  align-items: center; /* 각 항목을 가로 중앙 배치 */
  row-gap: 12px;
  text-align: left;
  width: 100%;
}
.checkbox-group legend {
  font-weight: 700;
  padding: 0 6px;
  font-size: 1rem;
}

/* 기본 라인형(이미지 없는 버전도 동일 동작): checkbox | text = 2열 고정 */
label.checkbox-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start; /* 텍스트가 여러 줄이어도 체크박스는 좌상단 고정 */
  column-gap: 8px;
  margin: 0;
  user-select: none;
  width: 100%;
  max-width: 520px; /* 필요 시 조정. 중앙 그룹에서 예쁘게 보이도록 */
}
label.checkbox-row input[type="checkbox"] {
  margin: 0;
}
label.checkbox-row strong {
  min-width: 0; /* ✅ 줄바꿈 허용을 위한 필수 */
  white-space: normal; /* ✅ 모바일에서 줄바꿈 허용 */
  overflow-wrap: anywhere; /* 긴 단어/붙은 문자열도 줄바꿈 */
  line-height: 1.4;
}

/* ========== 썸네일(이미지) 포함 항목(카드형) ========== */
.checkbox-row.with-thumb {
  width: 100%;
  max-width: 520px; /* 카드 폭 고정(가운데 정렬 유지) */
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 14px 14px 10px;
  border: 1px solid #e5e8eb;
  border-radius: 12px;
  background: #fff;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  text-align: left;
}

/* 상단 라인: checkbox | text 2열 고정(좌측 정렬 + 자동 줄바꿈) */
.checkbox-row.with-thumb .row-top {
  display: grid;
  grid-template-columns: auto 1fr; /* ✅ 항상 체크박스 왼쪽, 텍스트 오른쪽 */
  align-items: start; /* ✅ 체크박스 좌상단 고정 */
  column-gap: 10px;
  padding-left: 10px; /* 왼쪽 여백 추가 */
  padding-top: 2px; /* 위쪽 여백 추가 */
  margin-bottom: 4px; /* 이미지와의 간격 줄임 */
}
.checkbox-row.with-thumb .row-top input[type="checkbox"] {
  margin: 0;
}
.checkbox-row.with-thumb .row-top strong {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

/* 이미지 래퍼: 카드 폭에 맞춰 100% + 가운데 정렬 */
.acc-thumb {
  width: 100%;
  margin-top: -10px;
  display: flex;
  justify-content: center; /* 이미지만 가운데 정렬 */
}

/* 이미지: 반응형(라운드/테두리/그림자 제거) */
.acc-thumb img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* 체크 시 이미지 하이라이트(불 들어오는 느낌) */
.checkbox-row.with-thumb input[type="checkbox"]:checked ~ .acc-thumb img {
  box-shadow:
    0 0 0 2px rgba(59, 130, 246, 0.35),
    0 4px 10px rgba(59, 130, 246, 0.15);
  outline: 1px solid rgba(59, 130, 246, 0.55);
}

/* 카드 호버 */
.checkbox-row.with-thumb:hover {
  border-color: #d7dce1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* 안내문 */
.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 10px auto 0;
  max-width: 720px;
}

/* ===== 모달 ===== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}
.modal.is-open {
  display: flex;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-backdrop);
}
.modal__dialog {
  position: relative;
  width: calc(100% - 32px);
  max-width: 520px;
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  padding: 12px 14px;
  z-index: 2;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--modal-border);
}
.modal__body {
  padding: 12px 2px;
}
.modal__footer {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--modal-border);
}
.modal__footer--stack {
  flex-direction: column;
}
.modal__footer .btn {
  width: 100%;
}

/* 반응형 */
@media (max-width: 560px) {
  body {
    padding: 16px;
  }
  .controls {
    grid-template-columns: 1fr;
    max-width: 100%;
  }
  .controls label {
    margin-top: 6px;
  }
  input,
  select,
  button {
    width: 100%;
  }
  .card {
    padding: 12px 14px;
  }
  .result,
  .hint {
    max-width: 100%;
  }

  .checkbox-row.with-thumb,
  label.checkbox-row {
    max-width: 100%;
  } /* 모바일에서는 가로 100%로 */
}

/* 설치 방식 선택 버튼 스타일 */
#pickSerial,
#pickParallel {
  background-color: white;
  color: #333;
  border: 0.1px solid #000000;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition:
    background-color 0.3s,
    color 0.3s;
}
#pickSerial:hover,
#pickParallel:hover {
  background-color: #3b4cd2;
  color: #fff;
}
/* 제품명+설명 가로 배치 */
.label-text {
  display: flex;
  align-items: center;
  gap: 6px; /* 이름과 설명 사이 간격 */
  flex-wrap: wrap; /* 화면이 좁아지면 줄바꿈 허용 */
}

.label-text strong {
  font-weight: 700;
}

/* SEO Info Section */
.info-section {
  background: white;
  padding: 40px 20px;
  border-top: 1px solid #e5e7eb;
  margin-top: 40px;
  border-radius: 12px;
}
.content-box h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: #1f2937;
}
.content-box h3 {
  font-size: 1.25rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: #374151;
}
.content-box p {
  line-height: 1.6;
  color: #4b5563;
  margin-bottom: 1rem;
}
.content-box ul {
  padding-left: 20px;
  color: #4b5563;
  margin-bottom: 1.5rem;
}
.content-box li {
  margin-bottom: 0.5rem;
}
