:root {
  --color-bg:          #FFFFFF; 
  --color-surface:     #F9F9FB; 
  --color-surface-2:   #EAEAED; 
  --color-border:      #D4D4D8; 

  --color-text:        #15141A;
  --color-text-muted:  #8F8F9D;
  --color-text-inv:    #ffffff;

  --color-primary:     #2564eb46;
  --color-primary-hover: #1e4db7;
  --color-secondary:   #7c3aed;
  --color-secondary-hover: #5b21b6;

  --color-success:     #16a34a;
  --color-warning:     #d97706;
  --color-danger:      #dc2626;
  --color-info:        #0284c7;

  --color-row-hover:   #B4B4B7;
  --color-accent:      #e11d48;
  --color-toolbar-active: #c4c4cf;
  font-size: clamp(9px, 1.0vw, 18px);
}

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: system-ui, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
}

input,
select,
textarea {
    background-color: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.left-panel {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    border-right: 1px solid var(--color-border);
    height: 100%;
    position: relative;
    background: var(--color-surface)
}
.left-panel-toggle {
    position: absolute;
    top: 0;                            
    right: 0;                          
    background: none;
    border: none;
    cursor: pointer;
    padding: 1em 1em;
}

.left-panel-content{
    margin-top: 2rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: visible;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0rem;
    align-items: stretch;
}

table {
    background-color: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

ul.dash-list {
    list-style: none;     
    margin: 0;            
    padding-left: 0;      
}

ul.dash-list li {
    position: relative;
    padding-left: 1em;   
}

ul.dash-list li::before {
    content: "-";
    position: absolute;
    left: 0;              
}

.plot-container {
    position: relative !important;
    overflow: visible !important;
    width: 100%;
    height: 100%;
}

.plot-container .modebar {
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}
.plot-container .modebar-group,
.plot-container .modebar-btn {
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    min-width: max-content;
}

.dropdown-item {
    padding: 6px 12px;
    cursor: pointer;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--color-row-hover);
    outline: none;
}

.dropdown-submenu {
    top: 0;
    left: 100%;
    z-index: 2100;
}

.topbar {
    display: flex;
    gap: 1rem;
    background-color: var(--color-surface-2);
    padding: 6px 12px;
    border-bottom: 1px solid var(--color-border);
    font-family: sans-serif;
    font-size: 14px;
    user-select: none;
    z-index: 1000;
}

.menu {
    position: relative;
}

.menu-label {
    cursor: pointer;
    padding: 4px 8px;
}

.hidden-input {
    display: none;
}

.left-panel-sections,
.left-panel-section-header {
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #0f172a;
    padding: 0.3rem 0;
}

.roi-section-grid {
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    row-gap: 0.5rem;
    column-gap: 0.5rem;
    font-size: 1.2rem;
    width: 100%;
}

.roi-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0;
    min-height: 0;
    overflow-y: auto;
    background: #ffffff;
}

.roi-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    column-gap: 0.75rem;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.85rem;
    background: #ffffff;
}

.roi-row:last-child {
    border-bottom: none;
}

.roi-row-main {
    display: flex;
    align-items: center;
    min-width: 0;
}

.roi-row-actions {
    display: flex;
    justify-content: flex-end;
}

.roi-dropdown-wrapper {
    position: relative;
    display: inline-flex;
}

.roi-color-label {
    display: flex;
    align-items: center;
    justify-content: center;
}

.roi-color-input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 1.2rem;
    height: 1.2rem;
    border: 1px solid var(--color-border);
    border-radius: 1px;
    padding: 0;
    margin: 0;
    cursor: pointer;
    background: none;
    box-sizing: border-box;
}

.roi-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
    margin: 0;
    border-radius: 0px;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}

.roi-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 0px;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}

.roi-color-input::-moz-color-swatch {
    border: none;
    border-radius: 0px;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}

.roi-name {
    background: none;
    border: none;
    text-align: left;
    padding: 0;
    font-size: 0.9rem;
    font-weight: 400;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    color: var(--color-text);
    max-width: 20ch;
}

