:root {
  --bg-void: #0a0203;
  --bg-deep: #110305;
  --blood-dark: #3d0a0a;
  --blood-mid: #6b1010;
  --blood-bright: #9b1c1c;
  --blood-splat: #c0392b;
  --parchment: #e8d5a3;
  --parchment-dark: #c9b87a;
  --parchment-shadow: #8a6e3a;
  --ink: #1a0a00;
  --ink-faded: #3d2b10;
  --shelf-wood: #2a1505;
  --shelf-edge: #4a2510;
  --nav-bg: rgba(8,1,1,0.97);
  --nav-border: rgba(120,20,20,0.4);
  --accent: #8b1a1a;
  --accent-glow: rgba(139,26,26,0.3);
  --text-pale: #c9a882;
  --text-dim: #7a5a3a;
  --letter-font: 'Noto Serif KR', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg-void);
  color: var(--text-pale);
  font-family: 'Noto Serif KR', serif;
  min-height: 100vh;
  overflow-x: hidden;
  cursor: default;
}

/* ── 배경 ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 30%, rgba(80,5,5,0.35) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 70%, rgba(60,3,3,0.3) 0%, transparent 65%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(40,2,2,0.2) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* 꿀럭이는 덩어리 느낌? */
.void-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
}
.void-blob:nth-child(1) {
  width: 500px; height: 350px;
  background: radial-gradient(ellipse, #5a0808 0%, #1a0202 60%, transparent 100%);
  top: -80px; left: -100px;
  animation: blob-pulse 8s ease-in-out infinite;
}
.void-blob:nth-child(2) {
  width: 400px; height: 500px;
  background: radial-gradient(ellipse, #3d0505 0%, #0d0101 60%, transparent 100%);
  bottom: -100px; right: -80px;
  animation: blob-pulse 11s ease-in-out infinite reverse;
}
.void-blob:nth-child(3) {
  width: 300px; height: 300px;
  background: radial-gradient(ellipse, #6b0a0a 0%, #1f0202 60%, transparent 100%);
  top: 40%; left: 40%;
  animation: blob-drift 15s ease-in-out infinite;
  opacity: 0.1;
}
.void-blob:nth-child(4) {
  width: 200px; height: 400px;
  background: radial-gradient(ellipse, #4a0606 0%, #120101 60%, transparent 100%);
  top: 20%; right: 10%;
  animation: blob-pulse 9s ease-in-out infinite 2s;
  opacity: 0.12;
}

@keyframes blob-pulse {
  0%, 100% { transform: scale(1) translateY(0); opacity: 0.18; }
  50% { transform: scale(1.15) translateY(-20px); opacity: 0.25; }
}
@keyframes blob-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.1); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
}

/* 대충 혈흔 */
.blood-stain {
  position: fixed;
  pointer-events: none;
  z-index: 1;
  opacity: 0.55;
}

#app { position: relative; z-index: 2; min-height: 100vh; }

/* 네비게이션 바 */
#navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 52px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.8), 0 1px 0 rgba(150,20,20,0.15);
}

#nav-home {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 15px;
  color: var(--parchment);
  letter-spacing: 0.05em;
  background: none;
  border: 1px solid rgba(120,30,30,0.5);
  padding: 6px 14px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  text-shadow: 0 0 12px rgba(180,40,40,0.5);
  flex-shrink: 0;
}
#nav-home:hover {
  background: rgba(80,10,10,0.5);
  border-color: var(--accent);
  color: #e8c8a0;
}

.nav-spacer { flex: 1; }

#nav-search {
  flex: 1;
  max-width: 320px;
  background: rgba(20,5,5,0.8);
  border: 1px solid rgba(100,20,20,0.4);
  color: var(--parchment);
  padding: 7px 14px;
  border-radius: 3px;
  font-family: 'Noto Serif KR', serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
#nav-search::placeholder { color: var(--text-dim); }
#nav-search:focus { border-color: rgba(150,30,30,0.7); }

