* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Roboto, sans-serif;
    background: #1b1c1d;
    color: #ffffff;
    font-size: 14px;
    height: 100vh;
    overflow: hidden;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Adjusted for suite integration - removed header row */
.ms-app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: 1fr 60px; /* No header row */
    height: calc(100vh - 60px); /* Account for unified header */
    gap: 2px;
    background: #333537;
    transition: grid-template-columns 0.3s ease;
}

/* When left panel is collapsed, adjust grid */
.ms-app-container:has(.ms-left-panel.collapsed) {
    grid-template-columns: 0 1fr;
}

.ms-header {
    display: none; /* Hide original header for suite integration */
}

.ms-app-title {
    font-size: 24px;
    font-weight: bold;
    color: #f07727;
}

.ms-project-info {
    font-size: 12px;
    color: #ccc;
}

.ms-find-replace-container {
    display: none;
    gap: 6px;
    margin-right: 2px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 10px;
    pointer-events: auto;
}

.ms-find-replace-container.visible {
    display: flex;
}

.ms-find-replace-inputs {
    display: flex;
    gap: 4px;
    align-items: center;
}

.ms-find-scope-row {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 9px;
}

.ms-find-scope-option {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    color: #ccc;
}

.ms-find-scope-option input[type='radio'] {
    margin: 0;
    cursor: pointer;
    accent-color: #f07727;
}

.ms-find-scope-option span {
    user-select: none;
}

.ms-replace-input {
    padding: 3px;
    border: 1px solid #555;
    background: #444;
    color: white;
    border-radius: 4px;
    width: 80px;
    font-size: 10px;
}

.ms-replace-input:focus {
    border-color: #f07727;
    outline: none;
}

.ms-find-all-btn {
    padding: 4px 6px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 8px;
    background: #6c757d;
    color: #ffffff;
    transition: all 0.2s;
}

.ms-find-all-btn:hover:not(:disabled) {
    background: #5a6268;
}

.ms-find-all-btn:disabled {
    background: #444;
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Find Mode Label */
.ms-find-mode-label {
    font-weight: bold;
    font-size: 9px;
    color: #f07727;
    cursor: context-menu;
    user-select: none;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.15s;
}

.ms-find-mode-label:hover {
    background: rgba(240, 119, 39, 0.15);
}

/* MAP Text Highlight Box */
.ms-map-text-highlight {
    position: absolute;
    border: 2px solid #00ff00;
    background: transparent;
    pointer-events: none;
    z-index: 250;
    box-sizing: border-box;
}

/* Hide replace controls in MAP mode */
.ms-find-replace-container.ms-map-mode .ms-replace-input,
.ms-find-replace-container.ms-map-mode .ms-replace-btn,
.ms-find-replace-container.ms-map-mode .ms-find-all-btn {
    display: none;
}

.ms-replace-btn {
    padding: 6px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 9px;
    background: #f07727;
    color: #ffffff;
    transition: all 0.2s;
}

.ms-replace-btn:hover:not(:disabled) {
    background: #e55a00;
}

.ms-replace-btn:disabled {
    background: #444;
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

.ms-replace-status {
    font-size: 11px;
    color: #fff;
    text-align: center;
    min-height: 0;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 2px 6px;
    border-radius: 3px;
}

.ms-find-container {
    display: flex;
    gap: 1px;
    margin-right: 2px;
    flex-direction: column;
}

.ms-find-input {
    padding: 3px;
    border: 1px solid #555;
    background: #444;
    color: white;
    border-radius: 4px;
    width: 80px;
    font-size: 10px;
}

.ms-find-input.ms-has-results {
    border-color: #fe943d;
    box-shadow: 0 0 5px rgba(0, 255, 136, 0.3);
}

.ms-find-input.ms-no-results {
    border-color: #ff4444;
    box-shadow: 0 0 5px rgba(255, 68, 68, 0.3);
}

#find-count {
    font-size: 12px;
    color: #999;
    min-width: 70px;
}

.ms-btn {
    padding: 4px 4px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    font-size: 9px;
}

.ms-btn-primary {
    background: #f07727;
    color: #ffffff;
}

.ms-btn-primary:hover {
    background: #e55a00;
}

.ms-btn-primary:disabled {
    background: #444;
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

.ms-btn-success {
    background: #00b360;
    color: white;
}

.ms-btn-success:hover:not(:disabled) {
    background: #00cc6a;
}

.ms-btn-secondary {
    background: #6c757d;
    color: white;
}

.ms-btn-secondary:hover {
    background: #5a6268;
}

.ms-btn-danger {
    background: #dc3545;
    color: white;
}

.ms-btn-danger:hover {
    background: #c82333;
}

/* PDF Export Button Processing State */
.ms-btn-processing {
    border: 3px solid #ffffff !important;
    box-shadow: 0 0 0 2px #f07727 !important;
}

.ms-btn-glow-orange {
    background-color: #ff8800;
    color: white;
    animation: pulse-orange 2s infinite;
}

.ms-btn-compact {
    padding: 3px 5px;
    font-size: 9px;
}

.ms-btn-uniform-width {
    min-width: 80px;
}

.ms-btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #3a3a3a;
    border: 1px solid #555;
    border-radius: 4px;
    color: #ccc;
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s;
}

.ms-btn-icon:hover {
    background: #4a4a4a;
    color: #fff;
}

.ms-btn-icon.active {
    background: #f07727;
    color: #fff;
}

#dotcam-btn {
    /* Emoji sits low, nudge it up */
    padding-bottom: 4px;
}

.ms-map-icon-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ms-glow {
    animation: pulse 2s infinite;
}

.ms-logo-svg {
    height: 34px;
    width: auto;
    vertical-align: middle;
}

#map-filename-display {
    font-size: 10px;
    color: #aaa;
    margin-top: 4px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 102, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 102, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 102, 0, 0);
    }
}

@keyframes pulse-orange {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 136, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 136, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 136, 0, 0);
    }
}

.ms-left-panel {
    background: #333537;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #555;
    height: 100%;
    max-height: 100%;
    overflow: visible; /* Allow collapse button to show */
    transition: transform 0.3s ease;
    position: relative;
    z-index: 250; /* Above tool belt (z-index: 200) */
    width: 100%;
}

.ms-left-panel.collapsed {
    transform: translateX(-100%);
}

/* Collapse Button - attached to right edge of left panel */
.ms-panel-collapse-btn {
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 60px;
    background: #f07727;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    z-index: 250; /* Above tool belt (z-index: 200) */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}

.ms-panel-collapse-btn:hover {
    background: #e55a00;
}

.ms-panel-collapse-btn .collapse-arrow {
    color: white;
    font-size: 12px;
    transition: transform 0.3s ease;
}

.ms-left-panel.collapsed .ms-panel-collapse-btn .collapse-arrow {
    transform: rotate(180deg);
}

.ms-left-panel.ms-expanded {
    width: 60%;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    box-shadow: 5px 0 20px rgba(0, 0, 0, 0.5);
}

.ms-panel-header {
    background: #333537;
    color: #f07727; /* Changed to orange */
    padding: 12px;
    font-weight: bold;
    font-size: 18px;
    border-bottom: 1px solid #555;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    line-height: 1; /* Normalize line height for better vertical centering */
}

.ms-header-buttons {
    display: flex;
    align-items: center;
}

.ms-panel-content {
    flex: 1;
    overflow-y: hidden;
    padding: 10px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    position: relative;
}

.ms-expanded .ms-panel-content {
    overflow-y: auto;
}

.ms-filter-section {
    flex: 0 0 auto; /* Don't grow or shrink, controlled by JS */
    min-height: 100px; /* Minimum height to be usable */
    max-height: calc(50vh - 60px); /* Initial cap, overridden by JS after setup */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition:
        box-shadow 0.15s ease,
        border-color 0.15s ease;
}

/* Drag-and-drop visual feedback for marker type import */
.ms-filter-section.drag-over {
    box-shadow: inset 0 0 0 2px #f07727;
    background: rgba(240, 119, 39, 0.1);
}

/* Panel resizer between marker types and list */
.ms-panel-resizer {
    flex: 0 0 6px;
    background: #2a2a2a;
    cursor: ns-resize;
    position: relative;
    z-index: 10;
}

.ms-panel-resizer:hover,
.ms-panel-resizer.dragging {
    background: #f07727;
}

.ms-panel-resizer::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 2px;
    background: #666;
    border-radius: 1px;
}

.ms-panel-resizer:hover::after,
.ms-panel-resizer.dragging::after {
    background: #fff;
}

/* Special handling for panel-content inside filter section */
.ms-filter-section .ms-panel-content {
    overflow-y: hidden; /* Let the marker-type-container handle scrolling */
}

.ms-marker-type-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    max-height: 50vh; /* Limit to half viewport - scrollbar appears when exceeded */
    padding-right: 5px; /* Space for scrollbar */
}

.ms-marker-type-item {
    display: flex;
    flex-direction: column;
    padding: 4px;
    background: #3a3a3a;
    border-radius: 4px;
    transition: background 0.2s;
    border: 2px solid transparent;
    gap: 0;
}

.ms-marker-type-item:hover {
    background: #4a4a4a;
}

.ms-legend-item-active {
    border: 2px solid #f07727;
    box-shadow: 0 0 8px rgba(255, 102, 0, 0.5);
    background-color: #454545;
}

/* Header row - always visible */
.ms-marker-type-header {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 28px;
    cursor: pointer;
}

/* Expand arrow */
.ms-marker-type-expand {
    font-size: 10px;
    color: #888;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s;
    flex-shrink: 0;
    user-select: none;
}

.ms-marker-type-expand:hover {
    color: #f07727;
}

.ms-marker-type-item.ms-expanded .ms-marker-type-expand {
    transform: rotate(90deg);
}

/* Color pickers wrapper in header */
.ms-marker-type-colors {
    display: flex;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

/* Expanded area - hidden by default */
.ms-marker-type-expanded {
    display: none;
    padding: 8px 4px 4px 22px;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    border-top: 1px solid #555;
    margin-top: 4px;
}

.ms-marker-type-item.ms-expanded .ms-marker-type-expanded {
    display: flex;
}

/* Checkbox labels in expanded area */
.ms-marker-type-visibility-label,
.ms-marker-type-outline-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #ccc;
    cursor: pointer;
    white-space: nowrap;
}

