/* ==========================================================================
   Application Layout & Views Styles (Tarot Cards, Maps, Graph, Ideas, Mobile)
   ========================================================================== */

/* --- Navigation & Header (Quiz Matching) --- */
.site-header {
  border-bottom: 1px solid var(--glass-border);
  background: rgba(11, 12, 16, 0.4);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container-wrapper {
  max-width: 1600px;
  width: 92%;
  margin: 0 auto;
  padding: 1rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.logo {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #FFFFFF;
  display: flex;
  align-items: center;
}

.logo span {
  color: var(--accent-primary);
}

.logo .logo-subtitle {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 10px;
  border-left: 1px solid var(--glass-border);
  padding-left: 10px;
  text-transform: none;
  letter-spacing: normal;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.theme-switch-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  padding: 0;
}

.theme-switch-btn:hover {
  color: #FFFFFF;
  border-color: var(--accent-primary);
  background: rgba(102, 252, 241, 0.1);
  box-shadow: var(--glow-primary);
}

/* Full-Screen Login Gate */
.login-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 75vh;
  width: 100%;
}

.world-selector-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  gap: var(--space-sm);
  list-style: none;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.nav-link:hover, .nav-link.active {
  color: var(--accent-primary);
  background: rgba(102, 252, 241, 0.08);
  border-color: rgba(102, 252, 241, 0.2);
}

.nav-link.active {
  box-shadow: 0 0 10px rgba(102, 252, 241, 0.05);
}

/* Header Right */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* Search Bar */
.search-wrapper {
  position: relative;
  width: 260px;
}

.search-input {
  width: 100%;
  padding-left: 2.2rem;
}

.search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* --- Views Grid --- */
.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- World Cover Card Info --- */
.world-hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: 250px;
  margin-bottom: var(--space-2xl);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-premium);
  display: flex;
  align-items: flex-end;
  padding: var(--space-2xl);
}

.world-hero-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.4) blur(1px);
  z-index: 1;
}

.world-hero-gradient {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to top, rgba(11, 12, 16, 0.95) 0%, rgba(11, 12, 16, 0.4) 100%);
  z-index: 2;
}

.world-hero-content {
  position: relative;
  z-index: 3;
  max-width: 800px;
}

.world-hero h1 {
  font-size: 2.2rem;
  margin-bottom: var(--space-xs);
}

.world-hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.filter-tags {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.tag-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tag-btn:hover, .tag-btn.active {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.08);
}

.tag-btn.active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(102, 252, 241, 0.05);
}

