:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --text: #1a1f2c;
  --muted: #5d6679;
  --border: #e2e7f0;
  --primary: #2b5cff;
  --primary-soft: #e8eeff;
  --accent: #10b981;
  --danger: #ef4444;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(20, 40, 90, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131b;
    --surface: #171c27;
    --surface-2: #1f2533;
    --text: #e8ecf4;
    --muted: #98a2b5;
    --border: #2a3142;
    --primary: #6b8cff;
    --primary-soft: #1f2a4d;
    --accent: #34d399;
    --shadow: none;
  }
}

* { 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", sans-serif;
  line-height: 1.7;
  word-break: keep-all;
}
a { color: var(--primary); }
.container { max-width: 880px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
#site-header { min-height: 61px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 0.9rem; }
.nav { display: flex; align-items: center; gap: 6px; }
.nav-link, .nav-cat {
  color: var(--muted); text-decoration: none; font-size: 0.95rem; background: none; border: 0; cursor: pointer;
  font-family: inherit; padding: 8px 12px; border-radius: 8px; display: flex; align-items: center; gap: 4px;
}
.nav-link:hover, .nav-cat:hover, .nav-link[aria-current="page"], .nav-group.active > .nav-cat { color: var(--primary); }
.nav-cat:hover, .nav-link:hover { background: var(--surface-2); }
.caret { font-size: 0.7rem; }
.nav-group { position: relative; }
.dropdown {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 30px rgba(20, 40, 90, 0.12);
}
.nav-group:hover .dropdown, .nav-group:focus-within .dropdown, .nav-group.open .dropdown { display: block; }
.nav-group::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 6px; } /* hover 틈 메우기 */
.dropdown a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 0.93rem; }
.dropdown a:hover, .dropdown a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.menu-toggle { display: none; background: none; border: 0; font-size: 1.4rem; color: var(--text); cursor: pointer; width: 44px; height: 44px; }

/* Home: tool cards */
.search-box { max-width: 480px; margin: 18px auto 0; }
.tool-section { margin-bottom: 28px; }
.tool-section h2 { font-size: 1.1rem; display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tool-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s;
}
.tool-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.tool-card[hidden], .tool-section[hidden] { display: none; }
.tool-icon { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; }
.tool-icon.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 0.85rem; }
.tool-text { display: flex; flex-direction: column; gap: 2px; }
.tool-text span { color: var(--muted); font-size: 0.87rem; line-height: 1.5; }
.content .tool-grid .tool-card { background: var(--surface-2); }

/* Hero */
.hero { text-align: center; padding: 40px 0 24px; }
.hero h1 { font-size: clamp(1.6rem, 5vw, 2.3rem); margin: 0 0 8px; letter-spacing: -0.02em; }
.hero p { color: var(--muted); margin: 0; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 24px; }
.card h2 { margin-top: 0; font-size: 1.3rem; }

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: 0.95rem; }
.field .hint { font-size: 0.82rem; color: var(--muted); }
.input-wrap { position: relative; }
.input-wrap .unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
input[type="text"], select {
  width: 100%; padding: 12px 14px; font-size: 1rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-family: inherit;
}
input[type="text"]:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; background: var(--surface); }
#salary { font-size: 1.3rem; font-weight: 700; padding-right: 40px; }
.salary-korean { font-size: 0.9rem; color: var(--primary); min-height: 1.4em; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button, .seg button {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px;
  padding: 6px 12px; font-size: 0.85rem; cursor: pointer; font-family: inherit;
}
.quick button:hover { border-color: var(--primary); color: var(--primary); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; border-radius: 10px; padding: 10px; }
.seg button.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* Result */
.result-main { text-align: center; padding: 8px 0 20px; border-bottom: 1px dashed var(--border); margin-bottom: 16px; }
.result-main .label { color: var(--muted); font-size: 0.95rem; }
.result-main .amount { font-size: clamp(2rem, 8vw, 2.8rem); font-weight: 800; color: var(--primary); letter-spacing: -0.02em; line-height: 1.2; }
.result-main .sub { color: var(--muted); font-size: 0.92rem; margin-top: 4px; }
.bar { height: 10px; border-radius: 999px; background: var(--primary-soft); overflow: hidden; margin: 14px 0 6px; display: flex; }
.bar span { display: block; height: 100%; background: var(--danger); opacity: 0.85; }
.bar-legend { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); }
.breakdown { width: 100%; border-collapse: collapse; }
.breakdown td { padding: 9px 4px; border-bottom: 1px solid var(--border); }
.breakdown td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.breakdown tr.total td { font-weight: 700; border-bottom: none; color: var(--danger); }
.breakdown tr.net td { font-weight: 800; color: var(--primary); font-size: 1.05rem; border-bottom: none; }
.breakdown .rate { color: var(--muted); font-size: 0.82rem; margin-left: 4px; }