.ms-marker-type-visibility-label:hover,
.ms-marker-type-outline-label:hover {
    color: #fff;
}

.ms-marker-type-item input[type='checkbox'] {
    width: 14px;
    height: 14px;
    accent-color: #f07727;
    flex-shrink: 0;
    cursor: pointer;
}

.ms-marker-type-item .ms-checkbox-label {
    font-size: 11px;
    color: #ccc;
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

/* Removed duplicate .ms-marker-type-inputs - see line 2234 for the active rule */

.ms-dynamic-input {
    padding: 1px 4px !important;
    border: none !important;
    box-sizing: border-box;
}

.ms-marker-type-code-input,
.ms-marker-type-name-input {
    background: transparent;
    border: none;
    color: white;
    font-family: inherit;
    padding: 2px 4px;
    border-radius: 2px;
    width: 100%;
    border: 1px solid transparent;
}

.ms-marker-type-code-input {
    font-size: 12px;
    font-weight: bold;
}

.ms-marker-type-name-input {
    font-size: 10px;
    color: #aaa;
}

/* Disclaimer Modal Styles */
#disclaimer-modal {
    z-index: 5000;
}

#disclaimer-modal .ms-modal-content {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.ms-disclaimer-content {
    color: #ccc;
    line-height: 1.6;
    font-size: 14px;
}

.ms-disclaimer-content p {
    margin-bottom: 15px;
}

.ms-disclaimer-content strong {
    color: #f07727;
}

.ms-disclaimer-content ul {
    color: #ddd;
}