/* --- Tarot Cards Grid --- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: var(--space-xl);
}

/* Custom tarot height viewport from design_concept.md */
.portal-card {
  position: relative;
  background: #0D1117;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: 68vh;
  min-height: 560px;
  max-height: 750px;
  box-shadow: var(--shadow-premium);
  transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.portal-card::after {
  content: '';
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  pointer-events: none;
  z-index: 3;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.portal-card:hover {
  transform: translateY(-10px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-premium), var(--glow-primary);
}

.portal-card:hover::after {
  border-color: rgba(102, 252, 241, 0.35);
  box-shadow: inset 0 0 15px rgba(102, 252, 241, 0.1);
}

.card-link {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.card-image-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.card-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.65) contrast(1.15) saturate(0.85);
  transition: transform var(--transition-normal), filter var(--transition-normal);
}

.portal-card:hover .card-image-wrapper img {
  transform: scale(1.05);
  filter: brightness(0.85) contrast(1.05) saturate(1);
}

/* Centered content overlay container */
.card-content {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 45%;
  background: linear-gradient(to top, rgba(11, 12, 16, 0.98) 0%, rgba(11, 12, 16, 0.85) 60%, transparent 100%);
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
  transition: height var(--transition-normal);
}

.card-text-wrapper {
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card-content h3 {
  font-family: var(--font-card-title);
  font-size: 1.35rem;
  font-weight: 500;
  margin: 0;
  color: #fff;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: var(--space-sm);
  transition: border-color var(--transition-normal);
}

.portal-card:hover h3 {
  border-color: rgba(102, 252, 241, 0.25);
}

.card-badge {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(11, 12, 16, 0.8);
}

/* Specific Badge colors */
.badge-npc { color: #00E5FF; border-color: rgba(0, 229, 255, 0.3); }
.badge-location { color: #00E676; border-color: rgba(0, 230, 118, 0.3); }
.badge-faction { color: #BD00FF; border-color: rgba(189, 0, 255, 0.3); }
.badge-item { color: #FFD600; border-color: rgba(255, 214, 0, 0.3); }
.badge-adversary { color: #FF1744; border-color: rgba(255, 23, 68, 0.3); }
.badge-article { color: #FF9100; border-color: rgba(255, 145, 0, 0.3); }
.badge-other { color: #90A4AE; border-color: rgba(144, 164, 174, 0.3); }

.card-description {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
  max-height: 0;
  opacity: 0;
  transition: max-height var(--transition-normal), opacity var(--transition-normal), margin-top var(--transition-normal);
  text-align: center;
}

.portal-card:hover .card-content {
  height: 68%;
}

.portal-card:hover .card-description {
  max-height: 180px;
  opacity: 1;
  margin-top: var(--space-md);
}

/* --- Entity Details Overlay Drawer/View --- */
.entity-details-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--space-xl);
}

.entity-details-image {
  width: 100%;
  height: 320px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
}

.entity-meta-box {
  margin-top: var(--space-md);
  background: rgba(11, 12, 16, 0.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.meta-item {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 6px 0;
  font-size: 0.88rem;
}

.meta-item:last-child {
  border-bottom: none;
}

.meta-label {
  color: var(--text-muted);
}

.meta-value {
  font-weight: 500;
  color: #FFFFFF;
}

.entity-details-content h2 {
  font-family: var(--font-card-title);
  font-size: 2rem;
  margin-bottom: 4px;
}

.entity-details-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: var(--space-lg);
  font-style: italic;
}

.entity-properties-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
  width: 100%;
}

.entity-properties-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.entity-properties-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.property-pill {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  text-align: center;
}

.property-pill-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.property-pill-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: var(--font-heading);
}

.entity-markdown-body {
  line-height: 1.7;
  font-size: 0.98rem;
  color: rgba(245, 247, 250, 0.9);
  white-space: pre-wrap;
}

.entity-section-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 4px;
  margin: var(--space-xl) 0 var(--space-sm) 0;
  letter-spacing: 0.05em;
}

.entity-connections-list {
  list-style: none;
}

.entity-connection-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.entity-connection-item:last-child {
  border-bottom: none;
}

/* --- Interactive Maps Layout --- */
.maps-view-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-2xl);
  min-height: 650px;
}

.maps-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.map-list-item {
  padding: var(--space-md);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: rgba(22, 27, 34, 0.2);
}

.map-list-item:hover, .map-list-item.active {
  background: rgba(22, 27, 34, 0.5);
  border-color: var(--accent-primary);
}

.map-list-item h4 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.map-list-item p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.map-display-area {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
  background: #060709;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 550px;
}

.map-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.map-image {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.map-pin {
  position: absolute;
  width: 26px;
  height: 26px;
  background: rgba(var(--blob-color-rgb, 102, 252, 241), 0.25);
  border: 2px solid rgba(var(--blob-color-rgb, 102, 252, 241), 0.85);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(var(--blob-color-rgb, 102, 252, 241), 0.6);
  transition: all var(--transition-fast);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: blob-pulse 2.2s infinite;
}

.map-pin::after {
  content: '';
  width: 8px;
  height: 8px;
  background: rgba(var(--blob-color-rgb, 102, 252, 241), 0.9);
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.map-pin:hover {
  transform: translate(-50%, -50%) scale(1.25);
  background: rgba(var(--blob-color-rgb, 102, 252, 241), 0.45);
  border-color: #FFFFFF;
  box-shadow: 0 0 20px rgba(var(--blob-color-rgb, 102, 252, 241), 0.95), 0 0 0 4px rgba(var(--blob-color-rgb, 102, 252, 241), 0.2);
  z-index: 100;
}

.map-pin:hover::after {
  background: #FFFFFF;
  transform: scale(1.2);
}

@keyframes blob-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--blob-color-rgb, 102, 252, 241), 0.6);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(var(--blob-color-rgb, 102, 252, 241), 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(var(--blob-color-rgb, 102, 252, 241), 0);
  }
}

/* Pin Tooltip */
.map-pin-tooltip {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 22, 28, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  color: #FFFFFF;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-body);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 120;
}

.map-pin:hover .map-pin-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.map-no-content {
  text-align: center;
  padding: var(--space-3xl);
  color: var(--text-muted);
}

/* --- Connection Graph View --- */
.graph-container {
  height: 70vh;
  min-height: 550px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(22, 27, 34, 0.45) 0%, rgba(11, 12, 16, 0.9) 100%);
  position: relative;
}

/* Vis-Network styling modifications */
div.vis-network {
  outline: none;
}

.graph-overlay-actions {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  display: flex;
  gap: var(--space-sm);
  z-index: 10;
}

/* --- Ideas Scratchpad View (Mobile First Split) --- */
.ideas-view-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: var(--space-xl);
  height: 72vh;
  min-height: 580px;
}

