:root {
  /* 에디토리얼 미니멀: 잉크 블랙 + 오프화이트, 무채색 */
  --bg: #f6f5f1;             /* 오프화이트 캔버스 */
  --surface: #ffffff;
  --sidebar-bg: #f2f1ec;
  --paper: #efeee9;          /* 은은한 카드/블록 */
  --ink: #191919;            /* 잉크 블랙 (본문/주요) */
  --ink-2: #55534d;          /* 보조 */
  --ink-3: #8f8c84;          /* 흐린 톤 */
  --line: rgba(25,25,25,.11);
  --line-strong: rgba(25,25,25,.20);
  --hover: rgba(25,25,25,.05);
  /* 기능 신호색 (저채도) */
  --avail: #4f6350;          /* 세이지 그린 */
  --out: #9a5544;            /* 뮤트 테라코타 */
  --radius: 4px;
  --serif: "Newsreader", "Noto Serif KR", Georgia, "Nanum Myeongjo", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI",
          "Malgun Gothic", Helvetica, Arial, sans-serif;
  --shadow: 0 1px 2px rgba(25,25,25,.05), 0 10px 26px rgba(25,25,25,.09);
  --shadow-hover: 0 3px 6px rgba(25,25,25,.08), 0 18px 40px rgba(25,25,25,.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: var(--sans);
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-size: 15px; line-height: 1.55;
}
.layout { display: flex; min-height: 100vh; }

/* ─────────── 사이드바 ─────────── */
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar-bg);
  border-right: 1px solid var(--line); padding: 26px 14px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
}
.workspace { padding: 0 10px 26px; }
.ws-name { font-family: var(--serif); font-size: 19px; font-weight: 500;
  line-height: 1.25; color: var(--ink); letter-spacing: -.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border: none;
  background: none; cursor: pointer; border-radius: var(--radius); font-size: 14px;
  font-weight: 500; color: var(--ink-2); font-family: inherit; text-align: left;
  transition: background .12s, color .12s;
}
.ni-icon { width: 17px; height: 17px; flex-shrink: 0; fill: none; stroke: currentColor;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { background: rgba(25,25,25,.07); color: var(--ink); }

/* ─────────── 메인 ─────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 46px; display: flex; align-items: center; padding: 0 28px;
  border-bottom: 1px solid var(--line); font-size: 12px; color: var(--ink-3);
  letter-spacing: .14em; text-transform: uppercase;
  position: sticky; top: 0; background: rgba(246,245,241,.82);
  backdrop-filter: blur(10px); z-index: 5;
}
.content { max-width: 940px; width: 100%; margin: 0 auto; padding: 64px 56px 96px; }

.eyebrow { font-size: 11.5px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600; margin-bottom: 14px; }
.page-title { font-family: var(--serif); font-size: 46px; font-weight: 500;
  letter-spacing: -.02em; line-height: 1.05; }
.page-desc { color: var(--ink-2); font-size: 15.5px; margin-top: 14px; max-width: 52ch; }

/* 통계(클릭형 탭) */
.callouts { display: flex; gap: 30px; margin: 34px 0 4px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.callout-stat {
  display: flex; align-items: baseline; gap: 8px; background: none; border: none;
  padding: 4px 2px 14px; cursor: pointer; font-family: inherit; position: relative;
  color: var(--ink-3); transition: color .14s;
}
.callout-stat::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--ink); transform: scaleX(0); transform-origin: left;
  transition: transform .18s ease; }
.callout-stat:hover { color: var(--ink-2); }
.callout-stat.active { color: var(--ink); }
.callout-stat.active::after { transform: scaleX(1); }
.callout-stat .n { font-family: var(--serif); font-size: 26px; font-weight: 500;
  letter-spacing: -.01em; color: var(--ink); }
.callout-stat .l { font-size: 13px; }

/* 툴바 */
.toolbar { display: flex; gap: 18px; margin: 30px 0 30px; flex-wrap: wrap;
  align-items: center; justify-content: space-between; }
.search {
  flex: 1; min-width: 220px; display: flex; align-items: center; gap: 9px;
  border-bottom: 1px solid var(--line-strong); padding: 0 2px;
  transition: border-color .15s;
}
.search:focus-within { border-color: var(--ink); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--ink-3); stroke-width: 1.8; stroke-linecap: round; }
.search input { flex: 1; border: none; outline: none; background: none; font-family: inherit;
  font-size: 15px; padding: 11px 0; color: var(--ink); }