.ms-disclaimer-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.ms-original-char {
    color: #ff6b6b;
    font-weight: bold;
    background: rgba(255, 107, 107, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

.ms-replacement-text {
    color: #6bff6b;
    font-weight: bold;
    background: rgba(107, 255, 107, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

.ms-marker-type-code-input:focus,
.ms-marker-type-name-input:focus {
    background: #555;
    outline: none;
    border: 1px solid #f07727;
}

.ms-marker-type-code-input:not(:placeholder-shown),
.ms-marker-type-name-input:not(:placeholder-shown) {
    color: white;
}

.ms-marker-type-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
}

.ms-color-picker-wrapper {
    position: relative;
    width: 20px;
    height: 20px;
    border: 1px solid #666;
    border-radius: 3px;
    cursor: pointer;
}

.ms-delete-marker-type-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 16px;
    padding: 0 5px;
}
.ms-delete-marker-type-btn:hover {
    color: #ff4444;
}

.ms-list-section {
    flex: 1 1 0; /* Grow and shrink, start from 0 */
    min-height: 0; /* Allow it to shrink fully */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Special handling for panel-content inside list section */
.ms-list-section .ms-panel-content {
    flex: 1;
    min-height: 0;
    overflow: hidden; /* Let the location-list handle scrolling */
    display: flex;
    flex-direction: column;
}

#list-header-controls {
    display: flex;
    gap: 5px;
}

.ms-all-pages-container {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #ccc;
    margin-left: 8px;
}

.ms-all-pages-container input[type='checkbox'] {
    accent-color: #f07727;
}

#list-with-renumber {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#location-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    max-height: 100%;
    padding-right: 5px; /* Space for scrollbar */
}

.ms-empty-state {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
    font-size: 14px;
}

.ms-location-item {
    background: #3a3a3a;
    margin-bottom: 3px;
    border-radius: 4px;
    border-left: 4px solid #444;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 28px;
    display: flex;
    align-items: center;
    /* Prevent text selection on list items */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.ms-location-item:hover {
    background: #4a4a4a;
}

.ms-location-item.ms-selected {
    background: #4a2f1a !important;
    border-left-color: #f07727 !important;
    border: 2px solid #f07727 !important;
    box-shadow: 0 0 8px rgba(255, 102, 0, 0.5) !important;
}

.ms-location-header {
    padding: 4px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.ms-location-number {
    font-weight: bold;
    color: #f07727;
    flex-shrink: 0;
    font-size: 10px;
}

.ms-location-messages {
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 4px;
    min-width: 0;
}

.ms-location-message {
    flex: 1;
    color: #ccc;
    font-size: 9px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    min-width: 0;
}

.ms-location-message-input {
    background: transparent;
    border: none;
    color: #ccc;
    font-size: 9px;
    font-family: inherit;
    padding: 2px 4px;
    border-radius: 2px;
    min-width: 0;
}

.ms-location-message-input.ms-message1 {
    flex: 0 0 auto;
    width: auto;
    color: #f0f0f0;
    min-width: 60px;
    max-width: 50%;
}

.ms-location-message-input.ms-message2 {
    flex: 1 1 auto;
    color: #f0f0f0;
    min-width: 40px;
}

.ms-location-message-input:focus {
    background: #555;
    outline: none;
    border: 1px solid #f07727;
}

.ms-marker-type-category {
    background: #4a4a4a;
    margin-bottom: 2px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid;
}

.ms-marker-type-category:hover {
    background: #5a5a5a;
}

.ms-marker-type-category-header {
    padding: 4px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.ms-marker-type-category-title {
    font-weight: bold;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ms-expand-icon {
    font-size: 10px;
    transition: transform 0.2s;
}

.ms-expand-icon.ms-expanded {
    transform: rotate(90deg);
}

.ms-marker-type-category-count {
    color: #f07727;
    font-size: 9px;
    font-weight: bold;
}

.ms-marker-type-items {
    display: none;
    padding-left: 12px;
    border-left: 2px solid #666;
    margin-left: 8px;
    margin-bottom: 4px;
}

.ms-marker-type-items.ms-expanded {
    display: block;
}

.ms-grouped-location-item {
    background: #3a3a3a;
    margin-bottom: 2px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 2px solid #666;
}

.ms-grouped-location-header {
    padding: 4px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.ms-grouped-location-item:hover {
    background: #4a4a4a;
}

.ms-grouped-location-item.ms-selected {
    background: #4a2f1a !important;
    border-left-color: #f07727 !important;
    border: 2px solid #f07727 !important;
    box-shadow: 0 0 8px rgba(255, 102, 0, 0.5) !important;
}

.ms-marker-type-badge {
    background: #007acc;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 9px;
    flex-shrink: 0;
    box-sizing: border-box;
    max-width: 120px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Code required badge removed */

.ms-location-details {
    padding: 0 10px 10px;
    font-size: 12px;
    color: #ccc;
    display: none;
}

.ms-location-details.ms-open {
    display: block;
}

.ms-detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.ms-btn-small {
    padding: 4px 8px;
    font-size: 10px;
    margin-top: 5px;
    margin-right: 5px;
}

.ms-map-section {
    background: #1a1a1a;
    position: relative;
    overflow: hidden;
}

.ms-map-container {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: default;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><rect width="20" height="20" fill="%23222"/><rect width="1" height="20" fill="%23333"/><rect width="20" height="1" fill="%23333"/></svg>');
    overflow: hidden;
}

.ms-map-container.ms-dragging {
    cursor: grabbing;
}

#map-content {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    transition: transform 0.3s ease-out;
    /* Hardware acceleration for smooth panning */
    will-change: transform;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

.ms-upload-area {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #666;
    font-size: 18px;
    border: 3px dashed #444;
    padding: 40px;
    border-radius: 10px;
    cursor: pointer;
    background: rgba(42, 42, 42, 0.8);
    backdrop-filter: blur(10px);
    z-index: 500;
}

.ms-upload-area.ms-dragover {
    border-color: #00ff88;
    color: #00ff88;
}

/* Dragover state for map container when PDF is already loaded */
.ms-map-container.ms-dragover {
    box-shadow: inset 0 0 50px rgba(0, 255, 136, 0.3);
    border: 2px dashed #00ff88;
}

.ms-upload-area-note {
    font-size: 12px;
    color: #888;
    margin-top: 15px;
}

.ms-render-progress {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #00ff88;
    font-size: 16px;
    padding: 15px 25px;
    border-radius: 8px;
    background: rgba(42, 42, 42, 0.95);
    backdrop-filter: blur(10px);
    z-index: 500;
    border: 2px solid #00ff88;
}

#render-progress-text {
    font-weight: 600;
    white-space: pre-line;
}

#pdf-canvas {
    display: none;
}

.ms-crop-btn {
    background: #444;
    border: none;
    color: white;
    padding: 4px 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ms-crop-btn:hover {
    background: #555;
}

.ms-crop-btn.active {
    background: #4caf50;
    color: white;
}

.ms-crop-btn svg {
    width: 14px;
    height: 14px;
}

.ms-crop-overlay {
    position: absolute;
    border: 2px solid #4caf50;
    background: rgba(76, 175, 80, 0.1);
    pointer-events: none;
    z-index: 999;
}

.ms-crop-overlay.active {
    pointer-events: auto;
}

.ms-crop-handle {
    position: absolute;
    width: 25px;
    height: 25px;
    background: #4caf50;
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.1s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.ms-crop-handle-nw {
    top: -12.5px;
    left: -12.5px;
    cursor: nw-resize;
}

.ms-crop-handle-n {
    top: -12.5px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.ms-crop-handle-ne {
    top: -12.5px;
    right: -12.5px;
    cursor: ne-resize;
}

.ms-crop-handle-w {
    top: 50%;
    left: -12.5px;
    transform: translateY(-50%);
    cursor: w-resize;
}

.ms-crop-handle-e {
    top: 50%;
    right: -12.5px;
    transform: translateY(-50%);
    cursor: e-resize;
}

.ms-crop-handle-sw {
    bottom: -12.5px;
    left: -12.5px;
    cursor: sw-resize;
}

.ms-crop-handle-s {
    bottom: -12.5px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.ms-crop-handle-se {
    bottom: -12.5px;
    right: -12.5px;
    cursor: se-resize;
}

/* Crop mask */
.ms-crop-mask {
    pointer-events: none;
}

/* Crop all pages checkbox */
.ms-crop-all-pages-container {
    display: none;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #ccc;
    white-space: nowrap;
    padding: 0 8px;
    border-left: 1px solid #555;
}

.ms-crop-all-pages-container input[type='checkbox'] {
    margin: 0;
    cursor: pointer;
}

.ms-crop-all-pages-container label {
    cursor: pointer;
    user-select: none;
}

.ms-map-dot {
    position: absolute;
    background: #ff0000;
    border: none;
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 8px;
    font-weight: bold;
    transform: translate(-50%, -50%);
    z-index: 100;
    transition:
        transform 0.2s,
        box-shadow 0.2s;
    /* Prevent text selection on dots */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.ms-dot-number {
    text-shadow: none;
}

.ms-map-dot:hover {
    transform: translate(-50%, -50%) scale(1.2);
    z-index: 101;
}

.ms-map-dot.ms-dragging {
    z-index: 102;
    transform: translate(-50%, -50%) scale(1.3);
    cursor: grabbing !important;
}

.ms-map-dot.search-highlight {
    box-shadow:
        0 0 15px #f07727,
        0 0 30px #f07727;
    z-index: 200;
    animation: searchPulse 1.5s ease-in-out infinite;
}

.ms-map-dot.ms-selected {
    /* box-shadow and border now set dynamically in JS to scale with dot size */
    z-index: 200;
}

@keyframes searchPulse {
    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
    }
}

.ms-map-dot-message {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: bold;
    white-space: nowrap;
    z-index: 150;
    margin-top: -3px;
    display: none;
    text-shadow: none;
    -webkit-text-stroke: 0;
}

.ms-map-dot-message.ms-visible {
    display: block;
}

.ms-map-dot-message2 {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: bold;
    white-space: nowrap;
    z-index: 150;
    margin-top: 10px;
    display: none;
    text-shadow: none;
    -webkit-text-stroke: 0;
}

.ms-map-dot-message2.ms-visible {
    display: block;
}

.ms-dot-installed-checkmark {
    position: absolute;
    top: -2px;
    right: -3px;
    width: 16px;
    height: 16px;
    background: #00ff00;
    border: 2px solid #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: #ffffff;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.ms-dot-installed-checkmark {
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Vinyl backer styles removed */

.ms-selection-box {
    position: absolute;
    border: 2px dashed #f07727 !important;
    background: rgba(255, 102, 0, 0.1) !important;
    pointer-events: none;
    z-index: 300;
}

.ms-scrape-box {
    position: absolute;
    border: 2px dashed #00ff88 !important;
    background: rgba(0, 255, 136, 0.1) !important;
    pointer-events: none;
    z-index: 300;
}

.ms-scrape-box.ms-ocr-scrape {
    border: 2px dashed #ff44ff !important;
    background: rgba(255, 68, 255, 0.1) !important;
}

.ms-legends-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 200;
}

.ms-legend-box {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(42, 42, 42, 0.95);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 10px;
    backdrop-filter: blur(10px);
    min-width: 180px;
    max-width: 220px;
    max-height: calc(100% - 20px);
    display: none;
    pointer-events: auto;
    overflow: hidden;
    flex-direction: column;
}

.ms-map-legend-content {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding-right: 8px;
}

#unified-legend {
    top: 10px;
    right: 10px;
    z-index: 201;
}

.ms-legend-toggle {
    display: flex;
    gap: 2px;
}

.ms-legend-toggle-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.15s;
}

.ms-legend-toggle-btn:hover {
    color: #ccc;
}

.ms-legend-toggle-btn.active {
    color: #f07727;
    background: rgba(240, 119, 39, 0.15);
}

.ms-legend-box.ms-visible {
    display: flex;
}

.ms-map-legend-header {
    font-size: 12px;
    font-weight: bold;
    color: #f07727;
    margin-bottom: 8px;
    border-bottom: 1px solid #555;
    padding-bottom: 4px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ms-legend-collapse-arrow {
    transition: transform 0.2s;
    font-size: 14px;
    line-height: 1;
}

.ms-legend-box.ms-collapsed .ms-legend-collapse-arrow {
    transform: rotate(-90deg);
}

.ms-legend-box.ms-collapsed .ms-map-legend-content {
    display: none;
}

.ms-legend-empty-message {
    color: #888;
    font-size: 11px;
    font-style: italic;
    padding: 8px 4px;
    text-align: center;
}

.ms-map-legend-item-container {
    margin-bottom: 4px;
}

.ms-map-legend-item {
    display: flex;
    align-items: center;
    padding: 2px 0;
    font-size: 10px;
    color: #ccc;
}

.ms-map-legend-item-header {
    cursor: pointer;
    transition: background-color 0.2s;
}

.ms-map-legend-item-header:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.ms-map-legend-collapse-arrow {
    width: 12px;
    margin-right: 4px;
    font-size: 8px;
    color: #999;
    flex-shrink: 0;
    user-select: none;
}

.ms-map-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid white;
    flex-shrink: 0;
}

.ms-map-legend-text {
    flex: 1;
    min-width: 0;
}

.ms-map-legend-count {
    color: #ffffff;
    font-weight: bold;
    font-size: 11px;
    margin-left: 8px;
    flex-shrink: 0;
}

.ms-map-legend-flag-details {
    padding-left: 26px;
    margin-top: 2px;
}

.ms-map-legend-flag-row {
    display: flex;
    align-items: center;
    padding: 2px 0;
    font-size: 10px;
    color: #aaa;
}

.ms-map-legend-flag-symbol {
    width: 16px;
    margin-right: 6px;
    text-align: center;
    flex-shrink: 0;
}

.ms-map-legend-flag-name {
    flex: 1;
    min-width: 0;
}

.ms-map-legend-flag-count {
    color: #f07727;
    font-weight: bold;
    font-size: 11px;
    margin-left: 8px;
    flex-shrink: 0;
}

.ms-footer-controls {
    grid-column: 1 / -1;
    background: #333537;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    border-top: 1px solid #555;
    min-height: 50px;
}

.ms-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ms-automap-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ms-automap-select {
    width: 150px;
    padding: 8px;
}

.ms-automap-input {
    width: 200px;
    padding: 8px;
}

.ms-automap-checkbox-group {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #ccc;
    font-size: 12px;
}

.ms-automap-checkbox-group input[type='checkbox'] {
    accent-color: #f07727;
}

.ms-automap-status {
    font-size: 12px;
    color: #aaa;
    min-width: 150px;
    text-align: left;
}

.ms-controls-list-modal {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}

.ms-controls-list-modal li {
    padding: 5px 0;
    font-size: 13px;
    display: flex;
    border-bottom: 1px solid #444;
}

.ms-controls-list-modal li:last-child {
    border-bottom: none;
}

.ms-controls-list-modal li strong {
    color: #f07727;
    font-weight: bold;
    display: inline-block;
    width: 140px;
    flex-shrink: 0;
}

.ms-tooltip-description {
    font-size: 11px;
    font-style: italic;
    color: #aaa;
    padding-left: 15px;
}

.ms-tooltip-note {
    margin-top: 8px;
    font-size: 11px;
    font-style: italic;
    color: #ffc107;
}

/* Gallery Modal Styles */
.ms-gallery-modal {
    display: none;
    position: fixed;
    z-index: 10002 !important; /* Above edit modal backdrop */
    width: 380px; /* Slightly smaller than max to match edit modal */
    max-width: 400px;
    /* Position will be set dynamically by JavaScript */
}

.ms-gallery-modal.ms-visible {
    display: block;
}

.ms-gallery-content {
    background: #2a2a2a;
    border: 2px solid #444;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    padding: 10px;
    height: 100%;
    overflow: hidden;
}

.ms-gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    margin: -10px -10px 10px -10px;
    background: #333;
    border-bottom: 1px solid #444;
    border-radius: 6px 6px 0 0;
}

.ms-gallery-title {
    font-size: 20px;
    font-weight: bold;
    color: #f07727;
}

.ms-gallery-controls {
    display: flex;
    gap: 10px;
}

.ms-gallery-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ms-gallery-add-btn {
    background: #f07727;
    color: white;
}

.ms-gallery-add-btn:hover {
    background: #ff8833;
}

.ms-gallery-close-btn {
    background: #dc3545;
    color: white;
    border: 1px solid #dc3545;
}

.ms-gallery-close-btn:hover {
    background: #c82333;
    color: white;
    border-color: #c82333;
}

.ms-gallery-label-toggle-btn {
    background: #444;
    color: #999;
    border: 1px solid #555;
    font-size: 16px;
    font-weight: bold;
}

.ms-gallery-label-toggle-btn:hover {
    background: #555;
    color: #bbb;
    border-color: #666;
}

.ms-gallery-label-toggle-btn.active {
    background: #f07727;
    color: white;
    border-color: #f07727;
}

.ms-gallery-label-toggle-btn.active:hover {
    background: #ff8833;
    border-color: #ff8833;
}

.ms-gallery-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 5px 5px 5px;
    gap: 15px;
    overflow: hidden;
}

.ms-gallery-main-view {
    flex: 1;
    background: white;
    border: 1px solid #555;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ms-gallery-main-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ms-gallery-main-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.ms-gallery-location-label {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    pointer-events: none;
    z-index: 10;
}

.ms-gallery-delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 20px;
    transition: background 0.2s;
}

.ms-gallery-delete-btn:hover {
    background: rgba(255, 0, 0, 1);
}

.ms-gallery-placeholder {
    color: #333;
    font-size: 24px;
    font-weight: bold;
}

.ms-gallery-thumbnails {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    height: 80px;
}

.ms-gallery-thumb {
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: border-color 0.2s;
}

.ms-gallery-thumb:hover {
    border-color: #f07727;
}

.ms-gallery-thumb.active {
    border-color: #f07727;
    border-width: 2px;
}

.ms-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ms-gallery-thumb-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    font-size: 10px;
}

/* Photo Options Modal */
.ms-photo-options-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
}

.ms-photo-options-content {
    background: #2a2a2a;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 20px;
    min-width: 300px;
}

.ms-photo-options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: bold;
    color: #f07727;
}

.ms-photo-options-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ms-photo-option-btn {
    padding: 15px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Camera Modal */
.ms-camera-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10003;
}

.ms-camera-content {
    background: #2a2a2a;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 10px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.ms-camera-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #444;
    margin-bottom: 10px;
    font-size: 18px;
    font-weight: bold;
    color: #f07727;
}

.ms-camera-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    min-height: 400px;
}

