*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

.hidden { display: none !important; }

body {
    min-height: 100vh;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    color: #e2e8f0;
    background: #0a0a1a;
    overflow-x: hidden;
}

.bg-animated { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.bg-gradient {
    position: absolute; inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(236, 72, 153, 0.08) 0%, transparent 50%);
}

.app-container {
    position: relative; z-index: 1;
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 24px;
}

.glass-card {
    background: rgba(15, 15, 35, 0.75);
    -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 80px rgba(139, 92, 246, 0.06);
}

.app-card { width: 100%; max-width: 700px; padding: 32px; }

.app-header { text-align: center; margin-bottom: 24px; }
.app-icon { font-size: 36px; color: #8b5cf6; margin-bottom: 12px; }
.app-title { font-size: 22px; font-weight: 700; color: #fff; margin-bottom: 6px; }
.app-subtitle { font-size: 13px; color: #94a3b8; }

/* ===== Toolbar ===== */
.toolbar {
    display: flex; gap: 6px; margin-bottom: 16px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    flex-wrap: wrap;
}

.tool-btn {
    padding: 8px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #94a3b8;
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; gap: 6px;
    transition: all 0.2s;
    font-family: inherit;
}

.tool-btn:hover { background: rgba(139, 92, 246, 0.1); color: #e2e8f0; }

.tool-btn.active {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.3);
    color: #a78bfa;
}

.toolbar-spacer { flex: 1; }

/* ===== Editor ===== */
.editor-section { margin-bottom: 16px; }

.input-label {
    display: block;
    font-size: 11px; font-weight: 600; color: #94a3b8;
    margin-bottom: 6px;
    text-transform: uppercase; letter-spacing: 0.5px;
}

.json-editor {
    width: 100%;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 12px;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    tab-size: 2;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.json-editor:focus {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Status Bar */
.status-bar {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    color: #64748b;
}

.status-icon { font-size: 8px; }
.status-bar.valid .status-icon { color: #34d399; }
.status-bar.invalid .status-icon { color: #ef4444; }

/* ===== Output ===== */
.json-output {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 12px;
    max-height: 400px;
    overflow: auto;
}

.json-output pre {
    margin: 0;
    padding: 14px 16px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.json-output code {
    font-family: 'JetBrains Mono', monospace;
    background: none !important;
}

/* ===== Tree View ===== */
.tree-output {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 12px;
    max-height: 400px;
    overflow: auto;
    padding: 14px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.7;
}

.tree-key { color: #a78bfa; }
.tree-string { color: #34d399; }
.tree-number { color: #60a5fa; }
.tree-boolean { color: #f59e0b; }
.tree-null { color: #ef4444; }

.tree-toggle {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    color: #64748b;
    display: inline-block;
    width: 16px;
    text-align: center;
}

.tree-toggle:hover { color: #a78bfa; }

.tree-children {
    margin-left: 20px;
    border-left: 1px solid rgba(139, 92, 246, 0.1);
    padding-left: 12px;
}

.tree-children.collapsed { display: none; }

/* ===== Overlay & Source Viewer ===== */
.overlay-panel { position: fixed; bottom: 24px; right: 24px; z-index: 1000; background: rgba(15, 15, 35, 0.85); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border: 1px solid rgba(139, 92, 246, 0.25); border-radius: 16px; padding: 20px; min-width: 260px; max-width: 320px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 60px rgba(139, 92, 246, 0.1); font-family: 'Inter', 'Segoe UI', sans-serif; color: #e2e8f0; transition: transform 0.3s ease, opacity 0.3s ease; }
.overlay-panel.collapsed { transform: translateY(calc(100% - 48px)); }
.overlay-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.overlay-title { font-size: 15px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 8px; }
.overlay-title .icon-3d { color: #8b5cf6; font-size: 18px; }
.overlay-toggle { background: rgba(139, 92, 246, 0.15); border: 1px solid rgba(139, 92, 246, 0.3); border-radius: 8px; color: #a78bfa; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; font-size: 12px; }
.overlay-toggle:hover { background: rgba(139, 92, 246, 0.3); }
.overlay-body { display: flex; flex-direction: column; gap: 10px; }
.overlay-desc { font-size: 12px; color: #94a3b8; line-height: 1.5; }
.overlay-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; transition: all 0.3s ease; border: none; font-family: inherit; }
.btn-back { background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); color: #94a3b8; }
.btn-back:hover { background: rgba(255, 255, 255, 0.1); color: #e2e8f0; transform: translateX(-2px); }
.btn-source { background: linear-gradient(135deg, #8b5cf6, #6366f1); color: #fff; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); }
.btn-source:hover { transform: translateY(-2px); box-shadow: 0 6px 25px rgba(139, 92, 246, 0.45); }
.open-source-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 600; color: #34d399; background: rgba(52, 211, 153, 0.1); border: 1px solid rgba(52, 211, 153, 0.3); }
.overlay-desc .accent-text { color: #a78bfa; }

.source-viewer { position: fixed; inset: 0; z-index: 3000; background: rgba(10, 10, 26, 0.98); display: flex; flex-direction: column; opacity: 0; visibility: hidden; transition: all 0.3s ease; }
.source-viewer.active { opacity: 1; visibility: visible; }
.source-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; background: rgba(15, 15, 35, 0.95); border-bottom: 1px solid rgba(139, 92, 246, 0.2); }
.source-header-left { display: flex; align-items: center; gap: 12px; }
.source-filename { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: #a78bfa; font-weight: 600; }
.source-badge { background: rgba(52, 211, 153, 0.15); border: 1px solid rgba(52, 211, 153, 0.3); border-radius: 6px; padding: 2px 8px; font-size: 11px; color: #34d399; font-weight: 600; }
.source-header-right { display: flex; align-items: center; gap: 8px; }
.btn-copy-source, .btn-close-source { background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px; color: #94a3b8; padding: 8px 14px; font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px; font-family: inherit; }
.btn-copy-source:hover, .btn-close-source:hover { background: rgba(255, 255, 255, 0.1); color: #e2e8f0; }
.source-body { flex: 1; overflow: auto; padding: 0; }
.source-body pre { margin: 0; padding: 24px; font-size: 13px; line-height: 1.6; }
.source-body code { font-family: 'JetBrains Mono', monospace; }

@media (max-width: 600px) {
    .app-card { padding: 20px; }
    .toolbar { gap: 4px; }
    .tool-btn { padding: 6px 10px; font-size: 11px; }
    .json-editor { font-size: 12px; }
    .overlay-panel { bottom: 12px; right: 12px; left: 12px; min-width: unset; max-width: unset; }
    .source-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    .source-body pre { padding: 16px; font-size: 11px; }
}
