:root {
    --controls-offset: 0px;
    --nameLen: 25;
    --slider-value: 0%;
    --slider-fill: #888;
    --selected-bg: #90ee90;
    --column-selected-bg: #a5d6a7;
    --nuc-selected-bg: #ffff00;
    --tooltip-bg: white;
    --tooltip-border: #ccc;
    --modal-bg: #fefefe;
    --modal-border: #888;
    --dropzone-bg: #f0f8ff;
    --dropzone-hover-bg: #e0f0ff;
    --dropzone-border: #1a2129;
    --dropzone-hover-border: #004c99;
    --control-bg: white;
    --button-bg: white;
    --button-hover-bg: #e6f3ff;
    --button-border: #ccc;
    --block-sep-bg: #f0f0f0;
    --error-bg: #ffe6e6;
    --error-border: #ff8080;
    --search-hit-bg: yellow;
    /* shading defaults (can be overridden by JS color-pickers) */
    --blackShading: #000;
    --darkShading: #555;
    --lightShading: #ccc;
    --blackText: white;
}
#dropZone {
    border: 2px dashed var(--dropzone-border);
    border-radius: 4px;
    padding: 12px;
    text-align: center;
    color: #555;
    font-size: 14px;
    background: var(--dropzone-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    transition: all 0.2s;
}
#dropZone small {
    font-size: 11px;
    color: #777;
    margin-top: 4px;
}
#dropZone:hover {
    border-color: var(--dropzone-hover-border);
    background: var(--dropzone-hover-bg);
}
#controls {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--control-bg);
    padding: 1px 4px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 12px;
    border-bottom: 0;
    z-index: 100;
}
.status-row {
    background: var(--control-bg);
    padding: 2px 4px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    min-height: 18px;
}

.header-info-row {
    justify-content: flex-end;
    padding-top: 1px;
    padding-bottom: 2px;
}

.control-row {
    display: flex;
    gap: 3px;
    align-items: center;
    width: 100%;
    flex-wrap: nowrap;
    position: relative;
    padding-top: 5px;
}

.control-row.justify-center {
    justify-content: center;
}

.wide-section {
    width: 100%;
}
.menu-section {
    position: relative;
    display: inline-block;
    z-index: 10;
    /* Ensure this contains the absolutely positioned dropdown */
    isolation: isolate;
}

/* Input section needs higher z-index to appear above seq-names */
#input-section {
    z-index: 200;
}

.standard-menu-group {
    display: flex;
    justify-content: center;
    gap: 3px;
}

.side-section {
    display: inline-block;
    vertical-align: middle;
    flex: 0 0 auto;
    max-width: none;
    min-width: 0;
    box-sizing: border-box;
    overflow: visible; /* allow dropdowns to overflow outside the side section */
}

.standard-menu-group {
    flex: 1 1 auto; /* center group grows and shrinks as needed */
    display: flex;
    justify-content: center;
    gap: 10px;
    align-items: center;
    min-width: 220px;
}

/* Prevent side-section headers from stretching full width */
.side-section .section-header {
    display: inline-flex;
    width: auto;
}

/* Ensure all menu headers are inline so they don't stretch full width */
.menu-section .section-header {
    display: inline-flex;
    width: auto;
}

/* Make sure control-group absolute positioning lines up under its header only */
.side-section .control-group {
    left: 0;
    min-width: 0;
}

/* For side sections (Input/Actions) allow dropdowns to be wider than the small header
   and align them so they don't get clipped: input dropdown aligns left, actions aligns right. */
/* Fix Input menu z-index to appear above sticky sequence names */
.menu-section.side-section#input-section .control-group {
    left: 0;
    right: auto;
    min-width: 260px;
    padding: 15px; /* Increase padding for better hover area */
    z-index: 99999; /* Very high to ensure it's above seq-names (z-index: 100) */
}

/* Increase hover area for Input section to prevent gaps */
.menu-section.side-section#input-section::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: -5px; /* Extend below to cover gap */
    z-index: 9997;
    pointer-events: none;
}

