body {
    margin: 0;
}

/* Login overlay — shown on page load until a role is chosen */
#login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #0f0f0f;
    font-family: Arial, sans-serif;
}

#login-overlay.hidden {
    display: none;
}

#login-box {
    background: #1c1c1c;
    border-radius: 10px;
    padding: 40px 48px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
    min-width: 300px;
}

#login-box h1 {
    color: #f2e4c4;
    font-family: Georgia, 'Times New Roman', serif;
    margin: 0 0 28px 0;
    font-size: 26px;
}

#role-select-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

#role-select-buttons button {
    padding: 12px 22px;
    background: #333;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
}

#role-select-buttons button:hover {
    background: #444;
}

.password-section {
    display: none;
    margin-top: 24px;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.password-section.visible {
    display: flex;
}

.password-section label {
    color: #ccc;
    font-size: 14px;
}

.password-input {
    width: 220px;
    text-align: left;
    font-size: 16px;
    letter-spacing: normal;
    padding: 8px 10px;
    background: #111;
    color: white;
    border: 1px solid #444;
    border-radius: 6px;
}

.password-submit-btn {
    padding: 8px 20px;
    background: #4a3a1a;
    color: #f2e4c4;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.password-submit-btn:hover {
    background: #5a4622;
}

.password-error {
    color: #ff8080;
    font-size: 13px;
    min-height: 16px;
}

#map {
    width: 100%;
    height: 100vh;
    background-color: black;
}

#coordinates {
    position: absolute;
    top: 10px;
    right: 10px;

    z-index: 1000;

    background: rgba(0, 0, 0, 0.75);
    color: white;

    padding: 10px;
    border-radius: 6px;

    font-family: Arial, sans-serif;
    font-size: 14px;
}

/* Persistent current-day display, top-middle of the screen — visible
   whether or not the calendar popup itself is open. */
#calendar-day-display {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;

    display: flex;
    align-items: center;
    gap: 8px;

    background: rgba(0, 0, 0, 0.75);
    color: #f2e4c4;
    border-radius: 6px;
    padding: 10px 14px;

    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    cursor: pointer;
}

#calendar-day-display:hover {
    background: rgba(30, 30, 30, 0.9);
}

/* The arrow buttons need their own cursor/hover so they still read as
   distinct clickable controls within the otherwise-clickable display. */
#calendar-day-display button {
    cursor: pointer;
}

#calendar-day-text {
    font-size: 14px;
    color: #f2e4c4;
}

#calendar-advance-day-btn, #calendar-regress-day-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    line-height: 1;
    cursor: pointer;
    font-size: 14px;
}

#calendar-advance-day-btn:hover, #calendar-regress-day-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Hidden entirely for players — set via JS based on role, same pattern
   as every other DM-only control in the app. */
/* Generic utility — hides ANY element for non-DM users. Toggled via JS
   based on isDM(). Used for DM-only controls throughout the app (the
   calendar's day-advance arrows, the quest/roster "add" rows, etc.) —
   this must stay a plain class selector, not scoped to specific IDs, so
   any new DM-only control can reuse it without a CSS change. */
.dm-only-hidden {
    display: none !important;
}

/* --- Calendar popup: a true centered modal, not a slide-out panel,
   since this needs to be "big enough to easily see and use" rather than
   squeezed into a side strip. --- */
#calendar-popup-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 5000;

    background: rgba(0, 0, 0, 0.6);

    align-items: center;
    justify-content: center;
}

#calendar-popup-overlay.open {
    display: flex;
}

#calendar-popup {
    background: #1c1c1c;
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);

    width: min(920px, 94vw);
    max-height: 90vh;
    overflow-y: auto;

    font-family: Arial, sans-serif;
}

#calendar-popup-header {
    display: flex;
    align-items: center;
    gap: 14px;

    padding: 16px 20px;
    background: #2a2a2a;
    border-radius: 10px 10px 0 0;
}

#calendar-month-title {
    flex: 1;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    color: #ffcc66;
}

#calendar-prev-month-btn, #calendar-next-month-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
}

#calendar-prev-month-btn:hover, #calendar-next-month-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

#calendar-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

#calendar-jump-row {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 10px 20px;
    background: #222;
    border-bottom: 1px solid #333;

    font-size: 13px;
    color: #ccc;
}