#nav-sort {
  background: rgba(20,5,5,0.8);
  border: 1px solid rgba(100,20,20,0.4);
  color: var(--text-pale);
  padding: 7px 12px;
  border-radius: 3px;
  font-family: 'Noto Serif KR', serif;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
  flex-shrink: 0;
}
#nav-sort:hover { border-color: rgba(150,30,30,0.7); }

#nav-add {
  width: 34px; height: 34px;
  background: rgba(80,10,10,0.6);
  border: 1px solid rgba(150,30,30,0.6);
  color: var(--parchment);
  font-size: 20px;
  line-height: 1;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
#nav-add:hover {
  background: rgba(120,15,15,0.8);
  border-color: var(--blood-bright);
  box-shadow: 0 0 10px rgba(150,20,20,0.3);
}

/* ══ 메인 페이지 ══ */
#page-main { padding: 30px 20px 60px; }

/* 편지지 헤더 */
#letter-header {
  position: relative;
  max-width: 780px;
  margin: 0 auto 50px;
  background: #d4b87a;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
  padding: 40px 50px 44px;
  border-radius: 2px;
  box-shadow:
    inset 0 0 40px rgba(100,60,0,0.3),
    inset 0 0 80px rgba(80,40,0,0.15),
    0 4px 30px rgba(0,0,0,0.7),
    0 0 0 1px rgba(100,70,20,0.4);
  overflow: hidden;
}

/* 편지지 낡은 느낌용 레이어 */
#letter-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 15% 20%, rgba(160,100,20,0.2) 0%, transparent 50%),
    radial-gradient(ellipse 60% 80% at 85% 80%, rgba(120,70,10,0.15) 0%, transparent 50%),
    linear-gradient(135deg, rgba(180,120,30,0.08) 0%, transparent 50%),
    linear-gradient(to bottom, rgba(255,220,100,0.06) 0%, transparent 30%, rgba(80,40,0,0.1) 100%);
  pointer-events: none;
}

/* 편지지 해진 모서리 */
#letter-header::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 2px;
  box-shadow: inset 0 0 0 2px rgba(100,60,10,0.25);
  pointer-events: none;
}

/* 편지지 혈흔들 */
.letter-blood {
  position: absolute;
  border-radius: 50%;
  background: rgba(120,10,10,0.6);
  pointer-events: none;
  filter: blur(1px);
}

#letter-title {
  position: relative;
  font-family: var(--letter-font);
  font-size: clamp(14px, 2.5vw, 20px);
  font-weight: 400;
  color: #2a1500;
  line-height: 1.9;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: pre-line;
}

/* 줄 긋기 */
.letter-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.letter-line {
  position: absolute;
  left: 40px; right: 40px;
  height: 1px;
  background: rgba(100,60,10,0.15);
}

/* 폰트 선택 */
#font-picker-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: 'Noto Serif KR', serif;
}
#font-select {
  background: rgba(30,10,0,0.15);
  border: 1px solid rgba(100,60,10,0.35);
  color: var(--ink-faded);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 2px;
  font-family: 'Noto Serif KR', serif;
  cursor: pointer;
  outline: none;
}

/* ── 책장 ── */
#bookshelf-section {
  max-width: 1200px;
  margin: 0 auto;
}

.shelf-unit {
  position: relative;
  background:
    linear-gradient(to bottom,
      #1a0a02 0px, #2a1405 4px,
      #1e0c03 4px, #1e0c03 calc(100% - 16px),
      #3a1a08 calc(100% - 16px), #4a2510 calc(100% - 8px),
      #2a1205 calc(100% - 8px), #2a1205 100%);
  padding: 20px 24px 32px;
  border-radius: 4px;
  margin-bottom: 8px;
  box-shadow:
    inset 0 2px 0 rgba(100,50,10,0.3),
    inset 0 -4px 0 rgba(0,0,0,0.5),
    0 4px 15px rgba(0,0,0,0.6),
    2px 0 8px rgba(0,0,0,0.3),
    -2px 0 8px rgba(0,0,0,0.3);
}

/* 책장 옆면 질감 */
.shelf-unit::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(to right,
    #4a2510, #6a3515, #8a4520, #6a3515, #4a2510);
  border-radius: 4px 4px 0 0;
}

#books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
  min-height: 60px;
}