.search input::placeholder { color: var(--ink-3); }

.segment { display: inline-flex; gap: 4px; }
.seg-btn { border: none; background: none; cursor: pointer; font-family: inherit; font-size: 13px;
  font-weight: 500; color: var(--ink-3); padding: 6px 10px; border-radius: var(--radius);
  transition: color .12s, background .12s; }
.seg-btn:hover { color: var(--ink-2); background: var(--hover); }
.seg-btn.active { color: var(--ink); background: rgba(25,25,25,.07); }

/* ─────────── 책장 그리드 ─────────── */
.shelf {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: 40px 28px;
}
.book { cursor: pointer; display: flex; flex-direction: column; gap: 12px; }

.cover {
  position: relative; width: 100%; aspect-ratio: 2 / 3; border-radius: 2px 4px 4px 2px;
  overflow: hidden; box-shadow: var(--shadow);
  transition: transform .22s ease, box-shadow .22s ease;
}
.book:hover .cover { transform: translateY(-6px); box-shadow: var(--shadow-hover); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .35s ease; }
.cover img.loaded { opacity: 1; }

/* 생성 표지 — 무채색 페이퍼 + 세리프 */
.cover-gen { position: absolute; inset: 0; display: flex; flex-direction: column;
  justify-content: space-between; padding: 18px 15px 15px; color: var(--ink);
  border-left: 2px solid rgba(25,25,25,.12); }
.cover-gen .cg-title { font-family: var(--serif); font-size: 16px; font-weight: 500;
  line-height: 1.28; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.cover-gen .cg-author { font-size: 11px; color: var(--ink-2); letter-spacing: .02em;
  text-transform: uppercase; }

/* 상태 라벨(리본 대체) */
.ribbon { position: absolute; top: 10px; right: 10px;
  background: rgba(25,25,25,.9); color: #f6f5f1; font-size: 10px; font-weight: 600;
  letter-spacing: .1em; padding: 3px 8px; border-radius: 2px; }

.book-info { display: flex; flex-direction: column; gap: 3px; }
.book-title { font-family: var(--serif); font-size: 15.5px; font-weight: 500; line-height: 1.3;
  letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book-author { font-size: 12.5px; color: var(--ink-2); }
.book-status { font-size: 12px; font-weight: 500; margin-top: 3px; display: flex;
  align-items: center; gap: 6px; color: var(--ink-2); }
.book-status .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.book-status.avail .dot { background: var(--avail); }
.book-status.out .dot { background: var(--out); }

.db-empty { color: var(--ink-3); font-size: 14.5px; padding: 48px 4px; text-align: center; }

/* 버튼 */
.btn { border: 1px solid transparent; cursor: pointer; font-family: inherit; font-weight: 500;
  font-size: 14px; padding: 10px 20px; border-radius: var(--radius); transition: all .15s;
  letter-spacing: .01em; }
.btn.primary { background: var(--ink); color: #f6f5f1; }
.btn.primary:hover { background: #000; }
.btn.ghost { background: none; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--hover); }
.btn.block { width: 100%; }
.btn.small { padding: 6px 14px; font-size: 13px; }

/* 공통 블록 헤더 */
.block-h { font-family: var(--serif); font-size: 19px; font-weight: 500; letter-spacing: -.01em;
  margin: 30px 0 14px; color: var(--ink); }

/* 콜아웃(파일 메타) */
.callout { display: flex; align-items: center; gap: 10px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; font-size: 14px;
  color: var(--ink-2); margin-bottom: 20px; }

/* 업로드 비밀번호 게이트 */
.gate { text-align: center; padding: 60px 20px; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius); margin-top: 30px; }
.gate-icon { width: 34px; height: 34px; fill: none; stroke: var(--ink-2); stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round; }
.gate-title { font-family: var(--serif); font-size: 20px; font-weight: 500; margin-top: 16px; }
.gate-desc { font-size: 14px; color: var(--ink-2); margin-top: 6px; }
.gate-form { display: flex; gap: 8px; justify-content: center; margin-top: 22px; }
.gate-form input { font-family: inherit; font-size: 15px; padding: 11px 14px; width: 220px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); outline: none;
  background: var(--surface); color: var(--ink); }
.gate-form input:focus { border-color: var(--ink); }

/* 업로드 */
.dropzone { border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--paper);
  padding: 54px 20px; text-align: center; cursor: pointer; transition: all .18s;
  display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 28px; }
