/* 글자수 세기 공통 스타일 (MD HTML 변환기·LaTeX 워드 변환기와 같은 틀)
   색상은 모두 토큰으로 정의하고 다크 모드에서 다시 지정한다. */
:root {
  color-scheme: light dark;
  --bg: #f5f6fa; --card: #ffffff; --foreground: #1a1a2e; --muted: #5b6075;
  --border: #d6d9e3; --border-strong: #b8bdcf;
  --accent: #4b3fb8; --accent-hover: #3d3399; --accent-text: #4436a8; --accent-soft: #4b3fb81c;
  --mark: #f2a516; --mark-soft: #f2a51626;
  --ok: #15803d; --danger: #b91c1c;
  --warn-bg: #d9770614; --warn-border: #d9770650;
  --paper: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117; --card: #181b24; --foreground: #e6e8ef; --muted: #a0a6b8;
    --border: #2c3140; --border-strong: #3c4254;
    --accent: #6a5cf0; --accent-hover: #5a4be0; --accent-text: #b3a9ff; --accent-soft: #8f84ff26;
    --mark-soft: #f2a51633;
    --ok: #4ade80; --danger: #f87171;
    --warn-bg: #f59e0b14; --warn-border: #f59e0b45;
    --paper: #14161e;
  }
}
* { box-sizing: border-box; }
body { font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif; background: var(--bg); color: var(--foreground); margin: 0; line-height: 1.55; }
a { color: var(--accent-text); }
[hidden] { display: none !important; }
.wrap { max-width: 1060px; margin: 0 auto; padding: 24px 20px 0; }

/* ---- 헤더·푸터 ---- */
.site-header { background: var(--card); border-bottom: 1px solid var(--border); }
.site-header .inner { max-width: 1060px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; gap: 6px 20px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.2rem; color: var(--foreground); text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.site-nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.site-nav a { padding: 8px 14px; border-radius: 8px; font-size: 1rem; font-weight: 500; color: var(--foreground); text-decoration: none; }
.site-nav a:hover { background: var(--accent-soft); }
.site-nav a[aria-current="page"] { color: var(--accent-text); font-weight: 600; }
@media (max-width: 480px) {
  .site-nav { margin-left: -8px; width: calc(100% + 8px); gap: 0; }
  .site-nav a { padding: 6px 8px; font-size: 0.92rem; }
}
.site-footer { margin-top: 56px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.82rem; }
.site-footer .inner { max-width: 1060px; margin: 0 auto; padding: 20px 20px 40px; display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }
.site-footer p { margin: 0; }
.site-footer nav { display: flex; gap: 14px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--foreground); }
body.has-selbar .site-footer { padding-bottom: 210px; }

/* ---- 첫 화면: 큰 제목, 한 문장, 큰 버튼 하나 ---- */
.hero { text-align: center; padding: 56px 16px 64px; border-radius: 18px; }
.hero h1 { font-size: 2.75rem; line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 14px; word-break: keep-all; }
.hero .sub { font-size: 1.15rem; line-height: 1.65; color: var(--muted); max-width: 640px; margin: 0 auto 32px; word-break: keep-all; }
.btn.huge { font-size: 1.5rem; padding: 20px 60px; border-radius: 14px; box-shadow: 0 12px 32px rgba(75, 63, 184, 0.3); }
.btn.huge:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.hero .alt { margin: 18px 0 0; font-size: 0.95rem; color: var(--muted); }
.hero .status { margin: 14px auto 0; max-width: 600px; font-size: 0.92rem; min-height: 1.4em; word-break: keep-all; }
.hero .status.err { color: var(--danger); font-weight: 600; }
.hero .trust { display: inline-flex; align-items: center; gap: 7px; margin: 28px 0 0; padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); font-size: 0.85rem; color: var(--muted); }
.hero .trust svg { width: 15px; height: 15px; flex: none; }
body.dragging .hero { outline: 3px dashed var(--accent); outline-offset: -10px; background: var(--accent-soft); }
@media (max-width: 600px) {
  .hero { padding: 36px 8px 44px; }
  .hero h1 { font-size: 2rem; }
  .hero .sub { font-size: 1.02rem; margin-bottom: 26px; }
  .btn.huge { width: 100%; max-width: 420px; font-size: 1.25rem; padding: 18px 24px; }
}
.btn { display: inline-block; padding: 8px 15px; font: inherit; font-size: 0.9rem; font-weight: 600; border-radius: 9px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--foreground); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.small { padding: 6px 12px; font-size: 0.82rem; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, .linkbtn:focus-visible, tr[data-region]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.linkbtn { border: 0; background: none; padding: 0 4px; font: inherit; color: var(--accent-text); text-decoration: underline; cursor: pointer; }
.hint { font-size: 0.85rem; color: var(--muted); margin: 10px 0 0; }
.okmsg { color: var(--ok); font-weight: 600; font-size: 0.85rem; margin: 6px 0 0; }
.okmsg:empty { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- 기능 소개 카드 ---- */
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 40px 0 0; padding: 0; list-style: none; }
.features li { padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.features b { display: block; margin-bottom: 4px; }
.features span { display: block; font-size: 0.88rem; line-height: 1.6; color: var(--muted); }

/* ---- 설명 글(가이드·정책·도구 아래 안내) ---- */
.content { margin-top: 44px; }
.prose { max-width: 760px; }
.prose h1 { font-size: 1.6rem; line-height: 1.35; margin: 0 0 8px; }
.prose h2 { font-size: 1.2rem; line-height: 1.4; margin: 36px 0 10px; }
.prose h3 { font-size: 1.02rem; margin: 24px 0 6px; }
.prose p, .prose li { font-size: 1rem; line-height: 1.8; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 4px; }
.prose .meta { color: var(--muted); font-size: 0.85rem; margin: 0 0 20px; }
.prose .lead { font-size: 1.05rem; color: var(--muted); }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.92rem; margin: 12px 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--card); }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
.prose .note { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 10px; padding: 10px 14px; font-size: 0.92rem; }
.table-scroll { overflow-x: auto; }
.faq details { border: 1px solid var(--border); border-radius: 10px; background: var(--card); padding: 10px 14px; }
.faq details + details { margin-top: 8px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 0; }
.cardlinks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; padding: 0; margin: 12px 0 0; list-style: none; }
.cardlinks li + li { margin-top: 0; }
.cardlinks a { display: block; height: 100%; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--foreground); text-decoration: none; }
.cardlinks a:hover { border-color: var(--accent); }
.cardlinks b { display: block; margin-bottom: 4px; }
.cardlinks span { display: block; font-size: 0.85rem; line-height: 1.6; color: var(--muted); }