/* ── 책 카드 ── */
.book-card {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 3px 6px 6px 3px;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(.15,.7,.4,1.2), box-shadow 0.25s;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  box-shadow:
    -3px 0 6px rgba(0,0,0,0.5),
    3px 3px 12px rgba(0,0,0,0.6),
    inset 0 0 0 1px rgba(255,255,255,0.05);
  transform-origin: bottom center;
}

.book-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 6px;
  background: linear-gradient(to right, rgba(0,0,0,0.4), rgba(0,0,0,0.1));
  border-radius: 3px 0 0 3px;
}

.book-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.07) 0%, transparent 40%),
    linear-gradient(to bottom, rgba(0,0,0,0) 60%, rgba(0,0,0,0.3) 100%);
  pointer-events: none;
}

.book-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow:
    -3px 0 6px rgba(0,0,0,0.5),
    5px 12px 25px rgba(0,0,0,0.7),
    0 0 20px rgba(120,20,20,0.2),
    inset 0 0 0 1px rgba(255,255,255,0.08);
}

.book-title-display {
  position: relative;
  z-index: 1;
  font-family: 'Noto Serif KR', serif;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-align: center;
  line-height: 1.5;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  word-break: keep-all;
  hyphens: auto;
}

.book-id-display {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 9px;
  color: rgba(255,255,255,0.4);
  font-family: monospace;
  letter-spacing: 0.05em;
  z-index: 1;
}

/* 책 낡은 텍스처 오버레이 */
.book-texture {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  pointer-events: none;
}

/* 빈 상태 */
#empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  font-family: 'Hahmlet', serif;
  font-size: 14px;
  line-height: 2;
  display: none;
}
#empty-state.visible { display: block; }

/* ══ 추가 / 편집 페이지 ══ */
#page-add {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  display: none;
}
#page-add.active { display: block; }

.form-parchment {
  background: #c8a86a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E");
  border-radius: 3px;
  padding: 40px 44px 48px;
  box-shadow:
    inset 0 0 50px rgba(80,40,0,0.25),
    0 6px 40px rgba(0,0,0,0.7),
    0 0 0 1px rgba(100,60,10,0.3);
}

.form-parchment h2 {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 22px;
  color: var(--ink);
  margin-bottom: 32px;
  letter-spacing: 0.05em;
  text-align: center;
  opacity: 0.8;
}

.form-group { margin-bottom: 22px; }

.form-label {
  display: block;
  font-size: 12px;
  color: var(--ink-faded);
  margin-bottom: 6px;
  font-family: 'Noto Serif KR', serif;
  letter-spacing: 0.05em;
  opacity: 0.75;
}

