@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@400;700&display=swap');


:root {
    --bg-color: #0d1117;
    --primary-text: #c9d1d9;
    --secondary-text: #8b949e;
    --border-color: #30363d;
    --accent-color: #476b94;
    --hover-bg: #161b22;
    --timeline-bg: #1f242c;
    --timeline-slot: #30363d;
    --cursor-color: #f0f6fc;
    --modal-bg: #161b22;
    --input-bg: #010409;
    --font-family: 'VT323', monospace;
    --danger-color: #b63a38;
}

body {
    background-color: var(--bg-color);
    color: var(--primary-text);
    font-family: var(--font-family);
    font-size: 18px;
    margin: 0;
    overflow-x: hidden;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

header h1 {
    color: var(--accent-color);
    margin: 0;
    font-size: 2.5em;
    text-shadow: 0 0 5px var(--accent-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

.day-selector, .view-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.day-selector button, .view-selector button {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    padding: 5px 10px;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 1em;
}

.day-selector button.active, .view-selector button.active,
.day-selector button:hover, .view-selector button:hover {
    background-color: var(--accent-color);
    color: var(--bg-color);
    border-color: var(--accent-color);
}

.header-right {
    display: flex;
    gap: 10px;
}

.header-right button {
    background: none;
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 5px;
}
.header-right button:hover {
    border-color: var(--accent-color);
}
.header-right button img {
    width: 24px;
    height: 24px;
    display: block;
}
#map-container {
  flex: 0 0 auto; /* Do not grow or shrink */
  position: relative;
  max-width: 700px; /* Keep the max-width you had */
  margin-left: 20px; /* Add a small gap to the left */
  border: 0px solid var(--border-color);
}

#map-image {
    width: 100%;
    display: block;
}

#map-icons {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.map-icon {
    position: absolute;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    z-index: 10;
    background-size: contain;
    background-repeat: no-repeat;
    filter: drop-shadow(0 0 3px black);
    pointer-events: auto;
}


#timeline-container {
    margin-top: 20px;
    background-color: var(--timeline-bg);
    border: 1px solid var(--border-color);
    padding: 10px;
    user-select: none;
}

/* apply the same look & feel to every cloned ruler */
#timeline-ruler,

.cloned-timeline-ruler {
    position: relative;
    height: 20px;
    background: linear-gradient(to right, var(--timeline-slot) 1px, transparent 1px);
    background-size: calc(100% / 96) 100%;
    cursor: pointer;
    margin-top: 5px;
}




#cursor-time-display {
    position: absolute;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--modal-bg);
    color: var(--cursor-color);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.85em;
    white-space: nowrap;
    border: 1px solid var(--border-color);
}

#content-area {
    margin-top: 20px;
}

.view-content {
    display: none;
}
.view-content.active {
    display: block;
}

.controls-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: var(--hover-bg);
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.controls-bar button, .toggle-all-container button {
    background: var(--timeline-slot);
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    padding: 8px 15px;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.controls-bar button:hover, .toggle-all-container button:hover {
    border-color: var(--accent-color);
}
.controls-bar button img {
    width: 16px;
    height: 16px;
}

#cards-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.card-category {
    border: 1px solid var(--border-color);
    background-color: var(--hover-bg);
}

.card-category.collapsed .card-list {
    display: none;
}

.card-category-title {
    padding: 8px 12px;
    background-color: var(--timeline-bg);
    border-bottom: 1px solid var(--border-color);
    font-size: 1.2em;
    color: var(--accent-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    
    user-select: none; /* Add this line */
}

.collapse-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--secondary-text);
    cursor: pointer;
    font-family: var(--font-family);
    width: 25px;
    height: 25px;
    font-size: 1.2em;
    line-height: 1;
    padding: 0;
}

.collapse-toggle:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.card-row {
    display: flex;
    align-items: center;
    min-height: 40px;
}
.card-row:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}


