/* General Styles */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Viewer-local controls and standardized left-side panel toggles. */
.workspace-sidebar-trigger {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  z-index: 20;
}

.workspace-sidebar-trigger:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.segmentation-viewer-stage {
  position: relative;
  width: 100%;
  min-height: 240px;
  overflow: hidden;
  border-radius: 8px;
}

.segmentation-overlay-controls {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 15;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: calc(100% - 1.5rem);
  padding: 0.4rem;
  border: 1px solid rgba(209, 213, 219, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(4px);
}

.segmentation-viewer-stage #segmentationResultsCanvas {
  display: block;
}

.segmentation-tools-sidebar {
  flex: 0 0 152px;
  width: 152px;
  align-self: stretch;
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.6rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.segmentation-tools-sidebar .segmented-control {
  display: flex;
  flex-direction: column;
}

.segmentation-tools-sidebar .toolbar-button {
  width: 100%;
}

#segmentationStats {
  margin-top: 0.75rem;
}

.osdViewerControlsParent {
  gap: 0.4rem;
  padding: 0.5rem;
}

.osdViewerControl {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.osdViewerControl:has(.osdViewerCheckbox) {
  align-items: center;
}

.osdViewerCheckbox,
.osdViewerCheckboxLabel {
  align-self: center;
}

#editSidebar {
  z-index: 10050 !important;
}

.workspace-sidebar-column,
.virtual-grid-sidebar-column {
  flex: 0 0 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.workspace-sidebar-column:has(> aside.collapsed),
.virtual-grid-sidebar-column:has(#virtual-grid-sidebar.collapsed) {
  flex-basis: 44px;
}

.workspace-sidebar-column > aside {
  width: 100% !important;
}

.virtual-grid-sidebar-column #virtual-grid-sidebar {
  width: 100% !important;
  margin-right: 0 !important;
}

.virtual-grid-sidebar-column #virtual-grid-sidebar.collapsed {
  width: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  border: 0;
}

.virtual-grid-sidebar-column #virtualGridSidebarIcon {
  width: auto;
  min-width: 44px;
  padding: 0 0.65rem;
  gap: 0.35rem;
}

@media (max-width: 760px) {
  .workspace-layout,
  .virtual-grid-layout {
    gap: 0.5rem;
  }

  .workspace-sidebar-trigger {
    flex-basis: 40px;
    width: 40px;
    min-width: 40px !important;
    height: 40px;
  }

  .segmentation-overlay-controls {
    top: 0.4rem;
    left: 0.4rem;
    max-width: calc(100% - 0.8rem);
  }

  .segmentation-overlay-controls .toolbar-button {
    min-height: 34px;
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
  }

  .segmentation-overlay-controls .segmented-control {
    display: inline-flex;
    width: auto;
  }

  .osdViewerControlsParent {
    display: flex !important;
    max-width: calc(100vw - 5rem);
  }

  .workspace-sidebar-column,
  .virtual-grid-sidebar-column {
    flex-basis: auto;
    width: 100%;
  }

  .segmentation-tools-sidebar {
    flex: 0 0 auto;
    width: 100%;
    position: static;
  }

  .segmentation-tools-sidebar .segmented-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: #f3f4f6;
  /* Softened background color */
}

.container {
  max-width: 100%;
  /* Optimized for readability */
  margin: auto;
  padding: 1rem;
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  height:100%;
  position: relative;

}

.body-container{
  margin: auto;
  padding: 1rem;
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  height:100%;
  position: relative;
}

/* For large screens, set body-container's max-width to 80% */
@media (min-width: 1024px) {
  .body-container {
    max-width: 80%;
  }
}



/* Header Styles */
header {
  padding: 1rem 0;
  /* Reduced vertical padding */
}

.header-title {
  font-size: 1.75rem;
  /* Reduced size for better balance */
  font-weight: 600;
  /* Increased weight for better readability */
  margin-left: 0.5rem;
  /* Added margin for spacing between logo and text */
}

/* Navigation Styles */
nav a {
  padding: 0.5rem 1rem;
  /* Increased padding for better clickability */
  font-size: 0.875rem;
  /* Increased font size */
  font-weight: 500;
  /* Medium weight for readability */
}

/* Active Tab Indicator */
.upload-option-tab.active {
  background-color: #007BFF;
  
  /* Light blue background for active tab */
  font-weight: 600;
  /* Bold font for active tab */
}

/* Form Input Enhancements */
.form-input {
  padding: 0.5rem;
  /* Increased padding for larger click area */
  border: 2px solid #d1d5db;
  /* Thicker border for better visibility */
  font-size: 0.875rem;
  /* Larger font size for readability */
}

/* Choose File Button Enhancement */
.file-upload-button {
  display: inline-block;
  padding: 0.5rem 1rem;
  background-color: #e2e8f0;
  /* Lighter shade for the button */
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
}

.file-upload-button:hover {
  background-color: #cbd5e1;
  /* Slightly darker on hover */
}

/* Button Enhancements */
.btn-proceed {
  padding: 0.75rem 1.5rem;
  /* Larger button for prominence */
  font-size: 0.875rem;
  /* Larger font size */
  font-weight: 600;
  /* Bold font for importance */
  border: none;
  /* Remove border for a cleaner look */
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.4);
  /* Matching shadow color to the button */
}

.btn-proceed:hover, 
.btn-box-connect:hover {
  background-color: #43e67f;
  /* Darker green on hover for contrast */
  box-shadow: 0 6px 8px -2px rgba(71, 220, 171, 0.5);
  /* Enhance shadow on hover for a lifting  */
}


/* Footer Styles */
footer {
  background-color: #f9fafb;
  /* Slightly different background for footer */
  color: #6b7280;
  /* Subdued color for text */
  padding: 2rem 0;
  /* Increased padding for more space */
}

.footer-links {
  margin-top: 1rem;
  font-size: 0.875rem;
}

.footer-links a {
  color: #6b7280;
  margin-right: 1rem;
  /* Space out footer links */
  transition: color 0.3s ease-in-out;
}

.footer-links a:hover {
  color: #374151;
  /* Darken color on hover */
}

/* Progress Indicators */
.carousel-control {
  width: 2rem;
  /* Size of indicator */
  height: 2rem;
  /* Size of indicator */
  background-color: #d1d5db;
  /* Neutral color for indicators */
}

.carousel-control.completed {
  background-color: rgb(91, 186, 91);
  color: white;
  /* White text for better contrast */
}

.carousel-control.active {
  background-color: rgb(134, 229, 134);
  ;
  /* Green color for active state */
}

/* Color Palette for Branding */
:root {
  --primary-color: #3c8fe7;
  /* Example primary color */
  --secondary-color: #3fd677;
  /* Example secondary color */
  --accent-color: #7c3aed;
  /* Example accent color */

  --error-color: #d75959;
}

/* Apply branding colors to elements */
.upload-option-tab.active {
  background-color: var(--primary-color);
  color: white;
  /* White text for better contrast */
}

.btn-proceed,
.btn-box-connect {
  background-color: var(--secondary-color);
}

/* Responsive Design */
@media (min-width: 1024px) {
  .container {
    max-width: 100%;
    /* Increased width for larger screens */
  }

  .header-title {
    font-size: 2rem;
    /* Slightly larger font for headers on bigger screens */
  }

  .btn-proceed,
  .btn-back,
  .btn-box-connect {
    padding: 0.75rem 2rem;
    /* Larger buttons for easier interaction on larger screens */
  }
}

/* Accessibility Enhancements */
[role="button"],
a,
input[type="file"],
input[type="text"],
input[type="checkbox"],
input[type="range"],
button {
  cursor: pointer;
  /* Ensure all clickable items have a pointer cursor */
}

/* Error Handling Styles */
.error-message {
  background-color: var(--error-color);
  color: white;
  /* Red color for errors */
  font-size: 0.875rem;
  /* Readable font size for errors */
  margin-top: 0.5rem;
  /* Space out error message from inputs */
}
.actionButton{
  width: 50px;
  height: 50px;
}

/* Loading States */
.loading-overlay {
  display: none;
  /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  /* Semi-transparent overlay */
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-overlay.active {
  display: flex;
  /* Show overlay when active */
}

.loading-spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  /* White color for spinner */
  border-radius: 50%;
  width: 3rem;
  height: 3rem;
  animation: spin 1s linear infinite;
  z-index: 1001;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Styling for the image input drop zone */
#drop-area.highlight {
  border-color: #4575de;
  /* or your brand primary color */
}

