/* 토큰 계산기 — 전체 디자인 (모바일 우선) */

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --text: #16191f;
  --text-2: #4a5260;
  --text-3: #6b7280;
  --line: #dfe3ea;
  --accent: #2b5cd9;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefc;
  --ok: #0f7a4f;
  --ok-soft: #e3f4ec;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --err: #c0262d;
  --err-soft: #fde8e8;
  --best: #7a3fd1;
  --best-soft: #f1e9fd;
  --openai: #10a37f;
  --anthropic: #d97757;
  --google: #4285f4;
  --radius: 12px;
  --radius-s: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f232c;
    --text: #eceef2;
    --text-2: #c0c6d0;
    --text-3: #9aa3b0;
    --line: #2c313c;
    --accent: #7ea2ff;
    --accent-ink: #0f1115;
    --accent-soft: #1d2740;
    --ok: #5fd3a0;
    --ok-soft: #12291f;
    --warn: #f3c969;
    --warn-soft: #2d2412;
    --err: #ff8a8f;
    --err-soft: #34181a;
    --best: #c4a2ff;
    --best-soft: #2a1f3d;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 10;
  background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: var(--radius-s);
}
.skip-link:focus { top: 8px; }

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

/* ── 머리말 ─────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0 16px; }
.logo {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  font-weight: 800; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: -0.02em;
}
.logo-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink);
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 800;
}
.site-nav { flex: 1 1 100%; margin: 0 -16px; }
.site-nav ul {
  list-style: none; margin: 0; padding: 0 8px; display: flex; gap: 0;
}
.site-nav li { flex: 1 1 0; }
.site-nav a {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 6px;
  color: var(--text-2); text-decoration: none; font-size: 15px; font-weight: 600;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

@media (min-width: 720px) {
  .site-nav { flex: 0 1 auto; margin: 0 0 0 auto; }
  .site-nav ul { padding: 0; gap: 4px; }
  .site-nav a { padding: 0 14px; min-height: 60px; }
  .logo { min-height: 60px; }
}

/* ── 본문 공통 ──────────────────────── */
main { display: block; padding: 20px 0 48px; }
h1, h2, h3 { line-height: 1.3; letter-spacing: -0.02em; }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 21px; margin: 40px 0 12px; }
h3 { font-size: 18px; margin: 28px 0 8px; }
p { margin: 0 0 14px; }
ul, ol { padding-left: 22px; margin: 0 0 14px; }
li { margin-bottom: 6px; }
@media (min-width: 720px) {
  h1 { font-size: 30px; }
  h2 { font-size: 24px; }
  main { padding-top: 32px; }
}

.lead { color: var(--text-2); margin-bottom: 10px; }
.meta { color: var(--text-3); font-size: 14px; }
.privacy-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ok-soft); color: var(--ok); font-weight: 700; font-size: 14px;
  padding: 4px 10px; border-radius: 999px;
}
.privacy-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
@media (min-width: 720px) { .card { padding: 22px; } }

.prose { max-width: 760px; }
.prose > section, .prose > article > section { scroll-margin-top: 110px; }
.content-section { scroll-margin-top: 110px; }

.callout {
  border-left: 4px solid var(--accent); background: var(--accent-soft);
  padding: 12px 14px; border-radius: 0 var(--radius-s) var(--radius-s) 0; margin: 0 0 16px;
}
.callout p:last-child { margin-bottom: 0; }
.todo {
  background: var(--warn-soft); color: var(--warn); font-weight: 700;
  padding: 1px 6px; border-radius: 4px; border: 1px dashed currentColor;
}
.formula {
  font-family: var(--mono); font-size: 14px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 12px 14px; overflow-x: auto; white-space: pre; margin: 0 0 16px;
  line-height: 1.7;
}
code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

.cta-box {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 32px 0 0;
}
.cta-box p { margin: 0; font-weight: 700; }