.card-info {
    width: 250px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    cursor: grab; /* Add grab cursor for sortable hint */
}
.card-info:active {
    cursor: grabbing;
}

.card-info .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.card-name {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}
.card-name:hover {
    text-decoration: underline;
}

.card-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
}
.card-actions button img {
    width: 16px;
    height: 16px;
    display: block;
}

.card-timeline {
    flex-grow: 1;
    height: 40px;
    position: relative;
    background: linear-gradient(to right, var(--timeline-slot) 1px, transparent 1px);
    background-size: calc(100% / 96) 100%;
      overflow: visible;
}

.timeline-event {
    position: absolute;
    height: 100%;
    cursor: pointer;
    opacity: 0.7;
}

.timeline-event:hover {
    opacity: 1;
    filter: brightness(1.2);
}

.event-tooltip {
    visibility: hidden;
    width: 200px;
    background-color: var(--modal-bg);
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.9em;
    border: 1px solid var(--border-color);
     z-index: 400;   /
}

.timeline-event:hover .event-tooltip {
    visibility: visible;
    opacity: 1;
    z-index: 1100; 
}
.event-tooltip strong {
    color: var(--accent-color);
}

.card-toggle {
    width: 50px;
    padding: 0 10px;
    text-align: center;
}

.card-toggle input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--secondary-text);
    cursor: pointer;
    position: relative;
}
.card-toggle input[type="checkbox"]:checked::before {
    content: '✓';
    font-size: 18px;
    color: rgb(173, 74, 74);
    position: absolute;
    font-weight: bold;
    top: -4px;
    left: 2px;
    border-width: 2px;
}


/* MODALS */
#modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh; /* Changed to 100vh to cover the full screen */
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1100;
}

#timeline-tooltip {
    position: absolute;
    background-color: var(--modal-bg);
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9em;
    pointer-events: none;
    z-index: 300;
    transform: translate(-50%, -120%);
    z-index: 500;      
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--modal-bg);
    border: 2px solid var(--border-color);
    padding: 25px;
    z-index: 201;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
     z-index: 1101; 
}

.modal.hidden, #modal-backdrop.hidden {
    display: none;
}

.modal h2 {
    margin-top: 0;
    color: var(--accent-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.modal form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal label {
    color: var(--secondary-text);
}

.modal input[type="text"],
.modal select,
.modal textarea,
.modal input[type="color"],
.modal input[type="time"],
.modal input[type="number"] {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    padding: 10px;
    font-family: var(--font-family);
    font-size: 1em;
    width: 100%;
    box-sizing: border-box;
}

.modal input[type="color"] {
    padding: 5px; /* Color input has different default padding */
    height: 45px;
}

#card-icon-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.icon-option {
    border: 2px solid transparent;
    padding: 5px;
    cursor: pointer;
    background-color: var(--timeline-slot);
}
.icon-option.selected {
    border-color: var(--accent-color);
}
.icon-option img {
    width: 32px;
    height: 32px;
    display: block;
}

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

.modal-actions button {
    padding: 10px 20px;
    font-family: var(--font-family);
    font-size: 1em;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.modal-actions button[type="submit"], #confirm-yes {
    background-color: var(--accent-color);
    color: rgb(210, 210, 210);
    border-color: var(--accent-color);
}

.modal-actions .cancel-btn, #confirm-no {
    background-color: var(--timeline-slot);
    color: var(--primary-text);
}

.modal-actions .danger-btn {
    background-color: var(--danger-color);
    color: var(--primary-text);
    border-color: var(--danger-color);
}

#event-modal-info {
    background-color: var(--input-bg);
    padding: 10px;
    border: 1px solid var(--border-color);
    margin: 0;
    color: var(--secondary-text);
}

#event-location-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#location-fields-container,
#event-location-card-group,
#event-location-custom-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#event-location-card-group.hidden,
#event-location-custom-group.hidden {
    display: none;
}

.xy-inputs, .time-inputs {
    display: flex;
    gap: 10px;
    align-items: center;
}