#drop-area {
  border: 2px dashed #ccc;
  border-radius: 5px;
  width: 90%;
  margin: 30px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  position: relative;
  background: #f8f8f8;
  min-height: 300px;
}

#upload-instructions {
  margin-bottom: 20px;
}

.my-form p {
  margin: 10px 0;
  color: #555;
}

#file-info,
#metadata-file-info {
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 10px;
  display: flex;
  align-items: center;
  /* Align items in the center vertically */
  justify-content: space-between;
  /* Spreads out the child elements */
  height: auto;
  /* Remove any fixed height if it's set */
}

.file-icon {
  margin-right: 10px;
  height: 32px;
  width: 32px;
  /* Assuming square icons */
}

#file-details,
#metadata-file-details {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  flex-grow: 1;
  /* Allows the details to fill the space */
}

#file-name,
#metadata-file-name {
  font-weight: bold;
  margin: 0;
  /* Resets any margin */
}

#file-size {
  font-size: 0.9em;
  color: #555;
  margin: 0;
  /* Resets any margin */
}

.remove-button {
  background: none;
  border: none;
  color: #b60404;
  font-size: 1.5rem;
  cursor: pointer;
  margin-left: 10px;
  /* Adds some space between the text and the button */
}

.remove-button:hover {
  color: #de0505;
}

.small {
  font-size: 0.8em;
  color: #3d3d3d;
}

.browse-button {

  background-color: var(--primary-color);
  color: #FFFFFF;
  border: none;
  padding: 8px 15px;
  cursor: pointer;
  border-radius: 5px;
  transition: background-color 0.3s;
}

.browse-button:hover {
  background-color: #8fb7ea;
}

.skip-button {

  background-color: #a8a6a6b8;
  color: #FFFFFF;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 5px;
  transition: background-color 0.3s;
}

.skip-button:hover {
  background-color: #ccc;
}

.file-upload-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #f0f0f0;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 4px 8px;
}

.width-90-middle{
  width: 90%;
  margin: auto;

}

.file-input {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}

.file-upload-button{
  background-color: var(--primary-color);
  color: #FFFFFF;
  border: none;
  padding: 8px 12px;
  text-align: center;
  display: inline-block;
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: 4px;
  margin: 4px;
  white-space: nowrap;
}

.file-upload-button:hover,
.browse-button:hover {
  background-color: #75aff6;
}
/* Enhancements for Form Controls */

input[type="range"] {
  -webkit-appearance: none;
  display: block;

  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #e4e7ea;
  outline: none;
  opacity: 0.7;
  transition: opacity .2s;
}

input[type="range"]:hover {
  opacity: 1;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #007bff;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: #007bff;
  cursor: pointer;
}

/* Visual Enhancements for Select and Checkbox */
select {
  width: 100%;
  padding: 0.5rem;
  border-radius: 4px;
  border: 1px solid #ced4da;
  background-color: #fff;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"><path d="M5.293 7.293a1 1 0 010 1.414L10 13.414l4.707-4.707a1 1 0 111.414 1.414l-5 5a1 1 0 01-1.414 0l-5-5a1 1 0 011.414-1.414z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
}

.checkbox-group, .radio-group {
  display: flex;
  align-items: center;
  margin: 0.5rem 0;
  gap: 1rem;
}

.checkbox-group label, .radio-group label {
  margin-left: 0.5rem;
}

.radio-group {
  display: flex;
  margin-bottom: 10px; /* spacing between form elements */
}

.radio-group input[type="radio"] {
  display: none; /* hide the default radio button */
}

.radio-group label.radio-button {
  padding: 10px 20px;
  border: 1px solid #ccc;
  border-radius: 20px; /* rounded corners for pill shape */
  background-color: #f0f0f0;
  margin-right: 10px; /* spacing between buttons */
  cursor: pointer;
  transition: background-color 0.3s ease;
}

/* Change background color when radio button is selected */
.radio-group input[type="radio"]:checked + label.radio-button {
  background-color: #007BFF;
  color: white;
  border-color: #007BFF;
}



/* Custom styles for the collapsible sidebar */
.sidebar {
  transition: width 0.3s ease-in-out, padding 0.3s ease-in-out;
  width: 25%;
  /* Initial width */
  overflow: hidden;
}

.collapsed {
  width: 0;
  padding: 0;
}

.parameterSidebar {
  cursor: pointer;
  left: 0; /* Align to the left side of the viewport */
  top: 0; /* Align to the top of the viewport */
  width: 36px; /* Width of the collapsed menu */
  background-color: #1F2937; /* Darker background for better contrast */
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.25); /* More pronounced shadow for depth */
  border-top-right-radius: 8px; /* Slightly rounded corners for a softer look */
  border-bottom-right-radius: 8px;
  padding-top: 5px;
  display: flex; /* Flexbox for centering the icon */
  justify-content: center; /* Center the icon horizontally */
  transition: background-color 0.3s ease; /* Transition for hover effect */
}

.parameterSidebar:hover{
  background-color: #374151; /* Slightly lighter background on hover for interaction feedback */
}

.parameterSidebar svg{
  stroke: #ffffff; /* White color for the icon to stand out */
  stroke-width: 2;
}


.collapsed+#sidebarIcon {
  display: relative;
  /* Show when sidebar is collapsed */
}

#segmentation-sidebar.collapsed>*:not(#sidebarIcon) {
  display: none;
  /* Hide sidebar contents when collapsed */
}

#gridding-sidebar.collapsed>*:not(#sidebarIcon) {
  display: none;
  /* Hide sidebar contents when collapsed */
}
#virtual-grid-sidebar.collapsed>*:not(#sidebarIcon) {
  display: none;
  /* Hide sidebar contents when collapsed */
}



.gridding-sidebar-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  /* Make sure it fills the parent */
}

#advanced-settings-content {
  flex-grow: 1;
}


main {
  transition: margin-left 0.3s ease-in-out;
}

main.expanded {
  margin-left: 0%;
  /* Same as initial sidebar width */
  position: absolute;
  z-index: -1;
}

/* Hidden Classes */
#file-info.hidden {
  display: none;
}

#metadata-file-info.hidden {
  display: none;
}
#segmentationSidebarIcon.hidden{
  display:none;
}
#griddingSidebarIcon.hidden{
  display:none;
}
#virtualGridSidebarIcon.hidden{
  display:none;
}


/* Window Controls */
.window-controls button {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #666;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  margin-left: 5px;
  padding: 0;
}

/* Hover effect for all buttons */
.window-controls button:hover {
  color: white; /* White text for all buttons on hover for better contrast */
}

/* Hover color for the close button */
.window-controls .close-button:hover {
  background-color: #dc3545; /* Red color for an alert, 'stop' signal hover state */
}


/* Sidebar Header Styles */
.parameters-header {
  background-color: #f9f9f9; /* Updated to a slightly warmer shade of light grey */
  padding: 15px; /* Padding only on the top and bottom */
  width: 100%; /* Ensure the header takes the full width */
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* More pronounced shadow for depth */
  font-family: 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; /* Modern font-family */
  transition: all 0.3s ease; /* Smooth transition for interactive elements */
  top: 0; /* Align the top edge with the parent's top */
  left: 0; /* Align the left edge with the parent's left */
}



/* Sidebar Header Styles */
.sidebar-header {
  
  background-color: #f9f9f9; /* Updated to a slightly warmer shade of light grey */
  padding: 10px; /* Padding only on the top and bottom */
  margin: -20px; /* Remove any default margins */
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* More pronounced shadow for depth */
  font-family: 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; /* Modern font-family */
  transition: all 0.3s ease; /* Smooth transition for interactive elements */
  position: relative; /* Positioning it absolutely relative to its parent */
  top: 0; /* Align the top edge with the parent's top */
  left: 0; /* Align the left edge with the parent's left */
}

/* Edit sidebar */
.edit-sidebar {
  overflow: auto;
  width: 300px; /* Adjust width as needed */
  min-width: 200px; /* Minimum width so content doesn't get too squished */
  background-color: #ffffff;
  padding: 20px;
  height: 400px; /* Or use max-height */
  max-height: 100vh;
  overflow-y: auto;
  box-shadow: -1px 0px 4px rgba(0, 0, 0, 0.1); /* Add shadow for depth */
  margin-left: 20px; /* Add some space between the canvas and sidebar */
  position: absolute; /* Make the sidebar positionable */
  display: none; /* Initially hide the sidebar */
  z-index: 10; /* Ensure it's above other elements */
  transition: box-shadow 0.3s ease, transform 0.3s ease; /* Smooth transition for visual feedback */
}

