: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);
}

/* Cross-browser: prevent iOS Safari text zoom on focus */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

#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: flex-start;
    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;
    display: flex;
    justify-content: flex-start;
    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;
}

/* Actions section: align dropdown to the right so it stays on-screen */
#actions-section .control-group,
.menu-section.menu-align-right .control-group {
    left: auto;
    right: 0;
    border-radius: 4px 0 4px 4px;
}

#actions-section .control-group {
    min-width: 300px;
    max-width: min(380px, calc(100vw - 12px));
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
}

#controls #actions-section.menu-open .control-group {
    display: flex !important;
    flex-direction: column;
}

#actions-controls .actions-menu-body {
    padding: 10px 10px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#actions-controls .action-section {
    margin: 0;
    padding: 8px 10px 10px;
    border: 1px solid #e4e8ed;
    border-radius: 6px;
    background: linear-gradient(180deg, #fcfdfe 0%, #f6f8fa 100%);
    box-sizing: border-box;
}

#actions-controls .action-section-label {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 8px;
    padding: 2px 0 2px 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #455a64;
    background: transparent;
    border: none;
    border-left: 3px solid #90a4ae;
    border-radius: 0;
}

#actions-controls .action-section-selection .action-section-label { border-left-color: #1976d2; color: #1565c0; }
#actions-controls .action-section-order .action-section-label { border-left-color: #7b1fa2; color: #6a1b9a; }
#actions-controls .action-section-editing .action-section-label { border-left-color: #ef6c00; color: #e65100; }
#actions-controls .action-section-columns .action-section-label { border-left-color: #00897b; color: #00695c; }
#actions-controls .action-section-analysis .action-section-label { border-left-color: #5c6bc0; color: #3949ab; }
#actions-controls .action-section-settings .action-section-label { border-left-color: #546e7a; color: #37474f; }

#actions-controls .button-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    width: 100%;
    align-items: stretch;
}

#actions-controls .action-section-order .button-group {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

#actions-controls .button-group button {
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 4px 6px;
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

#actions-controls .action-section-columns .button-group {
    grid-template-columns: 1fr;
}

.actions-menu-footer {
    flex-shrink: 0;
    padding: 8px 10px 10px;
    border-top: 1px solid #d8dee4;
    background: #eef1f4;
    box-sizing: border-box;
}

.actions-hide-menu-btn {
    display: block;
    width: 100%;
    margin: 0 !important;
    padding: 6px 10px !important;
    font-size: 11px !important;
    font-weight: 600;
    color: #37474f;
    background: #fff !important;
    border: 1px solid #b0bec5 !important;
    border-radius: 4px;
    box-sizing: border-box;
}

.actions-hide-menu-btn:hover {
    background: #eceff1 !important;
    border-color: #78909c !important;
}

/* Ensure control-groups inside side-sections are visible outside the parent */
.side-section .control-group {
    overflow: visible;
}

.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;
}

/* Top menu dropdowns are JS-controlled to avoid overlap when switching sections */
#controls .menu-section.menu-open .control-group {
    display: block !important;
}

/* Prevent menu from closing when interacting with inputs inside */
.control-group input,
.control-group button,
.control-group textarea {
    pointer-events: auto;
}

/* Detachable panel: a dedicated drag handle (grip + title) at the top of a
   control-group. Deliberately its own element with no other function, so
   pressing and dragging anywhere on it can never collide with a real
   control. See makeControlGroupDetachable() in script.js. */
.panel-detach-handle {
    cursor: grab;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: bold;
    color: #555;
    padding: 5px 10px;
    margin: -15px -15px 8px -15px;
    background: #f2f4f6;
    border-bottom: 1px solid #ddd;
    border-radius: 3px 3px 0 0;
}
.panel-detach-handle:active {
    cursor: grabbing;
}
.panel-detach-grip {
    letter-spacing: -2px;
    color: #999;
}
.panel-dock-btn {
    display: none;
    margin-left: auto;
    font-size: 10px;
    font-weight: normal;
    color: #2a6fb0;
    cursor: pointer;
    padding: 1px 6px;
    border: 1px solid #bcd4ec;
    border-radius: 3px;
    background: #eaf2fb;
}
.panel-dock-btn:hover {
    background: #dcebfa;
}
/* While detached, ignore the hover-driven open/close machinery entirely -
   fixed positioning + explicit display, independent of .menu-open. */