.xy-inputs input, .time-inputs input {
    width: 50%;
}

/* Card Editor Modal Specifics */
#card-editor-modal form {
    gap: 0;
}
.modal-column-container {
    display: flex;
    gap: 25px;
    margin-bottom: 20px;
}
.modal-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
#card-fields-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.card-type-fields {
    display: none;
    flex-direction: column;
    gap: 5px;
}
.card-type-fields.active {
    display: flex;
}
#portrait-preview {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    margin-bottom: 5px;
    cursor: pointer;
}
#portrait-preview:hover {
    border-color: var(--accent-color);
}
#phone-number-editor {
    border: 1px solid var(--border-color);
    padding: 5px;
    background-color: var(--input-bg);
}
#phone-number-display {
    min-height: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding-bottom: 5px;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 5px;
}
#phone-number-display img {
    width: 20px;
    height: 20px;
}
#phone-button-palette {
    display: flex;
    gap: 8px;
    align-items: center;
}
#phone-button-palette img {
    width: 20px;
    height: 20px;
    cursor: pointer;
    opacity: 0.7;
}
#phone-button-palette img:hover {
    opacity: 1;
}
#phone-clear-btn {
    font-size: 0.8em;
    padding: 2px 6px;
    margin-left: auto;
    background-color: var(--timeline-slot);
    color: var(--primary-text);
    border: 1px solid var(--border-color);
    cursor: pointer;
}
#route-points-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 150px;
    overflow-y: auto;
    background-color: var(--input-bg);
    padding: 5px;
    border: 1px solid var(--border-color);
}
.route-point-entry {
    display: flex;
    align-items: center;
    gap: 5px;
}
.route-point-entry span {
    width: 20px;
}
.route-point-entry .xy-inputs {
    flex-grow: 1;
}
.route-point-entry button {
    padding: 2px 5px;
    font-size: 0.8em;
    background: var(--danger-color);
    color: var(--primary-text);
    border: none;
    cursor: pointer;
}


/* Portrait Picker Modal */
#portrait-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
}

.portrait-option {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: border-color 0.2s;
}

.portrait-option:hover {
    border-color: var(--accent-color);
}


/* Alternate Views */
#location-view, #subject-view {
    padding: 15px;
}

#location-view label, #subject-view label {
    font-size: 1.2em;
    margin-right: 10px;
}

#location-select, #subject-select {
    width: 300px;
    padding: 8px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    font-family: var(--font-family);
    font-size: 1em;
}

#location-view-content, #subject-view-content {
    margin-top: 20px;
}

.subject-day-view {
    margin-bottom: 20px;
}
.subject-day-view h3 {
    background-color: var(--timeline-bg);
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    margin-bottom: 5px;
}
.subject-day-timeline {
    height: 30px;
    position: relative;
    background: linear-gradient(to right, var(--timeline-slot) 1px, transparent 1px);
    background-size: calc(100% / 96) 100%;
    border: 1px solid var(--border-color);
}

.card-category-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.category-controls button {
  margin-left: 0.5em;
  font-size: 0.8em;
}
/* push each event block above the cursor line */
.timeline-event {
  position: absolute; /* you already have this */
  z-index: 350;       /* above #timeline-tooltip’s 300 */
}

/* push the little pop-over above everything */
.event-tooltip {
  z-index: 360;       /* just a bit higher than its parent */
}
/* Zoom controls styling */

/* ---------- Header text buttons ---------- */
.text-btn {
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
  color: var(--primary-text);
  font-family: var(--font-family);
  font-size: 1em;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 4px;
  /* make it bold:display: inline-flex; */
  
}

.text-btn:hover {
   background: #161d2a; /* lighter accent */
  color: rgb(169, 63, 30);
  border-color: rgb(169, 63, 30);
}