/* Styles to apply when dragging */
.edit-sidebar.dragging {
  box-shadow: 0 10px 20px rgba(0,0,0,0.2); /* Larger shadow for lifted effect */
  transform: scale(1.05); /* Slightly larger to indicate that it's being moved */
  cursor: grabbing; /* Cursor indicates a grab action */
  opacity: 0.9; /* Optional: slight transparency */
}

.edit-sidebar h2 {
  color: #333;
  font-weight: 600;
}

.edit-sidebar label {
  display: block;
  margin: 10px 0;
  font-size: 14px;
  width: fit-content;
}

.edit-sidebar input[type=number],
.edit-sidebar textarea {
  width: calc(100% - 20px);
  padding: 10px;
  margin-bottom: 5px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background-color: #f9f9f9;
  color: #555;
}
/* Styles for button group */
.edit-sidebar .button-group {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

/* Styling for the buttons */
.edit-sidebar button {
  flex: 1; /* Allows buttons to take equal width */
  padding: 10px;
  margin: 0 5px; /* Add some space between buttons */
  border-radius: 4px;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: background-color 0.3s ease;
  cursor: pointer;
}

/* Specific styling for the Cancel button */
.edit-sidebar .cancel-button {
  background-color: #F44336; /* Red color for cancel button */
  color: white;
}

/* Hover effect for buttons */
.edit-sidebar button:hover {
  opacity: 0.9;
}

/* Improve spacing and alignment of the Save button */
#saveCoreEdits {
  margin-top: 20px;
  width: 100%;
  padding: 10px;
  background-color: #0ca243;
  color: white;
  border: none;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
  transition: background-color 0.3s ease;
}

#removeCoreButton{
  margin-top: 20px;
  width: 100%;
  padding: 10px;
  background-color: #F44336;
  color: white;
  border: none;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
  transition: background-color 0.3s ease;
}

.osdViewerOverlay {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 10px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.osdViewerControls {
  display: flex;
  align-items: center;
}

.osdViewerControlsParent {
  display: flex;
  align-items: center;
  flex-direction: row;
}

.osdViewerControl {
  background-color: #007bff;
  color: white;
  border: none;
  padding: 5px 10px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.3s ease;
  /* margin-right: 10px; */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.osdViewerControl:hover {
  background-color: #0056b3;
}

.osdViewerControl i {
  margin-right: 5px;
}

.osdViewerCheckboxLabel {
  color: white;
  font-size: 14px;
  cursor: pointer;
  margin: auto 0px auto 5px;
}

.osdViewerCheckbox {
  appearance: none;
  width: 16px;
  height: 16px;
  margin: 0 auto;
  background-color: white;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
  border: 2px solid white;
}

.osdViewerCheckbox:checked {
  background-color: #000000;
}

.osdViewerCheckbox:checked::before {
  color: white;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
}

.core-overlay-for-gridding {
  box-sizing: border-box;
  border-style: solid;
  border-width: 3px;
  border-radius: 50%;
  border-color: #0056b3;
  cursor: grab;
}

.core-overlay-for-gridding:hover {
  border-width: 1px;
  border-color: #308cee;
}

.core-overlay-for-gridding.imaginary {
  border-color: #FFA500;
  border-width: 2px;

}

.core-overlay-for-gridding.temporary {
  border-style: dashed;
  border-color: #808080;
}

.core-overlay-for-gridding.misaligned {
  border-color: #FF0000;
  border-width: 2px;
}

.core-overlay-for-gridding.selected {
  /* border-width: 2px; */
  /* border-color: ; */
  border: none;
  box-shadow: 0px 0px 0px 2px #67e783;
  z-index: 100;
}

.core-overlay-for-gridding.marker {
  border-color: #51ff00;
  border-width: 2px;
}

.core-overlay-title-div {
  display: flex;
  position: relative;
  width: fit-content;
  font-size: 12px;
  margin: 0 auto;
  pointer-events: none;
}

.core-overlay-for-gridding.selected>.core-overlay-title-div {
  font-size: 16px;
  text-decoration: underline;
  color: maroon;
}

.coreResizeHandle {
  position: absolute;
  width: 5px;
  height: 5px;
  background-color: red;
  z-index: 1000;
}

.coreResizeHandle.topLeft,
.coreResizeHandle.bottomRight {
  cursor: nwse-resize
}

.coreResizeHandle.topRight,
.coreResizeHandle.bottomLeft {
  cursor: nesw-resize
}

svg {
  pointer-events: none;
}


#VirtualGridSVSContainer {
  display: grid;
  gap: 1px;
  /* Increased gap for better visual separation */
  padding: 10px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  width: 100%;
}

.grid-header {
  padding: 8px 12px;
  text-align: center;
  font-weight: bold;
  user-select: none;
}

.image-container {
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease-in-out;
  border-radius: 4px;
  overflow: hidden;
}

.image-placeholder {
  min-width: 64px;
  min-height: 64px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  background: #f8fafc;
  color: #64748b;
  border: 1px dashed #cbd5e1;
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
}

.image-container-missing {
  background: #f8fafc;
}

.image-container.active {
  border: 2px solid var(--primary-color); /* Highlight border for active container */
  z-index: 10;
  box-shadow: 0 0 8px rgba(0, 123, 255, 0.5); /* Optional: add a shadow for better visibility */
  background-color: #f0f8ff; /* Optional: slight background color change */
  transform: scale(1.05);
  overflow: visible;

}

.image-container:hover {
  transform: scale(1.05);
  z-index: 10;
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(31, 34, 36, 0.25);
  /* Dark overlay with increased opacity */
  color: white;
  display: none;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s;
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Adjust font size of image-overlay based on screen size */
@media (max-width: 1024px) {
  .image-overlay {
    font-size: 0.65rem;
  }
}

@media (max-width: 576px) {
  .image-overlay {
    font-size: 0.45rem;
  }
}


.image-container:hover .image-overlay {
  display: flex;
  opacity: 1;
}

.box-files-container {
  height: 90%;
}


.instructions-container {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
  color: #334155;
  margin: 1rem 0 1.25rem;
  overflow: hidden;
  padding: 1rem 3.25rem 1rem 1.25rem;
  position: relative;
  display: none;
}

.instructions-container::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #0f766e;
}

.instructions-container.space-y-4 > :not([hidden]) ~ :not([hidden]) {
  margin-top: 0.65rem !important;
}

.instructions-container h2 {
  align-items: center;
  color: #111827;
  display: flex;
  font-size: 1rem;
  font-weight: 800;
  gap: 0.5rem;
  line-height: 1.3;
  margin: 0 0 0.6rem !important;
}

.instructions-container h2::before {
  align-items: center;
  background: #ccfbf1;
  border: 1px solid #99f6e4;
  border-radius: 999px;
  color: #0f766e;
  content: "i";
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 900;
  height: 1.45rem;
  justify-content: center;
  line-height: 1;
  width: 1.45rem;
}

.instructions-container p {
  color: #475569;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0.5rem 0 0;
  padding-left: 1rem;
  position: relative;
}

.instructions-container p::before {
  background: #94a3b8;
  border-radius: 999px;
  content: "";
  height: 5px;
  left: 0;
  position: absolute;
  top: 0.78em;
  width: 5px;
}

.instructions-container strong {
  color: #0f172a;
  font-weight: 800;
}

.instructions-container kbd {
  color: #fff;
  background: #334155;
  border: 1px solid #0f172a;
  border-radius: 6px;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.18);
  display: inline-flex;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.86em;
  font-weight: 800;
  line-height: 1.2;
  padding: 0.14rem 0.42rem;
  vertical-align: baseline;
}

.close-instructions {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  left: auto;
  width: 2rem;
  height: 2rem;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  border-radius: 999px;
  padding: 0;
  font-size: 1rem;
  color: #64748b;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
  z-index: 1;
}

.close-instructions:hover,
.close-instructions:focus {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
  outline: none;
  box-shadow: 0 6px 16px rgba(185, 28, 28, 0.12);
}

