/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', sans-serif;
  background-color: #121212;
  color: #f5f5f5;
  height: 100vh;
  overflow: hidden;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: #1f1f1f;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
  flex: 1;
}

.header-center {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
}

.header-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
}

.brand-logo-main {
  height: 80px;
  width: auto;
  filter: 
    drop-shadow(0 0 8px rgba(255, 255, 255, 0.3))
    drop-shadow(0 0 16px rgba(255, 255, 255, 0.2))
    drop-shadow(0 4px 8px rgba(0, 0, 0, 0.6))
    brightness(1.2)
    contrast(1.1);
  transition: all 0.3s ease;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
  border-radius: 50%;
  padding: 8px;
}

.brand-logo-main:hover {
  transform: scale(1.05);
  filter: 
    drop-shadow(0 0 12px rgba(255, 255, 255, 0.5))
    drop-shadow(0 0 24px rgba(255, 255, 255, 0.3))
    drop-shadow(0 6px 12px rgba(0, 0, 0, 0.8))
    brightness(1.4)
    contrast(1.2);
}

.brand-text-logo {
  height: 32px;
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  margin-bottom: 0.25rem;
}

header h1 {
  font-size: 1.5rem;
  color: #f5f5f5;
  margin: 0;
}

.story-title-input {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #f5f5f5;
  padding: 0.4rem 0.8rem;
  font-size: 1rem;
  width: 300px;
  transition: all 0.2s ease;
}

.story-title-input:focus:not(.read-only) {
  border-color: #4c6ef5;
  outline: none;
  box-shadow: 0 0 0 2px rgba(76, 110, 245, 0.2);
}

.story-title-input.read-only {
  background: transparent;
  border-color: transparent;
  cursor: default;
  padding-left: 2px;
}

.story-title-input.read-only:focus {
  outline: none;
}

.story-title-input::placeholder {
  color: #888;
}

header button {
  background: #4c6ef5;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Plot controls styling */
.plot-controls {
  display: flex;
  gap: 8px;
  margin-right: 16px;
  padding-right: 16px;
  border-right: 2px solid #444;
  height: 100%;
  align-items: center;
}

.plot-control-btn {
  background: #6b46c1 !important;
  color: white;
  border: 1px solid #805ad5 !important;
  padding: 0.5rem 1rem;
  font-size: 0.9rem !important;
  display: flex;
  align-items: center;
  gap: 4px;
}

.plot-control-btn:hover {
  background: #805ad5 !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(128, 90, 213, 0.2);
}

.export-btn {
  background: #553c9a !important;
}

.import-btn {
  background: #6b46c1 !important;
}

.mode-btn {
  background: #2b2b2b !important;
  border: 1px solid #4c6ef5 !important;
  pointer-events: auto !important;
  opacity: 1 !important;
}

.mode-btn.edit-mode {
  background: #4c6ef5 !important;
}

/* Ensure mode toggle is never disabled */
#mode-toggle {
  pointer-events: auto !important;
  opacity: 1 !important;
}

#mode-toggle:disabled {
  pointer-events: auto !important;
  opacity: 1 !important;
  background: #2b2b2b !important;
  border: 1px solid #4c6ef5 !important;
  color: inherit !important;
}

.reference {
  color: #4c6ef5;
  text-decoration: none;
  cursor: pointer;
  background: rgba(76, 110, 245, 0.1);
  padding: 0 4px;
  border-radius: 4px;
}

.reference:hover {
  background: rgba(76, 110, 245, 0.2);
}

header button:hover {
  transform: scale(1.05);
}

/* Board */
#board {
  position: relative;
  width: 100%;
  height: calc(100vh - 70px);
  overflow: auto;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none; /* Prevent text selection while dragging */
}

#board-content {
  position: absolute;
  min-width: 200%;
  min-height: 200%;
  transform-origin: 0 0;
}

/* Grid styling */
#board.show-grid {
  background-size: 40px 40px;
  background-image:
    linear-gradient(to right, rgba(76, 110, 245, 0.1) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(76, 110, 245, 0.1) 1px, transparent 1px);
}

/* Settings Panel */
#settings-panel {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: #1f1f1f;
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 1000;
  color: #f5f5f5;
}

.settings-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.settings-group:last-child {
  margin-bottom: 0;
}

.settings-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* Custom checkbox styling */
.settings-group input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid #4c6ef5;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  position: relative;
}

.settings-group input[type="checkbox"]:checked {
  background-color: #4c6ef5;
}

.settings-group input[type="checkbox"]:checked::before {
  content: '✓';
  position: absolute;
  color: white;
  font-size: 12px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Sticky Note */
.note {
  position: absolute;
  width: 200px;
  height: 150px;
  background: #1e1e1e;
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  padding: 0.75rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  cursor: move;
  transition: transform 0.15s ease;
  animation: bounceIn 0.4s ease;
  overflow: visible;
  min-width: 150px;
  min-height: 100px;
  max-width: 600px;
  max-height: 400px;
}

.note-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.note:active {
  transform: scale(1.03);
}

.note-title {
  font-weight: bold;
  margin-bottom: 8px;
  color: #f5f5f5;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
}

/* Style for title editing input */
.note-title-editing {
  background: #2a2a2a !important;
  color: #f5f5f5 !important;
  border: 1px solid #4c6ef5 !important;
  border-radius: 4px !important;
  padding: 2px 4px !important;
  font-weight: bold !important;
  font-size: 0.9rem !important;
  outline: none !important;
}

.note-title-editing::selection {
  background: #4c6ef5 !important;
  color: white !important;
}

.note-details {
  font-size: 0.8rem;
  color: #ccc;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  line-clamp: 6;
  -webkit-box-orient: vertical;
  word-wrap: break-word;
}

/* Resize handle */
.note::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  background: linear-gradient(-45deg, transparent 0%, transparent 40%, #666 40%, #666 60%, transparent 60%);
  cursor: se-resize;
  z-index: 10;
  pointer-events: none;
}

.resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: se-resize;
  z-index: 11;
}

.note textarea {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  color: #f5f5f5;
  resize: none;
  font-size: 1rem;
  outline: none;
  caret-color: #4c6ef5;
}

/* Selected note styling */
.note.selected {
  outline: 2px solid #4c6ef5;
  box-shadow: 0 0 12px rgba(76,110,245,0.4);
}

/* Selection box styling */
.selection-box {
  position: absolute;
  border: 2px solid #4c6ef5;
  background-color: rgba(76, 110, 245, 0.1);
  pointer-events: none;
  z-index: 1000;
  margin: 0;
  padding: 0;
  cursor: crosshair;
}

/* Bounce animation */
@keyframes bounceIn {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  60% {
    transform: scale(1.05);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

/* Details Panel */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  /* Let JS set left/top/width/height as needed */
}

.modal.open {
  display: block;
}

.modal-content {
  background: #1f1f1f;
  border-radius: 12px;
  max-width: min(90vw, 1200px);
  min-width: 200px;
  min-height: 150px;
  max-height: 90vh;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: modalIn 0.3s ease;
  position: relative;
  resize: both;
  overflow: auto;
  cursor: move;
  margin: 0;
  transform: none !important;
}


/* Specific reference panel styling */
#reference-panel {

}

/* Draggable modal styling */
.modal.dragging,
.modal:has(.modal-content[style*="position: fixed"]) {
  align-items: flex-start !important;
  justify-content: flex-start !important;
}