/* Align them neatly */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Per-table control buttons ---------- */
.ctrl-btn {
  background: var(--timeline-slot);
  border: 1px solid var(--border-color);
  color: var(--primary-text);
  font-family: var(--font-family);
  font-size: 0.85em;
  padding: 4px 8px;
  margin-left: 0.5em;
  border-radius: 3px;
  cursor: pointer;
}

.ctrl-btn:hover {
  background: var(--accent-color);
  color: var(--bg-color);
  border-color: var(--accent-color);
}

/* Tighter layout for the controls group */
.category-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.portrait {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 50%;
}
#location-view, #subject-view { display: none !important; }
.card-category-title .title-text {
  display: flex;
  align-items: baseline;
  gap: 1em;
}

.cat-label {
  font-size: 1.2em;
  font-weight: bold;
  color: var(--accent-color);
}
.card-category-title .date-label {
  font-family: 'Dancing Script', cursive !important;
  font-weight: bold;
  font-size: 1em;
  color: white;
}
#color-swatches {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.swatch {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  border-radius: 4px;
  box-sizing: border-box;
  background-color: transparent;
}
.swatch.selected {
  outline: 2px solid var(--accent-color);
}
/* Brighter pastel rainbow */
.swatch[data-color="#f986aa"] { background: #f986aa; } /* pink */
.swatch[data-color="#f85252"] { background: #f85252; } /* coral red */
.swatch[data-color="#f9a047"] { background: #f9a047; } /* bright peach */
.swatch[data-color="#e3e05b"] { background: #e3e05b; } /* neon yellow */
.swatch[data-color="#6ecd53"] { background: #6ecd53; } /* vivid lime */
.swatch[data-color="#2cb16f"] { background: #2cb16f; } /* mint green */
.swatch[data-color="#44c3ea"] { background: #44c3ea; } /* cyan */
.swatch[data-color="#4c28ec"] { background: #4c28ec; } /* light violet */
.swatch[data-color="#9b64ee"] { background: #9b64ee; } /* pink */
.swatch[data-color="#aeaeae"] { background: #aeaeae; } /* lavender */
.swatch[data-color="#7f7f7f"] { background: #7f7f7f; } /* rose */
.swatch[data-color="#1e1e1e"] { background: #1e1e1e; } /* rich tan */
.swatch[data-color="#c4946b"] { background: #c4946b; } /* deep brown */
.swatch[data-color="#a05a2c"] { background: #a05a2c; } /* medium gray */

.timeline-event {
  position: absolute;
  height: 100%;
  cursor: pointer;
  opacity: 0.7;
  /* … */
}

.important-icon {
  position: absolute;
  bottom: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  pointer-events: none; /* click passes through to segment */
}
.card-category-title {
  position: relative;
  display: flex;
  align-items: center;
}
/* Inline day-buttons container: no wrapping */
.inline-day-buttons {
  display: flex;
  flex-wrap: nowrap;
}

/* Each button shares the space, shrinks as needed, and ellipsizes overflow */
.inline-day-buttons button {
  flex: 1 1 0;           /* grow & shrink equally */
  min-width: 0;          /* allow shrinking below its content width */
  padding: 4px 6px;      /* tighter padding */
  font-family: var(--font-family);
  font-weight: bold;
  font-size: 0.9em;      /* slightly smaller so 8 fit easier */
  color: var(--primary-text);
  background: none;
  border: 1px solid var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* Hover + active states */
.inline-day-buttons button:hover,
.inline-day-buttons button.active {
  background-color: rgb(186, 151, 109);
  color: rgb(60, 15, 15);
  border-color: var(--accent-color);
  border-radius: 7px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}
.card-category-title {
  display: flex;
  align-items: center;
  /* Prevent wrapping so everything stays on one line */
  flex-wrap: nowrap;
}

/* Let the title-text stay its intrinsic width */
.card-category-title .title-text {
  flex: 0 0 auto;
}

/* Inline buttons take whatever space is left, but can shrink down to zero */
.inline-day-buttons {
  display: flex;
  flex: 1 1 0;      /* grow & shrink */
  min-width: 0;     /* allow shrinking below content width */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Controls never shrink or wrap */
.category-controls {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

/* Individual buttons inside day-buttons already have flex:1, keep them */
.inline-day-buttons button {
  flex: 1 1 0;
  min-width: 0;
}

/* Ensure your .ctrl-btn stays visible */
.ctrl-btn {
  flex: 0 0 auto;
}


/* Position each label absolutely, centered on its slot */
#timeline-header .timeline-label {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}
/* map + sidebar only */
.map-section {
  display: flex;
  gap: 20px;
  margin-bottom: 20px; /* spacing before timeline */
}

/* keep the sidebar styling you already have */
.sidebar {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: var(--hover-bg);
  border: 1px solid var(--border-color);
}

/* ensure map takes the rest of the row */
#map-container {
  flex: 1;
}

/* below the map-section, timeline & content-area are full width */
#timeline-container,
#content-area {
  width: 100%;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  background: var(--modal-bg);
  color: var(--primary-text);
  border: 1px solid var(--border-color);
  font-size: 1em;
  padding: 8px 12px;
  border-radius: 4px;
  width: 280px;
  text-align: left;
  white-space: pre-wrap; /* This allows for multiple lines */
  opacity: 0;
  transition: opacity 0.15s ease;
  margin-left: 10px;
  pointer-events: none;
  visibility: hidden;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
}
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]:hover::after {
  opacity: 1;
}
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  background: var(--modal-bg);
  color: var(--primary-text);
  padding: 10px 20px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 2000;
}
.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.error {
  border-color: var(--danger-color);
}

/* Base sidebar & button styles */
.sidebar {
  width: 220px;
  padding: 20px;
  background: var(--hover-bg);
  border-right: 1px solid var(--border-color);
}

.sidebar h1 {
  margin-bottom: 1em;
  font-size: 1.5em;
  color: rgb(175, 135, 107);
  text-align: center;
   margin: 0 0 1em;
}


/* All sidebar buttons share this */
.sidebar .text-btn {
  display: block;
  width: 100%;
  margin-bottom: 0.1em;
  padding: 3px;
  font-family: var(--font-family);
  font-size: 0.9em;
  text-align: left;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

/* 1) Import & Export: calm, neutral */
.sidebar .import-export {
  background: var(--timeline-slot);
  border: 1px solid var(--border-color);
  color: rgb(217, 217, 217);
}
.sidebar .import-export:hover {
  background: #161d2a; /* lighter accent */
  color: rgb(169, 63, 30);
  border-color: rgb(169, 63, 30);
}

/* 2) Load-mode buttons: bold accent */
.sidebar .load-mode {
  background: var(--accent-color);
  border: 1px solid var(--border-color);
  color: rgb(205, 205, 205);
  
}
.sidebar .load-mode:hover {
  background: #161d2a; /* lighter accent */
  color: rgb(169, 63, 30);
  border-color: rgb(169, 63, 30);
  
}

/* 3) “Custom” & “Clear”: warning / special warning CLEAR LOCAL DATA COLOR */
.sidebar .action-mode {
  background:    rgb(81, 7, 7);;
  border: 1px solid var(--border-color);
  color: rgb(213, 213, 213);
}
.sidebar .action-mode:hover {
   background: #161d2a; /* lighter accent */
  color: rgb(169, 63, 30);
  border-color: rgb(169, 63, 30);
}/* Make the “Location:” label sit left and its dropdown right, on one line */
#add-event-modal #location-fields-container {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
}

#add-event-modal #location-fields-container > .field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;                  /* let both rows share width if you keep both */
}

/* If you only want the “Location:” row in that container: */
#add-event-modal #event-location-card-group {
  flex: 1;                  /* fill available space */
}

/* Tighten label / select */
#add-event-modal #event-location-card-group label {
  flex: 0 0 auto;
  margin: 0;
  font-size: 0.9em;
  color: var(--secondary-text);
}

#add-event-modal #event-location-card-group select {
  flex: 1;                  /* fill the rest of the row */
  min-width: 0;             /* prevents overflow */
}
info {
  background: var(--input-bg);
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  color: var(--primary-text);
  flex: 1;
}

/* FIELD ROWS */
.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.field-block {
  margin-bottom: 6px;
}

/* COLOR GRID: 2 rows of 8 swatches */
.color-grid #color-swatches {
  display: grid;
  grid-template-columns: repeat(8, 20px);
  grid-auto-rows: 20px;
  gap: 4px;
  margin-left: 4px;
}

/* BOTTOM ACTIONS */
.modal-actions.full-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px; /* A bit more space above */
  gap: 15px; /* A bit more space between items/rows */
  flex-wrap: wrap;
}
.modal-actions.full-row .action-group-left,
.modal-actions.full-row .action-group-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-actions.full-row label {
  font-size: 0.9em;
  color: var(--secondary-text);
}
.modal-actions.full-row select {
  padding: 4px 6px;
  font-size: 0.9em;
}

/* Tighter overall padding */
#add-event-modal .modal {
  max-height: 80vh;
  padding: 15px;
}
#add-event-modal .modal form {
  gap: 8px;
}
/* For both “Location Type” and “Location” rows: label on its own line above the control */
#add-event-modal #location-fields-container .field-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 8px;
}

#add-event-modal #location-fields-container .field-row label {
  margin: 0 0 4px;
  font-size: 0.9em;
  color: var(--secondary-text);
}

#add-event-modal #location-fields-container .field-row select {
  width: 100%;
}
/* make the info text inline, remove box styling */
.event-header #event-modal-info {
  display: inline-block;
  margin: 0 1em 0 0;       /* small gap after title */
  padding: 0;              /* no inner padding */
  border: none;            /* no border */
  background: none;        /* transparent bg */
  color: var(--primary-text);
  font-size: 1.4em;
  white-space: nowrap;
  
}

/* ensure header items stay on one line */
.event-header {
  display: flex;
  align-items: center;
  gap: 6em;
}


/* 2) Make the info span render as plain text */
.event-header .event-info {
  display: inline-block;
  margin: 0;              /* no extra spacing */
  padding: 0;             /* no internal padding */
  border: none;           /* remove any border */
  background: none;       /* transparent background */
  color: var(--primary-text);
  font-size: 1em;         /* match your H2’s size */
  white-space: nowrap;    /* keep it all on one line */
}
/* make all links white and underlined */
a {
  color: var(--primary-text) !important;     /* inherit your white text */
  text-decoration: underline;
}

/* make sure visited links stay white, not purple */
a:visited {
  color: var(--primary-text) !important;
}

/* optionally, on hover you can change color */
a:hover {
  color: var(--accent-color);
}
/* in style.css */
.event-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.event-header .event-icon {
  /* never smaller than 32px, scale up to 8% of viewport width, cap at 64px */
  width: clamp(32px, 8vw, 64px);
  height: auto;        /* keep aspect ratio */
  object-fit: contain;
  flex-shrink: 0;      /* never let it shrink below its clamp minimum */
  margin-left: 8px;    /* a little breathing room from the heading text */
}
.map-icon {
  position: absolute;
  pointer-events: auto;
}

/* Instant, custom tooltip */
/* Instant, custom tooltip for both map icons and cluster items */
.map-icon:hover::after,
.cluster-item:hover::after {
  content: attr(data-title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  white-space: nowrap;
  background: rgb(0, 0, 0);
  color: #fff;
  font-size: 12px;
  padding: 6px 6px;

  z-index: 1000;
  pointer-events: none;
}
.map-cluster {
  position: absolute;
  transform: translate(-50%, -100%);
  cursor: pointer;
}/* Cluster row must allow overflow so tooltips aren’t cut off */
.cluster-row {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  overflow: visible !important;   /* <-- allow tooltip to escape */
  max-height: 100px;
  transition: max-height 0.2s;
}

/* Each cluster‐item is its own positioning context */
.cluster-item {
  position: relative;             /* <-- for its tooltip */
  width: 24px;
  height: 24px;
  background-size: cover;
  background-position: center;
  border: 1px solid #fff;
  border-radius: 4px;
  pointer-events: auto;           /* <-- make hoverable */
}

.card-row.ruler-row {
  height: 40px;              /* match your normal row height */
   user-select: none; 
}

/* Make the info box in the ruler visible and centered */
.card-row.ruler-row .card-info {
    visibility: visible;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: default; /* Add this line to remove the grab cursor */
}

/* Style the date label itself */
.ruler-row .date-label {
    font-family: 'Dancing Script', cursive;
     font-size: clamp(1rem, 4vw, 1.5rem);
    color: var(--primary-text);
    text-shadow: 0 0 3px var(--accent-color);
}

/* allow dragging on the cloned rulers again */
.card-row.ruler-row .card-timeline {
  pointer-events: auto;
}




/* 3) Re-enable dragging on the real cursor */
#timeline-ruler {
  pointer-events: auto !important;
  cursor: grab !important;
   z-index: 1000 !important;
}

#timeline-ruler  {
  cursor: grabbing !important;
}