/* Ensure control-groups inside side-sections are visible outside the parent */
.side-section .control-group {
    overflow: visible;
}

.section-header {
    padding: 1px 4px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    cursor: pointer;
    user-select: none;
    font-weight: bold;
    border-radius: 4px 4px 0 0;
    font-size: 9px;
    margin: 0;
    color: #2c3e50;
    height: 14px;
    line-height: 14px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.section-header:hover {
    background: #e0e0e0;
}

.control-group {
    position: absolute;
    top: calc(100% - 1px);
    left: 0;
    width: auto;
    min-width: 200px; /* Ensure minimum width for content */
    max-width: 400px;
    background: #ffffff;
    border: 1px solid #ccc;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    padding: 15px; /* Increased padding for better hover area */
    display: none;
    z-index: 9999;
    border-radius: 0 4px 4px 4px;
    margin: 0;
    max-height: 85vh; /* Increased to prevent scrollbar for typical menus */
    overflow-y: auto; /* Only vertical scrolling when truly needed */
    overflow-x: visible; /* Allow horizontal content to be visible */
    will-change: display;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Reduce padding for shade controls to fit without scrollbar */
#shade-controls {
    padding: 6px 6px;
    overflow-y: visible;
    max-height: none;
}

/* Show control groups on hover */
.menu-section:hover .control-group,
.section-header:hover + .control-group,
.control-group:hover {
    display: block !important;
}

/* Prevent menu from closing when interacting with inputs inside */
.control-group input,
.control-group button,
.control-group textarea {
    pointer-events: auto;
}

/* Keep menu open when hovering anywhere in control-group area */
.menu-section:hover,
.menu-section:has(.control-group:hover) {
    z-index: 10001;
}

/* Show control groups when menu is open via JS (stable state) */
.menu-section.menu-open .control-group {
    display: block !important;
}

/* Add a larger invisible bridge to prevent hover breaking */
.menu-section:hover::after {
    content: '';
    position: absolute;
    top: 100%;
    left: -20px;
    right: -20px;
    height: 80px; /* Cover entire autocomplete popup area */
    z-index: 9998;
    pointer-events: auto; /* Allow interaction through bridge */
    background: transparent;
}

/* Keep bridge visible for open menus */
.menu-section.menu-open::after {
    content: '';
    position: absolute;
    top: 100%;
    left: -20px;
    right: -20px;
    height: 80px;
    z-index: 9998;
}

.color-picker {
    width: 30px;
    height: 20px;
    border: 1px solid #ccc;
    cursor: pointer;
    display: inline-block;
    margin: 2px;
}

.control-group label {
    display: inline-block;
    margin-right: 8px;
    font-size: 12px;
    min-width: 60px;
}

.control-group select,
.control-group input[type="number"],
.control-group input[type="text"] {
    font-size: 12px;
    padding: 2px 4px;
    border: 1px solid #ccc;
    border-radius: 3px;
    margin-right: 8px;
}

.control-group input[type="number"] {
    width: 60px;
}

/* Action sections organization */
.action-section {
    margin: 0;
    padding: 8px;
    border: none;
    border-radius: 0;
    background: transparent;
}

.action-section:first-child {
    margin-top: 0;
}

.action-section:last-child {
    margin-bottom: 0;
}

.action-section-label {
    font-size: 11px;
    font-weight: bold;
    color: #444;
    margin-bottom: 6px;
    padding: 3px 6px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    display: inline-block;
}

.button-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: center;
    font-size: 12px;
    width: min-content;
}

.button-spacer {
    width: 1px;
    height: 16px;
    background: #ccc;
    margin: 0 4px;
}

button {
    padding: 2px 6px;
    margin: 1px;
    font-size: 12px;
    border: 1px solid var(--button-border);
    border-radius: 3px;
    background: var(--button-bg);
    cursor: pointer;
}

button:hover {
    background: var(--button-hover-bg);
}
.slider-container {
    margin: 1px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    line-height: 22px;
}

/* Improved shade section alignment */
.shade-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    min-height: 28px;
}