.ideas-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--glass-border);
  padding-right: var(--space-xl);
  overflow-y: auto;
}

.ideas-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.idea-item {
  padding: var(--space-md);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.idea-item:hover, .idea-item.active {
  border-color: var(--accent-secondary);
  background: rgba(155, 108, 255, 0.05);
}

.idea-item.active {
  box-shadow: 0 0 10px rgba(155, 108, 255, 0.1);
}

.idea-item h4 {
  font-size: 0.95rem;
  margin-bottom: 4px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.idea-item p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ideas-editor-pane {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  height: 100%;
}

.ideas-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.ideas-editor-title {
  background: transparent;
  border: none;
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: #FFFFFF;
  outline: none;
  width: 100%;
  max-width: 500px;
}

.ideas-editor-title::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.ideas-editor-textarea {
  flex-grow: 1;
  background: rgba(11, 12, 16, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: rgba(255, 255, 255, 0.95);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: var(--space-lg);
  line-height: 1.6;
  outline: none;
  resize: none;
  transition: all var(--transition-fast);
}

.ideas-editor-textarea:focus {
  border-color: var(--accent-secondary);
  background: rgba(11, 12, 16, 0.5);
  box-shadow: 0 0 15px rgba(155, 108, 255, 0.08);
}

.idea-no-selection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: var(--space-md);
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--glass-border);
  background: rgba(11, 12, 16, 0.8);
  padding: var(--space-xl) 0;
  margin-top: var(--space-3xl);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-content {
  max-width: 1600px;
  width: 92%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-link:hover {
  color: var(--accent-primary);
}

.mobile-only {
  display: none !important;
}

/* --- Responsive Layout (Desktop-First) --- */
@media (max-width: 1200px) {
  .ideas-view-layout {
    grid-template-columns: 260px 1fr;
  }
  .maps-view-layout {
    grid-template-columns: 220px 1fr;
  }
}

@media (max-width: 1100px) {
  .logo .logo-subtitle {
    display: none !important;
  }
}

@media (max-width: 992px) {
  .header-container-wrapper {
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
  }
  
  .logo {
    margin-bottom: var(--space-xs);
  }
  
  #header-nav {
    width: 100%;
    display: flex !important;
    justify-content: center;
  }
  
  .nav-tabs {
    width: 100%;
    justify-content: center;
    padding: 0;
  }
  
  .nav-actions {
    width: 100%;
    justify-content: center;
    margin-top: var(--space-xs);
    gap: var(--space-sm);
  }
  
  .search-wrapper {
    flex-grow: 1;
    width: 100%;
    max-width: 320px;
  }

  .entity-details-grid {
    grid-template-columns: 1fr;
  }

  .entity-details-image {
    height: 240px;
  }
  
  .maps-view-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  
  .maps-sidebar {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: var(--space-sm);
  }
  
  .map-list-item {
    min-width: 160px;
    flex-shrink: 0;
    padding: var(--space-sm);
  }
  
  .ideas-view-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .ideas-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
    padding-right: 0;
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-md);
    max-height: 180px;
  }
}