.card-row.ruler-row {
  display: flex !important;
}
/* hide the original full‐width timeline */





/* style both the real header (hidden) and every cloned header */
#timeline-header,
.cloned-timeline-header {
    display: flex;
    justify-content: space-between;
    color: var(--secondary-text);
    padding: 0 10px;
    font-size: 0.9em;
}

/* position the labels in each cloned header */
.cloned-timeline-header .timeline-label {
    position: absolute;
    bottom: 0;
    transform: translateX(-50%);
    white-space: nowrap;
    user-select: none;
     pointer-events: none;
}



/* ─── Make cloned rulers look & behave like the real one ─── */
.cloned-timeline-ruler {
  position: relative;                     /* anchor absolute children */
  height: 20px;                           /* same as #timeline-ruler */
  background: linear-gradient(
    to right,
    var(--timeline-slot) 1px,
    transparent 1px
  );
  background-size: calc(100% / 96) 100%;  /* same 96-slot grid */
  cursor: pointer;                        /* so you see the hand */
}

/* ─── Style every cursor, cloned or real ─── */
/* ════════════════════════════════
   ONE unified rule for every cursor
   (original or cloned)
   ════════════════════════════════ */
#timeline-cursor,
.timeline-cursor {
  position: absolute;
  top: -5px;
  left: 0;
  width: 3px;
  height: 30px;
  background-color: var(--cursor-color);
  box-shadow: 0 0 5px var(--cursor-color);
  transform: translateX(-1.5px);
  overflow: visible;

  /* --- CRITICAL FIXES --- */
  pointer-events: auto;  /* Allows the cursor to be clicked and dragged */
  z-index: 1000;         /* Ensures it appears above timeline events */
  cursor: grab;          /* Indicates to the user that it's draggable */
}