.core-edit-container {
  position: relative; /* This ensures that child elements with absolute positioning are relative to this container */
  display: flex; /* Enable Flexbox */
  justify-content: space-between; /* Space between items */
  align-items: start; /* Align items to the top */
}
.preview-image{
  margin: 25px auto auto auto;
  width: 90%;
}
#url-upload{
  width: 90%;
  margin: auto;
}
.metadata-container{
  width: 90%;
  margin-right: auto;
  margin-left: auto;
  margin-top: 30px;
  margin-bottom: 20px;

}
.load-status {
  padding: 8px;
  text-align: center;
  font-size: 14px;
  font-weight: bold;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: opacity 0.3s ease-in-out;
  width: 90%;
  margin: 25px auto 50px auto;
}

.success-message {
  background-color: var(--secondary-color);
  color: white;
}

.export-grid-warning {
  width: min(100%, 640px);
  margin: 1rem 0 0 auto;
  padding: 0.85rem 1rem;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: left;
}

.standard-button{
    background-color: var(--primary-color);
    border: none;
    border-radius: 4px;
    width: 15%;
    color: white;
    padding: 8px 8px; /* Increased padding for a larger clickable area */
    font-size: 1rem; /* Increased font size for readability */
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-weight: 500;
    margin: 5px 0;
    transition: background-color 0.3s ease, transform 0.2s ease;
}


#rawDataLoadingSpinner{
  /* Make the spinner appear in the middle of the screen with absolute positioning */
  position: absolute;
  top: 50%;
  left: 50%;

}
/* Spinner styles */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 2s linear infinite;
  margin: auto;
  z-index: 2000;
}

/* Progress Overlay */
#progressOverlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.progress-dialog {
  background: #fff;
  padding: 20px;
  border-radius: 10px;
  width: 50%;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.progress-title {
  margin-top: 0;
  color: #333;
  font-size: 24px;
  font-weight: bold;
}

#progressBarContainer {
  background: #e0e0e0;
  border-radius: 5px;
  overflow: hidden;
  height: 20px;
  margin-top: 20px;
}

#progressBar {
  background: linear-gradient(to right, #4caf50, #81c784);
  width: 0%;
  height: 20px;
  border-radius: 5px;
  transition: width 0.4s ease;
}

#progressText {
  text-align: center;
  margin-top: 10px;
  color: #555;
  font-size: 16px;
}

/* Base styles for the form */
#editMetadataForm {
  background-color: #f7f7f7;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Styling for div containers */
#editMetadataForm div {
  margin-bottom: 15px;
}

/* Label styling */
#editMetadataForm label {
  display: block;
  margin-bottom: 5px;
  color: #333;
  font-size: 16px;
}

/* General input styling */
#editMetadataForm input[type="text"],
#editMetadataForm input[type="number"],
#editMetadataForm input[type="checkbox"] {
  width: 100%;
  padding: 10px;
  margin-top: 5px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box; /* Ensures padding doesn't affect overall width */
}

/* Checkbox customization */
#editMetadataForm input[type="checkbox"] {
  width: auto;
  margin-top: 0;
}

/* Styling for the submit button */
#editMetadataForm input[type="submit"] {
  cursor: pointer;
  border: none;
  color: #fff;
  background-color: #007bff;
  padding: 10px 20px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

#editMetadataForm input[type="submit"]:hover,
#editMetadataForm input[type="submit"]:focus {
  background-color: #0056b3;
}

/* Additional responsiveness and interaction */
@media (max-width: 768px) {
  #editMetadataForm {
    padding: 15px;
  }
}

:focus-visible {
  outline: 2px solid #007bff;
}

.app-tooltip {
  position: fixed;
  z-index: 10000;
  max-width: min(320px, calc(100vw - 24px));
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  background: #111827;
  color: #ffffff;
  box-shadow: 0 10px 25px rgba(17, 24, 39, 0.24);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: break-word;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.app-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.app-tooltip[hidden] {
  display: none;
}

/* Custom checkbox styles */
.custom-checkbox {
  display: inline-block;
  position: relative;
  cursor: pointer;
  user-select: none;
}

/* Hide the default checkbox */
.custom-checkbox input[type="checkbox"] {
  visibility: hidden;
  position: absolute;
  left: 0;
}

/* Create a custom box */
.custom-checkbox .checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 16px;
  width: 16px;
  background-color: #eee;
  border: 1px solid #ccc;
  border-radius: 2px;
}

/* On mouse-over, add a grey background color */
.custom-checkbox:hover input ~ .checkmark {
  background-color: #ccc;
}

/* When the checkbox is checked */
.custom-checkbox input:checked ~ .checkmark {
  background-color: #2196F3;
}

/* Create the checkmark/indicator (hidden when not checked) */
.custom-checkbox .checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

/* Show the checkmark when checked */
.custom-checkbox input:checked ~ .checkmark:after {
  display: block;
}

/* Style the checkmark/indicator */
.custom-checkbox .checkmark:after {
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}
/* Base styles for custom checkbox labels */
.custom-checkbox-label {
  display: block; /* Ensures that the label takes up the full width */
  position: relative;
  margin-bottom: 12px; /* Space between each checkbox */
  cursor: pointer;
  font-size: 16px; /* Set the font size for labels */
  user-select: none; /* Prevents text selection */
  line-height: 24px; /* Aligns the text vertically */
}

/* Hidden default checkbox */
.custom-checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

/* Custom checkmark box */
.custom-checkbox-label .checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 20px;
  width: 20px;
  background-color: #eee;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Checkmark appearance on checked */
.custom-checkbox-label input:checked ~ .checkmark:after {
  display: block;
}

/* Checkmark style */
.custom-checkbox-label .checkmark:after {
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid white;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}


/* Css for span tags that indicate file types */
.span-file-type {
  color: #475569;
  font-weight: 800;
}

.instructions-container .span-file-type {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #334155;
  display: inline-flex;
  font-size: 0.88em;
  line-height: 1.2;
  padding: 0.12rem 0.38rem;
  vertical-align: baseline;
}

.span-button,
.span-button-green,
.span-button-proceed {
  border-radius: 6px;
  cursor: default;
  display: inline-flex;
  font-size: 0.9em;
  font-weight: 800;
  line-height: 1.2;
  padding: 0.14rem 0.45rem;
  vertical-align: baseline;
}

.span-button {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.span-button-green,
.span-button-proceed {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
}

#advanced-settings-content label, 
#advanced-settings-content input {
    display: block; 
    width: 100%;
}

/* Responsive workflow polish */
html {
  min-height: 100%;
}

body {
  min-height: 100%;
  color: #111827;
}

.body-container {
  width: min(100%, 1440px);
  max-width: 1440px;
  min-height: 100vh;
  padding: 16px;
  border-radius: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.app-header .container {
  box-shadow: none;
  padding: 0.75rem 0;
}

.app-title {
  font-size: clamp(1.35rem, 4vw, 1.875rem);
  line-height: 1.1;
}

#navMenuMobile {
  right: 0.5rem;
  top: calc(100% + 0.5rem) !important;
  width: min(92vw, 280px);
  padding: 0.5rem;
}

#navMenuMobile a,
#navMenuMobile button,
nav a,
.btn-proceed,
.btn-back,
.upload-option-tab,
.browse-button,
.standard-button,
.file-upload-button,
.osdViewerControl {
  min-height: 44px;
}

.tool-panel {
  /* border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.08); */
}

.upload-tabs {
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: thin;
  justify-content: flex-start;
}

.upload-option-tab {
  flex: 0 0 auto;
  min-width: max-content;
  border-radius: 6px 6px 0 0;
}

.preview-image img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

#url-upload {
  align-items: stretch;
}

#url-upload .form-input {
  min-width: 0;
}

#drop-area {
  max-width: 880px;
}

.workspace-layout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  width: 100%;
}

.segmentation-workspace,
.gridding-workspace {
  flex-wrap: nowrap;
}

@media (min-width: 901px) {
  .segmentation-workspace,
  .gridding-workspace {
    align-items: stretch;
  }

  .workspace-sidebar-column {
    align-self: flex-start;
    min-height: 0;
    overflow: hidden;
  }

  .workspace-sidebar-column > #segmentation-sidebar:not(.collapsed),
  .workspace-sidebar-column > #gridding-sidebar:not(.collapsed) {
    flex: 1 1 auto;
    min-height: 0;
  }

  .virtual-grid-sidebar-column {
    align-self: flex-start;
    min-height: 0;
    overflow: hidden;
  }

  .virtual-grid-sidebar-column #virtual-grid-sidebar:not(.collapsed) {
    min-height: 0;
  }
}

#segmentation-sidebar,
#gridding-sidebar,
#virtual-grid-sidebar {
  flex: 0 0 320px;
  max-width: 100%;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  border: 1px solid #e5e7eb;
}

