/* 도구모음 공용 스타일
   Layout: 공구함 서랍처럼 — 카테고리 색 탭이 붙은 카드, 작업 화면은 왼쪽 작업대 + 오른쪽 설정 패널 */
:root {
  --bg: #edf0f3;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --ink: #141a21;
  --muted: #5a6672;
  --line: #d5dbe1;
  --accent: #ffcc00;
  --accent-ink: #141a21;
  --img: #0f8b8d;
  --vid: #d1495b;
  --aud: #6a4cc3;
  --doc: #2f6fdb;
  --txt: #b5651d;
  --des: #3f8f3a;
  --form: #9c3f73;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --err: #c53030;
  --shadow: 0 1px 0 rgba(20, 26, 33, .06), 0 6px 18px -10px rgba(20, 26, 33, .25);

  --f-display: "Black Han Sans", "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --f-body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --r: 10px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161b; --surface: #1a2027; --surface-2: #151a20; --ink: #e8edf2; --muted: #93a0ad;
    --line: #2b333c; --accent: #ffd23f; --accent-ink: #141a21;
    --img: #34b3b5; --vid: #ef6b7c; --aud: #9b83ee; --doc: #6aa0f5; --txt: #e0a060; --des: #6cc366; --form: #d77aac; --ok: #4cc283; --warn: #e0a84a; --err: #f07070;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 8px 22px -12px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161b; --surface: #1a2027; --surface-2: #151a20; --ink: #e8edf2; --muted: #93a0ad;
  --line: #2b333c; --accent: #ffd23f; --accent-ink: #141a21;
  --img: #34b3b5; --vid: #ef6b7c; --aud: #9b83ee; --doc: #6aa0f5; --txt: #e0a060; --des: #6cc366; --form: #d77aac; --ok: #4cc283; --warn: #e0a84a; --err: #f07070;
  --shadow: 0 1px 0 rgba(0,0,0,.3), 0 8px 22px -12px rgba(0,0,0,.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
img, video, canvas { max-width: 100%; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

.wrap { max-width: 1120px; margin: 0 auto; padding-inline: var(--gutter); }

/* ---------- 상단바 ---------- */
.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar .wrap { display: flex; align-items: center; gap: 16px; min-height: 58px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { height: 36px; width: auto; display: block; }
@media (max-width: 560px) { .brand-logo { height: 30px; } }
.brand-sub { font-size: 13px; color: var(--muted); }
.crumb { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); min-width: 0; }
.crumb strong { color: var(--ink); font-weight: 600; }
.topbar .spacer { flex: 1; }
.privacy-pill {
  font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
  display: inline-flex; align-items: center; gap: 6px;
}
.privacy-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* ---------- 툴 페이지 공통 ---------- */
.tool-head { padding-block: 28px 18px; display: flex; gap: 14px; align-items: flex-start; }
.tool-tag {
  flex: none; width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center;
  background: var(--cat, var(--ink)); color: #fff;
}
.tool-tag svg { width: 24px; height: 24px; }
.tool-head h1 { font-family: var(--f-display); font-weight: 400; font-size: clamp(26px, 4vw, 34px); line-height: 1.15; margin: 0; text-wrap: balance; }
.tool-head p { margin: 4px 0 0; color: var(--muted); max-width: 62ch; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; padding-bottom: 48px; align-items: start; }
@media (max-width: 860px) { .workspace { grid-template-columns: minmax(0, 1fr); } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.panel-body { padding: 18px; display: grid; gap: 16px; }
.panel h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; font-weight: 600; }
.side { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px); }
@media (max-width: 860px) { .side { position: static; } }

/* 드롭존 */
.drop {
  border: 2px dashed var(--line); border-radius: var(--r); background: var(--surface);
  padding: 40px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
  display: grid; gap: 8px; justify-items: center;
}
.drop:hover, .drop.over { border-color: var(--cat, var(--accent)); background: var(--surface-2); }
.drop strong { font-size: 17px; }
.drop span { color: var(--muted); font-size: 14px; }
.drop svg { width: 34px; height: 34px; color: var(--cat, var(--muted)); }
.drop input { display: none; }
.drop.compact { padding: 14px; grid-auto-flow: column; justify-content: center; align-items: center; }
.drop.compact svg { width: 22px; height: 22px; }

/* 폼 */
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; }
.hint { font-size: 12.5px; color: var(--muted); margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > * { min-width: 0; }
input[type="number"], input[type="text"], select {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type="number"] { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--cat, var(--ink)); }
input[type="checkbox"] { accent-color: var(--cat, var(--ink)); width: 16px; height: 16px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { text-align: center; padding: 8px 4px; font-size: 14px; cursor: pointer; background: var(--surface-2); border-left: 1px solid var(--line); }
.seg label:first-of-type { border-left: 0; }
.seg input:checked + label { background: var(--ink); color: var(--bg); font-weight: 600; }
.seg input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: -3px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px;
  padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover:not(:disabled) { border-color: var(--accent-ink); }
.btn-block { width: 100%; padding-block: 12px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }

.progress { height: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--cat, var(--accent)); transition: width .15s; }
.status { font-size: 13px; color: var(--muted); min-height: 1.3em; margin: 0; }
.status.err { color: var(--err); }
.status.ok { color: var(--ok); }

/* 파일 목록 */
.files { display: grid; gap: 8px; }
.file {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px 8px 8px;
}
.file .thumb { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--line) 0 50%) 0 0 / 12px 12px; }
.file .meta { min-width: 0; }
.file .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file .info { font-size: 12.5px; color: var(--muted); font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.file .info b { color: var(--ok); font-weight: 600; }
.file .info b.up { color: var(--warn); }
.file .acts { display: flex; gap: 6px; }
.icon-btn { border: 0; background: none; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.list-head p { margin: 0; font-size: 14px; color: var(--muted); }

/* 페이지 썸네일 격자 (PDF 도구) */
.pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.pg { position: relative; background: var(--surface); border: 2px solid var(--line); border-radius: 8px; padding: 8px; display: grid; gap: 6px; cursor: pointer; user-select: none; }
.pg canvas { width: 100%; height: auto; display: block; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); transition: transform .2s; }
.pg .no { font-size: 12px; color: var(--muted); text-align: center; font-family: var(--f-mono); }
.pg.sel { border-color: var(--cat, var(--accent)); background: color-mix(in srgb, var(--cat, var(--accent)) 10%, var(--surface)); }
.pg .tools { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; opacity: .9; z-index: 1; }
.pg .tools .icon-btn { background: var(--surface); border: 1px solid var(--line); padding: 4px; }
.pg .tools svg { width: 14px; height: 14px; }
.pg.drag { opacity: .4; }
.pg.over { outline: 3px dashed var(--cat, var(--accent)); outline-offset: 2px; }

/* 광고 자리 (검증한 직접 광고를 넣는 곳) */
.ad-slot:empty { display: none; }
.ad-slot { margin-block: 16px; text-align: center; }

.foot { border-top: 1px solid var(--line); padding-block: 22px; color: var(--muted); font-size: 13px; }
.foot .wrap { display: flex; gap: 12px 20px; flex-wrap: wrap; justify-content: space-between; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
