/* ==========================================================================
   소모품 실단가 계산기 — 스타일
   모바일 우선 1열 · 큰 터치 영역 · 라이트/다크 지원
   ========================================================================== */

:root {
  --brand: #0f766e;
  --brand-strong: #0b5d57;
  --brand-soft: #e6f4f1;
  --brand-ink: #06403c;

  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f0f3f2;
  --border: #dfe5e2;
  --border-strong: #c9d2ce;

  --text: #14201d;
  --text-muted: #5d6b67;
  --danger: #b42318;
  --danger-soft: #fdecea;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --result-from: #0f766e;
  --result-to: #0b5d57;
  --result-ink: #ffffff;
  --shadow: 0 1px 2px rgba(16, 33, 30, .04), 0 8px 24px rgba(16, 33, 30, .06);
  --tab-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #2dd4bf;
    --brand-strong: #5eead4;
    --brand-soft: #10312e;
    --brand-ink: #052e2b;

    --bg: #0d1211;
    --surface: #151d1b;
    --surface-2: #1c2523;
    --border: #2a3532;
    --border-strong: #3a4643;

    --text: #e8efec;
    --text-muted: #9babA6;
    --danger: #ff9b90;
    --danger-soft: #3a1b17;
    --result-from: #115e59;
    --result-to: #0a3f3b;
    --result-ink: #f0fdfa;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

/* hidden 속성이 display 규칙에 밀리지 않게 합니다 (예: .result-row { display:flex }) */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
    "Malgun Gothic", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 18px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
  z-index: 100;
  border-radius: 0 0 10px 0;
}
.skip-link:focus { left: 0; }

/* ------------------------------------------------------------- 헤더 */

.site-header {
  padding: 34px 0 22px;
  background:
    radial-gradient(120% 100% at 50% 0%, var(--brand-soft) 0%, transparent 70%);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--brand);
}

.site-header h1 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: -.02em;
}

.lede {
  margin: 0;
  font-size: 15.5px;
  color: var(--text-muted);
}
.lede strong { color: var(--text); }

/* ------------------------------------------------------- 모드 탭 */

.mode-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 4px 0 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.mode-tab {
  flex: 1;
  min-height: 46px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.mode-tab.is-active {
  background: var(--surface);
  color: var(--brand-strong);
  box-shadow: 0 1px 2px rgba(16, 33, 30, .08);
}
.mode-tab:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.mode-pane { display: block; }

/* ------------------------------------------------------- 카드 공통 */

.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* --- 프리셋 칩 --- */

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.chip {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.chip.is-active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-strong);
}
.chip:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.preset-hint {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--text-muted);
  min-height: 1.5em;
}

/* --- 입력 필드 --- */

.calc-form { display: grid; gap: 18px; }

.field { display: grid; gap: 8px; }
.field + .field { margin: 0; }

.field-label { display: grid; gap: 8px; }

.label-text {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
}

.optional {
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text-muted);
}

.input-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 54px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--text-muted); opacity: .55; font-size: 15px; }
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.input:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}
.input.is-invalid {
  border-color: var(--danger);
  background: var(--danger-soft);
}

/* 숫자 입력의 스피너 제거 */
.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.unit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.unit-select {
  min-height: 54px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* --- 세그먼트 버튼 --- */

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.seg {
  flex: 1 1 0;
  min-height: 44px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.seg.is-active {
  background: var(--surface);
  color: var(--brand-strong);
  box-shadow: 0 1px 2px rgba(16, 33, 30, .1);
}
.seg:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.seg-small .seg { font-size: 13px; min-height: 42px; }

/* --- 오류 --- */

.error {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--danger);
}

/* ------------------------------------------------------- 결과 카드 */

.result {
  margin-top: 20px;
  padding: 20px;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, var(--result-from) 0%, var(--result-to) 100%);
  color: var(--result-ink);
}

.result-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .04em;
  opacity: .85;
}

.result-big {
  margin: 2px 0 14px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}