#segmentation-sidebar.collapsed,
#gridding-sidebar.collapsed,
#virtual-grid-sidebar.collapsed {
  flex-basis: 0;
  min-width: 0;
  overflow: hidden;
}

.parameterSidebar {
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  padding-top: 0;
}

.viewer-panel {
  min-width: 0;
}

.viewer-scroll {
  width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  position: relative;
  min-height: 420px;
}

#ImageSegmentation,
#VirtualGrid,
.virtual-grid-main {
  min-width: 0;
}

#segmentationResultsCanvas,
#virtualGridCanvas {
  max-width: 100%;
  height: auto;
}

#osdViewer {
  max-width: 100%;
  background: #ffffff;
  min-height: 420px;
}

.virtual-grid-layout {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  min-height: 0;
}

.virtual-grid-sidebar-column {
  align-self: stretch;
}

.virtual-grid-sidebar-column #virtual-grid-sidebar:not(.collapsed) {
  flex: 1 1 auto;
  max-height: none;
}

.metadata-sidebar-close {
  display: none;
}

.workspace-sidebar-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: none;
  font-family: inherit;
  transition: none;
}

.virtual-grid-stage {
  display: flex;
  min-width: 0;
  overflow: auto;
  min-height: 420px;
}

.workspace-status-panel {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 9;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.35rem 0.75rem;
  align-items: center;
  width: min(420px, calc(100% - 2rem));
  padding: 1rem 1.1rem;
  border: 1px solid #dbeafe;
  border-left: 4px solid var(--primary-color);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.14);
  color: #111827;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.workspace-status-panel[hidden] {
  display: none;
}

.workspace-status-panel strong {
  font-size: 1rem;
  line-height: 1.25;
}

.workspace-status-panel span[data-status-detail] {
  grid-column: 2;
  color: #4b5563;
  font-size: 0.9rem;
  line-height: 1.35;
}

.workspace-status-spinner {
  width: 1.45rem;
  height: 1.45rem;
  border: 3px solid #bfdbfe;
  border-top-color: var(--primary-color);
  border-radius: 999px;
  opacity: 0;
}

.workspace-status-panel.is-loading .workspace-status-spinner {
  opacity: 1;
  animation: workspace-status-spin 0.8s linear infinite;
}

.workspace-status-panel.is-empty .workspace-status-spinner,
.workspace-status-panel.is-error .workspace-status-spinner,
.workspace-status-panel.is-success .workspace-status-spinner {
  border-color: transparent;
}

.workspace-status-panel.is-success {
  border-color: #bbf7d0;
  border-left-color: var(--secondary-color);
}

.workspace-status-panel.is-error {
  border-color: #fecaca;
  border-left-color: #dc2626;
}

@keyframes workspace-status-spin {
  to {
    transform: rotate(360deg);
  }
}

.marker-auto-status {
  display: block;
  margin: 0.5rem 0;
  padding: 0.5rem 1rem;
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--primary-color);
  border-radius: 6px;
  background: #eff6ff;
  color: #1f2937;
  font-size: 0.95rem;
}

.marker-auto-status.success {
  border-color: #bbf7d0;
  border-left-color: var(--secondary-color);
  background: #f0fdf4;
}

.marker-auto-status.warning {
  border-color: #fde68a;
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.marker-auto-status.neutral {
  border-color: #e5e7eb;
  border-left-color: #6b7280;
  background: #f9fafb;
}

.core-overlay-for-gridding.auto-assigned-marker {
  border-color: #0891b2;
  box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.22);
}

.core-overlay-for-gridding.needs-review {
  border-style: dashed;
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

input[type="number"],
input[type="text"],
textarea,
select {
  min-height: 44px;
  font-size: 16px;
}

input[type="range"] {
  min-height: 26px;
}

@media (max-width: 900px) {
  .body-container {
    padding: 10px;
    box-shadow: none;
  }

  section[id] {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  .tool-panel {
    padding: 0.5rem !important;
  }

  .workspace-layout,
  .virtual-grid-layout {
    flex-direction: column;
  }

  #segmentation-sidebar,
  #gridding-sidebar,
  #virtual-grid-sidebar {
    flex: 1 1 auto;
    width: 100% !important;
    max-height: none;
    margin-right: 0 !important;
  }

  #segmentation-sidebar.collapsed,
  #gridding-sidebar.collapsed,
  #virtual-grid-sidebar.collapsed {
    height: 0;
    min-height: 0;
  }

  .parameterSidebar {
    border-radius: 8px;
  }

  #drop-area {
    width: 100%;
    min-height: 180px;
    margin: 16px auto;
  }

  #url-upload {
    width: 100%;
    flex-direction: column;
  }

  #url-upload .standard-button,
  .standard-button {
    width: 100%;
  }

  .preview-image,
  .load-status,
  .width-90-middle {
    width: 100%;
  }

  .edit-sidebar {
    position: fixed;
    left: 0 !important;
    right: 0;
    bottom: 0;
    top: auto !important;
    width: 100%;
    height: min(80vh, 620px);
    max-height: 80vh;
    margin: 0;
    border-radius: 12px 12px 0 0;
    z-index: 1000;
  }

  .osdViewerControlsParent {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
  }

  .osdViewerControl {
    margin-right: 0;
  }
}

@media (max-width: 640px) {
  .app-header .container {
    padding: 0.5rem 0;
  }

  .upload-option-tab {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .instructions-container {
    margin-left: 0;
    padding: 0.95rem 3rem 0.95rem 1rem;
  }

  .flex.justify-between.items-center.mt-8,
  .flex.justify-between.mt-6 {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }

  .flex.justify-between.items-center.mt-8 > button,
  .flex.justify-between.mt-6 > button,
  .btn-proceed,
  .btn-back {
    width: 100%;
  }

  .carousel-controls {
    position: sticky;
    bottom: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.96);
  }
}

/* Workflow, toolbars, and review UI */
.workflow-steps {
  gap: 0.5rem;
  flex-wrap: wrap;
}

.workflow-step {
  width: auto !important;
  height: auto !important;
  min-width: 128px;
  min-height: 48px;
  border-radius: 8px !important;
  padding: 0.45rem 0.75rem;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "index label"
    "index status";
  align-items: center;
  column-gap: 0.6rem;
  text-align: left;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
}

.workflow-step .step-index {
  grid-area: index;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #1f2937;
  font-weight: 700;
}

.workflow-step .step-label {
  grid-area: label;
  font-weight: 700;
  line-height: 1.1;
}

.workflow-step .step-status {
  grid-area: status;
  font-size: 0.72rem;
  color: #6b7280;
}

.workflow-step.active {
  border-color: var(--primary-color);
  background: #eff6ff;
}

.workflow-step.completed {
  border-color: #86efac;
  background: #f0fdf4;
}

.upload-summary,
.stats-strip,
.viewer-toolbar,
.review-panel {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
}

.upload-summary {
  width: 90%;
  margin: -24px auto 32px auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.9rem;
}

.upload-summary > div {
  min-width: 0;
}

.summary-label {
  display: block;
  color: #6b7280;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.upload-summary strong {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.95rem;
  color: #111827;
  overflow-wrap: anywhere;
}

.advanced-control-group {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem;
  background: #f9fafb;
}

.advanced-control-group summary {
  cursor: pointer;
  font-weight: 700;
  color: #374151;
}

.apply-status {
  margin: 0.65rem 0 0 0;
  font-size: 0.86rem;
  color: #4b5563;
}

.apply-status[data-tone="success"] {
  color: #047857;
}

.apply-status[data-tone="warning"] {
  color: #b45309;
}

.apply-status[data-tone="error"] {
  color: #b91c1c;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.55rem;
  margin-bottom: 0.75rem;
  position: sticky;
  top: 72px;
  z-index: 12;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.06);
}

.segmented-control {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  border-radius: 8px;
  background: #f3f4f6;
}

.toolbar-button {
  min-height: 40px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
  padding: 0.45rem 0.7rem;
  font-weight: 700;
  line-height: 1;
}

.toolbar-button:hover,
.toolbar-button.active,
.toolbar-button[aria-pressed="true"] {
  border-color: var(--primary-color);
  background: #eff6ff;
  color: #1d4ed8;
}

.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem;
  margin-bottom: 0.75rem;
  color: #374151;
  font-size: 0.9rem;
}

.stats-strip span {
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: #f3f4f6;
}