@media (max-width: 768px) {
  .portal-container {
    width: 95%;
  }

  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-md);
  }

  .portal-card {
    height: 50vh;
    min-height: 400px;
  }

  .portal-card:hover .card-content {
    height: 80%;
  }

  .portal-card:hover .card-description {
    max-height: 130px;
  }

  .world-hero {
    height: 180px;
    padding: var(--space-md);
  }
  
  .world-hero h1 {
    font-size: 1.6rem;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-tags {
    justify-content: flex-start;
  }
  
  .footer-content {
    flex-direction: column;
    text-align: center;
  }

  .mobile-only {
    display: inline-block !important;
  }

  /* Stack sessions layout vertically */
  .sessions-layout {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr !important;
    height: auto !important;
    min-height: auto !important;
  }
  .sessions-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-md);
    max-height: 200px;
  }

  /* Make Connections Graph overlay actions wrap */
  .graph-overlay-actions {
    flex-wrap: wrap;
    gap: var(--space-xs) !important;
    position: relative !important;
    top: 0 !important;
    right: 0 !important;
    width: 100% !important;
    padding: var(--space-sm);
    background: rgba(11, 12, 16, 0.8);
    border-bottom: 1px solid var(--glass-border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-bottom: var(--space-sm);
  }
  .graph-legend {
    margin-left: 0 !important;
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 576px) {
  .nav-tabs {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .nav-link {
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
  }

  .tab-search-wrapper {
    flex-direction: column;
    align-items: stretch;
  }
  #loreSortSelector {
    width: 100% !important;
    max-width: none !important;
  }
}

/* ==========================================================================
   ENHANCED WORLD PLANNER STYLES (Search, Autocomplete, Drawer, Tag Selectors)
   ========================================================================== */

/* --- Global Search Results Dropdown --- */
.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(17, 22, 28, 0.95);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  margin-top: 6px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1010;
  box-shadow: var(--shadow-premium), var(--glow-secondary);
}

.search-results-dropdown.hidden {
  display: none !important;
}

.search-category-group {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: var(--space-sm) 0;
}

.search-category-group:last-child {
  border-bottom: none;
}

.search-category-title {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px var(--space-md);
}

.search-result-item {
  display: flex;
  flex-direction: column;
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.search-result-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.search-result-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #FFFFFF;
}

.search-result-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.search-no-results {
  padding: var(--space-md);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* --- Sliding Side-Drawer for Ideas (Detached Notepad) --- */
.ideas-drawer-overlay {
  position: fixed;
  top: 0;
  right: 0;
  width: 650px;
  height: 100vh;
  z-index: 1500;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  pointer-events: none;
}

.ideas-drawer-overlay.active {
  transform: translateX(0);
  pointer-events: auto;
}

.ideas-drawer-content {
  background: rgba(13, 17, 23, 0.95);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-left: 1px solid var(--glass-border);
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: var(--space-xl);
  box-shadow: -15px 0 35px rgba(0, 0, 0, 0.6);
}

.ideas-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: var(--space-md);
}

.ideas-drawer-layout-split {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-lg);
  flex-grow: 1;
  overflow: hidden;
  margin-top: var(--space-md);
}

.ideas-drawer-sidebar {
  border-right: 1px solid var(--glass-border);
  padding-right: var(--space-md);
  overflow-y: auto;
}

.ideas-drawer-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  overflow: hidden;
}

/* --- Autocomplete Dropdowns (Notepad & Forms) --- */
.mention-autocomplete-dropdown, .graph-autocomplete-dropdown {
  position: absolute;
  background: rgba(17, 22, 28, 0.98);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border-hover);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-premium), var(--glow-primary);
  max-height: 180px;
  overflow-y: auto;
  z-index: 2100;
  width: 250px;
}

