/* funtools — 공통 스타일. 모바일 360px 기준. */

:root {
  --accent: #FF5B34;
  --accent-dark: #E5431E;
  --accent-soft: #FFF1EC;
  --bg: #FFFFFF;
  --surface: #F7F7F5;
  --text: #191919;
  --muted: #6B6B6B;
  --line: #E7E6E3;

  --c-money: #2E7D52;
  --c-date: #2F6BFF;
  --c-food: #F08000;
  --c-fun: #8B5CF6;
  --c-life: #0E7C86;

  --r: 14px;
  --sp: 8px;
  --max: 640px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #FF7654;
    --accent-dark: #FF9070;
    --accent-soft: #2A1A15;
    --bg: #141414;
    --surface: #1E1E1E;
    --text: #F2F2F0;
    --muted: #A0A0A0;
    --line: #2E2E2E;
    --c-money: #5FBF8A;
    --c-date: #6D9BFF;
    --c-food: #FFA53D;
    --c-fun: #A98BFF;
    --c-life: #3FBFCB;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }

/* ── 헤더 ───────────────────────────── */
header.top {
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
}
header.top .wrap {
  display: flex; align-items: center; gap: 10px;
  height: 52px;
}
header.top a.logo {
  font-weight: 800; font-size: 17px; letter-spacing: -0.02em;
  color: var(--text); text-decoration: none;
}
header.top a.logo span { color: var(--accent); }
header.top nav { margin-left: auto; font-size: 14px; }
header.top nav a { color: var(--muted); text-decoration: none; }

/* ── 도구 페이지 ────────────────────── */
h1 {
  font-size: 25px; line-height: 1.3; letter-spacing: -0.03em;
  margin: 24px 0 8px; font-weight: 800;
}
.lead { color: var(--muted); font-size: 15px; margin: 0 0 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block; font-size: 14px; font-weight: 700;
  margin-bottom: 6px; color: var(--text);
}

input[type="number"], input[type="text"], input[type="date"], textarea, select {
  width: 100%; padding: 12px 14px;
  font: inherit; font-size: 16px; /* iOS 확대 방지 */
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

.ymd { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 6px; }
.ymd select { padding-right: 26px; background-position: calc(100% - 12px) 50%, calc(100% - 7px) 50%; }

.with-unit { position: relative; }
.with-unit .unit {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px; pointer-events: none;
}
.with-unit input { padding-right: 46px; }

/* 버튼형 선택 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  cursor: pointer; min-height: 40px;
}
.chips button[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ── 결과 ───────────────────────────── */
.result {
  margin: 16px 0 0; padding: 24px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--r);
  text-align: center;
}
.result .big {
  font-size: 52px; font-weight: 800; line-height: 1.1;
  letter-spacing: -0.04em; color: var(--accent-dark);
  overflow-wrap: anywhere; white-space: pre-line;
}
.result .big.sm { font-size: 27px; }
.result .big .u { font-size: 0.5em; font-weight: 700; margin-left: 2px; }
.result .suffix { font-size: 17px; font-weight: 700; margin-top: 2px; }
.result .note { font-size: 13px; color: var(--muted); margin-top: 10px; }
.result .warn {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line);
  font-size: 13px; text-align: left; color: var(--text);
}

.sub { margin: 12px 0 0; padding: 0; list-style: none; }
.sub li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line);
  font-size: 14px;
}
.sub li b { font-weight: 700; text-align: right; }
.sub li span { color: var(--muted); flex-shrink: 0; }

.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions button {
  flex: 1; font: inherit; font-size: 15px; font-weight: 700;
  padding: 13px; border-radius: 10px; cursor: pointer; min-height: 48px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.actions button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ── 다음 도구 ──────────────────────── */
.related { margin: 28px 0; }
.related h2 { font-size: 16px; margin: 0 0 10px; }
.related a {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; color: var(--text); font-size: 15px; font-weight: 600;
}
.related a .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.related a .arrow { margin-left: auto; color: var(--muted); }

/* ── 광고 (반드시 결과 아래) ─────────── */
.ad {
  margin: 24px 0; min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line); border-radius: var(--r);
  color: var(--muted); font-size: 12px;
}