.control-group.detached {
    position: fixed !important;
    display: block !important;
    z-index: 100000 !important;
    max-height: 85vh;
}
.control-group.detached .panel-dock-btn {
    display: inline-block;
}

/* Raise active menu above neighbours */
#controls .menu-section.menu-open,
.menu-section:has(.control-group:hover),
.menu-section.hover-active {
    z-index: 10001;
}

/* Invisible bridge between header and dropdown to prevent hover gaps */
#controls .menu-section.menu-open::after {
    content: '';
    position: absolute;
    top: 100%;
    left: -20px;
    right: -20px;
    height: 80px; /* Cover entire autocomplete popup area */
    z-index: 9998;
    pointer-events: auto;
    background: transparent;
}

.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);
}

.edit-toggle-button {
    height: 14px;
    line-height: 12px;
    padding: 0 6px;
    margin-left: 4px;
    font-size: 9px;
    font-weight: bold;
    border: 1px solid #aaa;
    border-radius: 3px;
    background: #f7f7f7;
    color: #333;
    vertical-align: middle;
}

.edit-toggle-button.active {
    background: #d8ecff;
    border-color: #2f73b7;
    color: #123f66;
}

.edit-tool-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
    padding: 2px 6px 3px 6px;
    border-top: 1px solid #d8e4ef;
    background: #f8fbfd;
    min-height: 24px;
    box-sizing: border-box;
}

.edit-tool-panel[hidden] {
    display: none !important;
}

.edit-tool-button,
.edit-command-button {
    height: 20px;
    padding: 1px 6px;
    margin: 0;
    font-size: 11px;
    line-height: 16px;
    white-space: nowrap;
}

.edit-tool-button.active {
    background: #cce5ff;
    border-color: #2f73b7;
    color: #103f66;
    box-shadow: inset 0 0 0 1px rgba(47, 115, 183, 0.25);
}

.edit-live-conservation {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 20px;
    margin: 0 1px 0 3px;
    font-size: 11px;
    line-height: 16px;
    color: #31485c;
    white-space: nowrap;
}

.edit-live-conservation input {
    width: 13px;
    height: 13px;
    margin: 0;
}

/* Tree modal toolbar */
.tree-tool {
    height: 18px;
    min-width: 20px;
    padding: 0 5px;
    font-size: 11px;
    line-height: 16px;
    border: 1px solid #c5d2df;
    border-radius: 3px;
    background: #f7f9fb;
    color: #31485c;
    cursor: pointer;
}

.tree-tool:hover {
    background: #e8f0fe;
    color: #103f66;
}

.tree-mode {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.tree-mode input {
    margin: 0;
}

/* Busy indicator for operations that hold the main thread. Deliberately covers the page:
   the viewer genuinely cannot be used while these run, and a dimmed page says so more
   honestly than a small spinner that invites clicking. */
#busyOverlay {
    position: fixed;
    inset: 0;
    z-index: 10060;
    background: rgba(255, 255, 255, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
}

#busyOverlay[hidden] {
    display: none;
}

#busyPanel {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 460px;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid #c5d2df;
    border-radius: 6px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
    font-size: 13px;
    color: #22303c;
}

#busySpinner {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    border: 2px solid #d7e2ee;
    border-top-color: #2f73b7;
    border-radius: 50%;
    animation: busySpin 0.8s linear infinite;
}

@keyframes busySpin {
    to { transform: rotate(360deg); }
}

#busyLabel {
    font-weight: 600;
}

#busyDetail {
    margin-top: 3px;
    font-size: 11px;
    color: #6b8299;
}

#busyDetail[hidden] {
    display: none;
}

#treeSvgOutput {
    margin: 0 0 8px;
}

/* Drag the bottom-right corner to make the tree box taller; it redraws to fit.
   The browser's native resize grip there is small and easy to miss against a plain
   white corner, so an explicit diagonal-stripe affordance marks the drag target. */
#treeSvgCanvas {
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    padding: 6px;
    height: 52vh;
    min-height: 180px;
    overflow: auto;
    resize: vertical;
    position: relative;
    /* Click-drag panning shouldn't trigger native browser text selection
       on the SVG leaf labels (was showing as blue selection highlight). */
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}
#treeSvgCanvas::after {
    content: '';
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 11px;
    height: 11px;
    pointer-events: none;
    background: repeating-linear-gradient(
        135deg,
        #b9c3cc 0px, #b9c3cc 1.5px,
        transparent 1.5px, transparent 4px
    );
}

