:root {
  --bg: #f7f7f5; --panel: #fff; --ink: #1c1b19; --muted: #74716b;
  --line: #e3e1dc; --accent: #2f6f4f; --mark: #ffe9a8; --warn: #b4472a;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.6 "Malgun Gothic", "맑은 고딕", -apple-system, system-ui, sans-serif;
}
main { max-width: 900px; margin: 0 auto; padding: 24px 20px 80px; }
a { color: var(--accent); }

.topbar {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; text-decoration: none; color: var(--ink); }
.tagline { color: var(--muted); font-size: 13px; }

.searchbar input {
  width: 100%; padding: 14px 16px; font-size: 17px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.searchbar input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.dropzone {
  margin: 14px 0; padding: 18px; text-align: center;
  border: 2px dashed var(--line); border-radius: 10px; background: var(--panel);
}
.dropzone p { margin: 4px 0; }
.linklike { color: var(--accent); cursor: pointer; text-decoration: underline; }
kbd {
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  padding: 0 4px; font-size: 12px; background: #fafaf8;
}

.status { color: var(--muted); font-size: 13px; min-height: 20px; }
.muted { color: var(--muted); }
.resultcount { margin: 14px 0 8px; font-size: 13px; }
.empty { margin-top: 24px; color: var(--muted); }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.card {
  display: flex; gap: 14px; padding: 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px;
}
.thumb {
  flex: 0 0 96px; width: 96px; height: 96px; display: flex;
  align-items: center; justify-content: center; overflow: hidden;
  background: #f1efea; border-radius: 6px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.noimg { font-size: 30px; }
.card .body { min-width: 0; flex: 1; }
.filename { font-weight: 600; text-decoration: none; word-break: break-all; }
.meta { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.tag {
  display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px;
  background: #eceae4; font-size: 11px;
}
.tag.warn { background: #f6e0d9; color: var(--warn); }
.snippet {
  margin: 4px 0; font-size: 14px; word-break: break-all;
  overflow-wrap: anywhere;
}
.pageno { color: var(--muted); font-size: 12px; margin-right: 6px; }
mark { background: var(--mark); padding: 0 1px; border-radius: 2px; }

.back { font-size: 13px; text-decoration: none; }
.doctitle { font-size: 20px; margin: 8px 0 4px; word-break: break-all; }
.error { color: var(--warn); }
.preview img, .preview embed {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
.preview embed { height: 70vh; }
.text pre {
  white-space: pre-wrap; word-break: break-all; margin: 0 0 14px;
  padding: 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; font: 13px/1.7 "Malgun Gothic", monospace;
}

@media (max-width: 720px) {
  .card { flex-direction: column; }
  .thumb { width: 100%; height: 140px; flex-basis: auto; }
}

/* --- 상단 네비 --- */
.topbar nav { margin-left: auto; display: flex; gap: 16px; }
.topbar nav a { text-decoration: none; color: var(--muted); font-size: 14px; }
.topbar nav a.on { color: var(--ink); font-weight: 600; }

/* --- 보관함 목록 --- */
.listhead h1 { font-size: 20px; margin: 4px 0; }
.listhead p { margin: 0 0 14px; font-size: 13px; }

.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filters a {
  padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); text-decoration: none; color: var(--muted); font-size: 13px;
}
.filters a.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.grid {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.tile {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; display: flex; flex-direction: column;
}
.tilethumb {
  display: flex; align-items: center; justify-content: center;
  height: 150px; background: #f1efea; overflow: hidden;
}
.tilethumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.tilebody { padding: 10px 12px 12px; }
.tilebody .filename { font-size: 13px; display: block; line-height: 1.4; }
.tilebody .meta { margin: 4px 0 0; }

.del {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px;
  border: none; border-radius: 6px; background: rgba(28, 27, 25, .55); color: #fff;
  font-size: 17px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .12s;
}
.tile:hover .del, .del:focus { opacity: 1; }
.del:hover { background: var(--warn); }
.del.inline {
  position: static; width: auto; height: auto; padding: 0; background: none;
  color: var(--warn); font-size: 12px; opacity: 1; text-decoration: underline;
}

.pager { display: flex; gap: 14px; align-items: center; justify-content: center; margin: 22px 0; }
.pager a { text-decoration: none; font-size: 14px; }

.versions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin: 10px 0 0; padding: 8px 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}
.versions .on { font-weight: 600; }

/* --- 추출 텍스트 렌더링 --- */
.md {
  padding: 14px 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; font-size: 13.5px; overflow-x: auto;
}
.md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 16px 0 6px; font-size: 14px; line-height: 1.5;
}
.md > :first-child { margin-top: 0; }
.md p { margin: 0 0 10px; word-break: break-all; overflow-wrap: anywhere; }
.md table { border-collapse: collapse; margin: 10px 0; width: 100%; }
.md th, .md td {
  border: 1px solid var(--line); padding: 6px 9px; text-align: left;
  vertical-align: top; font-size: 13px;
}
.md th { background: #f1efea; font-weight: 600; }

/* --- 처리 진행 패널 --- */
.queue {
  margin: 14px 0 20px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.queuehead {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600;
}
.queuehead .muted { font-weight: 400; font-size: 12px; }
.queue ul { list-style: none; margin: 0; padding: 0; }

.qitem {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.qitem:first-child { border-top: none; }
.qbody { flex: 1; min-width: 0; }
.qname {
  display: block; font-size: 13px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.qstate { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* 남은 시간을 알 수 없으므로 진행률 대신 흐르는 막대로 살아있음을 보인다 */
.qbar { height: 3px; margin-top: 6px; border-radius: 2px; background: #eceae4; overflow: hidden; }
.qbar i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.qitem.processing .qbar i { width: 40%; animation: slide 1.4s ease-in-out infinite; }
.qitem.pending .qbar i { width: 100%; background: #dedbd4; }
.qitem.done .qbar, .qitem.failed .qbar { display: none; }

.qicon {
  width: 20px; height: 20px; flex: 0 0 20px; display: flex;
  align-items: center; justify-content: center; border-radius: 50%; font-size: 12px;
}
.qitem.processing .qicon {
  border: 2px solid #dedbd4; border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
.qitem.pending .qicon { border: 2px solid #e6e3dd; }
.qitem.done .qicon { background: var(--accent); color: #fff; }
.qitem.failed .qicon { background: var(--warn); color: #fff; }
.qitem.done, .qitem.failed { animation: settle .35s ease; }
.qitem.failed .qstate { color: var(--warn); }

@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes settle { from { background: #f3f7f4; } to { background: transparent; } }

/* 보관함 타일: 처리 중인 항목은 자리만 잡고 반짝인다 */
.tile.busy .tilethumb {
  background: linear-gradient(100deg, #f1efea 30%, #e7e4dd 50%, #f1efea 70%);
  background-size: 300% 100%; animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -150% 0; } }

@media (prefers-reduced-motion: reduce) {
  .qitem.processing .qbar i, .qitem.processing .qicon,
  .tile.busy .tilethumb, .qitem.done, .qitem.failed { animation: none; }
  .qitem.processing .qbar i { width: 100%; }
}

/* --- PDF 미리보기 --- */
.pdfbox {
  position: relative; height: 70vh; min-height: 360px;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel);
}
/* iframe이 비어도 뒤에 안내가 보이도록 아래에 깔아 둔다 */
.pdffallback {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 20px;
}
.pdffallback p { margin: 0; font-size: 13px; }
.pdfbox iframe { position: relative; width: 100%; height: 100%; border: 0; }
.pdficon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 64px; margin-bottom: 8px; border-radius: 6px;
  background: #f1efea; border: 1px solid var(--line);
  font-size: 12px; font-weight: 700; letter-spacing: .5px; color: var(--warn);
}

/* 썸네일이 없는 PDF 타일도 빈 칸 대신 아이콘을 보인다 */
.tilethumb .noimg { font-size: 30px; color: var(--muted); }

.pdficon.sheet { color: #1d6f42; }  /* 엑셀 초록 */

/* ===== 문서 뷰어 ===== */
main.wide { max-width: 1240px; }

.dochead { margin-bottom: 14px; }
.dochead .back { font-size: 13px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 9px 18px; border: 1px solid transparent; border-bottom: none;
  border-radius: 8px 8px 0 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--muted);
}
.tab:hover { color: var(--ink); }
.tab.on {
  background: var(--panel); border-color: var(--line); color: var(--ink); font-weight: 600;
  margin-bottom: -1px; border-bottom: 1px solid var(--panel);
}

.panel {
  background: var(--panel); border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 10px 10px; padding: 16px;
}

.toolbar {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.finder { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 240px; }
.finder input {
  flex: 1; max-width: 340px; padding: 7px 11px; font: inherit; font-size: 13px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--bg);
}
.finder input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#findcount { font-size: 12px; min-width: 52px; font-variant-numeric: tabular-nums; }

.ghost {
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg); cursor: pointer; font: inherit; font-size: 12px; color: var(--ink);
}
.ghost:hover:not(:disabled) { background: #eceae4; }
.ghost:disabled { opacity: .4; cursor: default; }

.toc { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.toc a {
  padding: 4px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); text-decoration: none; color: var(--muted); font-size: 12px;
}
.toc a.on, .toc a:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.page + .page { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.page .pagehead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 8px;
}
.page .pagehead h2 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }

/* 탭 전환으로 본문이 전체 폭을 쓰므로 표에 숨통이 트인다 */
.md { border: none; padding: 0; background: none; font-size: 14px; }
.md table { font-size: 13px; }
.md th, .md td { padding: 7px 10px; }

mark.hit { background: #ffe9a8; }
mark.hit.on { background: #ffbf47; box-shadow: 0 0 0 2px #ffbf47; }

.srcimg { width: 100%; border: 1px solid var(--line); border-radius: 8px; }

@media (max-width: 720px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .finder input { max-width: none; }
}

.pdficon.slide { color: #c43e1c; }  /* 파워포인트 주황 */

/* --- 실패 재시도 --- */
.notice {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 16px; padding: 11px 14px;
  background: #f9ece7; border: 1px solid #edd3c9; border-radius: 9px; font-size: 13px;
}

.tile .retry {
  position: absolute; top: 6px; right: 38px; padding: 3px 9px;
  border: none; border-radius: 6px; background: rgba(28, 27, 25, .55); color: #fff;
  font: inherit; font-size: 11px; cursor: pointer; opacity: 0; transition: opacity .12s;
}
.tile:hover .retry, .tile .retry:focus { opacity: 1; }
.tile .retry:hover:not(:disabled) { background: var(--accent); }
.tile .retry:disabled { opacity: 1; background: #8a8781; cursor: default; }

.failbox {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-top: 10px; padding: 12px 14px;
  background: #f9ece7; border: 1px solid #edd3c9; border-radius: 9px;
}
.failbox p { margin: 4px 0 0; font-size: 12px; }

.qretry { flex: 0 0 auto; padding: 4px 10px; font-size: 11px; }

.pdficon.word { color: #185abd; }  /* 워드 파랑 */

/* --- 업로드 영역 문구 --- */
.droptitle { font-size: 15px; font-weight: 600; }
.formats { margin-top: 8px; font-size: 12px; color: var(--muted); letter-spacing: .2px; }

/* --- 화면 어디에 놓아도 받는 안내 --- */
#dropveil {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center;
  background: rgba(247, 247, 245, .88); backdrop-filter: blur(2px);
  pointer-events: none;
}
body.dragging #dropveil { display: flex; }
.veiltext {
  padding: 22px 34px; border: 2px dashed var(--accent); border-radius: 14px;
  background: var(--panel); font-size: 16px; font-weight: 600; color: var(--accent);
}
body.dragging .dropzone { border-color: var(--accent); background: #eef5f0; }

/* --- 문서 본문 서식 --- */
.md h2 { font-size: 17px; margin: 22px 0 8px; }
.md h3 { font-size: 15px; margin: 18px 0 6px; }
.md h4, .md h5, .md h6 { font-size: 14px; margin: 14px 0 6px; }
.md strong { font-weight: 700; }
.md em { font-style: italic; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md li > ul, .md li > ol { margin: 2px 0; }
.md blockquote {
  margin: 10px 0; padding: 8px 14px;
  border-left: 3px solid var(--line); background: #faf9f7;
  color: var(--muted); font-size: 13px;
}
.md blockquote p { margin: 0; }

/* --- 접속 암호 --- */
.gate {
  max-width: 340px; margin: 60px auto; padding: 26px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.gate h1 { font-size: 17px; margin: 0 0 4px; }
.gate p { margin: 0 0 14px; font-size: 13px; }
.gate input[type="password"] {
  width: 100%; padding: 10px 12px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.gate button {
  width: 100%; margin-top: 10px; padding: 10px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