.review-panel {
  margin: 0.75rem 0;
  padding: 0.6rem 0.7rem;
}

.gridding-workspace .review-sidebar {
  flex: 0 0 300px;
  width: 300px;
  align-self: stretch;
  min-height: 0;
  max-height: none;
  margin: 0;
  overflow: hidden;
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  transition: flex-basis 180ms ease, width 180ms ease, padding 180ms ease;
}

.gridding-workspace .review-sidebar .review-panel-header {
  flex: 0 0 auto;
}

.review-minimize-button {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f9fafb;
  color: #1d4ed8;
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
}

.review-minimize-button:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.gridding-workspace .review-sidebar .review-issue-drawer {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.gridding-workspace .review-sidebar.review-sidebar-minimized {
  flex-basis: 44px;
  width: 44px;
  padding: 0.3rem;
}

.review-sidebar-minimized .review-panel-title,
.review-sidebar-minimized .review-issue-drawer {
  display: none;
}

.review-sidebar-minimized .review-panel-header {
  justify-content: center;
}

.review-sidebar-minimized .review-minimize-button {
  width: 34px;
}

.review-panel-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.review-panel-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.review-panel h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.98rem;
  font-weight: 800;
  color: #111827;
}

.review-panel p {
  margin: 0;
  color: #6b7280;
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.review-actions .toolbar-button {
  min-height: 34px;
  padding: 0.35rem 0.55rem;
  font-size: 0.82rem;
}

.review-actions .toolbar-button:disabled {
  cursor: default;
  opacity: 0.45;
  border-color: #e5e7eb;
  background: #f9fafb;
  color: #9ca3af;
}

.review-count-badge {
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.78rem;
  font-weight: 900;
}

.review-issue-drawer {
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 0.6rem;
  padding-top: 0.55rem;
  border-top: 1px solid #e5e7eb;
}

.review-issue-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.review-issue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 0.4rem;
  align-items: stretch;
  min-width: 0;
}

.review-issue-focus,
.review-issue-resolve {
  width: 100%;
  min-height: 38px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.review-issue-focus {
  border-left: 4px solid #f59e0b;
  background: #fffbeb;
  text-align: left;
  padding: 0.45rem 0.6rem;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.review-issue-resolve {
  width: 36px;
  min-width: 36px;
  padding: 0;
  background: #ffffff;
  font-size: 1rem;
  line-height: 1;
}

.review-issue-resolve:hover {
  border-color: #86efac;
  background: #f0fdf4;
}

.review-issue-focus strong,
.review-issue-focus small {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
}

.review-issue-focus small {
  color: #4b5563;
  font-size: 0.78rem;
  margin-top: 0.15rem;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.35;
}

.review-issue-item.active .review-issue-focus {
  outline: 2px solid var(--primary-color);
  border-left-color: var(--primary-color);
  background: #eff6ff;
}

#osdViewer.hide-core-labels .core-overlay-title-div {
  display: none;
}

.core-overlay-for-gridding.marker {
  box-shadow:
    0 0 0 2px rgba(81, 255, 0, 0.25),
    inset 0 0 0 2px rgba(81, 255, 0, 0.35);
}

.core-overlay-for-gridding.imaginary {
  border-style: dashed;
}

@keyframes reviewPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.35);
  }
  100% {
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
  }
}

.core-overlay-for-gridding.needs-review {
  animation: reviewPulse 1.8s ease-out infinite;
}

.core-overlay-for-gridding.review-focus-target {
  border-color: #dc2626;
  border-width: 4px;
  box-shadow:
    0 0 0 4px rgba(245, 158, 11, 0.65),
    0 0 0 10px rgba(220, 38, 38, 0.24);
  animation: reviewPulse 1.1s ease-out infinite;
}

@media (max-width: 900px) {
  #segmentation-sidebar:not(.collapsed),
  #gridding-sidebar:not(.collapsed),
  #virtual-grid-sidebar:not(.collapsed) {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    max-height: min(40vh, 360px);
    max-height: min(40dvh, 360px);
    border-radius: 14px 14px 0 0;
    z-index: 50;
    box-shadow: 0 -18px 36px rgba(17, 24, 39, 0.18);
  }

  .virtual-grid-sidebar-column #virtual-grid-sidebar:not(.collapsed) {
    flex: 0 0 auto !important;
    height: min(40vh, 360px);
    height: min(40dvh, 360px);
    min-height: 0;
    max-height: min(40vh, 360px) !important;
    max-height: min(40dvh, 360px) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  #segmentation-sidebar .workspace-sidebar-header,
  #gridding-sidebar .workspace-sidebar-header,
  #virtual-grid-sidebar .workspace-sidebar-header {
    top: -0.75rem;
    margin: -0.75rem -0.75rem 0.75rem;
  }

  #virtual-grid-sidebar .metadata-sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .segmentation-workspace:has(#segmentation-sidebar:not(.collapsed)) #ImageSegmentation,
  .gridding-workspace:has(#gridding-sidebar:not(.collapsed)) .viewer-panel,
  .virtual-grid-layout:has(#virtual-grid-sidebar:not(.collapsed)) .virtual-grid-main {
    padding-bottom: min(40vh, 360px);
    padding-bottom: min(40dvh, 360px);
  }

  .viewer-toolbar {
    top: 58px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .toolbar-button {
    flex: 0 0 auto;
  }

  .upload-summary {
    width: 100%;
    grid-template-columns: 1fr;
    margin-top: -20px;
  }

  .review-panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .gridding-workspace .review-sidebar {
    flex: 1 1 auto;
    width: 100%;
    max-height: none;
    position: static;
    order: 3;
  }

  .gridding-workspace .review-sidebar.review-sidebar-minimized {
    flex: 0 0 44px;
    width: 100%;
    min-height: 44px;
    max-height: 44px;
  }

  .gridding-workspace .review-sidebar .review-actions {
    display: flex;
  }

  .gridding-workspace .review-sidebar .review-issue-drawer {
    max-height: min(38vh, 260px);
  }

  .review-actions {
    width: 100%;
  }

  .review-actions .toolbar-button {
    flex: 1 1 auto;
  }

  .workflow-step {
    min-width: calc(50% - 0.5rem);
  }
}

@media (max-width: 640px) {
  .workflow-steps {
    justify-content: stretch;
  }

  .workflow-step {
    min-width: 100%;
  }

  .stats-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* Integrated app shell polish */
body.bg-gray-100 {
  background:
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 52%, #f8fafc 100%) !important;
}

.body-container {
  background: transparent;
  box-shadow: none;
  padding: 0 16px 12px;
}

#app {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(203, 213, 225, 0.78);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  padding: clamp(12px, 2vw, 12px);
}

.app-header {
  padding: 8px 0;
  margin: 0 auto 8px;
  background: transparent;
  backdrop-filter: none;
}

.app-header-inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(320px, 1fr) auto;
  gap: 1rem;
  align-items: center;
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  color: #111827;
}

.brand-link:hover {
  color: #111827;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.app-subtitle {
  margin-top: 0.18rem;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 700;
}

.app-nav {
  justify-self: center;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f8fafc;
}

.app-nav-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  color: #475569;
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.app-nav-link:hover,
.app-nav-link.active {
  color: #0f172a;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  text-decoration: none;
}

.app-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.help-button,
.mobile-menu-button,
.app-status-pill {
  min-height: 40px;
  border-radius: 9px;
  border: 1px solid #dbe3ef;
  background: #ffffff;
  color: #1f2937;
  font-weight: 800;
}

.help-button,
.mobile-menu-button {
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.75rem;
}

.mobile-menu-button {
  position: relative;
  z-index: 75;
  min-width: 104px;
  min-height: 42px;
  gap: 0.55rem;
  border-color: #cbd5e1;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.menu-button-text {
  font-size: 0.88rem;
  line-height: 1;
}

.menu-button-icon {
  position: relative;
  width: 18px;
  height: 14px;
  display: inline-block;
}

.menu-button-icon span {
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
  transition:
    top 0.16s ease,
    opacity 0.12s ease,
    transform 0.16s ease;
}

.menu-button-icon span:nth-child(1) {
  top: 0;
}

.menu-button-icon span:nth-child(2) {
  top: 6px;
}

.menu-button-icon span:nth-child(3) {
  top: 12px;
}

.mobile-menu-button[aria-expanded="true"] {
  border-color: var(--primary-color);
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.14);
}

.mobile-menu-button[aria-expanded="true"] .menu-button-icon span:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
}