#treeSvgCanvas .tree-branch-hit,
#treeSvgCanvas .tree-node-hit {
    cursor: pointer;
}

/* Full screen: lift the panel out of the modal and give it the whole window. */
#treeSvgOutput.tree-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 10050;
    margin: 0;
    padding: 10px 12px 12px;
    background: #fff;
    display: flex;
    flex-direction: column;
}

#treeSvgOutput.tree-fullscreen #treeSvgCanvas {
    flex: 1 1 auto;
    height: auto;
    max-height: none;
    resize: none;
}

/* Undo/redo: one segmented control rather than four separately-styled buttons, with
   drawn glyphs instead of ASCII arrows so they align on the same optical baseline. */
.undo-redo-bar {
    display: inline-flex;
    vertical-align: middle;
    margin: 0 4px 0 2px;
}

.history-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 18px;
    min-width: 21px;
    padding: 0;
    border: 1px solid #c5d2df;
    border-left-width: 0;
    background: #f7f9fb;
    color: #31485c;
    cursor: pointer;
}

.history-btn:first-child {
    border-left-width: 1px;
    border-radius: 3px 0 0 3px;
}

.history-btn:last-child {
    border-radius: 0 3px 3px 0;
}

/* Visual seam between the undo pair and the redo pair. */
.history-btn-group-start {
    border-left-width: 1px;
    margin-left: 2px;
    border-radius: 3px 0 0 3px;
}

.history-btn-caret {
    min-width: 13px;
    color: #6b8299;
}

.history-btn:hover {
    background: #e8f0fe;
    color: #103f66;
}

.history-btn:active {
    background: #d7e5f8;
}

.history-btn svg {
    display: block;
}

.edit-tool-separator {
    width: 1px;
    height: 16px;
    background: #c5d2df;
    margin: 0 3px;
}
.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: 0;
    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;
}
.zoom-slider-wrap {
    position: relative;
    flex: 1;
    min-width: 100px;
    max-width: 200px;
    padding-top: 8px;
}
.zoom-slider-wrap .normal-slider {
    width: 100%;
    min-width: 0;
    max-width: none;
}
.zoom-100-tick {
    position: absolute;
    top: 0;
    width: 12px;
    height: 10px;
    padding: 0;
    border: 0;
    background: transparent;
    transform: translateX(-50%);
    cursor: pointer;
    z-index: 2;
}
.zoom-100-tick::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    margin: 0 auto;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #444;
}
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;
    /* Performance: GPU compositing hint for large alignments */
    will-change: scroll-position, top;
    transition: top 0.12s ease-out;
    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;
    /* Virtualized rows/spacers preserve geometry explicitly. Browser scroll
       anchoring fights those updates and visibly shifts scrollTop afterward. */
    overflow-anchor: none;
    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; }
/* Full-mode row virtualization: invisible spacers that stand in for the
   rows currently scrolled out of view, so native scrolling still reflects
   the alignment's true full height even though only a window of rows is
   actually rendered as DOM. */
.full-mode-row-spacer { display: block; margin: 0; padding: 0; pointer-events: 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;
    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;
}

/* Vertical counterpart of .horizontal-scrollbar. Native alignment scrollbars
   are hidden, so JS shows this control for Canvas and scrollable Full/Block
   modes, sizes it to the alignment viewport, and synchronizes the active
   mode's Canvas offset or DOM scrollTop. */
.vertical-scrollbar {
    position: absolute;
    top: 0;
    right: 0;
    width: 14px;
    background: transparent;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 50;
    box-sizing: content-box;
    cursor: grab;
    user-select: none;
    touch-action: pan-y;
    display: none; /* JS shows this only while the active mode can scroll */
}
.vertical-scrollbar-thumb { width: 1px; }
.vertical-scrollbar.grabbing { cursor: grabbing; }
.vertical-scrollbar::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -10px; right: -10px;
    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 {
    position: relative;
    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.15;
    padding-bottom: 1px;
}
.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;
    /* Performance: isolate layout within each row */
    contain: layout style;
    cursor: default;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    overflow: visible;
}

/* Residue case toggle (GeneDoc-style) */
.residue-case-upper .seq-data,
.residue-case-upper .gap { text-transform: uppercase; }
.residue-case-lower .seq-data,
.residue-case-lower .gap { text-transform: lowercase; }