.roi-name.hidden {
    color: #888;            /* greyed out */
}

.roi-name-input {
    font-size: 0.9rem;
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 0.25rem 0.4rem;
    width: 100%;
    box-sizing: border-box;
}

.roi-dropdown-toggle {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 4px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111827;
    transition: background 120ms ease, border-color 120ms ease;
}

.roi-dropdown-toggle:hover,
.roi-dropdown-toggle:focus-visible {
    background: rgba(15, 23, 42, 0.08);
    border-color: rgba(148, 163, 184, 0.6);
    outline: none;
}

.roi-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0px 8px 16px rgba(15, 23, 42, 0.18);
    font-size: 0.8rem;
    min-width: 140px;
    z-index: 10;
    border-radius: 8px;
    padding: 0.35rem 0;
}

.roi-dropdown--floating {
    position: fixed;
    z-index: 2000;
    right: auto;
    top: 0;
    left: 0;
}

.peak-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    table-layout: fixed;
    border: 1px solid var(--color-border);
    text-align: left;
    background: var(--color-surface);
}

.peak-table th{
    border: 1px solid var(--color-border);
    padding: 0.4rem;
    text-align: left;
    max-width: 8ch;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis; 
    background: var(--color-surface-2);
}
.peak-table td {
    border: 1px solid var(--color-border);
    padding: 0.4rem;
    text-align: left;
    max-width: 8ch;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.peak-table tr {
    cursor: pointer;
    background-color: var(--color-suface);
}

.peak-table tr.active {
    background-color: var(--color-surface-2);
}

.peak-table tr:hover {
    background-color: var(--color-row-hover);
}

.peak-table td:nth-child(n+6),
.peak-table th:nth-child(n+6) {
    display: none; /* hide everything after column 5 */
}

.indicator{
    font-size: 0.6rem;
}

.footer{
    text-align: left;
    padding: 0rem 1rem 2rem 1rem;
    font-size: 0.85rem;
    color: #666;
    border-top: 1px solid #ccc;
    flex-shrink: 0;
}

.right-panel{
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.image-plot{
    flex: 66; 
    border-bottom: 1px solid var(--color-border);
}
.spectrum-plot{
    flex: 33
}

.plot-toolbar {
    display: inline-flex;
    border-radius: 8px;
    width: fit-content;
    overflow: hidden;
    margin-top: 0.2rem;
    margin-left: 0.2rem;
    border: 1px solid var(--color-border);
    background: var(--color-surface-2);
}

.plot-toolbar-group {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    margin-top: 0.2rem;
    margin-left: 0.2rem;
}


.plot-toolbar-button {
    width: 1.3rem;
    height: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0;
    cursor: pointer;
    padding: 0;
    background: transparent;
    transition: background-color 0.2s ease;
}

.plot-toolbar-button--text {
    width: auto;
    min-width: 4.5rem;
    padding: 0 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.plot-toolbar-button:hover {
    background: var(--color-border);
}

.plot-toolbar-button.active {
    background: var(--color-toolbar-active);
}

.icon {
  width: 1.3rem;
  height: 1.3rem;
  fill: var(--color-text);
}

.auto-roi-popover {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    z-index: 12;
    width: min(28rem, calc(100vw - 1rem));
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-surface);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
}

.auto-roi-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.55rem;
    font-size: 0.85rem;
}

.auto-roi-popover-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: end;
}

.auto-roi-popover-grid--labels {
    margin-bottom: 0.2rem;
    color: var(--color-text-muted);
    font-size: 0.74rem;
    font-weight: 600;
}

.auto-roi-popover-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.55rem;
}

.auto-roi-inline-button {
    border: 0;
    background: transparent;
    color: var(--color-accent);
    cursor: pointer;
    padding: 0;
    font: inherit;
}

.auto-roi-go-button,
.auto-roi-create-button {
    white-space: nowrap;
}

.auto-roi-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.auto-roi-status {
    margin-top: 0.7rem;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--color-text-muted);
}