.dropzone:hover, .dropzone.drag { border-color: var(--ink); background: #eae9e3; }
.dz-icon { width: 32px; height: 32px; fill: none; stroke: var(--ink-2); stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round; }
.dropzone p { font-size: 15px; color: var(--ink-2); }
.dropzone strong { color: var(--ink); font-weight: 600; }
.dropzone .hint { font-size: 13px; color: var(--ink-3); letter-spacing: .04em; }

.preview-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 22px; }
.preview { width: 100%; border-collapse: collapse; font-size: 13px; }
.preview th, .preview td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.preview th { background: var(--paper); color: var(--ink-2); font-weight: 600; }
.preview tr:last-child td { border-bottom: none; }

.map-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 6px; }
.map-grid label { display: flex; flex-direction: column; gap: 7px; font-size: 12px; font-weight: 600;
  color: var(--ink-2); letter-spacing: .04em; text-transform: uppercase; }
.map-grid .req { color: var(--out); }
select { font-family: inherit; font-size: 14px; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; outline: none;
  text-transform: none; letter-spacing: 0; font-weight: 400; }
select:focus { border-color: var(--ink); }
.mode-hint { font-size: 13px; color: var(--ink-3); margin-top: 12px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; }

/* 표(대출 현황) */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 13px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.data-table th { color: var(--ink-3); font-weight: 600; font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .muted { color: var(--ink-3); }
.person { display: inline-flex; align-items: center; gap: 8px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #f6f5f1;
  font-size: 11px; font-weight: 600; display: grid; place-items: center; }
.tag { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 2px; letter-spacing: .06em;
  text-transform: uppercase; border: 1px solid var(--line-strong); }
.tag.out { border-color: var(--out); color: var(--out); }
.tag.done { color: var(--ink-3); }
.table-empty { color: var(--ink-3); font-size: 14px; padding: 8px 2px; }

/* 모달 (책 상세) */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,19,17,.42); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 50; animation: fade .16s ease; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 32px; width: 460px; max-width: 92vw;
  box-shadow: 0 30px 80px rgba(20,19,17,.34); animation: pop .2s cubic-bezier(.2,.9,.3,1.1); }
.modal-detail { display: flex; gap: 24px; }
.modal-detail .cover { width: 124px; flex-shrink: 0; }
.md-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.md-title { font-family: var(--serif); font-size: 25px; font-weight: 500; line-height: 1.2; letter-spacing: -.01em; }
.md-meta { font-size: 14.5px; color: var(--ink-2); margin-top: 8px; }
.md-isbn { font-size: 12px; color: var(--ink-3); margin-top: 6px; letter-spacing: .04em; }
.md-extra { font-size: 12.5px; color: var(--ink-2); margin-top: 12px; line-height: 1.6; }
.md-status { margin-top: 16px; }
.md-actions { margin-top: auto; padding-top: 22px; }
.modal input { width: 100%; font-family: inherit; font-size: 15px; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); outline: none; margin-bottom: 10px;
  background: var(--surface); color: var(--ink); }
.modal input:focus { border-color: var(--ink); }

/* 반납 확인 모달 */
#confirmModal { z-index: 55; }
.modal.confirm { width: 400px; text-align: center; }
.confirm-title { font-family: var(--serif); font-size: 24px; font-weight: 500; }
.confirm-msg { font-size: 15px; color: var(--ink-2); margin-top: 12px; }
.confirm-msg b { color: var(--ink); font-weight: 600; }
.confirm-note { font-size: 13px; color: var(--ink-3); margin-top: 12px; }
.confirm-borrower { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 15px;
  font-size: 14px; font-weight: 500; }
.modal.confirm .actions { justify-content: center; margin-top: 26px; }

/* 토스트 */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #f6f5f1; padding: 13px 24px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow); z-index: 60; animation: rise .25s ease; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } }

@media (max-width: 720px) {
  .sidebar { display: none; }
  .content { padding: 32px 22px 64px; }
  .page-title { font-size: 36px; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 30px 18px; }
  .map-grid { grid-template-columns: 1fr 1fr; }
  .modal-detail { flex-direction: column; } .modal-detail .cover { width: 108px; }
  .toolbar { flex-direction: column; align-items: stretch; }
}