.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;
    color: #2c3e50;
    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: 10px;
    color: #888;
    line-height: 1;
    text-align: right;
    white-space: nowrap;
    flex: 0 0 auto;
    pointer-events: auto;
}
#versionIndicator a { color: #888; }
#versionIndicator a:hover { color: #333; text-decoration: underline; }

body.suppress-menu-hover #controls .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: default;
}

.seq-data:hover {
    cursor: default;
}

body.edit-mode-active[data-edit-tool="moveNoGaps"] .seq-data,
body.edit-mode-active[data-edit-tool="slideKeepGaps"] .seq-data {
    cursor: default;
}

body.edit-mode-active[data-edit-tool="insertGapSeq"] .seq-data,
body.edit-mode-active[data-edit-tool="deleteGapSeq"] .seq-data,
body.edit-mode-active[data-edit-tool="insertGapOther"] .seq-data,
body.edit-mode-active[data-edit-tool="deleteGapOther"] .seq-data,
body.edit-mode-active[data-edit-tool="insertGapAll"] .seq-data,
body.edit-mode-active[data-edit-tool="deleteGapAll"] .seq-data,
body.edit-mode-active[data-edit-tool="selectColumn"] .seq-data {
    cursor: crosshair;
}

body.edit-mode-active[data-edit-tool="residue"] .seq-data {
    cursor: text;
}

body.edit-dragging,
body.edit-dragging .seq-data {
    cursor: default !important;
}

.seq-data span.edit-active-cell {
    outline: 1px solid #1976d2;
    outline-offset: -1px;
    background-color: #e3f2fd !important;
    color: #111 !important;
}
.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;
}

/* Non-monochrome schemes replace conservation shading with residue colours */
#alignmentContainer:not(.color-scheme-monochrome) .seq-data .black,
#alignmentContainer:not(.color-scheme-monochrome) .seq-data .dark,
#alignmentContainer:not(.color-scheme-monochrome) .seq-data .light,
#alignmentContainer:not(.color-scheme-monochrome) .seq-data .other {
    background-color: transparent !important;
    color: inherit !important;
}

/* Alignment residue color schemes. Monochrome is the existing conservation shading. */
#alignmentContainer.color-scheme-nucleotide .seq-data .base-A { background-color: #8ddf88 !important; color: #063b09 !important; }
#alignmentContainer.color-scheme-nucleotide .seq-data .base-C { background-color: #87c7ff !important; color: #07335e !important; }
#alignmentContainer.color-scheme-nucleotide .seq-data .base-G { background-color: #ffc878 !important; color: #5f3300 !important; }
#alignmentContainer.color-scheme-nucleotide .seq-data .base-T,
#alignmentContainer.color-scheme-nucleotide .seq-data .base-U { background-color: #ff8c8c !important; color: #5e0505 !important; }
#alignmentContainer.color-scheme-nucleotide .seq-data .base-N { background-color: #d9d9d9 !important; color: #333 !important; }

#alignmentContainer.color-scheme-purine-pyrimidine .seq-data .pp-purine { background-color: #ffe9a8 !important; color: #6b4500 !important; }
#alignmentContainer.color-scheme-purine-pyrimidine .seq-data .pp-pyrimidine { background-color: #cbe7ff !important; color: #06466d !important; }
#alignmentContainer.color-scheme-purine-pyrimidine .seq-data .iupac-ambiguous,
#alignmentContainer.color-scheme-purine-pyrimidine .seq-data .base-N { background-color: #e5e5e5 !important; color: #333 !important; }

#alignmentContainer.color-scheme-ambiguity .seq-data .iupac-ambiguous { background-color: #e8ddff !important; color: #3f1375 !important; font-weight: bold; }
#alignmentContainer.color-scheme-ambiguity .seq-data .base-R { background-color: #d7ffd7 !important; color: #075007 !important; }
#alignmentContainer.color-scheme-ambiguity .seq-data .base-Y { background-color: #d7edff !important; color: #06466d !important; }
#alignmentContainer.color-scheme-ambiguity .seq-data .base-S { background-color: #dff7ff !important; color: #06515f !important; }
#alignmentContainer.color-scheme-ambiguity .seq-data .base-W { background-color: #fff4c7 !important; color: #6b5200 !important; }
#alignmentContainer.color-scheme-ambiguity .seq-data .base-K { background-color: #ffe2ce !important; color: #6a2a00 !important; }
#alignmentContainer.color-scheme-ambiguity .seq-data .base-M { background-color: #f4dcff !important; color: #5d126d !important; }
#alignmentContainer.color-scheme-ambiguity .seq-data .base-N { background-color: #d9d9d9 !important; color: #333 !important; font-weight: bold; }

