:root {
  --ink: #17212b;
  --muted: #4a5866;
  --line: #d5dde5;
  --bg: #f6f8fa;
  --card: #ffffff;
  --accent: #0b5cad;
  --accent-dark: #084783;
  --ok: #0f6b3d;
  --err: #a4161a;
  --err-bg: #fff1f1;
  --focus: #f0a500;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 17px;
  line-height: 1.55;
}

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

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: #fff; padding: 12px 16px; z-index: 20;
}
.skip:focus { left: 8px; top: 8px; }

.top {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 22px 0 18px;
}
.brand { margin: 0 0 4px; font-weight: 700; color: var(--accent); font-size: 15px; letter-spacing: .01em; }
.ver { color: var(--muted); font-weight: 500; }
h1 { margin: 0 0 8px; font-size: 26px; line-height: 1.3; letter-spacing: -.01em; }
.sub { margin: 0 0 10px; color: var(--muted); font-size: 16px; }
.privacy {
  margin: 0; padding: 10px 12px;
  background: #eef5fc; border-left: 4px solid var(--accent);
  font-size: 14px; color: #24455f;
}

.tabs-wrap {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.tabs {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 0 16px 4px;
  max-width: 980px; margin: 0 auto;
  scrollbar-width: thin;
}
.tabs button {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.tabs button[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

main { padding: 22px 0 40px; }

.panel { outline: none; }
.panel h2 { margin: 0 0 4px; font-size: 22px; }
.lead { margin: 0 0 18px; color: var(--muted); }

form { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 700; font-size: 16px; padding: 0; margin-bottom: 12px; }

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

label { display: block; font-size: 15px; font-weight: 600; color: #2b3a48; }
input, select {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #b9c5d1;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 17px;
  font-family: inherit;
}
input:focus, select:focus, button:focus-visible, .tabs button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
input[aria-invalid="true"] { border-color: var(--err); background: var(--err-bg); }

.actions { display: flex; gap: 10px; margin-top: 18px; }
button.primary, button.ghost {
  min-height: 50px;
  padding: 0 22px;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
button.primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
button.primary:hover { background: var(--accent-dark); }
button.ghost { background: #fff; color: var(--ink); border: 1px solid #b9c5d1; }

.error-summary {
  margin: 14px 0 0;
  padding: 12px 14px;
  background: var(--err-bg);
  border: 1px solid #e7b4b4;
  border-left: 4px solid var(--err);
  border-radius: 8px;
  color: #721214;
  font-size: 15px;
}
.error-summary ul { margin: 6px 0 0; padding-left: 20px; }

.result-slot { margin-top: 18px; }

.result {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}
.result h3 { margin: 0 0 4px; font-size: 17px; color: var(--muted); font-weight: 700; }
.result .main {
  margin: 0 0 14px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--accent-dark);
  word-break: keep-all;
}
.result table { width: 100%; border-collapse: collapse; font-size: 16px; }
.result th, .result td { padding: 9px 0; border-bottom: 1px solid #edf1f4; text-align: left; }
.result th { color: var(--muted); font-weight: 600; width: 58%; }
.result td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.result tr.total th, .result tr.total td { border-bottom: 0; color: var(--ink); font-size: 17px; }
.result .note { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.result .tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.result .tools button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #b9c5d1;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.result .tools button:hover { background: #eef5fc; }
.copied { color: var(--ok); font-size: 14px; font-weight: 700; align-self: center; }

.assume { margin: 14px 2px 0; font-size: 14px; color: var(--muted); }

.foot { border-top: 1px solid var(--line); background: var(--card); padding: 18px 0 28px; }
.foot p { margin: 0 0 6px; font-size: 13px; color: var(--muted); }

/* 상단 메뉴 */
.site-nav {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.site-nav .wrap {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px 18px; padding-top: 6px; padding-bottom: 6px;
}
.site-nav .home {
  display: inline-flex; align-items: center;
  min-height: 44px; margin-right: auto;
  color: var(--accent-dark); font-weight: 800; font-size: 15px;
  text-decoration: none; letter-spacing: .01em;
}
.site-nav a {
  display: inline-flex; align-items: center; min-height: 44px;
  color: #2b3a48; font-size: 15px; font-weight: 600; text-decoration: none;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); text-decoration: underline; }

/* 해설 페이지 */
.doc { max-width: 760px; }
.doc h1 { margin-bottom: 10px; }
.doc h2 { margin: 30px 0 8px; font-size: 21px; }
.doc h3 { margin: 22px 0 6px; font-size: 18px; }
.doc p, .doc li { font-size: 16px; color: #22303c; }
.doc ul, .doc ol { padding-left: 22px; }
.doc li { margin-bottom: 6px; }
.doc .lead { font-size: 17px; }
.doc table { width: 100%; border-collapse: collapse; margin: 12px 0 6px; font-size: 15px; background: var(--card); }
.doc caption { caption-side: top; text-align: left; font-size: 14px; color: var(--muted); padding-bottom: 6px; }
.doc th, .doc td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.doc thead th { background: #eef5fc; }
.doc tbody td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.doc .formula {
  margin: 12px 0; padding: 12px 14px;
  background: #f2f6fa; border-left: 4px solid var(--accent);
  font-size: 16px; font-weight: 600; color: #17384f;
  word-break: keep-all;
}
.doc .note-box {
  margin: 14px 0; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); font-size: 15px;
}
.doc .note-box strong { color: var(--accent-dark); }
.crumbs { margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.doc .cta {
  display: inline-flex; align-items: center; min-height: 48px;
  margin: 8px 0 0; padding: 0 18px;
  border-radius: 10px; background: var(--accent); color: #fff;
  font-weight: 700; text-decoration: none;
}

/* 해설 목록 카드 */
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 16px 0 8px; padding: 0; list-style: none; }
.cards li { margin: 0; }
.cards a {
  display: block; height: 100%; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  text-decoration: none; color: var(--ink);
}
.cards a:hover { border-color: var(--accent); }
.cards .name { display: block; font-weight: 700; font-size: 16px; color: var(--accent-dark); }
.cards .desc { display: block; margin-top: 4px; font-size: 14px; color: var(--muted); }

.panel.section-gap { margin-top: 32px; }
.panel.section-gap ul { padding-left: 22px; }
.panel.section-gap li { margin-bottom: 6px; font-size: 16px; }

/* 광고 자리: 비어 있으면 자리를 차지하지 않는다 */
.ad-slot { margin: 24px 0 0; }
.ad-slot:empty { margin: 0; }
.ad-slot .ad-label { margin: 0 0 6px; font-size: 12px; color: var(--muted); }

.foot .links { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.foot .links a { display: inline-flex; align-items: center; min-height: 44px; color: #2b3a48; font-size: 14px; font-weight: 600; text-decoration: none; }
.foot .links a:hover { color: var(--accent); text-decoration: underline; }

@media (min-width: 720px) {
  .cards { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 720px) {
  h1 { font-size: 32px; }
  .grid { grid-template-columns: 1fr 1fr; }
  form { padding: 24px; }
  .result { padding: 22px; }
  .result .main { font-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

@media print {
  body { background: #fff; font-size: 12pt; }
  .site-nav, .top, .tabs-wrap, .actions, .foot, .assume, .result .tools, .skip, .ad-slot { display: none !important; }
  main { padding: 0; }
  .panel[hidden] { display: none !important; }
  form { display: none !important; }
  .result { border: 0; padding: 0; }
  .result .main { color: #000; font-size: 20pt; }
  .result th, .result td { border-bottom: 1px solid #999; }
}