.shade-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: auto;
    max-width: 180px;
}

.reset-button {
    padding: 1px 4px;
    font-size: 10px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    cursor: pointer;
    border-radius: 2px;
}

.reset-button:hover {
    background: #e0e0e0;
}

/* Improved search section alignment */
.search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 28px;
}

.search-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.search-button-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.display-slider-row {
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}
.slider-label {
    width: 70px;
    display: inline-block;
    text-align: right;
    font-weight: normal;
    white-space: nowrap;
}
input[type="range"].shading-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 130px;
    height: 22px;
    background: transparent;
    outline: none;
}
input[type="range"].shading-slider::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 4px;
    cursor: pointer;
    background: linear-gradient(to right, var(--slider-fill) 0%, var(--slider-fill) var(--slider-value), #e0e0e0 var(--slider-value), #e0e0e0 100%);
}
input[type="range"].shading-slider::-moz-range-track {
    height: 8px;
    border-radius: 4px;
    cursor: pointer;
    background: linear-gradient(to right, var(--slider-fill) 0%, var(--slider-fill) var(--slider-value), #e0e0e0 var(--slider-value), #e0e0e0 100%);
}
#blackSlider {
    --slider-fill: #000;
}
#darkSlider {
    --slider-fill: #555;
}
#lightSlider {
    --slider-fill: #ccc;
}
#groupConsensusThreshold {
    --slider-fill: #888;
}
input[type="range"].shading-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 14px;
    width: 8px;
    border: 2px solid black;
    border-radius: 2px;
    margin-top: -3px;
    cursor: pointer;
    background: white;
}
input[type="range"].shading-slider::-moz-range-thumb {
    height: 14px;
    width: 8px;
    border: 2px solid black;
    border-radius: 2px;
    cursor: pointer;
    background: white;
}
input[type="range"].normal-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 130px;
    min-width: 100px;
    height: 14px;
    background: transparent;
    outline: none;
}
input[type="range"].normal-slider::-webkit-slider-runnable-track {
    height: 7px;
    border-radius: 7px;
    background: linear-gradient(to right, #888 0%, #888 var(--slider-value), #e0e0e0 var(--slider-value), #e0e0e0 100%);
}
input[type="range"].normal-slider::-moz-range-track {
    height: 7px;
    border-radius: 7px;
    background: linear-gradient(to right, #888 0%, #888 var(--slider-value), #e0e0e0 var(--slider-value), #e0e0e0 100%);
}
input[type="range"].normal-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 8px;
    height: 14px;
    border: 2px solid black;
    border-radius: 2px;
    background: white;
    cursor: pointer;
    margin-top: -3px;
}
input[type="range"].normal-slider::-moz-range-thumb {
    width: 8px;
    height: 14px;
    border: 2px solid black;
    border-radius: 2px;
    background: white;
    cursor: pointer;
}
input[type="number"] {
    width: 32px;
    height: 18px;
    padding: 0;
    text-align: center;
    font-size: 12px;
}
.block-block {
    margin-bottom: 24px;
}
.block-sep {
    font-weight: bold;
    color: #666;
    text-align: center;
    margin: 4px 0;
    padding: 2px 0;
    background: var(--block-sep-bg);
    border-radius: 3px;
}
#alignmentContainer {
    position: static; /* flow in document under controls/status */
    margin: 0;
    padding: 2px 0.5rem 0 0.5rem;
    overflow-x: auto;
    overflow-y: auto;
    background: white;
    font-family: 'Courier New', monospace;
    line-height: 1.0;
    white-space: pre;
    border: 1px solid #ddd;
    border-top: 0;
    font-size: 13px;
    transition: font-size 0.1s;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    /* Instant scroll updates during drag to avoid jank */
    scroll-behavior: auto;
    z-index: 1; /* Ensure it's below the fixed menu (z-index: 1000) when menu appears */
}
/* Hide native horizontal scrollbar so only the custom bar is visible */
#alignmentContainer::-webkit-scrollbar:horizontal { height: 0; }
#alignmentContainer::-webkit-scrollbar { display: none; }
#alignmentContainer { -ms-overflow-style: none; scrollbar-width: none; }
    /* revert layout: seq-line stretches to container width */