/* ---- 광고 자리: assets/ads.js가 채운다. 설정 전에는 HTML의 hidden으로 숨겨져 있다 ---- */
.ad-slot { margin: 36px 0; min-height: 100px; }
.ad-slot .ad-label { display: block; font-size: 0.7rem; color: var(--muted); margin-bottom: 4px; }
.ad-slot.preview { display: flex; align-items: center; justify-content: center; border: 2px dashed var(--border-strong); border-radius: 10px; color: var(--muted); font-size: 0.85rem; }

/* ---- 작업 화면 ---- */
.workspace { padding-top: 16px; }
.ws-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.ws-file { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; min-width: 0; }
.ws-file b { font-size: 1.05rem; overflow-wrap: anywhere; }
.ws-back { padding: 0; font-size: 0.88rem; }
.ws-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 0.78rem; font-weight: 600; }
.card { border: 1px solid var(--border); border-radius: 14px; background: var(--card); padding: 16px 18px; }
.card-title { margin: 0 0 10px; font-size: 0.95rem; }
.card-title small { font-weight: 400; color: var(--muted); font-size: 0.8rem; margin-left: 6px; }
.stat-card.total { margin-top: 14px; }

/* 숫자 묶음: 큰 숫자 셋 + 작은 숫자 줄 */
.stats-main { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { cursor: help; }
.stat.big { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); }
.stat.big b { display: block; font-size: 2rem; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat.big b small { font-size: 0.95rem; font-weight: 600; margin-left: 2px; }
.stat.big span { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.stats-more { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 10px; font-size: 0.85rem; color: var(--muted); }
.stats-more .stat { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; gap: 6px; }
.stats-more b { color: var(--foreground); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) {
  .stat.big { padding: 8px 9px; }
  .stat.big b { font-size: 1.45rem; }
  .stat.big span { font-size: 0.78rem; }
}

.view-tabs { display: flex; gap: 0; margin: 18px 0 0; border-bottom: 1px solid var(--border-strong); }
.view-tabs button { padding: 10px 16px; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer; }
.view-tabs button[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); }
.view { margin-top: 12px; }
.view-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-bottom: 10px; }
.view-opts .hint { margin: 0; }
.check { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; cursor: pointer; }
.check input { width: 17px; height: 17px; flex: none; accent-color: var(--accent); margin: 0; }
.opt-row { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; font-weight: 600; }
.opt-row select { padding: 5px 8px; font: inherit; font-size: 0.88rem; font-weight: 400; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--card); color: var(--foreground); }