#calendar-jump-row label {
    flex-shrink: 0;
}

#calendar-jump-month-select {
    background: #111;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 5px 6px;
    font-size: 13px;
}

#calendar-jump-year-input {
    width: 80px;
    background: #111;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 5px 6px;
    font-size: 13px;
}

#calendar-jump-btn {
    background: #333;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 5px 12px;
    font-size: 13px;
    cursor: pointer;
}

#calendar-jump-btn:hover {
    background: #444;
}

#calendar-weekday-header {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    padding: 12px 20px 0 20px;

    font-size: 13px;
    color: #999;
    text-align: center;
    font-weight: bold;
}

#calendar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    padding: 8px 20px 20px 20px;
}

.calendar-day-cell {
    position: relative;
    min-height: 90px;

    background: #262626;
    border: 1px solid #383838;
    border-radius: 6px;
    padding: 6px;
}

.calendar-day-cell.is-current-day {
    background: #1f3d1f;
    border-color: #3f7d3f;
}

.calendar-day-number {
    font-size: 14px;
    font-weight: bold;
    color: #ddd;
}

.calendar-day-holiday-label {
    font-size: 11px;
    color: #ffcc66;
    margin-top: 2px;
    line-height: 1.2;
}

/* User-added events, shown the same way as holidays but in a different
   color so the two stay visually distinguishable — gold is reserved for
   the campaign's built-in lore holidays. */
.calendar-day-event-label {
    font-size: 11px;
    color: #7ec8e3;
    margin-top: 2px;
    line-height: 1.2;
}

.calendar-day-add-btn {
    position: absolute;
    top: 4px;
    right: 4px;

    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    width: 20px;
    height: 20px;
    line-height: 1;
    font-size: 13px;
    cursor: pointer;
}

.calendar-day-add-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.calendar-day-notes-count {
    position: absolute;
    bottom: 4px;
    right: 4px;

    background: #4a3a1a;
    color: #ffcc66;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    cursor: pointer;
}

/* --- Day notes popup: a smaller modal opened on top of the calendar
   popup when clicking + (or the notes count) on any day. --- */
/* --- Shared split-view popup layout: used by Quest Log and Player
   Notes — a list on the left the DM manages, a shared notepad on the
   right for whichever item is selected. --- */
.split-popup-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 5000;

    background: rgba(0, 0, 0, 0.6);

    align-items: center;
    justify-content: center;
}

.split-popup-overlay.open {
    display: flex;
}

.split-popup {
    background: #1c1c1c;
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);

    width: min(760px, 94vw);
    height: min(560px, 84vh);
    display: flex;
    flex-direction: column;

    font-family: Arial, sans-serif;
}

.split-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 14px 20px;
    background: #2a2a2a;
    border-radius: 10px 10px 0 0;

    font-size: 17px;
    font-weight: bold;
    color: #ffcc66;
}

.split-popup-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

.split-popup-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.split-popup-list-col {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #333;
    overflow: hidden;
}

.split-popup-list-col > div:first-child {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.split-popup-detail-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.split-popup-detail-title {
    padding: 12px 18px;
    font-weight: bold;
    font-size: 15px;
    color: #ffcc66;
    border-bottom: 1px solid #333;
}

.split-popup-add-row {
    padding: 10px 12px;
    border-top: 1px solid #333;
}

.split-popup-add-row input {
    width: 100%;
    box-sizing: border-box;
    background: #111;
    color: white;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
}

.split-popup-list-item {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 4px;
}

.split-popup-list-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.split-popup-list-item.selected {
    background: #4a3a1a;
    color: #ffcc66;
}

#quest-notes-list, #roster-player-notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 18px;
}

#day-notes-popup-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 5100;

    background: rgba(0, 0, 0, 0.6);

    align-items: center;
    justify-content: center;
}

#day-notes-popup-overlay.open {
    display: flex;
}

#day-notes-popup {
    background: #1c1c1c;
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);

    width: min(420px, 90vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;

    font-family: Arial, sans-serif;
}

#day-notes-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 14px 18px;
    background: #2a2a2a;
    border-radius: 10px 10px 0 0;
    font-weight: bold;
}

#day-notes-popup-title {
    font-size: 15px;
    color: #ffcc66;
}

#day-notes-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