.auto-roi-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    margin-top: 0.7rem;
    font-size: 0.74rem;
    color: var(--color-text-muted);
}

.auto-roi-preview {
    margin-top: 0.7rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--color-border);
}

.auto-roi-preview-header {
    margin-bottom: 0.45rem;
    font-size: 0.76rem;
    font-weight: 600;
}

.auto-roi-preview-plot {
    min-height: 80%;
}

.peak-preview {
    display: block;
    width: auto;
    max-width: none;
    height: auto;
    margin: 0;
    margin-left: auto;
    box-sizing: border-box;
}

/* Contextual modifiers */
.peak-preview--peaks {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* preserve original aspect */
}

.peak-preview--filter {
}

.peak-filter-preview-list--peaks {
    display: grid;
    grid-template-rows: repeat(5, 1fr);
    gap: 0.4rem;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.peak-preview-row--peaks {
    min-height: 0;
    height: 100%;
    align-items: center;
    overflow: hidden;
}

.peak-preview-row--placeholder {
    opacity: 0;
    pointer-events: none;
}

.peak-filter-preview-wrapper--peaks {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    overflow: hidden;
}

.peak-filter-preview-wrapper--filter {
}

/* Peak workflow forms */
.peak-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    padding: 1.5rem;
    box-sizing: border-box;
    z-index: 3500;
}

.identify-workflow-overlay {
    align-items: flex-start;
    justify-content: center;
    z-index: 3500;
}

.peak-picker-dialog {
    background-color: var(--color-bg);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.identify-workflow-dialog {
    width: min(1180px, 92vw);
    height: 92vh;
    max-height: 92vh;
    min-height: 0;
}

.peak-picker-sidebar {
    flex: 0 0 360px;
    max-width: 360px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
}

.identify-form-body {
    align-items: stretch;
}

.identify-form-sidebar {
    max-height: calc(92vh - 7.5rem);
    overflow-y: auto;
}

.identify-form-main {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
}

.identify-form-panel {
    position: relative;
    flex: 1 1 auto;
    min-height: 80%;
    border: 1px solid #dbe3ef;
    border-radius: 12px;
    overflow: auto;
    background: #ffffff;
}

.identify-form-note {
    margin: 0;
    font-size: 0.85rem;
    color: #4b5563;
}

.identify-form-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 0.75rem;
    margin-top: 0.5rem;
}

.identify-form-message {
    margin: 0;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    font-size: 0.9rem;
    color: #475569;
}

.identify-form-message--error {
    color: #b91c1c;
    border-color: #fecaca;
    background: #fef2f2;
}

.identify-form-message--warning {
    color: #b45309;
    border-color: #fcd34d;
    background: #fffbeb;
    font-weight: 600;
}

.identify-form-message--success {
    color: #0f766e;
    border-color: #99f6e4;
    background: #f0fdfa;
    font-weight: 600;
    white-space: pre-line;
}

.identify-form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.identify-form-actions .peak-form-button {
    width: 100%;
}

.identify-form-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.identify-form-table thead {
    position: sticky;
    top: 0;
    background: #f8fafc;
    z-index: 1;
}

.identify-form-table th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid #dbe3ef;
}

.identify-form-table th[data-align="right"] {
    text-align: right;
}

.identify-form-table td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid #eef2f7;
}

.identify-form-table td[data-align="right"] {
    text-align: right;
}

.identify-form-link-button {
    border: none;
    background: none;
    padding: 0;
    color: #1d4ed8;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.peak-picker-preview-area {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.peak-picker-preview-panel {
    width: 100%;
    height: 100%;
    min-height: 360px;
}

.peak-form-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.peak-form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.peak-form-fieldset {
    margin-top: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.75rem;
}

.peak-form-fieldset legend {
    padding: 0 0.5rem;
    font-weight: 600;
    color: var(--color-text);
}

.peak-form-grid {
    display: grid;
    row-gap: 0.5rem;
}