.ms-camera-body video {
    width: 100%;
    height: auto;
    max-height: 60vh;
    object-fit: contain;
}

.ms-camera-controls {
    display: flex;
    justify-content: center;
    padding: 15px;
}

.ms-camera-controls .ms-btn {
    padding: 12px 24px;
    font-size: 16px;
}

.ms-size-slider {
    width: 60px;
    height: 6px;
    background: #444;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.ms-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #f07727;
    border-radius: 50%;
    cursor: pointer;
}

.ms-size-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #f07727;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.ms-page-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ccc;
    font-size: 11px;
    background: rgba(42, 42, 42, 0.9);
    padding: 3px 4px;
    border-radius: 6px;
    border: 1px solid #444;
    backdrop-filter: blur(10px);
}

.ms-page-label-input {
    background: transparent;
    border: 1px solid #555;
    color: #ccc;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    width: 100px;
}

.ms-page-label-input:focus {
    border-color: #f07727;
    outline: none;
    background: rgba(255, 255, 255, 0.1);
}

.ms-nav-btn {
    background: #444;
    border: none;
    color: white;
    padding: 3px 8px;
    cursor: pointer;
    border-radius: 4px;
}

.ms-nav-btn:hover {
    background: #555;
}

.ms-nav-btn:disabled {
    background: #333;
    cursor: not-allowed;
    opacity: 0.5;
}

.ms-delete-page-btn {
    background: #d32f2f !important;
    margin-left: 8px;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
}

.ms-delete-page-btn:hover {
    background: #f44336 !important;
}

.ms-add-page-btn {
    background: #28a745 !important;
    margin-left: 4px;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
}

.ms-add-page-btn:hover {
    background: #34c759 !important;
}

.ms-map-overlay-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 200;
}

.ms-map-overlay-controls-top-left {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 200;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
    pointer-events: none;
}

.ms-map-overlay-controls-top-left button {
    pointer-events: auto;
}

.ms-map-controls-collapsible {
    display: flex;
    flex-direction: row;
    gap: 4px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.2s ease-out;
    pointer-events: none;
}

.ms-map-controls-collapsible.expanded {
    max-height: 500px;
    pointer-events: auto;
}

/* Map Context Menu (right-click / long-press) */
.ms-map-context-menu {
    display: none;
    position: fixed;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 160px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.ms-map-context-menu.visible {
    display: block;
}

.ms-map-context-menu-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    font-size: 12px;
    color: #ccc;
    cursor: pointer;
    transition: background 0.15s;
    gap: 8px;
}

.ms-map-context-menu-item:hover {
    background: #3a3a3a;
    color: #fff;
}

.ms-map-context-menu-check {
    width: 16px;
    text-align: center;
    color: #f07727;
    font-size: 12px;
}

.ms-map-context-menu-icon {
    width: 16px;
    text-align: center;
    color: #888;
    font-size: 12px;
    font-weight: bold;
}

.ms-map-context-menu-divider {
    height: 1px;
    background: #444;
    margin: 4px 0;
}

.ms-map-context-menu-slider {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ms-map-context-menu-slider label {
    font-size: 12px;
    color: #ccc;
    white-space: nowrap;
}

.ms-map-context-menu-slider input[type='range'] {
    flex: 1;
    height: 4px;
    cursor: pointer;
    accent-color: #f07727;
}

.ms-map-context-menu-tolerance {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #ccc;
}

.ms-map-context-menu-tolerance > label {
    white-space: nowrap;
}

.ms-ctx-tolerance-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.ms-ctx-tolerance-group input[type='number'] {
    width: 45px;
    padding: 2px 4px;
    font-size: 11px;
    background: #333;
    border: 1px solid #555;
    border-radius: 3px;
    color: #ccc;
    -moz-appearance: textfield;
}

.ms-ctx-tolerance-group input[type='number']::-webkit-outer-spin-button,
.ms-ctx-tolerance-group input[type='number']::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ms-map-controls-collapsible button {
    pointer-events: auto;
}

.ms-scrape-controls {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ms-tolerance-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ms-tolerance-input-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ms-tolerance-input-group label {
    color: #00ff88;
    font-weight: bold;
    font-size: 10px;
    font-family: monospace;
    min-width: 15px;
}

.ms-tolerance-input {
    width: 60px;
    padding: 2px 4px;
    background: #333;
    border: 1px solid #555;
    color: #00ff88;
    border-radius: 3px;
    font-size: 10px;
    font-family: monospace;
    text-align: center;
}

.ms-tolerance-input:focus {
    border-color: #00ff88;
    outline: none;
    background: #444;
}

.ms-tolerance-input::-webkit-outer-spin-button,
.ms-tolerance-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ms-tolerance-display {
    position: absolute;
    bottom: 30px;
    left: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
    color: #ccc;
    font-family: monospace;
}

.ms-tolerance-value {
    color: #00ff88;
    font-weight: bold;
}

/* Text Annotations */
.ms-text-annotation {
    position: absolute;
    padding: 2px 4px;
    background: transparent;
    color: #000;
    cursor: move;
    user-select: none;
    white-space: nowrap;
    z-index: 150;
    font-family: Arial, sans-serif;
    transform-origin: top left;
}

.ms-text-annotation.selected {
    outline: 1px dotted #888;
}

.ms-text-annotation.editing {
    cursor: text;
    user-select: text;
    background: rgba(255, 255, 255, 0.9);
    outline: none;
}

/* Text scale handles */
.ms-text-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #888;
    border: 1px solid #fff;
    display: none;
    z-index: 151;
}

.ms-text-annotation.selected .ms-text-handle {
    display: block;
}

.ms-text-annotation.editing .ms-text-handle {
    display: none;
}

.ms-text-handle-br {
    bottom: -4px;
    right: -4px;
    cursor: nwse-resize;
}

.ms-train-scrape-btn {
    background-color: #00ff00 !important;
    color: #000 !important;
    border: none;
}

.ms-train-scrape-btn.ms-glowing {
    animation: glow-green 1s ease-in-out infinite alternate;
}

@keyframes glow-green {
    from {
        box-shadow: 0 0 5px #00ff00;
    }
    to {
        box-shadow: 0 0 15px #00ff00;
    }
}

.ms-train-big-box {
    position: absolute;
    border: 2px solid #00ff00;
    background: rgba(0, 255, 0, 0.05);
    pointer-events: none;
    z-index: 300;
}

.ms-train-big-box.ms-glowing {
    animation: glow-green-box 1s ease-in-out infinite alternate;
}

@keyframes glow-green-box {
    from {
        box-shadow: 0 0 10px #00ff00;
    }
    to {
        box-shadow: 0 0 20px #00ff00;
    }
}

.ms-train-small-box {
    position: absolute;
    border: 2px dashed #008000;
    background: rgba(0, 128, 0, 0.1);
    pointer-events: none;
    z-index: 301;
}

.ms-train-counter-btn {
    position: absolute;
    top: -15px;
    left: 0;
    background: #00ff00;
    color: #000;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    z-index: 302;
}

.ms-train-counter-btn.ms-ready {
    background: #00ff00;
    animation: pulse-green 1s infinite;
}

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

/* Flash animation for upload area */
@keyframes flash-green {
    0%,
    100% {
        border-color: #666;
        background-color: rgba(42, 42, 42, 0.8);
        box-shadow: none;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        border-color: #00ff88;
        background-color: rgba(0, 255, 136, 0.2);
        box-shadow:
            0 0 30px rgba(0, 255, 136, 0.8),
            inset 0 0 20px rgba(0, 255, 136, 0.3);
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* More dramatic flash animation for buttons */
@keyframes flash-green-button {
    0%,
    100% {
        background-color: #f07727;
        box-shadow: none;
        transform: scale(1);
    }
    25% {
        background-color: #00ff88;
        box-shadow: 0 0 20px rgba(0, 255, 136, 0.9);
        transform: scale(1.1);
    }
    50% {
        background-color: #00ff88;
        box-shadow:
            0 0 30px rgba(0, 255, 136, 1),
            0 0 40px rgba(0, 255, 136, 0.5);
        transform: scale(1.15);
    }
    75% {
        background-color: #00ff88;
        box-shadow: 0 0 20px rgba(0, 255, 136, 0.9);
        transform: scale(1.1);
    }
}

.ms-upload-area.ms-flash-green {
    animation: flash-green 0.5s ease-in-out 3;
}

/* Flash animation for buttons */
.ms-btn.ms-flash-green {
    animation: flash-green-button 0.6s ease-in-out 3 !important;
    position: relative;
    z-index: 1000;
}

/* Tooltip Styles */
.ms-tooltip-popup {
    position: absolute;
    background: rgba(42, 42, 42, 0.95);
    border: 1px solid #f07727;
    border-radius: 6px;
    padding: 8px 12px;
    color: #ffffff;
    font-size: 12px;
    line-height: 1.4;
    max-width: 250px;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ms-tooltip-popup.ms-visible {
    opacity: 1;
    transform: scale(1);
}

.ms-tooltip-popup[data-position='top']::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #f07727;
}

.ms-tooltip-popup[data-position='bottom']::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: #f07727;
}

.ms-tooltip-popup[data-position='left']::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-left-color: #f07727;
}

.ms-tooltip-popup[data-position='right']::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 100%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: #f07727;
}

#tooltips-btn.ms-active {
    background: #f07727;
    color: #ffffff;
}

.ms-train-counter-btn,
.ms-train-cancel-btn {
    pointer-events: auto;
}

.ms-train-cancel-btn {
    position: absolute;
    top: -15px;
    right: 0;
    background: #ff0000;
    color: #fff;
    padding: 2px 6px;
    font-size: 12px;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    z-index: 302;
}

#renumber-modal .ms-modal-content {
    max-width: 280px;
    min-width: 260px;
    padding: 15px;
}

#renumber-modal .ms-modal-body {
    gap: 8px;
}

