/* ===== 디자인 토큰 ===== */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #e2e5ee;
  --text: #1c2030;
  --text-2: #4a5065;
  --muted: #7a8196;
  --accent: #3b5bdb;
  --accent-2: #edf1ff;
  --accent-text: #ffffff;
  --good: #2b8a3e;
  --warn: #e67700;
  --bad: #e03131;
  --c-finance: #3b5bdb;
  --c-life: #0c8599;
  --c-text: #7048e8;
  --c-pdf: #e03131;
  --c-image: #e8590c;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 4px 16px rgba(20, 24, 40, .05);
  --topbar-h: 60px;
  --sidebar-w: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141b;
    --surface: #1a1d26;
    --surface-2: #222634;
    --border: #2d3242;
    --text: #e9ebf2;
    --text-2: #b8bdcc;
    --muted: #8a90a3;
    --accent: #7491ff;
    --accent-2: #232b48;
    --accent-text: #0e1220;
    --good: #69db7c;
    --warn: #ffa94d;
    --bad: #ff8787;
    --c-finance: #7491ff;
    --c-life: #3bc9db;
    --c-text: #9775fa;
    --c-pdf: #ff8787;
    --c-image: #ff922b;
    --shadow: none;
    color-scheme: dark;
  }
}

/* ===== 기본 ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; letter-spacing: -0.02em; }
.ic { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }

/* ===== 상단바 ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); font-size: 17px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-size: 16px;
}
.search {
  margin-left: auto; position: relative; width: min(360px, 100%);
}
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 15px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--surface); }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.menu-btn { display: none; margin-left: -8px; }

/* ===== 레이아웃 ===== */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  position: sticky; top: var(--topbar-h);
  width: var(--sidebar-w); flex: none;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 16px 12px 40px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.nav-home, .sidebar li a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 15px;
}
.nav-home { font-weight: 700; color: var(--text); margin-bottom: 8px; }
.nav-home:hover, .sidebar li a:hover { background: var(--surface-2); text-decoration: none; }
.nav-home.active, .sidebar li a[aria-current="page"] { background: var(--accent-2); color: var(--accent); font-weight: 700; }
.nav-group { margin-top: 10px; }
.nav-title { display: flex; align-items: center; gap: 8px; margin: 0; padding: 6px 12px; font-size: 13px; font-weight: 700; color: var(--muted); }
.nav-title .ic { width: 16px; height: 16px; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a { padding-left: 36px; }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .4); }

.main { flex: 1; min-width: 0; max-width: 980px; margin: 0 auto; padding: 28px 32px 0; }

@media (max-width: 900px) {
  .menu-btn { display: grid; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 40; height: 100vh;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .2);
  }
  .sidebar.open { transform: none; }
  .main { padding: 20px 16px 0; }
  .topbar { padding: 0 16px; }
}
@media (max-width: 600px) {
  .brand span:last-child { display: none; }
  .search { width: auto; flex: 1; }
}

/* ===== 홈 ===== */
.hero { padding: 12px 0 8px; }
.hero h1 { font-size: clamp(28px, 4vw, 36px); margin: 6px 0 10px; }
.hero p { color: var(--text-2); margin: 0; }
.eyebrow { color: var(--accent) !important; font-weight: 700; font-size: 14px; }
.cat-section { margin-top: 36px; }
.cat-section h2 { display: flex; align-items: center; gap: 8px; font-size: 20px; margin: 0 0 14px; }
.search-empty { margin-top: 32px; padding: 32px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tool-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--text); transition: border-color .15s, transform .15s;
}
.tool-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.tool-card-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 10px; background: color-mix(in srgb, currentColor 12%, transparent); }
.tool-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tool-card-text strong { font-size: 16px; }
.tool-card-text span { font-size: 14px; color: var(--muted); line-height: 1.45; }
.cat-finance { color: var(--c-finance); }
.cat-life { color: var(--c-life); }
.cat-text { color: var(--c-text); }
.cat-pdf { color: var(--c-pdf); }
.cat-image { color: var(--c-image); }