.peak-form-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.peak-form-input,
.peak-form-select {
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    font-size: 0.9rem;
    background: var(--color-bg);
    color: var(--color-text);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.peak-form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-text);
    font-weight: 600;
}

.peak-form-hint {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.peak-form-inline {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.peak-form-button-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.peak-form-button-row--end {
    justify-content: flex-end;
}

.peak-form-button {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background: var(--color-surface-2);
    color: var(--color-text);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.15s ease;
}

.peak-form-button:hover:not(:disabled) {
    background: var(--color-border);
}

.peak-form-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.peak-form-button--primary {
    border-color: #2563eb;
    background: #2563eb;
    color: #ffffff;
    font-weight: 600;
}

.peak-form-button--primary:hover:not(:disabled) {
    background: #1e4db7;
}

.peak-form-button--danger {
    border-color: #dc2626;
    background: #dc2626;
    color: #ffffff;
    font-weight: 600;
}

.peak-form-button--danger:hover:not(:disabled) {
    background: #b91c1c;
}

.peak-form-button--ghost {
    border: none;
    background: none;
    color: #dc2626;
    cursor: pointer;
    font-size: 0.8rem;
}

.peak-filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 3200;
    overflow-y: auto;
    padding: 2rem 1rem;
}

.peak-filter-dialog {
    background: var(--color-bg);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    width: 96vw;
    max-width: 1400px;
    height: 92vh;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

.peak-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.peak-filter-title {
    margin: 0;
    font-size: 1.1rem;
    color: #1f2937;
}

.peak-filter-close {
    border: none;
    background: #f1f5f9;
    color: #1f2937;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
}

.peak-filter-body {
    display: flex;
    gap: 1.5rem;
    padding: 1.25rem 1.5rem 1.5rem;
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
}

.peak-filter-sidebar {
    flex: 0 0 360px;
    max-width: 360px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.peak-filter-heading {
    margin: 0;
    font-size: 0.95rem;
    color: #1f2937;
}

.peak-filter-rules {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    max-height: 100%;
    padding-right: 0.35rem;
}

.peak-filter-rule-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.65rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
}

.peak-filter-rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.peak-filter-rule-title {
    font-weight: 600;
    color: #1f2937;
}

.peak-filter-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.6rem;
    color: #475569;
}

.peak-filter-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.peak-filter-field {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    color: #475569;
    gap: 0.2rem;
}

.peak-filter-select {
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    font-size: 0.7rem;
    color: #1f2937;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.peak-filter-input {
    padding: 0.35rem;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    font-size: 0.7rem;
    color: #1f2937;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.peak-filter-note {
    margin: 0 0 0.75rem 0;
    font-size: 0.85rem;
    color: #4b5563;
}

.peak-filter-hint {
    font-size: 0.85rem;
    color: #64748b;
}

.peak-filter-stats {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    font-size: 0.82rem;
    color: #475569;
}

.peak-filter-stats p {
    margin: 0;
}

.peak-filter-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
    min-height: 0;
}

.peak-clustering-body {
    align-items: stretch;
}

.peak-clustering-main {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
}

.peak-clustering-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #475569;
}

.peak-clustering-toolbar strong {
    margin-right: 0.35rem;
    color: #0f172a;
    font-size: 0.9rem;
}

.peak-clustering-plot {
    position: relative;
    flex: 1 1 auto;
    border: 1px dashed #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    min-height: 80%;
    padding: 0.25rem;
}

#peak-clustering-dendrogram {
    width: 100%;
    height: 100%;
    min-height: 320px;
    position: relative;
}

.peak-clustering-threshold-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 2px dotted #dc2626;
    pointer-events: none;
    z-index: 2;
}

.peak-clustering-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #94a3b8;
    pointer-events: none;
    background: linear-gradient(
        180deg,
        rgba(248, 250, 252, 0.85),
        rgba(248, 250, 252, 0.65)
    );
}

.peak-clustering-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
}

.peak-clustering-actions .peak-form-button {
    width: 100%;
}

.peak-filter-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.peak-filter-align-right {
    text-align: right;
}

.peak-filter-list {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: visible;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
    position: relative;
}