#renumber-modal .ms-modal-text {
    margin-bottom: 8px;
    font-size: 12px;
}

.ms-renumber-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 8px 0;
}

.ms-renumber-option-btn {
    padding: 6px 8px;
    text-align: left;
    border-radius: 3px;
    border: 1px solid transparent;
    transition: all 0.2s;
    line-height: 0.65;
    font-size: 11px;
}

.ms-renumber-option-btn:hover {
    border-color: #f07727;
    background: #3a3a3a;
}

.ms-renumber-option-btn strong {
    display: block;
    font-size: 11px;
    margin-bottom: 1px;
}

.ms-renumber-option-btn small {
    color: #ffffff;
    font-size: 9px;
    line-height: 1.1;
}

#mapping-slayer-renumber-modal .ms-modal-buttons {
    margin-top: 10px;
}

#mapping-slayer-pdf-export-modal .ms-modal-content {
    max-width: 320px;
    min-width: 300px;
    padding: 15px;
}

#mapping-slayer-pdf-export-modal .ms-modal-body {
    gap: 8px;
}

#mapping-slayer-pdf-export-modal .ms-modal-text {
    margin-bottom: 8px;
    font-size: 12px;
}

.ms-pdf-export-options {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin: 8px 0;
    justify-content: center;
}

.ms-pdf-export-option-btn {
    padding: 10px 20px;
    text-align: center;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: all 0.2s;
    font-size: 12px;
    font-weight: bold;
    min-width: 120px;
}

.ms-pdf-export-option-btn:hover {
    border-color: #f07727;
    background: #3a3a3a;
}

.ms-pdf-export-checkbox {
    display: flex;
    justify-content: center;
    margin-top: 12px;
}

.ms-pdf-export-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    color: #ccc;
}

.ms-pdf-export-checkbox input[type='checkbox'] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

#mapping-slayer-pdf-export-modal .ms-modal-buttons {
    margin-top: 10px;
}

.ms-tooltip-controls-group {
    display: flex;
    align-items: center;
    gap: 5px;
    /* The background, padding, and border have been removed */
}

.ms-tooltip-style-selector {
    display: flex;
    gap: 5px;
    border-left: 1px solid #555;
    padding-left: 8px;
    margin-left: 4px;
}

.ms-tooltip-style-selector label {
    font-size: 12px;
    color: #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
}

.ms-tooltip-style-selector input[type='radio'] {
    accent-color: #f07727;
}

.ms-tooltip-style-selector.ms-hidden {
    display: none;
}

.ms-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
}

.ms-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2a2a2a;
    padding: 10px;
    border-radius: 8px;
    border: 2px solid #444;
    min-width: 280px;
    max-width: 400px;
}

#controls-modal .ms-modal-content {
    max-width: 420px;
}

.ms-modal-header {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 0px;
    color: #f07727;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* NEW MODAL STYLES */
.ms-modal-header-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 10px;
    margin-bottom: 8px;
}

.ms-modal-header-main .ms-modal-title {
    font-size: 14px;
    font-weight: bold;
    color: #f07727;
    margin: 0;
}

.ms-modal-header-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}

.ms-modal-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px;
    max-height: 50vh;
    overflow-y: auto;
}

.ms-form-textarea {
    min-height: 50px;
    resize: vertical;
    font-family: inherit;
    font-size: 10px;
}
/* END NEW MODAL STYLES */

.ms-modal-subheader {
    font-size: 9px;
    color: #aaa;
    margin-top: 5px;
    margin-bottom: 8px;
}

.ms-modal-text {
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 0px;
}

.ms-modal-text strong {
    color: #f07727;
}

.ms-form-group {
    margin-bottom: 0; /* Removed margin as gap is used in modal-body */
}

.ms-form-group label {
    display: block;
    color: #ccc;
    font-weight: normal;
    margin-bottom: 2px;
    font-size: 10px;
}

.ms-form-group-inline {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ms-form-group-inline label {
    margin-bottom: 0;
    font-size: 9px;
    color: #ccc;
    font-weight: normal;
}

/* Toggle buttons for Sign Preview and Gallery */
.ms-modal-toggle-buttons {
    display: flex;
    gap: 8px;
}

.ms-modal-toggle-btn {
    padding: 6px 12px;
    background: #555;
    color: #ccc;
    border: 1px solid #666;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    transition: all 0.2s;
    white-space: nowrap;
}

.ms-modal-toggle-btn:hover {
    background: #666;
    color: #fff;
}

.ms-modal-toggle-btn.active {
    background: #f07727;
    color: white;
    border-color: #f07727;
}

.ms-modal-toggle-btn.active:hover {
    background: #ff8833;
    border-color: #ff8833;
}

.ms-form-label {
    display: block;
    margin-bottom: 2px;
    color: #ccc;
    font-size: 10px;
    font-weight: normal;
}

.ms-form-input {
    width: 100%;
    padding: 3px 5px;
    background: #444;
    border: 1px solid #555;
    color: white;
    border-radius: 4px;
    font-size: 10px;
}

#edit-location-display {
    display: block;
    padding: 4px 0;
    color: #ccc;
    font-size: 10px;
    font-weight: normal;
    font-family: inherit;
}

.ms-modal-buttons {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 10px;
}

.ms-csv-status {
    position: absolute;
    top: 70px;
    right: 8px;
    background: rgba(42, 42, 42, 0.9);
    border: 1px solid #444;
    border-radius: 4px;
    padding: 10px;
    max-width: 300px;
    display: none;
    z-index: 1000;
    font-size: 10px;
}

.ms-csv-status.ms-visible {
    display: block;
}

.ms-csv-status.ms-success {
    border-color: #f07727;
}

.ms-csv-status.ms-error {
    border-color: #ff4444;
}

/* Automap progress modal */
.ms-automap-progress-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
}

.ms-automap-progress-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2a2a2a;
    padding: 30px;
    border-radius: 8px;
    border: 2px solid #f07727;
    min-width: 450px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
}

.ms-automap-progress-header {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    color: #f07727;
}

#automap-main-status {
    font-size: 24pt;
    color: #f07727;
    margin-bottom: 15px;
    font-weight: bold;
    line-height: 1.2;
}

#mapping-slayer-automap-activity-feed {
    max-height: 150px;
    overflow-y: auto;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 10px;
    font-family: monospace;
    font-size: 8pt;
    text-align: left;
    margin-top: 15px;
    margin-bottom: 20px;
    color: #ccc;
    line-height: 1.5;
}

.ms-activity-feed-item {
    padding: 2px 4px;
    border-bottom: 1px solid #333;
}

.ms-activity-feed-item:last-child {
    border-bottom: none;
}

.ms-activity-feed-item.ms-success {
    color: #6bff6b;
}

.ms-activity-feed-item.ms-error {
    color: #ff6b6b;
}

.ms-activity-feed-item.ms-info {
    color: #ccc;
}

.ms-automap-progress-bar {
    width: 100%;
    height: 20px;
    background: #444;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 15px;
}

.ms-automap-progress-fill {
    height: 100%;
    background: #f07727;
    transition: width 0.3s ease;
    width: 0%;
}

.ms-automap-results {
    text-align: left;
    font-size: 14px;
    color: #ccc;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 20px;
    padding: 10px;
    background: #333;
    border-radius: 4px;
}

/* Updated styles for the room list preview modal */
.ms-roomlist-preview {
    text-align: left;
    font-size: 13px;
    color: #ccc;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 15px;
    padding: 10px;
    background: #333;
    border-radius: 4px;
    border: 1px solid #444;
}

.ms-roomlist-preview-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 4px;
    border-bottom: 1px solid #4a4a4a;
    cursor: pointer;
}
.ms-roomlist-preview-item:hover {
    background: #404040;
}
.ms-roomlist-preview-item:last-child {
    border-bottom: none;
}
.ms-roomlist-preview-item input[type='checkbox'] {
    width: 16px;
    height: 16px;
    accent-color: #f07727;
    flex-shrink: 0;
}
.ms-roomlist-preview-key {
    color: #f07727;
    font-weight: bold;
}
.ms-roomlist-preview-value {
    color: #ddd;
}
.ms-modal-buttons button:first-child {
    margin-right: auto; /* Pushes the select all button to the left */
}
.ms-roomlist-preview-header {
    font-weight: bold;
    color: #f07727;
    margin-top: 10px;
    margin-bottom: 5px;
    font-size: 14px;
    border-bottom: 1px solid #555;
    padding-bottom: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ms-roomlist-preview-header:first-of-type {
    margin-top: 0;
}
.ms-roomlist-preview-value-old {
    color: #ff6b6b;
    text-decoration: line-through;
}
.ms-roomlist-preview-value-new {
    color: #6bff6b;
    font-weight: bold;
}
.ms-btn-select-all {
    padding: 2px 6px;
    font-size: 10px;
}
.ms-code-required-label {
    font-style: italic;
    color: yellow;
    font-size: 11px;
    margin-left: 5px;
}

.ms-marker-type-inputs {
    display: flex;
    gap: 4px;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 180px;
}

.ms-marker-type-code-input {
    width: 100%;
    min-width: 30px;
    max-width: 80px;
    flex-shrink: 0;
}

.ms-marker-type-name-input {
    flex: 1;
    max-width: 135px;
    min-width: 60px;
}

.train-cancel-btn {
    position: absolute;
    top: -15px;
    right: 0;
    background: #ff0000;
    color: #fff;
    padding: 2px 6px;
    font-size: 12px;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    z-index: 302;
}

/* Modal Positioning Fixes for Suite Integration */
#mapping-slayer-edit-modal,
#mapping-slayer-group-edit-modal,
#mapping-slayer-renumber-modal,
#mapping-slayer-pdf-export-modal,
#mapping-slayer-controls-modal,
#mapping-slayer-ocr-info-modal,
#mapping-slayer-save-roomlist-modal,
#mapping-slayer-disclaimer-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.8) !important;
    z-index: 10001 !important;
    display: none;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    max-width: none !important;
}

/* Automap progress modal follows same pattern */
#mapping-slayer-automap-progress-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.8) !important;
    z-index: 10001 !important;
    display: none;
    margin: 0 !important;
    padding: 0 !important;
}