/* Content */
.content h2 { font-size: 1.3rem; margin-top: 0; }
.content h3 { font-size: 1.08rem; margin-bottom: 4px; }
.content p, .content li { color: var(--text); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 480px; }
.data-table th, .data-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; }
.data-table th { background: var(--surface-2); font-weight: 600; text-align: right; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.note { font-size: 0.85rem; color: var(--muted); }

details { border-bottom: 1px solid var(--border); padding: 14px 0; }
details summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
details summary::after { content: "+"; color: var(--muted); font-size: 1.2rem; line-height: 1; }
details[open] summary::after { content: "−"; }
details p { margin: 10px 0 0; color: var(--muted); }

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

/* Text tools */
textarea {
  width: 100%; min-height: 260px; padding: 14px; font-size: 1rem; line-height: 1.7; resize: vertical;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); font-family: inherit;
}
textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; background: var(--surface); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-top: 10px; }
.toolbar .left, .toolbar .right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px;
  padding: 8px 14px; font-size: 0.9rem; cursor: pointer; font-family: inherit;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { opacity: 0.9; color: #fff; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 14px; }
.stat .k { font-size: 0.85rem; color: var(--muted); }
.stat .v { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat .v small { font-size: 0.85rem; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat.main { background: var(--primary-soft); }
.stat.main .v { color: var(--primary); }
.limit-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.limit-row input { width: 120px; }
.limit-row select { width: auto; }
.limit-bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.limit-bar span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .15s; }
.limit-bar.over span { background: var(--danger); }
.limit-msg { font-size: 0.9rem; margin-top: 6px; color: var(--muted); }
.limit-msg.over { color: var(--danger); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 0.9rem; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
.toast.show { opacity: 1; }

/* Ad slot: 승인 후 광고 코드를 넣으면 표시됩니다 */
.ad-slot { margin: 0 0 24px; text-align: center; }
.ad-slot:empty { display: none; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 28px 0; margin-top: 40px; font-size: 0.88rem; color: var(--muted); }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 20px; margin-bottom: 16px; }
.footer-col { display: flex; flex-direction: column; gap: 6px; }
.footer-col h4 { margin: 0 0 4px; color: var(--text); font-size: 0.92rem; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--primary); }

/* Article pages */
.article { padding-top: 32px; }
.article h1 { font-size: clamp(1.5rem, 5vw, 2rem); letter-spacing: -0.02em; }
.article .meta { color: var(--muted); font-size: 0.88rem; margin-top: -8px; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 18px; }
}
@media (max-width: 720px) {
  .menu-toggle { display: block; }
  .nav {
    display: none; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 16px; box-shadow: 0 12px 24px rgba(20, 40, 90, 0.08);
    max-height: calc(100vh - 60px); overflow-y: auto;
  }
  .nav.open { display: flex; }
  .nav-cat { width: 100%; font-weight: 700; color: var(--text); padding: 12px 4px 4px; pointer-events: none; }
  .caret { display: none; }
  .nav-group::after { display: none; }
  .dropdown { display: block; position: static; box-shadow: none; border: 0; padding: 0 0 4px; min-width: 0; }
  .nav-link { padding: 12px 4px; border-top: 1px solid var(--border); margin-top: 8px; }
}