.day-popup-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* The Notes section is last and holds the bulk of the content, so it's
   the one that flex-grows and scrolls; Events stays compact above it. */
.day-popup-section:last-of-type {
    flex: 1;
    min-height: 0;
}

#day-events-list {
    max-height: 130px;
}

.day-popup-section-label {
    padding: 10px 18px 4px 18px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
}

#day-notes-list, #day-events-list {
    overflow-y: auto;
    padding: 6px 18px;
}

.day-note-entry, .day-event-entry {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;

    background: #262626;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 8px;

    font-size: 14px;
}

.day-note-entry-text {
    flex: 1;
    cursor: pointer;
    white-space: pre-wrap;
    word-break: break-word;
}

.day-note-entry-text:hover {
    text-decoration: underline dotted;
}

.day-note-edit-input {
    flex: 1;
    background: #111;
    color: white;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 14px;
    font-family: Arial, sans-serif;
}

.day-note-delete-btn, .day-event-delete-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.day-note-delete-btn:hover, .day-event-delete-btn:hover {
    color: #ff8080;
}

.day-popup-add-row {
    padding: 10px 18px;
    border-top: 1px solid #333;
}

#day-notes-add-input, #day-events-add-input {
    width: 100%;
    box-sizing: border-box;
    background: #111;
    color: white;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
}

/* Right-click context menu */
#context-menu {
    display: none;
    position: absolute;
    z-index: 4000; /* must beat every panel (login 9999 aside) — it was previously
                       below #left-panel (2500), which hid "Mark Complete" behind it */

    margin: 0;
    padding: 4px 0;
    list-style: none;

    background: #222;
    color: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);

    font-family: Arial, sans-serif;
    font-size: 14px;
    min-width: 170px;
}

#context-menu li {
    padding: 8px 14px;
    cursor: pointer;
}

#context-menu li:hover {
    background: #444;
}

#delete-location-option {
    color: #ff8080;
}

#delete-npc-option {
    color: #ff8080;
}

#set-zoom-option {
    color: #9fd0ff;
}

/* Location marker icons are now plain PNG images (assets/*.png),
   sized directly via Leaflet's L.icon iconSize option — no CSS needed. */

/* Major landmark text labels (rotatable, draggable) */
.landmark-label-wrapper {
    /* no background box — the label itself provides its own styling */
}

.landmark-label {
    display: inline-block;
    white-space: nowrap;

    font-family: Georgia, 'Times New Roman', serif;
    font-weight: bold;
    font-size: 16px;
    letter-spacing: 1px;

    color: #f2e4c4;
    text-shadow:
        -1px -1px 0 #2a1c0d,
        1px -1px 0 #2a1c0d,
        -1px 1px 0 #2a1c0d,
        1px 1px 0 #2a1c0d,
        0 0 6px rgba(0, 0, 0, 0.8);

    transform-origin: center;
    cursor: grab;
    user-select: none;
}

/* Slide-out info panel for location notes */
#info-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 340px;

    background: #1c1c1c;
    color: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);

    display: flex;
    flex-direction: column;
    overflow-y: auto;

    transform: translateX(100%);
    transition: transform 0.25s ease;

    z-index: 3000;
}

#info-panel.open {
    transform: translateX(0);
}

#info-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 12px 16px;
    background: #2a2a2a;
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
}

#panel-title-input {
    flex: 1;
    min-width: 0;

    background: transparent;
    color: white;
    border: none;
    outline: none;

    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;

    padding: 2px 4px;
    border-radius: 3px;
}

#panel-title-input:hover {
    background: rgba(255, 255, 255, 0.08);
}

#panel-title-input:focus {
    background: rgba(255, 255, 255, 0.12);
}

#close-panel-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

#close-panel-btn:hover {
    color: #ff6b6b;
}

/* Rotation control — only shown for major landmarks */
#rotation-control {
    display: none;
    align-items: center;
    gap: 10px;

    padding: 10px 16px;
    background: #232323;
    border-bottom: 1px solid #333;

    font-family: Arial, sans-serif;
    font-size: 13px;
}

#rotation-input {
    width: 70px;
    background: #1c1c1c;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 6px;
}

#zoom-range-control {
    display: none;
    flex-direction: column;
    gap: 6px;

    padding: 10px 16px;
    background: #232323;
    border-bottom: 1px solid #333;

    font-family: Arial, sans-serif;
    font-size: 13px;
}