.peak-filter-list-header {
    display: grid;
    grid-template-columns: 60px minmax(0, 0.55fr) minmax(0, 110px) minmax(0, 1fr);
    column-gap: 0.45rem;
    row-gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f1f5f9;
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
}

.peak-filter-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: #475569;
}

.peak-filter-pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #475569;
}

.peak-filter-input--narrow {
    width: 3.25rem;
}

.peak-filter-range {
    width: 140px;
}

.peak-filter-percentage {
    min-width: 3.5rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.peak-filter-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    padding: 0.75rem;
    overflow-y: auto;
    min-height: 0;
}

.peak-header-menu {
    position: relative;
    justify-self: end;
}

.peak-header-menu-btn {
    border: 1px solid transparent;
    background: transparent;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    color: #111827;
    transition: background 120ms ease, border-color 120ms ease;
}

.peak-header-menu-btn:hover,
.peak-header-menu-btn:focus-visible {
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(148, 163, 184, 0.6);
    outline: none;
}

.peak-header-dropdown,
.peak-header-submenu {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18);
    padding: 0;
    width: max-content;
    color: #0f172a;
    font-weight: 400;
}

.peak-header-dropdown {
    position: fixed;
    z-index: 2500;
}

.peak-header-dropdown-section {
    position: relative;
}

.peak-header-submenu {
    position: absolute;
    top: 0;
    left: 100%;
    z-index: 2600;
}

.peak-header-dropdown-item {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 400;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.peak-header-dropdown-item:hover,
.peak-header-dropdown-item:focus-visible {
    background: rgba(148, 163, 184, 0.2);
    outline: none;
}


.peak-filter-preview-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.75rem;
    background: #ffffff;
}

.peak-filter-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #1f2937;
}

.peak-filter-preview-body {
    display: grid;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: #475569;
}

.peak-filter-preview-canvas {
    width: 100%;
    height: auto;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}

.peak-filter-preview-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.peak-filter-scale {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: #475569;
}

.peak-filter-scale input {
    padding: 0.25rem;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}

.peak-filter-radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.9rem;
    color: #1f2937;
}

.peak-filter-radio-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.peak-filter-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.peak-filter-actions .peak-form-button {
    margin-top: 0.25rem;
    font-size: 0.7rem;
}

.peak-filter-add-rule {
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    border: 1px dashed #94a3b8;
    background: transparent;
    color: #475569;
    cursor: pointer;
}

.peak-filter-preview-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.peak-filter-centered {
    display: flex;
    justify-content: center;
}

.peak-filter-metadata {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.peak-filter-metadata-title {
    font-weight: 600;
}

.peak-filter-metadata-text {
    font-size: 0.8rem;
    color: #475569;
}

.peak-filter-preview-wrapper {
    display: flex;
    justify-content: flex-end;
}

.peak-filter-page-btn {
    border: none;
    background: #e2e8f0;
    color: #0f172a;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
}

.peak-filter-page-btn:hover {
    background: #cbd5f5;
}

.roi-panel {
    flex: 0 0 auto;
}

.peaks-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.peaks-panel > summary {
    flex: 0 0 auto;
}

.peak-entry-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.peak-intensity-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.72rem;
    color: #475569;
}

.peak-intensity-value {
    display: inline-flex;
    gap: 0.05rem;
    align-items: flex-start;
    white-space: nowrap;
}

.peak-intensity-value sup {
    font-size: 0.65em;
    line-height: 1;
    position: relative;
    top: -0.35em;
}

.peak-intensity-value--empty {
    opacity: 0.7;
}

.peak-intensity-multiplier--hidden {
    visibility: hidden;
}

.peak-entry-snr {
    font-weight: 600;
    text-align: center;
}

.peak-entry-menu {
    display: flex;
    justify-content: flex-end;
}

.peak-entry-menu-wrapper {
    position: relative;
}

.peak-entry-dropdown-section {
    border-top: 1px solid #e2e8f0;
    margin-top: 0.25rem;
    padding-top: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.peak-entry-dropdown-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    padding: 0 0.75rem;
}

