/* 메인페이지 (mainpage.co.kr) - 돈 계산기와 시작페이지.
   Concept: a pay slip. Inputs on the left, the result printed as an itemized statement on
   torn-edge paper on the right, its total underlined in seal red. Pretendard throughout.
   Tokens use html:root so they win over the shared site CSS that loads after this file. */
html:root {
  --bg: #eef2f4; --surface: #ffffff; --text: #17212b; --muted: #56626e; --line: #d5dde3;
  --accent: #0b6e5f; --on-accent: #ffffff; --seal: #c0362c; --paper: #fffef9; --mark: #e6f3ef;
}
@media (prefers-color-scheme: dark) {
  html:root {
    --bg: #0f1519; --surface: #172026; --text: #e4eaee; --muted: #98a6b0; --line: #2a3740;
    --accent: #52c4ab; --on-accent: #0f1519; --seal: #ff8173; --paper: #1d272e; --mark: #1d3a33;
  }
}
[hidden] { display: none !important; }   /* .calc-form label sets display:grid, which would override hidden */
body.tools header.site, body.tools main, body.tools footer { max-width: 1080px; }
body.tools header.site { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.today { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.num, .stmt dd, .schedule td { font-variant-numeric: tabular-nums; }

/* --- start page --- */
.search { display: grid; gap: 10px; margin: 8px 0 36px; }
.search h1 { font-size: clamp(1.5rem, 4vw, 2rem); margin: 0; }
.engines { display: flex; gap: 6px; flex-wrap: wrap; }
.engines button { font: inherit; font-size: 0.9rem; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 4px 14px; cursor: pointer; }
.engines button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.search-row { display: flex; border: 2px solid var(--text); border-radius: 14px; background: var(--surface); overflow: hidden; }
.search-row input { flex: 1; min-width: 0; font: inherit; font-size: 1.15rem; border: 0; padding: 14px 18px; background: transparent; color: var(--text); }
.search-row button { font: inherit; font-weight: 700; border: 0; background: var(--text); color: var(--bg); padding: 0 22px; cursor: pointer; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 36px; align-items: start; }
@media (max-width: 760px) { .home-grid { grid-template-columns: 1fr; } }
.home-grid h2 { margin-top: 0; }
.tool-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--text); }
.tool-list li { border-bottom: 1px solid var(--line); }
.tool-list a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 4px; text-decoration: none; color: var(--text); }
.tool-list a:hover strong { text-decoration: underline; }
.tool-list strong { font-size: 1.08rem; }
.tool-list span { grid-column: 1 / -1; color: var(--muted); font-size: 0.92rem; }
.tool-list em { font-style: normal; font-size: 0.8rem; color: var(--accent); align-self: center; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.feed a { color: var(--text); font-weight: 600; text-decoration: none; }
.feed a:hover { text-decoration: underline; }
.feed small { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.links a { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.92rem; }
.links a:hover { border-color: var(--text); }
#favorites ul { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 8px; }
#favorites li { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
#favorites li a { padding: 6px 4px 6px 12px; color: var(--text); text-decoration: none; font-size: 0.92rem; }
#favorites li button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px 10px; font-size: 1rem; }
#favorites li.empty { border: 0; background: none; color: var(--muted); font-size: 0.9rem; }
#favorites form { display: flex; gap: 8px; flex-wrap: wrap; }
#favorites input { font: inherit; font-size: 0.92rem; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--surface); color: var(--text); min-width: 0; flex: 1 1 140px; }
#favorites form button, .calc-form button { font: inherit; font-weight: 700; border: 0; border-radius: 8px; padding: 7px 16px; background: var(--accent); color: var(--on-accent); cursor: pointer; }
.about { color: var(--muted); font-size: 0.95rem; max-width: 70ch; }

/* --- calculator page --- */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; margin: 8px 0 12px; }
@media (max-width: 820px) { .calc { grid-template-columns: 1fr; } }
.calc-form { display: grid; gap: 16px; }
.calc-form label { display: grid; gap: 6px; font-weight: 600; }
.calc-form label small { font-weight: 400; color: var(--muted); }
.calc-form input, .calc-form select { font: inherit; font-size: 1.05rem; border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px;
  background: var(--surface); color: var(--text); width: 100%; min-width: 0; }
.calc-form input[data-money], .calc-form input[inputmode="decimal"], .calc-form input[inputmode="numeric"] { text-align: right; font-variant-numeric: tabular-nums; }
.calc-form input:focus-visible, .calc-form select:focus-visible, .search-row input:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.seg { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { flex: 1; display: block; text-align: center; padding: 10px; cursor: pointer; font-weight: 600; background: var(--surface); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:has(input:checked) { background: var(--text); color: var(--bg); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: -3px; }

/* the statement: torn paper, dotted leaders, seal-red total */
.calc-result { position: sticky; top: 16px; background: var(--paper); padding: 26px 24px 30px; filter: drop-shadow(0 2px 6px rgba(20, 30, 40, 0.12));
  -webkit-mask: linear-gradient(#000 0 0) top/100% calc(100% - 10px) no-repeat, radial-gradient(circle at 6px 10px, transparent 5px, #000 5.5px) bottom/12px 10px repeat-x;
          mask: linear-gradient(#000 0 0) top/100% calc(100% - 10px) no-repeat, radial-gradient(circle at 6px 10px, transparent 5px, #000 5.5px) bottom/12px 10px repeat-x; }
@media (max-width: 820px) { .calc-result { position: static; } }
.calc-result h2 { margin: 0 0 4px; font-size: 1rem; letter-spacing: 0.02em; }
.calc-result .stamp-date { color: var(--muted); font-size: 0.82rem; margin: 0 0 16px; border-bottom: 2px solid var(--text); padding-bottom: 10px; }
.stmt { margin: 0; display: grid; gap: 9px; }
.stmt .line { display: flex; align-items: baseline; gap: 8px; }
.stmt dt { color: var(--text); font-size: 0.95rem; min-width: 0; }
.stmt .leader { flex: 1 1 24px; border-bottom: 1px dotted var(--muted); transform: translateY(-4px); min-width: 16px; }
.stmt dd { margin: 0; font-weight: 600; text-align: right; white-space: nowrap; }
.stmt .line.head dt, .stmt .line.head dd { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.stmt .line.mark { background: var(--mark); margin: 0 -8px; padding: 2px 8px; border-radius: 4px; }
.stmt .line.total { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.stmt .line.total dt { font-weight: 700; }
.stmt .line.total dd { font-size: 1.45rem; font-weight: 800; color: var(--seal); border-bottom: 3px double var(--seal); line-height: 1.25; }
.stmt-note { color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }
.calc-result .disclaim { color: var(--muted); font-size: 0.8rem; margin: 18px 0 0; }

.table-wrap { overflow-x: auto; margin-top: 12px; }
.schedule { border-collapse: collapse; width: 100%; font-size: 0.9rem; min-width: 520px; }
.schedule th, .schedule td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.schedule th:first-child, .schedule td:first-child { text-align: center; }
.schedule thead th { color: var(--muted); font-weight: 600; }

.basis { margin-top: 8px; }
.basis blockquote { margin: 0 0 6px; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--surface); }
.basis .src { color: var(--muted); font-size: 0.85rem; margin: 0 0 16px; }
.cta { display: inline-block; background: var(--accent); color: var(--on-accent); font-weight: 700; padding: 11px 20px; border-radius: 10px; text-decoration: none; }
.guide, .faq { max-width: 72ch; }
.faq dt { font-weight: 700; margin-top: 14px; }
.faq dd { margin: 4px 0 0; color: var(--text); }
.related { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.related a { font-weight: 600; }
.related small { color: var(--muted); display: block; font-size: 0.82rem; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }

/* fixed ad slots (src/tools/site.py _ad): labeled, separated from the calculator */
.ad-slot { margin: 28px 0; padding: 6px 0 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); min-height: 100px; }
/* home: the slot sits between the search box and the calculators - keep clear space below it */
body.home .ad-slot { margin: 0 0 48px; }
.ad-label { display: block; color: var(--muted); font-size: 0.75rem; margin-bottom: 4px; }