#zoom-range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

#zoom-min-input,
#zoom-max-input {
    width: 55px;
    background: #1c1c1c;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 6px;
}

#zoom-range-inputs span {
    color: #888;
}

#zoom-range-reset-btn {
    margin-left: auto;
    padding: 4px 10px;
    background: #333;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

#zoom-range-reset-btn:hover {
    background: #444;
}

/* Discovered checkbox — DM only */
#discovered-control {
    padding: 10px 16px;
    background: #232323;
    border-bottom: 1px solid #333;
    font-family: Arial, sans-serif;
    font-size: 13px;
}

#discovered-control label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #ccc;
}

#discovered-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Location image section */
#location-image-section {
    padding: 12px 16px;
    background: #202020;
    border-bottom: 1px solid #333;
    font-family: Arial, sans-serif;
    min-height: 40px; /* keeps this section visually present even with no image and no controls (player view) */
}

#location-image {
    display: none;
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 8px;
}

#no-image-placeholder {
    color: #888;
    font-size: 13px;
    font-style: italic;
    padding: 10px 0;
    text-align: center;
}

#image-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

#image-file-input {
    display: none;
}

#image-picker-label {
    display: inline-block;
    padding: 6px 12px;
    background: #333;
    color: white;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

#image-picker-label:hover {
    background: #444;
}

#remove-image-btn {
    display: none;
    padding: 6px 12px;
    background: transparent;
    color: #ff8080;
    border: 1px solid #553030;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

#remove-image-btn:hover {
    background: #3a2020;
}

/* Collapsible note sections */
.notes-section {
    border-bottom: 1px solid #2f2f2f;
}

.notes-section summary {
    padding: 10px 16px;
    cursor: pointer;
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: bold;
    background: #242424;
    list-style: none; /* hide default marker so we can draw our own */
}

.notes-section summary::-webkit-details-marker {
    display: none;
}

.notes-section summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.15s ease;
}

.notes-section[open] summary::before {
    transform: rotate(90deg);
}

.notes-section summary:hover {
    background: #2c2c2c;
}

.notes-section textarea {
    display: block;
    width: 100%;
    min-height: 140px;
    resize: vertical;
    box-sizing: border-box;

    border: none;
    outline: none;

    padding: 12px 16px;
    background: #1c1c1c;
    color: white;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* Read-only "preview" view — shows clickable links. This is what's shown
   by default; clicking it swaps in the plain textarea above for editing. */
.notes-display {
    display: block;
    width: 100%;
    min-height: 140px;
    box-sizing: border-box;

    padding: 12px 16px;
    background: #1c1c1c;
    color: white;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;

    white-space: pre-wrap;
    word-break: break-word;
    cursor: text;
}

.notes-display.read-only {
    cursor: default;
}

.notes-display.locked-by-other {
    cursor: not-allowed;
    background: #2a2416;
}

.notes-display .notes-locked-indicator {
    color: #d4a94e;
    font-style: italic;
}

.notes-display a {
    color: #6db8ff;
    text-decoration: underline;
    cursor: pointer;
}

.notes-display a:hover {
    color: #9fd0ff;
}

.notes-display .notes-placeholder {
    color: #777;
    font-style: italic;
}

/* --- Player notes: a chat-like list of entries, not one big field --- */

.player-notes-list {
    max-height: 260px;
    overflow-y: auto;
    background: #1c1c1c;
}

.player-note-entry {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid #262626;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

.player-note-text {
    flex: 1;
    color: white;
    white-space: pre-wrap;
    word-break: break-word;
}

.player-note-text a {
    color: #6db8ff;
    text-decoration: underline;
}

.player-note-text a:hover {
    color: #9fd0ff;
}

.player-note-text.locked-by-other {
    color: #b0a58a;
}

.player-note-lock-indicator {
    flex-shrink: 0;
    color: #d4a94e;
    font-style: italic;
    font-size: 12px;
    white-space: nowrap;
}

.player-note-edit-btn {
    flex-shrink: 0;
    padding: 3px 10px;
    background: #333;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.player-note-edit-btn:hover {
    background: #444;
}

.player-note-delete-btn {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 0;
    background: #333;
    color: #ff8080;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.player-note-delete-btn:hover {
    background: #3a2020;
}

.player-note-edit-input {
    flex: 1;
    background: #111;
    color: white;
    border: 1px solid #4a3a1a;
    border-radius: 4px;
    padding: 4px 8px;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

.player-notes-empty {
    padding: 14px 16px;
    color: #777;
    font-style: italic;
    font-size: 13px;
}

.player-notes-add-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 16px;
    background: #232323;
    color: white;
    border: none;
    border-top: 1px solid #333;
    outline: none;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

.player-notes-add-input::placeholder {
    color: #777;
}

/* Toggled via JS: only one of .notes-display / textarea is visible at a time */
.notes-display.hidden,
.notes-textarea.hidden {
    display: none;
}

/* --- NPC panel --- (visually mirrors #info-panel, kept separate so both
   panels can exist independently — a location and an NPC could in theory
   both have saved state at once, even though only one panel is open) */
#npc-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 340px;

    background: #1c1c1c;
    color: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.5);

    display: flex;
    flex-direction: column;
    overflow-y: auto;

    transform: translateX(100%);
    transition: transform 0.25s ease;

    z-index: 3000;
}

#npc-panel.open {
    transform: translateX(0);
}