#timeline-cursor:active,
.timeline-cursor:active {
  cursor: grabbing; /* Provides visual feedback during the drag action */
}/* Ensure the hidden main timeline container stays hidden */
#timeline-container { 
  display: none; 
}

/*
 * Card Editor Modal Fixes
 */

/* 1. Apply styles ONLY when the modal is NOT hidden */
#card-editor-modal:not(.hidden) {
    max-height: 85vh;
    max-width: 950px;
    width: 90vw;
    display: flex;
    flex-direction: column;
}

/* 2. Make the form fill the available space */
#card-editor-modal form {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
}

/* 3. Make the two-column container the scrollable element */
#card-editor-modal .modal-column-container {
    overflow-y: auto;
    padding-right: 15px; 
  }
  body.modal-open {
    overflow: hidden;
}
/*
 * About Modal Scrolling Fix
 */

/* 1. Limit the modal's height and prepare it for scrolling content */
#about-modal:not(.hidden) {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

/* 2. Make the content area scrollable if it overflows */
#about-modal .modal-content {
    overflow-y: auto; /* Adds a scrollbar ONLY when needed */
    padding: 0 1em;   /* Adds a little horizontal space */
}.portrait-and-details-container {
    display: flex;
    align-items: flex-start; /* Aligns items to the top of the container */
    gap: 20px; /* Creates space between the portrait and the text fields */
}