#mapping-slayer-edit-modal.modal .modal-content,
#mapping-slayer-group-edit-modal.modal .modal-content,
#mapping-slayer-renumber-modal.modal .modal-content,
#mapping-slayer-pdf-export-modal.modal .modal-content,
#mapping-slayer-controls-modal.modal .ms-modal-content {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    background: #2a2a2a !important;
    border: 2px solid #444 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
}

/* Dynamic Text Fields */
.ms-dynamic-fields-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Fields Wrapper */
.ms-fields-wrapper {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ms-fields-wrapper.scrollable {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 3px;
}

.ms-fields-wrapper.scrollable::-webkit-scrollbar {
    width: 4px;
}

.ms-fields-wrapper.scrollable::-webkit-scrollbar-track {
    background: #333;
    border-radius: 2px;
}

.ms-fields-wrapper.scrollable::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 2px;
}

.ms-fields-wrapper.scrollable::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Dynamic Text Field */
.ms-dynamic-text-field {
    position: relative;
}

.ms-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.ms-field-controls {
    display: flex;
    gap: 3px;
}

.ms-field-edit-btn,
.ms-field-delete-btn {
    padding: 2px 4px;
    background: transparent;
    color: #999;
    border: none;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.ms-field-edit-btn:hover {
    background: #444;
    color: #f07727;
}

.ms-field-delete-btn:hover {
    background: #444;
    color: #dc3545;
}

/* Field Name Edit Input */
.ms-field-name-edit-input {
    padding: 2px 4px;
    background: #444;
    color: white;
    border: 1px solid #f07727;
    border-radius: 3px;
    font-size: 10px;
    font-weight: normal;
    margin-right: 5px;
}

.ms-required-indicator {
    color: #f07727;
    font-weight: normal;
}

/* Text Field Management UI */
.ms-text-fields-manager {
    background: #333537;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 10px;
    margin-top: 10px;
}

.ms-text-fields-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #555;
}

.ms-text-fields-title {
    font-size: 12px;
    font-weight: bold;
    color: #f07727;
}

.ms-text-field-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    gap: 5px;
    align-items: center;
    padding: 5px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    margin-bottom: 4px;
}

.ms-text-field-item:hover {
    background: #333;
    border-color: #555;
}

.ms-field-drag-handle {
    cursor: move;
    color: #666;
    font-size: 16px;
    user-select: none;
}

.ms-field-drag-handle:hover {
    color: #999;
}

.ms-field-name-input {
    padding: 2px 4px;
    background: #444;
    border: 1px solid #555;
    color: white;
    border-radius: 4px;
    font-size: 10px;
}

.ms-field-name-input:focus {
    border-color: #f07727;
    outline: none;
}

.ms-field-required-checkbox {
    margin: 0;
}

.ms-field-max-length-input {
    width: 60px;
    padding: 4px;
    background: #444;
    border: 1px solid #555;
    color: white;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
}

.ms-field-max-length-input:focus {
    border-color: #f07727;
    outline: none;
}

.ms-remove-field-btn {
    padding: 4px 8px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.ms-remove-field-btn:hover {
    background: #c82333;
}

.ms-text-field-item.dragging {
    opacity: 0.5;
}

.ms-text-field-item.drag-over {
    border-top: 2px solid #f07727;
}

/* Automap progress modal has different structure */
#mapping-slayer-automap-progress-modal .ms-automap-progress-content {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    background: #2a2a2a !important;
    border: 2px solid #444 !important;
    border-radius: 8px !important;
    padding: 20px !important;
    min-width: 500px !important;
    max-width: 90% !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
}

/* Ensure modals show when they have display: block */
#mapping-slayer-edit-modal[style*='display: block'],
#mapping-slayer-group-edit-modal[style*='display: block'],
#mapping-slayer-renumber-modal[style*='display: block'],
#mapping-slayer-pdf-export-modal[style*='display: block'],
#mapping-slayer-controls-modal[style*='display: block'],
#mapping-slayer-ocr-info-modal[style*='display: block'],
#mapping-slayer-save-roomlist-modal[style*='display: block'],
#mapping-slayer-disclaimer-modal[style*='display: block'],
#mapping-slayer-automap-progress-modal[style*='display: block'] {
    display: block !important;
}

/* Annotation Lines */
.ms-annotation-line-temp {
    pointer-events: none;
    transition: none;
}

.ms-annotation-line {
    transition: all 0.2s;
}

.ms-annotation-line:hover {
    filter: brightness(1.3);
    box-shadow: 0 0 4px currentColor;
}

.ms-annotation-line.ms-selected {
    background-color: #00ff88 !important;
    box-shadow: 0 0 4px rgba(0, 255, 136, 0.5);
}

.ms-annotation-endpoint {
    transition: all 0.2s;
}

.ms-annotation-endpoint:hover {
    width: 12px !important;
    height: 12px !important;
    right: -6px !important;
    top: -5px !important;
    box-shadow: 0 0 6px currentColor;
    filter: brightness(1.2);
}

/* Custom color picker inputs */
.ms-custom-color-inputs {
    padding: 8px;
    border-top: 1px solid #e0e0e0;
}

.ms-color-inputs-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.ms-hexa-input {
    width: 70px;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-family: monospace;
    font-size: 11px;
    text-transform: uppercase;
    background: #f8f8f8;
}

.ms-hexa-input:focus {
    outline: none;
    border-color: #4285f4;
    background: #fff;
}

.ms-r-input,
.ms-g-input,
.ms-b-input {
    width: 40px;
    padding: 4px 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 11px;
    text-align: center;
    background: #f8f8f8;
}

.ms-r-input:focus,
.ms-g-input:focus,
.ms-b-input:focus {
    outline: none;
    border-color: #4285f4;
    background: #fff;
}

.ms-color-buttons-container {
    margin-left: auto;
    display: flex;
    gap: 4px;
    align-items: center;
}

.ms-eyedropper-btn {
    background: #f0f0f0;
    border: 1px solid #ddd;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.ms-eyedropper-btn:hover {
    background: #e0e0e0;
    border-color: #ccc;
}

.ms-eyedropper-btn:active {
    background: #d0d0d0;
}

/* Style the Pickr save button */
.pcr-save {
    background: #4285f4 !important;
    color: white !important;
    border: none !important;
    padding: 4px 12px !important;
    border-radius: 3px !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: background 0.2s !important;
    margin: 0 !important;
}

.pcr-save:hover {
    background: #357ae8 !important;
}

/* Hide the default input field if it exists */
.pcr-result {
    display: none !important;
}

/* Automap button styling */
#single-automap-btn {
    white-space: nowrap;
    min-width: fit-content;
}

/* Flag Customization Modal Styles */
.ms-flag-modal-content {
    width: 280px;
    max-width: 90vw;
}

.ms-flag-modal-body {
    padding: 15px;
    max-height: none;
    overflow-y: visible;
}

.ms-flag-visual-container {
    position: relative;
    width: auto;
    min-height: 162px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 20px;
    padding: 10px;
    justify-items: center;
    max-width: 260px;
}

.ms-flag-corner {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: #3a3a3a;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #555;
}

.ms-flag-top-left {
    grid-column: 1;
    grid-row: 1;
}

.ms-flag-top-right {
    grid-column: 2;
    grid-row: 1;
}

.ms-flag-bottom-left {
    grid-column: 1;
    grid-row: 2;
}

.ms-flag-bottom-right {
    grid-column: 2;
    grid-row: 2;
}

.ms-flag-name-input {
    width: 80px;
    padding: 3px;
    background: #2a2a2a;
    border: 1px solid #555;
    color: #fff;
    border-radius: 3px;
    text-align: center;
    font-size: 11px;
}

.ms-flag-name-input:focus {
    outline: none;
    border-color: #f07727;
}

.ms-flag-symbol-selector {
    display: flex;
    align-items: center;
    gap: 2px;
    background: #2a2a2a;
    padding: 4px;
    border-radius: 3px;
    border: 1px solid #555;
}

.ms-flag-prev-btn,
.ms-flag-next-btn {
    width: 18px;
    height: 18px;
    background: #555;
    color: #fff;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background 0.2s;
}

.ms-flag-prev-btn:hover,
.ms-flag-next-btn:hover {
    background: #f07727;
}

.ms-flag-symbol-display {
    width: 28px;
    height: 28px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    min-width: 28px;
}

.ms-flag-symbol-display.ms-flag-active {
    border-color: #f07727;
    background: #2a2a2a;
}

.ms-flag-symbol-display img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ms-flag-upload-btn {
    width: 100%;
    padding: 3px;
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #555;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s;
}

.ms-flag-upload-btn:hover {
    background: #3a3a3a;
    border-color: #f07727;
}

/* Flag indicators on dots */
.ms-dot-flag {
    position: absolute;
    font-size: 12px;
    line-height: 1;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 5;
}

.ms-dot-flag-top-left {
    top: -8px;
    left: -8px;
}

.ms-dot-flag-top-right {
    top: -8px;
    right: -8px;
}

.ms-dot-flag-bottom-left {
    bottom: -8px;
    left: -8px;
}

.ms-dot-flag-bottom-right {
    bottom: -8px;
    right: -8px;
}

/* Flag selectors in edit modals */
.ms-modal-header-flags {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}

.ms-flag-selector-item {
    display: flex;
    align-items: center;
}

.ms-flag-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ms-flag-label {
    font-size: 12px;
    color: #ccc;
    min-width: 80px;
}

.ms-flag-cycle-btn {
    width: 40px;
    height: 40px;
    background: #2a2a2a;
    border: 2px solid #555;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.ms-flag-cycle-btn:hover {
    border-color: #f07727;
    background: #3a3a3a;
}

.ms-flag-cycle-btn.ms-flag-indeterminate {
    border-style: dashed;
    opacity: 0.6;
}

.ms-flag-symbol {
    font-size: 20px;
    line-height: 1;
}
/* Mapping Slayer Header and Navigation Styles */

/* Toast Notifications */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-notification {
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    font-weight: 500;
    max-width: 400px;
    word-wrap: break-word;
}

.toast-notification.error {
    background: #dc3545 !important;
}

/* Global Box-Sizing Reset */
* {
    box-sizing: border-box;
}