.modal-content[style*="position: fixed"] {
  position: fixed !important;
  margin: 0 !important;
  transform: none !important;
  width: auto !important;
  max-width: min(90vw, 1200px) !important;
  min-width: 200px !important;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mode transition animations */
.modal-content.mode-transitioning {
  transition: all 0.3s ease;
}

.modal-body .form-group {
  transition: opacity 0.2s ease;
}

.modal-body input,
.modal-body textarea {
  transition: all 0.2s ease;
  background-color: #2a2a2a;
  border: 1px solid #555;
}

.modal-body input[readonly],
.modal-body textarea[readonly] {
  background-color: #1a1a1a;
  border-color: #444;
  cursor: default;
}

.modal-body input[readonly]:focus,
.modal-body textarea[readonly]:focus {
  outline: none;
  box-shadow: none;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #333;
}

.panel-actions {
  transition: opacity 0.2s ease;
}

.panel-actions button {
  transition: all 0.2s ease;
}

#save-reference,
#delete-reference {
  transition: all 0.2s ease;
}

.tags-container {
  transition: all 0.2s ease;
}

.tag-input {
  transition: all 0.2s ease;
}

/* Context Menu Styles */
.context-menu {
  position: fixed;
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border: 1px solid #4c6ef5;
  border-radius: 12px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(76, 110, 245, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 10000;
  min-width: 160px;
  padding: 8px;
  transform: scale(0.8) translateY(-10px);
  opacity: 0;
  animation: contextMenuIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  pointer-events: none;
}

.context-menu.show {
  pointer-events: auto;
}

@keyframes contextMenuIn {
  0% {
    transform: scale(0.8) translateY(-10px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 2px 0;
  border-radius: 8px;
  color: #f5f5f5;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.context-menu-item:hover {
  background: linear-gradient(145deg, #4c6ef5, #3851d1);
  border-color: rgba(76, 110, 245, 0.3);
  transform: translateX(2px);
  box-shadow: 0 2px 8px rgba(76, 110, 245, 0.3);
}

.context-menu-item.danger:hover {
  background: linear-gradient(145deg, #e03131, #c92a2a);
  border-color: rgba(224, 49, 49, 0.3);
  box-shadow: 0 2px 8px rgba(224, 49, 49, 0.3);
}

/* Selection styling for references */
.reference-item.selected {
  background: linear-gradient(135deg, #3742fa 0%, #2f3542 100%);
  border-color: #3742fa;
  transform: scale(1.02);
  box-shadow: 0 4px 20px rgba(55, 66, 250, 0.3);
}

.context-menu-item .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.context-menu-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #333, transparent);
  margin: 6px 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #333;
  gap: 0.5rem;
  min-height: 60px;
}

/* Header controls alignment */
.modal-header .header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.modal-header h2 {
  font-size: 1.4rem;
  color: #f5f5f5;
  margin: 0;
  flex: 1;
}

/* BBCode Helper */
.bbcode-helper {
  margin-bottom: 1rem;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  overflow: hidden;
}

.helper-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: #333;
  border-bottom: 1px solid #444;
}

.helper-header label {
  color: #f5f5f5;
  font-size: 0.9rem;
  margin: 0;
  font-weight: 500;
}

.helper-toggle {
  background: #4c6ef5;
  border: none;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  transition: all 0.2s ease;
}

.helper-toggle:hover {
  background: #5c7cfa;
}

.helper-content {
  padding: 0.75rem;
  display: block;
  transition: all 0.3s ease;
}

.helper-content.collapsed {
  display: none;
}

.helper-section {
  margin-bottom: 0.75rem;
}

.helper-section:last-child {
  margin-bottom: 0;
}

.helper-section strong {
  display: block;
  color: #f5f5f5;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
}

.helper-examples {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.helper-examples code {
  background: #1a1a1a;
  color: #4c6ef5;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-family: 'Courier New', monospace;
  border: 1px solid #333;
  cursor: pointer;
  transition: all 0.2s ease;
}

.helper-examples code:hover {
  background: #333;
  border-color: #4c6ef5;
}

/* Enhanced editing mode adjustments */
#details-panel.fullscreen.enhanced-editing .bbcode-helper {
  display: block;
}

#details-panel:not(.fullscreen) .bbcode-helper,
#details-panel:not(.enhanced-editing) .bbcode-helper {
  display: none;
}

/* Writing stats only visible in fullscreen enhanced mode */
#details-panel.fullscreen.enhanced-editing .writing-stats {
  display: block !important;
}

#details-panel:not(.fullscreen) .writing-stats {
  display: none !important;
}

/* Panel control buttons */
.enhanced-toggle,
.fullscreen-toggle {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #f5f5f5;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

/* Hide enhanced toggle in minimized view */
#details-panel:not(.fullscreen) .enhanced-toggle {
  display: none !important;
}

/* Hide close button in fullscreen view */
#details-panel.fullscreen #close-panel,
#read-panel.fullscreen #close-read-panel {
  display: none;
}

/* Modal header button alignment */
.modal-header button,
.modal-header .fullscreen-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  vertical-align: middle;
}

/* Enhanced toggle alignment only in fullscreen */
#details-panel.fullscreen .modal-header .enhanced-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  vertical-align: middle;
}

/* Hide enhanced toggle in minimized view */
#details-panel:not(.fullscreen) .enhanced-toggle {
  display: none !important;
}

/* Adjust button styling for minimized view */
#details-panel:not(.fullscreen) .modal-header button,
#details-panel:not(.fullscreen) .modal-header .fullscreen-toggle {
  background: none !important;
  border: none !important;
  color: #999 !important;
  font-size: 18px !important;
  width: 32px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#details-panel:not(.fullscreen) .modal-header button:hover,
#details-panel:not(.fullscreen) .modal-header .fullscreen-toggle:hover {
  background: #3a3a3a !important;
  border: none !important;
  color: #f5f5f5 !important;
}

#details-panel:not(.fullscreen) .fullscreen-toggle {
  background: none !important;
  border: none !important;
  color: #999 !important;
  font-size: 16px !important;
  width: 32px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#details-panel:not(.fullscreen) .fullscreen-toggle:hover {
  background: #3a3a3a !important;
  border: none !important;
  color: #f5f5f5 !important;
}

.enhanced-toggle:hover,
.fullscreen-toggle:hover {
  background: #3a3a3a;
  border-color: #555;
}

.enhanced-toggle.active,
.fullscreen-toggle.active {
  background: #4c6ef5;
  border-color: #4c6ef5;
}

.modal-header button[id$="-panel"] {
  background: #2a2a2a;
  border: 1px solid #444;
  color: #f5f5f5;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.modal-header button[id$="-panel"]:hover {
  background: #3a3a3a;
  border-color: #555;
}

.modal-body {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  color: #f5f5f5;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.bbcode-indicator {
  color: #4c6ef5;
  font-size: 0.8rem;
  font-weight: normal;
  opacity: 0.8;
}

/* Hide BBCode indicator in minimized editor */
#details-panel:not(.fullscreen) .bbcode-indicator {
  display: none;
}

#title-input {
  width: 100%;
  padding: 0.6rem;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #f5f5f5;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease;
}

#title-input:focus {
  border-color: #4c6ef5;
}