.seq-line {
    display: flex;
    font-family: 'Courier New', monospace;
    line-height: 1.0;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    align-items: flex-start;
    position: relative;
    min-width: max-content;
    height: 1em;
}

/* Persistent tiny scrollbar area below the alignment */
.horizontal-scrollbar {
    width: 100%;
    height: 14px; /* Tiny persistent scrollbar */
    background: transparent; /* Remove yellow coloring to avoid visual glitch */
    border-top: 0;
    overflow-x: auto;
    overflow-y: hidden;
    position: sticky;
    bottom: 0;
    z-index: 50;
    box-sizing: content-box;
    cursor: grab;
    user-select: none;
    touch-action: pan-x;
}

.horizontal-scrollbar-thumb { height: 1px; }
.horizontal-scrollbar.grabbing { cursor: grabbing; }

/* Invisible larger hit area around the tiny bar */
.horizontal-scrollbar::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: -10px; bottom: -10px; /* 10px larger on both sides */
    /* Keep it transparent but receive pointer events */
    background: transparent;
    pointer-events: auto;
}

/* Utility to temporarily disable text selection during drag */
.no-select { user-select: none !important; }

/* Optional: ensure container stacks alignment and bar vertically */
#viewer-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: var(--controls-offset);
}
.seq-line.context-menu-highlight {
    background-color: rgba(255, 215, 0, 0.2);
    outline: 2px solid rgba(255, 215, 0, 0.5);
    outline-offset: -1px;
}

/* Drag reorder: indicator line in seq-name area only */
.seq-name.drag-insert-above {
    box-shadow: 0 -2px 0 0 #1976D2;
}
.seq-name.drag-insert-below {
    box-shadow: 0 2px 0 0 #1976D2;
}
/* Highlight the sequence(s) being dragged */
.seq-name.drag-source {
    background: #e3f2fd !important;
    color: #1565C0 !important;
}
.seq-name {
    flex: 0 0 auto;
    min-width: calc(var(--nameLen) * 1ch + 16px);
    width: calc(var(--nameLen) * 1ch + 16px);
    max-width: calc(var(--nameLen) * 1ch + 16px);
    text-align: left;
    padding: 0 4px 0 12px;
    margin-right: 0;
    margin-left: -12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bold;
    color: #333;
    background: white;
    cursor: default;
    position: sticky;
    left: -15px;
    z-index: 50;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    contain: style;
    line-height: 1.0;
}
.seq-name.static {
    position: static;
}
.seq-name:hover {
    background-color: #f0f0f0;
    color: #000;
}

body.row-reorder-active .seq-name:hover {
    background-color: white;
    color: #333;
}

body.row-reorder-active .seq-name.drag-source:hover {
    background: #e3f2fd !important;
    color: #1565C0 !important;
}
.seq-name.selected::before {
    content: '';
    position: absolute;
    left: -3px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #0066ff;
    border-radius: 2px;
}
.seq-data {
    flex: 1 1 auto;
    display: inline-block;
    white-space: nowrap;
    margin: 0;
    padding: 0;
    line-height: 1.0;
    cursor: default;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    overflow: visible;
}

.seq-length {
    display: inline-block;
    margin-left: 6px;
    padding: 0 4px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.85em;
    color: #666;
    font-weight: bold;
    vertical-align: baseline;
    line-height: 1.0;
}

.active-searches {
    display: none;
    margin-top: 4px;
    padding: 4px;
    background: #f8f8f8;
    border-radius: 3px;
    font-size: 11px;
    border: 1px solid #ddd;
}

.search-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 2px 4px 2px 0;
    padding: 2px 6px;
    background: white;
    border-radius: 3px;
    border: 1px solid #ccc;
}

.search-swatch {
    width: 12px;
    height: 12px;
    border: 1px solid #666;
    border-radius: 2px;
    flex-shrink: 0;
}

