:root {
    --bg-main: #0f1115;
    --bg-panel: rgba(22, 25, 31, 0.7);
    --bg-panel-hover: rgba(30, 34, 43, 0.8);
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --radius: 12px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 340px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 40px;
    color: var(--text-primary);
}

.upload-section h3, .download-section h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.upload-section p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.file-drop-area {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.02);
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 16px;
}

.file-drop-area:hover, .file-drop-area.dragover {
    background: rgba(255,255,255,0.05);
    border-color: var(--accent);
}

.file-msg {
    font-size: 0.875rem;
    color: var(--text-secondary);
    pointer-events: none;
    text-align: center;
}

.file-drop-area input {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    cursor: pointer;
    opacity: 0;
}

.btn-primary, .btn-secondary {
    display: block;
    width: 100%;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    outline: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.15);
}

.status-msg {
    margin-top: 12px;
    font-size: 0.875rem;
    text-align: center;
}
.status-msg.error { color: #ef4444; }
.status-msg.success { color: #10b981; }

.diag-panel {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.02);
    overflow: hidden;
}
.diag-panel summary {
    padding: 10px 14px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.diag-panel summary::-webkit-details-marker { display: none; }
.diag-panel summary::before { content: '▸ '; }
.diag-panel[open] summary::before { content: '▾ '; }
.diag-log {
    padding: 4px 14px 12px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.6;
    max-height: 220px;
    overflow-y: auto;
    border-top: 1px solid var(--border);
}
.diag-log .l-info { color: var(--text-secondary); }
.diag-log .l-ok { color: #10b981; }
.diag-log .l-warn { color: #f59e0b; }
.diag-log .l-err { color: #ef4444; }

.download-section {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

/* Viewer Area */
.viewer-area {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at 50% 50%, #1e222d 0%, #0f1115 100%);
}

#viewerContainer {
    width: 100%;
    height: 100%;
    position: relative;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
}
.empty-state h2 {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Loader */
.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background: rgba(15, 17, 21, 0.9);
    padding: 24px 32px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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