/* 칸·문항별 목록 */
table.regions { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; font-size: 0.9rem; }
.regions th { text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.regions td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.regions tr:last-child td { border-bottom: 0; }
.regions tbody tr { cursor: pointer; }
.regions tbody tr:hover { background: var(--accent-soft); }
.regions tbody tr.on { background: var(--mark-soft); }
.regions .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.regions td.num:nth-child(3) { font-weight: 700; }
.regions .where { white-space: nowrap; color: var(--muted); font-size: 0.82rem; }
.regions .preview { color: var(--foreground); word-break: break-all; }
.regions .empty-row { text-align: center; color: var(--muted); cursor: default; }
@media (max-width: 640px) {
  .regions thead { display: none; }
  .regions, .regions tbody, .regions tr, .regions td { display: block; }
  .regions tr { display: grid; grid-template-columns: 1fr auto auto auto; gap: 2px 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .regions td { padding: 0; border: 0; }
  .regions .where { grid-column: 1 / -1; }
  .regions .preview { grid-column: 1 / -1; font-size: 0.86rem; color: var(--muted); }
  .regions td.num:nth-child(3)::before { content: "공백 포함 "; font-weight: 400; color: var(--muted); font-size: 0.78rem; }
  .regions td.num:nth-child(4)::before { content: "제외 "; color: var(--muted); font-size: 0.78rem; }
  .regions td.num:nth-child(5)::before { content: "단어 "; color: var(--muted); font-size: 0.78rem; }
  .regions td.num:nth-child(3) { grid-column: 1; text-align: left; }
}

/* 문서 보기 */
.doc { padding: 22px 26px; border: 1px solid var(--border); border-radius: 12px; background: var(--paper); font-size: 0.95rem; line-height: 1.7; overflow-wrap: anywhere; }
.doc p { margin: 0; white-space: pre-wrap; tab-size: 4; }
.doc p.empty { min-height: 0.8em; }
.doc p.k-box, .doc p.k-caption { color: var(--muted); }
.doc p.k-box::before, .doc p.k-caption::before { content: attr(data-kind); display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 5px; background: var(--accent-soft); font-size: 0.72rem; vertical-align: 1px; }
.doc [data-region] { scroll-margin-top: 16px; }
.doc .body-region { border-radius: 6px; margin: 0 -6px; padding: 0 6px; cursor: pointer; }
.doc .body-region:hover { background: var(--accent-soft); }
.doc .table-scroll { margin: 8px 0; }
.doc table.dt { border-collapse: collapse; min-width: 50%; max-width: 100%; }
.doc .dt td { position: relative; border: 1px solid var(--border-strong); padding: 6px 8px; vertical-align: top; min-width: 48px; }
.doc .dt td[data-region] { cursor: pointer; padding-top: 22px; }
.doc .dt td[data-region]:hover { background: var(--accent-soft); }
.doc .on[data-region], .doc .dt td.on { background: var(--mark-soft) !important; box-shadow: inset 0 0 0 2px var(--mark); }
.badge { position: absolute; top: 3px; right: 4px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 1.6; font-variant-numeric: tabular-nums; pointer-events: none; user-select: none; -webkit-user-select: none; }
@media (max-width: 600px) { .doc { padding: 14px 12px; font-size: 0.9rem; } }
.foot-note { margin-top: 18px; }

/* 아래에 붙는 '고른 부분' 막대 */
.selbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 0 12px 12px; pointer-events: none; }
.selbar-inner { max-width: 1060px; margin: 0 auto; padding: 12px 16px; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--card); box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.18); pointer-events: auto; }
.selhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 8px; }
.selhead b { font-size: 0.95rem; }
.selbtns { display: flex; gap: 6px; }
.selbar .stat.big { padding: 6px 10px; }
.selbar .stat.big b { font-size: 1.35rem; }
.selbar .stats-more { margin-top: 6px; }
@media (max-width: 520px) { .selbar .stats-more { display: none; } .selbar .stat.big b { font-size: 1.2rem; } }

/* 붙여넣기 */
.paste-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; margin-top: 14px; align-items: start; }
.paste-box textarea { display: block; width: 100%; min-height: 62vh; padding: 16px 18px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--paper); color: var(--foreground); font: inherit; font-size: 1rem; line-height: 1.75; resize: vertical; }
.paste-side { position: sticky; top: 12px; display: grid; gap: 12px; }
.paste-side .hint { margin: 0; }
.paste-side .stats-main { grid-template-columns: 1fr; }
.paste-side .stat.big { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.paste-side .stat.big b { font-size: 1.7rem; order: 2; }
.paste-side .stats-more { display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) {
  .paste-grid { grid-template-columns: 1fr; }
  .paste-side { position: static; order: -1; }
  .paste-side .stats-main { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .paste-side .stat.big { display: block; }
  .paste-box textarea { min-height: 50vh; font-size: 16px; } /* 16px 미만이면 iPhone이 확대해 버린다 */
}
