:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #e2e1dc;
  --accent: #2f5bd3;
  --accent-soft: #e8eefc;
  --ok: #1d7a4a;
  --warn: #a35b00;
  --radius: 10px;
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "D2Coding", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --surface: #1f1f1e; --text: #ececea; --muted: #a2a29c;
    --line: #34342f; --accent: #8aa8ff; --accent-soft: #24304f; --ok: #5cc98d; --warn: #f0a94b;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.65 var(--font); word-break: keep-all; overflow-wrap: anywhere;
}
a { color: var(--accent); }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 20px; }

/* 헤더 */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding-top: 12px; padding-bottom: 12px; }
.logo { font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; letter-spacing: -0.02em; }
.logo span { color: var(--accent); }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 999px; font-size: 14px; }
.nav a:hover { color: var(--text); background: var(--bg); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* 본문 */
main { padding: 32px 0 48px; }
h1 { font-size: clamp(24px, 4vw, 32px); line-height: 1.3; margin: 0 0 8px; letter-spacing: -0.02em; }
.lead { color: var(--muted); margin: 0 0 24px; }
h2 { font-size: 20px; margin: 40px 0 12px; letter-spacing: -0.01em; }
h3 { font-size: 16px; margin: 24px 0 6px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }

label { font-weight: 600; font-size: 14px; }
textarea, input[type="text"], input[type="number"], select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.6; }
textarea.mono, .mono { font-family: var(--mono); font-size: 14px; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.row > .field { flex: 1 1 160px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 680px) { .grid-2 { grid-template-columns: 1fr; } }

.btn {
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 9px 16px; min-height: 42px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #10162a; } }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.field > .seg { align-self: flex-start; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 14px; border: 0; background: var(--surface); color: var(--muted); padding: 8px 14px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; font-size: 14px; cursor: pointer; }

.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px 16px;
  text-align: center; color: var(--muted); cursor: pointer; background: var(--bg);
}
.drop:hover, .drop.over, .drop:focus-visible { border-color: var(--accent); color: var(--text); outline: none; }
.drop strong { color: var(--text); display: block; font-size: 16px; margin-bottom: 4px; }

.note { font-size: 14px; color: var(--muted); margin: 8px 0 0; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.msg { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-top: 12px; }
.msg.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.msg.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); }

.result { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-top: 10px; background: var(--bg); }
.result header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 6px; }
.result pre { margin: 0; white-space: pre-wrap; font: inherit; }

.preview { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 12px; }
.preview table { border-collapse: collapse; font-size: 13px; width: max-content; min-width: 100%; }
.preview th, .preview td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 4px 8px; text-align: left; white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.preview th { background: var(--surface); position: sticky; top: 0; font-weight: 600; }
.preview pre { margin: 0; padding: 10px; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }

.file-list { list-style: none; padding: 0; margin: 12px 0 0; }
.file-list li { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }

/* 메인 도구 목록 */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tool-card { display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; transition: border-color .15s, transform .15s; }
.tool-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.tool-card .ico { font-size: 22px; font-weight: 800; color: var(--accent); font-family: var(--mono); }
.tool-card h3 { font-size: 17px; margin: 8px 0 4px; }
.tool-card p { margin: 0; color: var(--muted); font-size: 14px; }

/* 설명 글 */
.guide { margin-top: 8px; }
.guide p, .guide li { color: var(--text); }
.guide ul, .guide ol { padding-left: 20px; }
.guide code { font-family: var(--mono); font-size: 0.92em; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
details { border-top: 1px solid var(--line); padding: 12px 0; }
details summary { cursor: pointer; font-weight: 600; }
details p { margin: 8px 0 0; }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; padding: 24px 0 40px; }
.site-footer a { color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  transition: opacity .2s, transform .2s; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* 꼬리말 도구 목록 */
.footer-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.footer-tools strong { color: var(--text); font-size: 14px; }
.footer-tools ul { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.site-footer .footer-tools { display: grid; }

/* 공통 표·숫자 */
.num { font-variant-numeric: tabular-nums; }
.big { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stat .label { font-size: 13px; color: var(--muted); }
table.plain { border-collapse: collapse; width: 100%; font-size: 14px; }
table.plain th, table.plain td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }
table.plain th { color: var(--muted); font-weight: 600; font-size: 13px; }
table.plain td.r, table.plain th.r { text-align: right; }
.plus { color: var(--ok); } .minus { color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 4px 10px; cursor: pointer; font-family: inherit; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 2px; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 8px; width: 38px; height: 38px; cursor: pointer; font-size: 16px; flex: 0 0 auto; }
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.tabs { margin-bottom: 16px; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
