:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --text: #1c1c1a;
  --muted: #66655f;
  --border: #e3e1da;
  --accent: #3550d6;
  --accent-hover: #2a41b5;
  --accent-weak: #eceffd;
  --accent-text: #ffffff;
  --good: #16794c;
  --bad: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131314;
    --surface: #1c1c1e;
    --surface-2: #26262a;
    --text: #ecece8;
    --muted: #a3a39c;
    --border: #323236;
    --accent: #8597f7;
    --accent-hover: #a0aef9;
    --accent-weak: #262b47;
    --accent-text: #10143a;
    --good: #4cc38a;
    --bad: #f07167;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
img, canvas { max-width: 100%; }
[hidden] { display: none !important; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* 헤더 · 푸터 */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; letter-spacing: -0.02em; }
.logo-sub { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-right: -2px; }
@media (max-width: 420px) { .logo-sub { display: none; } }
.logo-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-text); font-size: 15px; }
.site-nav { display: flex; gap: 4px; }
.site-nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px; padding: 6px 10px; border-radius: 8px; }
.site-nav a:hover { color: var(--text); background: var(--surface-2); }

.site-footer { margin-top: 72px; border-top: 1px solid var(--border); padding: 28px 0 48px; color: var(--muted); font-size: 14px; }
.site-footer p { margin: 6px 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.footer-links a { color: var(--text); text-decoration: none; font-weight: 600; }
.footer-links a:hover { text-decoration: underline; }

/* 홈 */
.home-hero { padding: 48px 0 8px; }
.home-hero h1 { font-size: clamp(1.75rem, 5vw, 2.6rem); line-height: 1.25; letter-spacing: -0.03em; margin: 0 0 12px; }
.home-hero .lead { margin: 0 0 24px; }
.search { width: 100%; max-width: 480px; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 40px 0 8px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.feature strong { display: block; margin-bottom: 2px; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; }
.category h2 { font-size: 1.2rem; margin: 40px 0 14px; letter-spacing: -0.01em; }
.no-result { color: var(--muted); }

/* 도구 카드 */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tool-card {
  display: flex; gap: 14px; align-items: flex-start; padding: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.tool-icon {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent-weak); color: var(--accent); font-weight: 800; font-size: 14px; letter-spacing: -0.03em;
}
.tool-card-body strong { display: block; font-size: 16px; }
.tool-card-body span { display: block; color: var(--muted); font-size: 14px; line-height: 1.5; margin-top: 2px; }

/* 도구 페이지 공통 */
.tool-hero { padding: 36px 0 4px; }
.tool-hero h1 { font-size: clamp(1.6rem, 4.4vw, 2.2rem); line-height: 1.25; letter-spacing: -0.03em; margin: 0 0 8px; }
.lead { color: var(--muted); font-size: 17px; margin: 0; }

.tool-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin: 24px 0;
}
@media (max-width: 560px) { .tool-panel { padding: 14px; } }

.textarea, .input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
}
.textarea { display: block; width: 100%; min-height: 240px; padding: 14px; resize: vertical; line-height: 1.7; }
.textarea-sm { min-height: 110px; }
.input { padding: 8px 10px; }
.input-sm { padding: 6px 8px; font-size: 15px; }
.textarea:focus, .input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
input[type="color"] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 15px;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-icon { padding: 6px 9px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.options { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 28px; margin: 18px 0 4px; }
.field { min-width: 0; }
.field-grow { flex: 1 1 200px; max-width: 320px; }

/* 세그먼트 버튼 (라디오) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 7px 14px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); border-left: 1px solid var(--border); }
.seg label:first-of-type { border-left: 0; }
.seg input:checked + label { background: var(--accent); color: var(--accent-text); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 15px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 16px; }

/* 글자수 세기 */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; margin-bottom: 14px; }
.stat { display: flex; flex-direction: column; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-main { background: var(--accent-weak); }
.stat-main .stat-value { font-size: 26px; color: var(--accent); }
.goal-bar { position: relative; height: 30px; margin-top: 12px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.goal-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-weak); transition: width .2s; }
.goal-bar.over .goal-fill { background: color-mix(in srgb, var(--bad) 22%, transparent); }
.goal-text { position: relative; display: block; padding: 0 12px; line-height: 30px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* 텍스트 정리 */
.split { display: grid; gap: 14px; }
@media (min-width: 760px) { .split { grid-template-columns: 1fr 1fr; } }
.split .textarea { min-height: 280px; }
.result-meta { font-size: 14px; color: var(--muted); }

/* 파일 업로드 */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 40px 16px; border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag { border-color: var(--accent); background: var(--accent-weak); outline: none; }
.dropzone strong { font-size: 17px; }
.dropzone span { color: var(--muted); font-size: 14px; }

.file-list { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 8px; }
.file-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 12px; }
.thumb { width: 56px; height: 56px; border-radius: 8px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.file-row.error .file-info { color: var(--bad); }
.smaller { color: var(--good); font-weight: 700; }
.bigger { color: var(--bad); font-weight: 700; }
.row-actions { display: flex; gap: 4px; }
.batch-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* QR */
.qr-layout { display: grid; gap: 20px; }
@media (min-width: 760px) { .qr-layout { grid-template-columns: minmax(0, 1fr) 300px; } }
.qr-preview { display: flex; flex-direction: column; align-items: center; gap: 12px; background: var(--surface-2); border-radius: var(--radius); padding: 20px; }
.qr-preview canvas { width: 240px; height: 240px; image-rendering: pixelated; border-radius: 4px; }
.qr-msg { margin: 0; color: var(--muted); font-size: 14px; text-align: center; }
.qr-msg.warn { color: var(--bad); }
.qr-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* 설명글 */
.guide, .prose { max-width: 720px; }
.guide { margin-top: 48px; }
.guide h2, .prose h2 { font-size: 1.25rem; letter-spacing: -0.01em; margin: 36px 0 10px; }
.prose h1 { font-size: clamp(1.6rem, 4.4vw, 2.1rem); letter-spacing: -0.03em; margin: 36px 0 12px; }
.guide p, .prose p { margin: 0 0 12px; }
.guide ol, .guide ul, .prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 12px; }
.guide li, .prose li { margin: 4px 0; }
.faq { border-top: 1px solid var(--border); }
.faq:last-of-type { border-bottom: 1px solid var(--border); }
.faq summary { cursor: pointer; font-weight: 600; padding: 14px 0; list-style-position: outside; }
.faq p { color: var(--muted); }
.note { color: var(--muted); font-size: 14px; }
.result-meta.warn { color: var(--bad); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .92em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.contact-mail { font-size: 20px; font-weight: 700; }

.related { margin-top: 56px; }
.related h2 { font-size: 1.2rem; margin: 0 0 14px; }

/* 알림 */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 50; transform: translate(-50%, 16px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 15px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 유틸 (CSP 때문에 인라인 style="" 대신 쓰는 한 줄짜리 클래스) */
.m-0 { margin: 0; }
.mt-14 { margin: 14px 0 0; }
.mt-16 { margin: 16px 0 0; }
.mt-18 { margin-top: 18px; }
.w-90 { width: 90px; }
.w-110 { width: 110px; }
.w-full { width: 100%; }

/* ---- ai-check 전용 ---- */
/* 결과 영역 전용 스타일 (공통 변수만 사용, 다크 모드 자동 대응) */
.ai-hint { font-size: 14px; color: var(--muted); margin: 10px 0 0; }
.ai-hint.warn { color: var(--bad); }
.result-top { display: grid; grid-template-columns: 220px 1fr; gap: 20px 28px; align-items: center; }
@media (max-width: 640px) { .result-top { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.gauge { position: relative; width: 220px; }
.gauge svg { display: block; width: 100%; height: auto; }
.gauge-track { fill: none; stroke: var(--surface-2); stroke-width: 16; stroke-linecap: round; }
.gauge-fill { fill: none; stroke-width: 16; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.gauge-num { position: absolute; left: 0; right: 0; top: 46px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gauge-num strong { font-size: 44px; line-height: 1; letter-spacing: -0.03em; }
.gauge-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; color: #fff; font-size: 13px; font-weight: 700; }
.gauge-conf { text-align: center; font-size: 13px; color: var(--muted); margin-top: 2px; }
.gauge-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.verdict-line { font-size: 20px; font-weight: 700; margin: 0 0 8px; letter-spacing: -0.01em; }
.verdict-more summary { cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 600; }
.verdict-more p { margin: 8px 0 0; font-size: 15px; line-height: 1.7; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 6px; }
.chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; cursor: help; }
.chip-label { color: var(--muted); }
.chip-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.result-h { font-size: 1.1rem; margin: 26px 0 12px; }
.signal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
@media (max-width: 400px) { .signal-list { grid-template-columns: 1fr; } }
.signal-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.signal-card.hold { opacity: .7; }
.signal-card.voice { border-color: var(--good); }
.signal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.signal-name { font-weight: 700; font-size: 15px; }
.signal-score { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.signal-bar { height: 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; margin: 8px 0 6px; }
.signal-fill { height: 100%; border-radius: 999px; }
.signal-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 10px; }
.signal-tag { color: var(--good); font-weight: 700; }
.signal-detail { font-size: 14px; line-height: 1.65; margin: 8px 0 0; }
.signal-examples { margin: 8px 0 0; padding-left: 4px; list-style: none; font-size: 13px; color: var(--muted); line-height: 1.6; }
.signal-examples li { margin: 2px 0; padding-left: 14px; text-indent: -14px; }
.signal-examples li::before { content: '▸ '; }
.cant-box { margin-top: 22px; padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--surface)); }
.cant-box h3 { margin: 0 0 8px; font-size: 15px; }
.cant-box ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.7; }
.result-foot { margin-top: 14px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.result-foot p { margin: 2px 0; }
.guide .cant-guide { border-left: 4px solid var(--bad); padding: 10px 16px; background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; }
.guide .cant-guide ul { margin: 6px 0 0; }

/* ---- tone-convert 전용 ---- */
.tone-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; }
.tone-top .field-label { margin-bottom: 0; }
.tone-top .field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detected { font-size: 14px; color: var(--muted); }
.detected:not(:empty)::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.skipped { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.skipped summary { cursor: pointer; font-size: 14px; font-weight: 600; padding: 10px 14px; }
.skipped ul { margin: 0; padding: 0 14px 12px 32px; font-size: 14px; }
.skipped li { margin: 4px 0; }
.skip-sentence { font-weight: 600; }
.skip-reason { color: var(--muted); }
.skip-reason::before { content: ' — '; }
.tone-table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 15px; }
.tone-table th, .tone-table td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.tone-table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.tone-table td:first-child { white-space: nowrap; font-weight: 600; }
.tone-table .ex { color: var(--muted); display: block; font-size: 14px; }
@media (max-width: 560px) { .tone-table { font-size: 14px; } .tone-table th, .tone-table td { padding: 6px 8px; } }