.result-big strong {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.result-unit {
  font-size: 17px;
  font-weight: 700;
  opacity: .9;
}

.result-error {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .16);
  font-size: 13.5px;
  font-weight: 600;
}

.result-rows {
  display: grid;
  gap: 1px;
  margin: 0;
  background: rgba(255, 255, 255, .18);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, .14);
}

.result-row dt {
  font-size: 13.5px;
  opacity: .9;
}

.result-row dd {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.formula {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, .18);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  word-break: break-word;
}

/* ------------------------------------------------------- 비교 모드 */

.compare-grid {
  display: grid;
  gap: 14px;
}

.compare-col { position: relative; }
.compare-host { display: block; }
.compare-col.is-a {
  --col-accent: var(--brand);
}

.compare-badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
}
.compare-col.is-b .compare-badge {
  background: color-mix(in srgb, #d97706 16%, var(--surface));
  color: #b45309;
}
@media (prefers-color-scheme: dark) {
  .compare-col.is-b .compare-badge { color: #fbbf24; }
}

.compare-col .calc-card { padding: 14px; }
.compare-col .result-big strong { font-size: 28px; }
.compare-col .result { padding: 16px; }

.compare-result {
  margin-top: 18px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.compare-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: .02em;
}

.compare-verdict {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.4;
  color: var(--brand-strong);
  word-break: keep-all;
}

.compare-sub {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

.compare-table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.compare-table th,
.compare-table td {
  padding: 10px 8px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.compare-table thead th {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 700;
}
.compare-table th[scope="row"] {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
}
.compare-table tbody tr:last-child th,
.compare-table tbody tr:last-child td { border-bottom: 0; }

/* ------------------------------------------------------- 가이드 */

.guide, .faq, .recommend {
  margin: 34px 0 0;
}

.guide h2, .faq h2, .recommend h2 {
  margin: 0 0 6px;
  font-size: 19px;
  letter-spacing: -.01em;
}

.section-lede {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--text-muted);
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.guide-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 14px;
}
.guide-table th, .guide-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.guide-table thead th {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
  white-space: nowrap;
}
.guide-table tbody tr:last-child th,
.guide-table tbody tr:last-child td { border-bottom: 0; }
.guide-table tbody th { font-weight: 700; white-space: nowrap; }
.guide-table td:nth-child(2) { color: var(--text-muted); }

.guide-note {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ------------------------------------------------------- FAQ */

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 16px;
  margin-bottom: 8px;
}
.faq summary {
  cursor: pointer;
  padding: 14px 0;
  font-size: 15px;
  font-weight: 700;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  color: var(--brand);
  font-weight: 800;
}
.faq details[open] summary::after { content: "−"; }
.faq details p {
  margin: 0 0 14px;
  font-size: 14.5px;
  color: var(--text-muted);
}

/* ------------------------------------------------------- 푸터 */

.site-footer {
  margin-top: 44px;
  padding: 26px 0 40px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}
.site-footer p { margin: 0 0 6px; }
.site-footer .privacy { opacity: .85; }

.notice {
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 14px;
  font-weight: 600;
}

/* ------------------------------------------------------- 추천 슬롯 (활성 시) */

.recommend {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.recommend-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.recommend-list li {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 14.5px;
}
.recommend-list a {
  color: var(--brand-strong);
  font-weight: 700;
  text-decoration: none;
}
.recommend-list a:hover { text-decoration: underline; }
.recommend-note { color: var(--text-muted); font-size: 13px; }
.recommend-disclosure {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ------------------------------------------------------- 반응형 */

@media (min-width: 640px) {
  .site-header { padding: 48px 0 28px; }
  .site-header h1 { font-size: 38px; }
  .lede { font-size: 17px; }
  .calc-card { padding: 22px; }
  .compare-grid { grid-template-columns: 1fr 1fr; }
  .result-big strong { font-size: 44px; }
}

@media (max-width: 380px) {
  .grid-2 { grid-template-columns: 1fr; }
  .result-big strong { font-size: 34px; }
  .compare-verdict { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