.form-input, .form-textarea {
  width: 100%;
  background: rgba(255,240,190,0.4);
  border: 1px solid rgba(100,60,10,0.35);
  color: var(--ink);
  font-family: 'Noto Serif KR', serif;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus, .form-textarea:focus {
  border-color: rgba(100,40,10,0.6);
  box-shadow: 0 0 0 2px rgba(100,40,10,0.1);
}
.form-input::placeholder, .form-textarea::placeholder {
  color: rgba(60,30,5,0.35);
}

.form-textarea {
  min-height: 280px;
  resize: vertical;
  font-size: 13px;
  line-height: 1.7;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.color-row input[type="color"] {
  width: 44px; height: 36px;
  border: 1px solid rgba(100,60,10,0.35);
  border-radius: 2px;
  padding: 2px;
  cursor: pointer;
  background: rgba(255,240,190,0.3);
}
.color-preview-text {
  font-size: 12px;
  color: var(--ink-faded);
  opacity: 0.7;
}

.markdown-hint {
  font-size: 11px;
  color: rgba(60,30,5,0.45);
  margin-top: 6px;
  line-height: 1.6;
  font-family: monospace;
}

.form-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 28px;
}

.btn-primary {
  background: rgba(80,15,5,0.85);
  color: var(--parchment);
  border: 1px solid rgba(150,40,20,0.7);
  padding: 10px 28px;
  font-family: 'Noto Serif KR', serif;
  font-size: 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover {
  background: rgba(110,20,8,0.9);
  border-color: rgba(180,50,25,0.9);
  box-shadow: 0 0 12px rgba(150,20,10,0.3);
}

.btn-secondary {
  background: rgba(0,0,0,0.2);
  color: rgba(60,30,5,0.7);
  border: 1px solid rgba(100,60,10,0.3);
  padding: 10px 20px;
  font-family: 'Noto Serif KR', serif;
  font-size: 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { background: rgba(0,0,0,0.3); }

.error-msg {
  color: #8b1a1a;
  font-size: 12px;
  margin-top: 6px;
  display: none;
}
.error-msg.visible { display: block; }

/* ══ 책 상세 페이지 ══ */
#page-wiki {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  display: none;
}
#page-wiki.active { display: block; }

.book-page-spread {
  position: relative;
  background: #e2ca8a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='5' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E");
  border-radius: 3px 8px 8px 3px;
  padding: 50px 56px 60px;
  box-shadow:
    inset -3px 0 8px rgba(80,40,0,0.2),
    inset 0 0 60px rgba(80,40,0,0.12),
    -4px 0 10px rgba(0,0,0,0.4),
    0 8px 40px rgba(0,0,0,0.7),
    0 0 0 1px rgba(100,70,20,0.25);
}

/* 페이지 왼쪽 바인딩 그림자 */
.book-page-spread::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 30px;
  background: linear-gradient(to right,
    rgba(80,40,0,0.25) 0%,
    rgba(80,40,0,0.08) 60%,
    transparent 100%);
  border-radius: 3px 0 0 3px;
  pointer-events: none;
}

/* 모서리 해짐 */
.book-page-spread::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 3px 8px 8px 3px;
  box-shadow:
    inset 4px 4px 15px rgba(80,40,0,0.2),
    inset -4px -4px 15px rgba(60,30,0,0.15),
    inset 2px 2px 0 rgba(200,170,80,0.3);
  pointer-events: none;
}

.wiki-book-title {
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(20px, 4vw, 32px);
  color: var(--ink);
  text-align: center;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  opacity: 0.85;
  position: relative;
}