.search-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    margin-left: 2px;
}

.section-header {
    font-weight: bold;
    font-size: 10px;
    margin: 0;
    padding: 1px 4px;
    background: #f0f0f0;
    border-radius: 4px 4px 0 0;
    border: 1px solid #ccc;
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 14px;
    line-height: 14px;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.section-header span {
    white-space: nowrap;
}

#controls .control-row > div[style*="margin-left: auto"] {
    flex: 0 0 auto;
    min-width: 220px;
    max-width: 55vw;
    white-space: nowrap !important;
}

#headerInfoPanel {
    flex: 0 1 auto;
    min-width: 0;
    max-width: min(44vw, 780px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 1px;
    padding-right: 8px;
    padding-left: 14px;
    pointer-events: none;
}

#actions-section {
    flex: 0 0 auto;
}

#sourceInfo {
    flex: 0 0 auto;
    min-width: 0;
    max-width: 100%;
    line-height: 1.1;
    pointer-events: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    font-size: 11px;
    color: #555;
}

.header-info-row {
    justify-content: flex-end;
    padding-top: 0;
    padding-bottom: 2px;
    min-height: 16px;
}

#sourcePathLine {
    max-width: min(72vw, 1200px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    font-size: 10px;
    color: #999;
    font-family: 'Courier New', monospace;
    pointer-events: auto;
}

#sourceInfo .source-file-name,
#sourceInfo .source-inline-path {
    font-size: 10px;
    color: #999;
    font-family: 'Courier New', monospace;
    pointer-events: auto;
    cursor: copy;
}

#sourceInfo .source-file-name {
    font-size: 11px;
    color: #555;
    font-family: inherit;
}

#versionIndicator {
    font-size: 9px;
    color: #bbb;
    line-height: 1;
    text-align: right;
    white-space: nowrap;
    flex: 0 0 auto;
}

body.suppress-menu-hover .menu-section:hover .control-group,
body.suppress-menu-hover .section-header:hover + .control-group,
body.suppress-menu-hover .control-group:hover,
body.suppress-menu-hover .menu-section.menu-open .control-group {
    display: none !important;
}

.section-header:hover {
    background: #e0f0ff;
}

.section-header .toggle-icon {
    font-size: 10px;
    color: #666;
    transition: transform 0.2s;
    margin-left: 4px;
}

.section-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.control-group {
    background: #ffffff;
}

/* Reset any problematic styling in menu items */
.control-group .slider-container {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0;
    height: auto;
}

.control-group .shade-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    height: auto;
}

.control-group.collapsed {
    display: none !important;
}

.search-remove:hover {
    color: #666;
}

.seq-data span {
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    display: inline-block;
    vertical-align: top;
    margin: 0;
    padding: 0;
    line-height: 1.0;
    position: relative;
    z-index: 1;
}
.seq-data span.seq-length {
    margin-left: 8px !important;
}
.seq-data:active {
    cursor: grabbing;
}