/* Header Styles */
.slayer-header {
    background: #333537;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid #555;
    height: 60px;
    flex-shrink: 0;
}

/* User Menu */
.user-menu {
    position: relative;
    margin-right: 30px;
}

.user-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f07727;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.3s ease;
    color: #ffffff;
}

.user-icon:hover {
    background: #e55a00;
    transform: scale(1.05);
}

.user-flyout {
    position: absolute;
    top: 50px;
    left: 0;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 6px;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.user-menu:hover .user-flyout {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.flyout-item {
    padding: 12px 16px;
    border-bottom: 1px solid #444;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    color: #ffffff;
}

.flyout-item:hover {
    background: #3a3a3a;
}

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

.flyout-item.danger:hover {
    background: #5a2626;
    color: #ff6b6b;
}

/* Logo Section */
.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-right: 30px;
    min-width: 400px;
}

.mapping-logo {
    font-size: 20px;
    font-weight: bold;
    color: #f07727;
    text-decoration: none;
}

/* Logo Context Menu (About Menu) */
.ms-logo-context-menu {
    position: fixed;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    min-width: 200px;
    z-index: 10000;
    padding: 8px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ms-logo-context-menu-item {
    padding: 8px 16px;
    color: #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    transition: background 0.15s ease;
}

.ms-logo-context-menu-item:hover {
    background: #3a3a3a;
}

.ms-logo-context-menu-item.disabled {
    color: #666;
    cursor: default;
}

.ms-logo-context-menu-item.disabled:hover {
    background: transparent;
}

.ms-logo-context-menu-separator {
    height: 1px;
    background: #444;
    margin: 6px 0;
}

.ms-logo-context-menu-header {
    padding: 10px 16px;
    color: #f07727;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid #444;
    margin-bottom: 4px;
}

.ms-logo-context-menu-version {
    padding: 6px 16px;
    color: #888;
    font-size: 11px;
}

.ms-logo-context-menu-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
}

/* About Dialog */
.ms-about-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
}

.ms-about-content {
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 8px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.ms-about-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #333;
}

.ms-about-header h3 {
    margin: 0;
    color: #f07727;
    font-size: 16px;
    font-weight: 600;
}

.ms-about-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.ms-about-close:hover {
    color: #fff;
}

.ms-about-body {
    padding: 24px;
    text-align: center;
}

.ms-about-logo {
    height: 60px;
    margin-bottom: 12px;
}

.ms-about-logo-text {
    font-size: 48px;
    font-weight: bold;
    color: #f07727;
    margin-bottom: 12px;
}

.ms-about-version {
    font-size: 14px;
    color: #888;
    margin-bottom: 16px;
}

.ms-about-description {
    color: #ccc;
    font-size: 14px;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.ms-about-libraries {
    text-align: left;
    font-size: 12px;
    color: #888;
    border-top: 1px solid #333;
    padding-top: 16px;
    margin-top: 16px;
}

.ms-about-libraries strong {
    color: #aaa;
}

.ms-about-libraries ul {
    margin: 10px 0 0 0;
    padding-left: 20px;
    columns: 2;
    column-gap: 20px;
}

.ms-about-libraries li {
    margin: 6px 0;
    break-inside: avoid;
}

.ms-about-libraries a {
    color: #f07727;
    text-decoration: none;
}

.ms-about-libraries a:hover {
    text-decoration: underline;
}

.ms-about-libraries-link,
.ms-about-libraries-link:visited,
.ms-about-libraries-link:active {
    color: #f07727;
    text-decoration: none;
    font-size: 13px;
    display: inline-block;
    margin-top: 8px;
}

.ms-about-libraries-link:hover {
    color: #f07727;
    text-decoration: underline;
}

.ms-libraries-body {
    text-align: left;
}

.ms-libraries-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ms-libraries-list li {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #333;
    font-size: 13px;
}

.ms-libraries-list li:last-child {
    border-bottom: none;
}

.ms-libraries-list a {
    color: #f07727;
    text-decoration: none;
    font-weight: 500;
    min-width: 100px;
}

.ms-libraries-list a:hover {
    text-decoration: underline;
}

.ms-libraries-list span {
    color: #aaa;
    flex: 1;
    margin-left: 12px;
}

.ms-libraries-list em {
    color: #666;
    font-style: normal;
    font-size: 11px;
    background: #2a2a2a;
    padding: 2px 8px;
    border-radius: 3px;
}

.ms-about-copyright {
    font-size: 11px;
    color: #666;
    margin-top: 12px;
}

.ms-about-footer {
    padding: 16px 20px;
    border-top: 1px solid #333;
    text-align: center;
}

.ms-about-btn {
    background: #f07727;
    color: #fff;
    border: none;
    padding: 10px 32px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.ms-about-btn:hover {
    background: #e06617;
}

.breadcrumb-separator {
    color: #666;
    font-size: 20px;
}

.app-logo {
    font-size: 20px;
    font-weight: bold;
    color: #ccc;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* App Navigation */
.app-navigation {
    display: flex;
    gap: 8px;
    margin-right: auto;
}

.app-nav-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 12px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #555;
    color: #ccc;
    position: relative;
    flex-shrink: 0;
}

.app-nav-btn:hover:not(:disabled) {
    background: #666;
    color: #fff;
    transform: translateY(-2px);
}

.app-nav-btn.active {
    background: #f07727;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(240, 119, 39, 0.5);
}

.app-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #2a2a2a;
    color: #666;
}

.app-nav-btn:disabled:hover {
    transform: none;
    background: #2a2a2a;
}

/* Suite-specific Button Styles - Matching Mapping Slayer */
.slayer-header .btn {
    padding: 4px 4px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    font-size: 9px;
}

.slayer-header .btn-primary {
    background: #f07727;
    color: #ffffff;
}

.slayer-header .btn-primary:hover {
    background: #e55a00;
}

.slayer-header .btn-primary:disabled {
    background: #444;
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

.slayer-header .btn-secondary {
    background: #6c757d;
    color: white;
}

.slayer-header .btn-secondary:hover {
    background: #5a6268;
}

.slayer-header .btn-compact {
    padding: 3px 5px;
    font-size: 9px;
}

/* Welcome Screen */
.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #1b1c1d;
    color: #ffffff;
    text-align: center;
}

.welcome-header {
    text-align: center;
    margin-bottom: 60px;
}

.welcome-title {
    font-size: 48px;
    font-weight: bold;
    color: #f07727;
    margin-bottom: 20px;
}

.welcome-subtitle {
    font-size: 24px;
    color: #ccc;
    margin-bottom: 0;
}

/* Project Info in Header */
.project-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 10px;
    color: #aaa;
    margin-right: 15px;
}

.project-name {
    font-weight: bold;
    color: #ccc;
    margin-bottom: 2px;
}

.autosave-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

.autosave-container input[type='checkbox'] {
    width: 12px;
    height: 12px;
    cursor: pointer;
    margin: 0;
}

.autosave-container label {
    cursor: pointer;
    color: #aaa;
    margin: 0;
    font-size: 10px;
}

/* Marker Type Context Menu */
.ms-marker-type-context-menu {
    position: fixed;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 6px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 10001;
    min-width: 180px;
    font-size: 13px;
}

.ms-context-menu-item {
    padding: 8px 16px;
    color: #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.ms-context-menu-item:hover {
    background: #3a3a3a;
    color: #fff;
}

.ms-context-menu-item span {
    font-size: 14px;
}

.ms-context-menu-divider {
    height: 1px;
    background: #444;
    margin: 6px 0;
}

/* Template Modal Styles */
.ms-template-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
    z-index: 10001;
    width: 338px;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.ms-template-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ms-template-header {
    background: #1e1e1e;
    padding: 8px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
}

.ms-template-title {
    color: #fff;
    font-size: 10px;
    font-weight: bold;
}

.ms-template-title #template-marker-type {
    color: #f07727;
}

.ms-template-controls {
    display: flex;
    gap: 8px;
}

.ms-template-btn {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid #555;
    background: #333;
    color: #ccc;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ms-template-btn:hover {
    background: #444;
    border-color: #666;
}

.ms-template-add-btn {
    background: #2d4f2d;
    border-color: #3a5f3a;
}

.ms-template-add-btn:hover {
    background: #3a5f3a;
    border-color: #4a6f4a;
}

.ms-template-remove-btn {
    background: #4f2d2d;
    border-color: #5f3a3a;
}

.ms-template-remove-btn:hover {
    background: #5f3a3a;
    border-color: #6f4a4a;
}

.ms-template-close-btn {
    background: #333;
    border-color: #555;
}

.ms-template-close-btn:hover {
    background: #c82333;
    border-color: #c82333;
    color: white;
}

.ms-template-create-btn-header {
    height: 18px;
    padding: 0 8px;
    border-radius: 3px;
    border: 1px solid #f07727;
    background: #f07727;
    color: #fff;
    cursor: pointer;
    font-size: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    white-space: nowrap;
}

.ms-template-create-btn-header:hover {
    background: #d96b1f;
    border-color: #d96b1f;
}

.ms-template-body {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    background: #1e1e1e;
}

/* Drag-and-drop visual feedback for template import */
.ms-template-body.drag-over {
    background: rgba(240, 119, 39, 0.15);
}

.ms-template-body.drag-over .ms-template-preview {
    border-color: #f07727;
    box-shadow: 0 0 10px rgba(240, 119, 39, 0.3);
}

.ms-template-preview {
    min-height: 200px;
    background: #2a2a2a;
    border: 2px dashed #444;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ms-template-display {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ms-template-placeholder {
    color: #666;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.ms-template-info {
    margin-top: 8px;
    padding: 5px;
    background: #2a2a2a;
    border-radius: 4px;
    border: 1px solid #444;
}

.ms-template-filename {
    color: #f07727;
    font-size: 9px;
    margin-bottom: 3px;
}

.ms-template-details {
    color: #999;
    font-size: 8px;
}

.ms-template-actions {
    margin-top: 10px;
    display: flex;
    justify-content: center;
}

.ms-template-create-btn {
    padding: 12px 32px;
    background: #f07727;
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.5px;
}

