/* 업무 도구함 공통 디자인 — 메인(index.html)과 같은 토큰/컴포넌트를 모든 도구 페이지에서 공유한다. */
:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #eef2f7;
    --border: #e3e8ef;
    --border-strong: #cfd6e0;
    --text: #111827;
    --text-2: #4b5563;
    --text-3: #8a94a6;
    --accent: #2563eb;
    --accent-hover: #1d4fd8;
    --accent-soft: #e8f0fe;
    --on-accent: #ffffff;
    --danger: #c2313f;
    --danger-soft: #fdecee;
    --ok: #15803d;
    --ok-soft: #e7f6ec;
    --warn: #b45309;
    --warn-soft: #fdf3e2;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-hover: 0 10px 28px rgba(16, 24, 40, .10);
    --radius: 16px;
    --radius-sm: 10px;
    --mono: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Consolas, monospace;
    --cat-excel: #16803c;   --cat-excel-bg: #e6f5ec;
    --cat-pdf: #d0362b;     --cat-pdf-bg: #fdebea;
    --cat-calc: #6d4ae0;    --cat-calc-bg: #efebfd;
    --cat-share: #c26a00;   --cat-share-bg: #fdf1e0;
    --cat-download: #0e7490; --cat-download-bg: #e2f4f8;
    --cat: var(--accent); --cat-bg: var(--accent-soft);
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117;
        --surface: #161b22;
        --surface-2: #1c222b;
        --surface-3: #232a35;
        --border: #2a313c;
        --border-strong: #3a4250;
        --text: #e8ecf2;
        --text-2: #aab3c0;
        --text-3: #717c8c;
        --accent: #6b9bff;
        --accent-hover: #8bb0ff;
        --accent-soft: #1b2a47;
        --on-accent: #0b1220;
        --danger: #ff7b86;
        --danger-soft: #3a1d22;
        --ok: #5ed38a;
        --ok-soft: #173024;
        --warn: #f5b454;
        --warn-soft: #3a2c14;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow-hover: 0 10px 28px rgba(0, 0, 0, .45);
        --cat-excel: #5ed38a;   --cat-excel-bg: #173024;
        --cat-pdf: #ff8a80;     --cat-pdf-bg: #3a1f1d;
        --cat-calc: #b29dff;    --cat-calc-bg: #28213f;
        --cat-share: #ffb95c;   --cat-share-bg: #3a2b14;
        --cat-download: #5fd0e6; --cat-download-bg: #13303a;
    }
}
[data-cat="excel"] { --cat: var(--cat-excel); --cat-bg: var(--cat-excel-bg); }
[data-cat="pdf"] { --cat: var(--cat-pdf); --cat-bg: var(--cat-pdf-bg); }
[data-cat="calc"] { --cat: var(--cat-calc); --cat-bg: var(--cat-calc-bg); }
[data-cat="share"] { --cat: var(--cat-share); --cat-bg: var(--cat-share-bg); }
[data-cat="download"] { --cat: var(--cat-download); --cat-bg: var(--cat-download-bg); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.wt {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    font-size: 16px;
    line-height: 1.55;
    word-break: keep-all;
}
body.wt a { color: var(--accent); }
body.wt :focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.wt-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 상단 바 */
.wt-topbar { max-width: 1080px; margin: 0 auto; padding: 22px 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
body.wt .wt-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1rem; color: var(--text); text-decoration: none; }
.wt-brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: .95rem; }
body.wt .wt-back {
    display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
    border-radius: var(--radius-sm); padding: 7px 12px; font-size: .88rem;
}
body.wt .wt-back:hover { color: var(--text); border-color: var(--text-3); }

/* 본문 */
.wt-page { max-width: 960px; margin: 0 auto; padding: 28px 16px 56px; }
.wt-page.wide { max-width: 1280px; }
.wt-page.narrow { max-width: 720px; }
.wt-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 24px; }
.wt-head-icon { flex: none; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; color: var(--cat); background: var(--cat-bg); }
.wt-head h1 { margin: 2px 0 4px; font-size: clamp(1.5rem, 3.4vw, 1.9rem); line-height: 1.25; letter-spacing: -0.02em; color: var(--text); }
.wt-head p { margin: 0; color: var(--text-2); }
.wt-head .wt-badges { margin-top: 10px; }

.wt-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.wt-badge { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; color: var(--text-2); background: var(--surface-3); }
.wt-badge.local { color: var(--ok); background: var(--ok-soft); }
.wt-badge.accent { color: var(--accent); background: var(--accent-soft); }
.wt-badge.warn { color: var(--warn); background: var(--warn-soft); }