.peak-entry-dropdown-empty {
    font-size: 0.75rem;
    color: #94a3b8;
    padding: 0.3rem 0.9rem;
}

.peak-entry-dropdown-list {
    display: flex;
    flex-direction: column;
}

.peak-no-data {
    padding: 0.75rem 0.5rem;
    color: #64748b;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
    grid-column: 1 / -1;
}

/* Responsive tweaks for peak workflow forms */
@media (max-width: 900px) {
    .peak-picker-overlay {
        padding: 1rem;
    }

    .identify-workflow-dialog {
        width: 100%;
        height: auto;
        min-height: 0;
        max-height: none;
    }

    .peak-picker-dialog {
        gap: 1rem;
    }

    .peak-picker-sidebar {
        flex: none;
        max-width: 100%;
        max-height: 45vh;
    }

    .identify-form-sidebar {
        max-height: none;
    }

    .peak-picker-preview-area {
        flex: none;
        min-height: 0;
    }

    .peak-picker-preview-panel {
        min-height: 260px;
    }

    .peak-filter-dialog {
        width: 100vw;
        height: auto;
        min-height: 0;
        max-height: none;
        margin: 1rem auto;
        border-radius: 0;
    }

    .peak-filter-body {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .peak-filter-sidebar {
        flex: none;
        max-width: 100%;
    }

    .peak-filter-preview-list {
        max-height: 45vh;
    }
}

@media (max-width: 540px) {
    .peak-form-button-row,
    .peak-filter-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .peak-form-button-row--end {
        justify-content: flex-start;
    }

    .peak-filter-pagination {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .peak-filter-pagination-controls {
        width: 100%;
        justify-content: space-between;
    }

    .peak-filter-preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

@media (max-width: 900px) {
  :root {
    font-size: clamp(11px, 3vw, 16px);
  }

  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: space-between;
  }

  .app-shell {
    flex-direction: column !important;
    height: auto !important;
    min-height: 100vh;
    overflow: visible !important;
  }

  .left-panel {
    width: 100% !important;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    flex: 0 0 auto !important;
    height: auto !important;
  }

  .left-panel-toggle {
    top: 0.5rem;
    right: 0.5rem;
  }

  .left-panel-content {
    margin-top: 3.5rem;
    max-height: 50vh;
    padding: 0.75rem;
  }

  .right-panel {
    height: auto;
    min-height: 0;
  }

  .image-plot {
    flex: none;
    min-height: 280px;
  }

  .spectrum-plot {
    flex: none;
    min-height: 220px;
    border-bottom: none;
  }

  .plot-toolbar {
    width: 100%;
    justify-content: space-between;
  }

  .plot-toolbar-group {
    display: flex;
    width: 100%;
    margin-right: 0.2rem;
  }

  .plot-toolbar-button {
    width: 1.6rem;
    height: 1.6rem;
  }

  .plot-toolbar-button--text {
    min-width: 5.5rem;
  }

  .icon {
    width: 1.6rem;
    height: 1.6rem;
  }

  .roi-row {
    font-size: 0.95rem;
    grid-template-columns: 28px minmax(0, 1fr) auto;
  }

  .peak-table {
    font-size: 0.75rem;
  }

  .peak-table td,
  .peak-table th {
    max-width: none;
    white-space: normal;
  }

  .dropdown {
    position: static;
    width: 100%;
    box-shadow: none;
  }
}

@media (max-width: 540px) {
  .left-panel-content {
    max-height: 45vh;
    padding: 0.6rem;
  }

  .image-plot {
    min-height: 220px;
  }

  .spectrum-plot {
    min-height: 180px;
  }

  .plot-toolbar {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .auto-roi-popover {
    width: min(100vw - 1rem, 24rem);
  }

  .auto-roi-popover-grid {
    grid-template-columns: 1fr;
  }

  .auto-roi-popover-grid--labels {
    display: none;
  }

  .auto-roi-options {
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
  }
}