#details-textarea {
  width: 100%;
  height: 150px;
  resize: vertical;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #f5f5f5;
  padding: 0.6rem;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease;
}

#details-textarea:focus {
  border-color: #4c6ef5;
}

.delete-btn {
  background-color: #dc3545;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.delete-btn:hover {
  background-color: #c82333;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

#read-panel-content {
  font-size: 1rem;
  line-height: 1.6;
  color: #f5f5f5;
  white-space: pre-wrap;
  word-break: break-word;
}

#read-panel-title {
  margin: 0;
  font-size: 1.4rem;
  color: #f5f5f5;
}

#close-panel, #close-read-panel {
  background: none;
  border: none;
  color: #999;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  transition: color 0.2s ease;
}

#close-panel:hover {
  color: #f5f5f5;
}

/* Note title */
.note-title {
  font-weight: bold;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.note-details {
  font-size: 0.9rem;
  color: #e0e0e0;
  line-height: 1.4;
  margin-top: 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.plot-point {
  position: absolute;
  width: 180px;
  min-height: 120px;
  background: #1e1e1e;
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  padding: 0.75rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  cursor: move;
  transition: transform 0.15s ease;
}

.plot-point:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.plot-point .plot-title {
  font-weight: bold;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

/* Connector logic */

.connector {
  position: absolute;
  right: -15px;
  top: 50%;
  transform: translateY(-50%) scale(0.3);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #4c6ef5;
  box-shadow: 0 0 12px rgba(76,110,245,0.6);
  transition: transform 0.2s ease;
  pointer-events: auto;
  cursor: crosshair;
  z-index: 5;
  opacity: 0.4;
  /* Add invisible larger hit area */
  border: 8px solid transparent;
}

.note.near .connector,
.note:active .connector,
.note:hover .connector {
  transform: translateY(-50%) scale(1);
  opacity: 1;
}

.connector:hover {
  transform: translateY(-50%) scale(1.2) !important;
  box-shadow: 0 0 20px rgba(76,110,245,0.8);
  opacity: 1 !important;
}

.note.snap-target {
  outline: 3px solid #4c6ef5;
  box-shadow: 0 0 20px rgba(76,110,245,0.6);
  transform: scale(1.02);
  transition: transform 0.2s ease, outline 0.2s ease, box-shadow 0.2s ease;
}

.note.snap-target .left-connector {
  transform: translateY(-50%) scale(1.4);
  box-shadow: 0 0 20px rgba(76,110,245,0.8);
  background: #4c6ef5;
  opacity: 1;
}

#connections {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.connection-line {
  stroke: #4c6ef5;
  stroke-width: 2;
}

.left-connector {
  position: absolute;
  left: -15px;
  top: 50%;
  transform: translateY(-50%) scale(0.3);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ff6b6b;
  box-shadow: 0 0 12px rgba(255, 107, 107, 0.6);
  z-index: 5;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0.4;
  transition: background-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease, opacity 0.2s ease;
  /* Add invisible larger hit area */
  border: 8px solid transparent;
}

.left-connector.connected {
  background: #40c057;
  box-shadow: 0 0 12px rgba(64, 192, 87, 0.6);
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.left-connector:hover {
  transform: translateY(-50%) scale(1.2);
  box-shadow: 0 0 16px rgba(255, 107, 107, 0.8);
  opacity: 1;
}

/* Tag System Styling */
.tags-container {
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(135deg, #2a2a2a 0%, #1f1f1f 100%);
  min-height: 48px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.3),
    0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.tags-container:focus-within {
  border-color: #4c6ef5;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.3),
    0 0 0 2px rgba(76, 110, 245, 0.2),
    0 4px 12px rgba(76, 110, 245, 0.1);
}

.tags-display {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 0 1 auto;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  background: #4c6ef5;
  color: white;
  padding: 6px 12px;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 500;
  gap: 8px;
  animation: tagFadeIn 0.2s ease;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.tag-chip.character {
  background: #2d8653;
}

.tag-chip.location {
  background: #c65d07;
}

.tag-chip.theme {
  background: #c2255c;
}

.tag-chip.plot {
  background: #6741d9;
}

.tag-chip.conflict {
  background: #e03131;
}

.tag-chip.custom {
  background: #5c5f66;
}

/* Drag and drop styling for tag chips */
.tag-chip[draggable="true"] {
  cursor: grab;
  transition: all 0.2s ease;
}

.tag-chip[draggable="true"]:active {
  cursor: grabbing;
}

.tag-chip.dragging {
  opacity: 0.3;
  transform: scale(1.05);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
  z-index: 1000;
}

.tag-chip.drag-over-left {
  border-left: 3px solid #4c6ef5;
  border-radius: 18px 18px 18px 0;
}

.tag-chip.drag-over-right {
  border-right: 3px solid #4c6ef5;
  border-radius: 18px 0 18px 18px;
}

/* Custom color override - higher specificity than built-in categories */
.tag-chip.custom-color {
  background: var(--custom-bg-color, #6741d9) !important;
  border: 2px solid var(--custom-border-color, #6741d9) !important;
}

/* Read mode tag styling */
.tag-chip.read-mode {
  opacity: 0.9;
}

.tag-chip.read-mode:hover {
  transform: none;
  opacity: 1;
}

.tag-chip.read-mode span {
  cursor: default !important;
}

/* Read panel tag styling */
.read-panel-tags {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #333;
}

.read-panel-tags strong {
  display: block;
  margin-bottom: 8px;
  color: #f5f5f5;
  font-weight: 500;
}

.read-panel-tags .tags-display {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-remove {
  background: none;
  border: none;
  color: currentColor;
  cursor: pointer;
  padding: 0;
  margin: 0;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 10px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.tag-remove:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.2);
}

.tag-input {
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 14px;
  padding: 8px 12px;
  min-width: 120px;
  flex: 1 1 auto;
  color: #f5f5f5;
  transition: all 0.2s ease;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.tag-input:focus {
  background: rgba(76, 110, 245, 0.05) !important;
  border-radius: 6px;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.tag-input::placeholder {
  color: #666;
  font-style: italic;
  transition: color 0.2s ease;
}

.tag-input:focus::placeholder {
  color: #888;
}

.tag-suggestions {
  position: fixed;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 9999;
  display: none;
  min-width: 200px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* Scrollbar styling for tag suggestions */
.tag-suggestions::-webkit-scrollbar {
  width: 6px;
}

.tag-suggestions::-webkit-scrollbar-track {
  background: #1a1a1a;
  border-radius: 3px;
}

.tag-suggestions::-webkit-scrollbar-thumb {
  background: #4c6ef5;
  border-radius: 3px;
}

.tag-suggestions::-webkit-scrollbar-thumb:hover {
  background: #5c7cfa;
}

/* Color picker panel styling */
.color-display-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.color-display {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 2px solid #444;
  flex-shrink: 0;
}

.color-hex-input {
  background: #2a2a2a;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 8px;
  color: #f5f5f5;
  font-family: monospace;
  width: 100px;
}

.color-hex-input:focus {
  border-color: #4c6ef5;
  outline: none;
  box-shadow: 0 0 0 2px rgba(76, 110, 245, 0.2);
}

/* Color history styles */
.color-history-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  min-height: 44px;
  padding: 8px;
  border: 1px solid #444;
  border-radius: 8px;
  background: #2a2a2a;
}

.color-history-item {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 2px solid #555;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.color-history-item:hover {
  transform: scale(1.1);
  border-color: #4c6ef5;
  box-shadow: 0 2px 8px rgba(76, 110, 245, 0.3);
}

.color-history-item.selected {
  border-color: #4c6ef5;
  box-shadow: 0 0 0 2px rgba(76, 110, 245, 0.4);
}

.color-history-empty {
  color: #888;
  font-style: italic;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px;
}

.color-palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.color-swatch {
  width: 35px;
  height: 35px;
  border-radius: 8px;
  border: 2px solid #444;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.1);
  border-color: #f5f5f5;
}

.color-swatch.selected {
  border-color: #4c6ef5;
  box-shadow: 0 0 0 2px rgba(76, 110, 245, 0.3);
}

/* Color swatch backgrounds */
.swatch-character { background: #2d8653; }
.swatch-location { background: #c65d07; }
.swatch-theme { background: #c2255c; }
.swatch-plot { background: #6741d9; }
.swatch-conflict { background: #e03131; }
.swatch-custom { background: #5c5f66; }
.swatch-blue { background: #4c6ef5; }
.swatch-teal { background: #12b886; }
.swatch-orange { background: #fd7e14; }
.swatch-red { background: #f03e3e; }
.swatch-violet { background: #ae3ec9; }
.swatch-yellow { background: #fab005; }



/* Color picker panel form elements */
#color-picker-panel select {
  width: 100%;
  padding: 10px;
  border-radius: 6px;
  background: #2a2a2a;
  color: #f5f5f5;
  border: 1px solid #444;
  transition: border-color 0.2s ease;
}

#color-picker-panel select:hover {
  border-color: #4c6ef5;
}

#color-picker-panel select:focus {
  outline: none;
  border-color: #4c6ef5;
}

.color-picker-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

#color-picker-panel button {
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

#color-picker-panel button:hover {
  transform: translateY(-1px);
}

#color-picker-panel .cancel-btn {
  background: #666;
  color: white;
}

#color-picker-panel .cancel-btn:hover {
  background: #777;
}

#color-picker-panel .save-btn {
  background: #4c6ef5;
  color: white;
}

#color-picker-panel .save-btn:hover {
  background: #5c7cfa;
}

.tag-suggestion {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s ease;
  color: #f5f5f5;
}

.tag-suggestion:hover {
  background: #3a3a3a;
}

.tag-suggestion.highlighted {
  background: #1a365d;
}

.suggestion-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

@keyframes tagFadeIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Note tags display on cards */
.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.note-tag {
  background: #4c6ef5;
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.note-tag.character { background: #2d8653; }
.note-tag.location { background: #c65d07; }
.note-tag.theme { background: #c2255c; }
.note-tag.plot { background: #6741d9; }
.note-tag.conflict { background: #e03131; }
.note-tag.custom { background: #5c5f66; }

/* Custom color override for note-tag elements */
.note-tag.custom-color {
  background: var(--custom-bg-color) !important;
  border-color: var(--custom-border-color) !important;
}

/* Auto-zoom loading overlay */
.zoom-loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(44, 44, 44, 0.95);
  border: 1px solid #4c6ef5;
  border-radius: 8px;
  padding: 16px 24px;
  color: #f5f5f5;
  font-size: 14px;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 12px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: zoomLoadingFadeIn 0.3s ease;
}

.zoom-loading .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #4c6ef5;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes zoomLoadingFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Reference System Styling */
/* Reference panel styles moved to modal system */

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  border-bottom: 1px solid #333;
  padding-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.2em;
  color: #f5f5f5;
}

#reference-description {
  width: 100%;
  min-height: 100px;
  margin: 10px 0;
  padding: 12px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 8px;
  color: #f5f5f5;
  resize: vertical;
  font-size: 1rem;
}

#reference-tags {
  width: 100%;
  padding: 10px;
  margin: 10px 0;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 8px;
  color: #f5f5f5;
  font-size: 0.9rem;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 15px;
}

.panel-actions button {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.panel-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#delete-reference {
  background-color: #dc3545;
}

#save-reference {
  background-color: #4c6ef5;
}

.floating-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 24px;
  background-color: #4c6ef5;
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  font-size: 1rem;
  transition: transform 0.2s ease;
}

.floating-btn:hover {
  transform: translateY(-2px);
}

#reference-list {
  max-height: 400px;
  overflow-y: auto;
  margin: 20px 0;
  padding: 0;
  background: #1f1f1f;
  border-radius: 12px;
  border: 1px solid #3a3a3a;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#reference-list::-webkit-scrollbar {
  width: 8px;
}

#reference-list::-webkit-scrollbar-track {
  background: #2a2a2a;
  border-radius: 4px;
}

#reference-list::-webkit-scrollbar-thumb {
  background: #4c6ef5;
  border-radius: 4px;
}

#reference-list::-webkit-scrollbar-thumb:hover {
  background: #5c7ef5;
}

.reference-item {
  padding: 15px;
  border-bottom: 1px solid #333;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.reference-item:hover {
  background: #2a2a2a;
}

.reference-name {
  font-weight: 600;
  color: #f5f5f5;
  margin-bottom: 4px;
}

.reference-tags {
  font-size: 0.85em;
  color: #888;
}

.search-box {
  margin: 20px 0;
}

#reference-search {
  width: 100%;
  padding: 12px;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 8px;
  color: #f5f5f5;
  font-size: 14px;
  transition: border-color 0.2s ease;
}

#reference-search:focus {
  outline: none;
  border-color: #4c6ef5;
}

#reference-search::placeholder {
  color: #888;
}

.add-btn {
  width: 100%;
  padding: 12px;
  background: #4c6ef5;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  margin-top: 15px;
  transition: background-color 0.2s ease;
}

.add-btn:hover {
  background: #4263eb;
}

/* Reference text styling in notes */
.reference {
  color: #4c6ef5;
  text-decoration: none;
  cursor: pointer;
  background: rgba(76, 110, 245, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  border-bottom: 1px dotted #4c6ef5;
  position: relative;
}

.reference:hover {
  background: rgba(76, 110, 245, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(76, 110, 245, 0.2);
}

/* Additional styling for edit mode references */
.reference.editable {
  background: rgba(76, 110, 245, 0.2);
  border: 1px solid rgba(76, 110, 245, 0.5);
  font-weight: 500;
  margin: 0 1px;
  box-shadow: 0 1px 3px rgba(76, 110, 245, 0.2);
}

.reference.editable:hover {
  background: rgba(76, 110, 245, 0.3);
  box-shadow: 0 2px 6px rgba(76, 110, 245, 0.3);
}

/* Add a small icon indicator for references */
.reference::after {
  content: '🔗';
  font-size: 0.7em;
  vertical-align: super;
  margin-left: 2px;
  opacity: 0.7;
}

/* Add pulsing highlight effect when references are first processed */
@keyframes pulse-highlight {
  0% { box-shadow: 0 0 0 rgba(76, 110, 245, 0); }
  50% { box-shadow: 0 0 10px rgba(76, 110, 245, 0.5); }
  100% { box-shadow: 0 0 0 rgba(76, 110, 245, 0); }
}

.reference.newly-detected {
  animation: pulse-highlight 1s ease-in-out;
}

/* Close buttons */
#close-reference-panel,
#close-reference-list {
  background: none;
  border: none;
  color: #888;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease;
}

#close-reference-panel:hover,
#close-reference-list:hover,
#close-reference-selection:hover {
  color: #f5f5f5;
}

/* Reference Selection Panel */
#reference-selection-panel {
  display: none;
  position: fixed;
  background: #1f1f1f;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 15000;
  width: 280px;
  border: 1px solid #4c6ef5;
  animation: modalIn 0.3s ease;
  pointer-events: auto;
}

#reference-selection-panel.open {
  display: block;
}

#reference-selection-panel .panel-header {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #333;
}

#reference-selection-panel p {
  margin: 10px 0;
  color: #e0e0e0;
  font-size: 0.9rem;
}

#selected-text {
  font-weight: bold;
  color: #4c6ef5;
  word-break: break-word;
  background: rgba(76, 110, 245, 0.1);
  padding: 2px 5px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 5px;
}

#reference-selection-panel .panel-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

#reference-selection-panel .panel-actions button {
  flex: 1;
  padding: 10px 15px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-weight: 500;
  color: white;
}

#create-new-reference {
  background: #4c6ef5;
}