#npc-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 12px 16px;
    background: #2a2a2a;
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
}

#npc-panel-title-input {
    flex: 1;
    min-width: 0;

    background: transparent;
    color: white;
    border: none;
    outline: none;

    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;

    padding: 2px 4px;
    border-radius: 3px;
}

#npc-panel-title-input:hover {
    background: rgba(255, 255, 255, 0.08);
}

#npc-panel-title-input:focus {
    background: rgba(255, 255, 255, 0.12);
}

#npc-close-panel-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

#npc-close-panel-btn:hover {
    color: #ff6b6b;
}

#npc-image-section {
    padding: 12px 16px;
    background: #202020;
    border-bottom: 1px solid #333;
    font-family: Arial, sans-serif;
    min-height: 40px;
}

#npc-image {
    display: none;
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 8px;
}

#npc-no-image-placeholder {
    color: #888;
    font-size: 13px;
    font-style: italic;
    padding: 10px 0;
    text-align: center;
}

#npc-image-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

#npc-image-file-input {
    display: none;
}

#npc-image-picker-label {
    display: inline-block;
    padding: 6px 12px;
    background: #333;
    color: white;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

#npc-image-picker-label:hover {
    background: #444;
}

#npc-remove-image-btn {
    display: none;
    padding: 6px 12px;
    background: transparent;
    color: #ff8080;
    border: 1px solid #553030;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

#npc-remove-image-btn:hover {
    background: #3a2020;
}

/* --- Left panel: search / NPCs / DM checklist / filter --- */

/* Sits just below Leaflet's default +/- zoom control, top-left. */
#left-panel-toggle-btn {
    position: absolute;
    top: 90px;
    left: 10px;
    z-index: 1000;

    width: 30px;
    height: 30px;
    padding: 0;

    background: white;
    color: #333;
    border: 2px solid rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

#left-panel-toggle-btn:hover {
    background: #f4f4f4;
}

#left-panel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 300px;

    background: #1c1c1c;
    color: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);

    display: flex;
    flex-direction: column;
    overflow-y: auto;

    transform: translateX(-100%);
    transition: transform 0.25s ease;

    z-index: 2500; /* below info/npc panels (3000) so both can't visually clash if opened in sequence */
}

#left-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 12px 16px;
    background: #2a2a2a;
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
}

/* Pin buttons — used on the left panel, info panel, and NPC panel headers */
.pin-btn {
    flex-shrink: 0;
    padding: 4px 10px;
    background: #333;
    color: #aaa;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.pin-btn:hover {
    background: #3a3a3a;
}

/* A top-level action button in the left panel — sits above the
   collapsible <details> sections, not inside one, since it's a single
   action (open the calendar) rather than a list of things to expand. */
.left-panel-action-btn {
    display: block;
    width: calc(100% - 32px);
    margin: 12px 16px;

    padding: 8px 12px;
    background: #333;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;

    font-family: Arial, sans-serif;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.left-panel-action-btn:hover {
    background: #444;
}

.pin-btn.pinned {
    background: #4a3a1a;
    color: #f2e4c4;
    border-color: #6a5428;
}

#left-panel.open {
    transform: translateX(0);
}