#alignmentContainer.color-scheme-aa-clustal .seq-data .aa-hydrophobic { background-color: #80b1ff !important; color: #062a5f !important; }
#alignmentContainer.color-scheme-aa-clustal .seq-data .aa-positive { background-color: #ff9a9a !important; color: #650808 !important; }
#alignmentContainer.color-scheme-aa-clustal .seq-data .aa-negative { background-color: #ff77dd !important; color: #5d064e !important; }
#alignmentContainer.color-scheme-aa-clustal .seq-data .aa-polar { background-color: #8ee68e !important; color: #064906 !important; }
#alignmentContainer.color-scheme-aa-clustal .seq-data .aa-aromatic { background-color: #8fe6ff !important; color: #07495a !important; }
#alignmentContainer.color-scheme-aa-clustal .seq-data .aa-special { background-color: #ffe680 !important; color: #5c4600 !important; }
#alignmentContainer.color-scheme-aa-clustal .seq-data .aa-stop { background-color: #222 !important; color: #fff !important; }

#alignmentContainer.color-scheme-aa-jalview .seq-data .aa-hydrophobic { background-color: #ffcc99 !important; color: #5c2c00 !important; }
#alignmentContainer.color-scheme-aa-jalview .seq-data .aa-positive { background-color: #99ccff !important; color: #06345f !important; }
#alignmentContainer.color-scheme-aa-jalview .seq-data .aa-negative { background-color: #ff9999 !important; color: #620909 !important; }
#alignmentContainer.color-scheme-aa-jalview .seq-data .aa-polar { background-color: #99e699 !important; color: #064906 !important; }
#alignmentContainer.color-scheme-aa-jalview .seq-data .aa-aromatic { background-color: #d6b3ff !important; color: #3d0b63 !important; }
#alignmentContainer.color-scheme-aa-jalview .seq-data .aa-special { background-color: #ffff99 !important; color: #555500 !important; }
#alignmentContainer.color-scheme-aa-jalview .seq-data .aa-stop { background-color: #222 !important; color: #fff !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;
}
/* Soft-trim visual indicator — dimmed columns excluded from clustering */
.soft-trim-col { opacity: 0.35; background-color: #f0f0f0 !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;
}
.tooltip.consensus-box .freq-row .raw {
    font-size: 10px;
    color: #888;
}

/* ============================================================================
   NUCLEOTIDE LETTER COLORING MODE (shadeMode=letter)
   ============================================================================ */