#reference-selection-panel .panel-actions button:hover {
  background: #4263eb;
}

#close-reference-selection {
  background: none;
  border: none;
  color: #888;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease;
}

/* Reference Creation Panel */
#reference-creation-panel {
  width: 600px;
  max-width: 90vw;
}

#reference-creation-panel .modal-content {
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border: 1px solid #4c6ef5;
  border-radius: 12px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(76, 110, 245, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#reference-creation-panel .modal-header {
  background: rgba(76, 110, 245, 0.1);
  border-bottom: 1px solid #4c6ef5;
  padding: 20px 24px;
}

#reference-creation-panel .modal-header h2 {
  color: #f5f5f5;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

#reference-creation-panel .modal-body {
  padding: 24px;
}

#reference-creation-panel .form-group {
  margin-bottom: 20px;
}

#reference-creation-panel .form-group label {
  display: block;
  color: #e0e0e0;
  font-size: 0.9rem;
  margin-bottom: 8px;
  font-weight: 500;
}

#reference-creation-panel #reference-name-input {
  width: 100%;
  padding: 12px 16px;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  color: #f5f5f5;
  font-size: 16px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

#reference-creation-panel #reference-name-input:focus {
  outline: none;
  border-color: #4c6ef5;
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.1);
  background: #232323;
}