/* ── 버튼 ───────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { color: var(--accent-ink); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.link-btn {
  min-height: 44px; padding: 0 8px; background: none; border: 0; color: var(--accent);
  font: inherit; font-size: 15px; font-weight: 700; text-decoration: underline; cursor: pointer;
}

/* ── 계산기 ─────────────────────────── */
.hero { margin-bottom: 12px; }
.hero .lead { margin-bottom: 6px; font-size: 15px; }
@media (min-width: 720px) { .hero .lead { font-size: 16px; } }

.tool { display: grid; gap: 14px; }
@media (min-width: 900px) {
  .tool { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
  .tool-results { grid-column: 1 / -1; }
}

.sample-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.sample-bar .btn { padding: 0 12px; }
textarea#prompt {
  display: block; width: 100%; min-height: 160px; height: 180px; resize: vertical;
  font: inherit; font-size: 16px; line-height: 1.55; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px;
}
@media (min-width: 900px) { textarea#prompt { height: 260px; } }
textarea#prompt:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }

.live-stats { margin-top: 10px; }
.count-line { color: var(--text-2); font-size: 15px; margin: 0 0 8px; }
.count-line b { color: var(--text); font-variant-numeric: tabular-nums; }
.token-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.token-chip {
  background: var(--surface-2); border-radius: var(--radius-s); padding: 8px 10px; min-width: 0;
}
.token-chip .tc-head { display: flex; align-items: center; gap: 5px; font-size: 14px; color: var(--text-2); font-weight: 600; flex-wrap: wrap; }
.token-chip .tc-num { display: block; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.25; }
.token-chip .tc-unit { font-size: 14px; color: var(--text-3); font-weight: 600; }
.token-chip .tc-note {
  display: block; margin-top: 4px; font-size: 12.5px; font-weight: 700; line-height: 1.35;
  color: var(--warn); background: var(--warn-soft); border: 1px dashed currentColor;
  border-radius: 4px; padding: 3px 6px;
}
.token-chip .tc-note[hidden], [data-ratio-pending][hidden] { display: none; }
.tok-status { font-size: 14px; color: var(--text-3); margin: 8px 0 0; }
.tok-status.is-error { color: var(--err); }

.notice { font-size: 14px; border-radius: var(--radius-s); padding: 8px 12px; margin: 0 0 10px; }
.notice-warn { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.notice-info { background: var(--surface-2); color: var(--text-2); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-openai { background: var(--openai); }
.dot-anthropic { background: var(--anthropic); }
.dot-google { background: var(--google); }

/* 설정 */
.settings { display: grid; gap: 16px; }
.field label, .field .label { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.field .help { display: block; font-size: 14px; color: var(--text-3); margin-top: 4px; line-height: 1.5; }
.field-error { color: var(--err); font-size: 14px; font-weight: 600; margin: 6px 0 0; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.num-input {
  width: 120px; min-height: 44px; padding: 0 12px; font: inherit; font-size: 16px;
  font-variant-numeric: tabular-nums; text-align: right; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
}
.num-input[aria-invalid="true"] { border-color: var(--err); }
.num-input:disabled { opacity: .5; }
.num-input.sm { width: 84px; }
.unit { color: var(--text-2); font-size: 15px; }
input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--accent); margin: 0; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick .btn { min-width: 72px; padding: 0 10px; font-variant-numeric: tabular-nums; }
.check {
  display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 0 0; cursor: pointer; font-weight: 600;
}
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
details.advanced { border-top: 1px solid var(--line); padding-top: 4px; }
details.advanced > summary {
  min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 700; color: var(--accent);
}
.adv-body { padding-bottom: 4px; }

/* 결과 */
.results-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; }
.results-head h2 { margin: 0; font-size: 20px; }
.summary {
  margin: 12px 0; padding: 14px 16px; border-radius: var(--radius);
  background: var(--best-soft); border: 1px solid transparent;
}
.summary.is-empty { background: var(--surface-2); }
.summary p { margin: 0; }
.summary-label { font-size: 14px; font-weight: 700; color: var(--text-2); }
.summary-model { font-size: 20px; margin-top: 4px !important; }
.summary-cost { font-size: 17px; margin-top: 2px !important; font-variant-numeric: tabular-nums; }
.summary-cost b { font-size: 20px; }
.summary-note { font-size: 14px; color: var(--text-3); margin-top: 6px !important; }
.summary-empty { font-weight: 700; font-size: 17px; }
.sub { display: block; font-size: 13.5px; color: var(--text-3); font-weight: 500; }
.summary .sub { display: inline; }

.tier-best {
  list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.tier-best li {
  margin: 0; font-size: 14px; background: var(--surface-2); border-radius: var(--radius-s); padding: 8px 10px;
}
.tier-best .tier-name { font-weight: 800; margin-right: 4px; }
.tier-best .tier-cost { color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

.sort-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.sort-bar .label { font-size: 14px; color: var(--text-3); font-weight: 700; }
.sort-bar .btn { min-height: 40px; font-size: 14px; padding: 0 12px; }

.badge {
  display: inline-flex; align-items: center; font-size: 12.5px; font-weight: 700; line-height: 1;
  padding: 4px 7px; border-radius: 999px; white-space: nowrap;
}
.badge-exact { background: var(--ok-soft); color: var(--ok); }
.badge-est { background: var(--warn-soft); color: var(--warn); }
.badge-preview { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.badge-long { background: var(--err-soft); color: var(--err); }
.badge-best { background: var(--best); color: #fff; }
.badge-tier { background: var(--best-soft); color: var(--best); }

/* 결과표: 데스크톱은 표, 600px 미만은 카드 */
.result-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.result-table th, .result-table td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.result-table th { font-size: 14px; color: var(--text-2); font-weight: 700; white-space: nowrap; background: var(--surface-2); }
.result-table th button {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; min-height: 44px; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 3px;
}
.result-table th button[aria-pressed="true"] { color: var(--accent); text-decoration-style: solid; }
.result-table th button[aria-pressed="true"]::after { content: " ▲"; font-size: 11px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.c-model { min-width: 0; }
.c-model .m-name { font-weight: 700; margin: 0 6px 0 6px; }
.c-model .m-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.c-krw { font-weight: 800; }
.c-tier { color: var(--text-2); white-space: nowrap; }
tr.is-best td { background: var(--best-soft); }
.is-dim td { color: var(--text-3); }
.is-dim .c-krw { font-weight: 600; }

@media (max-width: 599.98px) {
  .result-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .result-table, .result-table tbody { display: block; }
  .result-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px;
    grid-template-areas: "model model" "krw usd" "tok per";
    padding: 12px 14px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface);
  }
  .result-table tr.is-best { background: var(--best-soft); border-color: var(--best); }
  .result-table td { display: block; padding: 0; border: 0; background: none !important; }
  .result-table .c-model { grid-area: model; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin-bottom: 4px; }
  .result-table .c-tier { display: none; }
  .result-table .c-krw { grid-area: krw; text-align: left !important; font-size: 21px; line-height: 1.3; white-space: normal; }
  .result-table .c-usd { grid-area: usd; align-self: end; font-size: 15px; color: var(--text-2); }
  .result-table .c-usd::before { content: attr(data-label) " "; font-size: 13.5px; color: var(--text-3); }
  .result-table .c-tok { grid-area: tok; text-align: left !important; font-size: 14px; color: var(--text-3); }
  .result-table .c-per { grid-area: per; font-size: 14px; color: var(--text-3); }
  .result-table .c-tok::before, .result-table .c-per::before { content: attr(data-label) " "; }
  .result-table .c-tok::after { content: "개"; }
  .result-table .c-krw::before { content: "월 "; font-size: 14px; font-weight: 600; color: var(--text-3); }
  .result-table .c-krw .sub { display: inline; margin-left: 4px; }
}
.basis { font-size: 14px; color: var(--text-3); margin: 12px 0 0; }
.schedule { font-size: 14px; color: var(--warn); margin: 6px 0 0; padding-left: 18px; }
.calc-busy { font-size: 14px; color: var(--accent); font-weight: 700; margin: 0 0 8px; }

/* ── 일반 표 (단가표·본문 표) ────────── */
.table-wrap { position: relative; margin: 0 0 18px; }
.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface);
}
.table-scroll:focus-visible { outline-offset: 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 440px; }
.data-table caption { text-align: left; font-size: 14px; color: var(--text-3); padding: 8px 12px; caption-side: bottom; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: normal; }
.data-table tbody th { min-width: 150px; }
.data-table .tier { overflow-wrap: anywhere; }
.data-table thead th { background: var(--surface-2); font-size: 14px; color: var(--text-2); white-space: nowrap; }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody th { font-weight: 700; }
.data-table .num { text-align: right; }
.data-table .tier { display: block; font-size: 13.5px; color: var(--text-3); font-weight: 500; }
.data-table td.wrap-ok { white-space: normal; min-width: 130px; }
.price-up { display: block; font-size: 13.5px; color: var(--warn); font-weight: 700; white-space: nowrap; }
.price-old { display: block; font-size: 13.5px; color: var(--text-3); white-space: nowrap; }
.scroll-hint { display: none; font-size: 13.5px; color: var(--text-3); text-align: right; margin: 4px 2px 0; }
@media (max-width: 599.98px) {
  .scroll-hint { display: block; }
  .sticky-first th:first-child, .sticky-first td:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line);
  }
  .sticky-first thead th:first-child { background: var(--surface-2); }
}
.source-list { font-size: 15px; }

/* 예시 계산 */
.example-grid { display: grid; gap: 12px; margin: 0 0 18px; }
@media (min-width: 720px) { .example-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.example-grid .card h3 { margin-top: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.example-grid .card p { font-size: 15px; }
.example-grid .formula { font-size: 13.5px; white-space: pre-wrap; }
.big-num { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 0 0 2px !important; }

/* FAQ */
.faq details {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); margin-bottom: 8px;
}
.faq summary {
  list-style: none; cursor: pointer; padding: 12px 44px 12px 14px; min-height: 44px; position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  font-size: 22px; color: var(--accent); font-weight: 400;
}
.faq details[open] summary::after { content: "−"; }
.faq summary h3 { display: inline; font-size: 16px; margin: 0; line-height: 1.5; }
.faq .faq-a { padding: 0 14px 6px; color: var(--text-2); }

/* 가이드 */
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 16px 0 8px; }
.toc h2 { font-size: 16px; margin: 0 0 8px; }
.toc ol { margin: 0; }
.toc li { margin-bottom: 4px; }
.checklist { list-style: none; padding: 0; }
.checklist li { position: relative; padding-left: 30px; margin-bottom: 10px; }
.checklist li::before {
  content: ""; position: absolute; left: 0; top: 3px; width: 18px; height: 18px;
  border: 2px solid var(--accent); border-radius: 4px;
}
.tip-list > li { margin-bottom: 10px; }
.back-to-calc { font-size: 15px; font-weight: 700; }

/* 문의 폼 */
.form { display: grid; gap: 16px; max-width: 560px; }
.form input[type="text"], .form input[type="email"], .form select, .form textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s);
}
.form textarea { min-height: 160px; resize: vertical; }
.form .req { color: var(--err); font-weight: 700; }
.form-status { font-weight: 700; padding: 10px 12px; border-radius: var(--radius-s); margin: 0; }
.form-status.ok { background: var(--ok-soft); color: var(--ok); }
.form-status.err { background: var(--err-soft); color: var(--err); }

/* 404 */
.notfound { text-align: center; padding: 40px 0; }
.notfound .code { font-size: 64px; font-weight: 900; color: var(--accent); margin: 0; line-height: 1; letter-spacing: -0.04em; }
.notfound .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }

/* 광고 자리 (승인 후 사용) — 미리 높이를 잡아 레이아웃 밀림 방지 */
.ad-slot { min-height: 0; }

/* ── 꼬리말 ─────────────────────────── */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 20px 0 28px; font-size: 14px; color: var(--text-3); }
.site-footer nav ul { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 0 4px; }
.site-footer nav li { margin: 0; }
.site-footer nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: var(--text-2); font-weight: 600; }
.site-footer nav li:first-child a { padding-left: 0; }
.site-footer p { margin: 0 0 4px; }