.seq-data span:not(.nuc-selected):hover {
    cursor: default;
}
.black {
    background-color: var(--blackShading, #000) !important;
    color: var(--blackText, white) !important;
}
.dark {
    background-color: var(--darkShading, #555) !important;
    color: var(--darkText, white) !important;
}
.light {
    background-color: var(--lightShading, #ccc) !important;
    color: var(--lightText, black) !important;
}
.gap { background-color: white !important; color: #888 !important; }
.other { background-color: white; color: black; }
.ambiguous { color: #0000AA; font-weight: bold; }
.artifact {
    color: red !important;
    background-color: #ffe6e6 !important;
    font-weight: bold !important;
}
.selected .seq-name {
    background-color: var(--selected-bg) !important;
    color: #000 !important;
    font-weight: bold;
}
.selected .seq-data span {
    background-color: #e0ffe0 !important;
    color: black !important;
}

/* Column highlight: left and right pseudo-element bars only, no horizontal lines */
span.column-highlighted {
    position: relative;
}

span.column-highlighted::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(52, 152, 219, 0.9);
    pointer-events: none;
}

span.column-highlighted::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(52, 152, 219, 0.9);
    pointer-events: none;
}

/* Column selected: highlight full background */
span.column-selected {
    background-color: var(--column-selected-bg) !important;
    color: #000 !important;
}

/* Row highlight: top and bottom pseudo-element bars, no width expansion */
.seq-line.highlighted-row {
    position: relative;
}

.seq-line.highlighted-row::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 1px;
    background: rgba(220, 53, 69, 0.9);
    pointer-events: none;
    z-index: 2;
}

.seq-line.highlighted-row::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: rgba(220, 53, 69, 0.9);
    pointer-events: none;
    z-index: 2;
}

.consensus-line {
    font-style: normal;
    color: #555;
    font-weight: bold;
}

.consensus-line.consensus-top {
    border-bottom: 1px solid #ccc;
    margin-bottom: 4px;
}

.consensus-line.consensus-bottom {
    border-top: 1px solid #ccc;
    margin-top: 4px;
}
.consensus-line .seq-name {
    color: #555;
    font-weight: bold;
    background: white !important;
    z-index: 11;
}
.consensus-line .seq-data span {
    opacity: 0.9;
    background-color: transparent !important;
    color: #555;
}

/* Trim region indicators in consensus */
.consensus-line .seq-data span.trim-left {
    background-color: #ff6b6b !important;
    color: white !important;
    opacity: 1 !important;
}

.consensus-line .seq-data span.trim-right {
    background-color: #4ecdc4 !important;
    color: white !important;
    opacity: 1 !important;
}
.error-message {
    color: red;
    font-weight: bold;
    padding: 10px;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    margin: 5px;
    border-radius: 4px;
}
.search-hit {
    background-color: var(--search-hit-bg) !important;
    color: black !important;
    font-weight: bold;
}
.tooltip {
    position: fixed;
    background: var(--tooltip-bg);
    color: black;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 200;
    display: none;
    border: 1px solid var(--tooltip-border);
    pointer-events: none;
}
/* Consensus frequency tooltip */
.tooltip.consensus-box {
    background: #222;
    color: #eee;
    font-size: 11px;
    padding: 6px 8px;
    border: 1px solid #444;
    border-radius: 5px;
    white-space: normal;
    max-width: 200px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    line-height: 1.25;
}
.tooltip.consensus-box .cov-row {
    font-weight: 600;
    margin-bottom: 4px;
    text-align: left;
}
.tooltip.consensus-box .freq-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin: 2px 0;
    font-family: monospace;
}
.tooltip.consensus-box .freq-row .base {
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    color: #fff;
    min-width: 24px;
    text-align: center;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.15);
}
.tooltip.consensus-box .freq-row .pct {
    flex: 0 0 40px;
    text-align: right;
}
.tooltip.consensus-box .freq-row .raw {
    flex: 0 0 40px;
    text-align: right;
    opacity: 0.7;
}
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}
.modal-content {
    background-color: var(--modal-bg);
    margin: 5% auto;
    padding: 20px;
    border: 1px solid var(--modal-border);
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 8px;
    font-family: Arial, sans-serif;
    line-height: 1.6;
}
.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
}
.modal h2, .modal h3 {
    color: #2c3e50;
}
.modal ul {
    margin: 10px 0;
    padding-left: 20px;
}
.zoom-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
    width: 60px;
    justify-content: space-between;
}
.zoom-button {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    padding: 0;
    border-radius: 50%;
    line-height: 18px;
    text-align: center;
    box-sizing: border-box;
}
.zoom-value {
    width: 30px;
    min-width: 30px;
    text-align: center;
    display: inline-block;
}
.mode-container {
    display: flex;
    align-items: center;
    gap: 6px;
}
.shade-mode-label {
    margin-right: 8px;
}
#statusMessage {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 1000;
    display: none;
}
#minimizeBar {
    display: none;
    position: sticky;
    top: 0;
    background: white;
    padding: 4px;
    text-align: center;
    cursor: pointer;
    border-bottom: 1px solid #ddd;
    z-index: 99;
    font-size: 12px;
    color: #555;
}

