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

/* Hide scrollbars for all elements with overflow auto */
* {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
}

*::-webkit-scrollbar {
    display: none; /* WebKit */
}
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1a1f3a 50%, #0d1b2a 100%);
    min-height: 100vh; padding: 20px; color: #e2e8f0;
}
.container {
    max-width: 900px; margin: 0 auto; background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px); border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 24px; box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    overflow: hidden;
}
.header {
    background: linear-gradient(135deg, rgba(59,130,246,.1) 0%, rgba(139,92,246,.1) 100%);
    border-bottom: 1px solid rgba(148,163,184,.1); padding: 48px 40px; text-align: center; position: relative; overflow: hidden;
}
.header::before {
    content: ''; position: absolute; top: -50%; right: -20%; width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(59,130,246,.15) 0%, transparent 70%); border-radius: 50%; pointer-events: none;
}
.header h1 {
    font-family: 'Sora', sans-serif; font-size: 3.5rem; font-weight: 700; margin-bottom: 12px;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; letter-spacing: -1px; position: relative; z-index: 1;
}
.header p { font-size: 1.05rem; color: #cbd5e1; font-weight: 400; position: relative; z-index: 1; }
.content { padding: 48px 40px; }

.upload-area {
    border: 2px dashed rgba(59,130,246,.3); border-radius: 16px; padding: 60px 40px; text-align: center;
    transition: all .3s ease; cursor: pointer; background: rgba(59,130,246,.05); position: relative; overflow: hidden;
}
.upload-area::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at center, rgba(139,92,246,.1) 0%, transparent 70%); pointer-events: none; }
.upload-area:hover { border-color: rgba(59,130,246,.6); background: rgba(59,130,246,.1); transform: translateY(-2px); }
.upload-area.dragover { border-color: rgba(59,130,246,.8); background: rgba(59,130,246,.15); transform: scale(1.01); }
.upload-icon { font-size: 4rem; margin-bottom: 24px; animation: float 3s ease-in-out infinite; position: relative; z-index: 1; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
.upload-text { font-size: 1.3rem; color: #e2e8f0; margin-bottom: 8px; font-weight: 600; position: relative; z-index: 1; }
.upload-subtext { color: #94a3b8; font-size: .95rem; position: relative; z-index: 1; }
#fileInput { display: none; }

.btn {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); color: white; border: none; padding: 12px 28px; border-radius: 10px;
    font-size: .95rem; font-weight: 600; cursor: pointer; transition: all .3s ease; text-decoration: none; display: inline-block; margin: 8px;
    box-shadow: 0 4px 15px rgba(59,130,246,.3);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(59,130,246,.4); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.secondary { background: rgba(148,163,184,.1); color: #cbd5e1; border: 1px solid rgba(148,163,184,.2); box-shadow: none; }
.btn.secondary:hover { background: rgba(148,163,184,.15); box-shadow: 0 4px 15px rgba(148,163,184,.1); }
.btn.accent { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); box-shadow: 0 4px 15px rgba(139,92,246,.3); }
.btn.accent:hover { box-shadow: 0 8px 25px rgba(139,92,246,.4); }

.loading { display: none; text-align: center; padding: 40px 20px; }
.spinner { border: 3px solid rgba(59,130,246,.2); border-top: 3px solid #3b82f6; border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; margin: 0 auto 20px; }
@keyframes spin { 0%{transform:rotate(0)} 100%{transform:rotate(360deg)} }

.results { display: none; margin-top: 40px; }
.results h3 { color: #e2e8f0; margin-bottom: 24px; font-size: 1.5rem; font-weight: 700; }

.json-output {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 24px;
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

/* JSON toolbar */
.json-toolbar {
    display: flex; gap: 6px; align-items: center; justify-content: flex-end;
    padding: 12px; border-bottom: 1px solid rgba(148,163,184,.1); background: rgba(15,23,42,.8);
    flex-wrap: wrap; position: sticky; top: 0; z-index: 10;
}
.json-toolbar .mini-btn {
    background: rgba(148,163,184,.12); border: 1px solid rgba(148,163,184,.25); color: #cbd5e1;
    padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer;
    white-space: nowrap; flex-shrink: 0;
}
.json-toolbar .mini-btn:hover { background: rgba(148,163,184,.2); }

/* Mobile responsiveness for JSON toolbar */
@media (max-width: 768px) {
    .json-toolbar {
        gap: 4px; padding: 8px; justify-content: center;
    }
    .json-toolbar .mini-btn {
        padding: 6px 8px; font-size: 11px;
    }
    .json-toolbar span {
        font-size: 10px !important; display: none;
    }
}

@media (max-width: 480px) {
    .json-toolbar {
        flex-direction: column; gap: 6px; align-items: stretch;
    }
    .json-toolbar .mini-btn {
        text-align: center; padding: 8px;
    }
}

.json-viewer { padding: 16px 24px; font-family: 'Monaco','Menlo','Ubuntu Mono',monospace; font-size: .85rem; line-height: 1.6; color: #cbd5e1; }
.json-item { margin: 2px 0; user-select: none; }
.json-row { cursor: default; }
.json-row:hover { background: rgba(59,130,246,.08); border-radius: 4px; }
.json-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; margin-right: 6px; color: #3b82f6; cursor: pointer; border-radius: 2px; font-weight: 700;
}
.json-toggle:hover { background: rgba(59,130,246,.18); }
.json-key { color: #60a5fa; font-weight: 600; }
.json-index { color: #93c5fd; font-weight: 600; }
.json-string { color: #86efac; }
.json-number { color: #fbbf24; }
.json-boolean { color: #a78bfa; }
.json-null { color: #94a3b8; font-style: italic; }
.json-bracket { color: #cbd5e1; font-weight: bold; }
.json-comma { color: #94a3b8; }
.json-collapsed { color: #94a3b8; font-style: italic; }
.json-array-length, .json-object-length { color: #fbbf24; font-size: 0.8em; margin-left: 8px; }

.csv-download { text-align: center; margin-top: 24px; }

.performance-highlights {
    margin-top: 32px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 12px;
    padding: 24px;
}

.performance-highlights h3 {
    color: #e2e8f0;
    margin-bottom: 20px;
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
}

.performance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.performance-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.performance-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.1);
}

.performance-metric {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.performance-metric:last-child {
    margin-bottom: 0;
}

.metric-label {
    font-weight: 600;
    color: #cbd5e1;
    min-width: 100px;
    font-size: 0.9rem;
}

.metric-value {
    font-weight: 700;
    font-size: 1.1rem;
    margin-left: 12px;
}

.metric-best {
    color: #10b981;
}

.metric-worst {
    color: #ef4444;
}

.metric-average {
    color: #f59e0b;
}

.performance-indicator {
    margin-left: 8px;
    font-size: 1.2rem;
}

.card-title {
    color: #3b82f6;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 16px;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.error {
    background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5; padding: 16px; border-radius: 10px; margin: 20px 0; display: none; font-weight: 500;
}
.success {
    background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3);
    color: #86efac; padding: 16px; border-radius: 10px; margin: 20px 0; display: none; font-weight: 500;
}

.file-info {
    background: rgba(59,130,246,.05); border: 1px solid rgba(59,130,246,.2);
    border-radius: 12px; padding: 20px; margin: 24px 0; display: none;
}
.file-info h4 { color: #3b82f6; margin-bottom: 12px; font-weight: 600; }
.file-info p { margin: 8px 0; color: #cbd5e1; font-size: .95rem; }
.clickable-filename { cursor: pointer; color: #3b82f6 !important; text-decoration: underline; font-weight: 600; transition: all .3s ease; }
.clickable-filename:hover { color: #60a5fa !important; }

.action-buttons { margin-top: 20px; text-align: center; }
.action-buttons .btn { margin: 8px 10px; }

.split-results { margin-top: 40px; }
.segments-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin: 24px 0; max-height: 600px; overflow-y: auto; border: 1px solid rgba(148,163,184,.1); border-radius: 12px; padding: 16px; background: rgba(15,23,42,.4); }
.segment-item { border: 1px solid rgba(148,163,184,.2); border-radius: 10px; padding: 12px; text-align: center; background: rgba(30,41,59,.6); transition: all .3s ease; cursor: pointer; }
.segment-item:hover { border-color: rgba(59,130,246,.5); background: rgba(59,130,246,.1); transform: translateY(-4px); box-shadow: 0 8px 20px rgba(59,130,246,.2); }
.segment-item img { max-width: 100%; max-height: 120px; border-radius: 6px; margin-bottom: 10px; }
.segment-item .segment-info { font-size: .85rem; color: #94a3b8; }
.split-actions { text-align: center; margin-top: 24px; }
.split-actions .btn { margin: 0 10px; }

/* Modal */
.modal { display: none; position: fixed; z-index: 1000; inset: 0; background-color: rgba(0,0,0,.85); backdrop-filter: blur(4px); animation: fadeIn .3s ease; }
.modal.show { display: flex; align-items: center; justify-content: center; }
.modal-content {
    position: relative; max-width: 90%; max-height: 90%; background: rgba(15,23,42,.95);
    border: 1px solid rgba(148,163,184,.1); border-radius: 16px; overflow: auto; box-shadow: 0 25px 50px rgba(0,0,0,.7);
    display: flex; align-items: center; justify-content: center;
}
.modal-image { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; object-fit: contain; margin: auto; }
.modal-controls { position: fixed; top: 50%; transform: translateY(-50%); background: rgba(59,130,246,.8); color: white; border: none; padding: 12px 16px; font-size: 20px; cursor: pointer; border-radius: 8px; transition: all .3s ease; z-index: 1001; }
.modal-controls:hover { background: rgba(59,130,246,1); transform: translateY(-50%) scale(1.1); }
.modal-prev { left: 20px; }
.modal-next { right: 20px; }
.modal-close { position: fixed; top: 20px; right: 20px; background: rgba(59,130,246,.8); color: white; border: none; padding: 8px 12px; font-size: 20px; cursor: pointer; border-radius: 8px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; z-index: 1001; }
.modal-close:hover { background: rgba(239,68,68,.8); }
.modal-info { position: fixed; bottom: 20px; left: 20px; background: rgba(0,0,0,.6); color: #cbd5e1; padding: 10px 14px; border-radius: 6px; font-size: 13px; z-index: 1001; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

/* Crop */
.crop-modal-content { position: relative; width: 95%; height: 95%; max-width: 1200px; max-height: 800px; background: rgba(15,23,42,.95); border: 1px solid rgba(148,163,184,.1); border-radius: 16px; overflow: hidden; box-shadow: 0 25px 50px rgba(0,0,0,.7); display: flex; flex-direction: column; margin: auto; }
.crop-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; background: rgba(30,41,59,.6); border-bottom: 1px solid rgba(148,163,184,.1); }
.crop-modal-header h3 { margin: 0; color: #e2e8f0; font-weight: 600; }
.crop-modal-body { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto; }
.crop-modal-footer { padding: 20px; background: rgba(30,41,59,.6); border-top: 1px solid rgba(148,163,184,.1); }
.crop-modal-body .crop-container { position: relative; width: 100%; height: 100%; max-height: 70vh; overflow: hidden; }
.crop-modal-body #cropImage { display: block; max-width: 100%; max-height: 100%; }
.zoom-controls {
    position: absolute; top: 16px; right: 64px; display: flex; align-items: center; gap: 8px;
    background: rgba(15,23,42,.9); padding: 8px 12px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,.3);
    z-index: 1000; border: 1px solid rgba(148,163,184,.1);
}
.zoom-btn { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); color: white; border: none; border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 13px; font-weight: 600; transition: all .2s; }
.zoom-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(59,130,246,.3); }
#zoomLevel { font-size: 12px; font-weight: 600; color: #cbd5e1; min-width: 40px; text-align: center; }
