:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e5e8f0;
  --line-strong: #d6dbe8;
  --text: #1b2130;
  --muted: #6b7280;
  --muted-2: #98a0b3;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-weak: #eef0ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-weak: #fef2f2;
  --ok: #059669;
  --warn: #d97706;
  --row-h: 34px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 28, 51, .06), 0 8px 24px rgba(20, 28, 51, .06);
  font-synthesis: none;
}

* { box-sizing: border-box; }

/* hidden 속성은 항상 확실히 감춘다(뷰 전환·모달·토스트 등) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Pretendard Variable", "Malgun Gothic", "Apple SD Gothic Neo",
    "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app { display: flex; height: 100vh; width: 100%; overflow: hidden; }

/* ---------------- 사이드바 ---------------- */
.sidebar {
  width: 238px;
  flex: 0 0 238px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 12px 12px;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px 12px; }
.brand > div { min-width: 0; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-size: 17px;
  box-shadow: 0 6px 14px rgba(99, 102, 241, .35);
}
.brand-title { font-size: 13.5px; font-weight: 700; letter-spacing: -.2px; }
.brand-sub { font-size: 11px; color: var(--muted-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-block { padding: 10px 0; border-top: 1px solid var(--line); }
.side-block:first-of-type { border-top: 0; padding-top: 4px; }
.side-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 700; color: var(--muted-2);
  letter-spacing: .3px; text-transform: uppercase;
  padding: 2px 6px 8px;
}
.side-list { display: flex; flex-direction: column; gap: 2px; }

.drive-item, .fav-item {
  display: flex; align-items: center; gap: 8px;
  border: 0; background: transparent; text-align: left;
  padding: 7px 8px; border-radius: 8px; width: 100%;
  font-size: 12.5px; color: #2a3242;
}
.drive-item:hover, .fav-item:hover { background: #f3f5fb; }
.drive-item.active, .fav-item.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.drive-icon { font-size: 14px; }
.drive-meta { margin-left: auto; font-size: 10.5px; color: var(--muted-2); font-weight: 500; }
.drive-bar { height: 3px; border-radius: 3px; background: #eceef6; margin-top: 3px; overflow: hidden; }
.drive-bar > i { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #a78bfa); }
.fav-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-del {
  border: 0; background: transparent; color: var(--muted-2);
  font-size: 12px; padding: 0 2px; border-radius: 4px; visibility: hidden;
}
.fav-item:hover .fav-del { visibility: visible; }
.fav-del:hover { color: var(--danger); }

.side-action {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 1px solid var(--line); background: #fbfcff;
  border-radius: 9px; padding: 9px 10px; margin-bottom: 6px; text-align: left;
}
.side-action:hover { border-color: #c7cdf0; background: #f6f7ff; }
.side-action-icon { font-size: 15px; }
.side-action strong { display: block; font-size: 12.5px; font-weight: 600; }
.side-action small { color: var(--muted-2); font-size: 10.5px; }

.mini-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  font-size: 10.5px; padding: 2px 7px; color: var(--muted);
}
.mini-btn:hover { border-color: var(--accent); color: var(--accent); }

.side-status { margin-top: auto; font-size: 11.5px; }

/* 사이드바 파일 종류 요약 */
.kind-list { gap: 1px; }
.kind-row {
  display: flex; align-items: center; gap: 7px; width: 100%;
  border: 0; background: transparent; text-align: left;
  padding: 3px 8px; border-radius: 7px; font-size: 11.5px; color: #2a3242;
}
.kind-row:hover { background: #f3f5fb; }
.kind-row.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.kind-row .kr-ico { font-size: 12px; width: 15px; text-align: center; }
.kind-row .kr-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kind-row .kr-count { margin-left: auto; font-size: 10.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.kind-row.active .kr-count { color: var(--accent); }
.stat-row { display: flex; justify-content: space-between; padding: 4px 6px; color: var(--muted); }
.stat-row b { color: #333c50; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-note { font-size: 10.5px; color: var(--muted-2); padding: 2px 6px; }

.progress { height: 5px; border-radius: 5px; background: #eceef6; overflow: hidden; margin: 6px; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width .25s ease; }

/* ---------------- 메인 ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar { display: flex; gap: 12px; align-items: center; padding: 14px 18px 10px; }
.searchbox {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 12px; height: 42px;
  box-shadow: var(--shadow);
}
.searchbox:focus-within { border-color: #b9befa; box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.search-icon { font-size: 14px; opacity: .7; }
#searchInput {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 14px; height: 100%; min-width: 0;
}
#searchInput::placeholder { color: var(--muted-2); font-size: 12.5px; }
.search-time { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.view-tabs { display: flex; background: #e9ecf6; border-radius: 10px; padding: 3px; }
.tab {
  border: 0; background: transparent; border-radius: 8px;
  padding: 7px 14px; font-size: 12.5px; color: #4a5468; font-weight: 600;
}
.tab.active { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(20, 28, 51, .12); }

.filterbar { display: flex; align-items: center; gap: 6px; padding: 0 18px 8px; flex-wrap: wrap; row-gap: 6px; }
.filterbar.sub { padding-bottom: 10px; }
.filter-label { font-size: 11px; color: var(--muted-2); margin-right: 2px; white-space: nowrap; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 20px;
  padding: 3px 10px; font-size: 11px; color: #4b5568; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px; line-height: 1.5;
}
.chip:hover { border-color: #c3c8f5; color: var(--accent); background: var(--accent-weak); }
.chip.active {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 1px 4px rgba(79, 70, 229, .28);
}
.chip.active:hover { background: var(--accent-hover); color: #fff; }
.chip.sm { font-size: 10.5px; padding: 2px 9px; color: var(--muted); background: #fbfcff; }
.filter-spacer { flex: 1; }
.result-count { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0 18px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }

.table-head {
  display: grid;
  grid-template-columns: 24px minmax(140px, 1.5fr) 92px minmax(130px, 1.7fr) 84px 116px;
  gap: 8px; align-items: center;
  padding: 0 12px; height: 32px;
  border-bottom: 1px solid var(--line);
  font-size: 11px; color: var(--muted-2); font-weight: 700; letter-spacing: .2px;
  background: #fbfcff;
}

.list-scroll { position: relative; flex: 1; overflow: auto; outline: none; }
.list-spacer { position: relative; width: 100%; }
.list-body { position: absolute; top: 0; left: 0; right: 0; }

.row {
  position: absolute; left: 0; right: 0; height: var(--row-h);
  display: grid;
  grid-template-columns: 24px minmax(140px, 1.5fr) 92px minmax(130px, 1.7fr) 84px 116px;
  gap: 8px; align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid #f2f4f9;
  font-size: 12.5px; cursor: default; user-select: none;
}
.row:hover { background: #f7f8fe; }
.row.selected { background: var(--accent-weak); }
.row.selected .name { color: var(--accent); font-weight: 600; }
.row .icon { font-size: 14px; text-align: center; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.row .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11.5px; }
.row .size { text-align: right; font-variant-numeric: tabular-nums; color: #414b60; font-size: 11.5px; }
.row .date { text-align: right; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.row mark { background: #ffe9a8; color: inherit; border-radius: 3px; padding: 0 1px; }

/* 종류 배지 — 문서는 PDF/한글/엑셀처럼 한 단계 더 세분화해서 보여 준다 */
.kind-badge {
  display: inline-flex; align-items: center; gap: 3px;
  max-width: 100%; padding: 1px 7px; border-radius: 20px;
  font-size: 10.5px; font-weight: 600; white-space: nowrap; overflow: hidden;
  background: #f1f3f9; color: #4b5568; border: 1px solid #e7eaf3;
}
.kind-badge .kb-ico { font-size: 10.5px; line-height: 1; }
.kind-badge .kb-txt { overflow: hidden; text-overflow: ellipsis; }
.kind-badge[data-cat="folder"] { background: #fff7e6; border-color: #f6e2b8; color: #a16207; }
.kind-badge[data-cat="doc"] { background: #eef2ff; border-color: #dfe3fb; color: #4338ca; }
.kind-badge[data-cat="image"] { background: #f0fdf4; border-color: #cdeddb; color: #15803d; }
.kind-badge[data-cat="video"] { background: #fdf2f8; border-color: #f5d8e6; color: #be185d; }
.kind-badge[data-cat="audio"] { background: #f5f3ff; border-color: #e3dcfb; color: #6d28d9; }
.kind-badge[data-cat="exec"] { background: #fff1f2; border-color: #f7d4d7; color: #be123c; }
.kind-badge[data-cat="archive"] { background: #fffbeb; border-color: #f7e6b8; color: #b45309; }
.kind-badge[data-cat="code"] { background: #ecfeff; border-color: #c9eef3; color: #0e7490; }
.kind-badge[data-cat="font"] { background: #f8fafc; border-color: #e3e8ef; color: #475569; }
.kind-badge[data-cat="other"] { background: #f8fafc; border-color: #e5e9f0; color: #6b7280; }

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); padding: 30px; }
.empty.small { padding: 40px 20px; }
.empty-icon { font-size: 26px; opacity: .8; }
.empty-title { font-size: 13.5px; font-weight: 600; color: #3b4459; }
.empty-desc { font-size: 11.5px; color: var(--muted-2); }

/* ---------------- 중복 파일 ---------------- */
.dup-head { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); background: #fbfcff; }
.dup-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.dup-card { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.dup-card span { font-size: 10.5px; color: var(--muted-2); }
.dup-card b { font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.dup-card.accent { background: linear-gradient(135deg, #eef0ff, #f7f5ff); border-color: #d9dcfb; }
.dup-card.accent b { color: var(--accent); }
.dup-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.keep-rule { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.keep-rule select { border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; background: #fff; font-size: 11.5px; }
.dup-list { flex: 1; overflow: auto; padding: 10px 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.dup-progress { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.dup-progress .progress { flex: 1; margin: 0; }

.dup-group { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.dup-group-head {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: #f8f9fe; border-bottom: 1px solid var(--line);
}
.dup-group-head .g-size { font-weight: 700; font-size: 12.5px; }
.dup-group-head .g-badge { font-size: 10.5px; background: #eef0ff; color: var(--accent); border-radius: 20px; padding: 2px 8px; font-weight: 600; }
.dup-group-head .g-waste { margin-left: auto; font-size: 11.5px; color: var(--danger); font-weight: 600; }
.dup-group-head .g-btn { border: 1px solid var(--line-strong); background: #fff; border-radius: 7px; padding: 4px 9px; font-size: 11px; }
.dup-group-head .g-btn:hover { border-color: var(--accent); color: var(--accent); }
.dup-file {
  display: grid; grid-template-columns: 22px 20px minmax(0, 1fr) 90px 128px;
  gap: 8px; align-items: center; padding: 6px 12px; font-size: 12px;
  border-bottom: 1px solid #f4f5fa;
}
.dup-file:last-child { border-bottom: 0; }
.dup-file.keep { background: #f6fdf9; }
.dup-file.checked { background: var(--danger-weak); }
.dup-file .f-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #3b4459; }
.dup-file .f-size { text-align: right; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.dup-file .f-date { text-align: right; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.keep-badge { font-size: 10px; color: var(--ok); border: 1px solid #cdeee1; background: #effaf5; border-radius: 20px; padding: 1px 6px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; }

/* ---------------- 하단 상태바 ---------------- */
.statusbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 18px 12px; font-size: 11.5px; color: var(--muted);
}
.status-left { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-right { display: flex; align-items: center; gap: 8px; }
.selected-info { font-variant-numeric: tabular-nums; }

.btn {
  border: 1px solid var(--line-strong); background: #fff; color: #333c50;
  border-radius: 8px; padding: 7px 12px; font-size: 12px; font-weight: 600;
}
.btn:hover { border-color: #b9befa; color: var(--accent); background: #f8f8ff; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); color: #fff; }
.btn.danger { background: #fff; border-color: #f0c4c4; color: var(--danger); }
.btn.danger:hover { background: var(--danger-weak); border-color: var(--danger); color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.solid:hover { background: var(--danger-hover); }
.btn.small { padding: 5px 10px; font-size: 11.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------- 컨텍스트 메뉴 / 모달 / 토스트 ---------------- */
.ctx-menu {
  position: fixed; z-index: 60; min-width: 186px; padding: 5px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(20, 28, 51, .16);
}
.ctx-item { display: flex; justify-content: space-between; gap: 12px; width: 100%; border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 7px; font-size: 12px; }
.ctx-item:hover { background: #f4f5fb; }
.ctx-item .kbd { color: var(--muted-2); font-size: 10.5px; }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: var(--danger-weak); }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 6px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17, 22, 38, .42);
  display: flex; align-items: center; justify-content: center; z-index: 80; padding: 24px;
}
.modal {
  width: min(720px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(15, 20, 35, .3); overflow: hidden;
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head .m-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--danger-weak); color: var(--danger); font-size: 16px; }
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-head .m-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 14px 18px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fbfcff; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.summary-cell { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fbfcff; }
.summary-cell span { font-size: 10.5px; color: var(--muted-2); display: block; }
.summary-cell b { font-size: 14px; font-variant-numeric: tabular-nums; }

.file-preview {
  border: 1px solid var(--line); border-radius: 9px; max-height: 210px; overflow: auto; background: #fbfcff;
}
.file-preview .fp-row { display: flex; gap: 8px; padding: 6px 10px; border-bottom: 1px solid #f1f3f9; font-size: 11.5px; }
.file-preview .fp-row:last-child { border-bottom: 0; }
.fp-row .fp-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; color: #37405a; }
.fp-row .fp-size { color: var(--muted); font-variant-numeric: tabular-nums; }

.mode-select { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode-option { border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 10px; cursor: pointer; background: #fff; }
.mode-option.selected { border-color: var(--danger); background: var(--danger-weak); }
.mode-option strong { display: block; font-size: 12.5px; margin-bottom: 2px; }
.mode-option small { font-size: 10.5px; color: var(--muted); }

.warn-box {
  border: 1px solid #f3cfcf; background: var(--danger-weak); color: #9f1239;
  border-radius: 9px; padding: 10px 12px; font-size: 12px; line-height: 1.55;
}
.warn-box b { color: var(--danger-hover); }
.confirm-check { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: #414b60; }
.confirm-check input { margin-top: 2px; }
.final-count { font-size: 30px; font-weight: 800; letter-spacing: -1px; color: var(--danger); font-variant-numeric: tabular-nums; }
.step-dots { display: flex; gap: 5px; margin-left: auto; }
.step-dot { width: 6px; height: 6px; border-radius: 50%; background: #d9dded; }
.step-dot.on { background: var(--danger); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #1f2534; color: #fff; font-size: 12.5px;
  padding: 10px 16px; border-radius: 10px; z-index: 100;
  box-shadow: 0 12px 30px rgba(10, 15, 30, .3); max-width: 70vw;
}
.toast.err { background: #7f1d1d; }

.mode-badge { font-size: 9.5px; color: var(--muted-2); border: 1px solid var(--line); border-radius: 20px; padding: 1px 6px; margin-left: 6px; }