#reference-creation-panel #reference-name-input::placeholder {
  color: #888;
}

#reference-creation-panel .modal-actions {
  border-top: 1px solid #333;
  margin-top: 20px;
  padding-top: 20px;
}

#reference-creation-panel .btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px;
}

#reference-creation-panel .btn.primary {
  background: linear-gradient(135deg, #4c6ef5, #364fc7);
  color: white;
  box-shadow: 0 2px 8px rgba(76, 110, 245, 0.3);
}

#reference-creation-panel .btn.primary:hover {
  background: linear-gradient(135deg, #364fc7, #3b4cc9);
  box-shadow: 0 4px 12px rgba(76, 110, 245, 0.4);
  transform: translateY(-1px);
}

#reference-creation-panel .btn.secondary {
  background: #444;
  color: #e0e0e0;
  border: 1px solid #555;
}

#reference-creation-panel .btn.secondary:hover {
  background: #555;
  border-color: #666;
  transform: translateY(-1px);
}

#reference-creation-panel #close-reference-creation {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

#reference-creation-panel #close-reference-creation:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f5;
}

/* Enhanced Panel Styling for All Panels */
#details-panel {
  width: 600px;
  max-width: 90vw;
}

#details-panel .modal-content {
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border: 1px solid #4c6ef5;
  border-radius: 12px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(76, 110, 245, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#details-panel .modal-header {
  background: rgba(76, 110, 245, 0.1);
  border-bottom: 1px solid #4c6ef5;
  padding: 20px 24px;
}

#details-panel .modal-header h2 {
  color: #f5f5f5;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

#details-panel .modal-body {
  padding: 24px;
}

#details-panel .form-group {
  margin-bottom: 20px;
}

#details-panel .form-group label {
  display: block;
  color: #e0e0e0;
  font-size: 0.9rem;
  margin-bottom: 8px;
  font-weight: 500;
}

#details-panel input,
#details-panel textarea {
  width: 100%;
  padding: 12px 16px;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  color: #f5f5f5;
  font-size: 16px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

#details-panel input:focus,
#details-panel textarea:focus {
  outline: none;
  border-color: #4c6ef5;
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.1);
  background: #232323;
}

#details-panel input::placeholder,
#details-panel textarea::placeholder {
  color: #888;
}

#details-panel #close-panel {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

#details-panel #close-panel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f5;
}

/* Read Panel Enhanced Styling */
#read-panel {
  width: 700px;
  max-width: 90vw;
}

#read-panel .modal-content {
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border: 1px solid #4c6ef5;
  border-radius: 12px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(76, 110, 245, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#read-panel .modal-header {
  background: rgba(76, 110, 245, 0.1);
  border-bottom: 1px solid #4c6ef5;
  padding: 20px 24px;
}

#read-panel .modal-header h2 {
  color: #f5f5f5;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

#read-panel .modal-body {
  padding: 24px;
}

#read-panel .modal-actions {
  background: rgba(26, 26, 26, 0.9);
  border-top: 1px solid #333;
  padding: 16px 24px;
  border-radius: 0 0 12px 12px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

#read-panel .btn {
  padding: 10px 20px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#read-panel .btn-primary {
  background: linear-gradient(135deg, #4c6ef5, #3b5bdb);
  color: white;
  box-shadow: 0 2px 8px rgba(76, 110, 245, 0.3);
}

#read-panel .btn-primary:hover {
  background: linear-gradient(135deg, #5c7cff, #4c6ef5);
  box-shadow: 0 4px 12px rgba(76, 110, 245, 0.4);
  transform: translateY(-1px);
}

#read-panel .btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #e0e0e0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

#read-panel .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #f5f5f5;
}

#read-panel .btn-danger {
  background: linear-gradient(135deg, #e03131, #c92a2a);
  color: white;
  box-shadow: 0 2px 8px rgba(224, 49, 49, 0.3);
}

#read-panel .btn-danger:hover {
  background: linear-gradient(135deg, #f03e3e, #e03131);
  box-shadow: 0 4px 12px rgba(224, 49, 49, 0.4);
  transform: translateY(-1px);
}

#read-panel #close-panel {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

#read-panel #close-panel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f5;
}

/* Read panel button alignment for minimized view */
#read-panel:not(.fullscreen) .modal-header button,
#read-panel:not(.fullscreen) .modal-header .fullscreen-toggle {
  background: none !important;
  border: none !important;
  color: #999 !important;
  font-size: 18px !important;
  width: 32px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#read-panel:not(.fullscreen) .modal-header button:hover,
#read-panel:not(.fullscreen) .modal-header .fullscreen-toggle:hover {
  background: #3a3a3a !important;
  border: none !important;
  color: #f5f5f5 !important;
}

/* Import Panel Enhanced Styling */
#import-panel {
  width: 600px;
  max-width: 90vw;
}

#import-panel .modal-content {
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border: 1px solid #4c6ef5;
  border-radius: 12px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(76, 110, 245, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#import-panel .modal-header {
  background: rgba(76, 110, 245, 0.1);
  border-bottom: 1px solid #4c6ef5;
  padding: 20px 24px;
}