.wt-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.wt-card + .wt-card, .wt-grid-2 + .wt-card, .wt-card + .wt-grid-2, .wt-stack > * + * { margin-top: 16px; }
.wt-card + .wt-hint { margin-top: 12px; }
.wt-card-title { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 1.05rem; font-weight: 700; color: var(--text); }
.wt-card-title .bi { color: var(--cat); }
.wt-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.wt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.wt-muted { color: var(--text-2); font-size: .9rem; }
.wt-hint { color: var(--text-3); font-size: .84rem; margin: 6px 0 0; }
.wt-divider { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* 폼 컨트롤: 기존 마크업도 그대로 어울리도록 :where()로 낮은 우선순위를 준다. */
:where(body.wt) :where(label) { color: var(--text); }
.wt-label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 6px; color: var(--text); }
:where(body.wt) :where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]), select, textarea),
.wt-input {
    font: inherit; font-size: .95rem; color: var(--text);
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 12px; min-height: 42px; max-width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
:where(body.wt) :where(textarea) { min-height: 110px; resize: vertical; line-height: 1.55; }
:where(body.wt) :where(input, select, textarea):focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
:where(body.wt) :where(input, select, textarea)::placeholder { color: var(--text-3); }
:where(body.wt) :where(input[type=checkbox], input[type=radio]) { accent-color: var(--accent); width: 16px; height: 16px; }
:where(body.wt) :where(input[type=file]) { font: inherit; font-size: .9rem; color: var(--text-2); max-width: 100%; }
:where(body.wt) :where(input[type=file])::file-selector-button {
    font: inherit; font-weight: 600; font-size: .88rem; margin-right: 10px; cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 8px; padding: 7px 12px;
}

/* 버튼 */
:where(body.wt) :where(button),
.wt-btn {
    font: inherit; font-weight: 600; font-size: .92rem; line-height: 1.2;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 42px; padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    text-decoration: none; transition: background .15s, border-color .15s, filter .15s;
}
:where(body.wt) :where(button):hover, .wt-btn:hover { border-color: var(--text-3); background: var(--surface-2); }
:where(body.wt) :where(button):disabled, .wt-btn:disabled { opacity: .55; cursor: not-allowed; }
body.wt .wt-btn.primary, body.wt .wt-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
body.wt .wt-btn.primary:hover, body.wt .wt-btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
body.wt .wt-btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: var(--surface); }
body.wt .wt-btn.danger:hover { background: var(--danger-soft); }
body.wt .wt-btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
body.wt .wt-btn.ghost:hover { background: var(--surface-3); color: var(--text); }
body.wt .wt-btn.block { width: 100%; }
body.wt .wt-btn.sm { min-height: 32px; padding: 5px 10px; font-size: .84rem; border-radius: 8px; }

/* 파일 놓는 곳 */
.wt-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
    padding: 30px 20px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
    color: var(--text-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.wt-drop > .bi { font-size: 2rem; color: var(--cat); }
.wt-drop strong { color: var(--text); font-size: 1rem; }
.wt-drop:hover, .wt-drop.dragover, .wt-drop.drag, .wt-drop.active { border-color: var(--cat); background: var(--cat-bg); }

/* 결과, 알림, 로그 */
.wt-result { margin-top: 14px; padding: 16px 18px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); min-height: 1em; }
.wt-result:empty { display: none; }
.wt-alert { padding: 12px 14px; border-radius: 12px; font-size: .9rem; background: var(--accent-soft); color: var(--accent); }
.wt-alert.ok { background: var(--ok-soft); color: var(--ok); }
.wt-alert.error { background: var(--danger-soft); color: var(--danger); }
.wt-alert.warn { background: var(--warn-soft); color: var(--warn); }
.wt-log { font-family: var(--mono); font-size: .82rem; line-height: 1.6; white-space: pre-wrap; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; overflow: auto; }
.wt-progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.wt-progress > * { height: 100%; width: 0; background: var(--cat); border-radius: inherit; transition: width .2s; }

/* 목록, 표 */
.wt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wt-list > li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.wt-table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
:where(body.wt) :where(table) { border-collapse: collapse; width: 100%; font-size: .9rem; }
:where(body.wt) :where(th, td) { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; }
:where(body.wt) :where(th) { background: var(--surface-2); color: var(--text-2); font-weight: 600; }

.wt-footer { max-width: 960px; margin: 0 auto; padding: 0 16px 32px; text-align: center; color: var(--text-3); font-size: .82rem; }

@media (max-width: 640px) {
    .wt-topbar { padding-top: 16px; }
    .wt-back .wt-back-label { display: none; }
    .wt-page { padding-top: 20px; }
    .wt-head { gap: 12px; }
    .wt-head-icon { width: 44px; height: 44px; font-size: 1.3rem; border-radius: 12px; }
    .wt-card { padding: 18px 16px; }
    .wt-grid-2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