.mention-autocomplete-dropdown.hidden, .graph-autocomplete-dropdown.hidden {
  display: none !important;
}

.mention-item, .autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: #FFFFFF;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background var(--transition-fast);
}

.mention-item:last-child, .autocomplete-item:last-child {
  border-bottom: none;
}

.mention-item:hover, .mention-item.selected, .autocomplete-item:hover, .autocomplete-item.selected {
  background: rgba(102, 252, 241, 0.15);
  color: var(--accent-primary);
}

.mention-type, .autocomplete-type {
  font-size: 0.7rem;
  opacity: 0.7;
  text-transform: uppercase;
}

.button-tag-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: var(--space-xs) 0;
  width: 100%;
}

.btn-tag {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 0.8rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex: 1 1 auto;
  min-width: 70px;
  text-align: center;
}

.btn-tag:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}

.btn-tag.active {
  background: rgba(102, 252, 241, 0.12);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(102, 252, 241, 0.1);
}

/* Specific button tag colors */
.btn-tag.active.badge-faction {
  background: rgba(155, 108, 255, 0.12);
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
  box-shadow: 0 0 10px rgba(155, 108, 255, 0.1);
}

.btn-tag.active.badge-adversary {
  background: rgba(255, 77, 77, 0.12);
  border-color: #FF4D4D;
  color: #FF4D4D;
  box-shadow: 0 0 10px rgba(255, 77, 77, 0.1);
}

/* --- Inline Editing Styles --- */
.editable-field {
  border-bottom: 1px dashed transparent;
  transition: all var(--transition-fast);
  cursor: text;
}

.editable-field:hover {
  border-bottom-color: var(--glass-border-hover);
  background: rgba(255, 255, 255, 0.02);
}

.editable-field:focus {
  outline: none;
  border-bottom-style: solid;
  border-bottom-color: var(--accent-primary);
  background: rgba(11, 12, 16, 0.3);
  padding: 2px 4px;
}

.save-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.save-status-dot.saved {
  background-color: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
}

.save-status-dot.saving {
  background-color: #FFA500;
  box-shadow: 0 0 8px #FFA500;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

/* --- Canvas Quick Connect Drawer Overlay --- */
.graph-quick-connect {
  background: rgba(17, 22, 28, 0.85);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-premium);
  position: relative;
}

.graph-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  background: rgba(17, 22, 28, 0.98);
  border: 1px solid var(--glass-border-hover);
  border-radius: var(--radius-md);
  width: 150px;
  max-height: 120px;
  overflow-y: auto;
  z-index: 2050;
  box-shadow: var(--shadow-premium);
}

/* --- Mobile Specific Adaptations (Responsive Overlay) --- */
@media (max-width: 768px) {
  .ideas-drawer-overlay {
    width: 100%;
  }

  .ideas-drawer-content {
    padding: var(--space-md);
  }

  .ideas-drawer-layout-split {
    display: flex;
    flex-direction: column;
    height: calc(100% - 60px);
    overflow: hidden;
  }

  .ideas-drawer-sidebar {
    display: block;
    width: 100%;
    max-height: none !important;
    border-right: none;
    border-bottom: none;
    padding-right: 0;
    overflow-y: auto;
  }

  .ideas-drawer-editor {
    display: none;
    width: 100%;
    height: 100%;
  }

  /* When editing, show editor and hide sidebar list */
  .ideas-drawer-overlay.editing-idea .ideas-drawer-sidebar {
    display: none;
  }

  .ideas-drawer-overlay.editing-idea .ideas-drawer-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  
  .graph-quick-connect {
    width: 95%;
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1005;
  }
  
  .graph-quick-connect div {
    flex-wrap: wrap;
  }
}

/* Map Zoom Controls styling */
.map-zoom-controls {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius-md);
  background: rgba(20, 24, 33, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-premium);
  transition: opacity var(--transition-fast);
}

.map-zoom-controls.hidden {
  display: none !important;
}