#import-panel .modal-header h2 {
  color: #f5f5f5;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

#import-panel .modal-body {
  padding: 24px;
}

#import-panel .form-group {
  margin-bottom: 20px;
}

#import-panel .form-group label {
  display: block;
  color: #e0e0e0;
  font-size: 0.9rem;
  margin-bottom: 8px;
  font-weight: 500;
}

#import-panel input[type="file"] {
  width: 100%;
  padding: 12px 16px;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  color: #f5f5f5;
  font-size: 16px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

#import-panel input[type="file"]:focus {
  outline: none;
  border-color: #4c6ef5;
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.1);
  background: #232323;
}

#import-panel .modal-actions {
  background: rgba(26, 26, 26, 0.9);
  border-top: 1px solid #333;
  padding: 16px 24px;
  border-radius: 0 0 12px 12px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

#import-panel .btn {
  padding: 10px 20px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#import-panel .btn-primary {
  background: linear-gradient(135deg, #4c6ef5, #3b5bdb);
  color: white;
  box-shadow: 0 2px 8px rgba(76, 110, 245, 0.3);
}

#import-panel .btn-primary:hover {
  background: linear-gradient(135deg, #5c7cff, #4c6ef5);
  box-shadow: 0 4px 12px rgba(76, 110, 245, 0.4);
  transform: translateY(-1px);
}

#import-panel .btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #e0e0e0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

#import-panel .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #f5f5f5;
}

#import-panel #close-import {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

#import-panel #close-import:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f5;
}

/* Color Picker Panel Enhanced Styling */
#color-picker-panel {
  width: 450px;
  max-width: 90vw;
}

#color-picker-panel .modal-content {
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border: 1px solid #4c6ef5;
  border-radius: 12px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(76, 110, 245, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

#color-picker-panel .modal-header {
  background: rgba(76, 110, 245, 0.1);
  border-bottom: 1px solid #4c6ef5;
  padding: 20px 24px;
}

#color-picker-panel .modal-header h2 {
  color: #f5f5f5;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

#color-picker-panel .modal-body {
  padding: 24px;
}

#color-picker-panel .color-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

#color-picker-panel .color-option {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 2px solid #444;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

#color-picker-panel .color-option:hover {
  border-color: #4c6ef5;
  transform: scale(1.1);
}

#color-picker-panel .color-option.selected {
  border-color: #4c6ef5;
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.3);
}

#color-picker-panel .custom-color-input {
  width: 100%;
  padding: 12px 16px;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  color: #f5f5f5;
  font-size: 16px;
  transition: all 0.2s ease;
  box-sizing: border-box;
  margin-top: 16px;
}

#color-picker-panel .custom-color-input:focus {
  outline: none;
  border-color: #4c6ef5;
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.1);
  background: #232323;
}

#color-picker-panel .modal-actions {
  background: rgba(26, 26, 26, 0.9);
  border-top: 1px solid #333;
  padding: 16px 24px;
  border-radius: 0 0 12px 12px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

#color-picker-panel .btn {
  padding: 10px 20px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#color-picker-panel .btn-primary {
  background: linear-gradient(135deg, #4c6ef5, #3b5bdb);
  color: white;
  box-shadow: 0 2px 8px rgba(76, 110, 245, 0.3);
}

#color-picker-panel .btn-primary:hover {
  background: linear-gradient(135deg, #5c7cff, #4c6ef5);
  box-shadow: 0 4px 12px rgba(76, 110, 245, 0.4);
  transform: translateY(-1px);
}

#color-picker-panel .btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #e0e0e0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

#color-picker-panel .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #f5f5f5;
}

#color-picker-panel #close-color-picker {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

#color-picker-panel #close-color-picker:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f5;
}

/* Fullscreen Panel Mode */
.modal.fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 25000 !important;
  transform: none !important;
  max-width: none !important;
  max-height: none !important;
}

.modal.fullscreen .modal-content {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  display: flex;
  flex-direction: column;
}

.modal.fullscreen .modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #4c6ef5;
}

.modal.fullscreen .modal-header h2 {
  flex: 1;
  margin: 0;
  font-size: 1.4rem;
}

.modal.fullscreen .modal-header .panel-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  margin-right: 16px;
}

.modal.fullscreen .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Normal panel layout - single column */
.modal:not(.enhanced-editing) .modal-body {
  padding: 24px;
}

.modal:not(.enhanced-editing) .main-content {
  display: block;
}

.modal:not(.enhanced-editing) .sidebar-content {
  display: block;
  border-left: none;
  padding-left: 0;
  margin-top: 16px;
}

/* Hide enhanced toggle unless in fullscreen */
.enhanced-toggle {
  display: none;
}

.modal.fullscreen .enhanced-toggle {
  display: flex;
}

.modal.fullscreen textarea {
  min-height: 200px;
  resize: vertical;
}

.modal.fullscreen .panel-actions {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid #333;
}

/* Enhanced Plot Point Editing - Only in fullscreen mode */
.modal.fullscreen.enhanced-editing .modal-body {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  height: 100%;
}

.modal.fullscreen.enhanced-editing .main-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.modal.fullscreen.enhanced-editing .sidebar-content {
  border-left: 1px solid #333;
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal.fullscreen.enhanced-editing textarea {
  flex: 1;
  min-height: 300px;
  resize: none;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  font-size: 15px;
  padding: 20px;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  color: #f5f5f5;
  transition: all 0.2s ease;
}

.modal.fullscreen.enhanced-editing textarea:focus {
  border-color: #4c6ef5;
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.1);
  background: #232323;
}

.modal.fullscreen.enhanced-editing .form-group.title-group input {
  font-size: 1.3rem;
  font-weight: 600;
  padding: 16px 20px;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  color: #f5f5f5;
  transition: all 0.2s ease;
}

.modal.fullscreen.enhanced-editing .form-group.title-group input:focus {
  border-color: #4c6ef5;
  box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.1);
  background: #232323;
}

.modal.fullscreen.enhanced-editing .form-group.description-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.modal.fullscreen.enhanced-editing .form-group.description-group textarea {
  flex: 1;
}

.modal.fullscreen.enhanced-editing .form-group label {
  color: #e0e0e0;
  font-size: 0.95rem;
  margin-bottom: 8px;
  font-weight: 500;
}