.mobile-menu-button[aria-expanded="true"] .menu-button-icon span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-button[aria-expanded="true"] .menu-button-icon span:nth-child(3) {
  top: 6px;
  transform: rotate(-45deg);
}

.help-button:hover,
.mobile-menu-button:hover {
  border-color: var(--primary-color);
  color: #1d4ed8;
  background: #eff6ff;
}

.app-status-pill {
  align-items: center;
  padding: 0.45rem 0.7rem;
  color: #047857;
  background: #ecfdf5;
  border-color: #bbf7d0;
  font-size: 0.82rem;
}

#navMenuMobile.app-mobile-menu {
  position: absolute;
  right: 0.75rem;
  top: calc(100% + 0.6rem) !important;
  z-index: 70;
  width: min(92vw, 320px);
  padding: 0.5rem;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
  transform-origin: top right;
  animation: mobileMenuIn 0.16s ease-out;
}

#navMenuMobile.app-mobile-menu::before {
  content: "";
  position: absolute;
  right: 2.25rem;
  top: -7px;
  width: 14px;
  height: 14px;
  border-left: 1px solid #dbe3ef;
  border-top: 1px solid #dbe3ef;
  background: rgba(255, 255, 255, 0.98);
  transform: rotate(45deg);
}

@keyframes mobileMenuIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.app-mobile-link {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  color: #1f2937;
  font-weight: 800;
  text-align: left;
}

.app-mobile-link:hover {
  background: #f1f5f9;
  text-decoration: none;
}

.app-mobile-link:focus-visible,
.mobile-menu-button:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.32);
  outline-offset: 2px;
}

.mobile-help-button {
  border: 0;
  background: transparent;
}

.mobile-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(2px);
}

body.mobile-menu-open {
  overflow: hidden;
}

.app-header.menu-open .app-header-inner {
  border-color: #bfdbfe;
  box-shadow: 0 16px 44px rgba(37, 99, 235, 0.12);
}

@media (max-width: 767px) {
  .mobile-menu-button {
    display: inline-flex;
  }
}

@media (min-width: 768px) {
  .mobile-menu-button.md\:hidden,
  #navMenuMobile.app-mobile-menu,
  .mobile-menu-backdrop {
    display: none !important;
  }
}

.tool-panel,
.review-panel,
.upload-summary,
.viewer-toolbar,
.stats-strip,
.viewer-scroll,
#segmentation-sidebar,
#gridding-sidebar,
#virtual-grid-sidebar {
  /* box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06); */
}

.tool-panel,
.review-panel,
.upload-summary {
  border-radius: 10px;
}

.upload-tabs {
  padding: 0.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f8fafc;
}

.upload-option-tab {
  border: 0 !important;
  border-radius: 8px !important;
}

.upload-option-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.url-upload-panel {
  display: grid;
  gap: 0.75rem;
}

.url-upload-panel.hidden {
  display: none;
}

.url-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: stretch;
}

.url-upload-row .form-input {
  width: 100%;
  min-height: 48px;
  margin-top: 0;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  padding: 0.75rem 0.9rem;
  font-size: 1rem;
}

.url-upload-row .standard-button,
.sample-image-button {
  min-height: 48px;
  border-radius: 8px;
  padding: 0 1rem;
  white-space: nowrap;
}

.url-upload-row .standard-button {
  width: auto;
  min-width: 118px;
  max-width: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: stretch;
  margin: 0;
  line-height: 1.1;
  text-transform: none;
}

.sample-image-button {
  flex: 0 0 auto;
}

.sample-image-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  background: #eff6ff;
  padding: 0.85rem 1rem;
}

.sample-image-card strong {
  display: block;
  color: #0f172a;
  font-size: 0.95rem;
}

.sample-image-button {
  border: 1px solid #1d4ed8;
  background: #1d4ed8;
  color: #ffffff;
  font-weight: 800;
}

.sample-image-button:hover {
  border-color: #1e40af;
  background: #1e40af;
}

#drop-area {
  border-color: #cbd5e1;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.9), rgba(255, 255, 255, 0.96));
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

#drop-area.highlight,
#drop-area:hover {
  border-color: var(--primary-color);
  box-shadow: 0 10px 28px rgba(60, 143, 231, 0.12);
  transform: translateY(-1px);
}

#segmentation-sidebar,
#gridding-sidebar,
#virtual-grid-sidebar,
fieldset.p-6 {
  border-radius: 10px;
}

.instructions-container {
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.btn-proceed,
.btn-box-connect {
  background: #0f9f6e;
  box-shadow: 0 8px 18px rgba(15, 159, 110, 0.22);
}

.btn-proceed:hover,
.btn-box-connect:hover {
  background: #0b8a61;
  box-shadow: 0 10px 22px rgba(15, 159, 110, 0.28);
}

.btn-back {
  background: #be3a3a;
}

.standard-button,
.browse-button,
.file-upload-button {
  border-radius: 7px;
}

.workflow-steps {
  width: min(100%, 1440px);
  margin-left: auto;
  margin-right: auto;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.workflow-step {
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.workflow-step.active {
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(60, 143, 231, 0.12);
}

@media (max-width: 1120px) {
  .app-header-inner {
    grid-template-columns: minmax(210px, auto) 1fr auto;
  }

  .app-nav-link {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }
}

@media (max-width: 900px) {
  .body-container {
    padding-left: 10px;
    padding-right: 10px;
  }

  #app {
    border-radius: 12px;
  }

  .app-header {
    padding-top: 8px;
  }

  .app-header-inner {
    grid-template-columns: 1fr auto;
    padding: 0.55rem;
  }

  .app-subtitle {
    display: none;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 640px) {
  .sample-image-card,
  .url-upload-row {
    grid-template-columns: 1fr;
  }

  .sample-image-card {
    display: grid;
  }

  .url-upload-row .standard-button,
  .sample-image-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .body-container {
    padding-left: 6px;
    padding-right: 6px;
  }

  #app {
    border-radius: 10px;
    padding: 10px;
  }

  .app-header-inner {
    border-radius: 12px;
  }

  .app-title {
    font-size: 1.2rem;
  }
}

/* Workspace panel toggles */
.workspace-panel-toggle.parameterSidebar {
  position: static;
  inset: auto;
  width: auto !important;
  min-width: 148px;
  min-height: 48px;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: none;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1;
  text-transform: none;
}

.workspace-panel-toggle.parameterSidebar:hover,
.workspace-panel-toggle.parameterSidebar:focus-visible {
  border-color: #60a5fa;
  background: #dbeafe;
  color: #1e40af;
  transform: none;
}

.workspace-panel-toggle.parameterSidebar[aria-expanded="true"] {
  border-color: #0f766e;
  background: #ecfdf5;
  color: #047857;
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.12);
}

.panel-toggle-icon {
  width: 24px;
  height: 24px;
  display: inline-grid;
  gap: 3px;
  padding: 4px;
  border-radius: 7px;
  background: rgba(29, 78, 216, 0.1);
}

.panel-toggle-icon span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.workspace-panel-toggle[aria-expanded="true"] .panel-toggle-icon {
  background: rgba(4, 120, 87, 0.12);
}

.segmentation-toolbar,
.gridding-toolbar {
  align-items: center;
}

.virtual-grid-stage {
  position: relative;
}

.virtual-panel-toggle {
  position: absolute !important;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1) !important;
}

@media (max-width: 760px) {
  .workspace-panel-toggle.parameterSidebar {
    min-width: 100%;
    justify-content: flex-start;
  }

  .segmentation-toolbar,
  .gridding-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control .toolbar-button {
    flex: 1 1 0;
  }
}

/* Mobile work mode: keep the canvas dominant and make controls hideable. */
.mobile-workspace-controls-toggle {
  display: none;
}