.left-panel-section {
    border-bottom: 1px solid #2f2f2f;
}

.left-panel-section summary {
    padding: 10px 16px;
    cursor: pointer;
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: bold;
    background: #242424;
    list-style: none;
}

.left-panel-section summary::-webkit-details-marker {
    display: none;
}

.left-panel-section summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.15s ease;
}

.left-panel-section[open] summary::before {
    transform: rotate(90deg);
}

.left-panel-section summary:hover {
    background: #2c2c2c;
}

.left-panel-hint {
    margin: 0;
    padding: 8px 16px 0 16px;
    color: #888;
    font-size: 12px;
    font-style: italic;
}

#location-search-input,
#npc-search-input {
    display: block;
    width: calc(100% - 32px);
    margin: 12px 16px 8px 16px;
    padding: 8px 10px;
    background: #111;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

#npc-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 16px 8px 16px;
}

#npc-search-row #npc-search-input {
    flex: 1;
    margin: 0;
    width: auto;
}

#add-npc-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: #333;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
}

#add-npc-btn:hover {
    background: #444;
}

#checklist-header-row {
    padding: 12px 16px 4px 16px;
}

#add-checklist-item-btn {
    padding: 6px 12px;
    background: #333;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

#add-checklist-item-btn:hover {
    background: #444;
}

#checklist-location-picker {
    display: none;
    border-bottom: 1px solid #2f2f2f;
}

#location-search-results,
#npc-search-results,
#dm-checklist-list,
#checklist-location-picker {
    list-style: none;
    margin: 0;
    padding: 0 0 12px 0;
    max-height: 320px;
    overflow-y: auto;
}

#location-search-results li,
#npc-search-results li,
#dm-checklist-list li,
#checklist-location-picker li {
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    border-top: 1px solid #2a2a2a;
}

#location-search-results li:hover,
#npc-search-results li:hover,
#dm-checklist-list li:hover,
#checklist-location-picker li:hover {
    background: #2a2a2a;
}

#map-scale-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 16px 14px 16px;
    font-size: 13px;
    color: #ccc;
}

#miles-per-square-input {
    width: 60px;
    background: #1c1c1c;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 13px;
}

#zoom-defaults-list {
    padding: 4px 16px 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zoom-default-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-default-row .zoom-default-label {
    flex: 1;
    font-size: 13px;
    color: #ccc;
}

.zoom-default-row input {
    width: 48px;
    background: #1c1c1c;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 13px;
}

.zoom-default-row span {
    color: #777;
    font-size: 12px;
}

#filter-checkboxes {
    padding: 8px 16px 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#filter-checkboxes label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #ccc;
    cursor: pointer;
}

#filter-checkboxes input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
}

/* Checklist/road-related menu items get the same accent as their peers */
#mark-checklist-complete-option {
    color: #8fd48f;
}

#measure-option {
    color: #ffcc66;
}

/* --- Distance measure results popup --- */
#measure-popup {
    display: none;
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3500;

    background: #1c1c1c;
    color: white;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.6);

    min-width: 320px;
    max-width: 90vw;
    font-family: Arial, sans-serif;
}

#measure-popup.open {
    display: block;
}

#measure-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;

    padding: 12px 16px;
    background: #2a2a2a;
    border-radius: 8px 8px 0 0;
}

#measure-distance-text {
    font-size: 18px;
    font-weight: bold;
    color: #ffcc66;
}

#measure-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

#measure-close-btn:hover {
    color: #ff6b6b;
}

#measure-popup-body {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    overflow-x: auto;
    max-width: 90vw;
}

.measure-leg-column {
    flex-shrink: 0;
    min-width: 220px;
    border-right: 1px solid #2f2f2f;
}

.measure-leg-column:last-child {
    border-right: none;
}

.measure-leg-header {
    padding: 10px 16px 4px 16px;
    font-size: 13px;
    font-weight: bold;
    color: #ffcc66;
}

.measure-travel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.measure-travel-table td {
    padding: 8px 16px;
    border-top: 1px solid #2f2f2f;
}

.measure-travel-table td:first-child {
    color: #ccc;
}

.measure-travel-table td:last-child {
    text-align: right;
    color: white;
    font-weight: bold;
    white-space: nowrap;
}