/* Writing assistance features - only in fullscreen enhanced mode */
.modal.fullscreen.enhanced-editing .writing-stats {
  background: rgba(76, 110, 245, 0.05);
  border: 1px solid rgba(76, 110, 245, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.85rem;
  color: #ccc;
}

.modal.fullscreen.enhanced-editing .writing-stats .stat {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.modal.fullscreen.enhanced-editing .writing-stats .stat:last-child {
  margin-bottom: 0;
}

/* Enhanced tags in sidebar - only in fullscreen enhanced mode */
.modal.fullscreen.enhanced-editing .tags-container {
  background: rgba(26, 26, 26, 0.8);
  border: 1px solid #333;
  border-radius: 8px;
  padding: 16px;
}

.modal.fullscreen.enhanced-editing .tags-display {
  min-height: 60px;
  margin-bottom: 12px;
  padding: 8px;
  border: 1px dashed #444;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}

/* Panel action buttons in enhanced mode - only in fullscreen enhanced mode */
.modal.fullscreen.enhanced-editing .panel-actions {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid #333;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal.fullscreen.enhanced-editing .panel-actions .btn {
  padding: 12px 16px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.modal.fullscreen.enhanced-editing .delete-btn {
  background: linear-gradient(135deg, #e03131, #c92a2a);
  color: white;
  box-shadow: 0 2px 8px rgba(224, 49, 49, 0.3);
}

.modal.fullscreen.enhanced-editing .delete-btn:hover {
  background: linear-gradient(135deg, #f03e3e, #e03131);
  box-shadow: 0 4px 12px rgba(224, 49, 49, 0.4);
  transform: translateY(-1px);
}

/* Fullscreen toggle button */
.fullscreen-toggle {
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.fullscreen-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f5;
}

.fullscreen-toggle.active {
  color: #4c6ef5;
  background: rgba(76, 110, 245, 0.1);
}

/* Enhanced mode toggle button */
.enhanced-toggle {
  background: none;
  border: none;
  color: #888;
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.enhanced-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f5;
}

.enhanced-toggle.active {
  color: #4c6ef5;
  background: rgba(76, 110, 245, 0.1);
}

/* Mobile fullscreen adjustments */
@media (max-width: 768px) {
  .modal.fullscreen.enhanced-editing .modal-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  
  .modal.fullscreen.enhanced-editing .sidebar-content {
    border-left: none;
    border-top: 1px solid #333;
    padding-left: 0;
    padding-top: 24px;
  }
}

/* Read Panel Fullscreen Mode */
#read-panel.fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 25000 !important;
  transform: none !important;
  max-width: none !important;
  max-height: none !important;
}

#read-panel.fullscreen .modal-content {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
  display: flex;
  flex-direction: column;
}

#read-panel.fullscreen .modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #4c6ef5;
}

#read-panel.fullscreen .modal-header h2 {
  flex: 1;
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
}

#read-panel.fullscreen .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  line-height: 1.8;
  font-size: 16px;
}

#read-panel.fullscreen #read-panel-content {
  max-width: 800px;
  margin: 0;
  text-align: left;
}

/* BBCode Styling */
.bbcode-bold {
  font-weight: bold;
}

.bbcode-italic {
  font-style: italic;
}

.bbcode-underline {
  text-decoration: underline;
}

.bbcode-strikethrough {
  text-decoration: line-through;
}

.bbcode-color {
  /* Color will be set via inline styles */
}

.bbcode-size {
  /* Font size will be set via inline styles */
}

.bbcode-center {
  text-align: center;
  display: block;
}

.bbcode-quote {
  background: rgba(76, 110, 245, 0.1);
  border-left: 4px solid #4c6ef5;
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 0 8px 8px 0;
  font-style: italic;
}

.bbcode-code {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 2px 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: #f5f5f5;
}

.bbcode-code-block {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: #f5f5f5;
  white-space: pre-wrap;
  overflow-x: auto;
}

.bbcode-url {
  color: #4c6ef5;
  text-decoration: underline;
  cursor: pointer;
}

.bbcode-url:hover {
  color: #5c7cff;
}

.bbcode-list {
  margin: 16px 0;
  padding-left: 0;
}

.bbcode-list-item {
  margin: 8px 0 8px 24px;
  list-style-type: disc;
  display: list-item;
}

.bbcode-spoiler {
  background: #333;
  color: #333;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.bbcode-spoiler:hover,
.bbcode-spoiler.revealed {
  background: rgba(76, 110, 245, 0.1);
  color: #f5f5f5;
}

/* Tag styling */
.reference-tags-display {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.tag {
  background: #2a2a2a;
  color: #4c6ef5;
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 1rem;
  border: 1px solid #4c6ef5;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

#reference-description[readonly] {
  background: #2a2a2a;
  cursor: default;
  resize: none;
  border: 1px solid #333;
}

/* Import Panel Styles */
#import-panel .modal-content {
  width: 400px;
  min-height: 250px;
  background: #1a1a1a;
  border: 1px solid #333;
}

#import-panel .modal-header {
  background: #1a1a1a;
  padding: 1rem;
  border-bottom: 1px solid #333;
}

#import-panel .modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

#import-panel .modal-body {
  padding: 1.5rem;
}

#import-panel .modal-body h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.recent-plots {
  margin: 0.5rem 0 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recent-plot-item {
  background: #242424;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 65px;
}

.recent-plot-item:hover {
  border-color: #6b46c1;
  background: #2a2a2a;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.recent-plot-info {
  flex-grow: 1;
}

.plot-title {
  font-weight: 500;
  color: #f5f5f5;
  margin-bottom: 0.4rem;
  font-size: 1rem;
}

.plot-date {
  font-size: 0.8rem;
  color: #888;
  font-weight: 400;
}

.panel-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #333;
}

.panel-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.file-operations {
  padding: 1rem 0;
}

.file-ops-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.action-btn {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.9rem;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.action-btn .icon {
  font-size: 1.1rem;
}

.action-btn.export-btn {
  background: #6b46c1;
}

.action-btn.import-btn {
  background: #4c6ef5;
}

.action-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.auto-save-info {
  margin-top: 1rem;
}

.auto-save-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #888;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  padding: 4px 8px;
  border-radius: 4px;
}

.auto-save-status .icon {
  font-size: 1rem;
}

.auto-save-status.saving {
  color: #4c6ef5;
  background-color: rgba(76, 110, 245, 0.1);
  animation: pulse 1.5s infinite;
}

.auto-save-status.saved {
  color: #2ecc71;
  background-color: rgba(46, 204, 113, 0.1);
  animation: flash 0.5s ease-out;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes flash {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

#manual-import-btn:hover {
  background: #805ad5;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(107, 70, 193, 0.2);
}

#import-panel #close-import-panel {
  color: #888;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.2rem;
  transition: color 0.2s ease;
}

#import-panel #close-import-panel:hover {
  color: #f5f5f5;
}

.recent-plot-item .load-icon {
  color: #6b46c1;
  font-size: 1.1rem;
  opacity: 0;
  transition: all 0.2s ease;
  margin-left: 0.5rem;
}

.recent-plot-item:hover .load-icon {
  opacity: 1;
  transform: translateX(2px);
}

.plot-group {
  margin-bottom: 1rem;
  border-radius: 6px;
  overflow: hidden;
}

.versions-dropdown {
  margin-top: 2px;
}

.versions-toggle {
  background: #2a2a2a;
  border: none;
  color: #888;
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.2s ease;
}

.versions-toggle:hover {
  background: #333;
  color: #f5f5f5;
}

.versions-content {
  display: none;
  margin-top: 2px;
}

.versions-content.show {
  display: block;
}

.version-item {
  background: #242424;
  padding: 0.6rem 1rem;
  min-height: 50px;
}

.version-item .plot-title {
  font-size: 0.8rem;
  color: #888;
}