.map-zoom-controls button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.1rem;
  font-weight: bold;
}

.map-zoom-controls #mapZoomResetBtn {
  width: auto;
  height: auto;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: normal;
}

/* Image Dropzone wrapper styling */
.image-dropzone-wrapper {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  border: 1px dashed rgba(102, 252, 241, 0.3);
  padding: 8px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  transition: all var(--transition-fast);
  position: relative;
}

.image-dropzone-wrapper.drag-over {
  border-color: var(--accent-primary);
  background: rgba(102, 252, 241, 0.08);
  box-shadow: 0 0 10px rgba(102, 252, 241, 0.3);
}

.image-dropzone-wrapper::after {
  content: 'Drop image here';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 7, 9, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 5;
}

.image-dropzone-wrapper.drag-over::after {
  opacity: 1;
}

/* Preset Categories & Groups */
.preset-category {
  margin-bottom: 12px;
}

.preset-category:last-child {
  margin-bottom: 0;
}

.preset-category-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent-primary);
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(102, 252, 241, 0.12);
  padding-bottom: 2px;
  letter-spacing: 0.05em;
}

.relation-preset-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* New badge colors in CSS */
.badge-event { color: #FF4081; border-color: rgba(255, 64, 129, 0.3); }
.badge-concept { color: #29B6F6; border-color: rgba(41, 182, 246, 0.3); }
.badge-session { color: #26A69A; border-color: rgba(38, 166, 154, 0.3); }
.badge-article { color: #90A4AE; border-color: rgba(144, 164, 174, 0.3); }

/* Detail Image Hover Edit Overlay Styles */
.detail-image-wrapper {
  position: relative;
  width: 100%;
  height: 320px;
}

.image-edit-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
  cursor: pointer;
  z-index: 10;
  backdrop-filter: blur(2px);
  border: 1px dashed var(--accent-primary);
}

.detail-image-wrapper:hover .image-edit-overlay {
  opacity: 1;
}

.image-edit-overlay.drag-over {
  opacity: 1 !important;
  background: rgba(102, 252, 241, 0.25) !important;
  border-color: var(--accent-primary) !important;
  border-style: dashed !important;
}

.image-edit-overlay span {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* --- Zoomable Hover Thumbnails --- */
.zoomable-thumbnail-wrapper {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.thumbnail-small {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--glass-border);
  display: inline-block;
  vertical-align: middle;
}

.thumbnail-zoom {
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  width: 120px;
  height: 120px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 2px solid var(--glass-border);
  box-shadow: var(--shadow-premium);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1050;
  background: #0D1117;
}

.zoomable-thumbnail-wrapper:hover .thumbnail-zoom {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* --- SVG Map Connections --- */
.map-connections-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* --- Session Notes View --- */
.campaign-tabs {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}
.campaign-tab {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 500;
}
.campaign-tab:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.08);
}
.campaign-tab.active {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(102, 252, 241, 0.08);
  box-shadow: 0 0 8px rgba(102, 252, 241, 0.15);
}

.session-sidebar-item {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.session-sidebar-item:hover, .session-sidebar-item.active {
  background: rgba(102, 252, 241, 0.04);
  border-color: var(--accent-primary);
}
.session-sidebar-item.active .session-sidebar-title {
  color: var(--accent-primary);
}
.session-sidebar-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition-fast);
}
.session-sidebar-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.session-note-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  position: relative;
  text-align: left;
}
.session-note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 8px;
}
.session-note-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-primary);
}
.session-note-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.session-note-body {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-color);
  white-space: pre-wrap;
}

.session-notes-viewer {
  flex-grow: 1;
  overflow-y: auto;
  padding: var(--space-md);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-color);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.15);
  cursor: pointer;
  white-space: pre-wrap;
  min-height: 350px;
  transition: all var(--transition-fast);
}
.session-notes-viewer:hover {
  background: rgba(255, 255, 255, 0.01);
  border-color: rgba(102, 252, 241, 0.3);
}

/* --- Direct Relationship Category Filters --- */
.direct-relation-filters {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}