/* ===== 도구 페이지 ===== */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.tool-head { margin: 14px 0 20px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: color-mix(in srgb, currentColor 12%, transparent); }
.tool-head h1 { font-size: clamp(26px, 3.6vw, 32px); margin: 10px 0 8px; }
.lead { margin: 0; color: var(--text-2); }

.tool-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}
@media (max-width: 600px) { .tool-panel { padding: 18px 16px; } }

.ad-slot { margin: 24px 0; min-height: 90px; }

/* 폼 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .unit { position: absolute; right: 12px; color: var(--muted); font-size: 14px; pointer-events: none; }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
.input-wrap input { padding-right: 52px; text-align: right; font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; line-height: 1.7; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.seg button {
  border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 15px; font-weight: 600;
  padding: 8px 14px; border-radius: 9px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.seg-row { margin-bottom: 20px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }

/* 결과 */
.result { margin-top: 24px; padding: 20px; border-radius: var(--radius); background: var(--accent-2); }
.result-main { font-size: 15px; color: var(--text-2); margin: 0; }
.result-main strong { display: block; font-size: clamp(26px, 4vw, 32px); color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.stat { padding: 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.stat span { display: block; font-size: 13px; color: var(--muted); }
.stat b { font-size: 20px; font-variant-numeric: tabular-nums; }
.error { color: var(--bad); font-weight: 600; margin: 12px 0 0; }

.table-wrap { overflow-x: auto; margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 480px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 700; color: var(--text-2); }
td:first-child, th:first-child { text-align: center; }
tr:last-child td { border-bottom: 0; }

/* 파일 드롭존 */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 180px; padding: 24px; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-2);
  color: var(--text-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-2); }
.dropzone .ic { width: 36px; height: 36px; color: var(--accent); }
.dropzone strong { color: var(--text); font-size: 17px; }
.file-list { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 8px; }
.file-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.file-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-list .meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.file-list .order { color: var(--muted); font-weight: 700; width: 22px; text-align: center; }
.file-list .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.mini-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 7px; width: 32px; height: 32px; cursor: pointer; font-size: 15px; }
.mini-btn:hover { background: var(--surface-2); }
.mini-btn:disabled { opacity: .35; cursor: default; }

/* BMI 게이지 등 */
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: 15px; background: var(--surface); }
.meter { position: relative; height: 12px; border-radius: 999px; margin: 18px 0 6px; display: flex; overflow: hidden; }
.meter i { display: block; height: 100%; }
.meter-pin { position: absolute; top: -5px; width: 4px; height: 22px; border-radius: 2px; background: var(--text); transform: translateX(-2px); transition: left .3s; }
.meter-wrap { position: relative; }
.meter-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* ===== 본문 가이드 ===== */
.guide { margin-top: 40px; color: var(--text-2); }
.guide h2 { color: var(--text); font-size: 21px; margin: 36px 0 12px; }
.guide h3 { color: var(--text); font-size: 17px; margin: 24px 0 8px; }
.guide p, .guide li { line-height: 1.8; }
.steps { padding-left: 22px; }
.steps li { margin-bottom: 6px; }
.steps li::marker { color: var(--accent); font-weight: 800; }
.guide table { display: block; max-width: 100%; overflow-x: auto; margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.guide table td, .guide table th { text-align: center; white-space: normal; min-width: 90px; }
.guide code { font-size: 14px; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.note { padding: 14px 16px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.faq details { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 8px; }
.faq summary { cursor: pointer; padding: 14px 16px; font-weight: 700; color: var(--text); }
.faq details p { margin: 0; padding: 0 16px 14px; }
.updated { font-size: 13px; color: var(--muted); margin-top: 28px; }
.prose h1 { color: var(--text); font-size: 30px; }
.related { margin-top: 40px; }
.related h2 { font-size: 20px; }

/* ===== 푸터 ===== */
.footer { margin-top: 64px; padding: 28px 0 40px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.footer nav { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 10px; }
.footer nav a { color: var(--text-2); font-weight: 600; }
.footer p { margin: 4px 0; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