/* SSH mini-console */
#sshConsole {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 16px;
    width: 430px;
    max-width: calc(100vw - 32px);
    background: #1a1a1a;
    color: #ccc;
    border: 1px solid #555;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 11.5px;
    z-index: 9990;
    box-shadow: 0 4px 16px rgba(0,0,0,0.55);
}
#sshConsoleHeader {
    background: #2d2d2d;
    padding: 5px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 5px 5px 0 0;
    user-select: none;
}
#sshConsoleTitle { color: #9cdcfe; font-size: 11px; font-family: sans-serif; }
#sshConsoleHeader button {
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}
#sshConsoleHeader button:hover { color: #fff; }
#sshConsoleBody {
    padding: 7px 10px;
    max-height: 150px;
    overflow-y: auto;
}
.ssh-line       { margin: 1px 0; line-height: 1.5; white-space: pre-wrap; word-break: break-all; }
.ssh-line-ok    { color: #6ec16e; }
.ssh-line-err   { color: #e06c75; }
.ssh-line-info  { color: #9cdcfe; }
.ssh-line-plain { color: #ccc; }
.context-menu {
    position: absolute;
    background: white;
    border: 1px solid #ccc;
    padding: 5px;
    z-index: 1000;
}
.context-menu div {
    cursor: pointer;
    padding: 2px 5px;
}
.context-menu div:hover {
    background: #f0f0f0;
}
/* Make nucleotide selection always visible and not glitchy */
.seq-line.selected .seq-data span.nuc-selected,
.seq-data span.nuc-selected {
    background-color: #ffe600 !important; /* bright yellow */
    color: #222 !important;
    box-shadow: none !important; /* Remove box-shadow to fix edge glitch */
    border-radius: 2px; /* Optional: slightly rounded corners */
}

/* Scale ruler styling */
.scale-ruler-line {
    margin-bottom: 2px;
    height: 1em;
}

.scale-ruler-line .seq-name {
    /* Keep the name column visible but empty to maintain alignment */
    min-width: calc(var(--nameLen) * 1ch + 16px);
    width: calc(var(--nameLen) * 1ch + 16px);
    max-width: calc(var(--nameLen) * 1ch + 16px);
}

.scale-ruler-line .seq-data {
    font-family: 'Courier New', monospace;
    color: #666;
    padding: 0;
    white-space: pre;
    overflow: visible !important;
    display: inline-block;
    line-height: 1.0;
}

/* Hide horizontal scrollbar cross-browser */
#alignmentContainer::-webkit-scrollbar:horizontal {
    height: 0;
}
#alignmentContainer {
    -ms-overflow-style: none;  /* IE/Edge */
    scrollbar-width: none;     /* Firefox */
    overflow-x: auto;          /* Keep scrollable */
    overflow-y: auto;          /* Vertical scroll when needed */
}
#alignmentContainer::-webkit-scrollbar {
    display: none;             /* Chrome/Safari */
}

/* Remove page-wide vertical scrollbar */
/* Remove page-wide vertical scrollbar (allow normal scrolling) */
body {
    overflow: auto;
}

/* ============================================================================
   FULL-WINDOW DRAG AND DROP OVERLAY
   ============================================================================ */
.drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(59, 130, 246, 0.15);
    backdrop-filter: blur(4px);
    border: 4px dashed rgba(59, 130, 246, 0.5);
    z-index: 10000;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.drag-overlay.hidden {
    opacity: 0;
}

.drag-overlay.active {
    opacity: 1;
}

/* Diagnostic mutation highlighting */
span.diagnostic-mutation {
    font-weight: bold !important;
    cursor: help;
}
/* ============ BLAST UI STYLES ============ */

/* Search dialog */
.blast-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}
.blast-dialog {
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    max-width: 420px;
    width: 92%;
    max-height: 80vh;
    overflow-y: auto;
}
.blast-dialog-title {
    padding: 14px 16px;
    border-bottom: 1px solid #ddd;
    font-weight: bold;
    font-size: 13px;
}
.blast-dialog-content { padding: 16px; }