.wiki-book-id {
  text-align: center;
  font-size: 11px;
  color: rgba(40,20,0,0.4);
  font-family: monospace;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.wiki-meta {
  text-align: center;
  font-size: 11px;
  color: rgba(40,20,0,0.35);
  font-family: 'Noto Serif KR', serif;
  margin-bottom: 30px;
}

.page-divider {
  border: none;
  border-top: 1px solid rgba(80,40,0,0.25);
  margin: 0 auto 32px;
  width: 80%;
}

/* 마크다운 렌더 영역 */
.wiki-content {
  font-family: 'Noto Serif KR', serif;
  font-size: 15px;
  line-height: 2;
  color: var(--ink);
  min-height: 200px;
}

.wiki-content h1 { font-size: 22px; margin: 24px 0 12px; color: #1a0800; font-family: 'Black Han Sans', sans-serif; }
.wiki-content h2 { font-size: 18px; margin: 20px 0 10px; color: #2a1000; border-bottom: 1px solid rgba(80,40,0,0.2); padding-bottom: 4px; }
.wiki-content h3 { font-size: 15px; margin: 16px 0 8px; color: #2a1000; }
.wiki-content p { margin-bottom: 14px; }
.wiki-content strong { font-weight: 700; color: #1a0800; }
.wiki-content em { font-style: italic; opacity: 0.85; }
.wiki-content ul, .wiki-content ol { padding-left: 24px; margin-bottom: 14px; }
.wiki-content li { margin-bottom: 6px; }
.wiki-content blockquote {
  border-left: 3px solid rgba(80,40,0,0.35);
  padding: 8px 16px;
  margin: 16px 0;
  color: rgba(40,15,0,0.7);
  font-style: italic;
  background: rgba(0,0,0,0.04);
}
.wiki-content code {
  font-family: monospace;
  font-size: 13px;
  background: rgba(80,40,0,0.1);
  padding: 1px 5px;
  border-radius: 2px;
  color: #3d1500;
}
.wiki-content pre {
  background: rgba(20,5,0,0.1);
  padding: 12px 16px;
  border-radius: 3px;
  overflow-x: auto;
  margin-bottom: 14px;
}
.wiki-content hr { border: none; border-top: 1px solid rgba(80,40,0,0.2); margin: 20px 0; }
.wiki-content a { color: #6b2a08; text-decoration: underline; text-decoration-color: rgba(80,30,5,0.3); }
.wiki-content table { border-collapse: collapse; width: 100%; margin-bottom: 14px; }
.wiki-content th, .wiki-content td { border: 1px solid rgba(80,40,0,0.25); padding: 6px 12px; font-size: 14px; }
.wiki-content th { background: rgba(80,40,0,0.1); font-weight: 700; }

.wiki-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid rgba(80,40,0,0.2);
  flex-wrap: wrap;
  gap: 10px;
}

.wiki-actions { display: flex; gap: 10px; }

.btn-wiki {
  background: rgba(60,25,5,0.15);
  color: var(--ink-faded);
  border: 1px solid rgba(80,40,0,0.3);
  padding: 7px 16px;
  font-family: 'Noto Serif KR', serif;
  font-size: 13px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-wiki:hover { background: rgba(60,25,5,0.25); }

.btn-wiki-danger {
  color: #7a1515;
  border-color: rgba(100,20,20,0.35);
}
.btn-wiki-danger:hover { background: rgba(100,20,20,0.12); }

/* ══ 삭제 확인 다이얼로그 ══ */
#delete-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
#delete-modal.active { display: flex; }

.modal-box {
  background: #c5a86a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  border-radius: 3px;
  padding: 36px 40px 32px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8);
  text-align: center;
}
.modal-box h3 {
  font-family: 'Black Han Sans', sans-serif;
  font-size: 18px;
  color: var(--ink);
  margin-bottom: 12px;
  opacity: 0.8;
}
.modal-box p {
  font-size: 13px;
  color: var(--ink-faded);
  margin-bottom: 24px;
  line-height: 1.7;
}
.modal-buttons { display: flex; gap: 10px; justify-content: center; }

/* ══ 반응형 ══ */
@media (max-width: 768px) {
  #navbar { padding: 0 10px; gap: 6px; }
  #nav-home { padding: 6px 10px; font-size: 13px; }
  #nav-search { max-width: 180px; }
  #letter-header { padding: 28px 26px 32px; }
  .form-parchment { padding: 28px 22px 32px; }
  .book-page-spread { padding: 36px 28px 44px; }
  #books-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
}

@media (max-width: 480px) {
  #nav-search { max-width: 130px; font-size: 12px; }
  #nav-sort { font-size: 11px; padding: 7px 8px; }
  #letter-header { padding: 22px 18px 26px; }
  #letter-title { font-size: 13px; }
  .book-page-spread { padding: 28px 18px 36px; }
  #books-grid { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); gap: 10px; }
}

/* ══ 혈흔 SVG ══ */
.blood-svg {
  position: fixed;
  pointer-events: none;
  z-index: 1;
}

/* 로딩 화면 */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-void);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Black Han Sans', sans-serif;
  color: var(--blood-bright);
  font-size: 18px;
  letter-spacing: 0.15em;
  text-shadow: 0 0 20px rgba(150,20,20,0.5);
  animation: fade-out 0.5s 0.6s forwards;
}
@keyframes fade-out { to { opacity: 0; pointer-events: none; } }
/* ══════════════════════════════════════
   Phase 2 추가 스타일
══════════════════════════════════════ */

/* ── 네비 추가 요소 ── */
.nav-btn-ghost {
  background: none;
  border: 1px solid rgba(100,20,20,0.4);
  color: var(--text-pale);
  padding: 6px 12px;
  border-radius: 3px;
  font-family: 'Noto Serif KR', serif;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
}
.nav-btn-ghost:hover {
  background: rgba(80,10,10,0.4);
  border-color: rgba(150,30,30,0.7);
}

.nav-role-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 2px;
  font-family: 'Noto Serif KR', serif;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid;
}
.nav-role-badge.role-admin  { color: #e8a87c; border-color: rgba(200,100,30,0.5); background: rgba(80,30,5,0.3); }
.nav-role-badge.role-writer { color: #a8c87c; border-color: rgba(80,150,30,0.4); background: rgba(20,50,5,0.3); }
.nav-role-badge.role-viewer { color: var(--text-dim); border-color: rgba(100,80,40,0.35); background: rgba(20,15,5,0.2); }

.nav-count-badge {
  position: absolute;
  top: -5px; right: -5px;
  background: #8b1a1a;
  color: #fff;
  font-size: 9px;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  font-family: monospace;
}

/* ── 인증 페이지 ── */
.auth-wrap {
  max-width: 480px;
  margin: 60px auto;
  padding: 0 20px;
}
.auth-switch {
  margin-top: 18px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-faded);
  opacity: 0.7;
}
.auth-switch a {
  color: var(--ink-faded);
  text-decoration: underline;
  text-decoration-color: rgba(60,30,5,0.3);
}

/* ── 모달 오버레이 ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}

/* ── 로딩 행 ── */
.loading-row {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 13px;
  font-family: 'Noto Serif KR', serif;
  opacity: 0.6;
}

/* ── 비공개 뱃지 (책 카드) ── */
.book-private-badge {
  position: absolute;
  top: 7px; left: 10px;
  font-size: 9px;
  color: rgba(255,200,100,0.9);
  background: rgba(0,0,0,0.5);
  padding: 1px 5px;
  border-radius: 2px;
  font-family: monospace;
  letter-spacing: 0.05em;
  z-index: 2;
}

/* ── 상태 뱃지 ── */
.status-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 2px;
  font-family: 'Noto Serif KR', serif;
}
.status-pending  { background: rgba(100,70,10,0.25); color: #c8a84a; border: 1px solid rgba(150,100,10,0.3); }
.status-approved { background: rgba(20,80,20,0.2);  color: #7ac87a; border: 1px solid rgba(30,120,30,0.3); }
.status-rejected { background: rgba(100,15,15,0.2); color: #c87a7a; border: 1px solid rgba(150,20,20,0.3); }

/* ── 관리자 탭 ── */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(80,40,0,0.2);
  padding-bottom: 0;
}
.admin-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  font-family: 'Noto Serif KR', serif;
  font-size: 13px;
  color: rgba(40,20,0,0.5);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: -1px;
}
.admin-tab:hover  { color: rgba(40,20,0,0.75); }
.admin-tab.active { color: var(--ink); border-bottom-color: rgba(80,40,0,0.5); }
.admin-tab-content { min-height: 120px; }

/* ── 관리자 테이블 ── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: 'Noto Serif KR', serif;
  color: var(--ink);
  margin-top: 4px;
}
.admin-table th {
  background: rgba(80,40,0,0.08);
  font-weight: 700;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(80,40,0,0.2);
  font-size: 12px;
  opacity: 0.7;
}
.admin-table td {
  padding: 9px 10px;
  border-bottom: 1px solid rgba(80,40,0,0.1);
  vertical-align: middle;
}
.admin-table tr:hover td { background: rgba(80,40,0,0.04); }
.admin-table .user-inactive { opacity: 0.45; }

.admin-select {
  background: rgba(255,240,190,0.3);
  border: 1px solid rgba(100,60,10,0.3);
  color: var(--ink);
  font-family: 'Noto Serif KR', serif;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

/* ── 토스트 알림 ── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15,3,3,0.95);
  color: var(--parchment);
  border: 1px solid rgba(120,30,30,0.5);
  padding: 10px 22px;
  border-radius: 3px;
  font-family: 'Noto Serif KR', serif;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 300;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7);
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── 반응형 보완 ── */
@media (max-width: 600px) {
  .nav-btn-ghost { padding: 6px 8px; font-size: 11px; }
  .nav-role-badge { font-size: 9px; padding: 2px 6px; }
  .admin-table { font-size: 11px; }
  .admin-table th, .admin-table td { padding: 6px 6px; }
  .auth-wrap { margin: 30px auto; }
}