/* Loading indicator for auto-zoom */
.zoom-loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(31, 31, 31, 0.95);
  color: #4c6ef5;
  padding: 20px 30px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 14px;
  font-weight: 500;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #333;
  border-top: 2px solid #4c6ef5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.version-item .plot-date {
  color: #666;
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
  /* Header adjustments */
  header {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    height: auto;
    min-height: 60px;
  }
  
  .header-left {
    align-items: center;
    width: 100%;
  }
  
  .header-center {
    order: -1;
  }
  
  .header-controls {
    justify-content: center;
    flex-direction: row;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .header-left {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
  
  .brand-container {
    gap: 0.75rem;
  }
  
  .brand-logo-main {
    height: 64px;
  }
  
  .brand-text-logo {
    height: 24px;
  }
  
  .header-left h1 {
    font-size: 1.3rem;
    margin: 0;
  }
  
  .story-title-input {
    font-size: 14px;
    padding: 6px 10px;
    max-width: 250px;
  }
  
  .header-controls button {
    font-size: 12px;
    padding: 8px 12px;
    min-width: 80px;
  }
  
  /* Board adjustments */
  #board {
    height: calc(100vh - 80px);
    touch-action: pan-x pan-y;
  }
  
  /* Notes - larger and more touch-friendly */
  .note {
    min-width: 180px;
    min-height: 120px;
    font-size: 14px;
  }
  
  .note-title {
    font-size: 14px;
    padding: 8px;
  }
  
  .note-details {
    font-size: 12px;
    padding: 8px;
  }
  
  /* Connectors - larger touch targets */
  .connector, .left-connector {
    width: 20px;
    height: 20px;
    border-radius: 10px;
  }
  
  .connector {
    right: -10px;
    bottom: -10px;
  }
  
  .left-connector {
    left: -10px;
    top: -10px;
  }
  
  /* Resize handle - larger for touch */
  .resize-handle {
    width: 20px !important;
    height: 20px !important;
    bottom: -2px !important;
    right: -2px !important;
  }
  
  /* Settings panel - mobile friendly */
  #settings-panel {
    bottom: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    padding: 12px;
    border-radius: 8px;
  }
  
  .settings-group {
    justify-content: space-between;
    margin-bottom: 12px;
  }
  
  /* Modals - full screen on mobile */
  .modal-content {
    width: 95%;
    max-width: none;
    height: 90vh;
    max-height: 90vh;
    margin: auto;
    border-radius: 8px;
  }
  
  .modal-header {
    padding: 15px;
    border-bottom: 1px solid #333;
  }
  
  .modal-header h2 {
    font-size: 1.2rem;
  }
  
  .modal-body {
    padding: 15px;
    overflow-y: auto;
  }
  
  /* Form elements - touch friendly */
  .modal-body input,
  .modal-body textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px;
    border-radius: 6px;
  }
  
  .modal-body textarea {
    min-height: 120px;
  }
  
  /* Tags - larger for touch */
  .tag-chip, .tag {
    font-size: 12px;
    padding: 6px 10px;
    margin: 2px;
    border-radius: 12px;
  }
  
  .tag-input {
    font-size: 14px;
    padding: 8px 12px;
  }
  
  /* Reference panel adjustments */
  .reference-item {
    padding: 12px;
    margin-bottom: 8px;
  }
  
  .reference-name {
    font-size: 14px;
  }
  
  .reference-description {
    font-size: 12px;
  }
  
  /* Context menus - touch friendly */
  .context-menu {
    min-width: 180px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  }
  
  .context-menu-item {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  /* Library panel */
  .file-ops-buttons {
    flex-direction: column;
    gap: 10px;
  }
  
  .action-btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
  }
  
  /* Hide resize capability on very small screens */
  .modal-content {
    resize: none;
  }
  
  /* Zoom controls - if they exist */
  .zoom-controls {
    bottom: 80px;
    right: 10px;
    left: auto;
  }
  
  /* Selection box adjustments */
  .selection-box {
    border-width: 2px;
  }
}

/* Extra small screens */
@media screen and (max-width: 480px) {
  .brand-logo-main {
    height: 56px;
  }
  
  .brand-text-logo {
    height: 20px;
  }
  
  .header-left h1 {
    font-size: 1.1rem;
  }
  
  .story-title-input {
    max-width: 200px;
    font-size: 12px;
  }
  
  .header-controls button {
    font-size: 11px;
    padding: 6px 10px;
    min-width: 70px;
  }
  
  .note {
    min-width: 150px;
    min-height: 100px;
    font-size: 12px;
  }
  
  .note-title {
    font-size: 12px;
  }
  
  .note-details {
    font-size: 11px;
  }
  
  .modal-content {
    width: 98%;
    height: 95vh;
  }
  
  .modal-header {
    padding: 12px;
  }
  
  .modal-body {
    padding: 12px;
  }
  
  .modal-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }
  
  .modal-actions .btn {
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
  }
  
  .tag-chip, .tag {
    font-size: 11px;
    padding: 4px 8px;
  }
}

/* Landscape orientation adjustments */
@media screen and (max-width: 768px) and (orientation: landscape) {
  header {
    flex-direction: row;
    height: 50px;
    min-height: 50px;
  }
  
  .header-left {
    flex-direction: row;
    align-items: center;
  }
  
  .header-left h1 {
    font-size: 1.1rem;
  }
  
  .story-title-input {
    max-width: 150px;
    font-size: 12px;
  }
  
  #board {
    height: calc(100vh - 60px);
  }
  
  .modal-content {
    height: 85vh;
  }
}

/* Mobile device specific styles */
.mobile-device {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-device #board {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.mobile-device .note {
  touch-action: none;
}

.mobile-device .connector,
.mobile-device .left-connector {
  touch-action: none;
}

.mobile-device .resize-handle {
  touch-action: none;
}

/* Prevent text selection on mobile while allowing input fields */
.mobile-device * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.mobile-device input,
.mobile-device textarea {
  -webkit-user-select: text;
  user-select: text;
}

/* Mobile floating action button */
.mobile-fab {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: #4c6ef5;
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(76, 110, 245, 0.4);
  z-index: 1000;
  cursor: pointer;
  transition: all 0.3s ease;
}

.mobile-device .mobile-fab {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-fab:hover,
.mobile-fab:active {
  background: #3b5bdb;
  transform: scale(1.1);
}

.mobile-fab:active {
  transform: scale(0.95);
}

/* Mobile responsive improvements for modals */
@media screen and (max-width: 768px) {
  /* Make close buttons larger for touch */
  .modal-header button {
    min-width: 44px;
    min-height: 44px;
    font-size: 18px;
  }
  
  /* Better spacing for form elements */
  .form-group {
    margin-bottom: 20px;
  }
  
  .form-group label {
    font-size: 14px;
    margin-bottom: 8px;
    display: block;
  }
  
  /* Panel actions - stack vertically on mobile */
  .panel-actions {
    flex-direction: column;
    gap: 10px;
  }
  
  .panel-actions button {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    min-height: 44px;
  }
  
  /* Tags container - mobile friendly */
  .tags-container {
    padding: 10px;
  }
  
  .tags-display {
    min-height: 40px;
    margin-bottom: 10px;
  }
  
  /* Reference panel mobile improvements */
  .reference-list {
    max-height: 50vh;
  }
  
  .reference-item {
    border-radius: 8px;
    margin-bottom: 10px;
  }
  
  /* Auto-save status - adjust for mobile */
  .auto-save-info {
    text-align: center;
    padding: 10px;
  }
  
  /* File operation buttons */
  .file-ops-buttons {
    gap: 12px;
  }
  
  /* Hide regular add button on mobile when FAB is shown */
  .mobile-device #add-note {
    display: none;
  }
}

