/* PDF Content Map Explorer */
.map-app {
  display: grid;
  grid-template-columns: 260px 1fr min(420px, 38vw);
  grid-template-rows: auto auto auto 1fr;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
.map-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #0c1018;
  z-index: 10;
}
.map-topbar h1 { font-size: 0.95rem; margin: 0; font-weight: 600; white-space: nowrap; }
.map-topbar a { color: var(--muted); font-size: 0.78rem; text-decoration: none; }
.map-topbar a:hover { color: var(--accent); }
.search-wrap {
  flex: 1;
  max-width: 520px;
  position: relative;
}
.search-wrap input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 156, 245, 0.15);
}
.search-wrap .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.5;
  font-size: 0.85rem;
}
.search-opts {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--muted);
}
.search-opts label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

.chapter-nav {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: #0a0e14;
  overflow-x: auto;
  scrollbar-width: thin;
}
.chapter-nav .nav-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.chapter-pill {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chapter-pill:hover { border-color: #3d5a80; color: var(--text); }
.chapter-pill.on { background: #1a3050; border-color: var(--accent); color: var(--accent); }
.chapter-pill .range { opacity: 0.7; margin-left: 4px; font-size: 0.68rem; }

.export-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: #0c1018;
  flex-wrap: wrap;
}
.export-bar .btn-export {
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #2563b8, var(--accent));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}
.export-bar .btn-export:disabled { opacity: 0.45; cursor: not-allowed; }
.export-bar .btn-secondary {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.78rem;
  cursor: pointer;
}
.export-bar .sel-count { font-size: 0.78rem; color: var(--muted); margin-left: auto; }

.section-list { margin-bottom: 8px; }
.section-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: background 0.12s;
}
.section-item:hover { background: var(--card); }
.section-item.on { background: #1a2840; border-color: var(--accent); }
.section-item input { margin-top: 3px; accent-color: var(--accent); }
.section-item .info { flex: 1; min-width: 0; }
.section-item .title { font-size: 0.8rem; font-weight: 500; line-height: 1.3; }
.section-item .meta { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }

.map-sidebar {
  grid-row: 4;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
  background: #0a0e14;
}
.map-sidebar h2 {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 12px 0 8px;
}
.map-sidebar h2:first-child { margin-top: 0; }

.doc-item {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  transition: background 0.12s, border-color 0.12s;
}
.doc-item:hover { background: var(--card); }
.doc-item.on { background: #1a2840; border-color: var(--accent); }
.doc-item .name { font-size: 0.85rem; font-weight: 500; }
.doc-item .meta { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: #243044;
  color: var(--muted);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s;
}
.chip:hover { border-color: var(--border); color: var(--text); }
.chip.on { background: #1a3050; color: var(--accent); border-color: var(--accent); }
.chip .n { opacity: 0.65; margin-left: 3px; }

.map-main {
  grid-row: 4;
  overflow-y: auto;
  padding: 12px 16px;
  scroll-behavior: smooth;
}
.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  position: sticky;
  top: 0;
  background: rgba(10, 14, 20, 0.92);
  backdrop-filter: blur(8px);
  padding: 6px 0;
  z-index: 2;
}
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.page-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.page-card:hover {
  transform: translateY(-2px);
  border-color: #3d5a80;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.page-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.page-card .thumb {
  aspect-ratio: 16/9;
  background: #0a1018;
  overflow: hidden;
  position: relative;
}
.page-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.page-card .thumb .pg {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.65);
  color: #fff;
}
.page-card .body { padding: 10px 12px; }
.page-card .cat {
  font-size: 0.62rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.page-card .title {
  font-size: 0.82rem;
  font-weight: 500;
  margin: 4px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.page-card .sum {
  font-size: 0.72rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.page-card .card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.page-card .card-tags .chip {
  font-size: 0.62rem;
  padding: 2px 8px;
}

.map-detail {
  grid-row: 4;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  background: #0c1018;
  display: flex;
  flex-direction: column;
}
.map-detail.empty {
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 24px;
  text-align: center;
}
.detail-img {
  background: #0a1018;
  border-bottom: 1px solid var(--border);
  max-height: 42vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-img img {
  max-width: 100%;
  max-height: 42vh;
  object-fit: contain;
}
.detail-body { padding: 16px; flex: 1; }
.detail-body h2 { font-size: 1rem; margin: 0 0 8px; }
.detail-meta { font-size: 0.75rem; color: var(--muted); margin-bottom: 12px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.detail-tags .chip { cursor: pointer; }
.layout-block { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.layout-block h3 { font-size: 0.85rem; margin: 0 0 8px; }
.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin-top: 10px;
  max-height: 320px;
  overflow-y: auto;
}
.region-card {
  margin: 0;
  background: #0a1018;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.region-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.region-card figcaption { font-size: 0.62rem; padding: 6px; color: var(--muted); line-height: 1.35; }
.detail-md {
  font-size: 0.78rem;
  line-height: 1.55;
  color: #b8c8dc;
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  background: #0a1018;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.detail-nav {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.detail-nav button {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
}
.detail-nav button:hover { border-color: var(--accent); }

.load-more {
  display: block;
  width: 100%;
  margin: 16px 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
}
.load-more:hover { border-color: var(--accent); color: var(--accent); }

mark {
  background: rgba(245, 184, 61, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}

@media (max-width: 900px) {
  .map-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto 1fr auto;
    height: auto;
    min-height: 100vh;
  }
  .map-sidebar, .map-main, .map-detail { grid-row: auto; }
  .map-sidebar { max-height: 200px; border-right: none; border-bottom: 1px solid var(--border); }
  .map-detail { border-left: none; border-top: 1px solid var(--border); min-height: 360px; }
  .search-wrap { max-width: none; }
}