/* 애드핏은 반응형이 없어 모바일·PC 광고를 따로 두고 CSS 로 전환한다.
   광고 소재가 대부분 흰 배경이라 다크모드에서 튄다 → 카드로 감싸서 얹는다. */
.ad-live {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); min-height: 0; padding: 12px;
  overflow: hidden; text-align: center;
}
.ad-live::before {
  content: '광고'; display: block;
  font-size: 11px; color: var(--muted); text-align: left;
  margin-bottom: 8px; letter-spacing: 0.02em;
}
.ad-live ins { max-width: 100%; }
.adfit-pc { display: none !important; }
@media (min-width: 760px) {
  .adfit-m { display: none !important; }
  .adfit-pc { display: inline-block !important; }
}

/* ── 쿠팡 추천 상품 ─────────────────── */
.shop { margin: 28px 0; }
.shop h2 { font-size: 16px; margin: 0 0 10px; }
.shop a {
  display: flex; align-items: center; gap: 12px; padding: 14px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; color: var(--text);
}
.shop a .ico { flex: 0 0 48px; }
.shop a .ico svg { display: block; width: 48px; height: 48px; }
.shop a .txt { min-width: 0; }
.shop a strong { display: block; font-size: 15px; font-weight: 700; }
.shop a em {
  display: block; font-style: normal; font-size: 13px;
  color: var(--muted); margin-top: 3px;
}
.shop a .arrow {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--accent-dark); margin-top: 8px;
}
.shop .disc { font-size: 12px; color: var(--muted); margin: 10px 0 0; }

/* ── 설명 ───────────────────────────── */
.about { margin: 28px 0; }
.about h2 { font-size: 16px; margin: 0 0 10px; }
.about details {
  border-top: 1px solid var(--line); padding: 12px 0;
}
.about details summary {
  font-size: 15px; font-weight: 600; cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 8px;
}
.about details summary::-webkit-details-marker { display: none; }
.about details summary::after { content: '+'; margin-left: auto; color: var(--muted); }
.about details[open] summary::after { content: '−'; }
.about details p { font-size: 14px; color: var(--muted); margin: 8px 0 0; }

/* ── 홈 ─────────────────────────────── */
.hero { padding: 28px 0 20px; }
.hero .mascot { display: block; width: 72px; height: 72px; margin: 0 0 10px -4px; }
.hero h1 { font-size: 30px; margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0; }

.search { margin: 4px 0 24px; }
.search input { font-size: 16px; }

.group { margin-bottom: 26px; }
.group h2 {
  font-size: 15px; margin: 0 0 10px;
  display: flex; align-items: center; gap: 7px;
}
.group h2 .dot { width: 9px; height: 9px; border-radius: 50%; }
.grid { display: grid; grid-template-columns: 1fr; gap: 6px; }
@media (min-width: 520px) { .grid { grid-template-columns: 1fr 1fr; } }
.grid a {
  display: block; padding: 14px;
  border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; color: var(--text);
}
.grid a strong { display: block; font-size: 15px; font-weight: 700; }
.grid a em {
  display: block; font-style: normal; font-size: 13px;
  color: var(--muted); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.empty { color: var(--muted); font-size: 14px; padding: 20px 0; }

/* ── 푸터 ───────────────────────────── */
footer {
  border-top: 1px solid var(--line); margin-top: 40px;
  padding: 20px 0 40px; font-size: 13px; color: var(--muted);
}
footer a { color: var(--muted); }
footer .disc { margin-top: 8px; font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50;
}
.toast.on { opacity: 1; }

article h2 { letter-spacing: -0.02em; }