.ms-template-create-btn:hover {
    background: #ff8838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(240, 119, 39, 0.4);
}

.ms-template-create-btn:active {
    transform: translateY(0);
}

/* Sign Preview Modal Styles - Matches Gallery Modal Styling */
.ms-sign-preview-modal {
    position: absolute;
    z-index: 10002 !important; /* Above edit modal backdrop */
    width: 380px;
    display: none;
}

.ms-sign-preview-modal.ms-visible {
    display: block;
}

.ms-sign-preview-content {
    background: #2a2a2a;
    border: 2px solid #444;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 400px;
    overflow: hidden;
}

.ms-sign-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #333333;
    border-bottom: 1px solid #444;
    border-radius: 6px 6px 0 0;
}

.ms-sign-preview-title {
    font-size: 20px;
    font-weight: bold;
    color: #f07727;
}

.ms-sign-preview-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
    gap: 15px;
    overflow: hidden;
}

.ms-sign-preview-display {
    flex: 1;
    background: white;
    border: 1px solid #555;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.ms-sign-preview-display svg {
    max-width: 100%;
    height: auto;
}

.ms-sign-preview-placeholder {
    color: #333;
    font-size: 24px;
    font-weight: bold;
}

/* Thumbnail Viewer Panel */
.ms-thumbnail-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1b1c1d;
    z-index: 9999;
    flex-direction: column;
}

.ms-thumbnail-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #2a2a2a;
    border-bottom: 2px solid #444;
}

.ms-thumbnail-viewer-title {
    font-size: 24px;
    font-weight: bold;
    color: #f07727;
}

.ms-thumbnail-viewer-tabs-wrapper {
    display: flex;
    background: #2a2a2a;
    border-bottom: 2px solid #444;
}

.ms-thumbnail-viewer-tabs {
    display: flex;
    gap: 2px;
    padding: 0 20px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.ms-thumbnail-viewer-tabs::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.ms-thumbnail-viewer-tabs-nav {
    display: flex;
    gap: 2px;
    padding: 0 10px;
    align-items: center;
}

.ms-thumbnail-viewer-nav-btn {
    width: 24px;
    height: 24px;
    background: #444;
    color: #888;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition:
        background 0.2s,
        color 0.2s;
}

.ms-thumbnail-viewer-nav-btn:hover {
    background: #555;
    color: #fff;
}

.ms-thumbnail-viewer-tab {
    padding: 6px 12px;
    background: #333;
    color: #888;
    border: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    transition:
        background 0.2s,
        color 0.2s;
}

.ms-thumbnail-viewer-tab:hover {
    background: #444;
    color: #fff;
}

.ms-thumbnail-viewer-tab.active {
    background: #1b1c1d;
    color: #f07727;
}

.ms-thumbnail-viewer-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    color: #888;
    font-size: 18px;
}

.ms-thumbnail-viewer-body.empty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ms-thumbnail-viewer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    width: 100%;
}

.ms-thumbnail-card {
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

/* Updated indicator - orange border that shows thumbnail was just edited */
.ms-thumbnail-card.ms-thumbnail-updated {
    border-color: #f07727;
    box-shadow: 0 0 8px rgba(240, 119, 39, 0.5);
}

.ms-thumbnail-card-header {
    font-size: 11px;
    color: #888;
    margin-bottom: 8px;
    text-align: center;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.ms-thumbnail-card-location {
    font-weight: bold;
    color: #f07727;
}

.ms-thumbnail-flags {
    display: flex;
    gap: 2px;
    align-items: center;
}

.ms-thumbnail-flag {
    font-size: 10px;
    line-height: 1;
}

.ms-thumbnail-flag img {
    width: 12px;
    height: 12px;
    object-fit: contain;
}

/* Installed indicator - green diagonal line across thumbnail */
.ms-thumbnail-card.ms-thumbnail-installed .ms-thumbnail-card-preview {
    position: relative;
}

.ms-thumbnail-card.ms-thumbnail-installed .ms-thumbnail-card-preview::after {
    content: '';
    position: absolute;
    width: 141%;
    height: 3px;
    background: #00ff00;
    transform: rotate(-45deg);
    top: 50%;
    left: 50%;
    margin-left: -70.5%;
    margin-top: -1.5px;
    pointer-events: none;
    z-index: 10;
}

/* Sort context menu for thumbnail viewer tabs */
.ms-sort-context-menu {
    position: fixed;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 140px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.ms-sort-menu-title {
    padding: 6px 12px;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ms-sort-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: #ddd;
    transition: background 0.15s;
}

.ms-sort-menu-item:hover {
    background: #3a3a3a;
}

.ms-sort-menu-item.active {
    color: #f07727;
}

.ms-sort-menu-item.active::before {
    content: '✓ ';
}

.ms-sort-menu-divider {
    height: 1px;
    background: #444;
    margin: 4px 0;
}

.ms-thumbnail-card-preview {
    width: 100%;
    background: #1b1c1d;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    overflow: hidden;
}

.ms-thumbnail-card-preview svg {
    max-width: 100%;
    max-height: 150px;
    height: auto;
}

/* No template placeholder */
.ms-thumbnail-no-template {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #888;
    font-size: 11px;
    padding: 15px 10px;
    min-height: 80px;
}

/* Thumbnail Edit Modal */
.ms-thumbnail-edit-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10001;
    align-items: center;
    justify-content: center;
}

.ms-thumbnail-edit-content {
    background: #2a2a2a;
    border: 2px solid #444;
    border-radius: 8px;
    width: 500px;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
}

.ms-thumbnail-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #444;
}

.ms-thumbnail-edit-title {
    font-size: 16px;
    font-weight: bold;
    color: #f07727;
}

.ms-thumbnail-edit-location {
    font-size: 14px;
    color: #888;
}

.ms-thumbnail-edit-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.ms-thumbnail-edit-preview {
    background: #1b1c1d;
    border: 1px solid #444;
    border-radius: 4px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.ms-thumbnail-edit-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ms-thumbnail-edit-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 15px;
    border-top: 1px solid #444;
}

/* Thumbnail Export Popup */
.ms-thumbnail-export-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10002;
    align-items: center;
    justify-content: center;
}

.ms-thumbnail-export-content {
    background: #2a2a2a;
    border: 2px solid #444;
    border-radius: 8px;
    width: 350px;
    max-width: 90%;
}

.ms-thumbnail-export-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #444;
}

.ms-thumbnail-export-title {
    font-size: 16px;
    font-weight: bold;
    color: #f07727;
}

.ms-thumbnail-export-type {
    font-size: 12px;
    color: #888;
}

.ms-thumbnail-export-body {
    padding: 15px;
}

.ms-thumbnail-export-row {
    display: flex;
    gap: 10px;
}

.ms-thumbnail-export-row .ms-form-group {
    flex: 1;
}

.ms-thumbnail-export-row .ms-form-input {
    width: 100%;
    text-align: center;
}

.ms-thumbnail-export-info {
    margin-top: 12px;
    padding: 10px;
    background: #1b1c1d;
    border-radius: 4px;
    font-size: 12px;
    color: #888;
    text-align: center;
}

.ms-thumbnail-export-option {
    margin-top: 12px;
    padding: 10px 0;
}

.ms-thumbnail-export-option .ms-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #ccc;
}

.ms-thumbnail-export-option .ms-checkbox-label input[type='checkbox'] {
    width: 16px;
    height: 16px;
    accent-color: #4caf50;
    cursor: pointer;
}

.ms-thumbnail-export-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 15px;
    border-top: 1px solid #444;
}

/* ===========================================
   TABLET/MOBILE VIEWPORT FIX
   Accounts for browser chrome on tablets/phones
   =========================================== */

/* Use dvh (dynamic viewport height) where supported, fallback to vh */
@supports (height: 100dvh) {
    .ms-app-container {
        height: calc(100dvh - 60px);
    }

    .slayer-app-container {
        height: 100dvh;
    }
}

/* ===========================================
   SPLIT MESSAGE MODAL
   =========================================== */

#mapping-slayer-split-message-modal {
    z-index: 10010 !important; /* Above edit modal and its backdrop */
}

#mapping-slayer-split-message-modal .ms-modal-content {
    max-width: 450px;
    min-height: 320px; /* Prevent size jumping when preview shows */
}

.ms-split-link {
    color: #ff9800;
    font-size: 11px;
    font-weight: normal;
    cursor: pointer;
    margin-left: 4px;
}

.ms-split-link:hover {
    color: #ffb74d;
    text-decoration: underline;
}

.ms-split-message-container {
    margin: 15px 0;
}

.ms-split-message-text {
    background: #2a2b2c;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 12px 15px;
    font-size: 14px;
    color: #fff;
    min-height: 40px;
    user-select: text;
    cursor: text;
    line-height: 1.5;
}

.ms-split-message-text::selection {
    background: #ff9800;
    color: #000;
}

.ms-split-preview {
    background: #1e1f20;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 12px;
    margin: 15px 0;
    min-height: 76px; /* Reserve space so modal doesn't jump */
}

.ms-split-preview-row {
    display: flex;
    margin-bottom: 8px;
}

.ms-split-preview-row:last-child {
    margin-bottom: 0;
}

.ms-split-preview-label {
    color: #888;
    font-size: 12px;
    min-width: 120px;
}

.ms-split-preview-value {
    color: #fff;
    font-size: 12px;
    font-weight: 500;
}

.ms-split-result {
    margin-top: 15px;
    padding: 10px;
    background: #1e1f20;
    border-radius: 4px;
    font-size: 13px;
}

/* Button state modifiers for split modal */
.ms-btn-warning {
    background: #ff9800 !important;
    color: #000 !important;
    border-color: #ff9800 !important;
}

.ms-btn-warning:hover {
    background: #ffb74d !important;
    border-color: #ffb74d !important;
}

.ms-btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Save As Bounce Arrow */
.save-as-wrapper {
    position: relative;
    display: inline-block;
}

.ms-save-bounce-arrow {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    animation: ms-bounce-arrow 0.6s ease-in-out infinite;
}

.ms-save-bounce-arrow.visible {
    display: block;
}

@keyframes ms-bounce-arrow {
    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-8px);
    }
}
