* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, #16213e 0%, #1a1a2e 100%);
    border-bottom: 2px solid #e94560;
    padding: 0.5rem 2rem;
}

.header-content {
    max-width: 1800px;
    margin: 0 auto;
}

.header h1 {
    color: #e94560;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 0.15rem;
}

.header .subtitle {
    color: #7f8c8d;
    font-size: 0.85rem;
    margin-top: 0;
}

.container {
    display: grid;
    grid-template-columns: 240px 1fr 340px;
    gap: 1rem;
    padding: 1rem;
    max-width: 1800px;
    margin: 0 auto;
    flex: 1;
    width: 100%;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-section {
    background: #16213e;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #2a2a4a;
}

.sidebar-section h3 {
    color: #e94560;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #2a2a4a;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.mode-btn {
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #2a2a4a;
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: left;
}

.mode-btn:hover {
    background: #1a4f7a;
    border-color: #e94560;
}

.mode-btn.active {
    background: #e94560;
    color: white;
    border-color: #e94560;
}

.run-btn {
    width: 100%;
    background: linear-gradient(135deg, #e94560 0%, #c73e54 100%);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.run-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #ff5a75 0%, #e94560 100%);
    transform: translateY(-1px);
}

.run-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.run-icon {
    font-size: 0.75rem;
}

.thumbnail-section {
    text-align: center;
}

.thumbnail-img {
    width: 100%;
    border-radius: 4px;
    border: 1px solid #2a2a4a;
    cursor: pointer;
    transition: border-color 0.2s;
}

.thumbnail-img:hover {
    border-color: #e94560;
}

.change-roi-btn {
    width: 100%;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #3498db;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    transition: all 0.2s;
}

.change-roi-btn:hover {
    background: #1a4f7a;
    border-color: #e94560;
}

.thumbnail-caption {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-top: 0.5rem;
}

.metadata-panel {
    font-size: 0.8rem;
}

.metadata-list {
    display: grid;
    gap: 0.4rem;
}

.metadata-list dt {
    color: #7f8c8d;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metadata-list dd {
    color: #e0e0e0;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.image-panel {
    background: #16213e;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #2a2a4a;
    min-height: 450px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.image-container {
    width: 100%;
    text-align: center;
}

.result-image {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    cursor: crosshair;
}

.click-hint {
    font-size: 0.8rem;
    color: #e94560;
    margin-top: 0.5rem;
    font-style: italic;
}

.extra-images-panel {
    background: #16213e;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #2a2a4a;
    text-align: center;
}

.extra-images-panel h4 {
    color: #e94560;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.scatter-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
}

.placeholder {
    text-align: center;
    color: #7f8c8d;
    padding: 2rem;
}

.placeholder p {
    font-size: 1rem;
}

.loading {
    text-align: center;
    color: #e94560;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #2a2a4a;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.error-panel {
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid #e94560;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    max-width: 400px;
}

.error-panel h3 {
    color: #e94560;
    margin-bottom: 0.5rem;
}

.hidden {
    display: none !important;
}

.info-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.info-section {
    background: #16213e;
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid #2a2a4a;
}

.info-section h3 {
    color: #e94560;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #2a2a4a;
}

.summary {
    color: #bdc3c7;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    font-size: 0.9rem;
}

.details ul, .cluster-list {
    list-style: none;
    padding: 0;
}

.details li, .cluster-list li {
    color: #95a5a6;
    padding: 0.4rem 0;
    padding-left: 1rem;
    position: relative;
    line-height: 1.3;
    font-size: 0.85rem;
}

.details li::before, .cluster-list li::before {
    content: ">";
    color: #e94560;
    position: absolute;
    left: 0;
    font-weight: bold;
}

.cluster-panel, .local-panel {
    border-color: #3498db;
}

.local-image {
    width: 100%;
    border-radius: 4px;
    margin-top: 0.75rem;
}

.code-panel {
    border-color: #27ae60;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.collapsible-header:hover {
    color: #ff6b8a;
}

.toggle-icon {
    font-size: 1.2rem;
    font-weight: bold;
}

.code-content {
    margin-top: 0.75rem;
}

.code-step {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #2a2a4a;
}

.code-step:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.step-header {
    color: #3498db;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}

.step-desc {
    color: #95a5a6;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.step-code {
    background: #0d1117;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    padding: 0.5rem;
    overflow-x: auto;
    font-size: 0.75rem;
}

.step-code code {
    color: #7ee787;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    white-space: pre;
}

.pipeline-section {
    text-align: center;
}

.pipeline-img {
    width: 100%;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.pipeline-img:hover {
    opacity: 0.8;
}

.pipeline-stage {
    color: #3498db;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.pipeline-caption {
    font-size: 0.75rem;
    color: #7f8c8d;
}

.about-section p {
    color: #95a5a6;
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 0.4rem;
}

.about-section .note {
    font-style: italic;
    color: #7f8c8d;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #2a2a4a;
}

.error-msg {
    color: #e94560;
    font-size: 0.85rem;
}

.geological-panel {
    border-color: #f39c12;
}

.experimental-note {
    font-size: 0.75rem;
    color: #f39c12;
    margin-bottom: 0.5rem;
}

.run-geo-btn {
    width: 100%;
    background: linear-gradient(135deg, #f39c12 0%, #d68910 100%);
    color: white;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    transition: all 0.2s;
}

.run-geo-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #f5b041 0%, #f39c12 100%);
}

.run-geo-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.geo-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: rgba(243, 156, 18, 0.1);
    border: 1px solid rgba(243, 156, 18, 0.3);
    border-radius: 6px;
}

.geo-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(243, 156, 18, 0.3);
    border-top-color: #f39c12;
    border-radius: 50%;
    animation: geo-spin 1s linear infinite;
    margin-bottom: 0.5rem;
}

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

.geo-loading-text {
    color: #f39c12;
    font-size: 0.9rem;
    font-weight: 600;
    animation: geo-pulse 1.5s ease-in-out infinite;
}

.geo-loading-subtext {
    color: #95a5a6;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

@keyframes geo-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.geo-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.geo-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.geo-stat {
    background: #0f3460;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
}

.stat-label {
    color: #7f8c8d;
}

.stat-value {
    font-weight: 600;
    margin-left: 0.3rem;
}

.stat-red { color: #e94560; }
.stat-green { color: #2ecc71; }
.stat-yellow { color: #f1c40f; }
.stat-blue { color: #3498db; }
.stat-orange { color: #e67e22; }
.stat-red-dark { color: #e74c3c; }
.stat-purple { color: #9b59b6; }
.stat-orange-light { color: #f39c12; }

.geo-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    padding: 0.4rem;
    background: rgba(15, 52, 96, 0.5);
    border-radius: 4px;
    font-size: 0.65rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    color: #95a5a6;
}

.leg-circle {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid;
}

.leg-square {
    width: 10px;
    height: 10px;
    border: 2px solid;
}

.leg-line {
    width: 14px;
    height: 2px;
}

.leg-red { border-color: #e94560; background: transparent; }
.leg-green { background: #2ecc71; }
.leg-yellow { border-color: #f1c40f; background: transparent; }
.leg-dashed { border-style: dashed; }
.leg-blue { border-color: #3498db; background: transparent; }
.leg-orange { border-color: #e67e22; background: transparent; }
.leg-red-dark { background: #e74c3c; }
.leg-purple { border-color: #9b59b6; background: transparent; }

.geo-image {
    width: 100%;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    cursor: pointer;
}

.geo-details {
    list-style: none;
    padding: 0;
    margin: 0;
}

.geo-details li {
    color: #95a5a6;
    padding: 0.3rem 0;
    padding-left: 1rem;
    position: relative;
    font-size: 0.8rem;
    line-height: 1.3;
}

.geo-details li::before {
    content: ">";
    color: #f39c12;
    position: absolute;
    left: 0;
    font-weight: bold;
}

.clickable-image {
    cursor: zoom-in;
    transition: opacity 0.2s;
}

.clickable-image:hover {
    opacity: 0.9;
}

.enlarge-hint {
    font-size: 0.7rem;
    color: #7f8c8d;
    text-align: center;
    margin: 0.3rem 0 0.5rem 0;
    font-style: italic;
}

.image-viewer-modal-content {
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
}

.image-viewer-body {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    max-height: 85vh;
    overflow: auto;
}

.image-viewer-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
}

.warning-msg {
    color: #f39c12;
    font-size: 0.85rem;
}

.info-msg {
    color: #7f8c8d;
    font-size: 0.85rem;
    font-style: italic;
}

.footer {
    background: #16213e;
    border-top: 1px solid #2a2a4a;
    padding: 0.75rem 2rem;
    text-align: center;
    color: #7f8c8d;
    font-size: 0.8rem;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #16213e;
    border-radius: 12px;
    border: 1px solid #2a2a4a;
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
}

.roi-modal-content {
    width: 900px;
}

.pipeline-modal-content {
    width: 1200px;
}

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

.modal-header h2 {
    color: #e94560;
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    color: #7f8c8d;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.modal-close:hover {
    color: #e94560;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #2a2a4a;
}

.btn {
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #e94560;
    color: white;
    border: none;
}

.btn-primary:hover:not(:disabled) {
    background: #ff5a75;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    color: #e0e0e0;
    border: 1px solid #2a2a4a;
}

.btn-secondary:hover {
    border-color: #e94560;
}

.roi-selector-container {
    text-align: center;
    margin-bottom: 1rem;
}

#roi-canvas {
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    cursor: crosshair;
    max-width: 100%;
}

.roi-instructions {
    color: #7f8c8d;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.roi-info {
    display: flex;
    gap: 2rem;
    justify-content: center;
    color: #bdc3c7;
    font-size: 0.9rem;
}

.roi-note {
    color: #7f8c8d;
    font-size: 0.8rem;
}

.pipeline-large-img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.pipeline-description {
    color: #bdc3c7;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.pipeline-note {
    color: #7f8c8d;
    font-size: 0.85rem;
    font-style: italic;
    padding-top: 0.75rem;
    border-top: 1px solid #2a2a4a;
}

@media (max-width: 1400px) {
    .container {
        grid-template-columns: 220px 1fr 300px;
    }
}

@media (max-width: 1100px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .sidebar-section {
        flex: 1;
        min-width: 200px;
    }
    
    .mode-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .mode-btn {
        flex: 1;
        min-width: 80px;
        text-align: center;
    }
    
    .info-panel {
        flex-direction: row;
        flex-wrap: wrap;
        max-height: none;
    }
    
    .info-section {
        flex: 1;
        min-width: 260px;
    }
}