/* In letter mode, override ALL shading backgrounds to white/transparent */
.shade-letter .seq-data .black,
.shade-letter .seq-data .dark,
.shade-letter .seq-data .light { background: transparent !important; }
.shade-letter .seq-data .base-A { color: #2ecc40 !important; }    /* Green */
.shade-letter .seq-data .base-C { color: #0074d9 !important; }    /* Blue */
.shade-letter .seq-data .base-G { color: #ff851b !important; }    /* Orange */
.shade-letter .seq-data .base-T { color: #ff4136 !important; }    /* Red */
.shade-letter .seq-data .base-U { color: #b10dc9 !important; }    /* Purple */
.shade-letter .seq-data .base-N { color: #888 !important; }       /* Grey */
/* Common IUPAC ambiguity codes */
.shade-letter .seq-data .base-R { color: #01ff70 !important; }
.shade-letter .seq-data .base-Y { color: #7fdbff !important; }
.shade-letter .seq-data .base-M { color: #f39c12 !important; }
.shade-letter .seq-data .base-K { color: #e74c3c !important; }
.shade-letter .seq-data .base-S { color: #3498db !important; }
.shade-letter .seq-data .base-W { color: #1abc9c !important; }
.shade-letter .seq-data .base-H { color: #9b59b6 !important; }
.shade-letter .seq-data .base-B { color: #e67e22 !important; }
.shade-letter .seq-data .base-V { color: #2c3e50 !important; }
.shade-letter .seq-data .base-D { color: #16a085 !important; }

.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;
    cursor: pointer;
    border-radius: 2px;
    padding: 1px 2px;
    transition: background-color 0.15s;
}
.zoom-value:hover {
    background-color: #e8f0fe;
}
.zoom-value.not-default {
    font-weight: bold;
    color: #1a73e8;
}
/* Always-visible quick display-mode switcher in the top bar (mirrors the
   Full/Block/Canvas/Reads radios buried in the Display dropdown, so the
   active mode is visible and switchable without opening that menu). */
.quick-mode-switch {
    display: inline-flex;
    align-items: stretch;
    height: 18px;
    border: 1px solid #bbb;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
    flex: 0 0 auto;
    align-self: center;
}
.quick-mode-switch input[type="radio"] {
    display: none;
}
.quick-mode-switch label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    font-size: 10px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    border-right: 1px solid #ccc;
}
.quick-mode-switch label:last-of-type {
    border-right: none;
}
.quick-mode-switch label:hover {
    background: #e0f0ff;
}
.quick-mode-switch input:checked + label {
    background: #1a73e8;
    color: #fff;
}

.canvas-mode-chip {
    display: none;
    align-self: center;
    flex: 0 0 auto;
    height: 18px;
    line-height: 18px;
    padding: 0 7px;
    font-size: 10px;
    font-weight: 600;
    color: #5c4a00;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 4px;
    white-space: nowrap;
    user-select: none;
    cursor: default;
}

.canvas-mode-chip.is-visible {
    display: inline-flex;
    align-items: center;
}

#shortcuts-section .control-group {
    min-width: 260px;
    max-width: min(340px, calc(100vw - 12px));
    padding: 6px;
}

/* Top-bar codon analysis controls (visible when Codon analysis is enabled) */
.codon-mode-panel {
    display: none !important;
    align-self: center;
    flex: 0 0 auto;
    flex-shrink: 0;
    align-items: center;
    gap: 4px;
    height: 18px;
    padding: 0 5px;
    border: 1px solid #81c784;
    border-radius: 4px;
    background: #e8f5e9;
    white-space: nowrap;
    overflow: hidden;
}
.codon-mode-panel.is-visible {
    display: inline-flex !important;
}
.codon-mode-panel[hidden] {
    display: none !important;
}
.codon-panel-label {
    font-size: 10px;
    font-weight: 600;
    color: #2e7d32;
    user-select: none;
}
.codon-frame-switch {
    display: inline-flex;
    align-items: stretch;
    height: 16px;
    border: 1px solid #a5d6a7;
    border-radius: 3px;
    overflow: hidden;
    background: #f1f8e9;
}
.codon-frame-switch input[type="radio"] {
    display: none;
}
.codon-frame-switch label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    font-size: 9px;
    font-weight: bold;
    color: #33691e;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    border-right: 1px solid #c8e6c9;
}
.codon-frame-switch label:last-of-type {
    border-right: none;
}
.codon-frame-switch label:hover {
    background: #c8e6c9;
}
.codon-frame-switch input:checked + label {
    background: #43a047;
    color: #fff;
}
.codon-panel-btn {
    height: 16px;
    line-height: 14px;
    padding: 0 5px;
    font-size: 9px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #a5d6a7;
    border-radius: 3px;
    background: #fff;
    color: #2e7d32;
}
.codon-panel-btn:hover {
    background: #c8e6c9;
}

.mode-container {
    display: flex;
    align-items: flex-start;
    gap: 2px;
    height: auto;
    min-height: 22px;
}
.mode-container label {
    min-width: 0;
    margin-right: 0;
}
.mode-container input[type="checkbox"] {
    vertical-align: middle;
    margin: 0 2px 0 0;
}

/* Display menu: need more width for mode controls */
#display-controls {
    max-width: 520px;
    min-width: 360px;
}
.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;
    /* Purely a passive toast (no click handler anywhere), but centered and
       sized to its text - it was intercepting wheel/click events meant for
       whatever's underneath, most noticeably Canvas mode's wheel-to-pan,
       for as long as a message stayed visible (e.g. the 6s auto-switch
       notice), making vertical scroll silently do nothing during that
       window. */
    pointer-events: none;
}
#minimizeBar {
    display: none;
    position: sticky;
    top: 0;
    height: 18px;
    line-height: 18px;
    background: #ccc;
    cursor: pointer;
    z-index: 100;
    text-align: center;
    transition: background 0.15s, opacity 0.12s ease-out;
    font-size: 10px;
    color: #666;
    user-select: none;
}
#minimizeBar:hover { background: #aaa; color: #333; }

/* 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);
    -webkit-backdrop-filter: blur(4px);
    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;
}

.seq-data span.tsd-mark-bold {
    font-weight: 700 !important;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 1px;
}

.seq-data span.tsd-mark-color {
    border-radius: 2px;
}

@media (max-width: 700px) {
    #controls {
        padding: 1px 3px;
    }

    .control-row {
        flex-wrap: wrap !important;
        align-items: flex-start;
        gap: 2px;
        padding-top: 2px;
    }

    .undo-redo-bar {
        margin-left: 0 !important;
    }

    #snapshot-section {
        margin-left: 0 !important;
    }

    .standard-menu-group {
        order: 10;
        flex: 1 1 100% !important;
        min-width: 0 !important;
        width: 100% !important;
        flex-wrap: wrap !important;
        gap: 3px;
    }

    #actions-section {
        order: 11;
        flex: 0 0 auto !important;
        margin-left: 0 !important;
    }

    #headerInfoPanel {
        order: 12;
        flex: 1 1 100%;
        max-width: 100%;
        align-items: flex-start;
        padding: 0;
    }

    #sourceInfo,
    #sourcePathLine {
        max-width: 100%;
        text-align: left;
    }

    .control-group,
    .menu-section.side-section#input-section .control-group,
    #actions-section .control-group {
        position: fixed !important;
        left: 4px !important;
        right: 4px !important;
        top: 86px !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        box-sizing: border-box;
        padding: 8px;
        max-height: calc(100vh - 96px);
    }

    #actions-section .control-group {
        max-height: calc(100vh - 96px);
        max-width: calc(100vw - 8px);
    }

    #actions-controls .button-group {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .action-section {
        padding: 6px 0;
    }

    #editToolPanel {
        flex-wrap: wrap;
        gap: 3px;
    }
}
/* ============ 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-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; }
.blast-row-flash td { background:#FFF3B0 !important; transition: background 1.5s ease; }

/* Graphical hit-distribution diagram (NCBI-BLAST-style position bars) —
   its own independently-scrollable section, separate from the summary
   table below, so a database with many hits doesn't force the diagram and
   the table to compete for the same bounded scroll area. Bars render as
   near-hairline strokes (2px) but each row keeps a taller invisible hit
   area (7px) so hovering/clicking a bar stays easy despite the thin
   visual weight. */
.blast-hitdist-section { flex-shrink:0; overflow-y:auto; max-height:130px; border-bottom:2px solid #ddd; padding:6px 14px; }
.blast-hitdist-track { position:relative; }
.blast-hitdist-ruler { position:relative; height:16px; font-family:'Courier New',monospace; font-size:10px; color:#555; border-bottom:1px solid #999; margin-bottom:2px; }
.blast-hitdist-ruler .tick-left { position:absolute; left:0; top:0; }
.blast-hitdist-ruler .tick-right { position:absolute; right:0; top:0; }
.blast-hitdist-ruler .tick-mid { position:absolute; top:0; transform:translateX(-50%); }
.blast-hitdist-ruler .tick-mid::after { content:''; position:absolute; left:50%; bottom:-5px; width:1px; height:4px; background:#999; }
.blast-hitdist-row { position:relative; height:7px; }
.blast-hitdist-bar {
    position:absolute; top:2.5px; height:2px; border-radius:1px; cursor:pointer;
    opacity:0.9; outline:none;
}
.blast-hitdist-bar:hover, .blast-hitdist-bar:focus { opacity:1; height:3px; top:2px; box-shadow:0 0 0 1px #333; }
/* Single shared tooltip, appended to <body>, position:fixed so it's never
   clipped by the diagram's own scrollable ancestor (.blast-hitdist-section) —
   see the JS-side note where it's created for the incident this replaced. */
.blast-hitdist-tooltip {
    position:fixed; z-index:10010; background:#222; color:#fff; display:none;
    font-size:10px; font-family:-apple-system,'Segoe UI',sans-serif; padding:4px 7px;
    border-radius:3px; white-space:nowrap; pointer-events:none;
}

/* 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; }

/* Highlight-diffs mode: dim columns that match the consensus (highlight differences) */
body.highlight-diffs .seq-data > span:not(.diff-highlight) { opacity: 0.4; }
body.highlight-diffs .seq-data > span.diff-highlight { font-weight: bold; }


/* ── Codon Analysis ── */
/* Codon phase coloring */
body.codon-mode span.codon-p0 { border-bottom: 2px solid #3498db; }  /* 1st pos: blue */
body.codon-mode span.codon-p1 { border-bottom: 2px solid #2ecc71; }  /* 2nd pos: green */
body.codon-mode span.codon-p2 { border-bottom: 2px solid #e67e22; }  /* 3rd pos: orange */

/* In-frame stop codons */
body.codon-mode span.codon-stop {
    background: #ff6b6b !important;
    color: #fff !important;
    font-weight: bold;
    border-radius: 2px;
}

/* Frameshift positions */
body.codon-mode span.codon-fs {
    border-bottom: 3px wavy #e74c3c;
}

/* Internal frameshift (gap indel not multiple of 3) */
body.codon-mode span.codon-fs-internal {
    border-left: 2px solid #e74c3c;
    border-right: 2px solid #e74c3c;
    background-color: rgba(231, 76, 60, 0.15) !important;
}

/* Synonymous mutations */
body.codon-mode span.codon-syn {
    text-decoration: underline;
    text-decoration-color: #27ae60;
    text-underline-offset: 2px;
}

/* Non-synonymous mutations */
body.codon-mode span.codon-nonsyn {
    text-decoration: underline;
    text-decoration-color: #c0392b;
    text-decoration-style: double;
    text-underline-offset: 2px;
}

/* AA translation rows - must match .seq-line font metrics for column alignment */
body.codon-mode .aa-row {
    display: flex;
    align-items: flex-start;
    font-family: 'Courier New', monospace;
    font-size: inherit;
    line-height: 1.0;
    color: #1a5276;
    background: #f8fdf8;
    border-bottom: 1px solid #d4efdf;
    padding: 0;
    margin: 0;
    min-height: 1em;
    white-space: nowrap;
    min-width: max-content;
}

body.codon-mode .aa-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-size: inherit;
    font-weight: bold;
    color: #95a5a6;
    background: #f8fdf8;
    position: sticky;
    left: -15px;
    z-index: 45;
}

body.codon-mode .aa-data {
    flex: 1 1 auto;
    display: inline-block;
    white-space: nowrap;
    margin: 0;
    padding: 0;
    line-height: 1.0;
    font-size: inherit;
    letter-spacing: 0;
}
body.codon-mode .aa-row:empty { display: none; }

/* Frame-specific AA row styling */
body.codon-mode .aa-row-f0 { color: #2980b9; background: #f0f8ff; }
body.codon-mode .aa-row-f1 { color: #27ae60; background: #f0fff4; }
body.codon-mode .aa-row-f2 { color: #e67e22; background: #fff8f0; }

/* Best frame (auto-detected) highlight */
body.codon-mode .aa-row-best {
    font-weight: bold;
    border-left: 3px solid #3498db;
}

/* Recent files dropdown */
.recent-item:hover { background: #e8f0fe; }
.recent-item:last-of-type { border-bottom: none !important; }

/* Variable sites only — hide fully-conserved columns */
body.var-sites-only .seq-data > span[data-pos]:not(.diff-highlight) { display: none !important; }
body.var-sites-only .seq-data > span[data-pos]:not(.diff-highlight).var-site-hidden { display: none !important; }

/* Variable sites — breakpoint markers */
.col-breakpoint {
    display: inline-block;
    width: 0.6em;
    min-width: 8px;
    text-align: center;
    background-color: var(--brk-bg, #d0d0d0);
    color: #666;
    font-size: 0.85em;
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    border-left: 1px solid #b0b0b0;
    border-right: 1px solid #b0b0b0;
    line-height: 1.2;
    filter: brightness(1);
}
.col-breakpoint:hover {
    filter: brightness(0.9);
    color: #333;
}
body.var-sites-only.hide-breakpoints .col-breakpoint { display: none !important; }
/* .consensus-line .seq-data span forces background-color:transparent !important
   (avoids double-shading conflicts with base-colour classes on that row) -
   this more specific selector is needed to let the marker's own colour win there too. */
.consensus-line .seq-data span.col-breakpoint { background-color: var(--brk-bg, #d0d0d0) !important; }

/* Keyboard shortcut displays — key column must not wrap */
#infoModal > div strong,
#shortcuts-controls strong,
#hotkeysTooltip strong {
    white-space: nowrap;
}
#hotkeysTooltip { max-width: 340px !important; }

/* Recent Files "Max" count now has its own explicit up/down buttons
   (visible, sized, and testable in headless Chrome, unlike native OS
   spin-button chrome) - hide the native WebKit spinner so there's only
   one set of arrows, not two overlapping ones. */
#historyMaxInput::-webkit-inner-spin-button,
#historyMaxInput::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
