body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 2.5em;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.workflow-steps {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 10px;
}

.step {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    background: #f8f9fa;
    color: #6c757d;
}

.step.active {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.step.completed {
    background: linear-gradient(45deg, #2ecc71, #27ae60);
    color: white;
}

.arrow {
    font-size: 20px;
    color: #bdc3c7;
    margin: 0 5px;
}

.section {
    margin-bottom: 30px;
    padding: 25px;
    border: 1px solid #e9ecef;
    border-radius: 15px;
    background: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.section:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.section h3 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 1.3em;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
}

.upload-area:hover {
    border-color: #2980b9;
    background: linear-gradient(45deg, #e9ecef, #dee2e6);
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: #27ae60;
    background: linear-gradient(45deg, #d5f4e6, #c8e6c9);
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin: 5px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Specific styling for Medical Assessment button when disabled */
#analyzeExpandedContextBtn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background: #6c757d !important;
    transform: none !important;
}

/* Slow flashing animation for processing messages */
@keyframes slowFlash {
    0%, 50% { opacity: 1; }
    25%, 75% { opacity: 0.3; }
}

.processing-flash {
    animation: slowFlash 2s ease-in-out infinite;
}

/* Alternative pulsing glow effect for processing */
@keyframes processingGlow {
    0%, 100% { 
        opacity: 1; 
        text-shadow: 0 0 10px rgba(123, 44, 191, 0.3);
    }
    50% { 
        opacity: 0.6; 
        text-shadow: 0 0 20px rgba(123, 44, 191, 0.8);
    }
}

.processing-glow {
    animation: processingGlow 1.5s ease-in-out infinite;
}

.btn-primary { background: linear-gradient(45deg, #667eea, #764ba2); color: white; }
.btn-success { background: linear-gradient(45deg, #2ecc71, #27ae60); color: white; }
.btn-warning { background: linear-gradient(45deg, #f39c12, #e67e22); color: white; }
/* .btn-danger { background: linear-gradient(45deg, #e74c3c, #c0392b); color: white; } */
.btn-info { background: linear-gradient(45deg, #3498db, #2980b9); color: white; }

.image-display {
    max-width: 100%;
    max-height: 400px;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    cursor: crosshair;
    transition: all 0.3s ease;
}

.image-display:hover {
    border-color: #667eea;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.2);
}

.status {
    padding: 8px 12px;
    margin: 10px 0;
    border-radius: 6px;
    font-weight: 500;
    font-size: 13px;
}

.status.success { 
    background: linear-gradient(45deg, #d5f4e6, #c8e6c9); 
    color: #155724; 
    border-left: 3px solid #27ae60; 
}
.status.error { 
    background: linear-gradient(45deg, #fadbd8, #f5c6cb); 
    color: #721c24; 
    border-left: 3px solid #e74c3c; 
}
.status.info { 
    background: linear-gradient(45deg, #d1ecf1, #bee5eb); 
    color: #0c5460; 
    border-left: 3px solid #17a2b8; 
}
.status.processing { 
    background: linear-gradient(45deg, #f3e5f5, #e1bee7); 
    color: #7b2cbf; 
    border-left: 3px solid #7b2cbf; 
    font-size: 1.2em; 
    font-weight: bold; 
    animation: pulse 1.5s infinite; 
    text-shadow: 0 0 10px rgba(123, 44, 191, 0.3);
}

.dual-image-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.image-panel-left, .image-panel-right {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.image-panel-left h4, .image-panel-right h4 {
    text-align: center;
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 1em;
}

.image-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    border-radius: 10px;
    background: #f8f9fa;
}

.point-marker {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid white;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    animation: pointPulse 0.6s ease-out;
}

@keyframes pointPulse {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.foreground-point { background: #27ae60; }
.background-point { background: #e74c3c; }

/* Mobile/Touch optimizations */
@media (max-width: 768px), (pointer: coarse) {
    .point-marker {
        width: 14px;
        height: 14px;
        border: 3px solid white;
    }
    
    #displayImage {
        cursor: crosshair;
        touch-action: manipulation; /* Prevent zoom on double-tap */
        user-select: none; /* Prevent text selection */
        -webkit-user-select: none;
        -webkit-touch-callout: none; /* Prevent iOS callout */
    }
}

/* Toggle buttons styling */
.segmentation-toggle-group .toggle-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.segmentation-toggle-group .toggle-btn:active {
    transform: translateY(0);
}

/* Touch-friendly image interaction */
.image-display {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.hidden { display: none; }

.progress-container {
    margin: 20px 0;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    display: none;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #dee2e6;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    margin-top: 10px;
    text-align: center;
    color: #667eea;
    font-weight: 500;
}

.tissue-results {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.tissue-card {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
    border-left: 4px solid #667eea;
}

.tissue-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.tissue-percentage {
    font-size: 2.2em;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 8px;
}

.tissue-label {
    font-size: 14px;
    color: #7f8c8d;
    font-weight: 500;
}

.parameter-group {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.parameter-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

.parameter-group input[type="range"] {
    width: 100%;
    margin: 10px 0;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #e74c3c, #f39c12, #2ecc71);
    outline: none;
    cursor: pointer;
}

.parameter-value {
    font-weight: bold;
    color: #667eea;
}

.form-group {
    margin: 20px 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus, .form-group textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

input[list] {
    appearance: none;
    -moz-appearance: none;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.mask-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.mask-panel {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.mask-panel:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.mask-panel h4 {
    text-align: center;
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.1em;
}

.mask-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mask-image-wrapper {
    width: 100%;
    min-height: 300px;
    border-radius: 8px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.mask-image {
    max-width: 100%;
    max-height: 280px;
    object-fit: contain;
    border-radius: 6px;
    opacity: 1;
}

.mask-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.threshold-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.threshold-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    min-width: 70px;
}

.threshold-slider {
    width: 120px;
    height: 6px;
    background: linear-gradient(to right, #e74c3c, #f39c12, #2ecc71);
    outline: none;
    border-radius: 3px;
    cursor: pointer;
}

.threshold-value {
    font-size: 12px;
    color: #667eea;
    font-weight: bold;
    min-width: 30px;
    text-align: center;
}

.placeholder {
    color: #999;
    font-size: 12px;
    text-align: center;
    padding: 20px;
}

.tissue-colors {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.color-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
}

.legend-percentage {
    font-size: 1.2em;
    font-weight: 700;
}

.color-box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #333;
}

#combinedMaskImage {
    max-width: 100%;
    max-height: 400px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    opacity: 1;
}

@media (max-width: 768px) {
    .grid, .dual-image-container {
        grid-template-columns: 1fr;
    }
    
    .workflow-steps {
        flex-direction: column;
    }
    
    .arrow {
        transform: rotate(90deg);
    }
    
    .mask-row {
        grid-template-columns: 1fr;
    }
    
    .mask-panel {
        margin-bottom: 20px;
    }
    
    .mask-controls {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .threshold-slider {
        width: 100px;
    }
}