.portrait-container {
    flex-shrink: 0; /* Prevents the portrait image from shrinking */
}

.details-container {
    flex-grow: 1; /* Allows this section to fill the available space */
    display: flex;
    flex-direction: column; /* Stacks the name, age, and profile fields vertically */
}
#night-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000033; /* A dark blue as a fallback */
    background-size: cover;
    background-position: center;
    mix-blend-mode: multiply; /* This creates a nice darkening effect */
    opacity: 0;
    pointer-events: none; /* Allows clicks to pass through to the map */
    transition: opacity 0.1s linear; /* Smooths the transition when scrubbing */
    z-index: 2; /* Sits above the map image but below icons */
}
#map-image-wrapper {
  position: relative;
  display: inline-block; /* Makes the wrapper shrink to the size of the image */
  line-height: 0;      /* Removes extra space below the image */
}
/* New styles for the floating map controls */
#map-controls-box {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 50;
  background-color: rgba(18, 18, 22, 0.85);
  border: 1px solid #555;
  border-radius: 5px;
  padding: 8px;
  backdrop-filter: blur(4px);
  width: 125px; 
}

.map-controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #eee;
}

#collapse-map-controls-btn {
  background: #444;
  border: 1px solid #666;
  color: #eee;
  cursor: pointer;
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 18px;
  line-height: 18px;
}