@media (max-width: 760px) {
  .app-header {
    position: static;
    padding: 6px 0;
    margin-bottom: 4px;
  }

  html,
  body,
  .body-container,
  #app {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .body-container {
    width: 100%;
    padding-left: 4px;
    padding-right: 4px;
    padding-bottom: 12px;
  }

  #app {
    padding: 8px;
  }

  section[id] {
    padding-top: 0.5rem;
    padding-bottom: 0.75rem;
  }

  .instructions-container {
    display: none;
  }

  .mobile-workspace-controls-toggle {
    width: 100%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.45rem;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 900;
  }

  .mobile-workspace-controls-toggle[aria-expanded="true"] {
    border-color: #0f766e;
    background: #ecfdf5;
    color: #047857;
  }

  .workspace-layout,
  #ImageSegmentation,
  .viewer-panel,
  .virtual-grid-main,
  .virtual-grid-stage {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #segmentation-sidebar:not(.collapsed),
  #gridding-sidebar:not(.collapsed),
  #virtual-grid-sidebar:not(.collapsed) {
    left: 8px;
    right: 8px;
    bottom: 0;
    width: auto !important;
    max-width: calc(100vw - 16px);
    max-height: min(40vh, 360px);
    max-height: min(40dvh, 360px);
    padding: 0.75rem !important;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #segmentation-sidebar fieldset,
  #gridding-sidebar fieldset,
  #virtual-grid-sidebar fieldset {
    min-width: 0;
  }

  #gridding-sidebar fieldset.p-6,
  #virtual-grid-sidebar fieldset.p-6 {
    padding: 0.85rem !important;
  }

  .viewer-toolbar {
    position: static;
    top: auto;
    z-index: auto;
    margin-bottom: 0.45rem;
    padding: 0.4rem;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
    overflow-x: visible;
    flex-wrap: initial;
    box-shadow: none;
  }

  .viewer-toolbar.mobile-controls-collapsed {
    display: none;
  }

  .segmentation-toolbar,
  .gridding-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .workspace-panel-toggle.parameterSidebar {
    grid-column: 1 / -1;
    width: 100% !important;
    min-width: 0;
    justify-content: center;
  }

  .segmented-control {
    grid-column: 1 / -1;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.25rem;
    min-width: 0;
  }

  .viewer-toolbar .toolbar-button,
  .segmented-control .toolbar-button {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
    min-height: 38px;
    padding: 0.42rem 0.45rem;
    font-size: 0.8rem;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .stats-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
    width: 100%;
    overflow-x: visible;
    margin-bottom: 0.45rem;
    padding: 0.4rem;
    font-size: 0.78rem;
  }

  .stats-strip span {
    min-width: 0;
    padding: 0.25rem 0.45rem;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #markerAutoStatus {
    max-height: 42px;
    overflow: auto;
    margin: 0.1rem 0;
    padding: 0.15rem 0.2rem;
    font-size: 0.78rem;
  }

  .review-panel {
    margin: 0.4rem 0;
    padding: 0.45rem;
    box-shadow: none;
  }

  .review-panel-header {
    gap: 0.45rem;
  }

  .review-panel h2 {
    font-size: 0.9rem;
  }

  .review-panel p {
    display: none;
  }

  .review-actions {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .review-actions .toolbar-button {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0.32rem 0.5rem;
    font-size: 0.76rem;
  }

  .review-issue-drawer {
    max-height: min(38vh, 260px);
  }

  .viewer-scroll {
    max-height: calc(100vh - 190px);
    max-height: calc(100svh - 190px);
    border-radius: 8px;
  }

  #segmentationResultsCanvas {
    display: block;
    width: 100% !important;
    max-width: 100%;
    height: auto !important;
    max-height: calc(100vh - 230px);
    max-height: calc(100svh - 230px);
    object-fit: contain;
  }

  #osdViewer {
    min-height: min(68vh, 560px);
  }

  .osdViewerControlsParent {
    display: none !important;
  }

  .carousel-controls,
  .workflow-steps {
    position: static !important;
    bottom: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    margin: 0.5rem auto 0 !important;
    padding: 0.45rem 0 !important;
    background: transparent;
    scrollbar-width: thin;
  }

  .workflow-step {
    min-width: 112px;
    min-height: 42px;
    padding: 0.35rem 0.55rem;
    flex: 0 0 auto;
  }

  .workflow-step .step-index {
    width: 24px;
    height: 24px;
    font-size: 0.78rem;
  }

  .workflow-step .step-label {
    font-size: 0.82rem;
  }

  .workflow-step .step-status {
    display: none;
  }

  section[id] > .flex.justify-between.items-center {
    gap: 0.5rem;
    margin-top: 1rem !important;
  }

  section[id] > .flex.justify-between.items-center .btn-back,
  section[id] > .flex.justify-between.items-center .btn-proceed {
    flex: 1 1 0;
    min-width: 0;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

@media (max-width: 340px) {
  .stats-strip {
    grid-template-columns: 1fr;
  }
}

/* Keep viewer controls above the responsive toolbar rules declared earlier. */
.segmentation-overlay-controls {
  position: absolute;
  display: flex;
  width: auto;
  margin: 0;
}

.workspace-sidebar-trigger.parameterSidebar {
  width: 44px !important;
  min-width: 44px;
  justify-content: center;
}

#virtualGridSidebarIcon.workspace-sidebar-trigger {
  width: auto !important;
  min-width: 44px;
  padding-inline: 0.65rem;
}

#editSidebar {
  z-index: 10050 !important;
}

@media (max-width: 760px) {
  .segmentation-overlay-controls {
    display: flex !important;
    grid-template-columns: none;
  }

  .workspace-sidebar-trigger.parameterSidebar {
    width: 40px !important;
    min-width: 40px !important;
  }

  .osdViewerControlsParent {
    display: flex !important;
  }
}

/* ==========================================================================
   TMA-Grid polish layer (2026-10-14)
   One consistent visual system, applied last so it wins over the layered
   rules above: 8px button radius, one primary blue, one success green,
   neutral Back buttons, visible keyboard focus everywhere, and a real
   footer. No layout, class, or id changes: JS hooks are untouched.
   ========================================================================== */

:root {
  --tma-primary: #1d4ed8;
  --tma-primary-hover: #1e40af;
  --tma-success: #15803d;
  --tma-success-hover: #166534;
  --tma-ink: #1f2937;
  --tma-border: #d1d5db;
  --tma-focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.45);
}

::selection {
  background: #bfdbfe;
  color: #111827;
}

/* The brand title is the page h1; keep it visually identical to the
   former span (no browser default margin or weight shift). */
h1.app-title {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.01em;
}

/* Visible keyboard focus. Several components set focus:outline-none in
   markup; this restores a clear ring for keyboard users only. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
label.browse-button:focus-visible {
  outline: 2px solid var(--tma-primary);
  outline-offset: 2px;
  box-shadow: var(--tma-focus-ring);
}

/* Primary actions: one blue. Previously Apply appeared as blue-500,
   blue-600, and var(--primary-color) #3c8fe7 in different panels. */
#applySegmentation,
#apply-hyperparameters,
#applyVirtualGridSettings,
#downloadAllCoresButton,
.btn-box-connect,
.standard-button {
  background-color: var(--tma-primary);
  border-radius: 8px;
  font-weight: 600;
  text-transform: none;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

#applySegmentation:hover,
#apply-hyperparameters:hover,
#applyVirtualGridSettings:hover,
#downloadAllCoresButton:hover,
.btn-box-connect:hover,
.standard-button:hover {
  background-color: var(--tma-primary-hover);
}

/* Proceed and metadata export: one green, one radius. */
.btn-proceed,
#saveResultsAsJson,
#saveResultsAsCsv {
  background-color: var(--tma-success);
  border-radius: 8px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-proceed:hover,
#saveResultsAsJson:hover,
#saveResultsAsCsv:hover {
  background-color: var(--tma-success-hover);
}

/* Back is navigation, not a destructive action: neutral white button.
   Overrides the earlier red utilities and the late #be3a3a rule. */
.btn-back {
  background: #ffffff;
  color: var(--tma-ink);
  border: 1px solid var(--tma-border);
  border-radius: 8px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-back:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

/* Icon-only close and remove buttons get a consistent hit area. */
.close-button,
.remove-button {
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  line-height: 1;
}

/* External nav links carry an arrow so leaving the app is not a surprise. */
.app-nav-link[target="_blank"]::after,
.app-mobile-link[target="_blank"]::after {
  content: "↗";
  margin-left: 0.3em;
  font-size: 0.85em;
  opacity: 0.6;
}

/* Footer with the paper citation and the same links as the header. */
.app-footer {
  border-top: 1px solid #e5e7eb;
  margin-top: 1rem;
}

.app-footer-links {
  margin-top: 0.35rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.app-footer-links a {
  color: var(--tma-primary);
  font-weight: 500;
}

.app-footer-links a:hover {
  color: var(--tma-primary-hover);
  text-decoration: underline;
}

/* Instruction panels: one heading size, calmer body text. */
.instructions-container h2 {
  font-size: 1.25rem;
  line-height: 1.4;
}

.instructions-container p {
  color: #374151;
  line-height: 1.6;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