/* Results modal */
.blast-results-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}
.blast-results-dialog-text {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
    width: 92vw;
    max-width: 1100px;
    height: 82vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Title bar */
.blast-text-title-bar {
    padding: 10px 14px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.blast-close-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 2px 4px;
}
.blast-close-btn:hover { color: #000; }

/* Tab bar */
.blast-tab-bar {
    display: flex;
    border-bottom: 2px solid #ccc;
    flex-shrink: 0;
    background: #f5f5f5;
}
.blast-tab-btn {
    flex: 1;
    padding: 8px 6px;
    border: none;
    border-bottom: 3px solid transparent;
    background: none;
    cursor: pointer;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    color: #555;
    transition: background 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: -2px;
}
.blast-tab-btn:hover { background: #e8e8e8; }
.blast-tab-btn.active {
    background: #fff;
    border-bottom: 3px solid #2a7d2a;
    color: #000;
    font-weight: bold;
}

/* Content panes */
.blast-pane {
    display: none;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.blast-pane.active { display: flex; flex-direction: column; }

.blast-text-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.55;
    background: #fafafa;
    color: #222;
    white-space: pre;
    word-wrap: normal;
    margin: 0;
    tab-size: 4;
}

/* Override pane scroll — inner sections handle their own scroll */
.blast-pane { overflow: hidden; }

/* Summary section — fixed at top of each pane */
.blast-summary-section { flex-shrink:0; overflow-y:auto; max-height:38%; border-bottom:2px solid #ddd; padding:6px 14px 0; }
.blast-db-stats { font-family:'Courier New',monospace; font-size:11px; color:#555; margin-bottom:6px; }
.blast-summary-table { width:100%; border-collapse:collapse; font-family:'Courier New',monospace; font-size:11px; white-space:nowrap; }
.blast-summary-table thead th { background:#ececec; padding:4px 8px; text-align:left; border-bottom:2px solid #bbb; position:sticky; top:0; z-index:1; }
.blast-summary-table td { padding:3px 8px; border-bottom:1px solid #f0f0f0; cursor:pointer; vertical-align:middle; }
.blast-summary-table td.desc { white-space:normal; max-width:280px; word-break:break-word; }
.blast-summary-table .strand-plus  { color:#1a6b1a; font-weight:bold; }
.blast-summary-table .strand-minus { color:#8b0000; font-weight:bold; }
.blast-summary-row:hover td { background:#eef8ee; }

/* Scrollable hits section */
.blast-hits-section { flex:1; overflow-y:auto; min-height:0; }
.blast-hit { padding:10px 16px 4px; border-top:2px solid #e0e0e0; }
.blast-hit:first-child { border-top:none; }
.blast-hit-header { font-family:'Courier New',monospace; font-size:12px; font-weight:bold; color:#1a4a1a; margin-bottom:4px; word-break:break-word; }
.blast-hit-actions { display:flex; gap:6px; margin-bottom:6px; flex-wrap:wrap; }
.blast-copy-btn { padding:2px 10px; font-size:11px; cursor:pointer; border:1px solid #bbb; border-radius:3px; background:#f5f5f5; color:#333; white-space:nowrap; }
.blast-copy-btn:hover  { background:#e8f5e8; border-color:#4a9a4a; }
.blast-copy-btn.copied { background:#d0f0d0; border-color:#2a7d2a; color:#1a5a1a; }
.blast-hit-stats { font-family:'Courier New',monospace; font-size:11px; color:#444; margin-bottom:6px; line-height:1.7; }
.blast-hit-stats .stat-strand-plus  { color:#1a6b1a; font-weight:bold; }
.blast-hit-stats .stat-strand-minus { color:#8b0000; font-weight:bold; }
.blast-alignment-block { background:#f6f8f6; border:1px solid #ddd; border-radius:3px; padding:8px 12px; margin:0 0 8px; font-family:'Courier New',monospace; font-size:12px; line-height:1.5; white-space:pre; overflow-x:auto; }