.map-controls-content {
  margin-top: 8px;
}

/* This rule hides the content when the box is collapsed */
#map-controls-box.collapsed .map-controls-content {
  display: none;
}

.map-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 3px;
  background-color: #333;
  color: #eee;
  font-family: 'VT323', monospace;
  font-size: 16px;
  border: 1px solid #666;
  user-select: none; /* Prevents text selection on click */
}

.map-toggle-btn:hover {
  background-color: #444;
}

.map-toggle-btn input {
  /* Simple checkbox style */
  width: 16px;
  height: 16px;
}

/* New style for stale icons on the map */
.stale {
  filter: grayscale(1);
  opacity: 0.75;
}
.map-icon:hover {
  z-index: 20!important; /* Bring the hovered icon (and its tooltip) to the front */
}
/* --- Phonebook Styles --- */
#phonebook-box {
  position: absolute; /* This makes it float over the map */
  top: 15px;          /* Positions it near the top */
  right: 15px;        /* Positions it on the right */
  z-index: 51;        /* Ensures it's above the other controls */
  background-color: rgba(18, 18, 22, 0.85);
  border: 1px solid #555;
  border-radius: 5px;
  padding: 8px;
  backdrop-filter: blur(4px);
  width: 250px; 
}

.phonebook-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #eee;
  cursor: pointer;
}

#collapse-phonebook-btn {
  background: #444;
  border: 1px solid #666;
  color: #eee;
  cursor: pointer;
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 18px;
  line-height: 18px;
}

#phonebook-content {
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.phonebook-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  background-color: rgba(0,0,0,0.2);
}

.phonebook-entry .icon {
  width: 24px;
  height: 24px;
  object-fit: cover;
  flex-shrink: 0;
}

.phonebook-entry span {
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phonebook-number {
  display: flex;
  gap: 4px;
}

/* This fixes the "giant icons" issue */
.phonebook-number img {
  width: 16px;
  height: 16px;
}

/* This makes the collapse button work */
#phonebook-box.collapsed #phonebook-content {
  display: none;
}

/* This nudges your other control box down to make room */
#map-controls-box {
  top: 90px; 
}
