.memory-directory[hidden] { display: none; }
#atlasLensSubbar {
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  box-sizing: border-box;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#atlasLensSubbar::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
#atlasLensSubbar .lens-btn { flex-shrink: 0; }

.memory-directory {
  position: fixed; left: 20px; top: 110px; bottom: 84px; width: min(410px, calc(100vw - 40px));
  z-index: 1200; box-sizing: border-box; overflow-y: auto; padding: 0 18px 18px 18px;
  color: #e2e8f0; background: rgba(14, 18, 26, 0.88); backdrop-filter: blur(28px) saturate(130%);
  -webkit-backdrop-filter: blur(28px); border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); font-family: var(--font-sans, sans-serif);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.memory-directory header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; background: rgba(14, 18, 26, 0.94); backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px); z-index: 10;
  margin: 0 -18px 12px -18px; padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px 18px 0 0;
}
.memory-directory h2 {
  font-size: 1.02rem; margin: 0; font-weight: 600; line-height: 1.3; flex: 1;
  display: flex; align-items: center; gap: 8px; color: #fff;
}
.popup-title-icon {
  font-size: 1.2rem; line-height: 1; flex-shrink: 0; display: inline-block;
}
.memory-place-people h2 { font-size: 1.1rem; margin: 0 0 12px; }
#memoryClose, #botClose {
  width: 30px; height: 30px; min-width: 30px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18); color: #d5e7f4;
  font-size: 0.95rem; line-height: 1; cursor: pointer; flex-shrink: 0; margin: 0; align-self: center;
  transition: all 0.2s ease;
}
#memoryClose:hover, #botClose:hover {
  background: rgba(161, 56, 42, 0.6); border-color: #a1382a; color: #fff;
}
.memory-directory p, .memory-person p { font-size: .82rem; line-height: 1.6; margin: 8px 0; color: #cbd5e1; }
.directory-lead-desc {
  font-size: 0.8rem; line-height: 1.5; color: #94a3b8; margin: 0 0 10px 0;
}
.directory-filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.directory-field {
  display: flex;
  flex-direction: column;
}
.directory-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-amber, #f59e0b);
  margin-bottom: 4px;
}
.memory-directory input, .memory-directory select {
  width: 100%; box-sizing: border-box; padding: 8px 10px; margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px;
  background: rgba(20, 26, 36, 0.85); color: #fff; font: inherit; font-size: 0.84rem;
  line-height: 1.4; outline: none; transition: border-color 0.2s, background 0.2s;
}
.memory-directory input:focus, .memory-directory select:focus {
  border-color: #e3c9ff; background: rgba(26, 34, 48, 0.95);
  outline: 2px solid rgba(227, 201, 255, 0.3); outline-offset: 1px;
}
.directory-results-count {
  font-size: 0.78rem; color: #94a3b8; margin: 6px 0 10px 0;
}
.memory-person { padding: 14px 0; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.memory-person:first-child { border-top: none; }
.memory-person h3 { font-size: 0.98rem; margin: 0 0 5px 0; color: #e3c9ff; font-weight: 600; line-height: 1.35; }
.memory-role { color: #c7a4e7; font-size: 0.78rem; font-weight: 500; }
.memory-relation { color: #94a3b8; font-size: 0.8rem; line-height: 1.5; }
.memory-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.memory-links button, .memory-links a {
  color: #d5e7f4; background: rgba(37, 56, 73, 0.85); border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px; padding: 6px 10px; font: inherit; font-size: .78rem; text-align: left;
  cursor: pointer; max-width: 100%; box-sizing: border-box; word-break: break-word; line-height: 1.35;
  transition: all 0.2s ease;
}
.memory-links a { text-decoration: none; }
.memory-links button:hover, .memory-links a:hover { background: #3d5063; border-color: rgba(255, 255, 255, 0.3); }
.memory-links button:focus-visible, #memoryClose:focus-visible, #botClose:focus-visible, #memorySearch:focus-visible, #botSearch:focus-visible {
  outline: 2px solid #e3c9ff; outline-offset: 2px;
}
.memory-place-people { margin-top: 20px; }
.pin-has-keepers .pin-core { box-shadow: 0 0 0 3px #bba0d9; }
.pin-has-keepers::after { content: '●'; position: absolute; right: -6px; top: -8px; color: #e3c9ff; font-size: 15px; }

@media (max-width: 768px) {
  .memory-directory {
    top: 50px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    left: 8px;
    right: 8px;
    width: auto;
    max-width: calc(100vw - 16px);
    padding: 0 14px 14px;
    border-radius: 16px;
    z-index: 1200;
  }
  .memory-directory header {
    margin: 0 -14px 10px -14px;
    padding: 12px 14px;
    border-radius: 16px 16px 0 0;
  }
  .memory-directory h2 {
    font-size: 0.94rem;
  }
  .directory-filter-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
